|
|
|
@ -75,6 +75,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters |
|
|
|
private readonly WeChatOrderAppService _weChatOrderAppService; |
|
|
|
private readonly IRepository<Charge> _chargeRepository; |
|
|
|
private readonly IRepository<ChargePay> _chargePayRepository; |
|
|
|
private readonly IRepository<ChargeAsbitem> _chargeAsbitemRepository; |
|
|
|
public AppointPatientRegisterAppService(IRepository<AppointPatientRegister> repository, |
|
|
|
CacheService cacheService, |
|
|
|
IRepository<ItemType> itemTypeRepository, |
|
|
|
@ -111,7 +112,8 @@ namespace Shentun.WebPeis.AppointPatientRegisters |
|
|
|
IRepository<AppointScheduleTime> appointScheduleTimeRepository, |
|
|
|
WeChatOrderAppService weChatOrderAppService, |
|
|
|
IRepository<Charge> chargeRepository, |
|
|
|
IRepository<ChargePay> chargePayRepository) |
|
|
|
IRepository<ChargePay> chargePayRepository, |
|
|
|
IRepository<ChargeAsbitem> chargeAsbitemRepository) |
|
|
|
{ |
|
|
|
_repository = repository; |
|
|
|
_cacheService = cacheService; |
|
|
|
@ -151,9 +153,10 @@ namespace Shentun.WebPeis.AppointPatientRegisters |
|
|
|
_weChatOrderAppService = weChatOrderAppService; |
|
|
|
_chargeRepository = chargeRepository; |
|
|
|
_chargePayRepository = chargePayRepository; |
|
|
|
_chargeAsbitemRepository = chargeAsbitemRepository; |
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
/// 创建预约,小程序使用
|
|
|
|
/// 创建预约,小程序使用 部分单位跟个人
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
@ -191,151 +194,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters |
|
|
|
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 && |
|
|
|
appointPatientRegister.CustomerOrgId == GuidFlag.PersonCustomerOrgId |
|
|
|
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, |
|
|
|
ChargeFlag = o.FirstOrDefault().appointPatientRegister.ChargeFlag, |
|
|
|
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>
|
|
|
|
@ -420,7 +279,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 取消预约
|
|
|
|
/// 取消预约 收费的会退款
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
@ -467,96 +326,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
/// 获取预约的组合项目通过预约ID
|
|
|
|
/// </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>
|
|
|
|
/// 获取预约的人员信息通过备单登记ID
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[AllowAnonymous] |
|
|
|
[HttpPost("api/app/AppointPatientRegister/GetByPatientRegisterId")] |
|
|
|
public async Task<AppointPatientRegisterDto> GetByPatientRegisterIdAsync(PatientRegisterIdInputDto input) |
|
|
|
{ |
|
|
|
if (input == null) throw new UserFriendlyException("参数不能为空"); |
|
|
|
var appointRegister = await _repository.FindAsync(o => o.PatientRegisterId == input.PatientRegisterId && o.CompleteFlag == AppointPatientRegisterCompleteFlag.Appoint); |
|
|
|
if (appointRegister == null) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("没有预约的人员信息"); |
|
|
|
} |
|
|
|
var AppointPatientRegisterDto = new AppointPatientRegisterDto() |
|
|
|
{ |
|
|
|
AppointPatientRegisterId = appointRegister.AppointPatientRegisterId |
|
|
|
}; |
|
|
|
return AppointPatientRegisterDto; |
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
/// 获取单位预约病人
|
|
|
|
/// </summary>
|
|
|
|
@ -1360,5 +1130,270 @@ namespace Shentun.WebPeis.AppointPatientRegisters |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#region 提供给体检系统调用
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取预约的组合项目通过预约ID
|
|
|
|
/// </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; |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
#region 获取收费明细数据,有就赋值
|
|
|
|
|
|
|
|
var chargeAsbitemDetail = (from charge in await _chargeRepository.GetQueryableAsync() |
|
|
|
join chargeAsbitem in await _chargeAsbitemRepository.GetQueryableAsync() on charge.AppointPatientRegisterId equals input.AppointPatientRegisterId |
|
|
|
where charge.ChargeFlag == '0' |
|
|
|
select new |
|
|
|
{ |
|
|
|
asbitemId = chargeAsbitem.AsbitemId, |
|
|
|
chargeAsbitemId = chargeAsbitem.ChargeAsbitemId |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
appointRegisterAsbitemDtos.ForEach(o => |
|
|
|
{ |
|
|
|
var chargeAsbitemEnt = chargeAsbitemDetail.FirstOrDefault(x => x.asbitemId == o.AsbitemId); |
|
|
|
if (chargeAsbitemEnt != null) |
|
|
|
{ |
|
|
|
o.ChargeAsbitemId = chargeAsbitemEnt.chargeAsbitemId; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
appointRegisterAsbitemDtos = appointRegisterAsbitemDtos.OrderBy(o => o.ItemTypeDisplayOrder) |
|
|
|
.OrderBy(o => o.DisplayOrder).ToList(); |
|
|
|
return appointRegisterAsbitemDtos; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取预约的人员信息通过备单登记ID
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[AllowAnonymous] |
|
|
|
[HttpPost("api/app/AppointPatientRegister/GetByPatientRegisterId")] |
|
|
|
public async Task<AppointPatientRegisterDto> GetByPatientRegisterIdAsync(PatientRegisterIdInputDto input) |
|
|
|
{ |
|
|
|
if (input == null) throw new UserFriendlyException("参数不能为空"); |
|
|
|
var appointRegister = await _repository.FindAsync(o => o.PatientRegisterId == input.PatientRegisterId && o.CompleteFlag == AppointPatientRegisterCompleteFlag.Appoint); |
|
|
|
if (appointRegister == null) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("没有预约的人员信息"); |
|
|
|
} |
|
|
|
var AppointPatientRegisterDto = new AppointPatientRegisterDto() |
|
|
|
{ |
|
|
|
AppointPatientRegisterId = appointRegister.AppointPatientRegisterId |
|
|
|
}; |
|
|
|
return AppointPatientRegisterDto; |
|
|
|
} |
|
|
|
|
|
|
|
/// <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 && |
|
|
|
appointPatientRegister.CustomerOrgId == GuidFlag.PersonCustomerOrgId |
|
|
|
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, |
|
|
|
ChargeFlag = o.FirstOrDefault().appointPatientRegister.ChargeFlag, |
|
|
|
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; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
} |