Browse Source

项目结果匹配、参考范围

bjmzak
wxd 2 years ago
parent
commit
3b2e39090a
  1. 16
      src/Shentun.Peis.Application/ItemResultMatchs/ItemResultMatchAppService.cs
  2. 2
      src/Shentun.Peis.Domain/DataHelper.cs
  3. 25
      src/Shentun.Peis.Domain/ItemResultMatchs/ItemResultMatchManager.cs
  4. 2
      src/Shentun.Peis.Domain/ItemResultTemplates/ItemResultTemplateManager.cs
  5. 85
      src/Shentun.Peis.Domain/ReferenceRanges/ReferenceRangeManager.cs

16
src/Shentun.Peis.Application/ItemResultMatchs/ItemResultMatchAppService.cs

@ -53,11 +53,6 @@ namespace Shentun.Peis.ItemResultMatchs
public override async Task<ItemResultMatchDto> GetAsync(Guid id)
{
var entity = await Repository.FindAsync(o => o.Id == id);
//throw new Exception("标准异常测试");
//throw new BusinessException("业务异常测试");
//throw new UserFriendlyException("友好异常测试");
//throw new EntityNotFoundException("未发现实体异常测试");
//return null;
if (entity == null)
return null;
return ObjectMapper.Map<ItemResultMatch, ItemResultMatchDto>(entity);
@ -158,16 +153,7 @@ namespace Shentun.Peis.ItemResultMatchs
/// <summary>
/// 修改排序 相邻之间
/// </summary>
/// <param name="id">需要修改的ID</param>
/// <param name="targetid">目标ID</param>
[HttpPut("api/app/itemresultmatch/updatesort")]
public async Task UpdateSortAsync(Guid id, Guid targetid)
{
await _manager.UpdateSortAsync(id, targetid);
}
/// <summary>
/// 修改排序 置顶,置底

2
src/Shentun.Peis.Domain/DataHelper.cs

@ -478,7 +478,7 @@ namespace Shentun.Peis
/// <param name="parameterName">字段名称</param>
/// <param name="ExceptionMessage">异常提示后缀</param>
/// <exception cref="ArgumentException"></exception>
public static void CheckGuidIsDefaultValue(Guid? value, string parameterName, string ExceptionMessage = "不能为默认值00000000-0000-0000-0000-000000000000")
public static void CheckGuidIsDefaultValue(Guid value, string parameterName, string ExceptionMessage = "不能为默认值00000000-0000-0000-0000-000000000000")
{
if (value == Guid.Empty)
{

25
src/Shentun.Peis.Domain/ItemResultMatchs/ItemResultMatchManager.cs

@ -33,8 +33,7 @@ namespace Shentun.Peis.ItemResultMatchs
ItemResultMatch entity
)
{
Check.NotNullOrWhiteSpace(entity.Result, nameof(entity.Result));
Verify(entity);
return new ItemResultMatch
{
DiagnosisId = entity.DiagnosisId,
@ -56,26 +55,28 @@ namespace Shentun.Peis.ItemResultMatchs
ItemResultMatch targetEntity
)
{
Check.NotNullOrWhiteSpace(sourceEntity.Result, nameof(sourceEntity.Result));
DataHelper.CheckEntityIsNull(targetEntity);
Verify(sourceEntity);
targetEntity.ItemId = sourceEntity.ItemId;
targetEntity.DiagnosisId = sourceEntity.DiagnosisId;
targetEntity.Result = sourceEntity.Result;
}
/// <summary>
/// 修改排序 相邻之间
/// 验证新增、修改字段
/// </summary>
/// <param name="id">需要修改的ID</param>
/// <param name="targetid">目标ID</param>
public async Task UpdateSortAsync(Guid id, Guid targetid)
/// <param name="entity"></param>
/// <exception cref="ArgumentException"></exception>
private void Verify(ItemResultMatch entity)
{
await EntityHelper.UpdateSort(_repository, id, targetid);
DataHelper.CheckEntityIsNull(entity);
DataHelper.CheckStringIsNull(entity.Result, "结果");
DataHelper.CheckGuidIsDefaultValue(entity.ItemId, "项目编号");
DataHelper.CheckGuidIsDefaultValue(entity.DiagnosisId, "诊断编号");
}
/// <summary>
/// 修改排序 置顶,置底
/// </summary>

2
src/Shentun.Peis.Domain/ItemResultTemplates/ItemResultTemplateManager.cs

@ -77,7 +77,7 @@ namespace Shentun.Peis.ItemResultTemplates
private void Verify(ItemResultTemplate entity)
{
DataHelper.CheckEntityIsNull(entity);
DataHelper.CheckStringIsNull(entity.Result, "名称");
DataHelper.CheckStringIsNull(entity.Result, "结果");
DataHelper.CheckGuidIsDefaultValue(entity.ItemId, "项目编号");
DataHelper.CheckCharIsYOrN(entity.IsNameIntoSummary, "小结前是否加名称");
DataHelper.CheckCharIsYOrN(entity.IsResultIntoSummary, "是否进入小结");

85
src/Shentun.Peis.Domain/ReferenceRanges/ReferenceRangeManager.cs

@ -39,6 +39,7 @@ namespace Shentun.Peis.ReferenceRanges
ReferenceRange entity
)
{
Verify(entity);
return new ReferenceRange
{
AgeLowerLimit = entity.AgeLowerLimit,
@ -54,28 +55,7 @@ namespace Shentun.Peis.ReferenceRanges
}
/// <summary>
/// 创建
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public ReferenceRange CreateTextAsync(
ReferenceRange entity
)
{
return new ReferenceRange
{
//AgeLowerLimit = entity.AgeLowerLimit,
//AgeUpperLimit = entity.AgeUpperLimit,
//CriticalRangeValue = entity.CriticalRangeValue,
//ForSexId = entity.ForSexId,
ItemId = entity.ItemId,
//LowerDiagnosisId = entity.LowerDiagnosisId,
ReferenceRangeValue = entity.ReferenceRangeValue,
ReferenceRangeTypeFlag = entity.ReferenceRangeTypeFlag
//UpperDiagnosisId = entity.UpperDiagnosisId
};
}
/// <summary>
/// 更新
@ -88,12 +68,13 @@ namespace Shentun.Peis.ReferenceRanges
ReferenceRange targetEntity
)
{
DataHelper.CheckEntityIsNull(targetEntity);
Verify(sourceEntity);
targetEntity.AgeLowerLimit = sourceEntity.AgeLowerLimit;
targetEntity.AgeUpperLimit = sourceEntity.AgeUpperLimit;
targetEntity.CriticalRangeValue = sourceEntity.CriticalRangeValue;
targetEntity.ForSexId = sourceEntity.ForSexId;
//targetEntity.ItemId = sourceEntity.ItemId;
targetEntity.ItemId = sourceEntity.ItemId;
targetEntity.LowerDiagnosisId = sourceEntity.LowerDiagnosisId;
targetEntity.ReferenceRangeValue = sourceEntity.ReferenceRangeValue;
targetEntity.UpperDiagnosisId = sourceEntity.UpperDiagnosisId;
@ -112,11 +93,67 @@ namespace Shentun.Peis.ReferenceRanges
ReferenceRange targetEntity
)
{
DataHelper.CheckEntityIsNull(targetEntity);
Verify(sourceEntity);
targetEntity.ReferenceRangeValue = sourceEntity.ReferenceRangeValue;
targetEntity.ReferenceRangeTypeFlag = sourceEntity.ReferenceRangeTypeFlag;
}
/// <summary>
/// 验证新增、修改字段
/// </summary>
/// <param name="entity"></param>
/// <exception cref="ArgumentException"></exception>
private void Verify(ReferenceRange entity)
{
DataHelper.CheckEntityIsNull(entity);
DataHelper.CheckGuidIsDefaultValue(entity.ItemId, "项目编号");
if (entity.ReferenceRangeTypeFlag != ItemReferenceRangeTypeFlag.None
&& entity.ReferenceRangeTypeFlag != ItemReferenceRangeTypeFlag.Number
&& entity.ReferenceRangeTypeFlag != ItemReferenceRangeTypeFlag.Character
&& entity.ReferenceRangeTypeFlag != ItemReferenceRangeTypeFlag.SexHormone
)
{
throw new ArgumentException($"参考范围类别参数为:{entity.ReferenceRangeTypeFlag},是无效值,只能为'0','1','2','3'");
}
if (entity.ReferenceRangeTypeFlag == ItemReferenceRangeTypeFlag.Character)
{
//字符型
if (string.IsNullOrWhiteSpace(entity.ReferenceRangeValue))
{
throw new ArgumentException("参考范围值不能为空");
}
entity.ForSexId = ForSexFlag.All;
entity.AgeLowerLimit = 0;
entity.AgeUpperLimit = 200;
}
else if (entity.ReferenceRangeTypeFlag == ItemReferenceRangeTypeFlag.Number)
{
//数字型
if (entity.ForSexId != ForSexFlag.All
&& entity.ForSexId != ForSexFlag.Male
&& entity.ForSexId != ForSexFlag.Female
)
{
throw new ArgumentException($"适用性别参数为:{entity.ForSexId},是无效值,只能为'{ForSexFlag.All}','{ForSexFlag.Male}','{ForSexFlag.Female}'");
}
if (entity.AgeLowerLimit >= 0 && entity.AgeLowerLimit < 200)
{
throw new ArgumentException($"年龄下限参数为:{entity.AgeLowerLimit},是无效值,值只能为0~200之间");
}
if (entity.AgeUpperLimit >= 0 && entity.AgeUpperLimit < 200)
{
throw new ArgumentException($"年龄上限参数为:{entity.AgeUpperLimit},是无效值,值只能为0~200之间");
}
}
}
/// <summary>
/// 获取项目的参考范围,根据登记信息的性别、年龄获取
/// </summary>

Loading…
Cancel
Save