diff --git a/src/Shentun.Peis.Application/DiagnosisFunctions/DiagnosisBuilder.cs b/src/Shentun.Peis.Application/DiagnosisFunctions/DiagnosisBuilder.cs
index ee26726..5bfaa37 100644
--- a/src/Shentun.Peis.Application/DiagnosisFunctions/DiagnosisBuilder.cs
+++ b/src/Shentun.Peis.Application/DiagnosisFunctions/DiagnosisBuilder.cs
@@ -147,13 +147,9 @@ using Shentun.Peis.DiagnosisFunctions;
///
public short? Age { get; set; }
///
- /// 诊断项目ID
+ /// 项目
///
- public Guid ItemId { get; set; }
- ///
- /// 诊断项目名称
- ///
- public List Items { get; set; } = new List();
+ public ItemResultInput Item { get; set; }
}
///
@@ -189,4 +185,19 @@ using Shentun.Peis.DiagnosisFunctions;
public string ItemName { get; set; }
public string Result { get; set; }
}
+
+ public class DoctorCheckItemDiagnosisResult
+ {
+ public string ItemName { get; set;}
+ public List ItemDiagnosisTypeResults { get; set; } = new List();
+ }
+
+ public class ItemDiagnosisTypeResult
+ {
+ ///
+ /// 诊断类型0-通过计算函数,1-通过参考范围,2-通过模板
+ ///
+ public char DiagnosisType { get; set; }
+ public List Diagnosis { get; set; } = new List();
+ }
}
diff --git a/src/Shentun.Peis.Application/DiagnosisFunctions/DiagnosisFunctionAppService.cs b/src/Shentun.Peis.Application/DiagnosisFunctions/DiagnosisFunctionAppService.cs
index 338636f..81ff487 100644
--- a/src/Shentun.Peis.Application/DiagnosisFunctions/DiagnosisFunctionAppService.cs
+++ b/src/Shentun.Peis.Application/DiagnosisFunctions/DiagnosisFunctionAppService.cs
@@ -1,19 +1,30 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.EntityFrameworkCore;
using NPOI.DDF;
+using NUglify.Helpers;
using Shentun.Peis.Enums;
using Shentun.Peis.Models;
+using Shentun.Peis.Sexs;
+using Shentun.Peis.SumDiagnosises;
+using Shentun.Peis.SysParmValues;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
+using System.Text.RegularExpressions;
using System.Threading.Tasks;
+using TencentCloud.Cdn.V20180606.Models;
+using TencentCloud.Pts.V20210728.Models;
using Volo.Abp;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Uow;
+using Xceed.Document.NET;
+using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
namespace Shentun.Peis.DiagnosisFunctions
@@ -34,7 +45,14 @@ namespace Shentun.Peis.DiagnosisFunctions
private readonly IRepository _itemResultMatchRepository;
private readonly IRepository _suggestionRepository;
private readonly CacheService _cacheService;
-
+ private SysParmValueManager _sysParmValueManager;
+ private string _isAddAbnormalResult;
+ private string _isAddReferenceRange;
+ private string _isAutoAddSuffix;
+ private string _lowerSuffix;
+ private string _highSuffix;
+ string[] _numArry = { "①", "②", "③", "④", "⑤", "⑥", "⑦", "⑧", "⑨", "⑩",
+ "⑪", "⑫", "⑬", "⑭", "⑮", "⑯", "⑰", "⑱", "⑲", "⑳" };
public DiagnosisFunctionAppService(
IRepository patientRegisterRepository,
IRepository registerAsbitemRepository,
@@ -47,8 +65,9 @@ namespace Shentun.Peis.DiagnosisFunctions
IRepository itemResultTemplateRepository,
IRepository itemResultMatchRepository,
IRepository suggestionRepository,
- CacheService cacheService)
-
+ CacheService cacheService,
+ SysParmValueManager sysParmValueManager)
+
{
this._patientRegisterRepository = patientRegisterRepository;
this._registerAsbitemRepository = registerAsbitemRepository;
@@ -62,6 +81,8 @@ namespace Shentun.Peis.DiagnosisFunctions
this._itemResultMatchRepository = itemResultMatchRepository;
this._suggestionRepository = suggestionRepository;
_cacheService = cacheService;
+ _sysParmValueManager = sysParmValueManager;
+
}
@@ -228,7 +249,7 @@ namespace Shentun.Peis.DiagnosisFunctions
List diagnosisTrips = new List(); //异常提示
- if (query.Count > 0)
+ if (query.Count() > 0)
{
@@ -340,7 +361,671 @@ namespace Shentun.Peis.DiagnosisFunctions
}
}
+ public async Task GetDiagnosisResultAsync2(GetDiagnosisResultRequestDto input)
+ {
+ var reslist = new List();
+ var suggestionlist = new List();
+
+
+ //根据检查单ID查询
+ var query = (from registerCheck in await _registerCheckRepository.GetQueryableAsync()
+ join registerAsbitem in await _registerAsbitemRepository.GetQueryableAsync() on registerCheck.Id equals registerAsbitem.RegisterCheckId
+ join registerCheckItem in await _registerCheckItemRepository.GetQueryableAsync() on registerCheck.Id equals registerCheckItem.RegisterCheckId
+ join asbitem in await _asbitemRepository.GetQueryableAsync() on registerAsbitem.AsbitemId equals asbitem.Id
+ join item in (await _itemRepository.GetQueryableAsync()).Include(x => x.ReferenceRanges).Include(x => x.ItemResultMatches).Include(x => x.ItemResultTemplates)
+ on registerCheckItem.ItemId equals item.Id
+ join patientRegister in await _patientRegisterRepository.GetQueryableAsync() on registerCheck.PatientRegisterId equals patientRegister.Id
+ where registerCheck.Id == input.RegisterCheckId
+ select new { registerCheck, registerAsbitem, registerCheckItem, asbitem, item, patientRegister }).ToList();
+
+ var resultDto = new GetDiagnosisResultDto
+ {
+ DiagnosisResultDetails = reslist,
+ DiagnosisSuggestionDetails = suggestionlist,
+ };
+ if (query.Count() == 0)
+ {
+ return resultDto;
+ }
+ await LoadSysParm(query[0].patientRegister.MedicalCenterId);
+ /*处理逻辑:
+ * 1、处理组合项目诊断函数,如果继续处理走下一步,只处理不合并组合项目的,合并组合项目的不支持
+ * 2、处理项目诊断函数,如果继续处理走下一步
+ * 3、如果是数字型结果,并且有参考范围则处理数字型参考范围,处理完毕后后续几步不处理
+ * 4、如果是字符型结果则从结果模板和结果匹配中去找到对应的诊断,如果都没有生成诊断,则根据结果直接生成诊断
+ * 5、如果没有诊断,返回组合项目默认结果
+ * */
+ //设置基本参数
+ var doctorCheckDiagnosisInput = new DoctorCheckDiagnosisInput()
+ {
+ SexId = query[0].patientRegister.SexId,
+ SexName = _cacheService.GetSexNameAsync(query[0].patientRegister.SexId).Result,
+ Age = query[0].patientRegister.Age
+ };
+ foreach (var item in query)
+ {
+ if (doctorCheckDiagnosisInput.Asbitems.Where(o => o.AsbitemId == item.asbitem.Id).Count() == 0)
+ {
+ var asbitemInput = new AsbitemInput()
+ {
+ AsbitemId = item.asbitem.Id,
+ AsbitemName = item.asbitem.DisplayName,
+ IsDiagnosisFunction = item.asbitem.IsDiagnosisFunction,
+ DiagnosisFunction = item.asbitem.DiagnosisFunction,
+ IsContinueProcess = item.asbitem.IsContinueProcess,
+ DefaultResult = item.asbitem.DefaultResult,
+ };
+ doctorCheckDiagnosisInput.Asbitems.Add(asbitemInput);
+ }
+
+ if (doctorCheckDiagnosisInput.Items.Where(o => o.ItemId == item.item.Id).Count() == 0)
+ {
+ var inputItem = input.Items.Where(o => o.ItemId == item.item.Id).FirstOrDefault();
+ var inputResult = "";
+ if(inputItem != null)
+ {
+ inputResult = inputItem.Result;
+ }
+ var itemInput = new ItemInput()
+ {
+ ItemId = item.item.Id,
+ ItemName = item.item.DisplayName,
+ IsDiagnosisFunction = item.item.IsDiagnosisFunction,
+ DiagnosisFunction = item.item.DiagnosisFunction,
+ IsContinueProcess = item.item.IsContinueProcess,
+ IsNameIntoSummary = item.item.IsNameIntoSummary,
+ IsProduceSummary = item.item.IsProduceSummary,
+ ReferenceRangeTypeFlag = item.item.ReferenceRangeTypeFlag,
+ DefaultResult = item.item.DefaultResult,
+ Result = inputResult,
+ DisplayOrder = item.item.DisplayOrder,
+ ItemResultMatches = item.item.ItemResultMatches.ToList(),
+ ItemResultTemplates = item.item.ItemResultTemplates.ToList(),
+ ReferenceRanges = item.item.ReferenceRanges.ToList()
+ };
+ doctorCheckDiagnosisInput.Items.Add(itemInput);
+ }
+ }
+ doctorCheckDiagnosisInput.Items = doctorCheckDiagnosisInput.Items.OrderBy(o=>o.DisplayOrder).ToList();
+
+ //处理组合项目诊断函数
+ List diagnosisList = new List();
+ List asbitemDiagnosisList;
+ var isContinueProcess = GetAsbitemDiagnosisByFunction(doctorCheckDiagnosisInput, out asbitemDiagnosisList);
+ diagnosisList.AddRange(asbitemDiagnosisList);
+ if (isContinueProcess)
+ {
+ //处理项目诊断
+ var itemDiagnosisList = await GetItemDiagnosis(doctorCheckDiagnosisInput);
+ var itemDiagnosisStringList = GetItemDiagnosisStringList(itemDiagnosisList);
+ diagnosisList.AddRange(itemDiagnosisStringList);
+
+ }
+ //设置返回值
+ //去掉空结果数据
+ diagnosisList = diagnosisList.Where(o => !string.IsNullOrWhiteSpace(o)).ToList();
+ //去掉重复结果数据
+ diagnosisList = diagnosisList.Distinct().ToList();
+ if (!diagnosisList.Any())
+ {
+ //设置组合项目默认小结
+ diagnosisList.Add(doctorCheckDiagnosisInput.Asbitems[0].DefaultResult);
+ }
+ foreach(var diagnosis in diagnosisList)
+ {
+ var getDiagnosisResult_Detail = new GetDiagnosisResult_Detail()
+ {
+ DiagnosisResult = diagnosis
+ };
+ resultDto.DiagnosisResultDetails.Add(getDiagnosisResult_Detail);
+ }
+ return resultDto;
+
+ }
+ private List GetItemDiagnosisStringList(List itemDiagnosisList)
+ {
+ var diagnosisList = new List();
+ foreach (var itemDiagnosis in itemDiagnosisList)
+ {
+ if (!itemDiagnosis.ItemDiagnosisTypeResults.Any())
+ {
+ continue;
+ }
+
+ string diagnosis = "";
+ foreach (var itemDiagnosisType in itemDiagnosis.ItemDiagnosisTypeResults)
+ {
+ if (itemDiagnosisType.DiagnosisType == '1')
+ {
+ //数字型检验参考范围
+ diagnosisList.AddRange(itemDiagnosisType.Diagnosis);
+ }
+ else
+ {
+ if (itemDiagnosisType.Diagnosis.Count() > _numArry.Count())
+ {
+ throw new UserFriendlyException($"诊断数量超过{_numArry.Count()}个,不支持");
+ }
+ if (itemDiagnosisType.Diagnosis.Count() == 0)
+ {
+ continue;
+ }
+
+ for (int i = 0; i < itemDiagnosisType.Diagnosis.Count(); i++)
+ {
+ if (string.IsNullOrWhiteSpace(itemDiagnosisType.Diagnosis[i]))
+ {
+ continue;
+ }
+ diagnosis = diagnosis + _numArry[i] + itemDiagnosisType.Diagnosis[i] + ";";
+ }
+ }
+ }
+
+ if (!string.IsNullOrWhiteSpace(diagnosis))
+ {
+ diagnosis = itemDiagnosis.ItemName + ";" + diagnosis;
+ diagnosisList.Add(diagnosis);
+ }
+
+ }
+
+ return diagnosisList;
+ }
+
+ ///
+ /// 加载系统参数
+ ///
+ ///
+ ///
+ private async Task LoadSysParm(Guid medicalCenterId)
+ {
+ _isAddAbnormalResult = await _sysParmValueManager.GetSysParmValueInMedicalCenterId(
+ medicalCenterId, "doctor_check_lis_summary_mode_add_abnormal_result");
+ _isAddReferenceRange = await _sysParmValueManager.GetSysParmValueInMedicalCenterId(
+ medicalCenterId, "doctor_check_lis_summary_mode_add_reference_range");
+ _isAutoAddSuffix = await _sysParmValueManager.GetSysParmValueInMedicalCenterId(
+ medicalCenterId, "doctor_check_lis_summary_mode_auto_add_suffix");
+ _lowerSuffix = await _sysParmValueManager.GetSysParmValueInMedicalCenterId(
+ medicalCenterId, "doctor_check_lis_summary_mode_lower_suffix");
+ _highSuffix = await _sysParmValueManager.GetSysParmValueInMedicalCenterId(
+ medicalCenterId, "doctor_check_lis_summary_mode_high_suffix");
+ }
+ ///
+ /// 获取组合项目诊断通过诊断函数
+ ///
+ ///
+ ///
+ ///
+ private bool GetAsbitemDiagnosisByFunction(DoctorCheckDiagnosisInput doctorCheckDiagnosisInput, out List diagnosisList)
+ {
+ var patientAsbitemDiagnosisInput = new PatientAsbitemDiagnosisInput()
+ {
+ SexName = doctorCheckDiagnosisInput.SexName,
+ Age = doctorCheckDiagnosisInput.Age
+ };
+
+ foreach (var item in doctorCheckDiagnosisInput.Items)
+ {
+ var itemResult = new ItemResultInput()
+ {
+ ItemId = item.ItemId,
+ ItemName = item.ItemName,
+ Result = item.Result
+ };
+ patientAsbitemDiagnosisInput.Items.Add(itemResult);
+ }
+ var diagnosisBuilder = new DiagnosisBuilder();
+ diagnosisList = new List();
+ bool isContinueProcess = true;
+ foreach (var asbitem in doctorCheckDiagnosisInput.Asbitems)
+ {
+ if (asbitem.IsDiagnosisFunction == 'Y' && !string.IsNullOrWhiteSpace(asbitem.DiagnosisFunction))
+ {
+ var diagnosis = diagnosisBuilder.GetAsbitemDiagnosisResult(patientAsbitemDiagnosisInput, asbitem.DiagnosisFunction);
+ diagnosisList.Add(diagnosis);
+ if (asbitem.IsContinueProcess != 'Y')
+ {
+ //有一个不允许继续处理,则不允许继续处理
+ isContinueProcess = false;
+ }
+ }
+ }
+ return isContinueProcess;
+
+ }
+ ///
+ /// 获取项目诊断
+ ///
+ ///
+ ///
+ private async Task> GetItemDiagnosis(DoctorCheckDiagnosisInput doctorCheckDiagnosisInput)
+ {
+ var patientItemDiagnosisInput = new PatientItemDiagnosisInput()
+ {
+ SexName = doctorCheckDiagnosisInput.SexName,
+ Age = doctorCheckDiagnosisInput.Age
+ };
+
+ var diagnosisBuilder = new DiagnosisBuilder();
+ var diagnosisList = new List();
+ foreach (var item in doctorCheckDiagnosisInput.Items)
+ {
+
+ if (string.IsNullOrWhiteSpace(item.Result))
+ {
+ continue;
+ }
+ if (string.IsNullOrWhiteSpace(item.DefaultResult) && item.Result == item.DefaultResult)
+ {
+ continue;
+ }
+ if (item.IsProduceSummary != 'Y')
+ {
+ continue;
+ }
+
+ var doctorCheckItemDiagnosisResult = new DoctorCheckItemDiagnosisResult()
+ {
+ ItemName = item.ItemName,
+ };
+ diagnosisList.Add(doctorCheckItemDiagnosisResult);
+ if (item.IsDiagnosisFunction == 'Y' && !string.IsNullOrWhiteSpace(item.DiagnosisFunction))
+ {
+ var itemResult = new ItemResultInput()
+ {
+ ItemId = item.ItemId,
+ ItemName = item.ItemName,
+ Result = item.Result
+ };
+ patientItemDiagnosisInput.Item = itemResult;
+
+ //通过计算获取诊断
+ var diagnosis = diagnosisBuilder.GetItemDiagnosisResult(patientItemDiagnosisInput, item.DiagnosisFunction);
+
+ var itemDiagnosisTypeResult = new ItemDiagnosisTypeResult()
+ {
+ DiagnosisType = '0'
+ };
+ itemDiagnosisTypeResult.Diagnosis.Add(diagnosis);
+ doctorCheckItemDiagnosisResult.ItemDiagnosisTypeResults.Add(itemDiagnosisTypeResult);
+
+
+ }
+ if (item.IsDiagnosisFunction == 'Y' && item.IsContinueProcess != 'Y')
+ {
+ continue;
+ }
+ //通过参考范围获取诊断
+ if(item.ReferenceRangeTypeFlag == ItemReferenceRangeTypeFlag.Number)
+ {
+ var referenceRangeDiagnosis = await GetItemDiagnosisByReferenceRanges(doctorCheckDiagnosisInput.SexId, doctorCheckDiagnosisInput.Age, item);
+ if (!string.IsNullOrWhiteSpace(referenceRangeDiagnosis))
+ {
+ var itemDiagnosisTypeResult = new ItemDiagnosisTypeResult()
+ {
+ DiagnosisType = '1'
+ };
+ itemDiagnosisTypeResult.Diagnosis.Add(referenceRangeDiagnosis);
+ doctorCheckItemDiagnosisResult.ItemDiagnosisTypeResults.Add(itemDiagnosisTypeResult);
+ }
+ }
+ else
+ {
+
+ //通过结果模板获取诊断
+ var templateList = await GetItemDiagnosisByTemplate(item);
+ var itemDiagnosisTypeResult = new ItemDiagnosisTypeResult()
+ {
+ DiagnosisType = '2'
+ };
+
+ itemDiagnosisTypeResult.Diagnosis.AddRange(templateList);
+ //通过匹配关系获取诊断
+ var matcheList = await GetItemDiagnosisByMatche(item);
+ itemDiagnosisTypeResult.Diagnosis.AddRange(matcheList);
+ if (!templateList.Any() && !matcheList.Any())
+ {
+ //获取异常结果
+ itemDiagnosisTypeResult.Diagnosis.Add(item.Result);
+
+ }
+ //去掉重复诊断
+ itemDiagnosisTypeResult.Diagnosis = itemDiagnosisTypeResult.Diagnosis.Distinct().ToList();
+ doctorCheckItemDiagnosisResult.ItemDiagnosisTypeResults.Add(itemDiagnosisTypeResult);
+
+
+ }
+
+ }
+ return diagnosisList;
+
+ }
+ ///
+ /// 通过参考范围获取项目诊断列表
+ ///
+ ///
+ ///
+ ///
+ ///
+ private async Task GetItemDiagnosisByReferenceRanges(char sexId, short? age, ItemInput itemInput)
+ {
+ var diagnosisList = new List();
+ if (string.IsNullOrWhiteSpace(itemInput.Result))
+ {
+ return null;
+ }
+ decimal resultDecimal;
+ if (!decimal.TryParse(itemInput.Result, out resultDecimal))
+ {
+ return null;
+ }
+ var referenceRangeList = itemInput.ReferenceRanges.Where(o => o.ReferenceRangeTypeFlag == ItemReferenceRangeTypeFlag.Number).ToList();
+ if (!referenceRangeList.Any())
+ {
+ return null;
+ }
+ if (age == null)
+ {
+ age = 30;
+ }
+ var referenceRange = referenceRangeList.Where(o => o.ForSexId == sexId && age >= o.AgeLowerLimit && age <= o.AgeUpperLimit).FirstOrDefault();
+ if (referenceRange == null)
+ {
+ referenceRange = referenceRangeList.Where(o => o.ForSexId == ForSexFlag.All && age >= o.AgeLowerLimit && age <= o.AgeUpperLimit).FirstOrDefault();
+ if (referenceRange == null)
+ {
+ return null;
+ }
+ }
+ string lowReferenceRangeValueStr;
+ string hegihtReferenceRangeValueStr;
+ decimal lowReferenceRangeValue;
+ decimal hegihtReferenceRangeValue;
+ string diagnosis = null;
+ var pos = referenceRange.ReferenceRangeValue.IndexOf("-");
+ if (pos > 0)
+ {
+ //参考范围形式:10-30
+ lowReferenceRangeValueStr = referenceRange.ReferenceRangeValue.Substring(0, pos);
+ hegihtReferenceRangeValueStr = referenceRange.ReferenceRangeValue.Substring(pos + 1);
+ if (!decimal.TryParse(lowReferenceRangeValueStr, out lowReferenceRangeValue))
+ {
+ return null;
+ }
+ if (!decimal.TryParse(hegihtReferenceRangeValueStr, out hegihtReferenceRangeValue))
+ {
+ return null;
+ }
+ if (resultDecimal < lowReferenceRangeValue)
+ {
+ diagnosis = await GetNumberDiagnosis(itemInput.ItemName, itemInput.Result, true, referenceRange);
+ }
+ else if (resultDecimal > hegihtReferenceRangeValue)
+ {
+ diagnosis = await GetNumberDiagnosis(itemInput.ItemName, itemInput.Result, false, referenceRange);
+ }
+
+ return diagnosis;
+ }
+
+ pos = referenceRange.ReferenceRangeValue.IndexOf(">=");
+ var charLength = ">=".Length;
+ if (pos == 0)
+ {
+ pos = referenceRange.ReferenceRangeValue.IndexOf("≥");
+ charLength = "≥".Length;
+ if (pos == 0)
+ {
+ pos = referenceRange.ReferenceRangeValue.IndexOf("≧");
+ charLength = "≧".Length;
+ }
+ }
+ if (pos > 0)
+ {
+ //参考范围形式:>=
+ lowReferenceRangeValueStr = referenceRange.ReferenceRangeValue.Substring(pos + charLength);
+
+ if (!decimal.TryParse(lowReferenceRangeValueStr, out lowReferenceRangeValue))
+ {
+ return null;
+ }
+ if (resultDecimal < lowReferenceRangeValue)
+ {
+ diagnosis = await GetNumberDiagnosis(itemInput.ItemName, itemInput.Result, true, referenceRange);
+ }
+ return diagnosis;
+ }
+
+ pos = referenceRange.ReferenceRangeValue.IndexOf(">");
+ charLength = ">".Length;
+ if (pos > 0)
+ {
+ //参考范围形式:>
+ lowReferenceRangeValueStr = referenceRange.ReferenceRangeValue.Substring(pos + charLength);
+
+ if (!decimal.TryParse(lowReferenceRangeValueStr, out lowReferenceRangeValue))
+ {
+ return null;
+ }
+ if (resultDecimal <= lowReferenceRangeValue)
+ {
+ diagnosis = await GetNumberDiagnosis(itemInput.ItemName, itemInput.Result, true, referenceRange);
+ }
+ return diagnosis;
+ }
+
+ pos = referenceRange.ReferenceRangeValue.IndexOf("<=");
+ charLength = "<=".Length;
+ if (pos == 0)
+ {
+ pos = referenceRange.ReferenceRangeValue.IndexOf("≤");
+ charLength = "≤".Length;
+ if (pos == 0)
+ {
+ pos = referenceRange.ReferenceRangeValue.IndexOf("≦");
+ charLength = "≦".Length;
+ }
+ }
+ if (pos > 0)
+ {
+ //参考范围形式:<=
+ hegihtReferenceRangeValueStr = referenceRange.ReferenceRangeValue.Substring(pos + charLength);
+
+ if (!decimal.TryParse(hegihtReferenceRangeValueStr, out hegihtReferenceRangeValue))
+ {
+ return null;
+ }
+ if (resultDecimal >= hegihtReferenceRangeValue)
+ {
+ diagnosis = await GetNumberDiagnosis(itemInput.ItemName, itemInput.Result, false, referenceRange);
+ }
+ return diagnosis;
+ }
+ pos = referenceRange.ReferenceRangeValue.IndexOf("<");
+ charLength = "<".Length;
+ if (pos > 0)
+ {
+ //参考范围形式:<
+ hegihtReferenceRangeValueStr = referenceRange.ReferenceRangeValue.Substring(pos + charLength);
+
+ if (!decimal.TryParse(hegihtReferenceRangeValueStr, out hegihtReferenceRangeValue))
+ {
+ return null;
+ }
+ if (resultDecimal >= hegihtReferenceRangeValue)
+ {
+ diagnosis = await GetNumberDiagnosis(itemInput.ItemName, itemInput.Result, false, referenceRange);
+ }
+ return diagnosis;
+ }
+ return diagnosis;
+ }
+
+
+ private async Task GetNumberDiagnosis(string itemName, string result, bool isLower,
+ ReferenceRange referenceRange)
+ {
+ string diagnosis = null;
+ if (isLower)
+ {
+ if (referenceRange.LowerDiagnosisId != null && referenceRange.LowerDiagnosisId != Guid.Empty)
+ {
+ var diagnosisEntity = await _diagnosisRepository.FindAsync(o => o.Id == referenceRange.LowerDiagnosisId);
+ if (diagnosisEntity != null)
+ {
+ diagnosis = diagnosisEntity.DisplayName + "↓";
+ }
+ else
+ {
+ if (_isAutoAddSuffix == "Y")
+ {
+ diagnosis = itemName + _lowerSuffix + "↓";
+ }
+ }
+
+ }
+ else
+ {
+ if (_isAutoAddSuffix == "Y")
+ {
+ diagnosis = itemName + _lowerSuffix + "↓";
+ }
+ }
+ }
+ else
+ {
+ if (referenceRange.UpperDiagnosisId != null && referenceRange.UpperDiagnosisId != Guid.Empty)
+ {
+ var diagnosisEntity = await _diagnosisRepository.FindAsync(o => o.Id == referenceRange.UpperDiagnosisId);
+ if (diagnosisEntity != null)
+ {
+ diagnosis = diagnosisEntity.DisplayName + "↑";
+ }
+ else
+ {
+ if (_isAutoAddSuffix == "Y")
+ {
+ diagnosis = itemName + _highSuffix + "↑";
+ }
+ }
+
+ }
+ else
+ {
+ if (_isAutoAddSuffix == "Y")
+ {
+ diagnosis = itemName + _highSuffix + "↑";
+ }
+ }
+ }
+ if (!string.IsNullOrWhiteSpace(diagnosis))
+ {
+ if (_isAddAbnormalResult == "Y")
+ {
+ diagnosis = diagnosis + "(结果:" + result + ",参考范围:" + referenceRange.ReferenceRangeValue + ")";
+ }
+ }
+ return diagnosis;
+ }
+
+ ///
+ /// 通过模板获取诊断
+ ///
+ ///
+ ///
+ private async Task> GetItemDiagnosisByTemplate(ItemInput itemInput)
+ {
+ List diagnosisList = new List();
+ //将结果解析到数组中
+ string[] resultArry = GetResultArry(itemInput.Result);
+ //结果模板中的结果去掉数字,* /等符号
+ foreach (var template in itemInput.ItemResultTemplates)
+ {
+ if (!string.IsNullOrWhiteSpace(template.Result))
+ {
+
+ template.Result = Regex.Replace(template.Result, @"\d+", "").Replace("*", "").Replace("/", "").Replace(" ", "");
+ }
+ }
+ foreach (var resultSplit in resultArry)
+ {
+ if (string.IsNullOrWhiteSpace(resultSplit) || resultSplit.StartsWith("余未见异常"))
+ {
+ continue;
+ }
+ var templatesList = itemInput.ItemResultTemplates.Where(o => o.Result == resultSplit && o.IsResultIntoSummary == 'Y').ToList();
+ foreach (var template in templatesList)
+ {
+ if (template != null && template.DiagnosisId != null && template.DiagnosisId != Guid.Empty)
+ {
+ var temp_diagnosis = await _diagnosisRepository.FirstOrDefaultAsync(m => m.Id == template.DiagnosisId);
+ if (temp_diagnosis != null)
+ {
+ diagnosisList.Add(temp_diagnosis.DisplayName);
+ }
+ }
+ else
+ {
+ diagnosisList.Add(resultSplit);
+ }
+ }
+ }
+
+
+ return diagnosisList.Distinct().ToList();
+ }
+ ///
+ /// 获取项目诊断通过匹配关系
+ ///
+ ///
+ ///
+ private async Task> GetItemDiagnosisByMatche(ItemInput itemInput)
+ {
+ List diagnosisList = new List();
+ //将结果解析到数组中
+ string[] resultArry = GetResultArry(itemInput.Result);
+
+ foreach (var resultSplit in resultArry)
+ {
+ if (string.IsNullOrWhiteSpace(resultSplit) || resultSplit.StartsWith("余未见异常"))
+ {
+ continue;
+ }
+ var templatesList = itemInput.ItemResultMatches.Where(o => resultSplit.Contains(o.Result)).ToList();
+ foreach (var template in templatesList)
+ {
+ if (template != null && template.DiagnosisId != Guid.Empty)
+ {
+ var temp_diagnosis = await _diagnosisRepository.FirstOrDefaultAsync(m => m.Id == template.DiagnosisId);
+ if (temp_diagnosis != null)
+ {
+ diagnosisList.Add(temp_diagnosis.DisplayName);
+ }
+ }
+ }
+ }
+
+
+ return diagnosisList.Distinct().ToList();
+ }
+ ///
+ /// 去掉结果中的数字符号和分号
+ ///
+ ///
+ ///
+ private string[] GetResultArry(string result)
+ {
+ result = result.Trim().Replace(";", ";");
+ foreach (var num in _numArry)
+ {
+ result = result.Replace(num, "");
+ }
+ //将结果通过英文;解析到数组中
+ string[] resultArry = result.Split(";");
+ return resultArry;
+ }
#region 执行项目计算函数
///
@@ -351,20 +1036,20 @@ namespace Shentun.Peis.DiagnosisFunctions
[HttpPost("api/app/diagnosisfunction/getcalculationfunctionresult")]
public async Task GetCalculationFunctionResultAsync(GetDiagnosisResultRequestDto input)
{
- await GetCalculationFunctionAsync(input);
+ await GetItemResultByCalculationFunctionAsync(input);
return input;
}
- private async Task GetCalculationFunctionAsync(GetDiagnosisResultRequestDto input)
+ private async Task GetItemResultByCalculationFunctionAsync(GetDiagnosisResultRequestDto input)
{
//根据检查单ID查询
var list = (
from patientRegister in await _patientRegisterRepository.GetQueryableAsync()
join registerCheck in await _registerCheckRepository.GetQueryableAsync()
on patientRegister.Id equals registerCheck.PatientRegisterId
- join registerCheckItem in await _registerCheckItemRepository.GetQueryableAsync()
+ join registerCheckItem in await _registerCheckItemRepository.GetQueryableAsync()
on registerCheck.Id equals registerCheckItem.RegisterCheckId
- join item in await _itemRepository.GetQueryableAsync()
+ join item in await _itemRepository.GetQueryableAsync()
on registerCheckItem.ItemId equals item.Id
where registerCheck.Id == input.RegisterCheckId
select new
@@ -397,11 +1082,11 @@ namespace Shentun.Peis.DiagnosisFunctions
{
//计算函数
//计算结果
-
+
string CalculationFunctionValue = diagnosisBuilder.GetItemCalculateResult(patientItemCalculateInput, item.Item.CalculationFunction);
//CalculationFunctionValue = GetCodeResult(input, item.CalculationFunction, list);
- input.Items.Where(m => m.ItemId == item.Id).FirstOrDefault().Result = CalculationFunctionValue; //赋值
+ input.Items.Where(m => m.ItemId == item.Item.Id).FirstOrDefault().Result = CalculationFunctionValue; //赋值
}
}
@@ -886,12 +1571,7 @@ namespace Shentun.Peis.DiagnosisFunctions
return tempcode;
}
-
- }
-
-
-
-
-}
+ }
+}
\ No newline at end of file
diff --git a/src/Shentun.Peis.Application/DiagnosisFunctions/DoctorCheckDiagnosisInput.cs b/src/Shentun.Peis.Application/DiagnosisFunctions/DoctorCheckDiagnosisInput.cs
new file mode 100644
index 0000000..54b2b68
--- /dev/null
+++ b/src/Shentun.Peis.Application/DiagnosisFunctions/DoctorCheckDiagnosisInput.cs
@@ -0,0 +1,60 @@
+using Org.BouncyCastle.Bcpg.OpenPgp;
+using Shentun.Peis.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Shentun.Peis.DiagnosisFunctions
+{
+ public class DoctorCheckDiagnosisInput
+ {
+ public char SexId { get; set; }
+ public string SexName { get; set; }
+ public short? Age { get; set; }
+ public List Asbitems { get; set; } = new List();
+ public List Items { get; set; } = new List { };
+ }
+
+ public class AsbitemInput
+ {
+ ///
+ /// 组合项目ID
+ ///
+ public Guid AsbitemId { get; set; }
+ ///
+ /// 组合项目名称
+ ///
+ public string AsbitemName { get; set; }
+ public char IsDiagnosisFunction { get; set; }
+ public string DiagnosisFunction { get; set; }
+ public char IsContinueProcess { get; set; }
+ public string DefaultResult { get; set; }
+
+ }
+
+ public class ItemInput
+ {
+ ///
+ /// 项目ID
+ ///
+ public Guid ItemId { get; set; }
+ ///
+ /// 项目名称
+ ///
+ public string ItemName { get; set; }
+ public char IsDiagnosisFunction { get; set; }
+ public string DiagnosisFunction { get; set; }
+ public char IsContinueProcess { get; set; }
+ public char IsNameIntoSummary { get; set; }
+ public char IsProduceSummary { get; set; }
+ public char ReferenceRangeTypeFlag { get; set; }
+ public string DefaultResult { get; set; }
+ public string Result { get; set; }
+ public int DisplayOrder { get; set; }
+ public List ItemResultMatches { get; set; }
+ public List ItemResultTemplates { get; set; }
+ public List ReferenceRanges { get; set; }
+ }
+}
diff --git a/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs b/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs
index 6ecf9f1..d22625a 100644
--- a/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs
+++ b/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs
@@ -556,7 +556,7 @@ namespace Shentun.Peis.PatientRegisters
PatientRegister ent = null;
if (!string.IsNullOrWhiteSpace(input.PatientRegisterNo))
{
- ent = query.Where(m => m.PatientRegisterNo == input.PatientRegisterNo).First();
+ ent = query.Where(m => m.PatientRegisterNo == input.PatientRegisterNo).FirstOrDefault();
if (ent == null)
{
throw new UserFriendlyException("未找到人员信息");
diff --git a/src/Shentun.Peis.Application/PrintReports/PrintReportAppService.cs b/src/Shentun.Peis.Application/PrintReports/PrintReportAppService.cs
index afab897..14067ad 100644
--- a/src/Shentun.Peis.Application/PrintReports/PrintReportAppService.cs
+++ b/src/Shentun.Peis.Application/PrintReports/PrintReportAppService.cs
@@ -140,9 +140,9 @@ namespace Shentun.Peis.PrintReports
{
#region 系统参数配置
- var MedicalCenterAddress = await _sysParmValueManager.GetSysParmValueInOrganizationUnitId(patientRegisterEnt.MedicalCenterId, "medical_center_address");
- var MedicalCenterFax = await _sysParmValueManager.GetSysParmValueInOrganizationUnitId(patientRegisterEnt.MedicalCenterId, "medical_center_fax");
- var MedicalCenterTelphone = await _sysParmValueManager.GetSysParmValueInOrganizationUnitId(patientRegisterEnt.MedicalCenterId, "medical_center_telphone");
+ var MedicalCenterAddress = await _sysParmValueManager.GetSysParmValueInMedicalCenterId(patientRegisterEnt.MedicalCenterId, "medical_center_address");
+ var MedicalCenterFax = await _sysParmValueManager.GetSysParmValueInMedicalCenterId(patientRegisterEnt.MedicalCenterId, "medical_center_fax");
+ var MedicalCenterTelphone = await _sysParmValueManager.GetSysParmValueInMedicalCenterId(patientRegisterEnt.MedicalCenterId, "medical_center_telphone");
#endregion
msg = new PeisReportDto
@@ -153,7 +153,7 @@ namespace Shentun.Peis.PrintReports
MedicalCenterTelphone = MedicalCenterTelphone,
detailedResultsListDtos = new List(),
MedicalCenterAddress = MedicalCenterAddress,
- MedicalStartDate = DataHelper.ConversionDateToString(patientRegisterEnt.MedicalStartDate),
+ MedicalStartDate = patientRegisterEnt.MedicalStartDate.ToString(),
OrganizationUnitId = patientRegisterEnt.MedicalCenterId,
OrganizationUnitName = organizationUnitList.Where(m => m.Id == patientRegisterEnt.MedicalCenterId).Select(s => s.DisplayName).FirstOrDefault(),
PatientName = patientRegisterEnt.PatientName,
@@ -162,7 +162,7 @@ namespace Shentun.Peis.PrintReports
resultStatusDtos = new List(),
sumSuggestionHeaderOrContentDtos = new List(),
SexName = sexList.Where(m => m.Id == patientRegisterEnt.SexId).Select(s => s.DisplayName).FirstOrDefault(),
- SummaryDate = DataHelper.ConversionDateToString(patientRegisterEnt.SummaryDate),
+ SummaryDate = patientRegisterEnt.SummaryDate.ToString(),
sumSummaryHeaderOrContentDtos = new List()
};
@@ -256,7 +256,7 @@ namespace Shentun.Peis.PrintReports
{
AsbitemName = string.Join(",", s.RegisterCheckAsbitems.Select(rs => rs.Asbitem.DisplayName).ToList()),
ItemTypeName = string.Join(",", s.RegisterCheckAsbitems.Select(rs => rs.Asbitem.ItemType.DisplayName).ToList()),
- CheckDate = DataHelper.ConversionDateToString(s.CheckDate),
+ CheckDate = s.CheckDate.ToString(),
CheckDoctorName = EntityHelper.GetCheckDoctorName(s.CheckDoctorId, userlist),
Items = s.RegisterCheckItems.Select(sa => new DetailedResultsList_Asbitem_Item
{
diff --git a/src/Shentun.Peis.Domain/ReferenceRanges/ReferenceRangeManager.cs b/src/Shentun.Peis.Domain/ReferenceRanges/ReferenceRangeManager.cs
index f4ecd0e..9044bc1 100644
--- a/src/Shentun.Peis.Domain/ReferenceRanges/ReferenceRangeManager.cs
+++ b/src/Shentun.Peis.Domain/ReferenceRanges/ReferenceRangeManager.cs
@@ -142,15 +142,18 @@ namespace Shentun.Peis.ReferenceRanges
{
throw new ArgumentException($"适用性别参数为:{entity.ForSexId},是无效值,只能为'{ForSexFlag.All}','{ForSexFlag.Male}','{ForSexFlag.Female}'");
}
- if (entity.AgeLowerLimit >= 0 && entity.AgeLowerLimit < 200)
+ if (entity.AgeLowerLimit < 0 || entity.AgeLowerLimit > 200)
{
throw new ArgumentException($"年龄下限参数为:{entity.AgeLowerLimit},是无效值,值只能为0~200之间");
}
- if (entity.AgeUpperLimit >= 0 && entity.AgeUpperLimit < 200)
+ if (entity.AgeUpperLimit < 0 || entity.AgeUpperLimit > 200)
{
throw new ArgumentException($"年龄上限参数为:{entity.AgeUpperLimit},是无效值,值只能为0~200之间");
}
-
+ if (entity.AgeLowerLimit > entity.AgeUpperLimit)
+ {
+ throw new ArgumentException($"年龄下限不能大于上限值");
+ }
}
}
diff --git a/src/Shentun.Peis.Domain/SysParmValues/SysParmValueManager.cs b/src/Shentun.Peis.Domain/SysParmValues/SysParmValueManager.cs
index 0e6fdc6..e17e361 100644
--- a/src/Shentun.Peis.Domain/SysParmValues/SysParmValueManager.cs
+++ b/src/Shentun.Peis.Domain/SysParmValues/SysParmValueManager.cs
@@ -68,10 +68,10 @@ namespace Shentun.Peis.SysParmValues
/// 根据体检中心获取系统参数值(优先找体检中心的参数,未找到获取全局参数)
/// 如果is_public=Y或者只有一个体检中心,只取公共参数值,如果is_public=N并且有多个体检中心,优先取体检中心值,如果体检中心没记录行或者其中的值为空,则取公共参数
///
- /// 体检中心ID
+ /// 体检中心ID
/// 系统参数ID
///
- public async Task GetSysParmValueInOrganizationUnitId(Guid OrganizationUnitId, string SysParmId)
+ public async Task GetSysParmValueInMedicalCenterId(Guid medicalCenterId, string SysParmId)
{
string msg = "";
@@ -100,11 +100,12 @@ namespace Shentun.Peis.SysParmValues
var sysParmValueList = await _sysParmValueRepository.GetListAsync(m => m.SysParmId == SysParmId);
if (sysParmValueList.Any())
{
- if (sysParmValueList.Where(m => m.MedicalCenterId == OrganizationUnitId).Count() > 0)
+ if (sysParmValueList.Where(m => m.MedicalCenterId == medicalCenterId).Count() > 0)
{
- msg = sysParmValueList.Where(m => m.MedicalCenterId == OrganizationUnitId).FirstOrDefault().ParmValue;
+ msg = sysParmValueList.Where(m => m.MedicalCenterId == medicalCenterId).FirstOrDefault().ParmValue;
+
}
- else if (sysParmValueList.Where(m => m.MedicalCenterId == Guid.Empty).Count() > 0)
+ if (string.IsNullOrWhiteSpace(msg) && sysParmValueList.Where(m => m.MedicalCenterId == Guid.Empty).Count() > 0)
{
msg = sysParmValueList.Where(m => m.MedicalCenterId == Guid.Empty).FirstOrDefault().ParmValue;
}
diff --git a/src/Shentun.Peis.EntityFrameworkCore/PrintReports/PatientRegisterGuideReportRepository.cs b/src/Shentun.Peis.EntityFrameworkCore/PrintReports/PatientRegisterGuideReportRepository.cs
index c6ba36b..e8cbe62 100644
--- a/src/Shentun.Peis.EntityFrameworkCore/PrintReports/PatientRegisterGuideReportRepository.cs
+++ b/src/Shentun.Peis.EntityFrameworkCore/PrintReports/PatientRegisterGuideReportRepository.cs
@@ -61,16 +61,16 @@ namespace Shentun.Peis.PrintReports
#region 系统参数配置
- var MedicalCenterAddress = await _sysParmValueManager.GetSysParmValueInOrganizationUnitId(OrOrganizationUnitId, "medical_center_address");
- var MedicalCenterFax = await _sysParmValueManager.GetSysParmValueInOrganizationUnitId(OrOrganizationUnitId, "medical_center_fax");
- var MedicalCenterTelphone = await _sysParmValueManager.GetSysParmValueInOrganizationUnitId(OrOrganizationUnitId, "medical_center_telphone");
+ var MedicalCenterAddress = await _sysParmValueManager.GetSysParmValueInMedicalCenterId(OrOrganizationUnitId, "medical_center_address");
+ var MedicalCenterFax = await _sysParmValueManager.GetSysParmValueInMedicalCenterId(OrOrganizationUnitId, "medical_center_fax");
+ var MedicalCenterTelphone = await _sysParmValueManager.GetSysParmValueInMedicalCenterId(OrOrganizationUnitId, "medical_center_telphone");
#endregion
var dbContext = await GetDbContextAsync();
- var customerOrgList = await _customerOrgRepository.GetListAsync();
+ var customerOrgList =await _customerOrgRepository.GetListAsync();
var query = from a in dbContext.PatientRegisters
join b in dbContext.Sexes on a.SexId equals b.Id
@@ -89,9 +89,9 @@ namespace Shentun.Peis.PrintReports
Age = a.Age,
PatientRegisterId = a.Id,
CustomerOrgGroupName = ac.DisplayName,
- CustomerOrgName = EntityHelper.GetCustomerOrgParentNameNoSql(customerOrgList, a.CustomerOrgId),
- CustomerOrgShortName = EntityHelper.GetCustomerOrgParentShortNameNoSql(customerOrgList, a.CustomerOrgId),
- DepartmentName = EntityHelper.GetCustomerOrgNameNoSql(customerOrgList, a.CustomerOrgId),
+ CustomerOrgName = EntityHelper.GetCustomerOrgParentNameNoSql(customerOrgList,a.CustomerOrgId),
+ CustomerOrgShortName = EntityHelper.GetCustomerOrgParentShortNameNoSql(customerOrgList,a.CustomerOrgId),
+ DepartmentName = EntityHelper.GetCustomerOrgNameNoSql(customerOrgList,a.CustomerOrgId),
IdNo = e.IdNo,
JobCardNo = a.JobCardNo,
MedicalCardNo = a.MedicalCardNo,
@@ -108,7 +108,7 @@ namespace Shentun.Peis.PrintReports
SexName = b.DisplayName,
// Photo = string.IsNullOrEmpty(a.Photo) ? "" : ImageHelper.GetImageBase64StringAsync(a.Photo),
Photo = string.IsNullOrEmpty(a.Photo) ? "" : ApiUrl + a.Photo,
- MedicalStartDate = DataHelper.ConversionDateToString(a.MedicalStartDate),
+ MedicalStartDate = Convert.ToDateTime(a.MedicalStartDate.ToString()).ToString("yyyy-MM-dd"),
OrganizationUnitId = a.MedicalCenterId,
OrganizationUnitName = ag.DisplayName,
Detail = PatientRegisterGuideAsbitem(a.Id, OrOrganizationUnitId, a.SexId)
@@ -126,9 +126,9 @@ namespace Shentun.Peis.PrintReports
#region 系统参数配置
- var MedicalCenterAddress = await _sysParmValueManager.GetSysParmValueInOrganizationUnitId(OrOrganizationUnitId, "medical_center_address");
- var MedicalCenterFax = await _sysParmValueManager.GetSysParmValueInOrganizationUnitId(OrOrganizationUnitId, "medical_center_fax");
- var MedicalCenterTelphone = await _sysParmValueManager.GetSysParmValueInOrganizationUnitId(OrOrganizationUnitId, "medical_center_telphone");
+ var MedicalCenterAddress = await _sysParmValueManager.GetSysParmValueInMedicalCenterId(OrOrganizationUnitId, "medical_center_address");
+ var MedicalCenterFax = await _sysParmValueManager.GetSysParmValueInMedicalCenterId(OrOrganizationUnitId, "medical_center_fax");
+ var MedicalCenterTelphone = await _sysParmValueManager.GetSysParmValueInMedicalCenterId(OrOrganizationUnitId, "medical_center_telphone");
#endregion
var dbContext = await GetDbContextAsync();
@@ -171,7 +171,7 @@ namespace Shentun.Peis.PrintReports
SexName = b.DisplayName,
// Photo = string.IsNullOrEmpty(a.Photo) ? "" : ImageHelper.GetImageBase64StringAsync( a.Photo),
Photo = string.IsNullOrEmpty(a.Photo) ? "" : ApiUrl + a.Photo,
- MedicalStartDate = DataHelper.ConversionDateToString(a.MedicalStartDate),
+ MedicalStartDate = Convert.ToDateTime(a.MedicalStartDate.ToString()).ToString("yyyy-MM-dd"),
OrganizationUnitId = a.MedicalCenterId,
OrganizationUnitName = ag.DisplayName,
Detail = PatientRegisterGuideAsbitem(a.Id, OrOrganizationUnitId, a.SexId)
diff --git a/test/Shentun.Peis.Application.Tests/DiagnosisFunctionAppServiceTest.cs b/test/Shentun.Peis.Application.Tests/DiagnosisFunctionAppServiceTest.cs
index 53e1f02..9151a72 100644
--- a/test/Shentun.Peis.Application.Tests/DiagnosisFunctionAppServiceTest.cs
+++ b/test/Shentun.Peis.Application.Tests/DiagnosisFunctionAppServiceTest.cs
@@ -5,6 +5,7 @@ using Shentun.Peis.Models;
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Runtime.ConstrainedExecution;
using System.Text;
using System.Threading.Tasks;
using TencentCloud.Ame.V20190916.Models;
@@ -28,6 +29,172 @@ namespace Shentun.Peis
_repository = GetRequiredService>();
_appService = GetRequiredService();
}
+ [Fact]
+ public async Task GetDiagnosisResultAsync2()
+ {
+ using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
+ {
+ var getDiagnosisResultRequestDto = new GetDiagnosisResultRequestDto()
+ {
+ RegisterCheckId = new Guid("3a11eeb9-81e2-44bc-fd9d-72ca7d3ef9a6"),
+ Items = new List
+ {
+ new GetDiagnosisResultRequest_Item()
+ {
+ ItemId = new Guid("3a11eeb8-716b-6103-9e89-dbd9df85227f"),
+ Result = "180/110"
+ },
+
+ new GetDiagnosisResultRequest_Item()
+ {
+ ItemId = new Guid("3a0c5186-2920-6492-c8bf-5908fe6bda56"),
+ Result = "肥胖;其它病"
+ }
+ }
+ };
+ var result = await _appService.GetDiagnosisResultAsync2(getDiagnosisResultRequestDto);
+ foreach (var item in result.DiagnosisResultDetails)
+ {
+ _output.WriteLine(item.DiagnosisResult);
+ }
+ }
+ }
+
+ [Fact]
+ public async Task GetDiagnosisResultAsync3()
+ {
+ using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
+ {
+ var getDiagnosisResultRequestDto = new GetDiagnosisResultRequestDto()
+ {
+ RegisterCheckId = new Guid("3a11ee70-0351-8970-5bc5-dc0f72e62339"),
+ Items = new List
+ {
+ new GetDiagnosisResultRequest_Item()
+ {
+ ItemId = new Guid("3a0c6555-0dad-55b4-b59f-b11e8074cfdd"),
+ Result = "阳性"
+ },
+
+ new GetDiagnosisResultRequest_Item()
+ {
+ ItemId = new Guid("3a0c6558-e2a6-4aab-e6e9-d34957a7c3ed"),
+ Result = "阴性"
+ },
+ new GetDiagnosisResultRequest_Item()
+ {
+ ItemId = new Guid("3a0c655a-1fdc-2447-6dc9-d8ec8e110d2e"),
+ Result = "阳性"
+ },
+ new GetDiagnosisResultRequest_Item()
+ {
+ ItemId = new Guid("3a0c655c-1c9f-c8c5-150a-59b3cc351472"),
+ Result = "阴性"
+ },
+ new GetDiagnosisResultRequest_Item()
+ {
+ ItemId = new Guid("3a0c655d-6ab7-ca7e-3920-3b493ec83192"),
+ Result = "阳性"
+ },
+ }
+ };
+ var result = await _appService.GetDiagnosisResultAsync2(getDiagnosisResultRequestDto);
+ foreach (var item in result.DiagnosisResultDetails)
+ {
+ _output.WriteLine(item.DiagnosisResult);
+ }
+ }
+ }
+ [Fact]
+ public async Task GetDiagnosisResultAsync4()
+ {
+ using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
+ {
+ var getDiagnosisResultRequestDto = new GetDiagnosisResultRequestDto()
+ {
+ RegisterCheckId = new Guid("3a11ee70-034c-1ce6-40f9-7eabb02830a9"),
+ Items = new List
+ {
+ new GetDiagnosisResultRequest_Item()
+ {
+ ItemId = new Guid("3a0d2916-3706-a22a-69dd-bd80be509d07"),
+ Result = "30.5"
+ },
+
+ new GetDiagnosisResultRequest_Item()
+ {
+ ItemId = new Guid("3a0d2919-49d5-30d3-4373-b3dc1e806732"),
+ Result = "9"
+ },
+ new GetDiagnosisResultRequest_Item()
+ {
+ ItemId = new Guid("3a0d2917-40e2-2f81-ebfc-267a9a98b02e"),
+ Result = "91.3"
+ },
+ new GetDiagnosisResultRequest_Item()
+ {
+ ItemId = new Guid("3a0d291a-6ab5-8642-9cd3-30353ecb5d15"),
+ Result = "90"
+ },
+ new GetDiagnosisResultRequest_Item()
+ {
+ ItemId = new Guid("3a0d2918-344b-0373-a53c-b4888bd6b9a6"),
+ Result = "13"
+ },
+ }
+ };
+ var result = await _appService.GetDiagnosisResultAsync2(getDiagnosisResultRequestDto);
+ foreach (var item in result.DiagnosisResultDetails)
+ {
+ _output.WriteLine(item.DiagnosisResult);
+ }
+ }
+ }
+ [Fact]
+ public async Task GetDiagnosisResultAsync5()
+ {
+ using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
+ {
+ var getDiagnosisResultRequestDto = new GetDiagnosisResultRequestDto()
+ {
+ RegisterCheckId = new Guid("3a11ee70-034c-1ce6-40f9-7eabb02830a9"),
+ Items = new List
+ {
+ new GetDiagnosisResultRequest_Item()
+ {
+ ItemId = new Guid("3a0d2916-3706-a22a-69dd-bd80be509d07"),
+ Result = "30.5"
+ },
+
+ new GetDiagnosisResultRequest_Item()
+ {
+ ItemId = new Guid("3a0d2919-49d5-30d3-4373-b3dc1e806732"),
+ Result = "9"
+ },
+ new GetDiagnosisResultRequest_Item()
+ {
+ ItemId = new Guid("3a0d2917-40e2-2f81-ebfc-267a9a98b02e"),
+ Result = "91.3"
+ },
+ new GetDiagnosisResultRequest_Item()
+ {
+ ItemId = new Guid("3a0d291a-6ab5-8642-9cd3-30353ecb5d15"),
+ Result = "90"
+ },
+ new GetDiagnosisResultRequest_Item()
+ {
+ ItemId = new Guid("3a0d2918-344b-0373-a53c-b4888bd6b9a6"),
+ Result = "13"
+ },
+ }
+ };
+ var result = await _appService.GetDiagnosisResultAsync2(getDiagnosisResultRequestDto);
+ foreach (var item in result.DiagnosisResultDetails)
+ {
+ _output.WriteLine(item.DiagnosisResult);
+ }
+ }
+ }
///
/// 体重指数测试结果
///
@@ -58,7 +225,7 @@ namespace Shentun.Peis
}
};
var result = GetItemCalculateResultTzzs(patient);
- _output.WriteLine("结果:"+result);
+ _output.WriteLine("结果:" + result);
string code = @"
string result = """";
decimal sg = 0;
@@ -102,12 +269,12 @@ namespace Shentun.Peis
DiagnosisBuilder diagnosisBuilder = new DiagnosisBuilder();
- result = diagnosisBuilder.GetItemCalculateResult(patient, code);
+ result = diagnosisBuilder.GetItemCalculateResult(patient, code);
_output.WriteLine("动态结果:" + result);
}
-
+
///
/// 体重指数
///
@@ -118,10 +285,11 @@ namespace Shentun.Peis
string result = "";
decimal sg = 0;
decimal tz = 0;
+
foreach (var item in patient.Items)
{
if (item.ItemName == "身高")
- {
+ {
if (decimal.TryParse(item.Result, out sg))
{
if (sg == 0)
@@ -136,7 +304,7 @@ namespace Shentun.Peis
}
if (item.ItemName == "体重")
- {
+ {
if (decimal.TryParse(item.Result, out tz))
{
if (tz == 0)
@@ -151,7 +319,111 @@ namespace Shentun.Peis
}
}
- result = (tz /((sg/100) * (sg / 100))).ToString("0.00");
+ result = (tz / ((sg / 100) * (sg / 100))).ToString("0.00");
+ return result;
+ }
+
+ [Fact]
+ public void GetItemDiagnosisResultXYTest()
+ {
+ PatientItemDiagnosisInput patient = new PatientItemDiagnosisInput();
+ patient.SexName = "男";
+ patient.Age = 30;
+ patient.Item = new ItemResultInput()
+ {
+ ItemId = Guid.NewGuid(),
+ ItemName = "血压",
+ Result = "180/110"
+ };
+ var result = GetItemDiagnosisResultXY(patient);
+ _output.WriteLine("结果:" + result);
+ string code = @"
+ string result = """";
+ decimal szyDecimal = 0;
+ decimal ssyDecimal = 0;
+ var itemResult = patient.Item.Result;
+ if (string.IsNullOrWhiteSpace(itemResult))
+ {
+ return null;
+ }
+ if (itemResult == ""/"")
+ return null;
+ var pos = itemResult.IndexOf(""/"");
+ var szy = itemResult.Substring(0, pos);
+ var ssy = itemResult.Substring(pos + 1);
+ if (!decimal.TryParse(szy, out szyDecimal))
+ {
+ return null;
+ }
+
+ if (!decimal.TryParse(ssy, out ssyDecimal))
+ {
+ return null;
+ }
+ if (szyDecimal > 180 || ssyDecimal > 110)
+ {
+ return ""Ⅲ级高血压"";
+ }
+ if (szyDecimal > 160 || ssyDecimal > 100)
+ {
+ return ""Ⅱ级高血压"";
+ }
+ if (szyDecimal > 140 || ssyDecimal > 90)
+ {
+ return ""Ⅰ级高血压"";
+ }
+ return result;
+ ";
+
+
+ DiagnosisBuilder diagnosisBuilder = new DiagnosisBuilder();
+ result = diagnosisBuilder.GetItemDiagnosisResult(patient, code);
+ _output.WriteLine("动态结果:" + result);
+
+
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public string GetItemDiagnosisResultXY(PatientItemDiagnosisInput patient)
+ {
+ string result = "";
+ decimal szyDecimal = 0;
+ decimal ssyDecimal = 0;
+ var itemResult = patient.Item.Result;
+ if (string.IsNullOrWhiteSpace(itemResult))
+ {
+ return null;
+ }
+ if (itemResult == "/")
+ return null;
+ var pos = itemResult.IndexOf("/");
+ var szy = itemResult.Substring(0, pos);
+ var ssy = itemResult.Substring(pos + 1);
+ if (!decimal.TryParse(szy, out szyDecimal))
+ {
+ return null;
+ }
+
+ if (!decimal.TryParse(ssy, out ssyDecimal))
+ {
+ return null;
+ }
+ if (szyDecimal > 180 || ssyDecimal > 110)
+ {
+ return "Ⅲ级高血压";
+ }
+ if (szyDecimal > 160 || ssyDecimal > 100)
+ {
+ return "Ⅱ级高血压";
+ }
+ if (szyDecimal > 140 || ssyDecimal > 90)
+ {
+ return "Ⅰ级高血压";
+ }
return result;
}
@@ -159,7 +431,7 @@ namespace Shentun.Peis
/// 乙肝五项
///
[Fact]
- public void GetAsbitemDiagnosisResultTest()
+ public void GetAsbitemDiagnosisResultYgwxTest()
{
var patient = new PatientAsbitemDiagnosisInput();
patient.SexName = "男";
@@ -169,62 +441,128 @@ namespace Shentun.Peis
new ItemResultInput()
{
ItemId = Guid.NewGuid(),
- ItemName = "身高",
- Result = "122"
+ ItemName = "乙肝表面抗原(HBsAg)",
+ Result = "阳性"
},
new ItemResultInput()
{
ItemId = Guid.NewGuid(),
- ItemName = "体重",
- Result = "221"
+ ItemName = "乙肝表面抗体(抗-HBs)",
+ Result = "阴性"
},
new ItemResultInput()
{
ItemId = Guid.NewGuid(),
- ItemName = "体重指数",
+ ItemName = "乙肝e抗原(HBeAg)",
+ Result = "阳性"
+ },
+ new ItemResultInput()
+ {
+ ItemId = Guid.NewGuid(),
+ ItemName = "乙肝e抗体(抗-HBe)",
+ Result = "阴性"
+ },
+ new ItemResultInput()
+ {
+ ItemId = Guid.NewGuid(),
+ ItemName = "乙肝核心抗体(抗-HBc)",
+ Result = "阳性"
}
};
- var result = GetAsbitemDiagnosisResult(patient);
+ var result = GetAsbitemDiagnosisResultYgwx(patient);
_output.WriteLine("结果:" + result);
string code = @"
- string result = """";
- decimal sg = 0;
- decimal tz = 0;
+ string msg = null;
+ string result1 = """";
+ string result2= """";
+ string result3 = """";
+ string result4 = """";
+ string result5 = """";
foreach (var item in patient.Items)
{
- if (item.ItemName == ""身高"")
- {
- if (decimal.TryParse(item.Result, out sg))
- {
- if (sg == 0)
- {
- return null;
- }
- }
- else
- {
- return null;
- }
-
+ if(item.ItemName == ""乙肝表面抗原(HBsAg)"")
+ {
+ result1 = item.Result;
}
- if (item.ItemName == ""体重"")
- {
- if (decimal.TryParse(item.Result, out tz))
- {
- if (tz == 0)
- {
- return null;
- }
- }
- else
- {
- return null;
- }
-
+ if (item.ItemName == ""乙肝表面抗体(抗-HBs)"")
+ {
+ result2 = item.Result;
+ }
+ if (item.ItemName == ""乙肝e抗原(HBeAg)"")
+ {
+ result3 = item.Result;
}
+ if (item.ItemName == ""乙肝e抗体(抗-HBe)"")
+ {
+ result4 = item.Result;
+ }
+ if (item.ItemName == ""乙肝核心抗体(抗-HBc)"")
+ {
+ result5 = item.Result;
+ }
+
}
- result = (tz /((sg/100) * (sg / 100))).ToString(""0.00"");
- return result;
+ switch (result1 + "","" + result2 + "","" + result3 + "","" + result4 + "","" + result5)
+ {
+ case ""阳性,阴性,阳性,阴性,阳性"":
+ msg = ""乙肝五项检查大三阳"";
+ break;
+ case ""阳性,阴性,阴性,阳性,阳性"":
+ msg = ""乙肝五项检查小三阳"";
+ break;
+ case ""阳性,阴性,阳性,阴性,阴性"":
+ msg = ""乙肝五项检查第一项,第三项阳性"";
+ break;
+ case ""阴性,阴性,阳性,阳性,阳性"":
+ msg = ""乙肝两对半三,四,五阳性"";
+ break;
+ case ""阳性,阴性,阴性,阴性,阳性"":
+ msg = ""乙肝五项检查第一项,第五项阳性"";
+ break;
+ case ""阴性,阴性,阴性,阳性,阳性"":
+ msg = ""乙肝五项检查第四项,第五项阳性"";
+ break;
+ case ""阳性,阴性,阳性,阳性,阴性"":
+ msg = ""乙肝两对半一,三,四阳性"";
+ break;
+ case ""阴性,阴性,阳性,阴性,阳性"":
+ msg = ""乙肝五项检查第三项,第五项阳性"";
+ break;
+ case ""阴性,阴性,阴性,阴性,阴性"":
+ msg = ""乙肝五项全阴"";
+ break;
+ case ""阴性,阳性,阴性,阴性,阴性"":
+ msg = ""乙肝表面抗体阳性"";
+ break;
+ case ""阳性,阴性,阴性,阴性,阴性"":
+ msg = ""乙肝表面抗原阳性"";
+ break;
+ case ""阴性,阳性,阴性,阳性,阳性"":
+ msg = ""乙肝五项检查第二,第四,第五项阳性"";
+ break;
+ case ""阴性,阴性,阴性,阳性,阴性"":
+ msg = ""乙肝e抗体阳性"";
+ break;
+ case ""阳性,阴性,阴性,阳性,阴性"":
+ msg = ""乙肝五项检查第一项,第四项阳性"";
+ break;
+ case ""阴性,阳性,阴性,阴性,阳性"":
+ msg = ""乙肝五项检查第二项,第五项阳性"";
+ break;
+ case ""阴性,阴性,阴性,阴性,阳性"":
+ msg = ""乙肝核心抗体阳性"";
+ break;
+ case ""阴性,弱阳性,阴性,阴性,阴性"":
+ msg = ""乙肝表面抗体弱阳性"";
+ break;
+ case ""阴性,弱阳性,阴性,阴性,阳性"":
+ msg = ""乙肝五项检查第二项弱阳性,第五项阳性"";
+ break;
+ default:
+ msg = """";
+ break;
+ }
+ return msg;
";
@@ -235,10 +573,99 @@ namespace Shentun.Peis
}
- public string GetAsbitemDiagnosisResult(PatientAsbitemDiagnosisInput patient)
+ public string GetAsbitemDiagnosisResultYgwx(PatientAsbitemDiagnosisInput patient)
{
- string result = "";
- return result;
+ string msg = null;
+ string result1 = "";
+ string result2 = "";
+ string result3 = "";
+ string result4 = "";
+ string result5 = "";
+ foreach (var item in patient.Items)
+ {
+ if (item.ItemName == "乙肝表面抗原(HBsAg)")
+ {
+ result1 = item.Result;
+ }
+ if (item.ItemName == "乙肝表面抗体(抗-HBs)")
+ {
+ result2 = item.Result;
+ }
+ if (item.ItemName == "乙肝e抗原(HBeAg)")
+ {
+ result3 = item.Result;
+ }
+ if (item.ItemName == "乙肝e抗体(抗-HBe)")
+ {
+ result4 = item.Result;
+ }
+ if (item.ItemName == "乙肝核心抗体(抗-HBc)")
+ {
+ result5 = item.Result;
+ }
+
+ }
+ switch (result1 + "," + result2 + "," + result3 + "," + result4 + "," + result5)
+ {
+ case "阳性,阴性,阳性,阴性,阳性":
+ msg = "乙肝五项检查大三阳";
+ break;
+ case "阳性,阴性,阴性,阳性,阳性":
+ msg = "乙肝五项检查小三阳";
+ break;
+ case "阳性,阴性,阳性,阴性,阴性":
+ msg = "乙肝五项检查第一项,第三项阳性";
+ break;
+ case "阴性,阴性,阳性,阳性,阳性":
+ msg = "乙肝两对半三,四,五阳性";
+ break;
+ case "阳性,阴性,阴性,阴性,阳性":
+ msg = "乙肝五项检查第一项,第五项阳性";
+ break;
+ case "阴性,阴性,阴性,阳性,阳性":
+ msg = "乙肝五项检查第四项,第五项阳性";
+ break;
+ case "阳性,阴性,阳性,阳性,阴性":
+ msg = "乙肝两对半一,三,四阳性";
+ break;
+ case "阴性,阴性,阳性,阴性,阳性":
+ msg = "乙肝五项检查第三项,第五项阳性";
+ break;
+ case "阴性,阴性,阴性,阴性,阴性":
+ msg = "乙肝五项全阴";
+ break;
+ case "阴性,阳性,阴性,阴性,阴性":
+ msg = "乙肝表面抗体阳性";
+ break;
+ case "阳性,阴性,阴性,阴性,阴性":
+ msg = "乙肝表面抗原阳性";
+ break;
+ case "阴性,阳性,阴性,阳性,阳性":
+ msg = "乙肝五项检查第二,第四,第五项阳性";
+ break;
+ case "阴性,阴性,阴性,阳性,阴性":
+ msg = "乙肝e抗体阳性";
+ break;
+ case "阳性,阴性,阴性,阳性,阴性":
+ msg = "乙肝五项检查第一项,第四项阳性";
+ break;
+ case "阴性,阳性,阴性,阴性,阳性":
+ msg = "乙肝五项检查第二项,第五项阳性";
+ break;
+ case "阴性,阴性,阴性,阴性,阳性":
+ msg = "乙肝核心抗体阳性";
+ break;
+ case "阴性,弱阳性,阴性,阴性,阴性":
+ msg = "乙肝表面抗体弱阳性";
+ break;
+ case "阴性,弱阳性,阴性,阴性,阳性":
+ msg = "乙肝五项检查第二项弱阳性,第五项阳性";
+ break;
+ default:
+ msg = "";
+ break;
+ }
+ return msg;
}
}
}