|
|
|
@ -6,6 +6,7 @@ using Microsoft.EntityFrameworkCore.Metadata.Internal; |
|
|
|
using Microsoft.Extensions.Configuration; |
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
using NPOI.POIFS.Properties; |
|
|
|
using NPOI.SS.Formula.Functions; |
|
|
|
using NPOI.Util; |
|
|
|
using NUglify.Helpers; |
|
|
|
using Org.BouncyCastle.Asn1.Ocsp; |
|
|
|
@ -16,7 +17,9 @@ using Shentun.Peis.CustomerOrgs; |
|
|
|
using Shentun.Peis.Enums; |
|
|
|
using Shentun.Peis.LisRequests; |
|
|
|
using Shentun.Peis.Models; |
|
|
|
using Shentun.Peis.OcCheckTypeDetails; |
|
|
|
using Shentun.Peis.PatientOccupationalDiseases; |
|
|
|
using Shentun.Peis.PatientPoisons; |
|
|
|
using Shentun.Peis.PatientRegisterExters; |
|
|
|
using Shentun.Peis.Patients; |
|
|
|
using Shentun.Peis.PeisReports; |
|
|
|
@ -119,6 +122,12 @@ namespace Shentun.Peis.PatientRegisters |
|
|
|
private readonly PatientOccupationalDiseaseManager _patientOccupationalDiseaseManager; |
|
|
|
private readonly IRepository<ThirdInterface, Guid> _thirdInterfaceRepository; |
|
|
|
private readonly IRepository<CustomerOrgRegister, Guid> _customerOrgRegisterRepository; |
|
|
|
private readonly IRepository<OcCheckType, Guid> _ocCheckTypeRepository; |
|
|
|
private readonly IRepository<Poison, Guid> _poisonRepository; |
|
|
|
private readonly IRepository<OcCheckTypeDetail> _ocCheckTypeDetailRepository; |
|
|
|
private readonly IRepository<PatientOccupationalDisease, Guid> _patientOccupationalDiseaseRepository; |
|
|
|
private readonly IRepository<PatientPoison> _patientPoisonRepository; |
|
|
|
private readonly PatientPoisonManager _patientPoisonManager; |
|
|
|
public PatientRegisterAppService( |
|
|
|
IRepository<PatientRegister, Guid> repository, |
|
|
|
IRepository<Patient, Guid> patientRepository, |
|
|
|
@ -171,7 +180,13 @@ namespace Shentun.Peis.PatientRegisters |
|
|
|
IRepository<UserItemType> userItemTypeRepository, |
|
|
|
PatientOccupationalDiseaseManager patientOccupationalDiseaseManager, |
|
|
|
IRepository<ThirdInterface, Guid> thirdInterfaceRepository, |
|
|
|
IRepository<CustomerOrgRegister, Guid> customerOrgRegisterRepository) |
|
|
|
IRepository<CustomerOrgRegister, Guid> customerOrgRegisterRepository, |
|
|
|
IRepository<OcCheckType, Guid> ocCheckTypeRepository, |
|
|
|
IRepository<Poison, Guid> poisonRepository, |
|
|
|
IRepository<OcCheckTypeDetail> ocCheckTypeDetailRepository, |
|
|
|
IRepository<PatientOccupationalDisease, Guid> patientOccupationalDiseaseRepository, |
|
|
|
IRepository<PatientPoison> patientPoisonRepository, |
|
|
|
PatientPoisonManager patientPoisonManager) |
|
|
|
: base(repository) |
|
|
|
{ |
|
|
|
this._repository = repository; |
|
|
|
@ -226,6 +241,12 @@ namespace Shentun.Peis.PatientRegisters |
|
|
|
_patientOccupationalDiseaseManager = patientOccupationalDiseaseManager; |
|
|
|
_thirdInterfaceRepository = thirdInterfaceRepository; |
|
|
|
_customerOrgRegisterRepository = customerOrgRegisterRepository; |
|
|
|
_ocCheckTypeRepository = ocCheckTypeRepository; |
|
|
|
_poisonRepository = poisonRepository; |
|
|
|
_ocCheckTypeDetailRepository = ocCheckTypeDetailRepository; |
|
|
|
_patientOccupationalDiseaseRepository = patientOccupationalDiseaseRepository; |
|
|
|
_patientPoisonRepository = patientPoisonRepository; |
|
|
|
_patientPoisonManager = patientPoisonManager; |
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
/// 获取通过主键
|
|
|
|
@ -2416,6 +2437,80 @@ namespace Shentun.Peis.PatientRegisters |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("姓名不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#region 转换职业病信息
|
|
|
|
|
|
|
|
Guid ocCheckTypeId = Guid.Empty; |
|
|
|
List<Guid> poisonIds = new List<Guid>(); |
|
|
|
|
|
|
|
if (input.IsOccupationalDisease == 'Y') |
|
|
|
{ |
|
|
|
if (string.IsNullOrWhiteSpace(input.OcCheckTypeName)) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("职业病检查类别不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(input.JobType)) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("职业病工种不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
if (!input.Poisons.Any()) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("职业病毒害因素不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
#region 职业病检查类别
|
|
|
|
var ocCheckTypeEnt = await _ocCheckTypeRepository.FirstOrDefaultAsync(f => f.DisplayName == input.OcCheckTypeName); |
|
|
|
if (ocCheckTypeEnt == null) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("职业病检查类别名称不正确"); |
|
|
|
} |
|
|
|
|
|
|
|
ocCheckTypeId = ocCheckTypeEnt.Id; |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 职业病毒害因素
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var poisonItem in input.Poisons) |
|
|
|
{ |
|
|
|
var poisonEnt = await _poisonRepository.FirstOrDefaultAsync(f => f.DisplayName == poisonItem); |
|
|
|
if (poisonEnt == null) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("职业病毒害因素名称不正确"); |
|
|
|
} |
|
|
|
if (!poisonIds.Contains(poisonEnt.Id)) |
|
|
|
{ |
|
|
|
poisonIds.Add(poisonEnt.Id); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Guid? medicalTypeId; |
|
|
|
|
|
|
|
if (input.IsDefaultMedicalType == 'Y' && input.IsOccupationalDisease == 'Y') |
|
|
|
{ |
|
|
|
//人员登记检查类别
|
|
|
|
var systemMedicalTypeId = await _sysParmValueManager.GetSysParmValueAsync(input.MedicalCenterId, "patient_register_occ_check_id"); |
|
|
|
if (string.IsNullOrWhiteSpace(systemMedicalTypeId)) |
|
|
|
throw new UserFriendlyException("系统参数中未配置职业病检查的体检类别ID"); |
|
|
|
medicalTypeId = Guid.Parse(systemMedicalTypeId); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
medicalTypeId = await GetMedicalTypeIdByName(input.MedicalTypeName); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
//设置人员信息
|
|
|
|
Patient patient = null; |
|
|
|
Patient updatePatientEntity = new Patient() |
|
|
|
@ -2490,7 +2585,7 @@ namespace Shentun.Peis.PatientRegisters |
|
|
|
MaritalStatusId = updatePatientEntity.MaritalStatusId, |
|
|
|
MedicalCardNo = input.MedicalCardNo, |
|
|
|
MedicalPackageId = null, |
|
|
|
MedicalTypeId = await GetMedicalTypeIdByName(input.MedicalTypeName), |
|
|
|
MedicalTypeId = medicalTypeId, |
|
|
|
MedicalCenterId = input.MedicalCenterId, |
|
|
|
PatientId = patient.Id, |
|
|
|
PatientName = input.PatientName, |
|
|
|
@ -2521,6 +2616,44 @@ namespace Shentun.Peis.PatientRegisters |
|
|
|
StandardPrice = s.Asbitem.Price |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
#region 职业病业务 检索职业病对应的项目
|
|
|
|
|
|
|
|
if (input.IsOccupationalDisease == 'Y') |
|
|
|
{ |
|
|
|
//var ocCheckTypeDetailList = await _ocCheckTypeDetailRepository.GetListAsync(f => f.OcCheckTypeId == ocCheckTypeId && poisonIds.Contains(f.PoisonId));
|
|
|
|
var ocCheckTypeDetailList = from ocCheckTypeDetail in await _ocCheckTypeDetailRepository.GetQueryableAsync() |
|
|
|
join asbitem in await _asbitemRepository.GetQueryableAsync() on ocCheckTypeDetail.AsbitemId equals asbitem.Id |
|
|
|
where ocCheckTypeDetail.OcCheckTypeId == ocCheckTypeId && poisonIds.Contains(ocCheckTypeDetail.PoisonId) |
|
|
|
select new |
|
|
|
{ |
|
|
|
Amount = ocCheckTypeDetail.Amount, |
|
|
|
AsbitemId = ocCheckTypeDetail.AsbitemId, |
|
|
|
ChargePrice = ocCheckTypeDetail.Price, |
|
|
|
StandardPrice = asbitem.Price |
|
|
|
}; |
|
|
|
|
|
|
|
foreach (var item in ocCheckTypeDetailList) |
|
|
|
{ |
|
|
|
if (registerAsbitems.Where(m => m.AsbitemId == item.AsbitemId).Count() == 0) |
|
|
|
{ |
|
|
|
registerAsbitems.Add(new RegisterCheckAsbitem |
|
|
|
{ |
|
|
|
Amount = item.Amount, |
|
|
|
AsbitemId = item.AsbitemId, |
|
|
|
ChargePrice = item.ChargePrice, |
|
|
|
IsCharge = 'N', |
|
|
|
PatientRegisterId = patientRegister.Id, |
|
|
|
PayTypeFlag = PayTypeFlag.OrgPay, |
|
|
|
StandardPrice = item.StandardPrice |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
createRegisterCheckAsbitemEntity = await _registerAsbitemManager.UpdateManyAsync(patientRegister, registerAsbitems); |
|
|
|
|
|
|
|
if (createRegisterCheckAsbitemEntity != null) |
|
|
|
@ -2528,6 +2661,43 @@ namespace Shentun.Peis.PatientRegisters |
|
|
|
await UpdateRegisterChecks(createRegisterCheckAsbitemEntity); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#region 增加职业病信息
|
|
|
|
|
|
|
|
if (input.IsOccupationalDisease == 'Y') |
|
|
|
{ |
|
|
|
|
|
|
|
//基础信息
|
|
|
|
var patientOccupationalDiseaseEnt = new PatientOccupationalDisease |
|
|
|
{ |
|
|
|
JobType = input.JobType, |
|
|
|
OcCheckTypeId = ocCheckTypeId, |
|
|
|
RiskFactors = string.Join(",", input.Poisons), |
|
|
|
PatientRegisterId = patientRegister.Id |
|
|
|
}; |
|
|
|
|
|
|
|
patientOccupationalDiseaseEnt = _patientOccupationalDiseaseManager.CreateAsync(patientOccupationalDiseaseEnt); |
|
|
|
await _patientOccupationalDiseaseRepository.InsertAsync(patientOccupationalDiseaseEnt); |
|
|
|
|
|
|
|
//毒害因素
|
|
|
|
List<PatientPoison> patientPoisons = new List<PatientPoison>(); |
|
|
|
|
|
|
|
foreach (var poisonId in poisonIds) |
|
|
|
{ |
|
|
|
var patientPoisonEnt = new PatientPoison |
|
|
|
{ |
|
|
|
PatientRegisterId = patientRegister.Id, |
|
|
|
PoisonId = poisonId |
|
|
|
}; |
|
|
|
|
|
|
|
patientPoisonEnt = _patientPoisonManager.CreateAsync(patientPoisonEnt); |
|
|
|
|
|
|
|
patientPoisons.Add(patientPoisonEnt); |
|
|
|
} |
|
|
|
|
|
|
|
await _patientPoisonRepository.InsertManyAsync(patientPoisons); |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -3571,7 +3741,7 @@ namespace Shentun.Peis.PatientRegisters |
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet("api/app/PatientRegister/UpdatePatientRegisterBaseInfoByPatientRegisterId")] |
|
|
|
[HttpPost("api/app/PatientRegister/UpdatePatientRegisterBaseInfoByPatientRegisterId")] |
|
|
|
public async Task<PatientRegisterOrNoDto> UpdatePatientRegisterBaseInfoByPatientRegisterIdAsync(UpdatePatientRegisterBaseInfoByPatientRegisterIdInputDto input) |
|
|
|
{ |
|
|
|
PatientRegisterOrNoDto msg = new PatientRegisterOrNoDto(); |
|
|
|
|