diff --git a/src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/GerAppointPatientRegisterWithAsbitemListDto.cs b/src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/GerAppointPatientRegisterWithAsbitemListDto.cs index f9fb140..6c33f39 100644 --- a/src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/GerAppointPatientRegisterWithAsbitemListDto.cs +++ b/src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/GerAppointPatientRegisterWithAsbitemListDto.cs @@ -21,6 +21,11 @@ namespace Shentun.Peis.AppointPatientRegisters /// public string AppointDate { get; set; } + /// + /// 收费合计金额 + /// + public decimal ChargeSumMoney { get; set; } + /// /// 预约项目 /// diff --git a/src/Shentun.Peis.Application/CustomerOrgs/CustomerOrgAppService.cs b/src/Shentun.Peis.Application/CustomerOrgs/CustomerOrgAppService.cs index 95c0dfb..62732df 100644 --- a/src/Shentun.Peis.Application/CustomerOrgs/CustomerOrgAppService.cs +++ b/src/Shentun.Peis.Application/CustomerOrgs/CustomerOrgAppService.cs @@ -156,8 +156,8 @@ namespace Shentun.Peis.CustomerOrgs SalesPersonPhone = s.SalesPersonPhone, MedicalCenterId = s.MedicalCenterId, CountryOrgCode = s.CountryOrgCode, - CreatorName = _cacheService.GetSurnameAsync(s.CreatorId).Result, - LastModifierName = _cacheService.GetSurnameAsync(s.LastModifierId).Result + CreatorName = _cacheService.GetSurnameAsync(s.CreatorId).GetAwaiter().GetResult(), + LastModifierName = _cacheService.GetSurnameAsync(s.LastModifierId).GetAwaiter().GetResult() }).OrderBy(m => m.DisplayOrder).ToList(); diff --git a/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs b/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs index 1769fa5..ce82ff6 100644 --- a/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs +++ b/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs @@ -42,6 +42,7 @@ using System.Linq; using System.Linq.Dynamic.Core; using System.Runtime.CompilerServices; using System.Security; +using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; using Volo.Abp; @@ -3654,23 +3655,81 @@ namespace Shentun.Peis.PatientRegisters [HttpPost("api/app/patientregister/getpatientregisternotchargedlist")] public async Task> GetPatientRegisterNotChargedListAsync(PatientRegisterChargeRequestDto input) { - PatientRegisterChargeEfCoreDto patientRegisterChargeEfCoreDto = new PatientRegisterChargeEfCoreDto + + var query = from patientRegister in await _repository.GetQueryableAsync() + join patient in await _patientRepository.GetQueryableAsync() on patientRegister.PatientId equals patient.Id + join registerCheck in await _registerCheckRepository.GetQueryableAsync() on patientRegister.Id equals registerCheck.PatientRegisterId + join registerCheckAsbitem in await _registerCheckAsbitemRepository.GetQueryableAsync() on registerCheck.Id equals registerCheckAsbitem.RegisterCheckId + where registerCheckAsbitem.IsCharge == 'N' && registerCheckAsbitem.PayTypeFlag == PayTypeFlag.PersonPay + orderby patientRegister.Id ascending + select new + { + patientRegister, + patient + }; + + if (!string.IsNullOrEmpty(input.StartDate) && !string.IsNullOrEmpty(input.EndDate)) { - EndDate = input.EndDate, - InvoiceNo = input.InvoiceNo, - PatientName = input.PatientName, - PatientNo = input.PatientNo, - PatientRegisterNo = input.PatientRegisterNo, - StartDate = input.StartDate - }; - var patientRegisterNotChargedList = await _patientRegisterChargeRepository.GetPatientRegisterNotChargedListAsync(patientRegisterChargeEfCoreDto); + query = query.Where(m => m.patientRegister.CreationTime >= Convert.ToDateTime(input.StartDate) && + m.patientRegister.CreationTime < Convert.ToDateTime(input.EndDate).AddDays(1)); + } + if (!string.IsNullOrEmpty(input.PatientName)) + { + query = query.Where(m => !string.IsNullOrEmpty(m.patientRegister.PatientName) && m.patientRegister.PatientName.Contains(input.PatientName)); + } + if (!string.IsNullOrEmpty(input.PatientNo)) + { + query = query.Where(m => m.patient.PatientNo == input.PatientNo); + } + if (!string.IsNullOrEmpty(input.PatientRegisterNo)) + { + query = query.Where(m => m.patientRegister.PatientRegisterNo == input.PatientRegisterNo); + } + + var patientRegisterGroup = query.ToList().GroupBy(g => g.patientRegister); + + int totalCount = patientRegisterGroup.Count(); + + patientRegisterGroup = patientRegisterGroup.Skip(input.SkipCount * input.MaxResultCount).Take(input.MaxResultCount); + + var entListDto = patientRegisterGroup.ToList().Select(s => new GetPatientRegisterNotChargedListDto + { + PatientRegisterId = s.Key.Id, + Address = s.FirstOrDefault().patient.Address, + Age = s.Key.Age, + CustomerOrgName = _cacheService.GetCustomerOrgAsync(s.Key.CustomerOrgId).GetAwaiter().GetResult().DisplayName, + CustomerOrgParentName = _cacheService.GetTopCustomerOrgAsync(s.Key.CustomerOrgId).GetAwaiter().GetResult().DisplayName, + Email = s.FirstOrDefault().patient.Email, + IdNo = s.FirstOrDefault().patient.IdNo, + IsVip = s.Key.IsVip, + MedicalTimes = s.Key.MedicalTimes, + MobileTelephone = s.FirstOrDefault().patient.MobileTelephone, + PatientName = s.Key.PatientName, + PatientNo = s.FirstOrDefault().patient.PatientNo, + PatientRegisterNo = s.Key.PatientRegisterNo, + Salesman = s.Key.Salesman, + SexId = _cacheService.GetSexNameAsync(s.Key.SexId).GetAwaiter().GetResult(), + Telephone = s.FirstOrDefault().patient.Telephone + }).ToList(); + + return new PagedResultDto(totalCount, entListDto); + //PatientRegisterChargeEfCoreDto patientRegisterChargeEfCoreDto = new PatientRegisterChargeEfCoreDto + //{ + // EndDate = input.EndDate, + // InvoiceNo = input.InvoiceNo, + // PatientName = input.PatientName, + // PatientNo = input.PatientNo, + // PatientRegisterNo = input.PatientRegisterNo, + // StartDate = input.StartDate + //}; + //var patientRegisterNotChargedList = await _patientRegisterChargeRepository.GetPatientRegisterNotChargedListAsync(patientRegisterChargeEfCoreDto); - int totalCount = patientRegisterNotChargedList.Count; + //int totalCount = patientRegisterNotChargedList.Count; - patientRegisterNotChargedList = patientRegisterNotChargedList.Skip(input.SkipCount * input.MaxResultCount).Take(input.MaxResultCount).ToList(); + //patientRegisterNotChargedList = patientRegisterNotChargedList.Skip(input.SkipCount * input.MaxResultCount).Take(input.MaxResultCount).ToList(); - return new PagedResultDto(totalCount, patientRegisterNotChargedList); + //return new PagedResultDto(totalCount, patientRegisterNotChargedList); } /// diff --git a/src/Shentun.Peis.EntityFrameworkCore/PatientRegisters/PatientRegisterChargeRepository.cs b/src/Shentun.Peis.EntityFrameworkCore/PatientRegisters/PatientRegisterChargeRepository.cs index 25b32ea..d93abdc 100644 --- a/src/Shentun.Peis.EntityFrameworkCore/PatientRegisters/PatientRegisterChargeRepository.cs +++ b/src/Shentun.Peis.EntityFrameworkCore/PatientRegisters/PatientRegisterChargeRepository.cs @@ -14,8 +14,14 @@ namespace Shentun.Peis.PatientRegisters { public class PatientRegisterChargeRepository : EfCoreRepository, IPatientRegisterChargeRepository { - public PatientRegisterChargeRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) + private readonly CacheService _cacheService; + + public PatientRegisterChargeRepository( + IDbContextProvider dbContextProvider, + CacheService cacheService + ) : base(dbContextProvider) { + _cacheService = cacheService; } /// @@ -28,17 +34,14 @@ namespace Shentun.Peis.PatientRegisters { var dbContext = await GetDbContextAsync(); - List customerOrgs = dbContext.CustomerOrgs.ToList(); - + var query = (from a in dbContext.PatientRegisters join b in dbContext.Patients on a.PatientId equals b.Id into bb from ab in bb.DefaultIfEmpty() - join c in dbContext.Sexes on a.SexId equals c.Id into cc - from ac in cc.DefaultIfEmpty() join d in dbContext.Charges on a.Id equals d.PatientRegisterId join e in dbContext.ChargeBacks on d.Id equals e.ChargeId where d.ChargeFlag == '1' - select new { a, ab, ac, d, e } + select new { a, ab, d, e } ); if (!string.IsNullOrEmpty(input.StartDate) && !string.IsNullOrEmpty(input.EndDate)) @@ -63,8 +66,7 @@ namespace Shentun.Peis.PatientRegisters query = query.Where(m => m.a.PatientRegisterNo == input.PatientRegisterNo); } - - var entlist = query.OrderBy(o => o.a.CreationTime).Select(s => new GetPatientRegisterChargeBackListDto + var entlist = query.ToList().OrderBy(o => o.a.CreationTime).Select(s => new GetPatientRegisterChargeBackListDto { PatientRegisterId = s.a.Id, Address = s.ab.Address, @@ -73,8 +75,8 @@ namespace Shentun.Peis.PatientRegisters ChargeBackId = s.e.Id, InvoiceNo = s.d.InvoiceNo, InvoiceOrgName = s.d.InvoiceOrgName, - CustomerOrgName = EntityHelper.GetCustomerOrgNameNoSql(customerOrgs, s.a.CustomerOrgId), - CustomerOrgParentName = EntityHelper.GetCustomerOrgParentNameNoSql(customerOrgs, s.a.CustomerOrgId), + CustomerOrgName = _cacheService.GetCustomerOrgAsync(s.a.CustomerOrgId).GetAwaiter().GetResult().DisplayName, + CustomerOrgParentName = _cacheService.GetTopCustomerOrgAsync(s.a.CustomerOrgId).GetAwaiter().GetResult().DisplayName, Email = s.ab.Email, IdNo = s.ab.IdNo, IsVip = s.a.IsVip, @@ -84,7 +86,7 @@ namespace Shentun.Peis.PatientRegisters PatientNo = s.ab.PatientNo, PatientRegisterNo = s.a.PatientRegisterNo, Salesman = s.a.Salesman, - SexId = s.ac.DisplayName, + SexId = _cacheService.GetSexNameAsync(s.a.SexId).GetAwaiter().GetResult(), Telephone = s.ab.Telephone }).ToList(); @@ -101,20 +103,16 @@ namespace Shentun.Peis.PatientRegisters var dbContext = await GetDbContextAsync(); - List customerOrgs = dbContext.CustomerOrgs.ToList(); + var query = (from a in dbContext.PatientRegisters join b in dbContext.Patients on a.PatientId equals b.Id into bb from ab in bb.DefaultIfEmpty() - join c in dbContext.Sexes on a.SexId equals c.Id into cc - from ac in cc.DefaultIfEmpty() join d in dbContext.Charges on a.Id equals d.PatientRegisterId where d.ChargeFlag == '0' - select new { a, ab, ac, d } + select new { a, ab, d } ); - var sss = query.ToQueryString(); - if (!string.IsNullOrEmpty(input.StartDate) && !string.IsNullOrEmpty(input.EndDate)) { query = query.Where(m => m.a.CreationTime >= Convert.ToDateTime(input.StartDate) && @@ -138,7 +136,7 @@ namespace Shentun.Peis.PatientRegisters } - var entlist = query.OrderBy(o => o.a.CreationTime).Select(s => new GetPatientRegisterChargeListDto + var entlist = query.ToList().OrderBy(o => o.a.CreationTime).Select(s => new GetPatientRegisterChargeListDto { PatientRegisterId = s.a.Id, Address = s.ab.Address, @@ -146,8 +144,8 @@ namespace Shentun.Peis.PatientRegisters ChargeId = s.d.Id, InvoiceNo = s.d.InvoiceNo, InvoiceOrgName = s.d.InvoiceOrgName, - CustomerOrgName = EntityHelper.GetCustomerOrgNameNoSql(customerOrgs, s.a.CustomerOrgId), - CustomerOrgParentName = EntityHelper.GetCustomerOrgParentNameNoSql(customerOrgs, s.a.CustomerOrgId), + CustomerOrgName = _cacheService.GetCustomerOrgAsync(s.a.CustomerOrgId).GetAwaiter().GetResult().DisplayName, + CustomerOrgParentName = _cacheService.GetTopCustomerOrgAsync(s.a.CustomerOrgId).GetAwaiter().GetResult().DisplayName, Email = s.ab.Email, IdNo = s.ab.IdNo, IsVip = s.a.IsVip, @@ -157,7 +155,7 @@ namespace Shentun.Peis.PatientRegisters PatientNo = s.ab.PatientNo, PatientRegisterNo = s.a.PatientRegisterNo, Salesman = s.a.Salesman, - SexId = s.ac.DisplayName, + SexId = _cacheService.GetSexNameAsync(s.a.SexId).GetAwaiter().GetResult(), Telephone = s.ab.Telephone }).ToList(); @@ -175,16 +173,15 @@ namespace Shentun.Peis.PatientRegisters { var dbContext = await GetDbContextAsync(); - List customerOrgs = dbContext.CustomerOrgs.ToList(); var query = (from a in dbContext.PatientRegisters.Where(m => dbContext.RegisterCheckAsbitems.Where(rsb => rsb.IsCharge == 'N' && rsb.PayTypeFlag == PayTypeFlag.PersonPay).Select(s => s.PatientRegisterId).Contains(m.Id)) join b in dbContext.Patients on a.PatientId equals b.Id into bb from ab in bb.DefaultIfEmpty() - join c in dbContext.Sexes on a.SexId equals c.Id into cc - from ac in cc.DefaultIfEmpty() - select new { a, ab, ac } + select new { a, ab } ); + + if (!string.IsNullOrEmpty(input.StartDate) && !string.IsNullOrEmpty(input.EndDate)) { query = query.Where(m => m.a.CreationTime >= Convert.ToDateTime(input.StartDate) && @@ -204,13 +201,13 @@ namespace Shentun.Peis.PatientRegisters } - var entlist = query.OrderBy(o => o.a.CreationTime).Select(s => new GetPatientRegisterNotChargedListDto + var entlist = query.ToList().OrderBy(o => o.a.CreationTime).Select(s => new GetPatientRegisterNotChargedListDto { PatientRegisterId = s.a.Id, Address = s.ab.Address, Age = s.a.Age, - CustomerOrgName = EntityHelper.GetCustomerOrgNameNoSql(customerOrgs, s.a.CustomerOrgId), - CustomerOrgParentName = EntityHelper.GetCustomerOrgParentNameNoSql(customerOrgs, s.a.CustomerOrgId), + CustomerOrgName = _cacheService.GetCustomerOrgAsync(s.a.CustomerOrgId).GetAwaiter().GetResult().DisplayName, + CustomerOrgParentName = _cacheService.GetTopCustomerOrgAsync(s.a.CustomerOrgId).GetAwaiter().GetResult().DisplayName, Email = s.ab.Email, IdNo = s.ab.IdNo, IsVip = s.a.IsVip, @@ -220,7 +217,7 @@ namespace Shentun.Peis.PatientRegisters PatientNo = s.ab.PatientNo, PatientRegisterNo = s.a.PatientRegisterNo, Salesman = s.a.Salesman, - SexId = s.ac.DisplayName, + SexId = _cacheService.GetSexNameAsync(s.a.SexId).GetAwaiter().GetResult(), Telephone = s.ab.Telephone }).ToList();