4 changed files with 499 additions and 5 deletions
-
196src/Shentun.Peis.Application.Contracts/OccupationalDiseaseReports/GetCompanyOccupationalDiseaseSummaryReportDto.cs
-
12src/Shentun.Peis.Application.Contracts/OccupationalDiseaseReports/GetCompanyOccupationalDiseaseSummaryReportInputDto.cs
-
242src/Shentun.Peis.Application/OccupationalDiseaseReports/OccupationalDiseaseReportAppService.cs
-
54src/Shentun.Peis.Application/QueueRegisters/QueueRegisterAppService.cs
@ -0,0 +1,196 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using System.Xml.Schema; |
|||
|
|||
namespace Shentun.Peis.OccupationalDiseaseReports |
|||
{ |
|||
public class GetCompanyOccupationalDiseaseSummaryReportDto |
|||
{ |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 单位名称
|
|||
/// </summary>
|
|||
public string CustomerOrgName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 证书编号
|
|||
/// </summary>
|
|||
public string CertificateNo { get; set; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 体检类别
|
|||
/// </summary>
|
|||
public string MedicalTypeName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 体检日期 年月日
|
|||
/// </summary>
|
|||
public string MedicalStartDate { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 备案号
|
|||
/// </summary>
|
|||
public string RecordNumber { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 体检中心名称
|
|||
/// </summary>
|
|||
public string MedicalCenterName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 体检地点
|
|||
/// </summary>
|
|||
public string MedicalCenterAddress { get; set; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 报告日期 年月日
|
|||
/// </summary>
|
|||
public string ReportDate { get; set; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 体检总人数
|
|||
/// </summary>
|
|||
public int MedicalSumCount { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 离岗时人数
|
|||
/// </summary>
|
|||
public int WhenLeavingWorkCount { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 在岗期间人数
|
|||
/// </summary>
|
|||
public int OnDutyCount { get; set; } |
|||
|
|||
/// <summary>
|
|||
///危害因素 A、B格式
|
|||
/// </summary>
|
|||
public string PoisonNames { get; set; } |
|||
|
|||
|
|||
/// <summary>
|
|||
///部分结论 A、B格式
|
|||
/// </summary>
|
|||
public string Conclusions { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 工种 A、B格式
|
|||
/// </summary>
|
|||
public string JobTypes { get; set; } |
|||
|
|||
///// <summary>
|
|||
///// 疑似职业病人数
|
|||
///// </summary>
|
|||
//public int SuspectedOccupationalDiseaseCount { get; set; }
|
|||
|
|||
///// <summary>
|
|||
///// 疑似职业病比例
|
|||
///// </summary>
|
|||
//public decimal SuspectedOccupationalDiseaseRatio { get; set; }
|
|||
|
|||
|
|||
///// <summary>
|
|||
///// 职业禁忌症人数
|
|||
///// </summary>
|
|||
//public int OccupationalContraindicationsCount { get; set; }
|
|||
|
|||
///// <summary>
|
|||
///// 职业禁忌症比例
|
|||
///// </summary>
|
|||
//public decimal OccupationalContraindicationsRatio { get; set; }
|
|||
|
|||
|
|||
///// <summary>
|
|||
///// 复查人数
|
|||
///// </summary>
|
|||
//public int ReviewCount { get; set; }
|
|||
|
|||
///// <summary>
|
|||
///// 复查比例
|
|||
///// </summary>
|
|||
//public decimal ReviewRatio { get; set; }
|
|||
|
|||
|
|||
///// <summary>
|
|||
///// 其他疾病人数
|
|||
///// </summary>
|
|||
//public int OtherDiseasesCount { get; set; }
|
|||
|
|||
///// <summary>
|
|||
///// 其他疾病比例
|
|||
///// </summary>
|
|||
//public decimal OtherDiseasesRatio { get; set; }
|
|||
|
|||
///// <summary>
|
|||
///// 未见异常人数
|
|||
///// </summary>
|
|||
//public int NoAbnormalConditionsCount { get; set; }
|
|||
|
|||
///// <summary>
|
|||
///// 未见异常比例
|
|||
///// </summary>
|
|||
//public decimal NoAbnormalConditionsRatio { get; set; }
|
|||
|
|||
/// <summary>
|
|||
/// 结论
|
|||
/// </summary>
|
|||
public List<GetCompanyOccupationalDiseaseSummaryReportConclusionDetailDto> ConclusionDetails { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 项目异常
|
|||
/// </summary>
|
|||
public List<GetCompanyOccupationalDiseaseSummaryReportAsbitemAbnormalDto> AsbitemAbnormals { get; set; } |
|||
} |
|||
|
|||
public class GetCompanyOccupationalDiseaseSummaryReportAsbitemAbnormalDto |
|||
{ |
|||
/// <summary>
|
|||
/// 异常项目名称
|
|||
/// </summary>
|
|||
public string AbnormalAsbitemName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 异常人数
|
|||
/// </summary>
|
|||
public int AbnormalCount { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 异常比例
|
|||
/// </summary>
|
|||
public decimal AbnormalRatio { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 排序值
|
|||
/// </summary>
|
|||
public int DisplayOrder { get; set; } |
|||
} |
|||
|
|||
|
|||
public class GetCompanyOccupationalDiseaseSummaryReportConclusionDetailDto |
|||
{ |
|||
/// <summary>
|
|||
/// 异常项目名称
|
|||
/// </summary>
|
|||
public string ConclusionName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 异常人数
|
|||
/// </summary>
|
|||
public int ConclusionCount { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 异常比例
|
|||
/// </summary>
|
|||
public decimal ConclusionRatio { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 排序值
|
|||
/// </summary>
|
|||
public int DisplayOrder { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using Shentun.Peis.PeisReports; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
|
|||
namespace Shentun.Peis.OccupationalDiseaseReports |
|||
{ |
|||
public class GetCompanyOccupationalDiseaseSummaryReportInputDto |
|||
{ |
|||
public List<GetPeisReportDetailRequest_CustomerOrg> CustomerOrgs { get; set; } = new List<GetPeisReportDetailRequest_CustomerOrg>() { }; |
|||
} |
|||
} |
|||
@ -0,0 +1,242 @@ |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Shentun.Peis.Enums; |
|||
using Shentun.Peis.Models; |
|||
using Shentun.Peis.SysParmValues; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Services; |
|||
using Volo.Abp.Domain.Repositories; |
|||
using Volo.Abp.Identity; |
|||
|
|||
namespace Shentun.Peis.OccupationalDiseaseReports |
|||
{ |
|||
[ApiExplorerSettings(GroupName = "Work")] |
|||
[Authorize] |
|||
public class OccupationalDiseaseReportAppService : ApplicationService |
|||
{ |
|||
|
|||
private readonly IRepository<PatientRegister, Guid> _patientRegisterRepository; |
|||
private readonly IRepository<RegisterCheck, Guid> _registerCheckRepository; |
|||
private readonly IRepository<RegisterCheckAsbitem, Guid> _registerCheckAsbitemRepository; |
|||
private readonly IRepository<Asbitem, Guid> _asbitemRepository; |
|||
private readonly IRepository<PatientOccupationalDisease, Guid> _patientOccupationalDiseaseRepository; |
|||
private readonly SysParmValueManager _sysParmValueManager; |
|||
private readonly CacheService _cacheService; |
|||
private readonly IRepository<OrganizationUnit, Guid> _organizationUnitRepository; |
|||
private readonly IRepository<OcCheckType, Guid> _ocCheckTypeRepository; |
|||
private readonly IRepository<PatientPoison> _patientPoisonRepository; |
|||
private readonly IRepository<OccupationalAbnormal, Guid> _occupationalAbnormalRepository; |
|||
private readonly IRepository<Poison, Guid> _poisonRepository; |
|||
private readonly IRepository<RegisterCheckSummary, Guid> _registerCheckSummaryRepository; |
|||
|
|||
public OccupationalDiseaseReportAppService( |
|||
IRepository<PatientRegister, Guid> patientRegisterRepository, |
|||
IRepository<RegisterCheck, Guid> registerCheckRepository, |
|||
IRepository<RegisterCheckAsbitem, Guid> registerCheckAsbitemRepository, |
|||
IRepository<Asbitem, Guid> asbitemRepository, |
|||
IRepository<PatientOccupationalDisease, Guid> patientOccupationalDiseaseRepository, |
|||
SysParmValueManager sysParmValueManager, |
|||
CacheService cacheService, |
|||
IRepository<OrganizationUnit, Guid> organizationUnitRepository, |
|||
IRepository<OcCheckType, Guid> ocCheckTypeRepository, |
|||
IRepository<PatientPoison> patientPoisonRepository, |
|||
IRepository<OccupationalAbnormal, Guid> occupationalAbnormalRepository, |
|||
IRepository<Poison, Guid> poisonRepository, |
|||
IRepository<RegisterCheckSummary, Guid> registerCheckSummaryRepository) |
|||
{ |
|||
_patientRegisterRepository = patientRegisterRepository; |
|||
_registerCheckRepository = registerCheckRepository; |
|||
_registerCheckAsbitemRepository = registerCheckAsbitemRepository; |
|||
_asbitemRepository = asbitemRepository; |
|||
_patientOccupationalDiseaseRepository = patientOccupationalDiseaseRepository; |
|||
_sysParmValueManager = sysParmValueManager; |
|||
_cacheService = cacheService; |
|||
_organizationUnitRepository = organizationUnitRepository; |
|||
_ocCheckTypeRepository = ocCheckTypeRepository; |
|||
_patientPoisonRepository = patientPoisonRepository; |
|||
_occupationalAbnormalRepository = occupationalAbnormalRepository; |
|||
_poisonRepository = poisonRepository; |
|||
_registerCheckSummaryRepository = registerCheckSummaryRepository; |
|||
} |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 获取单位职业病总结报告
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
[HttpPost("api/app/OccupationalDiseaseReport/GetCompanyOccupationalDiseaseSummaryReport")] |
|||
public async Task<GetCompanyOccupationalDiseaseSummaryReportDto> GetCompanyOccupationalDiseaseSummaryReportAsync(GetCompanyOccupationalDiseaseSummaryReportInputDto input) |
|||
{ |
|||
|
|||
if (!input.CustomerOrgs.Any()) |
|||
throw new UserFriendlyException("单位信息不能为空"); |
|||
|
|||
var customerOrgPara = input.CustomerOrgs.First(); |
|||
if (customerOrgPara.CustomerOrgId == null || customerOrgPara.CustomerOrgId == Guid.Empty) |
|||
throw new UserFriendlyException("单位不能为空"); |
|||
if (customerOrgPara.CustomerOrgRegisterId == null || customerOrgPara.CustomerOrgRegisterId == Guid.Empty) |
|||
throw new UserFriendlyException("单位体检次数不能为空"); |
|||
|
|||
#region 人员信息
|
|||
var query = from patientRegister in await _patientRegisterRepository.GetQueryableAsync() |
|||
join patientOccupationalDisease in await _patientOccupationalDiseaseRepository.GetQueryableAsync() on patientRegister.Id equals patientOccupationalDisease.PatientRegisterId |
|||
join patientPoison in await _patientPoisonRepository.GetQueryableAsync() on patientRegister.Id equals patientPoison.PatientRegisterId into patientPoisonTemp |
|||
from patientPoisonHaveEmpty in patientPoisonTemp.DefaultIfEmpty() |
|||
join poison in await _poisonRepository.GetQueryableAsync() on patientPoisonHaveEmpty.PoisonId equals poison.Id into poisonTemp |
|||
from posionHaveEmpty in poisonTemp.DefaultIfEmpty() |
|||
join occupationalAbnormal in await _occupationalAbnormalRepository.GetQueryableAsync() on patientPoisonHaveEmpty.OccupationalAbnormalId equals occupationalAbnormal.Id into occupationalAbnormalTemp |
|||
from occupationalAbnormalHaveEmpty in occupationalAbnormalTemp.DefaultIfEmpty() |
|||
where patientRegister.CustomerOrgRegisterId == customerOrgPara.CustomerOrgRegisterId |
|||
&& patientRegister.CompleteFlag == PatientRegisterCompleteFlag.SumCheck |
|||
select new |
|||
{ |
|||
patientRegister, |
|||
patientOccupationalDisease, |
|||
posionHaveEmpty, |
|||
patientPoisonHaveEmpty, |
|||
occupationalAbnormalHaveEmpty |
|||
}; |
|||
|
|||
|
|||
if (!string.IsNullOrEmpty(customerOrgPara.StartDate) && !string.IsNullOrEmpty(customerOrgPara.EndDate)) |
|||
{ |
|||
if (customerOrgPara.DateType == '1') |
|||
{ |
|||
query = query.Where(m => m.patientRegister.CreationTime >= Convert.ToDateTime(customerOrgPara.StartDate) && |
|||
m.patientRegister.CreationTime < Convert.ToDateTime(customerOrgPara.EndDate).AddDays(1)); |
|||
} |
|||
else if (customerOrgPara.DateType == '2') |
|||
{ |
|||
query = query.Where(m => m.patientRegister.MedicalStartDate != null && m.patientRegister.MedicalStartDate.Value >= Convert.ToDateTime(customerOrgPara.StartDate) && |
|||
m.patientRegister.MedicalStartDate.Value < Convert.ToDateTime(customerOrgPara.EndDate).AddDays(1)); |
|||
} |
|||
else if (customerOrgPara.DateType == '3') |
|||
{ |
|||
query = query.Where(m => m.patientRegister.SummaryDate != null && m.patientRegister.SummaryDate.Value >= Convert.ToDateTime(customerOrgPara.StartDate) && |
|||
m.patientRegister.SummaryDate.Value < Convert.ToDateTime(customerOrgPara.EndDate).AddDays(1)); |
|||
} |
|||
} |
|||
|
|||
|
|||
if (customerOrgPara.CustomerOrgGroupId.Any()) |
|||
{ |
|||
query = query.Where(m => m.patientRegister.CustomerOrgGroupId != null && customerOrgPara.CustomerOrgGroupId.Contains(m.patientRegister.CustomerOrgGroupId.Value)); |
|||
} |
|||
|
|||
#endregion
|
|||
|
|||
|
|||
var patientRegisterList = query.ToList(); |
|||
|
|||
var msg = new GetCompanyOccupationalDiseaseSummaryReportDto |
|||
{ |
|||
AsbitemAbnormals = new List<GetCompanyOccupationalDiseaseSummaryReportAsbitemAbnormalDto>(), |
|||
ConclusionDetails = new List<GetCompanyOccupationalDiseaseSummaryReportConclusionDetailDto>(), |
|||
}; |
|||
|
|||
|
|||
if (patientRegisterList.Any()) |
|||
{ |
|||
|
|||
//人员id
|
|||
var patientRegisters = query.Select(m => m.patientRegister).Distinct().ToList(); |
|||
|
|||
var patientRegisterfisrt = query.First(); |
|||
|
|||
//在岗ID
|
|||
Guid onDutyId = (await _ocCheckTypeRepository.FirstOrDefaultAsync(f => f.DisplayName.Contains("在岗"))).Id; |
|||
//离岗时ID
|
|||
Guid whenLeavingWorkId = (await _ocCheckTypeRepository.FirstOrDefaultAsync(f => f.DisplayName.Contains("离岗时"))).Id; |
|||
|
|||
//未见异常ID
|
|||
Guid noAbnormalId = (await _occupationalAbnormalRepository.FirstOrDefaultAsync(f => f.DisplayName.Contains("未见异常"))).Id; |
|||
|
|||
|
|||
msg.CertificateNo = await _sysParmValueManager.GetSysParmValueAsync(Guid.Empty, "medical_center_qualification_certificate_number"); |
|||
msg.MedicalTypeName = await _cacheService.GetMedicalTypeNameAsync(patientRegisterfisrt.patientRegister.MedicalTypeId); |
|||
msg.CustomerOrgName = await _cacheService.GetTopCustomerOrgNameAsync(patientRegisterfisrt.patientRegister.CustomerOrgId); |
|||
msg.MedicalCenterAddress = await _sysParmValueManager.GetSysParmValueAsync(Guid.Empty, "medical_center_address"); |
|||
msg.MedicalCenterName = (await _organizationUnitRepository.GetAsync(patientRegisterfisrt.patientRegister.MedicalCenterId)).DisplayName; |
|||
msg.MedicalStartDate = Convert.ToDateTime(customerOrgPara.StartDate).ToString("yyyy年MM月dd日"); |
|||
msg.MedicalSumCount = patientRegisters.Count; |
|||
msg.RecordNumber = await _sysParmValueManager.GetSysParmValueAsync(Guid.Empty, "medical_center_record_number"); |
|||
msg.ReportDate = DateTime.Now.ToString("yyyy年MM月dd日"); |
|||
msg.OnDutyCount = patientRegisterList.Where(m => m.patientOccupationalDisease.OcCheckTypeId == onDutyId).Count(); |
|||
msg.WhenLeavingWorkCount = patientRegisterList.Where(m => m.patientOccupationalDisease.OcCheckTypeId == whenLeavingWorkId).Count(); |
|||
msg.PoisonNames = string.Join('、', patientRegisterList.Where(m => m.patientOccupationalDisease.OcCheckTypeId == onDutyId |
|||
|| m.patientOccupationalDisease.OcCheckTypeId == whenLeavingWorkId).Select(s => s.posionHaveEmpty.DisplayName).Distinct()); |
|||
|
|||
//有结论的数据
|
|||
var conclusionList = patientRegisterList.Where(m => (m.patientOccupationalDisease.OcCheckTypeId == onDutyId |
|||
|| m.patientOccupationalDisease.OcCheckTypeId == whenLeavingWorkId) |
|||
&& (m.patientPoisonHaveEmpty.OccupationalAbnormalId != null || m.patientPoisonHaveEmpty.OccupationalAbnormalId != noAbnormalId)); |
|||
|
|||
msg.Conclusions = string.Join('、', conclusionList.Select(s => s.occupationalAbnormalHaveEmpty.DisplayName).Distinct()); |
|||
msg.JobTypes = string.Join('、', conclusionList.Select(s => s.patientOccupationalDisease.JobType).Distinct()); |
|||
|
|||
#region 检查结果
|
|||
|
|||
//目标疾病检出情况
|
|||
List<GetCompanyOccupationalDiseaseSummaryReportConclusionDetailDto> conclusionDetails = new List<GetCompanyOccupationalDiseaseSummaryReportConclusionDetailDto>(); |
|||
|
|||
var occupationalAbnormalList = (await _occupationalAbnormalRepository.GetListAsync()).OrderBy(o => o.DisplayOrder); |
|||
foreach (var item in occupationalAbnormalList) |
|||
{ |
|||
var conclusionCount = patientRegisterList.Where(m => m.patientPoisonHaveEmpty.OccupationalAbnormalId == item.Id).Select(s => s.patientRegister.Id).Distinct().Count(); |
|||
var conclusionRatio = Convert.ToDecimal(conclusionCount * 100) / patientRegisters.Count; |
|||
var conclusionDetail = new GetCompanyOccupationalDiseaseSummaryReportConclusionDetailDto |
|||
{ |
|||
ConclusionName = item.DisplayName, |
|||
DisplayOrder = item.DisplayOrder, |
|||
ConclusionCount = conclusionCount, |
|||
ConclusionRatio = conclusionRatio |
|||
}; |
|||
|
|||
conclusionDetails.Add(conclusionDetail); |
|||
} |
|||
|
|||
msg.ConclusionDetails = conclusionDetails; |
|||
|
|||
//相关检查情况
|
|||
|
|||
|
|||
var asbitemAbnormalList = (from patientRegister in patientRegisters |
|||
join registerCheck in await _registerCheckRepository.GetQueryableAsync() on patientRegister.Id equals registerCheck.PatientRegisterId |
|||
join registerCheckAsbitem in await _registerCheckAsbitemRepository.GetQueryableAsync() on registerCheck.Id equals registerCheckAsbitem.RegisterCheckId |
|||
join asbitem in await _asbitemRepository.GetQueryableAsync() on registerCheckAsbitem.AsbitemId equals asbitem.Id into asbitemTemp |
|||
from asbitemHaveEmpty in asbitemTemp.DefaultIfEmpty() |
|||
join registerCheckSummary in await _registerCheckSummaryRepository.GetQueryableAsync() on registerCheck.Id equals registerCheckSummary.RegisterCheckId |
|||
where !registerCheckSummary.Summary.Contains("未见异常") |
|||
select new |
|||
{ |
|||
asbitemName = asbitemHaveEmpty.DisplayName, |
|||
patientRegisterId = patientRegister.Id |
|||
}).ToList(); |
|||
|
|||
//异常总人数
|
|||
var abnormalSumCount = asbitemAbnormalList.Select(s => s.patientRegisterId).Distinct().Count(); |
|||
|
|||
|
|||
var asbitemAbnormals = asbitemAbnormalList.GroupBy(g => g.asbitemName).Select((s, index) => new GetCompanyOccupationalDiseaseSummaryReportAsbitemAbnormalDto |
|||
{ |
|||
AbnormalAsbitemName = s.Key, |
|||
AbnormalCount = s.Count(), |
|||
AbnormalRatio = Convert.ToDecimal(s.Count() * 100) / abnormalSumCount, |
|||
DisplayOrder = index + 1 |
|||
}).ToList(); |
|||
|
|||
|
|||
msg.AsbitemAbnormals = asbitemAbnormals; |
|||
#endregion
|
|||
|
|||
} |
|||
|
|||
return msg; |
|||
} |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue