diff --git a/src/Shentun.Peis.Application/DiagnosisFunctions/DiagnosisBuilder.cs b/src/Shentun.Peis.Application/DiagnosisFunctions/DiagnosisBuilder.cs index 77f25ee..2439319 100644 --- a/src/Shentun.Peis.Application/DiagnosisFunctions/DiagnosisBuilder.cs +++ b/src/Shentun.Peis.Application/DiagnosisFunctions/DiagnosisBuilder.cs @@ -113,6 +113,62 @@ using Shentun.Peis.DiagnosisFunctions; return GetResult(codeInput, "AsbitemDiagnosisResult", "PatientAsbitemDiagnosisInput", patient); } + /// + /// 获取组合项目危急值函数结果 + /// + /// + /// + /// + public bool GetAsbitemCriticalResult(PatientAsbitemDiagnosisInput patient, string codeInput) + { + string result = GetResult(codeInput, "AsbitemCriticalResult", "PatientAsbitemDiagnosisInput", patient); + if (string.IsNullOrWhiteSpace(result)) + return false; + return Convert.ToBoolean(result); + } + + /// + /// 获取项目危急值函数结果 + /// + /// + /// + /// + public bool GetItemCriticalResult(PatientItemDiagnosisInput patient, string codeInput) + { + string result = GetResult(codeInput, "ItemCriticalResult", "PatientItemDiagnosisInput", patient); + if (string.IsNullOrWhiteSpace(result)) + return false; + return Convert.ToBoolean(result); + } + + /// + /// 获取组合项目随访函数结果 + /// + /// + /// + /// + public bool GetAsbitemFollowUpResult(PatientAsbitemDiagnosisInput patient, string codeInput) + { + string result = GetResult(codeInput, "AsbitemFollowUpResult", "PatientAsbitemDiagnosisInput", patient); + if (string.IsNullOrWhiteSpace(result)) + return false; + return Convert.ToBoolean(result); + } + + /// + /// 获取项目随访函数结果 + /// + /// + /// + /// + public bool GetItemFollowUpResult(PatientItemDiagnosisInput patient, string codeInput) + { + string result = GetResult(codeInput, "ItemFollowUpResult", "PatientItemDiagnosisInput", patient); + if (string.IsNullOrWhiteSpace(result)) + return false; + return Convert.ToBoolean(result); + } + } /// @@ -189,7 +245,7 @@ using Shentun.Peis.DiagnosisFunctions; public class DoctorCheckItemDiagnosisResult { public char IsNameIntoSummary { get; set; } - public string ItemName { get; set;} + public string ItemName { get; set; } public List ItemDiagnosisTypeResults { get; set; } = new List(); } diff --git a/src/Shentun.Peis.Application/DiagnosisFunctions/DiagnosisFunctionAppService.cs b/src/Shentun.Peis.Application/DiagnosisFunctions/DiagnosisFunctionAppService.cs index 64f2379..f52796b 100644 --- a/src/Shentun.Peis.Application/DiagnosisFunctions/DiagnosisFunctionAppService.cs +++ b/src/Shentun.Peis.Application/DiagnosisFunctions/DiagnosisFunctionAppService.cs @@ -4,8 +4,10 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.EntityFrameworkCore; using NPOI.DDF; +using NPOI.POIFS.Properties; using NUglify.Helpers; using Shentun.Peis.Enums; +using Shentun.Peis.ItemResultMatchs; using Shentun.Peis.Models; using Shentun.Peis.RegisterCheckItems; using Shentun.Peis.Sexs; @@ -23,6 +25,7 @@ using Volo.Abp; using Volo.Abp.Application.Services; using Volo.Abp.Domain.Repositories; using Volo.Abp.Uow; +using Volo.Abp.Users; using Xceed.Document.NET; using static Microsoft.EntityFrameworkCore.DbLoggerCategory; @@ -55,6 +58,11 @@ namespace Shentun.Peis.DiagnosisFunctions private string _highSuffix; string[] _numArry = { "①", "②", "③", "④", "⑤", "⑥", "⑦", "⑧", "⑨", "⑩", "⑪", "⑫", "⑬", "⑭", "⑮", "⑯", "⑰", "⑱", "⑲", "⑳" }; + + private readonly IRepository _criticalFollowValueRepository; + private readonly ICurrentUser _currentUser; + private readonly IRepository _followUpRepository; + public DiagnosisFunctionAppService( IRepository patientRegisterRepository, IRepository registerAsbitemRepository, @@ -70,7 +78,10 @@ namespace Shentun.Peis.DiagnosisFunctions IRepository unitRepository, CacheService cacheService, SysParmValueManager sysParmValueManager, - RegisterCheckItemManager registerCheckItemManager) + RegisterCheckItemManager registerCheckItemManager, + IRepository criticalFollowValueRepository, + ICurrentUser currentUser, + IRepository followUpRepository) { this._patientRegisterRepository = patientRegisterRepository; @@ -88,7 +99,9 @@ namespace Shentun.Peis.DiagnosisFunctions _sysParmValueManager = sysParmValueManager; _registerCheckItemManager = registerCheckItemManager; _unitRepository = unitRepository; - + _criticalFollowValueRepository = criticalFollowValueRepository; + _currentUser = currentUser; + _followUpRepository = followUpRepository; } @@ -234,6 +247,7 @@ namespace Shentun.Peis.DiagnosisFunctions /// /// [HttpPost("api/app/diagnosisfunction/getdiagnosisresult")] + [RemoteService(false)] public async Task GetDiagnosisResultAsync(GetDiagnosisResultRequestDto input) { throw new Exception("禁止使用"); @@ -367,6 +381,12 @@ namespace Shentun.Peis.DiagnosisFunctions } } + + /// + /// 生成小结 + /// + /// + /// [HttpPost("api/app/DiagnosisFunction/GetDoctorCheckDiagnosisResultAsync")] public async Task GetDoctorCheckDiagnosisResultAsync(GetDiagnosisResultRequestDto input) { @@ -428,12 +448,17 @@ namespace Shentun.Peis.DiagnosisFunctions { var asbitemInput = new AsbitemInput() { + RegisterCheckId = item.registerCheck.Id, AsbitemId = item.asbitem.Id, AsbitemName = item.asbitem.DisplayName, IsDiagnosisFunction = item.asbitem.IsDiagnosisFunction, DiagnosisFunction = item.asbitem.DiagnosisFunction, IsContinueProcess = item.asbitem.IsContinueProcess, DefaultResult = item.asbitem.DefaultResult, + CriticalValueFunction = item.asbitem.CriticalValueFunction, + FollowUpFunction = item.asbitem.FollowUpFunction, + IsCriticalValueFunction = item.asbitem.IsCriticalValueFunction, + IsFollowUpFunction = item.asbitem.IsFollowUpFunction }; doctorCheckDiagnosisInput.Asbitems.Add(asbitemInput); } @@ -448,6 +473,7 @@ namespace Shentun.Peis.DiagnosisFunctions } var itemInput = new ItemInput() { + RegisterCheckId = item.registerCheck.Id, ItemId = item.item.Id, ItemName = item.item.DisplayName, Unit = (item.unitHaveEmpty == null) ? "" : item.unitHaveEmpty.DisplayName, @@ -462,7 +488,11 @@ namespace Shentun.Peis.DiagnosisFunctions DisplayOrder = item.item.DisplayOrder, ItemResultMatches = item.item.ItemResultMatches.ToList(), ItemResultTemplates = item.item.ItemResultTemplates.ToList(), - ReferenceRanges = item.item.ReferenceRanges.ToList() + ReferenceRanges = item.item.ReferenceRanges.ToList(), + CriticalValueFunction = item.item.CriticalValueFunction, + FollowUpFunction = item.item.FollowUpFunction, + IsFollowUpFunction = item.item.IsFollowUpFunction, + IsCriticalValueFunction = item.item.IsCriticalValueFunction }; doctorCheckDiagnosisInput.Items.Add(itemInput); } @@ -500,9 +530,33 @@ namespace Shentun.Peis.DiagnosisFunctions }; resultDto.DiagnosisResultDetails.Add(getDiagnosisResult_Detail); } + + #region 处理危急值函数 + + var isCritical = await GetPatientRegisterIsCriticalAsync(doctorCheckDiagnosisInput, resultDto); + var isFollowUp = false; + if (!isCritical) + { + //随访 + isFollowUp = await GetPatientRegisterIsFollowUpAsync(doctorCheckDiagnosisInput, resultDto); + } + else + { + isFollowUp = true; + } + + if (isCritical || isFollowUp) + { + await CreateFollowUpAsync(query.First().patientRegister.Id); //标记危急值 生成随访记录 + } + #endregion + return resultDto; } + + #region 小结方法 + private List GetItemDiagnosisStringList(List itemDiagnosisList) { var diagnosisList = new List(); @@ -1505,6 +1559,379 @@ namespace Shentun.Peis.DiagnosisFunctions } + #endregion + + #region 危急值函数 + + /// + /// 获取人员是否有危急值项目 + /// 【优先处理组合项目危急值函数 + /// 未触发时执行项目危急值函数 + /// 未触发项目检索危急值关键字 + /// 未触发检索小结是否包含危急值关键字】 + /// + /// + /// + /// + public async Task GetPatientRegisterIsCriticalAsync( + DoctorCheckDiagnosisInput doctorCheckDiagnosisInput, + GetDiagnosisResultDto resultDto) + { + var isCritical = false; + + isCritical = await GetAsbitemCriticalFunction(doctorCheckDiagnosisInput); + + if (isCritical) + { + return isCritical; + } + + var criticalFollowValueList = await _criticalFollowValueRepository.GetListAsync(m => m.CriticalFollowValueFlag == CriticalFollowValueFlag.Critical); + + //检索项目函数+关键字 + isCritical = await GetItemCriticalFunction(doctorCheckDiagnosisInput, criticalFollowValueList); + + if (isCritical) + { + return isCritical; + } + + //检索小结 + foreach (var diagnosisResult in resultDto.DiagnosisResultDetails) + { + isCritical = criticalFollowValueList.Count(m => diagnosisResult.DiagnosisResult.Contains(m.DisplayName)) > 0 ? true : false; + if (isCritical) + break; + } + + return isCritical; + } + + + /// + /// 获取人员是否有需要随访的项目 + /// 【优先处理组合项目随访函数 + /// 未触发时执行项目随访函数 + /// 未触发项目检索随访关键字 + /// 未触发检索小结是否包含随访关键字】 + /// + /// + /// + /// + public async Task GetPatientRegisterIsFollowUpAsync( + DoctorCheckDiagnosisInput doctorCheckDiagnosisInput, + GetDiagnosisResultDto resultDto) + { + var isCritical = false; + + isCritical = await GetAsbitemFollowUpFunction(doctorCheckDiagnosisInput); + + if (isCritical) + { + return isCritical; + } + + var criticalFollowValueList = await _criticalFollowValueRepository.GetListAsync(m => m.CriticalFollowValueFlag == CriticalFollowValueFlag.FollowUp); + + //检索项目函数+关键字 + isCritical = await GetItemFollowUpFunction(doctorCheckDiagnosisInput, criticalFollowValueList); + + if (isCritical) + { + return isCritical; + } + + //检索小结 + foreach (var diagnosisResult in resultDto.DiagnosisResultDetails) + { + isCritical = criticalFollowValueList.Count(m => diagnosisResult.DiagnosisResult.Contains(m.DisplayName)) > 0 ? true : false; + if (isCritical) + break; + } + + return isCritical; + } + + /// + /// 组合项目危急值函数 + /// + /// + /// + private async Task GetAsbitemCriticalFunction(DoctorCheckDiagnosisInput doctorCheckDiagnosisInput) + { + bool isCritical = false; + 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(); + + foreach (var asbitem in doctorCheckDiagnosisInput.Asbitems) + { + if (asbitem.IsCriticalValueFunction == 'Y' && !string.IsNullOrWhiteSpace(asbitem.CriticalValueFunction)) + { + isCritical = diagnosisBuilder.GetAsbitemCriticalResult(patientAsbitemDiagnosisInput, asbitem.DiagnosisFunction); + if (isCritical) + { + await CreateRegisterCheckCritical(asbitem.RegisterCheckId, 'Y'); + break; + } + } + } + + return isCritical; + } + + /// + /// 项目危急值函数 + /// + /// + /// + /// + private async Task GetItemCriticalFunction( + DoctorCheckDiagnosisInput doctorCheckDiagnosisInput, + List criticalFollowValueList + ) + { + bool isCritical = false; + var patientItemDiagnosisInput = new PatientItemDiagnosisInput() + { + SexName = doctorCheckDiagnosisInput.SexName, + Age = doctorCheckDiagnosisInput.Age + }; + + var diagnosisBuilder = new DiagnosisBuilder(); + + foreach (var item in doctorCheckDiagnosisInput.Items) + { + if (string.IsNullOrWhiteSpace(item.Result)) + { + continue; + } + + if (item.IsCriticalValueFunction == 'Y' && !string.IsNullOrWhiteSpace(item.CriticalValueFunction)) + { + var itemResult = new ItemResultInput() + { + ItemId = item.ItemId, + ItemName = item.ItemName, + Result = item.Result + }; + patientItemDiagnosisInput.Item = itemResult; + + + isCritical = diagnosisBuilder.GetItemCriticalResult(patientItemDiagnosisInput, item.CriticalValueFunction); + + if (isCritical) + { + await CreateRegisterCheckItemCritical(item.RegisterCheckId, item.ItemId, 'Y'); + break; + } + + } + + + //关键字检索 + if (criticalFollowValueList.Count(m => item.Result.Contains(m.DisplayName)) > 0) + { + isCritical = true; + } + + if (isCritical) + { + await CreateRegisterCheckItemCritical(item.RegisterCheckId, item.ItemId, 'Y'); + break; + } + + } + + return isCritical; + } + + + /// + /// 组合项目随访函数 + /// + /// + /// + private async Task GetAsbitemFollowUpFunction(DoctorCheckDiagnosisInput doctorCheckDiagnosisInput) + { + bool isFollowUp = false; + 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(); + + foreach (var asbitem in doctorCheckDiagnosisInput.Asbitems) + { + if (asbitem.IsFollowUpFunction == 'Y' && !string.IsNullOrWhiteSpace(asbitem.FollowUpFunction)) + { + isFollowUp = diagnosisBuilder.GetAsbitemFollowUpResult(patientAsbitemDiagnosisInput, asbitem.DiagnosisFunction); + if (isFollowUp) + { + await CreateRegisterCheckCritical(asbitem.RegisterCheckId, 'Y'); + break; + } + } + } + + return isFollowUp; + } + + /// + /// 项目随访函数 + /// + /// + /// + /// + private async Task GetItemFollowUpFunction( + DoctorCheckDiagnosisInput doctorCheckDiagnosisInput, + List criticalFollowValueList + ) + { + bool isFollowUp = false; + var patientItemDiagnosisInput = new PatientItemDiagnosisInput() + { + SexName = doctorCheckDiagnosisInput.SexName, + Age = doctorCheckDiagnosisInput.Age + }; + + var diagnosisBuilder = new DiagnosisBuilder(); + + foreach (var item in doctorCheckDiagnosisInput.Items) + { + if (string.IsNullOrWhiteSpace(item.Result)) + { + continue; + } + + if (item.IsFollowUpFunction == 'Y' && !string.IsNullOrWhiteSpace(item.FollowUpFunction)) + { + var itemResult = new ItemResultInput() + { + ItemId = item.ItemId, + ItemName = item.ItemName, + Result = item.Result + }; + patientItemDiagnosisInput.Item = itemResult; + + + isFollowUp = diagnosisBuilder.GetItemFollowUpResult(patientItemDiagnosisInput, item.FollowUpFunction); + + if (isFollowUp) + { + await CreateRegisterCheckItemCritical(item.RegisterCheckId, item.ItemId, 'N'); + break; + } + + } + + if (criticalFollowValueList.Count(m => item.Result.Contains(m.DisplayName)) > 0) + { + isFollowUp = true; + } + + if (isFollowUp) + { + await CreateRegisterCheckItemCritical(item.RegisterCheckId, item.ItemId, 'N'); + break; + } + + } + + return isFollowUp; + } + + + /// + /// 生成危急值标记、随访记录 + /// + /// + private async Task CreateFollowUpAsync(Guid patientRegisterId) + { + var isFollowUp = await _followUpRepository.FirstOrDefaultAsync(f => f.PatientRegisterId == patientRegisterId); + if (isFollowUp == null) + { + var followUpEnt = new FollowUp + { + IsPhoneComplete = 'N', + IsSmsComplete = 'N', + PatientRegisterId = patientRegisterId + }; + + await _followUpRepository.InsertAsync(followUpEnt); + } + } + + /// + /// 生成明细表危急值相关数据 + /// + private async Task CreateRegisterCheckItemCritical(Guid registerCheckId, Guid itemId, char isCriticalValue) + { + var registerCheckItemEnt = await _registerCheckItemRepository.FirstOrDefaultAsync(m => m.RegisterCheckId == registerCheckId + && m.ItemId == itemId); + if (registerCheckItemEnt != null) + { + registerCheckItemEnt.CriticalRangeValue = ""; + registerCheckItemEnt.IsCriticalValue = isCriticalValue; + registerCheckItemEnt.CriticalValueCreatorId = _currentUser.Id; + registerCheckItemEnt.CriticalValueCreationTime = DateTime.Now; + registerCheckItemEnt.IsCriticalValueAudit = 'N'; + registerCheckItemEnt.IsReview = isCriticalValue; + registerCheckItemEnt.FollowUpFlag = '1'; + + await _registerCheckItemRepository.UpdateAsync(registerCheckItemEnt); + } + + await CreateRegisterCheckCritical(registerCheckId, isCriticalValue); + } + + /// + /// 生成registerCheck表危急值相关数据 + /// + private async Task CreateRegisterCheckCritical(Guid registerCheckId, char isCriticalValue) + { + var registerCheckEnt = await _registerCheckRepository.FirstOrDefaultAsync(m => m.Id == registerCheckId); + if (registerCheckEnt != null) + { + registerCheckEnt.CriticalRangeValue = ""; + registerCheckEnt.IsCriticalValue = isCriticalValue; + registerCheckEnt.CriticalValueCreatorId = _currentUser.Id; + registerCheckEnt.CriticalValueCreationTime = DateTime.Now; + registerCheckEnt.IsCriticalValueAudit = 'N'; + registerCheckEnt.IsReview = isCriticalValue; + registerCheckEnt.FollowUpFlag = '1'; + + await _registerCheckRepository.UpdateAsync(registerCheckEnt); + } + } + #endregion + } } \ No newline at end of file diff --git a/src/Shentun.Peis.Application/DiagnosisFunctions/DoctorCheckDiagnosisInput.cs b/src/Shentun.Peis.Application/DiagnosisFunctions/DoctorCheckDiagnosisInput.cs index ddafee4..0424c28 100644 --- a/src/Shentun.Peis.Application/DiagnosisFunctions/DoctorCheckDiagnosisInput.cs +++ b/src/Shentun.Peis.Application/DiagnosisFunctions/DoctorCheckDiagnosisInput.cs @@ -19,6 +19,7 @@ namespace Shentun.Peis.DiagnosisFunctions public class AsbitemInput { + public Guid RegisterCheckId { get; set; } /// /// 组合项目ID /// @@ -32,10 +33,22 @@ namespace Shentun.Peis.DiagnosisFunctions public char IsContinueProcess { get; set; } public string DefaultResult { get; set; } + /// + /// 危急值 + /// + public char IsCriticalValueFunction { get; set; } + public string CriticalValueFunction { get; set; } + /// + /// 随访 + /// + public char IsFollowUpFunction { get; set; } + public string FollowUpFunction { get; set; } + } public class ItemInput { + public Guid RegisterCheckId { get; set; } /// /// 项目ID /// @@ -57,5 +70,16 @@ namespace Shentun.Peis.DiagnosisFunctions public List ItemResultMatches { get; set; } public List ItemResultTemplates { get; set; } public List ReferenceRanges { get; set; } + + /// + /// 危急值 + /// + public char IsCriticalValueFunction { get; set; } + public string CriticalValueFunction { get; set; } + /// + /// 随访 + /// + public char IsFollowUpFunction { get; set; } + public string FollowUpFunction { get; set; } } } diff --git a/src/Shentun.Peis.Application/PrintReports/PrintReportAppService.cs b/src/Shentun.Peis.Application/PrintReports/PrintReportAppService.cs index cbdcbe0..3ddd5c1 100644 --- a/src/Shentun.Peis.Application/PrintReports/PrintReportAppService.cs +++ b/src/Shentun.Peis.Application/PrintReports/PrintReportAppService.cs @@ -240,9 +240,9 @@ namespace Shentun.Peis.PrintReports Age = a.Age, PatientRegisterId = a.Id, CustomerOrgGroupName = ac.DisplayName, - CustomerOrgName = _cacheService.GetTopCustomerOrgNameAsync(a.CustomerOrgId).Result, - CustomerOrgShortName = _cacheService.GetTopCustomerOrgAsync(a.CustomerOrgId).Result.ShortName, - DepartmentName = _cacheService.GetCustomerOrgNameAsync(a.CustomerOrgId).Result, + CustomerOrgName = _cacheService.GetTopCustomerOrgNameAsync(a.CustomerOrgId).GetAwaiter().GetResult(), + CustomerOrgShortName = _cacheService.GetTopCustomerOrgAsync(a.CustomerOrgId).GetAwaiter().GetResult().ShortName, + DepartmentName = _cacheService.GetAllDepartmentNameAsync(a.CustomerOrgId).GetAwaiter().GetResult(), IdNo = e.IdNo, JobCardNo = a.JobCardNo, MedicalCardNo = a.MedicalCardNo, @@ -364,7 +364,7 @@ namespace Shentun.Peis.PrintReports SampleTypeName = (o.sampleTypeHaveEmpty == null) ? "" : o.sampleTypeHaveEmpty.DisplayName, SexName = o.sex.DisplayName, CustomerOrgName = _cacheService.GetTopCustomerOrgShortNameAsync(o.patientRegister.CustomerOrgId).Result, - DepartmentName = _cacheService.GetCustomerOrgShortNameAsync(o.patientRegister.CustomerOrgId).Result, + DepartmentName = _cacheService.GetAllDepartmentNameAsync(o.patientRegister.CustomerOrgId).Result, IsPrint = o.lisRequest.IsPrint, IsSignIn = o.lisRequest.IsSignIn, SamplingTime = o.lisRequest.SamplingTime, @@ -545,7 +545,7 @@ namespace Shentun.Peis.PrintReports SampleContainerRemark = lisRequestInfo.sampleContainer.ContainerRemark, AsbitemNames = string.Join(",", list.OrderBy(o => o.asbitem.DisplayOrder).Select(o => o.asbitem.DisplayName).Distinct()), CustomerOrgName = _cacheService.GetTopCustomerOrgShortNameAsync(lisRequestInfo.patientRegister.CustomerOrgId).Result, - DepartmentName = _cacheService.GetCustomerOrgShortNameAsync(lisRequestInfo.patientRegister.CustomerOrgId).Result, + DepartmentName = _cacheService.GetAllDepartmentNameAsync(lisRequestInfo.patientRegister.CustomerOrgId).Result, SampleGroupName = lisRequestInfo.sampleGroupName, MobileTelephone = lisRequestInfo.patient.MobileTelephone, SamplePrintCount = lisRequestInfo.samplePrintCount @@ -819,7 +819,7 @@ namespace Shentun.Peis.PrintReports PatientRegisterNo = s.FirstOrDefault().PatientRegisterNo, SexName = s.FirstOrDefault().SexName, CustomerOrgName = _cacheService.GetTopCustomerOrgShortNameAsync(s.FirstOrDefault().CustomerOrgId).Result, - DepartmentName = _cacheService.GetCustomerOrgShortNameAsync(s.FirstOrDefault().CustomerOrgId).Result, + DepartmentName = _cacheService.GetAllDepartmentNameAsync(s.FirstOrDefault().CustomerOrgId).Result, MobileTelephone = s.FirstOrDefault().MobileTelephone }); } @@ -835,7 +835,7 @@ namespace Shentun.Peis.PrintReports PatientRegisterNo = s.FirstOrDefault().PatientRegisterNo, SexName = s.FirstOrDefault().SexName, CustomerOrgName = _cacheService.GetTopCustomerOrgShortNameAsync(s.FirstOrDefault().CustomerOrgId).Result, - DepartmentName = _cacheService.GetCustomerOrgShortNameAsync(s.FirstOrDefault().CustomerOrgId).Result, + DepartmentName = _cacheService.GetAllDepartmentNameAsync(s.FirstOrDefault().CustomerOrgId).Result, MobileTelephone = s.FirstOrDefault().MobileTelephone }); } @@ -900,7 +900,7 @@ namespace Shentun.Peis.PrintReports PatientRegisterNo = queryGroup.FirstOrDefault().PatientRegisterNo, SexName = queryGroup.FirstOrDefault().SexName, CustomerOrgName = _cacheService.GetTopCustomerOrgShortNameAsync(queryGroup.FirstOrDefault().CustomerOrgId).Result, - DepartmentName = _cacheService.GetCustomerOrgShortNameAsync(queryGroup.FirstOrDefault().CustomerOrgId).Result + DepartmentName = _cacheService.GetAllDepartmentNameAsync(queryGroup.FirstOrDefault().CustomerOrgId).Result }; } else if (queryGroup.Where(m => m.BarcodeMode == '1').Count() > 0) @@ -914,7 +914,7 @@ namespace Shentun.Peis.PrintReports PatientRegisterNo = queryGroup.FirstOrDefault().PatientRegisterNo, SexName = queryGroup.FirstOrDefault().SexName, CustomerOrgName = _cacheService.GetTopCustomerOrgShortNameAsync(queryGroup.FirstOrDefault().CustomerOrgId).Result, - DepartmentName = _cacheService.GetCustomerOrgShortNameAsync(queryGroup.FirstOrDefault().CustomerOrgId).Result + DepartmentName = _cacheService.GetAllDepartmentNameAsync(queryGroup.FirstOrDefault().CustomerOrgId).Result }; } diff --git a/src/Shentun.Peis.Domain.Shared/Enums/CriticalFollowValueFlag.cs b/src/Shentun.Peis.Domain.Shared/Enums/CriticalFollowValueFlag.cs new file mode 100644 index 0000000..9d2ae73 --- /dev/null +++ b/src/Shentun.Peis.Domain.Shared/Enums/CriticalFollowValueFlag.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Text; + +namespace Shentun.Peis.Enums +{ + /// + /// 危急随访值标志 + /// + public static class CriticalFollowValueFlag + { + /// + /// 危急值 + /// + [Description("危急值")] + public const char Critical = '0'; + + + /// + /// 随访值 + /// + [Description("随访值")] + public const char FollowUp = '1'; + + + } +} diff --git a/src/Shentun.Peis.Domain/CacheService.cs b/src/Shentun.Peis.Domain/CacheService.cs index 0852933..ee1a98f 100644 --- a/src/Shentun.Peis.Domain/CacheService.cs +++ b/src/Shentun.Peis.Domain/CacheService.cs @@ -3,6 +3,7 @@ using Microsoft.Extensions.Caching.Distributed; using Microsoft.Extensions.Caching.Memory; using Shentun.Peis.Enums; using Shentun.Peis.Models; +using Shentun.Peis.SysParmValues; using System; using System.Collections.Generic; using System.Linq; @@ -48,6 +49,8 @@ namespace Shentun.Peis private readonly IDistributedCache _sampleTypeCache; private readonly IRepository _sampleTypeRepository; + private readonly SysParmValueManager _sysParmValueManager; + public CacheService( IDistributedCache userCache, IMemoryCache customerOrgCache, @@ -73,7 +76,8 @@ namespace Shentun.Peis IRepository personnelTypeRepository, IDistributedCache customerOrgTopNameCache, IDistributedCache sampleTypeCache, - IRepository sampleTypeRepository) + IRepository sampleTypeRepository, + SysParmValueManager sysParmValueManager) { _userCache = userCache; _userRepository = userRepository; @@ -110,6 +114,7 @@ namespace Shentun.Peis _customerOrgTopNameCache = customerOrgTopNameCache; _sampleTypeCache = sampleTypeCache; _sampleTypeRepository = sampleTypeRepository; + _sysParmValueManager = sysParmValueManager; } private async Task GetUserAsync(Guid id) @@ -311,6 +316,11 @@ namespace Shentun.Peis return entity.DisplayName; } + /// + /// 获取部门名称 + /// + /// + /// public async Task GetCustomerOrgAsync(Guid id) { var entity = (CustomerOrg)_customerOrgCache.Get(id); @@ -324,6 +334,11 @@ namespace Shentun.Peis return entity; } + /// + /// 获取部门名称 + /// + /// + /// public async Task GetCustomerOrgNameAsync(Guid? id) { if (id == null || id == default(Guid) || !id.HasValue) @@ -334,6 +349,11 @@ namespace Shentun.Peis return entity.DisplayName; } + /// + /// 获取一级单位 + /// + /// + /// public async Task GetTopCustomerOrgAsync(Guid id) { var entity = (CustomerOrg)_customerOrgCache.Get(id); @@ -379,6 +399,62 @@ namespace Shentun.Peis return customerOrgEnt.ShortName; } + /// + /// 获取所有部门名称 + /// + /// + /// + public async Task GetAllDepartmentNameAsync(Guid CustomerOrgId) + { + var departmentDisplayMode = await _sysParmValueManager.GetSysParmValueAsync(Guid.Empty, "department_display_mode"); + if (departmentDisplayMode == "1") + { + List customerOrgNames = new List(); + await GetAllDepartmentNameAsync(customerOrgNames, CustomerOrgId); + + if (customerOrgNames.Count > 1) + { + customerOrgNames.RemoveAt(0); + return string.Join("\\", customerOrgNames); + } + else + { + //无部门 + return ""; + } + } + else + { + //兼容不设置系统参数的 + return await GetCustomerOrgNameAsync(CustomerOrgId); + } + + + } + + /// + /// 遍历获取单位数据 + /// + /// + /// + /// + public async Task GetAllDepartmentNameAsync(List customerOrgNames, Guid? customerOrgId) + { + if (customerOrgId != null) + { + var customerOrgEnt = await GetCustomerOrgAsync(customerOrgId.Value); + if (customerOrgEnt != null) + { + if (string.IsNullOrWhiteSpace(customerOrgEnt.ShortName)) + customerOrgNames.AddFirst(customerOrgEnt.DisplayName); + else + customerOrgNames.AddFirst(customerOrgEnt.ShortName); + + await GetAllDepartmentNameAsync(customerOrgNames, customerOrgEnt.ParentId); + } + } + } + /// /// 缓存取单位名称 /// diff --git a/test/Shentun.Peis.Application.Tests/DiagnosisFunctionAppServiceTest.cs b/test/Shentun.Peis.Application.Tests/DiagnosisFunctionAppServiceTest.cs index 4c4c9a8..e7b8a55 100644 --- a/test/Shentun.Peis.Application.Tests/DiagnosisFunctionAppServiceTest.cs +++ b/test/Shentun.Peis.Application.Tests/DiagnosisFunctionAppServiceTest.cs @@ -1052,5 +1052,7 @@ namespace Shentun.Peis return itemResult; } + + } }