|
|
|
@ -26,6 +26,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters |
|
|
|
private readonly IRepository<Nation> _nationRepository; |
|
|
|
private readonly SysParmValueManager _sysParmValueManager; |
|
|
|
private readonly IRepository<PrimarykeyBuilder> _primarykeyBuilderRepository; |
|
|
|
private readonly IRepository<Asbitem> _asbitemRepository; |
|
|
|
public AppointPatientRegisterManager(IRepository<AppointPatientRegister> repository, |
|
|
|
IRepository<IdentityUser> identityUserRepository, |
|
|
|
IdentityUserManager identityUserManager, |
|
|
|
@ -35,7 +36,8 @@ namespace Shentun.WebPeis.AppointPatientRegisters |
|
|
|
IRepository<CustomerOrgGroup> customerOrgGroupRepository, |
|
|
|
IRepository<MedicalPackage> medicalPackageRepository, |
|
|
|
IRepository<CustomerOrg> customerOrgRepository, |
|
|
|
IRepository<CustomerOrgRegister> customerOrgRegisterRepository |
|
|
|
IRepository<CustomerOrgRegister> customerOrgRegisterRepository, |
|
|
|
IRepository<Asbitem> asbitemRepository |
|
|
|
) |
|
|
|
{ |
|
|
|
_repository = repository; |
|
|
|
@ -48,6 +50,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters |
|
|
|
_medicalPackageRepository = medicalPackageRepository; |
|
|
|
_customerOrgRepository = customerOrgRepository; |
|
|
|
_customerOrgRegisterRepository = customerOrgRegisterRepository; |
|
|
|
_asbitemRepository = asbitemRepository; |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<AppointPatientRegister> CreateAsync(AppointPatientRegister entity) |
|
|
|
@ -65,8 +68,8 @@ namespace Shentun.WebPeis.AppointPatientRegisters |
|
|
|
Check.NotNull<Guid>(entity.PersonId, "人员ID"); |
|
|
|
Check.NotNull<Guid>(entity.MedicalCenterId, "体检中心"); |
|
|
|
Check.NotDefaultOrNull<Guid>(entity.CustomerOrgId, "单位"); |
|
|
|
Check.NotNull<DateTime>(entity.MedicalStartDate, "体检日期"); |
|
|
|
if(entity.MedicalStartDate < DateTime.Now.Date) |
|
|
|
Check.NotNull<DateTime>(entity.AppointDate, "体检日期"); |
|
|
|
if(entity.AppointDate < DateTime.Now.Date) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("预约日期不能小于当前日期"); |
|
|
|
} |
|
|
|
@ -135,20 +138,22 @@ namespace Shentun.WebPeis.AppointPatientRegisters |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("必须预约组合项目"); |
|
|
|
} |
|
|
|
var asbitems = await _asbitemRepository.GetListAsync(); |
|
|
|
foreach (var appointRegisterAsbitem in entity.AppointRegisterAsbitems) |
|
|
|
{ |
|
|
|
|
|
|
|
if(appointRegisterAsbitem.ChargePrice < 0) |
|
|
|
var asbitem = asbitems.Where(o => o.AsbitemId == appointRegisterAsbitem.AsbitemId).Single(); |
|
|
|
appointRegisterAsbitem.StandardPrice = asbitem.Price; |
|
|
|
if (appointRegisterAsbitem.ChargePrice < 0) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("价格不能小于0"); |
|
|
|
throw new UserFriendlyException($"{asbitem.AsbitemName}价格不能小于0"); |
|
|
|
} |
|
|
|
if (appointRegisterAsbitem.ChargePrice > 10000) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("价格不能大于10000"); |
|
|
|
throw new UserFriendlyException($"{asbitem.AsbitemName}价格不能大于10000"); |
|
|
|
} |
|
|
|
if (appointRegisterAsbitem.Amount < 1) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("数量不能小于1"); |
|
|
|
throw new UserFriendlyException($"{asbitem.AsbitemName}数量不能小于1"); |
|
|
|
} |
|
|
|
if (customerOrg.CustomerOrgId == GuidFlag.PersonCustomerOrgId) |
|
|
|
{ |
|
|
|
@ -161,9 +166,10 @@ namespace Shentun.WebPeis.AppointPatientRegisters |
|
|
|
if (appointRegisterAsbitem.PayTypeFlag != PayTypeFlag.PersonPay && |
|
|
|
appointRegisterAsbitem.PayTypeFlag != PayTypeFlag.OrgPay) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("支付类别错误"); |
|
|
|
throw new UserFriendlyException($"{asbitem.AsbitemName}支付类别错误"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
appointRegisterAsbitem.IsCharge = 'N'; |
|
|
|
} |
|
|
|
} |
|
|
|
|