|
|
|
@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc; |
|
|
|
using Shentun.WebPeis.AppointRegisterAsbitems; |
|
|
|
using Shentun.WebPeis.CustomerOrgs; |
|
|
|
using Shentun.WebPeis.Models; |
|
|
|
using Shentun.WebPeis.OrganizationUnits; |
|
|
|
using System; |
|
|
|
using System.Collections; |
|
|
|
using System.Collections.Generic; |
|
|
|
@ -38,6 +39,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters |
|
|
|
private readonly CacheService _cacheService; |
|
|
|
private readonly AppointPatientRegisterManager _appointPatientRegisterManager; |
|
|
|
private readonly CustomerOrgManager _customerOrgManager; |
|
|
|
private readonly WebPeisOrganizationUnitManager _webPeisOrganizationUnitManager; |
|
|
|
public AppointPatientRegisterAppService(IRepository<AppointPatientRegister> repository, |
|
|
|
CacheService cacheService, |
|
|
|
IRepository<ItemType> itemTypeRepository, |
|
|
|
@ -51,7 +53,8 @@ namespace Shentun.WebPeis.AppointPatientRegisters |
|
|
|
IRepository<Asbitem> asbitemRepository, |
|
|
|
IRepository<CustomerOrg> customerOrgRepository, |
|
|
|
IRepository<MedicalPackageDetail> medicalPackageDetailRepository, |
|
|
|
IRepository<CustomerOrgGroupDetail> customerOrgGroupDetailRepository |
|
|
|
IRepository<CustomerOrgGroupDetail> customerOrgGroupDetailRepository, |
|
|
|
WebPeisOrganizationUnitManager webPeisOrganizationUnitManager |
|
|
|
) |
|
|
|
{ |
|
|
|
_repository = repository; |
|
|
|
@ -68,6 +71,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters |
|
|
|
_customerOrgRepository = customerOrgRepository; |
|
|
|
_medicalPackageDetailRepository = medicalPackageDetailRepository; |
|
|
|
_customerOrgGroupDetailRepository = customerOrgGroupDetailRepository; |
|
|
|
_webPeisOrganizationUnitManager = webPeisOrganizationUnitManager; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@ -77,6 +81,23 @@ namespace Shentun.WebPeis.AppointPatientRegisters |
|
|
|
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); |
|
|
|
@ -84,10 +105,42 @@ namespace Shentun.WebPeis.AppointPatientRegisters |
|
|
|
} |
|
|
|
|
|
|
|
[HttpPost("api/app/AppointPatientRegister/GetListByIdNoOrMobilePhone")] |
|
|
|
public async Task<List<AppointPatientRegisterDto>> GetListByIdNoOrMobilePhoneAsync(IdNoOrMobilePhoneInputDto input) |
|
|
|
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("手机号和身份证必须至少填一个"); |
|
|
|
@ -109,7 +162,9 @@ namespace Shentun.WebPeis.AppointPatientRegisters |
|
|
|
on appointRegisterAsbitem.AsbitemId equals asbitem.AsbitemId |
|
|
|
join customerOrg in await _customerOrgRepository.GetQueryableAsync() |
|
|
|
on appointPatientRegister.CustomerOrgId equals customerOrg.CustomerOrgId |
|
|
|
where appointPatientRegister.AppointDate >= DateTime.Now.Date.AddDays(-10) |
|
|
|
where appointPatientRegister.MedicalCenterId == medicalCenterId && |
|
|
|
appointPatientRegister.AppointDate >= input.AppointStartDate && |
|
|
|
appointPatientRegister.AppointDate < input.AppointStopDate |
|
|
|
orderby appointPatientRegister.AppointDate |
|
|
|
select new |
|
|
|
{ |
|
|
|
|