diff --git a/src/Shentun.Peis.Application.Contracts/ThirdPartyPublicInterfaces/PublicPatientRegisterNoInputDto.cs b/src/Shentun.Peis.Application.Contracts/ThirdPartyPublicInterfaces/PublicPatientRegisterNoInputDto.cs index d1a5836..6c75df5 100644 --- a/src/Shentun.Peis.Application.Contracts/ThirdPartyPublicInterfaces/PublicPatientRegisterNoInputDto.cs +++ b/src/Shentun.Peis.Application.Contracts/ThirdPartyPublicInterfaces/PublicPatientRegisterNoInputDto.cs @@ -7,7 +7,7 @@ namespace Shentun.Peis.ThirdPartyPublicInterfaces public class PublicPatientRegisterNoInputDto { /// - /// 体检人员条码号 + /// 体检编号 /// public List PatientRegisterNos { get; set; } } diff --git a/src/Shentun.Peis.Application/ThirdPartyPublicInterfaces/ThirdPartyPublicInterfaceAppService.cs b/src/Shentun.Peis.Application/ThirdPartyPublicInterfaces/ThirdPartyPublicInterfaceAppService.cs index 2daa6f1..06ea58c 100644 --- a/src/Shentun.Peis.Application/ThirdPartyPublicInterfaces/ThirdPartyPublicInterfaceAppService.cs +++ b/src/Shentun.Peis.Application/ThirdPartyPublicInterfaces/ThirdPartyPublicInterfaceAppService.cs @@ -74,126 +74,131 @@ namespace Shentun.Peis.ThirdPartyPublicInterfaces /// [Authorize(PeisPermissions.Third.Default)] [HttpPost("api/Third/ThirdPartyPublicInterface/GetBasicInformationOfMedicalExaminationPersonnel")] - public async Task GetBasicInformationOfMedicalExaminationPersonnelAsync(PublicPatientRegisterNoInputDto input) + public async Task> GetBasicInformationOfMedicalExaminationPersonnelAsync(PublicPatientRegisterNoInputDto input) { if (input == null) { throw new UserFriendlyException($"请求参数错误"); } - if(!input.PatientRegisterNos.Any()) + if (!input.PatientRegisterNos.Any()) throw new UserFriendlyException($"体检编号不能为空"); - var result = new BasicInformationOfMedicalExaminationPersonnelDto(); + var listDto = new List(); - var patientRegisterEnt = (await _patientRegisterRepository.GetQueryableAsync()).Include(x => x.Patient) - .FirstOrDefault(m => input.PatientRegisterNos.Contains(m.PatientRegisterNo) - && m.CompleteFlag == PatientRegisterCompleteFlag.SumCheck); - if (patientRegisterEnt != null) + var patientRegisterList = (await _patientRegisterRepository.GetQueryableAsync()).Include(x => x.Patient) + .Where(m => input.PatientRegisterNos.Contains(m.PatientRegisterNo) + && m.CompleteFlag == PatientRegisterCompleteFlag.SumCheck).ToList(); + if (patientRegisterList.Any()) { - //基础信息 - result = new BasicInformationOfMedicalExaminationPersonnelDto + foreach (var patientRegisterEnt in patientRegisterList) { - BirthDate = patientRegisterEnt.BirthDate != null ? patientRegisterEnt.BirthDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "", - PatientRegisterNo = patientRegisterEnt.PatientRegisterNo, - CompleteFlag = patientRegisterEnt.CompleteFlag, - IsMedicalStart = patientRegisterEnt.IsMedicalStart, - MedicalStartDate = patientRegisterEnt.MedicalStartDate != null ? patientRegisterEnt.MedicalStartDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "", - PatientName = patientRegisterEnt.PatientName, - SexName = _cacheService.GetSexNameAsync(patientRegisterEnt.SexId).Result, - SummaryDoctorName = _cacheService.GetSurnameAsync(patientRegisterEnt.SummaryDoctorId).Result, - SummaryDate = patientRegisterEnt.SummaryDate != null ? patientRegisterEnt.SummaryDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "", - CustomerOrgName = _cacheService.GetTopCustomerOrgNameAsync(patientRegisterEnt.CustomerOrgId).Result, - IdNo = patientRegisterEnt.Patient.IdNo, - MobileTelephone = patientRegisterEnt.Patient.MobileTelephone - }; - - - var registerCheckItemList = from patientRegister in await _patientRegisterRepository.GetQueryableAsync() - join registerCheck in await _registerCheckRepository.GetQueryableAsync() on patientRegister.Id equals registerCheck.PatientRegisterId - join registerCheckItem in await _registerCheckItemRepository.GetQueryableAsync() on registerCheck.Id equals registerCheckItem.RegisterCheckId - join item in await _itemRepository.GetQueryableAsync() on registerCheckItem.ItemId equals item.Id - join itemType in await _itemTypeRepository.GetQueryableAsync() on item.ItemTypeId equals itemType.Id into itemTypeTemp - from itemTypeHaveEmpty in itemTypeTemp.DefaultIfEmpty() - where patientRegister.Id == patientRegisterEnt.Id - select new - { - registerCheckItem, - ItemName = item.DisplayName, - DepartmentName = itemTypeHaveEmpty != null ? itemTypeHaveEmpty.DisplayName : "" - }; - - - - //明细项目 - result.Items = registerCheckItemList.Select(s => new BasicInformationOfMedicalExaminationPersonnelItemDto - { - DepartmentName = s.DepartmentName, - ItemName = s.ItemName, - ReferenceRangeValue = s.registerCheckItem.ReferenceRangeValue, - Result = s.registerCheckItem.Result, - Unit = s.registerCheckItem.Unit - }).ToList(); - - //总检综述 - - var sumSummaryList = from patientRegister in await _patientRegisterRepository.GetQueryableAsync() - join sumSummaryHeader in await _sumSummaryHeaderRepository.GetQueryableAsync() on patientRegister.Id equals sumSummaryHeader.PatientRegisterId - join sumSummaryContent in await _sumSummaryContentRepository.GetQueryableAsync() on sumSummaryHeader.Id equals sumSummaryContent.SumSummaryHeaderId - where patientRegister.Id == patientRegisterEnt.Id - orderby sumSummaryHeader.DisplayOrder, sumSummaryContent.DisplayOrder - select new - { - SummaryTitle = sumSummaryHeader.SummaryTitle, - SummaryContent = sumSummaryContent.SummaryContent - }; - - result.SumSummarys = sumSummaryList.Select(s => new BasicInformationOfMedicalExaminationPersonnelSumSummaryDto - { - SumSummaryTitle = s.SummaryTitle, - SumSummaryContent = s.SummaryContent - }).ToList(); - //总检建议 - - var sumSuggestionsList = from patientRegister in await _patientRegisterRepository.GetQueryableAsync() - join sumSuggestionHeader in await _sumSuggestionHeaderRepository.GetQueryableAsync() on patientRegister.Id equals sumSuggestionHeader.PatientRegisterId - join sumSuggestionContent in await _sumSuggestionContentRepository.GetQueryableAsync() on sumSuggestionHeader.Id equals sumSuggestionContent.SumSuggestionHeaderId + //基础信息 + var result = new BasicInformationOfMedicalExaminationPersonnelDto + { + BirthDate = patientRegisterEnt.BirthDate != null ? patientRegisterEnt.BirthDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "", + PatientRegisterNo = patientRegisterEnt.PatientRegisterNo, + CompleteFlag = patientRegisterEnt.CompleteFlag, + IsMedicalStart = patientRegisterEnt.IsMedicalStart, + MedicalStartDate = patientRegisterEnt.MedicalStartDate != null ? patientRegisterEnt.MedicalStartDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "", + PatientName = patientRegisterEnt.PatientName, + SexName = _cacheService.GetSexNameAsync(patientRegisterEnt.SexId).Result, + SummaryDoctorName = _cacheService.GetSurnameAsync(patientRegisterEnt.SummaryDoctorId).Result, + SummaryDate = patientRegisterEnt.SummaryDate != null ? patientRegisterEnt.SummaryDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "", + CustomerOrgName = _cacheService.GetTopCustomerOrgNameAsync(patientRegisterEnt.CustomerOrgId).Result, + IdNo = patientRegisterEnt.Patient.IdNo, + MobileTelephone = patientRegisterEnt.Patient.MobileTelephone + }; + + + var registerCheckItemList = from patientRegister in await _patientRegisterRepository.GetQueryableAsync() + join registerCheck in await _registerCheckRepository.GetQueryableAsync() on patientRegister.Id equals registerCheck.PatientRegisterId + join registerCheckItem in await _registerCheckItemRepository.GetQueryableAsync() on registerCheck.Id equals registerCheckItem.RegisterCheckId + join item in await _itemRepository.GetQueryableAsync() on registerCheckItem.ItemId equals item.Id + join itemType in await _itemTypeRepository.GetQueryableAsync() on item.ItemTypeId equals itemType.Id into itemTypeTemp + from itemTypeHaveEmpty in itemTypeTemp.DefaultIfEmpty() + where patientRegister.Id == patientRegisterEnt.Id + select new + { + registerCheckItem, + ItemName = item.DisplayName, + DepartmentName = itemTypeHaveEmpty != null ? itemTypeHaveEmpty.DisplayName : "" + }; + + + + //明细项目 + result.Items = registerCheckItemList.Select(s => new BasicInformationOfMedicalExaminationPersonnelItemDto + { + DepartmentName = s.DepartmentName, + ItemName = s.ItemName, + ReferenceRangeValue = s.registerCheckItem.ReferenceRangeValue, + Result = s.registerCheckItem.Result, + Unit = s.registerCheckItem.Unit + }).ToList(); + + //总检综述 + + var sumSummaryList = from patientRegister in await _patientRegisterRepository.GetQueryableAsync() + join sumSummaryHeader in await _sumSummaryHeaderRepository.GetQueryableAsync() on patientRegister.Id equals sumSummaryHeader.PatientRegisterId + join sumSummaryContent in await _sumSummaryContentRepository.GetQueryableAsync() on sumSummaryHeader.Id equals sumSummaryContent.SumSummaryHeaderId where patientRegister.Id == patientRegisterEnt.Id - orderby sumSuggestionHeader.DisplayOrder, sumSuggestionContent.DisplayOrder + orderby sumSummaryHeader.DisplayOrder, sumSummaryContent.DisplayOrder select new { - SuggestionTitle = sumSuggestionHeader.SuggestionTitle, - SuggestionFlag = sumSuggestionHeader.SuggestionFlag, - SuggestionContent = sumSuggestionContent.SuggestionContent + SummaryTitle = sumSummaryHeader.SummaryTitle, + SummaryContent = sumSummaryContent.SummaryContent }; - result.SumSuggestions = sumSuggestionsList.Select(s => new BasicInformationOfMedicalExaminationPersonnelSumSuggestionDto - { - DiagnosisName = s.SuggestionTitle, - CommonReasons = sumSuggestionsList.Where(m => m.SuggestionFlag == SuggestionTypeFlag.CommonReasons) - .Select(ss => new BasicInformationOfMedicalExaminationPersonnelSumSuggestionDetailDto - { - SumSuggestionContent = ss.SuggestionContent - }).ToList(), - HealthGuidances = sumSuggestionsList.Where(m => m.SuggestionFlag == SuggestionTypeFlag.HealthGuidance) - .Select(ss => new BasicInformationOfMedicalExaminationPersonnelSumSuggestionDetailDto - { - SumSuggestionContent = ss.SuggestionContent - }).ToList(), - MedicalInterpretations = sumSuggestionsList.Where(m => m.SuggestionFlag == SuggestionTypeFlag.MedicalInterpretation) - .Select(ss => new BasicInformationOfMedicalExaminationPersonnelSumSuggestionDetailDto - { - SumSuggestionContent = ss.SuggestionContent - }).ToList() - }).ToList(); + result.SumSummarys = sumSummaryList.Select(s => new BasicInformationOfMedicalExaminationPersonnelSumSummaryDto + { + SumSummaryTitle = s.SummaryTitle, + SumSummaryContent = s.SummaryContent + }).ToList(); + + //总检建议 + + var sumSuggestionsList = from patientRegister in await _patientRegisterRepository.GetQueryableAsync() + join sumSuggestionHeader in await _sumSuggestionHeaderRepository.GetQueryableAsync() on patientRegister.Id equals sumSuggestionHeader.PatientRegisterId + join sumSuggestionContent in await _sumSuggestionContentRepository.GetQueryableAsync() on sumSuggestionHeader.Id equals sumSuggestionContent.SumSuggestionHeaderId + where patientRegister.Id == patientRegisterEnt.Id + orderby sumSuggestionHeader.DisplayOrder, sumSuggestionContent.DisplayOrder + select new + { + SuggestionTitle = sumSuggestionHeader.SuggestionTitle, + SuggestionFlag = sumSuggestionHeader.SuggestionFlag, + SuggestionContent = sumSuggestionContent.SuggestionContent + }; + + result.SumSuggestions = sumSuggestionsList.Select(s => new BasicInformationOfMedicalExaminationPersonnelSumSuggestionDto + { + DiagnosisName = s.SuggestionTitle, + CommonReasons = sumSuggestionsList.Where(m => m.SuggestionFlag == SuggestionTypeFlag.CommonReasons) + .Select(ss => new BasicInformationOfMedicalExaminationPersonnelSumSuggestionDetailDto + { + SumSuggestionContent = ss.SuggestionContent + }).ToList(), + HealthGuidances = sumSuggestionsList.Where(m => m.SuggestionFlag == SuggestionTypeFlag.HealthGuidance) + .Select(ss => new BasicInformationOfMedicalExaminationPersonnelSumSuggestionDetailDto + { + SumSuggestionContent = ss.SuggestionContent + }).ToList(), + MedicalInterpretations = sumSuggestionsList.Where(m => m.SuggestionFlag == SuggestionTypeFlag.MedicalInterpretation) + .Select(ss => new BasicInformationOfMedicalExaminationPersonnelSumSuggestionDetailDto + { + SumSuggestionContent = ss.SuggestionContent + }).ToList() + }).ToList(); + listDto.Add(result); + } } else { - throw new UserFriendlyException($"条码号不正确"); + throw new UserFriendlyException($"体检编号不正确"); } - return result; + return listDto; }