|
|
|
@ -1,5 +1,6 @@ |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
using Shentun.Peis.Enums; |
|
|
|
using Shentun.Peis.Models; |
|
|
|
using Shentun.Peis.SysParmValues; |
|
|
|
@ -131,6 +132,7 @@ namespace Shentun.Peis.OccupationalDiseaseReports |
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var patientRegisterList = query.ToList(); |
|
|
|
|
|
|
|
var msg = new GetCompanyOccupationalDiseaseSummaryReportDto |
|
|
|
@ -166,7 +168,7 @@ namespace Shentun.Peis.OccupationalDiseaseReports |
|
|
|
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.OnDutyCount = patientRegisterList.Where(m => m.patientOccupationalDisease.OcCheckTypeId == onDutyId).GroupBy(g => g.patientRegister).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()); |
|
|
|
@ -174,7 +176,7 @@ namespace Shentun.Peis.OccupationalDiseaseReports |
|
|
|
//有结论的数据
|
|
|
|
var conclusionList = patientRegisterList.Where(m => (m.patientOccupationalDisease.OcCheckTypeId == onDutyId |
|
|
|
|| m.patientOccupationalDisease.OcCheckTypeId == whenLeavingWorkId) |
|
|
|
&& (m.patientPoisonHaveEmpty.OccupationalAbnormalId != null || m.patientPoisonHaveEmpty.OccupationalAbnormalId != noAbnormalId)); |
|
|
|
&& 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()); |
|
|
|
@ -204,29 +206,58 @@ namespace Shentun.Peis.OccupationalDiseaseReports |
|
|
|
|
|
|
|
//相关检查情况
|
|
|
|
|
|
|
|
|
|
|
|
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 asbitemAbnormalQuery = (from patientRegister in await _patientRegisterRepository.GetQueryableAsync() |
|
|
|
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 |
|
|
|
{ |
|
|
|
patientRegister, |
|
|
|
asbitemName = asbitemHaveEmpty.DisplayName |
|
|
|
}); |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(customerOrgPara.StartDate) && !string.IsNullOrEmpty(customerOrgPara.EndDate)) |
|
|
|
{ |
|
|
|
if (customerOrgPara.DateType == '1') |
|
|
|
{ |
|
|
|
asbitemAbnormalQuery = asbitemAbnormalQuery.Where(m => m.patientRegister.CreationTime >= Convert.ToDateTime(customerOrgPara.StartDate) && |
|
|
|
m.patientRegister.CreationTime < Convert.ToDateTime(customerOrgPara.EndDate).AddDays(1)); |
|
|
|
} |
|
|
|
else if (customerOrgPara.DateType == '2') |
|
|
|
{ |
|
|
|
asbitemAbnormalQuery = asbitemAbnormalQuery.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') |
|
|
|
{ |
|
|
|
asbitemAbnormalQuery = asbitemAbnormalQuery.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()) |
|
|
|
{ |
|
|
|
asbitemAbnormalQuery = asbitemAbnormalQuery.Where(m => m.patientRegister.CustomerOrgGroupId != null && customerOrgPara.CustomerOrgGroupId.Contains(m.patientRegister.CustomerOrgGroupId.Value)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var asbitemAbnormalList = asbitemAbnormalQuery.ToList(); |
|
|
|
|
|
|
|
//异常总人数
|
|
|
|
var abnormalSumCount = asbitemAbnormalList.Select(s => s.patientRegisterId).Distinct().Count(); |
|
|
|
var abnormalSumCount = asbitemAbnormalList.Select(s => s.patientRegister.Id).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, |
|
|
|
AbnormalCount = s.Select(ss => ss.patientRegister.Id).Distinct().Count(), |
|
|
|
AbnormalRatio = Convert.ToDecimal(s.Select(ss => ss.patientRegister.Id).Distinct().Count() * 100) / abnormalSumCount, |
|
|
|
DisplayOrder = index + 1 |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
|