From eb12f9ef8a6edeefa0f997ffe7c7036c413a3f7d Mon Sep 17 00:00:00 2001 From: "DESKTOP-G961P6V\\Zhh" <839860190@qq.com> Date: Mon, 3 Jun 2024 18:58:43 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=84=E7=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AppointPatientRegisterDto.cs | 94 ++++++++- .../AppointPatientRegisterIdInputDto.cs | 11 ++ .../IdNoOrMobilePhoneInputDto.cs | 13 ++ .../MobilePhoneInputDto.cs | 11 ++ .../AppointRegisterAsbitemDto.cs | 45 +++++ .../DiseaseScreeningTypeAsbitemDto.cs | 2 +- .../AppointPatientRegisterAppService.cs | 181 +++++++++++++++++- .../AppointPatientRegisterAppServiceTest.cs | 42 ++++ 8 files changed, 392 insertions(+), 7 deletions(-) create mode 100644 src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/AppointPatientRegisterIdInputDto.cs create mode 100644 src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/IdNoOrMobilePhoneInputDto.cs create mode 100644 src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/MobilePhoneInputDto.cs create mode 100644 src/Shentun.WebPeis.Application.Contracts/AppointRegisterAsbitems/AppointRegisterAsbitemDto.cs diff --git a/src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/AppointPatientRegisterDto.cs b/src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/AppointPatientRegisterDto.cs index 88b97cc..7dd4aab 100644 --- a/src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/AppointPatientRegisterDto.cs +++ b/src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/AppointPatientRegisterDto.cs @@ -1,37 +1,121 @@ -using System; +using Shentun.WebPeis.AppointRegisterAsbitems; +using System; using System.Collections.Generic; using System.Text; namespace Shentun.WebPeis.AppointPatientRegisters { + /// + /// 预约信息 + /// public class AppointPatientRegisterDto { + /// + /// 预约登记ID + /// public Guid AppointPatientRegisterId { get; set; } + /// + /// 人员ID + /// public Guid PersonId { get; set; } + /// + /// 姓名 + /// + + public string PersonName { get; set; } + /// + /// 身份证号 + /// + public string? IdNo { get; set; } + /// + /// 性别ID + /// + public char SexId { get; set; } + /// + /// 性别名称 + /// + public string SexName { get; set; } + /// + /// 婚姻状况ID + /// + public char MaritalStatusId { get; set; } + /// + /// 婚姻状况名称 + /// + public string MaritalStatusName { get; set; } + /// + /// 单位ID + /// public Guid CustomerOrgId { get; set; } + /// + /// 单位名称 + /// + public string CustomerOrgName { get; set; } + public string ChildCustomerOrgName { get; set; } + /// + /// 单位分组ID + /// public Guid? CustomerOrgGroupId { get; set; } + /// + /// 单位分组名称 + /// + public string CustomerOrgGroupName { get; set; } + /// + /// 套餐ID + /// public Guid? MedicalPackageId { get; set; } + /// + /// 套餐名称 + /// + public string MedicalPackageName { get; set; } + /// + /// 完成标志 + /// public char CompleteFlag { get; set; } + /// + /// 预约日期 + /// - public DateTime MedicalStartDate { get; set; } + public DateTime AppointDate { get; set; } + /// + /// 备注 + /// public string? Remark { get; set; } + /// + /// 体检中心ID + /// public Guid MedicalCenterId { get; set; } + /// + /// 单位登记ID + /// public Guid CustomerOrgRegisterId { get; set; } - - public string? ConcurrencyStamp { get; set; } + /// + /// 备孕标志 + /// public char PregnantFlag { get; set; } - + public string PregnantFlagName { get; set; } + /// + /// 身高 + /// public decimal? Height { get; set; } + /// + /// 体重 + /// public decimal? Weight { get; set; } + /// + /// 预约组合项目 + /// + + public List AppointRegisterAsbitems { get; set; } = new List(); } } diff --git a/src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/AppointPatientRegisterIdInputDto.cs b/src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/AppointPatientRegisterIdInputDto.cs new file mode 100644 index 0000000..62f8aa0 --- /dev/null +++ b/src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/AppointPatientRegisterIdInputDto.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.WebPeis.AppointPatientRegisters +{ + public class AppointPatientRegisterIdInputDto + { + public Guid AppointPatientRegisterId { get; set; } + } +} diff --git a/src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/IdNoOrMobilePhoneInputDto.cs b/src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/IdNoOrMobilePhoneInputDto.cs new file mode 100644 index 0000000..13d3c8c --- /dev/null +++ b/src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/IdNoOrMobilePhoneInputDto.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.WebPeis.AppointPatientRegisters +{ + public class IdNoOrMobilePhoneInputDto + { + public string IdNo { get; set; } + public string MobilePhone { get; set; } + + } +} diff --git a/src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/MobilePhoneInputDto.cs b/src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/MobilePhoneInputDto.cs new file mode 100644 index 0000000..e2e17e1 --- /dev/null +++ b/src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/MobilePhoneInputDto.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.WebPeis.AppointPatientRegisters +{ + public class MobilePhoneInputDto + { + public string MobilePhone { get; set; } + } +} diff --git a/src/Shentun.WebPeis.Application.Contracts/AppointRegisterAsbitems/AppointRegisterAsbitemDto.cs b/src/Shentun.WebPeis.Application.Contracts/AppointRegisterAsbitems/AppointRegisterAsbitemDto.cs new file mode 100644 index 0000000..909b731 --- /dev/null +++ b/src/Shentun.WebPeis.Application.Contracts/AppointRegisterAsbitems/AppointRegisterAsbitemDto.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.WebPeis.AppointRegisterAsbitems +{ + public class AppointRegisterAsbitemDto + { + /// + /// 主键 + /// + public Guid AppointRegisterAsbitemId { get; set; } + /// + /// 组合项目ID + /// + public Guid AsbitemId { get; set; } + public string AsbitemName { get; set; } + /// + /// 预约主档ID + /// + public Guid AppointPatientRegisterId { get; set; } + /// + /// 标准价格 + /// + public decimal StandardPrice { get; set; } + /// + /// 收费价格 + /// + public decimal ChargePrice { get; set; } + /// + /// 支付类别标准 + /// + public char PayTypeFlag { get; set; } + /// + /// 是否收费 + /// + public char IsCharge { get; set; } + /// + /// 数量 + /// + public short Amount { get; set; } + + public char IsInMedicalPackage { get; set; } = 'N'; + } +} diff --git a/src/Shentun.WebPeis.Application.Contracts/Asbitems/DiseaseScreeningTypeAsbitemDto.cs b/src/Shentun.WebPeis.Application.Contracts/Asbitems/DiseaseScreeningTypeAsbitemDto.cs index 314ae04..0308acc 100644 --- a/src/Shentun.WebPeis.Application.Contracts/Asbitems/DiseaseScreeningTypeAsbitemDto.cs +++ b/src/Shentun.WebPeis.Application.Contracts/Asbitems/DiseaseScreeningTypeAsbitemDto.cs @@ -9,7 +9,7 @@ namespace Shentun.WebPeis.Asbitems public string DiseaseScreeningTypeId { get; set; } public string DiseaseScreeningTypeName { get; set; } public int DisplayOrder { get; set; } - public List Asbitems = new List(); + public List Asbitems { get; set; } = new List(); } public class DiseaseScreeningTypeAsbitem diff --git a/src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs b/src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs index 6ac56ce..729eb8f 100644 --- a/src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs +++ b/src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs @@ -1,14 +1,19 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Shentun.WebPeis.AppointRegisterAsbitems; +using Shentun.WebPeis.CustomerOrgs; using Shentun.WebPeis.Models; using System; +using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Volo.Abp; using Volo.Abp.Application.Services; using Volo.Abp.Domain.Repositories; +using Volo.Abp.Identity; +using static Volo.Abp.Identity.Settings.IdentitySettingNames; namespace Shentun.WebPeis.AppointPatientRegisters { @@ -21,14 +26,32 @@ namespace Shentun.WebPeis.AppointPatientRegisters { private readonly IRepository _repository; private readonly IRepository _appointRegisterAsbitemRepository; + private readonly IRepository _personRepository; + private readonly IRepository _customerOrgRepository; + private readonly IRepository _identityUserRepository; + private readonly IRepository _asbitemRepository; private readonly IRepository _itemTypeRepository; + private readonly IRepository _medicalPackageRepository; + private readonly IRepository _medicalPackageDetailRepository; + private readonly IRepository _customerOrgGroupRepository; + private readonly IRepository _customerOrgGroupDetailRepository; private readonly CacheService _cacheService; private readonly AppointPatientRegisterManager _appointPatientRegisterManager; + private readonly CustomerOrgManager _customerOrgManager; public AppointPatientRegisterAppService(IRepository repository, CacheService cacheService, IRepository itemTypeRepository, AppointPatientRegisterManager appointPatientRegisterManager, - IRepository appointRegisterAsbitemRepository + IRepository appointRegisterAsbitemRepository, + IRepository personRepository, + IRepository identityUserRepository, + CustomerOrgManager customerOrgManager, + IRepository medicalPackageRepository, + IRepository customerOrgGroupRepository, + IRepository asbitemRepository, + IRepository customerOrgRepository, + IRepository medicalPackageDetailRepository, + IRepository customerOrgGroupDetailRepository ) { _repository = repository; @@ -36,6 +59,15 @@ namespace Shentun.WebPeis.AppointPatientRegisters _itemTypeRepository = itemTypeRepository; _appointPatientRegisterManager = appointPatientRegisterManager; _appointRegisterAsbitemRepository = appointRegisterAsbitemRepository; + _personRepository = personRepository; + _identityUserRepository = identityUserRepository; + _customerOrgManager = customerOrgManager; + _medicalPackageRepository = medicalPackageRepository; + _customerOrgGroupRepository = customerOrgGroupRepository; + _asbitemRepository = asbitemRepository; + _customerOrgRepository = customerOrgRepository; + _medicalPackageDetailRepository = medicalPackageDetailRepository; + _customerOrgGroupDetailRepository = customerOrgGroupDetailRepository; } @@ -50,5 +82,152 @@ namespace Shentun.WebPeis.AppointPatientRegisters var result = ObjectMapper.Map(entity); return result; } + + [HttpPost("api/app/AppointPatientRegister/GetByIdNoOrMobilePhone")] + public async Task> GetByIdNoOrMobilePhoneAsync(IdNoOrMobilePhoneInputDto input) + { + if (input == null) throw new UserFriendlyException("参数不能为空"); + + if (string.IsNullOrWhiteSpace(input.MobilePhone) && string.IsNullOrWhiteSpace(input.IdNo)) + { + throw new UserFriendlyException("手机号和身份证必须至少填一个"); + } + var query = (from user in await _identityUserRepository.GetQueryableAsync() + join person in await _personRepository.GetQueryableAsync() + on user.Id equals person.PersonId + join appointPatientRegister in await _repository.GetQueryableAsync() + on person.PersonId equals appointPatientRegister.PersonId + join medicalPackage in await _medicalPackageRepository.GetQueryableAsync() + on appointPatientRegister.MedicalPackageId equals medicalPackage.MedicalPackageId into canEmptyMedicalPackage + from haveMedicalPackage in canEmptyMedicalPackage.DefaultIfEmpty() + join customerOrgGroup in await _customerOrgGroupRepository.GetQueryableAsync() + on appointPatientRegister.CustomerOrgGroupId equals customerOrgGroup.CustomerOrgGroupId into canEmptyCustomerOrgGroup + from haveCustomerOrgGroup in canEmptyCustomerOrgGroup.DefaultIfEmpty() + join appointRegisterAsbitem in await _appointRegisterAsbitemRepository.GetQueryableAsync() + on appointPatientRegister.AppointPatientRegisterId equals appointRegisterAsbitem.AppointPatientRegisterId + join asbitem in await _asbitemRepository.GetQueryableAsync() + on appointRegisterAsbitem.AsbitemId equals asbitem.AsbitemId + join customerOrg in await _customerOrgRepository.GetQueryableAsync() + on appointPatientRegister.CustomerOrgId equals customerOrg.CustomerOrgId + orderby appointPatientRegister.AppointDate + select new + { + user, + person, + appointPatientRegister, + appointRegisterAsbitem, + asbitem, + haveMedicalPackage, + haveCustomerOrgGroup, + customerOrg + } + ); + + + if (!string.IsNullOrWhiteSpace(input.IdNo)) + { + if (input.IdNo.Length != 18) + { + throw new UserFriendlyException("身份证长度必须是18位"); + } + query = query.Where(o => o.person.IdNo == input.IdNo); + + } + else + { + if (input.MobilePhone.Length != 11) + { + throw new UserFriendlyException("手机号长度必须是11位"); + } + query = query.Where(o => o.user.PhoneNumber == input.MobilePhone); + } + + var appointPatientRegisterDtos = query.ToList(); + + var list = appointPatientRegisterDtos.GroupBy(o => o.appointPatientRegister) + .Select(o => new AppointPatientRegisterDto() + { + AppointPatientRegisterId = o.FirstOrDefault().appointPatientRegister.AppointPatientRegisterId, + PersonId = o.FirstOrDefault().appointPatientRegister.PersonId, + PersonName = o.FirstOrDefault().user.Name, + IdNo = o.FirstOrDefault().person.IdNo, + SexId = o.FirstOrDefault().person.SexId, + MaritalStatusId = o.FirstOrDefault().person.MaritalStatusId, + CustomerOrgId = o.FirstOrDefault().appointPatientRegister.CustomerOrgId, + ChildCustomerOrgName = o.FirstOrDefault().customerOrg.PathCode.Length == 5 ? "" : o.FirstOrDefault().customerOrg.CustomerOrgName, + CustomerOrgGroupId = o.FirstOrDefault().appointPatientRegister.CustomerOrgGroupId, + CustomerOrgGroupName = o.FirstOrDefault().haveCustomerOrgGroup == null ? "" : o.FirstOrDefault().haveCustomerOrgGroup.DisplayName, + CustomerOrgRegisterId = o.FirstOrDefault().appointPatientRegister.CustomerOrgRegisterId, + MedicalPackageId = o.FirstOrDefault().appointPatientRegister.MedicalPackageId, + MedicalPackageName = o.FirstOrDefault().haveMedicalPackage == null ? "" : o.FirstOrDefault().haveMedicalPackage.MedicalPackageName, + MedicalCenterId = o.FirstOrDefault().appointPatientRegister.MedicalCenterId, + CompleteFlag = o.FirstOrDefault().appointPatientRegister.CompleteFlag, + AppointDate = o.FirstOrDefault().appointPatientRegister.AppointDate, + Remark = o.FirstOrDefault().appointPatientRegister.Remark, + PregnantFlag = o.FirstOrDefault().appointPatientRegister.PregnantFlag, + Height = o.FirstOrDefault().appointPatientRegister.Height, + Weight = o.FirstOrDefault().appointPatientRegister.Weight, + SexName = _cacheService.GetSexNameAsync(o.FirstOrDefault().person.SexId).Result, + MaritalStatusName = _cacheService.GetMaritalStatusNameAsync(o.FirstOrDefault().person.MaritalStatusId).Result, + CustomerOrgName = _customerOrgManager.GetTopCustomerOrgAsync(o.FirstOrDefault().appointPatientRegister.CustomerOrgId).Result.CustomerOrgName + + }).ToList(); + + + return list; + + + + } + + [HttpPost("api/app/AppointPatientRegister/GetAppointRegisterAsbitemListById")] + public async Task> GetAppointRegisterAsbitemListByIdAsync(AppointPatientRegisterIdInputDto input) + { + var appointPatientRegister = await _repository.GetAsync(o => o.AppointPatientRegisterId == input.AppointPatientRegisterId); + var appointRegisterAsbitemDtos = ( + + from appointRegisterAsbitem in await _appointRegisterAsbitemRepository.GetQueryableAsync() + join asbitem in await _asbitemRepository.GetQueryableAsync() + on appointRegisterAsbitem.AsbitemId equals asbitem.AsbitemId + orderby appointPatientRegister.AppointDate + where appointRegisterAsbitem.AppointPatientRegisterId == input.AppointPatientRegisterId + select new AppointRegisterAsbitemDto() + { + AppointPatientRegisterId = input.AppointPatientRegisterId, + AsbitemId = appointRegisterAsbitem.AsbitemId, + AsbitemName = asbitem.AsbitemName, + StandardPrice = appointRegisterAsbitem.StandardPrice, + ChargePrice = appointRegisterAsbitem.ChargePrice, + Amount = appointRegisterAsbitem.Amount, + IsCharge = appointRegisterAsbitem.IsCharge + } + + ).ToList(); + + List asbitems = new List(); + if (appointPatientRegister.MedicalPackageId != null) + { + asbitems = (await _medicalPackageDetailRepository.GetQueryableAsync()) + .Where(o => o.MedicalPackageId == appointPatientRegister.MedicalPackageId) + .Select(x => x.AsbitemId).ToList(); + ; + } + else if (appointPatientRegister.CustomerOrgGroupId != null) + { + asbitems = (await _customerOrgGroupDetailRepository.GetQueryableAsync()) + .Where(o => o.CustomerOrgGroupId == appointPatientRegister.CustomerOrgGroupId) + .Select(x => x.AsbitemId).ToList(); + } + + appointRegisterAsbitemDtos.ForEach(o => + { + if (asbitems.Where(x => x == o.AsbitemId).ToList().Any()) + { + o.IsInMedicalPackage = 'Y'; + } + }); + + return appointRegisterAsbitemDtos; + } } } diff --git a/test/Shentun.WebPeis.Application.Tests/AppointPatientRegisterAppServiceTest.cs b/test/Shentun.WebPeis.Application.Tests/AppointPatientRegisterAppServiceTest.cs index f17997f..e161bcf 100644 --- a/test/Shentun.WebPeis.Application.Tests/AppointPatientRegisterAppServiceTest.cs +++ b/test/Shentun.WebPeis.Application.Tests/AppointPatientRegisterAppServiceTest.cs @@ -70,5 +70,47 @@ namespace Shentun.WebPeis await unitOfWork.CompleteAsync(); } } + + [Fact] + public async Task GetByIdNoOrMobilePhoneAsync() + { + using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true)) + { + + var entity = new IdNoOrMobilePhoneInputDto() + { + MobilePhone = "18911254911" + }; + var list = await _appService.GetByIdNoOrMobilePhoneAsync(entity); + foreach (var item in list) + { + _output.WriteLine(item.PersonName); + foreach(var asbitem in item.AppointRegisterAsbitems) + { + _output.WriteLine(asbitem.AsbitemName); + } + } + await unitOfWork.CompleteAsync(); + } + } + + [Fact] + public async Task GetAppointRegisterAsbitemListById() + { + using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true)) + { + + var entity = new AppointPatientRegisterIdInputDto() + { + AppointPatientRegisterId = new Guid("3a12ec60-278d-1814-753b-87ff8782aa26") + }; + var list = await _appService.GetAppointRegisterAsbitemListByIdAsync(entity); + foreach (var item in list) + { + _output.WriteLine(item.AsbitemName); + } + await unitOfWork.CompleteAsync(); + } + } } }