|
|
|
@ -42,6 +42,12 @@ namespace Shentun.Peis.PatientRegisters |
|
|
|
private readonly IRepository<PatientRegister, Guid> _repository; |
|
|
|
|
|
|
|
private readonly IRepository<CustomerOrg, Guid> _customerOrgRepository; |
|
|
|
private readonly IRepository<CustomerOrgGroup, Guid> _customerOrgGroupRepository; |
|
|
|
private readonly IRepository<MedicalType, Guid> _medicalTypeRepository; |
|
|
|
private readonly IRepository<PersonnelType, Guid> _personnelTypeRepository; |
|
|
|
private readonly IRepository<MedicalPackage, Guid> _medicalPackageRepository; |
|
|
|
private readonly IRepository<MedicalConclusion, Guid> _medicalConclusionRepository; |
|
|
|
private readonly IRepository<SexHormoneTerm, Guid> _sexHormoneTermRepository; |
|
|
|
private readonly IRepository<PrimarykeyBuilder> _primarykeyBuilderRepository; |
|
|
|
private readonly IRepository<Patient, Guid> _patientRepository; |
|
|
|
private readonly IRepository<RegisterAsbitem, Guid> _registerAsbitemRepository; |
|
|
|
@ -64,6 +70,12 @@ namespace Shentun.Peis.PatientRegisters |
|
|
|
|
|
|
|
public PatientRegisterManager( |
|
|
|
IRepository<PatientRegister, Guid> repository, |
|
|
|
IRepository<CustomerOrgGroup, Guid> _customerOrgGroupRepository, |
|
|
|
IRepository<MedicalType, Guid> _medicalTypeRepository, |
|
|
|
IRepository<PersonnelType, Guid> _personnelTypeRepository, |
|
|
|
IRepository<MedicalPackage, Guid> _medicalPackageRepository, |
|
|
|
IRepository<MedicalConclusion, Guid> _medicalConclusionRepository, |
|
|
|
IRepository<SexHormoneTerm, Guid> _sexHormoneTermRepository, |
|
|
|
IRepository<SysParmValue> sysParmValueRepository, |
|
|
|
IRepository<CustomerOrg, Guid> customerOrgRepository, |
|
|
|
IRepository<PrimarykeyBuilder> primarykeyBuilderRepository, |
|
|
|
@ -248,7 +260,198 @@ namespace Shentun.Peis.PatientRegisters |
|
|
|
return await _repository.InsertAsync(patientRegisterEnt, true); |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<PatientRegister> CreateAsync2(PatientRegister entity) |
|
|
|
{ |
|
|
|
Verify(entity); |
|
|
|
if (entity.IsVip == default(char)) |
|
|
|
{ |
|
|
|
entity.IsVip = 'N'; |
|
|
|
} |
|
|
|
DataHelper.CheckCharIsYOrN(entity.IsVip, "VIP标志"); |
|
|
|
if (entity.IsUpload == default(char)) |
|
|
|
{ |
|
|
|
entity.IsUpload = 'N'; |
|
|
|
} |
|
|
|
DataHelper.CheckCharIsYOrN(entity.IsUpload, "上传标志"); |
|
|
|
if (entity.IsNameHide == default(char)) |
|
|
|
{ |
|
|
|
entity.IsNameHide = 'N'; |
|
|
|
} |
|
|
|
DataHelper.CheckCharIsYOrN(entity.IsNameHide, "姓名隐藏"); |
|
|
|
if (entity.IsPhoneFollow == default(char)) |
|
|
|
{ |
|
|
|
entity.IsPhoneFollow = 'N'; |
|
|
|
} |
|
|
|
DataHelper.CheckCharIsYOrN(entity.IsPhoneFollow, "随访标志"); |
|
|
|
if (entity.IsMedicalStart == default(char)) |
|
|
|
{ |
|
|
|
entity.IsMedicalStart = 'N'; |
|
|
|
} |
|
|
|
DataHelper.CheckCharIsYOrN(entity.IsMedicalStart, "体检开始标志"); |
|
|
|
if (entity.IsRecoverGuide == default(char)) |
|
|
|
{ |
|
|
|
entity.IsRecoverGuide = 'N'; |
|
|
|
} |
|
|
|
DataHelper.CheckCharIsYOrN(entity.IsRecoverGuide, "指引单回收标志"); |
|
|
|
|
|
|
|
if (entity.CompleteFlag == default(char)) |
|
|
|
{ |
|
|
|
entity.CompleteFlag = PatientRegisterCompleteFlag.PreRegistration; |
|
|
|
} |
|
|
|
var completeFlagByte = (byte)entity.CompleteFlag; |
|
|
|
if (completeFlagByte < 0 || completeFlagByte > 3) |
|
|
|
{ |
|
|
|
throw new ArgumentException("完成标志错误"); |
|
|
|
} |
|
|
|
|
|
|
|
if (entity.IsAudit == default(char)) |
|
|
|
{ |
|
|
|
entity.IsAudit = 'N'; |
|
|
|
} |
|
|
|
DataHelper.CheckCharIsYOrN(entity.IsAudit, "审核标志"); |
|
|
|
|
|
|
|
var patientRegisterNo = entity.PatientRegisterNo; |
|
|
|
if (string.IsNullOrWhiteSpace(patientRegisterNo)) |
|
|
|
{ |
|
|
|
patientRegisterNo = await CreatePatientRegisterNo(entity.OrganizationUnitId.Value); |
|
|
|
} |
|
|
|
if(entity.MedicalTimes == 0) |
|
|
|
{ |
|
|
|
entity.MedicalTimes = await GetPatientCount(entity.PatientId); |
|
|
|
} |
|
|
|
var patientRegisterEnt = new PatientRegister(_guidGenerator.Create()) |
|
|
|
{ |
|
|
|
Age = entity.Age, |
|
|
|
AuditDate = entity.AuditDate, |
|
|
|
AuditDoctor = entity.AuditDoctor, |
|
|
|
BirthDate = entity.BirthDate, |
|
|
|
CompleteFlag = entity.CompleteFlag, |
|
|
|
CustomerOrgGroupId = entity.CustomerOrgGroupId, |
|
|
|
CustomerOrgId = entity.CustomerOrgId, |
|
|
|
CustomerOrgRegisterId = entity.CustomerOrgRegisterId, |
|
|
|
GuidePrintTimes = entity.GuidePrintTimes, |
|
|
|
InterposeMeasure = entity.InterposeMeasure, |
|
|
|
IsAudit = entity.IsAudit, |
|
|
|
IsLock = entity.IsLock, |
|
|
|
IsMedicalStart = entity.IsMedicalStart, |
|
|
|
IsNameHide = entity.IsNameHide, |
|
|
|
IsPhoneFollow = entity.IsPhoneFollow, |
|
|
|
IsRecoverGuide = entity.IsRecoverGuide, |
|
|
|
IsUpload = entity.IsUpload, |
|
|
|
IsVip = entity.IsVip, |
|
|
|
JobCardNo = entity.JobCardNo, |
|
|
|
JobPost = entity.JobPost, |
|
|
|
JobTitle = entity.JobTitle, |
|
|
|
MaritalStatusId = entity.MaritalStatusId, |
|
|
|
MedicalCardNo = entity.MedicalCardNo, |
|
|
|
MedicalConclusionId = entity.MedicalConclusionId, |
|
|
|
MedicalPackageId = entity.MedicalPackageId, |
|
|
|
MedicalStartDate = entity.MedicalStartDate, |
|
|
|
MedicalTimes = entity.MedicalTimes, |
|
|
|
MedicalTypeId = entity.MedicalTypeId, |
|
|
|
OrganizationUnitId = entity.OrganizationUnitId, |
|
|
|
PatientId = entity.PatientId, |
|
|
|
PatientName = entity.PatientName, |
|
|
|
PatientRegisterNo = patientRegisterNo, |
|
|
|
PersonnelTypeId = entity.PersonnelTypeId, |
|
|
|
Photo = entity.Photo, |
|
|
|
Remark = entity.Remark, |
|
|
|
ReportPrintTimes = entity.ReportPrintTimes, |
|
|
|
Salesman = entity.Salesman, |
|
|
|
SexHormoneTermId = entity.SexHormoneTermId, |
|
|
|
SexId = entity.SexId, |
|
|
|
SummaryDate = entity.SummaryDate, |
|
|
|
SummaryDoctor = entity.SummaryDoctor, |
|
|
|
ThirdInfo = entity.ThirdInfo |
|
|
|
}; |
|
|
|
return patientRegisterEnt; |
|
|
|
} |
|
|
|
private async void Verify(PatientRegister entity) |
|
|
|
{ |
|
|
|
DataHelper.CheckEntityIsNull(entity); |
|
|
|
DataHelper.CheckGuidIsDefaultValue(entity.PatientId, "病人ID"); |
|
|
|
DataHelper.CheckStringIsNull(entity.PatientName, "姓名"); |
|
|
|
DataHelper.CheckGuidIsDefaultValue(entity.OrganizationUnitId, "单位ID"); |
|
|
|
DataHelper.CheckGuidIsDefaultValue(entity.CustomerOrgId, "客户单位ID"); |
|
|
|
DataHelper.CheckSex(entity.SexId); |
|
|
|
DataHelper.CheckMaritalStatus(entity.MaritalStatusId); |
|
|
|
if (entity.MedicalTimes < 0) |
|
|
|
{ |
|
|
|
throw new ArgumentException("体检次数必须大于等于0"); |
|
|
|
} |
|
|
|
if (entity.Age <= 0) |
|
|
|
{ |
|
|
|
throw new ArgumentException("年龄不能小于等于0"); |
|
|
|
} |
|
|
|
|
|
|
|
if (entity.GuidePrintTimes < 0) |
|
|
|
{ |
|
|
|
throw new ArgumentException("指引单打印次数不能小于0"); |
|
|
|
} |
|
|
|
|
|
|
|
if (entity.ReportPrintTimes < 0) |
|
|
|
{ |
|
|
|
throw new ArgumentException("报告单打印次数不能小于0"); |
|
|
|
} |
|
|
|
if(entity.CustomerOrgGroupId != Guid.Empty && entity.CustomerOrgGroupId != default(Guid)) |
|
|
|
{ |
|
|
|
if( await _customerOrgGroupRepository.GetQueryableAsync().Result. |
|
|
|
Where(o=>o.Id == entity.CustomerOrgGroupId).CountAsync() == 0) |
|
|
|
{ |
|
|
|
throw new ArgumentException("单位分组ID不存在"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (entity.MedicalPackageId != Guid.Empty && entity.MedicalPackageId != default(Guid)) |
|
|
|
{ |
|
|
|
if (await _medicalPackageRepository.GetQueryableAsync().Result. |
|
|
|
Where(o => o.Id == entity.MedicalPackageId).CountAsync() == 0) |
|
|
|
{ |
|
|
|
throw new ArgumentException("套餐ID不存在"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (entity.MedicalTypeId != Guid.Empty && entity.MedicalTypeId != default(Guid)) |
|
|
|
{ |
|
|
|
if (await _medicalTypeRepository.GetQueryableAsync().Result. |
|
|
|
Where(o => o.Id == entity.MedicalTypeId).CountAsync() == 0) |
|
|
|
{ |
|
|
|
throw new ArgumentException("体检类别ID不存在"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (entity.PersonnelTypeId != Guid.Empty && entity.PersonnelTypeId != default(Guid)) |
|
|
|
{ |
|
|
|
if (await _personnelTypeRepository.GetQueryableAsync().Result. |
|
|
|
Where(o => o.Id == entity.PersonnelTypeId).CountAsync() == 0) |
|
|
|
{ |
|
|
|
throw new ArgumentException("人员类别ID不存在"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (entity.MedicalConclusionId != Guid.Empty && entity.MedicalConclusionId != default(Guid)) |
|
|
|
{ |
|
|
|
if (await _medicalConclusionRepository.GetQueryableAsync().Result. |
|
|
|
Where(o => o.Id == entity.MedicalConclusionId).CountAsync() == 0) |
|
|
|
{ |
|
|
|
throw new ArgumentException("体检结论ID不存在"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (entity.SexHormoneTermId != Guid.Empty && entity.SexHormoneTermId != default(Guid)) |
|
|
|
{ |
|
|
|
if (await _sexHormoneTermRepository.GetQueryableAsync().Result. |
|
|
|
Where(o => o.Id == entity.SexHormoneTermId).CountAsync() == 0) |
|
|
|
{ |
|
|
|
throw new ArgumentException("性激素期限ID不存在"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if((entity.Age == 0 || entity.Age == null)) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
/// 更新
|
|
|
|
/// </summary>
|
|
|
|
|