diff --git a/src/Shentun.Peis.Application/PrintReports/PrintReportAppService.cs b/src/Shentun.Peis.Application/PrintReports/PrintReportAppService.cs index 0e61eed..9e2dd19 100644 --- a/src/Shentun.Peis.Application/PrintReports/PrintReportAppService.cs +++ b/src/Shentun.Peis.Application/PrintReports/PrintReportAppService.cs @@ -1,8 +1,10 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; using NPOI.POIFS.Properties; using NUglify.Helpers; +using Shentun.Peis.AsbitemGuides; using Shentun.Peis.Enums; using Shentun.Peis.LisRequests; using Shentun.Peis.Models; @@ -34,6 +36,7 @@ namespace Shentun.Peis.PrintReports public class PrintReportAppService : ApplicationService { private readonly IRepository _customerOrgRepository; + private readonly IRepository _customerOrgGroupRepository; private readonly IRepository _patientRepository; private readonly IRepository _patientRegisterRepository; private readonly IRepository _registerCheckAsbitemRepository; @@ -42,6 +45,7 @@ namespace Shentun.Peis.PrintReports private readonly IRepository _registerCheckPictureRepository; private readonly IRepository _asbitemRepository; private readonly IRepository _itemRepository; + private readonly IRepository _medicalPackageRepository; private readonly IRepository _medicalReportTypeRepository; private readonly IRepository _itemTypeRepository; private readonly IRepository _lisRequestRepository; @@ -54,7 +58,9 @@ namespace Shentun.Peis.PrintReports private readonly IRepository _identityUserRepository; private readonly IRepository _sumSuggestionHeaderRepository; private readonly IRepository _registerCheckRepository; - private readonly IOrganizationUnitRepository _organizationUnitRepository; + private readonly IRepository _personnelTypeRepository; + //private readonly IOrganizationUnitRepository _organizationUnitRepository; + private readonly IRepository _organizationUnitRepository; private readonly IPatientRegisterGuideReportRepository _patientRegisterGuideReportRepository; private readonly ILisRequestReportRepository _lisRequestReportRepository; private readonly ICheckRequestNoReportRepository _checkRequestNoReportRepository; @@ -63,9 +69,12 @@ namespace Shentun.Peis.PrintReports private readonly CacheService _cacheService; private readonly LisRequestManager _lisRequestManager; private readonly IUnitOfWorkManager _unitOfWorkManager; + private static AsbitemGuideManager _asbitemGuideManager; + private readonly IConfiguration _configuration; public PrintReportAppService( IRepository patientRepository, IRepository customerOrgRepository, + IRepository customerOrgGroupRepository, IRepository patientRegisterRepository, IRepository registerCheckAsbitemRepository, IRepository registerCheckItemRepository, @@ -73,6 +82,7 @@ namespace Shentun.Peis.PrintReports IRepository registerCheckPictureRepository, IRepository asbitemRepository, IRepository itemRepository, + IRepository medicalPackageRepository, IRepository medicalReportTypeRepository, IRepository itemTypeRepository, IRepository lisRequestRepository, @@ -80,20 +90,25 @@ namespace Shentun.Peis.PrintReports IRepository sampleContainerRepository, IRepository sampleTypeRepository, IRepository sexRegisterRepository, + IRepository personnelTypeRepository, IRepository resultStatusRepository, IRepository sumSummaryHeaderRepository, IRepository identityUserRepository, IRepository sumSuggestionHeaderRepository, IRepository registerCheckRepository, - IOrganizationUnitRepository organizationUnitRepository, + //IOrganizationUnitRepository organizationUnitRepository, + IRepository organizationUnitRepository, IPatientRegisterGuideReportRepository patientRegisterGuideReportRepository, ILisRequestReportRepository lisRequestReportRepository, ICheckRequestNoReportRepository checkRequestNoReportRepository, IChargeReportRepository chargeReportRepository, + SysParmValueManager sysParmValueManager, CacheService cacheService, LisRequestManager lisRequestManager, - IUnitOfWorkManager unitOfWorkManager + IUnitOfWorkManager unitOfWorkManager, + AsbitemGuideManager asbitemGuideManager, + IConfiguration configuration ) { this._customerOrgRepository = customerOrgRepository; @@ -126,6 +141,12 @@ namespace Shentun.Peis.PrintReports _lisRequestManager = lisRequestManager; _unitOfWorkManager = unitOfWorkManager; _patientRepository = patientRepository; + _asbitemGuideManager = asbitemGuideManager; + _customerOrgGroupRepository = customerOrgGroupRepository; + _medicalPackageRepository = medicalPackageRepository; + _personnelTypeRepository = personnelTypeRepository; + _configuration = configuration; + _organizationUnitRepository = organizationUnitRepository; } @@ -137,7 +158,72 @@ namespace Shentun.Peis.PrintReports [HttpPost("api/app/PrintReport/getpatientregisterguidereport")] public async Task GetPatientRegisterGuideReportAsync(Guid PatientRegisterId) { - return await _patientRegisterGuideReportRepository.GetPatientRegisterGuideReportAsync(PatientRegisterId); + //return await _patientRegisterGuideReportRepository.GetPatientRegisterGuideReportAsync(PatientRegisterId); + + var apiUrl = _configuration.GetValue("HostUrl:ApiUrl") + "/"; + var patientRegister = await _patientRegisterRepository.GetAsync(o=>o.Id == PatientRegisterId); + Guid medicalCenterId = patientRegister.MedicalCenterId; + + + #region 系统参数配置 + var MedicalCenterAddress = await _sysParmValueManager.GetSysParmValueAsync(medicalCenterId, "medical_center_address"); + var MedicalCenterFax = await _sysParmValueManager.GetSysParmValueAsync(medicalCenterId, "medical_center_fax"); + var MedicalCenterTelphone = await _sysParmValueManager.GetSysParmValueAsync(medicalCenterId, "medical_center_telphone"); + #endregion + + var customerOrgList = await _customerOrgRepository.GetListAsync(); + + var query = from a in await _patientRegisterRepository.GetQueryableAsync() + join b in await _sexRegisterRepository.GetQueryableAsync() + on a.SexId equals b.Id + join c in await _customerOrgGroupRepository.GetQueryableAsync() + on a.CustomerOrgGroupId equals c.Id into cc + from ac in cc.DefaultIfEmpty() + join d in await _medicalPackageRepository.GetQueryableAsync() + on a.MedicalPackageId equals d.Id into dd + from ad in dd.DefaultIfEmpty() + join e in await _patientRepository.GetQueryableAsync() + on a.PatientId equals e.Id + join f in await _personnelTypeRepository.GetQueryableAsync() + on a.PersonnelTypeId equals f.Id into ff + from af in ff.DefaultIfEmpty() + join g in await _organizationUnitRepository.GetQueryableAsync() + on a.MedicalCenterId equals g.Id into gg + from ag in gg.DefaultIfEmpty() + where (a.Id == PatientRegisterId) + select new PatientRegisterGuideReportDto + { + Age = a.Age, + PatientRegisterId = a.Id, + CustomerOrgGroupName = ac.DisplayName, + CustomerOrgName = _cacheService.GetTopCustomerOrgNameAsync( a.CustomerOrgId).Result, + CustomerOrgShortName = _cacheService.GetTopCustomerOrgAsync(a.CustomerOrgId).Result.ShortName, + DepartmentName = _cacheService.GetCustomerOrgNameAsync( a.CustomerOrgId).Result, + IdNo = e.IdNo, + JobCardNo = a.JobCardNo, + MedicalCardNo = a.MedicalCardNo, + MedicalCenterAddress = MedicalCenterAddress, + MedicalCenterFax = MedicalCenterFax, + MedicalCenterTelphone = MedicalCenterTelphone, + MedicalPackageName = ad.DisplayName, + MedicalTimes = a.MedicalTimes, + MobileTelephone = e.MobileTelephone, + PatientName = a.PatientName, + PatientNo = e.PatientNo, + PatientRegisterNo = a.PatientRegisterNo, + PersonnelTypeName = af.DisplayName, + SexName = b.DisplayName, + // Photo = string.IsNullOrEmpty(a.Photo) ? "" : ImageHelper.GetImageBase64StringAsync( a.Photo), + Photo = string.IsNullOrEmpty(a.Photo) ? "" : apiUrl + a.Photo, + MedicalStartDate = Convert.ToDateTime(a.MedicalStartDate.ToString()).ToString("yyyy-MM-dd"), + OrganizationUnitId = a.MedicalCenterId, + OrganizationUnitName = ag.DisplayName, + Detail = PatientRegisterGuideAsbitem(a.Id, medicalCenterId, a.SexId), + HisPatientId = a.HisPatientId + }; + + return query.FirstOrDefault(); + } @@ -693,5 +779,42 @@ namespace Shentun.Peis.PrintReports } return MedicalReportMedicalReportTypeDtos; } + + private List PatientRegisterGuideAsbitem(Guid PatientRegisterId, Guid medicalCenterId, char SexId) + { + var entlist = _registerCheckAsbitemRepository.GetQueryableAsync().Result + .Include(x => x.Asbitem) + .Include(x => x.Asbitem.ItemType) + .Include(x => x.Asbitem.ItemType.GuidType) + .Where(m => m.PatientRegisterId == PatientRegisterId && m.Asbitem.IsCheck == 'Y') + .Select(s => new PatientRegisterGuideReport_Asbitem_Temp + { + AsbitemName = s.Asbitem.DisplayName, + AsbitemGuide = _asbitemGuideManager.GetAsbitemGuideConvertSexId(medicalCenterId, s.AsbitemId, SexId), + AsbitemDisplayOrder = s.Asbitem.DisplayOrder, + GuideDisplayOrder = s.Asbitem.ItemType.GuidType.DisplayOrder, + GuideName = s.Asbitem.ItemType.GuidType.DisplayName + }) + .OrderBy(o => o.GuideDisplayOrder) + .GroupBy(g => new { g.GuideName, g.GuideDisplayOrder }) + .Select(s => new PatientRegisterGuideReport_Detail + { + GuideName = s.Key.GuideName, + AsbitemCount = s.Count(), + DisplayOrder = s.Key.GuideDisplayOrder, + Detail_Name = s.ToList().Select(ss => new PatientRegisterGuideReport_Detail_Asbitem + { + AsbitemName = ss.AsbitemName, + AsbitemGuide = ss.AsbitemGuide, + DisplayOrder = ss.AsbitemDisplayOrder + }).OrderBy(o => o.DisplayOrder).ToList() + }).OrderBy(o => o.DisplayOrder).ToList(); + + + + + return entlist; + + } } } diff --git a/src/Shentun.Peis.EntityFrameworkCore/PrintReports/PatientRegisterGuideReportRepository.cs b/src/Shentun.Peis.EntityFrameworkCore/PrintReports/PatientRegisterGuideReportRepository.cs index c12d840..adfcbb6 100644 --- a/src/Shentun.Peis.EntityFrameworkCore/PrintReports/PatientRegisterGuideReportRepository.cs +++ b/src/Shentun.Peis.EntityFrameworkCore/PrintReports/PatientRegisterGuideReportRepository.cs @@ -189,12 +189,11 @@ namespace Shentun.Peis.PrintReports /// private static List PatientRegisterGuideAsbitem(Guid PatientRegisterId, Guid medicalCenterId, char SexId) { - var entlist = _registerAsbitemRepository.GetDbSetAsync().Result + var entlist = _registerAsbitemRepository.GetQueryableAsync().Result .Include(x => x.Asbitem) .Include(x => x.Asbitem.ItemType) .Include(x => x.Asbitem.ItemType.GuidType) - - .Where(m => m.PatientRegisterId == PatientRegisterId) + .Where(m => m.PatientRegisterId == PatientRegisterId && m.Asbitem.IsCheck == 'Y') .Select(s => new PatientRegisterGuideReport_Asbitem_Temp { AsbitemName = s.Asbitem.DisplayName,