|
|
using Microsoft.AspNetCore.Authorization;using Microsoft.AspNetCore.Mvc;using Shentun.WebPeis.AppointRegisterAsbitems;using Shentun.WebPeis.CustomerOrgs;using Shentun.WebPeis.Enums;using Shentun.WebPeis.MedicalPackages;using Shentun.WebPeis.Models;using Shentun.WebPeis.OrganizationUnits;using Shentun.WebPeis.PatientRegisters;using Shentun.WebPeis.Persons;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{ /// <summary>
/// 微信预约
/// </summary>
[ApiExplorerSettings(GroupName = "Work")] [Authorize] public class AppointPatientRegisterAppService : ApplicationService { private readonly IRepository<AppointPatientRegister> _repository; private readonly IRepository<AppointRegisterAsbitem> _appointRegisterAsbitemRepository; private readonly IRepository<Person> _personRepository; private readonly IRepository<CustomerOrg> _customerOrgRepository; private readonly IRepository<IdentityUser> _identityUserRepository; private readonly IRepository<Asbitem> _asbitemRepository; private readonly IRepository<ItemType> _itemTypeRepository; private readonly IRepository<MedicalPackage> _medicalPackageRepository; private readonly IRepository<MedicalPackageDetail> _medicalPackageDetailRepository; private readonly IRepository<CustomerOrgGroup> _customerOrgGroupRepository; private readonly IRepository<CustomerOrgGroupDetail> _customerOrgGroupDetailRepository; private readonly CacheService _cacheService; private readonly AppointPatientRegisterManager _appointPatientRegisterManager; private readonly CustomerOrgManager _customerOrgManager; private readonly WebPeisOrganizationUnitManager _webPeisOrganizationUnitManager; private readonly IRepository<PatientRegister> _patientRegisterRepository; private readonly IRepository<Patient> _patientRepository; private readonly IRepository<RegisterCheck> _registerCheckRepository; private readonly IRepository<RegisterCheckAsbitem> _registerCheckAsbitemRepository; public AppointPatientRegisterAppService(IRepository<AppointPatientRegister> repository, CacheService cacheService, IRepository<ItemType> itemTypeRepository, AppointPatientRegisterManager appointPatientRegisterManager, IRepository<AppointRegisterAsbitem> appointRegisterAsbitemRepository, IRepository<Person> personRepository, IRepository<IdentityUser> identityUserRepository, CustomerOrgManager customerOrgManager, IRepository<MedicalPackage> medicalPackageRepository, IRepository<CustomerOrgGroup> customerOrgGroupRepository, IRepository<Asbitem> asbitemRepository, IRepository<CustomerOrg> customerOrgRepository, IRepository<MedicalPackageDetail> medicalPackageDetailRepository, IRepository<CustomerOrgGroupDetail> customerOrgGroupDetailRepository, WebPeisOrganizationUnitManager webPeisOrganizationUnitManager, IRepository<PatientRegister> patientRegisterRepository, IRepository<Patient> patientRepository, IRepository<RegisterCheck> registerCheckRepository, IRepository<RegisterCheckAsbitem> registerCheckAsbitemRepository ) { _repository = repository; _cacheService = cacheService; _itemTypeRepository = itemTypeRepository; _appointPatientRegisterManager = appointPatientRegisterManager; _appointRegisterAsbitemRepository = appointRegisterAsbitemRepository; _personRepository = personRepository; _identityUserRepository = identityUserRepository; _customerOrgManager = customerOrgManager; _medicalPackageRepository = medicalPackageRepository; _customerOrgGroupRepository = customerOrgGroupRepository; _asbitemRepository = asbitemRepository; _customerOrgRepository = customerOrgRepository; _medicalPackageDetailRepository = medicalPackageDetailRepository; _customerOrgGroupDetailRepository = customerOrgGroupDetailRepository; _webPeisOrganizationUnitManager = webPeisOrganizationUnitManager; _patientRegisterRepository = patientRegisterRepository; _patientRepository = patientRepository; _registerCheckAsbitemRepository = registerCheckAsbitemRepository; _registerCheckRepository = registerCheckRepository;
} /// <summary>
/// 预约,小程序使用
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="UserFriendlyException"></exception>
[HttpPost("api/app/AppointPatientRegister/Create")] public async Task<AppointPatientRegisterDto> CreateAsync(CreateAppointPatientRegisterDto input) { var entity = ObjectMapper.Map<CreateAppointPatientRegisterDto, AppointPatientRegister>(input); var asbitems = ObjectMapper.Map<List<CreateAppointRegisterAsbitemDto>, List<AppointRegisterAsbitem>>(input.Asbitems); entity.AppointRegisterAsbitems = asbitems;
Guid medicalCenterId; if (input.MedicalCenterId == null || input.MedicalCenterId == Guid.Empty) { var webPeisOrganizationUnit = await _webPeisOrganizationUnitManager.GetMedicalCenterListAsync(); if (webPeisOrganizationUnit.Count > 1 || webPeisOrganizationUnit.Count == 0) { throw new UserFriendlyException("体检中心参数不能为空"); } medicalCenterId = webPeisOrganizationUnit.First().Id; } else { medicalCenterId = (Guid)input.MedicalCenterId; } entity.MedicalCenterId = medicalCenterId;
entity = await _appointPatientRegisterManager.CreateAsync(entity); await _repository.InsertAsync(entity); var result = ObjectMapper.Map<AppointPatientRegister, AppointPatientRegisterDto>(entity); return result; }
/// <summary>
/// 通过手机号等获取预约列表信息,体检程序前台登记使用
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="UserFriendlyException"></exception>
[AllowAnonymous] [HttpPost("api/app/AppointPatientRegister/GetListByFilter")] public async Task<List<AppointPatientRegisterDto>> GetListByFilterAsync(AppointPatientRegisterInputDto input) { if (input == null) throw new UserFriendlyException("参数不能为空");
Guid medicalCenterId; if (input.MedicalCenterId == null || input.MedicalCenterId == Guid.Empty) { var webPeisOrganizationUnit = await _webPeisOrganizationUnitManager.GetMedicalCenterListAsync(); if (webPeisOrganizationUnit.Count > 1 || webPeisOrganizationUnit.Count == 0) { throw new UserFriendlyException("体检中心参数不能为空"); } medicalCenterId = webPeisOrganizationUnit.First().Id; } else { medicalCenterId = (Guid)input.MedicalCenterId; } if (input.AppointStartDate == null) { input.AppointStartDate = DateTime.Now.Date; } else { input.AppointStartDate = ((DateTime)input.AppointStartDate).Date; }
if (input.AppointStopDate == null) { input.AppointStopDate = DateTime.Now.Date.AddDays(3650); } else { input.AppointStopDate = ((DateTime)input.AppointStopDate).Date.AddDays(1); }
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 where appointPatientRegister.MedicalCenterId == medicalCenterId && appointPatientRegister.AppointDate >= input.AppointStartDate && appointPatientRegister.AppointDate < input.AppointStopDate 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); }
if(input.CompleteFlag != null) { query = query.Where(o => o.appointPatientRegister.CompleteFlag == input.CompleteFlag); } 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, MobileTelephone = o.FirstOrDefault().user.PhoneNumber, 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.CustomerOrgGroupName, 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, IsCharge = o.FirstOrDefault().appointPatientRegister.IsCharge, 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;
} /// <summary>
/// 获取某人的预约列表,小程序使用
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="UserFriendlyException"></exception>
[HttpPost("api/app/AppointPatientRegister/GetListByPersonId")] public async Task<List<AppointPatientRegisterDto>> GetListByPersonIdAsync(PersonIdInputDto input) { if (input == null) 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 where appointPatientRegister.PersonId == input.PersonId && appointPatientRegister.CompleteFlag != AppointPatientRegisterCompleteFlag.CancelAppoint orderby appointPatientRegister.AppointDate select new { user, person, appointPatientRegister, appointRegisterAsbitem, asbitem, haveMedicalPackage, haveCustomerOrgGroup, customerOrg } );
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.CustomerOrgGroupName, 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; }
/// <summary>
/// 取消预约
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="UserFriendlyException"></exception>
[HttpPost("api/app/AppointPatientRegister/CancelAppoint")] public async Task CancelAppointAsync(AppointPatientRegisterIdInputDto input) { var appointPatientRegister = await _repository.GetAsync(o => o.AppointPatientRegisterId == input.AppointPatientRegisterId); if(appointPatientRegister.IsCharge == 'Y') { throw new UserFriendlyException("已收费不能取消"); } if (appointPatientRegister.CompleteFlag == AppointPatientRegisterCompleteFlag.Check) { throw new UserFriendlyException("已到检不能取消"); } if (appointPatientRegister.CompleteFlag == AppointPatientRegisterCompleteFlag.CancelAppoint) { throw new UserFriendlyException("已取消预约不能重复取消"); } appointPatientRegister.CompleteFlag = AppointPatientRegisterCompleteFlag.CancelAppoint; await _repository.UpdateAsync(appointPatientRegister);
} /// <summary>
/// 获取预约的组合项目
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[AllowAnonymous] [HttpPost("api/app/AppointPatientRegister/GetAppointRegisterAsbitemListById")] public async Task<List<AppointRegisterAsbitemDto>> 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 join itemType in await _itemTypeRepository.GetQueryableAsync() on asbitem.ItemTypeId equals itemType.ItemTypeId 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, DisplayOrder = asbitem.DisplayOrder, ItemTypeId = itemType.ItemTypeId, ItemTypeName = itemType.ItemTypeName, ItemTypeDisplayOrder = itemType.DisplayOrder, PayTypeFlag = appointRegisterAsbitem.PayTypeFlag }
).ToList();
List<Guid> asbitems = new List<Guid>(); 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(); } var itemTypes = await _itemTypeRepository.GetListAsync(); appointRegisterAsbitemDtos.ForEach(o => { if (asbitems.Where(x => x == o.AsbitemId).ToList().Any()) { o.IsBelongGroupPackage = 'Y'; } var itemType = itemTypes.Where(o => o.ItemTypeId == o.ItemTypeId).First(); itemType = itemTypes.Where(o => o.PathCode == itemType.PathCode.Substring(0, 5)).First(); o.ItemTypeId = itemType.ItemTypeId; o.ItemTypeDisplayOrder = itemType.DisplayOrder; }); appointRegisterAsbitemDtos = appointRegisterAsbitemDtos.OrderBy(o => o.ItemTypeDisplayOrder) .OrderBy(o => o.DisplayOrder).ToList(); return appointRegisterAsbitemDtos; }
/// <summary>
/// 获取单位预约病人
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("api/app/AppointPatientRegister/GetCustomerOrgAppointPatientRegisterByPersonId")] public async Task<PatientRegisterDto> GetCustomerOrgAppointPatientRegisterByPersonIdAsync(PersonIdInputDto input) { var patientRegisterDto = (from user in await _identityUserRepository.GetQueryableAsync() join person in await _personRepository.GetQueryableAsync() on user.Id equals person.PersonId join patient in await _patientRepository.GetQueryableAsync() on new { idNo = person.IdNo, phone = user.PhoneNumber } equals new { idNo = patient.IdNo, phone = patient.MobileTelephone } join patientRegister in await _patientRegisterRepository.GetQueryableAsync() on patient.PatientId equals patientRegister.PatientId join customerOrg in await _customerOrgRepository.GetQueryableAsync() on patientRegister.CustomerOrgId equals customerOrg.CustomerOrgId join customerOrgGroup in await _customerOrgGroupRepository.GetQueryableAsync() on patientRegister.CustomerOrgGroupId equals customerOrgGroup.CustomerOrgGroupId into canEmptyCustomerOrgGroup from haveCustomerOrgGroup in canEmptyCustomerOrgGroup.DefaultIfEmpty() where user.Id == input.PersonId && (patientRegister.CompleteFlag == PatientRegisterCompleteFlag.PreRegistration || patientRegister.CompleteFlag == PatientRegisterCompleteFlag.Registration) && patientRegister.MedicalStartDate >= DateTime.Now.Date.AddDays(-365) orderby patientRegister.MedicalStartDate descending select new PatientRegisterDto() { PatientRegisterId = patientRegister.PatientRegisterId, CustomerOrgId = customerOrg.CustomerOrgId, ChildCustomerOrgName = customerOrg.CustomerOrgName, CustomerOrgRegisterId = patientRegister.CustomerOrgRegisterId, CustomerOrgGroupId = patientRegister.CustomerOrgGroupId, CustomerOrgGroupName = haveCustomerOrgGroup == null?"": haveCustomerOrgGroup.CustomerOrgGroupName, Price = haveCustomerOrgGroup == null ? 0:haveCustomerOrgGroup.Price, CanAddMoney = haveCustomerOrgGroup == null ? 0 : haveCustomerOrgGroup.CanAddMoney, }).FirstOrDefault(); if (patientRegisterDto == null) { return patientRegisterDto; } var customerOrgEntity = await _customerOrgRepository.GetAsync(o => o.CustomerOrgId == patientRegisterDto.CustomerOrgId); customerOrgEntity = await _customerOrgRepository.GetAsync(o => o.PathCode == customerOrgEntity.PathCode.Substring(0, 5)); patientRegisterDto.CustomerOrgName = customerOrgEntity.CustomerOrgName;
var appointPatientRegisters = await _repository.GetListAsync(o => o.PersonId == input.PersonId && o.AppointDate >= DateTime.Now.Date && o.CustomerOrgRegisterId == patientRegisterDto.CustomerOrgRegisterId && o.CompleteFlag != AppointPatientRegisterCompleteFlag.CancelAppoint); if (appointPatientRegisters .Any()) { throw new UserFriendlyException("已有今天及之后的团检预约订单,必须先取消订单才能重新预约"); }
return patientRegisterDto; }
/// <summary>
/// 获取团检中个人备案项目
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("api/app/AppointPatientRegister/GetCheckTypeWithAsbitemsListByPatientRegisterId")] public async Task<List<MedicalPackageCheckTypeWithAsbitemsDto>> GetCheckTypeWithAsbitemsListByPatientRegisterIdAsync(PatientRegisterIdInputDto input) { //获取团检个人所有组合项目
var asbitems = (from registerCheck in await _registerCheckRepository.GetQueryableAsync() join registerCheckAsbitem in await _registerCheckAsbitemRepository.GetQueryableAsync() on registerCheck.RegisterCheckId equals registerCheckAsbitem.RegisterCheckId join asbitem in await _asbitemRepository.GetQueryableAsync() on registerCheckAsbitem.AsbitemId equals asbitem.AsbitemId where registerCheck.PatientRegisterId == input.PatientRegisterId select new MedicalPackageAsbitem() { ItemTypeId = asbitem.ItemTypeId, AsbitemId = asbitem.AsbitemId, AsbitemName = asbitem.AsbitemName, ShortName = asbitem.ShortName, Price = asbitem.Price, ForSexId = asbitem.ForSexId, //ForSexName = _cacheService.GetForSexNameAsync(asbitem.ForSexId).Result,
IsBeforeEat = asbitem.IsBeforeEat, ClinicalMeaning = asbitem.ClinicalMeaning, IsCheck = asbitem.IsCheck, Warn = asbitem.Warn, DiseaseScreeningTypeId = asbitem.DiseaseScreeningTypeId, SimpleCode = asbitem.SimpleCode, DisplayOrder = asbitem.DisplayOrder, } ).ToList();
//获取检查分类
var medicalPackageAsbitemDtos = new List<MedicalPackageCheckTypeWithAsbitemsDto>() { new MedicalPackageCheckTypeWithAsbitemsDto(){CheckTypeFlag = CheckTypeFlag.Regular,CheckTypeFlagName = "科室检查",DisplayOrder = 1}, new MedicalPackageCheckTypeWithAsbitemsDto(){CheckTypeFlag = CheckTypeFlag.Laboratory,CheckTypeFlagName = "检验",DisplayOrder = 2}, new MedicalPackageCheckTypeWithAsbitemsDto(){CheckTypeFlag =CheckTypeFlag.SpecialInspection,CheckTypeFlagName = "特检",DisplayOrder = 3}, new MedicalPackageCheckTypeWithAsbitemsDto(){CheckTypeFlag = CheckTypeFlag.Radiology,CheckTypeFlagName = "放射",DisplayOrder = 4} };
var itemTypes = await _itemTypeRepository.GetListAsync(); foreach (var asbitem in asbitems) { asbitem.ForSexName = await _cacheService.GetForSexNameAsync(asbitem.ForSexId); var itemType = itemTypes.Where(o => o.ItemTypeId == asbitem.ItemTypeId).Single(); if (itemType.PathCode.Length > 5) { itemType = itemTypes.Where(o => o.PathCode == itemType.PathCode.Substring(0, 5)).Single(); asbitem.ItemTypeId = itemType.ItemTypeId; } asbitem.CheckTypeFlag = itemType.CheckTypeFlag; } //设置每个分类包含的组合项目
foreach (var medicalPackageAsbitemDto in medicalPackageAsbitemDtos) { medicalPackageAsbitemDto.Asbitems = asbitems.Where(o => o.CheckTypeFlag == medicalPackageAsbitemDto.CheckTypeFlag).ToList();
}
return medicalPackageAsbitemDtos;
}
}}
|