|
|
@ -454,7 +454,7 @@ namespace Shentun.Peis.OccupationalDiseaseReports |
|
|
PatientName = s.FirstOrDefault().patientRegister.PatientName, |
|
|
PatientName = s.FirstOrDefault().patientRegister.PatientName, |
|
|
PatientRegisterNo = s.FirstOrDefault().patientRegister.PatientRegisterNo, |
|
|
PatientRegisterNo = s.FirstOrDefault().patientRegister.PatientRegisterNo, |
|
|
PoisonNames = string.Join(",", s.Select(ss => ss.posionHaveEmpty.DisplayName).Distinct()), |
|
|
PoisonNames = string.Join(",", s.Select(ss => ss.posionHaveEmpty.DisplayName).Distinct()), |
|
|
PoisonWorkTime = s.Key.PoisonWorkTime |
|
|
|
|
|
|
|
|
PoisonWorkTime = s.Key.PoisonWorkTime, |
|
|
}).ToList(); |
|
|
}).ToList(); |
|
|
msg.MedicalResultDetails = medicalResultDetails; |
|
|
msg.MedicalResultDetails = medicalResultDetails; |
|
|
#endregion
|
|
|
#endregion
|
|
|
@ -658,6 +658,126 @@ namespace Shentun.Peis.OccupationalDiseaseReports |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return msg; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取单位职业病结果Excel数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPost("api/app/OccupationalDiseaseReport/GetCompanyOccupationalDiseaseDataExcel")] |
|
|
|
|
|
public async Task<List<GetCompanyOccupationalDiseaseDataExcelDto>> GetCompanyOccupationalDiseaseDataExcelAsync(GetCompanyOccupationalDiseaseDetailReportInputDto 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() |
|
|
|
|
|
join ocCheckType in await _ocCheckTypeRepository.GetQueryableAsync() on patientOccupationalDisease.OcCheckTypeId equals ocCheckType.Id into ocCheckTypeTemp |
|
|
|
|
|
from ocCheckTypeHaveEmpty in ocCheckTypeTemp.DefaultIfEmpty() |
|
|
|
|
|
join sumSummaryHeader in (await _sumSummaryHeaderRepository.GetQueryableAsync()).Include(x => x.SumSummaryContents) on patientRegister.Id equals sumSummaryHeader.PatientRegisterId into sumSummaryHeaderTemp |
|
|
|
|
|
from sumSummaryHeaderHaveEmpty in sumSummaryHeaderTemp.DefaultIfEmpty() |
|
|
|
|
|
where patientRegister.CustomerOrgRegisterId == customerOrgPara.CustomerOrgRegisterId |
|
|
|
|
|
&& patientRegister.CompleteFlag != PatientRegisterCompleteFlag.PreRegistration |
|
|
|
|
|
select new |
|
|
|
|
|
{ |
|
|
|
|
|
patientRegister, |
|
|
|
|
|
patientOccupationalDisease, |
|
|
|
|
|
posionHaveEmpty, |
|
|
|
|
|
patientPoisonHaveEmpty, |
|
|
|
|
|
occupationalAbnormalHaveEmpty, |
|
|
|
|
|
ocCheckTypeHaveEmpty, |
|
|
|
|
|
sumSummaryHeaderHaveEmpty |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 List<GetCompanyOccupationalDiseaseDataExcelDto>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (patientRegisterList.Any()) |
|
|
|
|
|
{ |
|
|
|
|
|
////人员
|
|
|
|
|
|
//var patientRegisters = patientRegisterList.Select(m => m.patientRegister).Distinct().ToList();
|
|
|
|
|
|
|
|
|
|
|
|
//var patientRegisterfisrt = patientRegisterList.First();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 体检结果一览表
|
|
|
|
|
|
var medicalResultDetails = patientRegisterList.GroupBy(g => g.patientOccupationalDisease) |
|
|
|
|
|
.Select((s, index) => new GetCompanyOccupationalDiseaseDataExcelDto |
|
|
|
|
|
{ |
|
|
|
|
|
AnomalyIndex = $"{SetSumSummarys(s.Select(ss => ss.sumSummaryHeaderHaveEmpty).Distinct().ToList())}", |
|
|
|
|
|
MedicalConclusion = s.Key.OccupationalAbnormal, |
|
|
|
|
|
OcCheckTypeName = s.FirstOrDefault().ocCheckTypeHaveEmpty != null ? s.FirstOrDefault().ocCheckTypeHaveEmpty.DisplayName : "", |
|
|
|
|
|
HandlingSuggestions = s.Key.OccupationalAbSuggestion, |
|
|
|
|
|
JobType = s.Key.JobType, |
|
|
|
|
|
PatientName = s.FirstOrDefault().patientRegister.PatientName, |
|
|
|
|
|
PatientRegisterNo = s.FirstOrDefault().patientRegister.PatientRegisterNo, |
|
|
|
|
|
PoisonNames = string.Join(",", s.Select(ss => ss.posionHaveEmpty.DisplayName).Distinct()), |
|
|
|
|
|
PoisonWorkTime = s.Key.PoisonWorkTime, |
|
|
|
|
|
MedicalStartDate = DataHelper.ConversionDateShortToString(s.FirstOrDefault().patientRegister.MedicalStartDate), |
|
|
|
|
|
SummaryDoctorName = _cacheService.GetSurnameAsync(s.FirstOrDefault().patientRegister.SummaryDoctorId).GetAwaiter().GetResult() |
|
|
|
|
|
}).OrderBy(o => o.MedicalConclusion).ToList(); |
|
|
|
|
|
msg = medicalResultDetails; |
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return msg; |
|
|
return msg; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|