diff --git a/src/Shentun.Peis.Domain.Shared/Enums/MaritalStatusFlag.cs b/src/Shentun.Peis.Domain.Shared/Enums/MaritalStatusFlag.cs
index 4f77a70..af9f309 100644
--- a/src/Shentun.Peis.Domain.Shared/Enums/MaritalStatusFlag.cs
+++ b/src/Shentun.Peis.Domain.Shared/Enums/MaritalStatusFlag.cs
@@ -25,6 +25,12 @@ namespace Shentun.Peis.Enums
///
[Description("离异")]
public const char Divorce = '2';
+
+ [Description("丧偶")]
+ public const char Widowed = '3';
+
+ [Description("离异或丧偶")]
+ public const char DivorceOrWidowed = '4';
///
/// 未知
///
diff --git a/src/Shentun.Peis.Domain/DataHelper.cs b/src/Shentun.Peis.Domain/DataHelper.cs
index 3f5aacb..52cf346 100644
--- a/src/Shentun.Peis.Domain/DataHelper.cs
+++ b/src/Shentun.Peis.Domain/DataHelper.cs
@@ -8,6 +8,7 @@ using System.Threading.Tasks;
using Volo.Abp;
using Shentun.Peis.Models;
using TencentCloud.Bda.V20200324.Models;
+using Shentun.Peis.Enums;
namespace Shentun.Peis
{
@@ -480,7 +481,7 @@ namespace Shentun.Peis
///
public static void CheckGuidIsDefaultValue(Guid? value, string parameterName, string ExceptionMessage = "不能为默认值00000000-0000-0000-0000-000000000000")
{
- if (value == Guid.Empty)
+ if (value == Guid.Empty || value == default(Guid))
{
throw new ArgumentException($"{parameterName}{ExceptionMessage}");
}
@@ -517,6 +518,33 @@ namespace Shentun.Peis
}
}
+ public static void CheckSex(char value)
+ {
+ if (value.ToString() != SexFlag.Male && value.ToString() != SexFlag.Female && value.ToString() != SexFlag.UnKnown)
+ {
+ throw new ArgumentException($"性别参数不正确");
+ }
+ }
+
+ public static void CheckForSex(char value)
+ {
+ if (value != ForSexFlag.Male && value != ForSexFlag.Female && value != ForSexFlag.All)
+ {
+ throw new ArgumentException($"性别参数不正确");
+ }
+ }
+
+ public static void CheckMaritalStatus(char value)
+ {
+ if (value != MaritalStatusFlag.UnMarried && value != MaritalStatusFlag.Married &&
+ value != MaritalStatusFlag.Divorce && value != MaritalStatusFlag.Widowed &&
+ value != MaritalStatusFlag.DivorceOrWidowed &&
+ value != MaritalStatusFlag.UnMarried)
+ {
+ throw new ArgumentException($"婚姻状况参数不正确");
+ }
+ }
+
#endregion
}
diff --git a/src/Shentun.Peis.Domain/PatientRegisters/PatientRegister.cs b/src/Shentun.Peis.Domain/PatientRegisters/PatientRegister.cs
index 4bd0425..a9d88cc 100644
--- a/src/Shentun.Peis.Domain/PatientRegisters/PatientRegister.cs
+++ b/src/Shentun.Peis.Domain/PatientRegisters/PatientRegister.cs
@@ -85,7 +85,7 @@ namespace Shentun.Peis.Models
///
[Column("sex_id")]
[MaxLength(1)]
- public char? SexId { get; set; }
+ public char SexId { get; set; }
///
/// 出生日期
///
@@ -113,7 +113,7 @@ namespace Shentun.Peis.Models
///
[Column("marital_status_id")]
[MaxLength(1)]
- public char? MaritalStatusId { get; set; }
+ public char MaritalStatusId { get; set; }
///
/// 体检类别
///
@@ -172,25 +172,25 @@ namespace Shentun.Peis.Models
/// 体检报告打印次数
///
[Column("report_print_times")]
- public short? ReportPrintTimes { get; set; }
+ public short ReportPrintTimes { get; set; }
///
/// 是否上传到WEB
///
[Column("is_upload")]
[MaxLength(1)]
- public char? IsUpload { get; set; }
+ public char IsUpload { get; set; }
///
/// 完成标志(0 预登记 1正式登记 2部分已检 3已总检)
///
[Column("complete_flag")]
[MaxLength(1)]
- public char? CompleteFlag { get; set; }
+ public char CompleteFlag { get; set; }
///
/// 体检开始标志
///
[Column("is_medical_start")]
[MaxLength(1)]
- public char? IsMedicalStart { get; set; }
+ public char IsMedicalStart { get; set; }
///
/// 体检开始日期
///
@@ -201,7 +201,7 @@ namespace Shentun.Peis.Models
///
[Column("is_recover_guide")]
[MaxLength(1)]
- public char? IsRecoverGuide { get; set; }
+ public char IsRecoverGuide { get; set; }
///
/// 总检日期
///
@@ -218,7 +218,7 @@ namespace Shentun.Peis.Models
///
[Column("is_audit")]
[MaxLength(1)]
- public char? IsAudit { get; set; }
+ public char IsAudit { get; set; }
///
/// 审核医生
///
@@ -241,19 +241,19 @@ namespace Shentun.Peis.Models
///
[Column("is_name_hide")]
[MaxLength(1)]
- public char? IsNameHide { get; set; }
+ public char IsNameHide { get; set; }
///
/// 电话随访
///
[Column("is_phone_follow")]
[MaxLength(1)]
- public char? IsPhoneFollow { get; set; }
+ public char IsPhoneFollow { get; set; }
///
/// vip客户
///
[Column("is_vip")]
[MaxLength(1)]
- public char? IsVip { get; set; }
+ public char IsVip { get; set; }
///
/// 附加第三方信息
///
@@ -264,7 +264,7 @@ namespace Shentun.Peis.Models
/// 指引单打印次数
///
[Column("guide_print_times")]
- public short? GuidePrintTimes { get; set; }
+ public short GuidePrintTimes { get; set; }
///
/// 备注
///
diff --git a/src/Shentun.Peis.Domain/PatientRegisters/PatientRegisterManager.cs b/src/Shentun.Peis.Domain/PatientRegisters/PatientRegisterManager.cs
index 332e344..3d33f71 100644
--- a/src/Shentun.Peis.Domain/PatientRegisters/PatientRegisterManager.cs
+++ b/src/Shentun.Peis.Domain/PatientRegisters/PatientRegisterManager.cs
@@ -42,6 +42,12 @@ namespace Shentun.Peis.PatientRegisters
private readonly IRepository _repository;
private readonly IRepository _customerOrgRepository;
+ private readonly IRepository _customerOrgGroupRepository;
+ private readonly IRepository _medicalTypeRepository;
+ private readonly IRepository _personnelTypeRepository;
+ private readonly IRepository _medicalPackageRepository;
+ private readonly IRepository _medicalConclusionRepository;
+ private readonly IRepository _sexHormoneTermRepository;
private readonly IRepository _primarykeyBuilderRepository;
private readonly IRepository _patientRepository;
private readonly IRepository _registerAsbitemRepository;
@@ -64,6 +70,12 @@ namespace Shentun.Peis.PatientRegisters
public PatientRegisterManager(
IRepository repository,
+ IRepository _customerOrgGroupRepository,
+ IRepository _medicalTypeRepository,
+ IRepository _personnelTypeRepository,
+ IRepository _medicalPackageRepository,
+ IRepository _medicalConclusionRepository,
+ IRepository _sexHormoneTermRepository,
IRepository sysParmValueRepository,
IRepository customerOrgRepository,
IRepository primarykeyBuilderRepository,
@@ -248,7 +260,198 @@ namespace Shentun.Peis.PatientRegisters
return await _repository.InsertAsync(patientRegisterEnt, true);
}
+ public async Task 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))
+ {
+
+ }
+
+ }
///
/// 更新
///
diff --git a/src/Shentun.Peis.Domain/Patients/Patient.cs b/src/Shentun.Peis.Domain/Patients/Patient.cs
index 000467c..8e6bf8a 100644
--- a/src/Shentun.Peis.Domain/Patients/Patient.cs
+++ b/src/Shentun.Peis.Domain/Patients/Patient.cs
@@ -50,13 +50,13 @@ namespace Shentun.Peis.Models
///
[Column("sex_id")]
[MaxLength(1)]
- public char? SexId { get; set; }
+ public char SexId { get; set; }
///
/// 婚姻状况
///
[Column("marital_status_id")]
[MaxLength(1)]
- public char? MaritalStatusId { get; set; }
+ public char MaritalStatusId { get; set; }
///
/// 出生日期
///
diff --git a/src/Shentun.Peis.Domain/Patients/PatientManager.cs b/src/Shentun.Peis.Domain/Patients/PatientManager.cs
index abb91f6..0485507 100644
--- a/src/Shentun.Peis.Domain/Patients/PatientManager.cs
+++ b/src/Shentun.Peis.Domain/Patients/PatientManager.cs
@@ -250,5 +250,16 @@ namespace Shentun.Peis.Patients
return false;
else return true;
}
+
+ private void Verify(Patient entity)
+ {
+ DataHelper.CheckEntityIsNull(entity);
+ //DataHelper.CheckStringIsNull(entity.PatientNo, "病人号");
+ DataHelper.CheckStringIsNull(entity.DisplayName, "姓名");
+ DataHelper.CheckSex(entity.SexId);
+ DataHelper.CheckMaritalStatus(entity.MaritalStatusId);
+
+
+ }
}
}