|
|
|
@ -18,25 +18,34 @@ namespace Shentun.Peis.InternalReports |
|
|
|
/// 内部报表
|
|
|
|
/// </summary>
|
|
|
|
[ApiExplorerSettings(GroupName = "Work")] |
|
|
|
//[Authorize]
|
|
|
|
[Authorize] |
|
|
|
public class InternalReportAppService : ApplicationService |
|
|
|
{ |
|
|
|
private readonly IRepository<IdentityUser, Guid> _userRepository; |
|
|
|
private readonly IRepository<PatientRegister, Guid> _patientRegisterRepository; |
|
|
|
private readonly IRepository<RegisterAsbitem, Guid> _registerAsbitemRepository; |
|
|
|
private readonly IRepository<RegisterCheck, Guid> _registerCheckRepository; |
|
|
|
private readonly IRepository<Asbitem, Guid> _asbitemRepository; |
|
|
|
private readonly IRepository<ItemType, Guid> _itemTypeRepository; |
|
|
|
private readonly IRepository<CustomerOrg, Guid> _customerOrgRepository; |
|
|
|
|
|
|
|
public InternalReportAppService( |
|
|
|
IRepository<IdentityUser, Guid> userRepository, |
|
|
|
IRepository<PatientRegister, Guid> patientRegisterRepository, |
|
|
|
IRepository<RegisterAsbitem, Guid> registerAsbitemRepository, |
|
|
|
IRepository<Asbitem, Guid> asbitemRepository |
|
|
|
IRepository<RegisterCheck, Guid> registerCheckRepository, |
|
|
|
IRepository<Asbitem, Guid> asbitemRepository, |
|
|
|
IRepository<ItemType, Guid> itemTypeRepository, |
|
|
|
IRepository<CustomerOrg, Guid> customerOrgRepository |
|
|
|
) |
|
|
|
{ |
|
|
|
this._userRepository = userRepository; |
|
|
|
this._patientRegisterRepository = patientRegisterRepository; |
|
|
|
this._registerAsbitemRepository = registerAsbitemRepository; |
|
|
|
this._registerCheckRepository = registerCheckRepository; |
|
|
|
this._asbitemRepository = asbitemRepository; |
|
|
|
this._itemTypeRepository = itemTypeRepository; |
|
|
|
this._customerOrgRepository = customerOrgRepository; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -83,22 +92,25 @@ namespace Shentun.Peis.InternalReports |
|
|
|
public async Task<List<GetDoctorPersonnelWorkLoadReportDto>> GetDoctorPersonnelWorkLoadReportAsync(GetDoctorPersonnelWorkLoadReportRequestDto input) |
|
|
|
{ |
|
|
|
var query = (from a in await _registerAsbitemRepository.GetQueryableAsync() |
|
|
|
join b in await _userRepository.GetQueryableAsync() on a.CreatorId equals b.Id into bb |
|
|
|
from ab in bb.DefaultIfEmpty() |
|
|
|
join c in await _asbitemRepository.GetQueryableAsync() on a.AsbitemId equals c.Id into cc |
|
|
|
from ac in cc.DefaultIfEmpty() |
|
|
|
join d in await _registerCheckRepository.GetQueryableAsync() on a.RegisterCheckId equals d.Id into dd |
|
|
|
from ad in dd.DefaultIfEmpty() |
|
|
|
join b in await _userRepository.GetQueryableAsync() on ad.CheckDoctorId equals b.Id.ToString() into bb |
|
|
|
from ab in bb.DefaultIfEmpty() |
|
|
|
where (a.CreationTime >= Convert.ToDateTime(input.StartDate) && |
|
|
|
a.CreationTime < Convert.ToDateTime(input.EndDate).AddDays(1)) |
|
|
|
select new |
|
|
|
{ |
|
|
|
a, |
|
|
|
CheckDoctorId = ad.CheckDoctorId, |
|
|
|
DoctorName = ab != null ? ab.UserName : "", |
|
|
|
AsbitemName = ac != null ? ac.DisplayName : "" |
|
|
|
}); |
|
|
|
|
|
|
|
if (input.UserIds.Count > 0) |
|
|
|
{ |
|
|
|
query = query.Where(m => input.UserIds.Contains(m.a.CreatorId.Value)); |
|
|
|
query = query.Where(m => input.UserIds.Contains(m.CheckDoctorId)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -112,8 +124,8 @@ namespace Shentun.Peis.InternalReports |
|
|
|
DoctorName = s.FirstOrDefault().DoctorName, |
|
|
|
AvgChargePrice = Math.Round(s.Average(v => v.a.ChargePrice.Value), 2), |
|
|
|
AvgStandardPrice = Math.Round(s.Average(v => v.a.StandardPrice.Value), 2), |
|
|
|
SumChargePrice = Math.Round(s.Sum(v => v.a.ChargePrice.Value), 2), |
|
|
|
SumStandardPrice = Math.Round(s.Sum(v => v.a.StandardPrice.Value), 2) |
|
|
|
SumChargePrice = Math.Round(s.Sum(v => v.a.ChargePrice.Value * v.a.Amount.Value), 2), |
|
|
|
SumStandardPrice = Math.Round(s.Sum(v => v.a.StandardPrice.Value * v.a.Amount.Value), 2) |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
@ -122,16 +134,248 @@ namespace Shentun.Peis.InternalReports |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
///// 总检医生工作量统计
|
|
|
|
///// </summary>
|
|
|
|
///// <param name="input"></param>
|
|
|
|
///// <returns></returns>
|
|
|
|
//[HttpPost("api/app/internalreport/getsumcheckdoctorworkloadreport")]
|
|
|
|
//public async Task<List<GetSumCheckDoctorWorkLoadReportDto>> GetSumCheckDoctorWorkLoadReportAsync(GetSumCheckDoctorWorkLoadReportRequestDto input)
|
|
|
|
//{
|
|
|
|
|
|
|
|
//}
|
|
|
|
/// <summary>
|
|
|
|
/// 总检医生工作量统计
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("api/app/internalreport/getsumcheckdoctorworkloadreport")] |
|
|
|
public async Task<List<GetSumCheckDoctorWorkLoadReportDto>> GetSumCheckDoctorWorkLoadReportAsync(GetSumCheckDoctorWorkLoadReportRequestDto input) |
|
|
|
{ |
|
|
|
var query = (from a in await _patientRegisterRepository.GetQueryableAsync() |
|
|
|
join b in await _userRepository.GetQueryableAsync() on a.SummaryDoctor equals b.Id.ToString() into bb |
|
|
|
from ab in bb.DefaultIfEmpty() |
|
|
|
where (!string.IsNullOrEmpty(a.SummaryDoctor) && a.SummaryDate != null && a.SummaryDate.Value.ToDateTime(TimeOnly.MinValue) >= Convert.ToDateTime(input.StartDate) && |
|
|
|
a.SummaryDate.Value.ToDateTime(TimeOnly.MinValue) < Convert.ToDateTime(input.EndDate).AddDays(1)) |
|
|
|
select new |
|
|
|
{ |
|
|
|
a, |
|
|
|
SumCheckDoctorName = ab != null ? ab.UserName : "" |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
var sumCount = query.Count(); //总数
|
|
|
|
|
|
|
|
if (input.UserIds.Count > 0) |
|
|
|
{ |
|
|
|
query = query.Where(m => input.UserIds.ToString().Contains(m.a.SummaryDoctor)); |
|
|
|
} |
|
|
|
|
|
|
|
var entlistdto = query.GroupBy(g => new { g.a.SummaryDoctor, g.SumCheckDoctorName }) |
|
|
|
.Select(s => new GetSumCheckDoctorWorkLoadReportDto |
|
|
|
{ |
|
|
|
SumCheckDoctorName = s.Key.SumCheckDoctorName, |
|
|
|
SumCheckCount = s.Count(), |
|
|
|
Percentage = Math.Round(Convert.ToDecimal(s.Count() * 100) / sumCount, 2).ToString() |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
return entlistdto; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 审核医生工作量统计
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("api/app/internalreport/getauditdoctorworkloadreport")] |
|
|
|
public async Task<List<GetAuditDoctorWorkLoadReportDto>> GetAuditDoctorWorkLoadReportAsync(GetAuditDoctorWorkLoadReportRequestDto input) |
|
|
|
{ |
|
|
|
var query = (from a in await _patientRegisterRepository.GetQueryableAsync() |
|
|
|
join b in await _userRepository.GetQueryableAsync() on a.SummaryDoctor equals b.Id.ToString() into bb |
|
|
|
from ab in bb.DefaultIfEmpty() |
|
|
|
where (!string.IsNullOrEmpty(a.AuditDoctor) && a.AuditDate != null && a.AuditDate.Value.ToDateTime(TimeOnly.MinValue) >= Convert.ToDateTime(input.StartDate) && |
|
|
|
a.AuditDate.Value.ToDateTime(TimeOnly.MinValue) < Convert.ToDateTime(input.EndDate).AddDays(1)) |
|
|
|
select new |
|
|
|
{ |
|
|
|
a, |
|
|
|
AuditDoctorName = ab != null ? ab.UserName : "" |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
var sumCount = query.Count(); //总数
|
|
|
|
|
|
|
|
if (input.UserIds.Count > 0) |
|
|
|
{ |
|
|
|
query = query.Where(m => input.UserIds.ToString().Contains(m.a.AuditDoctor)); |
|
|
|
} |
|
|
|
|
|
|
|
var entlistdto = query.GroupBy(g => new { g.a.AuditDoctor, g.AuditDoctorName }) |
|
|
|
.Select(s => new GetAuditDoctorWorkLoadReportDto |
|
|
|
{ |
|
|
|
AuditDoctorName = s.Key.AuditDoctorName, |
|
|
|
AuditCount = s.Count(), |
|
|
|
Percentage = Math.Round(Convert.ToDecimal(s.Count() * 100) / sumCount, 2).ToString() |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
return entlistdto; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 科室工作量统计 标准格式 只统计RegisterCheck表标记检查了的数据
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("api/app/internalreport/getitemtypeworkloadinstandard")] |
|
|
|
public async Task<List<GetItemTypeWorkLoadInStandardDto>> GetItemTypeWorkLoadInStandardAsync(GetItemTypeWorkLoadInStandardRequestDto input) |
|
|
|
{ |
|
|
|
|
|
|
|
var qeruy = from a in await _registerAsbitemRepository.GetQueryableAsync() |
|
|
|
join b in await _asbitemRepository.GetQueryableAsync() on a.AsbitemId equals b.Id |
|
|
|
join c in await _itemTypeRepository.GetQueryableAsync() on b.ItemTypeId equals c.Id |
|
|
|
join d in await _registerCheckRepository.GetQueryableAsync() on a.RegisterCheckId equals d.Id into dd |
|
|
|
from ad in dd.DefaultIfEmpty() |
|
|
|
where (!string.IsNullOrEmpty(ad.CheckDoctorId) && ad.CheckDate != null) |
|
|
|
select new |
|
|
|
{ |
|
|
|
a.AsbitemId, |
|
|
|
a.StandardPrice, |
|
|
|
a.ChargePrice, |
|
|
|
a.Amount, |
|
|
|
AsbitemName = b.DisplayName, |
|
|
|
ItemTypeId = b.ItemTypeId, |
|
|
|
ItemTypeName = c.DisplayName, |
|
|
|
ad.CheckDate |
|
|
|
}; |
|
|
|
|
|
|
|
if (input.ItemTypeId.Any()) |
|
|
|
{ |
|
|
|
qeruy = qeruy.Where(m => input.ItemTypeId.Contains(m.ItemTypeId)); |
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(input.StartDate) && !string.IsNullOrEmpty(input.EndDate)) |
|
|
|
{ |
|
|
|
qeruy = qeruy.Where(m => m.CheckDate.Value.ToDateTime(TimeOnly.MinValue) >= Convert.ToDateTime(input.StartDate) && |
|
|
|
m.CheckDate.Value.ToDateTime(TimeOnly.MinValue) < Convert.ToDateTime(input.EndDate).AddDays(1)); |
|
|
|
} |
|
|
|
|
|
|
|
var entlist = qeruy.GroupBy(g => new { g.ItemTypeId, g.AsbitemId }) |
|
|
|
.Select(s => new GetItemTypeWorkLoadInStandardDto |
|
|
|
{ |
|
|
|
AsbitemName = s.First().AsbitemName, |
|
|
|
AsbitemCount = s.Count(), |
|
|
|
ItemTypeName = s.First().ItemTypeName, |
|
|
|
AvgChargePrice = Math.Round(s.Average(v => v.ChargePrice.Value), 2), |
|
|
|
AvgStandardPrice = Math.Round(s.Average(v => v.StandardPrice.Value), 2), |
|
|
|
SumChargePrice = Math.Round(s.Sum(v => v.ChargePrice.Value * v.Amount.Value), 2), |
|
|
|
SumStandardPrice = Math.Round(s.Sum(v => v.StandardPrice.Value * v.Amount.Value), 2) |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
return entlist; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 科室工作量统计 单位和医生
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("api/app/internalreport/getitemtypeworkloadincustomeranddoctor")] |
|
|
|
public async Task<List<GetItemTypeWorkLoadInCustomerAndDoctorDto>> GetItemTypeWorkLoadInCustomerAndDoctorAsync(GetItemTypeWorkLoadInCustomerAndDoctorRequestDto input) |
|
|
|
{ |
|
|
|
var qeruy = from a in await _registerAsbitemRepository.GetQueryableAsync() |
|
|
|
join b in await _asbitemRepository.GetQueryableAsync() on a.AsbitemId equals b.Id |
|
|
|
join c in await _itemTypeRepository.GetQueryableAsync() on b.ItemTypeId equals c.Id |
|
|
|
join d in await _registerCheckRepository.GetQueryableAsync() on a.RegisterCheckId equals d.Id into dd |
|
|
|
from ad in dd.DefaultIfEmpty() |
|
|
|
join e in await _patientRegisterRepository.GetQueryableAsync() on a.PatientRegisterId equals e.Id |
|
|
|
join f in await _customerOrgRepository.GetQueryableAsync() on e.CustomerOrgId equals f.Id into ff |
|
|
|
from af in ff.DefaultIfEmpty() |
|
|
|
join g in await _userRepository.GetQueryableAsync() on ad.CheckDoctorId equals g.Id.ToString() into gg |
|
|
|
from ag in gg.DefaultIfEmpty() |
|
|
|
where (!string.IsNullOrEmpty(ad.CheckDoctorId) && ad.CheckDate != null) |
|
|
|
select new |
|
|
|
{ |
|
|
|
a.AsbitemId, |
|
|
|
AsbitemName = b.DisplayName, |
|
|
|
ItemTypeId = b.ItemTypeId, |
|
|
|
ItemTypeName = c.DisplayName, |
|
|
|
CustomerName = af.DisplayName, |
|
|
|
CustomerOrgId = e.CustomerOrgId, |
|
|
|
ad.CheckDoctorId, |
|
|
|
ad.CheckDate, |
|
|
|
DoctorName = ag != null ? ag.UserName : "" |
|
|
|
}; |
|
|
|
|
|
|
|
if (input.ItemTypeId.Any()) |
|
|
|
{ |
|
|
|
qeruy = qeruy.Where(m => input.ItemTypeId.Contains(m.ItemTypeId)); |
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(input.StartDate) && !string.IsNullOrEmpty(input.EndDate)) |
|
|
|
{ |
|
|
|
qeruy = qeruy.Where(m => m.CheckDate.Value.ToDateTime(TimeOnly.MinValue) >= Convert.ToDateTime(input.StartDate) && |
|
|
|
m.CheckDate.Value.ToDateTime(TimeOnly.MinValue) < Convert.ToDateTime(input.EndDate).AddDays(1)); |
|
|
|
} |
|
|
|
|
|
|
|
var entlist = qeruy.GroupBy(g => new { g.CustomerOrgId, g.ItemTypeId, g.AsbitemId, g.CheckDoctorId }) |
|
|
|
.Select(s => new GetItemTypeWorkLoadInCustomerAndDoctorDto |
|
|
|
{ |
|
|
|
AsbitemName = s.First().AsbitemName, |
|
|
|
DoctorCheckCount = s.Count(), |
|
|
|
ItemTypeName = s.First().ItemTypeName, |
|
|
|
CustomerName = s.First().CustomerName, |
|
|
|
DoctorName = s.First().DoctorName |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
return entlist; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 科室工作量统计 单位和组合项目
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("api/app/internalreport/getitemtypeworkloadincustomerandasbitem")] |
|
|
|
public async Task<List<GetItemTypeWorkLoadInCustomerAndAsbitemDto>> GetItemTypeWorkLoadInCustomerAndAsbitemAsync(GetItemTypeWorkLoadInCustomerAndAsbitemRequestDto input) |
|
|
|
{ |
|
|
|
var qeruy = from a in await _registerAsbitemRepository.GetQueryableAsync() |
|
|
|
join b in await _asbitemRepository.GetQueryableAsync() on a.AsbitemId equals b.Id |
|
|
|
join c in await _itemTypeRepository.GetQueryableAsync() on b.ItemTypeId equals c.Id |
|
|
|
join d in await _registerCheckRepository.GetQueryableAsync() on a.RegisterCheckId equals d.Id into dd |
|
|
|
from ad in dd.DefaultIfEmpty() |
|
|
|
join e in await _patientRegisterRepository.GetQueryableAsync() on a.PatientRegisterId equals e.Id |
|
|
|
join f in await _customerOrgRepository.GetQueryableAsync() on e.CustomerOrgId equals f.Id into ff |
|
|
|
from af in ff.DefaultIfEmpty() |
|
|
|
where (!string.IsNullOrEmpty(ad.CheckDoctorId) && ad.CheckDate != null) |
|
|
|
select new |
|
|
|
{ |
|
|
|
a.AsbitemId, |
|
|
|
AsbitemName = b.DisplayName, |
|
|
|
ItemTypeId = b.ItemTypeId, |
|
|
|
ItemTypeName = c.DisplayName, |
|
|
|
CustomerName = af.DisplayName, |
|
|
|
CustomerOrgId = e.CustomerOrgId, |
|
|
|
ad.CheckDate |
|
|
|
}; |
|
|
|
|
|
|
|
if (input.ItemTypeId.Any()) |
|
|
|
{ |
|
|
|
qeruy = qeruy.Where(m => input.ItemTypeId.Contains(m.ItemTypeId)); |
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(input.StartDate) && !string.IsNullOrEmpty(input.EndDate)) |
|
|
|
{ |
|
|
|
qeruy = qeruy.Where(m => m.CheckDate.Value.ToDateTime(TimeOnly.MinValue) >= Convert.ToDateTime(input.StartDate) && |
|
|
|
m.CheckDate.Value.ToDateTime(TimeOnly.MinValue) < Convert.ToDateTime(input.EndDate).AddDays(1)); |
|
|
|
} |
|
|
|
|
|
|
|
var entlist = qeruy.GroupBy(g => new { g.CustomerOrgId, g.ItemTypeId, g.AsbitemId }) |
|
|
|
.Select(s => new GetItemTypeWorkLoadInCustomerAndAsbitemDto |
|
|
|
{ |
|
|
|
AsbitemName = s.First().AsbitemName, |
|
|
|
DoctorCheckCount = s.Count(), |
|
|
|
ItemTypeName = s.First().ItemTypeName, |
|
|
|
CustomerName = s.First().CustomerName |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
return entlist; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |