From 6aa3ffb060d01ae17bbb6d0b6271c8f2e5a8c129 Mon Sep 17 00:00:00 2001 From: "DESKTOP-G961P6V\\Zhh" <839860190@qq.com> Date: Fri, 19 Apr 2024 21:33:40 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=BC=E8=BF=B0=E5=BB=BA=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SumSuggestionHeaders/SumSuggestionDto.cs | 51 +++ .../PatientRegisterAppService.cs | 36 ++- .../RegisterChecks/RegisterCheckAppService.cs | 5 +- .../SumSuggestionHeaderAppService.cs | 299 +++++++++++------- .../SumSummaryHeaderAppService.cs | 38 ++- .../Enums/SuggestionTypeFlag.cs | 10 +- .../SumSummaryHeaderManager.cs | 78 ++++- .../PatientRegisterAppServiceTest.cs | 137 ++++---- .../SumSuggestionHeaderAppServiceTest.cs | 44 +++ .../SumSummaryHeaderAppServiceTest.cs | 44 +++ 10 files changed, 538 insertions(+), 204 deletions(-) create mode 100644 src/Shentun.Peis.Application.Contracts/SumSuggestionHeaders/SumSuggestionDto.cs create mode 100644 test/Shentun.Peis.Application.Tests/SumSuggestionHeaderAppServiceTest.cs create mode 100644 test/Shentun.Peis.Application.Tests/SumSummaryHeaderAppServiceTest.cs diff --git a/src/Shentun.Peis.Application.Contracts/SumSuggestionHeaders/SumSuggestionDto.cs b/src/Shentun.Peis.Application.Contracts/SumSuggestionHeaders/SumSuggestionDto.cs new file mode 100644 index 0000000..c44992e --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/SumSuggestionHeaders/SumSuggestionDto.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.SumSuggestionHeaders +{ + public class SumSuggestionDto + { + /// + /// 建议标题 + /// + public string SuggestionTitle { get; set; } + /// + /// 建议标志 + /// + public char? SuggestionFlag { get; set; } + + /// + /// 诊断列表 + /// + public List DiagnosisIds { get; set; } + + /// + /// 排序值 + /// + public int DisplayOrder { get; set; } + /// + /// 医学解释 + /// + public List MedicalInterpretations = new List(); + /// + /// 常见原因 + /// + public List CommonReasons = new List(); + /// + /// 健康指导 + /// + public List HealthGuidances = new List(); + + + } + public class SumSuggestionContentData + { + /// + /// 建议内容 + /// + public string SuggestionContent { get; set; } + + public int? DisplayOrder { get; set; } + } +} diff --git a/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs b/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs index 8b063bd..16bf4d6 100644 --- a/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs +++ b/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs @@ -1409,6 +1409,7 @@ namespace Shentun.Peis.PatientRegisters [HttpPost("api/app/patientregister/updatepatientregisterauditordoctor")] public async Task UpdatePatientRegisterAuditorDoctorAsync(UpdatePatientRegisterAuditorDoctorDto input) { + if (input == null || input.PatientRegisterId == Guid.Empty) { throw new UserFriendlyException("请求参数有误"); @@ -1430,6 +1431,7 @@ namespace Shentun.Peis.PatientRegisters [HttpPost("api/app/patientregister/updatepatientregistersummarydoctor")] public async Task UpdatePatientRegisterSummaryDoctorAsync(UpdatePatientRegisterSummaryDoctorDto input) { + throw new UserFriendlyException("禁止使用"); if (input == null || input.PatientRegisterId == Guid.Empty) { throw new UserFriendlyException("请求参数有误"); @@ -1458,12 +1460,15 @@ namespace Shentun.Peis.PatientRegisters var entity = await _repository.GetAsync(input.PatientRegisterId); var entitydto = ObjectMapper.Map(input); var newentity = await _manager.UpdatePatientRegisterSummaryDoctorAsync(entitydto, entity); + //删除综述题头时通过级联关系删除相应的综述内容 + await _sumSummaryHeaderRepository.DeleteAsync(m => m.PatientRegisterId == input.PatientRegisterId, true); + //先删除建议内容 + await _sumSuggestionHeaderRepository.DeleteAsync(m => m.PatientRegisterId == input.PatientRegisterId, true); + //删除对应的诊断数据 + await _sumDiagnosisRepository.DeleteAsync(m => m.PatientRegisterId == input.PatientRegisterId, true); //更新综述 - if(input.SumSummarys.Any()) + if (input.SumSummarys.Any()) { - //删除综述题头时通过级联关系删除相应的综述内容 - await _sumSummaryHeaderRepository.DeleteAsync(m => m.PatientRegisterId == input.PatientRegisterId, true); - foreach (var item in input.SumSummarys) { #region 插入SumSummaryHeader @@ -1472,7 +1477,6 @@ namespace Shentun.Peis.PatientRegisters summaryFlag: null, displayOrder: input.SumSummarys.IndexOf(item) + 1); - var sumSummaryHeaderEnt_New = await _sumSummaryHeaderRepository.InsertAsync(sumSummaryHeaderEnt, true); if (sumSummaryHeaderEnt_New != null) @@ -1494,15 +1498,19 @@ namespace Shentun.Peis.PatientRegisters #endregion } } - //更新建议 + //更新建议和诊断 if (input.SumSuggestions.Any()) { - //先删除总诊头跟内容 - await _sumSuggestionHeaderRepository.DeleteAsync(m => m.PatientRegisterId == input.PatientRegisterId, true); - - //删除对应的诊断数据 - await _sumDiagnosisRepository.DeleteAsync(m => m.PatientRegisterId == input.PatientRegisterId, true); - + //判断有没有重复诊断 + List diagnosisList = new List(); + foreach (var item in input.SumSuggestions) + { + diagnosisList.AddRange(item.DiagnosisIds); + } + if(diagnosisList.Count() != diagnosisList.Distinct().Count()) + { + throw new UserFriendlyException("不允许有重复诊断"); + } foreach (var item in input.SumSuggestions) { #region 插入SumSuggestionHeader @@ -1531,6 +1539,7 @@ namespace Shentun.Peis.PatientRegisters }; await _sumDiagnosisRepository.InsertAsync(sumDiagnosis); } + } #endregion @@ -1552,9 +1561,8 @@ namespace Shentun.Peis.PatientRegisters #endregion } } - //更新诊断 - return ObjectMapper.Map(newentity); + return ObjectMapper.Map(newentity); } /// diff --git a/src/Shentun.Peis.Application/RegisterChecks/RegisterCheckAppService.cs b/src/Shentun.Peis.Application/RegisterChecks/RegisterCheckAppService.cs index 2c10f4f..d429492 100644 --- a/src/Shentun.Peis.Application/RegisterChecks/RegisterCheckAppService.cs +++ b/src/Shentun.Peis.Application/RegisterChecks/RegisterCheckAppService.cs @@ -11,7 +11,6 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using TencentCloud.Ame.V20190916.Models; using Volo.Abp; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; @@ -124,7 +123,9 @@ namespace Shentun.Peis.RegisterChecks .Include(x => x.RegisterCheckAsbitems) .ThenInclude(x => x.Asbitem) .Where(m => m.RegisterCheckAsbitems.Select(s => s.PatientRegisterId).Contains(PatientRegisterId)).ToList(); - + //排序 + entlist = entlist.OrderBy(o=>o.RegisterCheckAsbitems.Max(o=>o.Asbitem.ItemType.DisplayOrder)).ToList() + .OrderBy(o=>o.RegisterCheckAsbitems.Max(o=>o.Asbitem.DisplayOrder)).ToList(); var userList = await _userRepository.GetListAsync(); var entdto = entlist.Select(s => new RegisterCheckOrAsbitemNameOrIsChargeDto diff --git a/src/Shentun.Peis.Application/SumSuggestionHeaders/SumSuggestionHeaderAppService.cs b/src/Shentun.Peis.Application/SumSuggestionHeaders/SumSuggestionHeaderAppService.cs index 9c5aa80..e2932c5 100644 --- a/src/Shentun.Peis.Application/SumSuggestionHeaders/SumSuggestionHeaderAppService.cs +++ b/src/Shentun.Peis.Application/SumSuggestionHeaders/SumSuggestionHeaderAppService.cs @@ -1,6 +1,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; +using Shentun.Peis.Enums; using Shentun.Peis.Models; using Shentun.Peis.SumSuggestionContents; using Shentun.Peis.SumSummaryContents; @@ -27,192 +28,256 @@ namespace Shentun.Peis.SumSuggestionHeaders private readonly IRepository _sumSuggestionContentRepository; private readonly IRepository _registerCheckRepository; private readonly IRepository _sumDiagnosisRepository; - + private readonly IRepository _patientRegisterRepository; + private readonly IRepository _diagnosisRepository; + private readonly SumSummaryHeaderManager _sumSummaryHeaderManager; public SumSuggestionHeaderAppService( IRepository sumSuggestionHeaderRepository, IRepository sumSuggestionContentRepository, IRepository registerCheckRepository, - IRepository sumDiagnosisRepository + IRepository sumDiagnosisRepository, + IRepository patientRegisterRepository, + IRepository diagnosisRepository, + SumSummaryHeaderManager sumSummaryHeaderManager ) { this._sumSuggestionHeaderRepository = sumSuggestionHeaderRepository; this._sumSuggestionContentRepository = sumSuggestionContentRepository; this._registerCheckRepository = registerCheckRepository; this._sumDiagnosisRepository = sumDiagnosisRepository; + _patientRegisterRepository = patientRegisterRepository; + _sumSummaryHeaderManager = sumSummaryHeaderManager; + _diagnosisRepository = diagnosisRepository; } /// /// 获取人员总检诊台建议 (如还未录入,获取医生诊台录入的建议) /// - /// 人员登记ID + /// 人员登记ID /// [HttpGet("api/app/sumsuggestionheader/getsumsuggestionlist")] - public async Task> GetSumSuggestionListAsync(Guid PatientRegisterId) + public async Task> GetSumSuggestionListAsync(Guid patientRegisterId) { - List msg = new List(); - + List msg = new List(); - var query = from a in await _sumSuggestionHeaderRepository.GetQueryableAsync() - join b in await _sumDiagnosisRepository.GetQueryableAsync() on new { a.PatientRegisterId, a.Id } equals new { b.PatientRegisterId, Id = b.SumSuggestionHeaderId } into bb - from ab in bb.DefaultIfEmpty() - join c in await _sumSuggestionContentRepository.GetQueryableAsync() on a.Id equals c.SumSuggestionHeaderId into cc - from ac in cc.DefaultIfEmpty() - where (a.PatientRegisterId == PatientRegisterId) - orderby a.DisplayOrder ascending, ac.DisplayOrder ascending + var patientRegister = await _patientRegisterRepository.GetAsync(patientRegisterId); + var query = from sumSuggestionHeader in await _sumSuggestionHeaderRepository.GetQueryableAsync() + join sumDiagnosis in await _sumDiagnosisRepository.GetQueryableAsync() + on new { sumSuggestionHeader.PatientRegisterId, sumSuggestionHeader.Id } equals new { sumDiagnosis.PatientRegisterId, Id = sumDiagnosis.SumSuggestionHeaderId } into bb + from sumDiagnosisHaveEmpty in bb.DefaultIfEmpty() + join sumSuggestionContent in await _sumSuggestionContentRepository.GetQueryableAsync() + on sumSuggestionHeader.Id equals sumSuggestionContent.SumSuggestionHeaderId into cc + from sumSuggestionContentHaveEmpty in cc.DefaultIfEmpty() + where (sumSuggestionHeader.PatientRegisterId == patientRegisterId) + orderby sumSuggestionHeader.DisplayOrder ascending, sumSuggestionContentHaveEmpty.DisplayOrder ascending select new { - a, - ab, - ac + sumSuggestionHeader, + sumDiagnosisHaveEmpty, + sumSuggestionContentHaveEmpty }; - if (query.Any()) + if (patientRegister.CompleteFlag == PatientRegisterCompleteFlag.GeneralInspected) { - msg = query.GroupBy(g => g.a.Id).Select(s => new SumSuggestionHeaderOrContentDto + msg = query.GroupBy(g => g.sumSuggestionHeader.Id).Select(s => new SumSuggestionDto { - SuggestionTitle = s.FirstOrDefault().a.SuggestionTitle, - SuggestionFlag = s.FirstOrDefault().a.SuggestionFlag, - PatientRegisterId = s.FirstOrDefault().a.PatientRegisterId, - DisplayOrder = s.FirstOrDefault().a.DisplayOrder, - Id = s.FirstOrDefault().a.Id, - DiagnosisId = s.FirstOrDefault().ab != null ? s.FirstOrDefault().ab.DiagnosisId : null, - Details = s.Where(m => m.ac != null).Select(sa => new SumSuggestionContentDto + SuggestionTitle = s.FirstOrDefault().sumSuggestionHeader.SuggestionTitle, + SuggestionFlag = s.FirstOrDefault().sumSuggestionHeader.SuggestionFlag, + DisplayOrder = s.FirstOrDefault().sumSuggestionHeader.DisplayOrder, + DiagnosisIds = s.Where(o => o.sumDiagnosisHaveEmpty != null). + Select(x => x.sumDiagnosisHaveEmpty.DiagnosisId).ToList(), + MedicalInterpretations = s.Where(m => m.sumSuggestionContentHaveEmpty != null && + m.sumSuggestionContentHaveEmpty.SuggestionType == SuggestionTypeFlag.MedicalInterpretation). + Select(sa => new SumSuggestionContentData + { + DisplayOrder = sa.sumSuggestionContentHaveEmpty.DisplayOrder, + SuggestionContent = sa.sumSuggestionContentHaveEmpty.SuggestionContent, + }).OrderBy(o => o.DisplayOrder).ToList(), + CommonReasons = s.Where(m => m.sumSuggestionContentHaveEmpty != null && + m.sumSuggestionContentHaveEmpty.SuggestionType == SuggestionTypeFlag.CommonReasons). + Select(sa => new SumSuggestionContentData { - DisplayOrder = sa.ac.DisplayOrder, - SuggestionContent = sa.ac.SuggestionContent, - SumSuggestionHeaderId = sa.ac.SumSuggestionHeaderId + DisplayOrder = sa.sumSuggestionContentHaveEmpty.DisplayOrder, + SuggestionContent = sa.sumSuggestionContentHaveEmpty.SuggestionContent, }).OrderBy(o => o.DisplayOrder).ToList(), + HealthGuidances = s.Where(m => m.sumSuggestionContentHaveEmpty != null && + m.sumSuggestionContentHaveEmpty.SuggestionType == SuggestionTypeFlag.HealthGuidance). + Select(sa => new SumSuggestionContentData + { + DisplayOrder = sa.sumSuggestionContentHaveEmpty.DisplayOrder, + SuggestionContent = sa.sumSuggestionContentHaveEmpty.SuggestionContent, + }).OrderBy(o => o.DisplayOrder).ToList(), + }).OrderBy(o => o.DisplayOrder).ToList(); } else { //没有值的情况 - var checklist = (await _registerCheckRepository.GetDbSetAsync()) - .Include(x => x.RegisterCheckAsbitems) - .ThenInclude(x => x.Asbitem) - .Include(x => x.RegisterCheckSuggestions) - .Where(m => m.RegisterCheckAsbitems.Select(s => s.PatientRegisterId).Contains(PatientRegisterId) && m.RegisterCheckSuggestions.Count > 0) - .ToList(); + var checklist = await _sumSummaryHeaderManager.GetSumSummarysByDoctorCheck(patientRegisterId); + //获取所有综述 + var registerCheckSummaries = new List(); + foreach (var registerCheck in checklist) + { + + foreach (var registerCheckSummary in registerCheck.RegisterCheckSummaries) + { + registerCheckSummaries.Add(registerCheckSummary.Summary); + } + } + //根据综述生成建议 + var diagnosis = (await _diagnosisRepository.GetQueryableAsync()).Include(o => o.Suggestions).ToList(); - if (checklist.Any() && checklist.Count(c => c.RegisterCheckSuggestions.Count > 0) > 0) + foreach (var registerCheckSummary in registerCheckSummaries) { - msg = checklist.Select(s => new SumSuggestionHeaderOrContentDto + var matchDiagnosisList = diagnosis.Where(o => registerCheckSummary.Contains(o.DisplayName)).ToList(); + var matchDiagnosis = matchDiagnosisList.OrderByDescending(o => o.DisplayName.Length).FirstOrDefault(); + if (matchDiagnosis != null) { - Id = s.Id, - SuggestionTitle = string.Join(",", s.RegisterCheckAsbitems.Select(rs => rs.Asbitem.DisplayName).ToList()), - SuggestionFlag = null, - PatientRegisterId = s.RegisterCheckAsbitems.FirstOrDefault().PatientRegisterId, - DisplayOrder = 0, - Details = s.RegisterCheckSuggestions.OrderBy(o => o.DisplayOrder).Select(sa => new SumSuggestionContentDto + if (msg.Where(o => o.SuggestionTitle == matchDiagnosis.DisplayName).Count() > 0) + { + continue; + } + var sumSuggestionDto = new SumSuggestionDto() { - DisplayOrder = sa.DisplayOrder, - SuggestionContent = sa.Suggestion, - SumSuggestionHeaderId = sa.RegisterCheckId - }).OrderBy(o => o.DisplayOrder).ToList() - }).OrderBy(o => o.DisplayOrder).ToList(); + SuggestionTitle = matchDiagnosis.DisplayName, + SuggestionFlag = null, + DisplayOrder = 0, + DiagnosisIds = new List() { matchDiagnosis.Id }, + MedicalInterpretations = matchDiagnosis.Suggestions. + Where(o => o.SuggestionType == SuggestionTypeFlag.MedicalInterpretation) + .OrderBy(o => o.DisplayOrder) + .Select(x => new SumSuggestionContentData() + { + SuggestionContent = x.SuggestionContent, + DisplayOrder = x.DisplayOrder, + } + ).ToList(), + CommonReasons = matchDiagnosis.Suggestions. + Where(o => o.SuggestionType == SuggestionTypeFlag.CommonReasons) + .OrderBy(o => o.DisplayOrder) + .Select(x => new SumSuggestionContentData() + { + SuggestionContent = x.SuggestionContent, + DisplayOrder = x.DisplayOrder, + } + ).ToList(), + HealthGuidances = matchDiagnosis.Suggestions. + Where(o => o.SuggestionType == SuggestionTypeFlag.HealthGuidance) + .OrderBy(o => o.DisplayOrder) + .Select(x => new SumSuggestionContentData() + { + SuggestionContent = x.SuggestionContent, + DisplayOrder = x.DisplayOrder, + } + ).ToList() + }; + msg.Add(sumSuggestionDto); + } + } + + } return msg; - } - - /// - /// 批量插入总诊台建议 - /// - /// - /// - [HttpPost("api/app/sumsuggestionheader/createsumsuggestion")] - public async Task CreateSumSuggestionAsync(List input) - { - if (input.Any()) + /// + /// 批量插入总诊台建议 + /// + /// + /// + [HttpPost("api/app/sumsuggestionheader/createsumsuggestion")] + public async Task CreateSumSuggestionAsync(List input) { + throw new UserFriendlyException("禁止使用"); + if (input.Any()) + { - //先删除总诊头跟内容 - await _sumSuggestionHeaderRepository.DeleteAsync(m => m.PatientRegisterId == input.FirstOrDefault().PatientRegisterId, true); + //先删除总诊头跟内容 + await _sumSuggestionHeaderRepository.DeleteAsync(m => m.PatientRegisterId == input.FirstOrDefault().PatientRegisterId, true); - //删除对应的诊断数据 - await _sumDiagnosisRepository.DeleteAsync(m => m.PatientRegisterId == input.FirstOrDefault().PatientRegisterId, true); + //删除对应的诊断数据 + await _sumDiagnosisRepository.DeleteAsync(m => m.PatientRegisterId == input.FirstOrDefault().PatientRegisterId, true); - foreach (var item in input) - { - #region 插入SumSuggestionHeader - SumSuggestionHeader sumSuggestionHeaderEnt = new SumSuggestionHeader + foreach (var item in input) { - DisplayOrder = input.IndexOf(item) + 1, - PatientRegisterId = item.PatientRegisterId, - SuggestionFlag = null, - SuggestionTitle = item.SuggestionTitle - }; - - var sumSuggestionHeaderEnt_New = await _sumSuggestionHeaderRepository.InsertAsync(sumSuggestionHeaderEnt, true); + #region 插入SumSuggestionHeader + SumSuggestionHeader sumSuggestionHeaderEnt = new SumSuggestionHeader + { + DisplayOrder = input.IndexOf(item) + 1, + PatientRegisterId = item.PatientRegisterId, + SuggestionFlag = null, + SuggestionTitle = item.SuggestionTitle + }; - if (sumSuggestionHeaderEnt_New != null) - { + var sumSuggestionHeaderEnt_New = await _sumSuggestionHeaderRepository.InsertAsync(sumSuggestionHeaderEnt, true); - #region 插入SumDiagnosis - if (item.DiagnosisId != null && item.DiagnosisId != Guid.Empty) + if (sumSuggestionHeaderEnt_New != null) { - SumDiagnosis sumDiagnosis = new SumDiagnosis + #region 插入SumDiagnosis + if (item.DiagnosisId != null && item.DiagnosisId != Guid.Empty) { - DiagnosisId = item.DiagnosisId.Value, - DisplayOrder = input.IndexOf(item) + 1, - PatientRegisterId = item.PatientRegisterId, - SumSuggestionHeaderId = sumSuggestionHeaderEnt_New.Id - }; - await _sumDiagnosisRepository.InsertAsync(sumDiagnosis); - } - #endregion + SumDiagnosis sumDiagnosis = new SumDiagnosis + { + DiagnosisId = item.DiagnosisId.Value, + DisplayOrder = input.IndexOf(item) + 1, + PatientRegisterId = item.PatientRegisterId, + SumSuggestionHeaderId = sumSuggestionHeaderEnt_New.Id + }; - #region 插入SumSuggestionContent - List sumSuggestionContentList = new List(); - foreach (var item2 in item.Details) - { - SumSuggestionContent sumSuggestionContentEnt = new SumSuggestionContent + await _sumDiagnosisRepository.InsertAsync(sumDiagnosis); + } + #endregion + + #region 插入SumSuggestionContent + List sumSuggestionContentList = new List(); + foreach (var item2 in item.Details) { - DisplayOrder = item.Details.IndexOf(item2) + 1, - SuggestionContent = item2.SuggestionContent, - SumSuggestionHeaderId = sumSuggestionHeaderEnt_New.Id - }; + SumSuggestionContent sumSuggestionContentEnt = new SumSuggestionContent + { + DisplayOrder = item.Details.IndexOf(item2) + 1, + SuggestionContent = item2.SuggestionContent, + SumSuggestionHeaderId = sumSuggestionHeaderEnt_New.Id + }; - sumSuggestionContentList.Add(sumSuggestionContentEnt); - } + sumSuggestionContentList.Add(sumSuggestionContentEnt); + } - await _sumSuggestionContentRepository.InsertManyAsync(sumSuggestionContentList); + await _sumSuggestionContentRepository.InsertManyAsync(sumSuggestionContentList); + #endregion + } #endregion } - #endregion } } - } - /// - /// 清空总诊台建议内容 - /// - /// - /// - [HttpPost("api/app/sumsuggestionheader/deletesumsuggestionmany")] - public async Task DeleteSumSuggestionManyAsync(Guid PatientRegisterId) - { - if (PatientRegisterId != Guid.Empty) - { - await _sumSuggestionHeaderRepository.DeleteAsync(d => d.PatientRegisterId == PatientRegisterId); - //删除对应的诊断数据 - await _sumDiagnosisRepository.DeleteAsync(m => m.PatientRegisterId == PatientRegisterId); - } - else + /// + /// 清空总诊台建议内容 + /// + /// + /// + [HttpPost("api/app/sumsuggestionheader/deletesumsuggestionmany")] + public async Task DeleteSumSuggestionManyAsync(Guid PatientRegisterId) { - throw new UserFriendlyException("请求参数有误"); + if (PatientRegisterId != Guid.Empty) + { + await _sumSuggestionHeaderRepository.DeleteAsync(d => d.PatientRegisterId == PatientRegisterId); + //删除对应的诊断数据 + await _sumDiagnosisRepository.DeleteAsync(m => m.PatientRegisterId == PatientRegisterId); + } + else + { + throw new UserFriendlyException("请求参数有误"); + } } } } -} diff --git a/src/Shentun.Peis.Application/SumSummaryHeaders/SumSummaryHeaderAppService.cs b/src/Shentun.Peis.Application/SumSummaryHeaders/SumSummaryHeaderAppService.cs index fda21b7..3488a9c 100644 --- a/src/Shentun.Peis.Application/SumSummaryHeaders/SumSummaryHeaderAppService.cs +++ b/src/Shentun.Peis.Application/SumSummaryHeaders/SumSummaryHeaderAppService.cs @@ -1,8 +1,10 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; +using Shentun.Peis.Enums; using Shentun.Peis.Models; using Shentun.Peis.SumSummaryContents; +using Shentun.Peis.SysParmValues; using System; using System.Collections.Generic; using System.Linq; @@ -23,39 +25,50 @@ namespace Shentun.Peis.SumSummaryHeaders [Authorize] public class SumSummaryHeaderAppService : ApplicationService { + private readonly IRepository _sumSummaryHeaderRepository; private readonly IRepository _sumSummaryContentRepository; private readonly IRepository _registerCheckRepository; - + private readonly IRepository _patientRegisterRepository; + private readonly SysParmValueManager _sysParmValueManager; + private readonly SumSummaryHeaderManager _sumSummaryHeaderManager; public SumSummaryHeaderAppService( IRepository sumSummaryHeaderRepository, IRepository sumSummaryContentRepository, - IRepository registerCheckRepository + IRepository registerCheckRepository, + IRepository patientRegisterRepository, + SysParmValueManager sysParmValueManager, + SumSummaryHeaderManager sumSummaryHeaderManager + ) { this._sumSummaryHeaderRepository = sumSummaryHeaderRepository; this._sumSummaryContentRepository = sumSummaryContentRepository; this._registerCheckRepository = registerCheckRepository; + _sysParmValueManager = sysParmValueManager; + _patientRegisterRepository = patientRegisterRepository; + _sumSummaryHeaderManager = sumSummaryHeaderManager; } /// /// 获取人员总检诊台小结 (如还未录入,获取医生诊台录入的小结) /// - /// 人员登记ID + /// 人员登记ID /// [HttpGet("api/app/sumsummaryheader/getsumsummarylist")] - public async Task> GetSumSummaryListAsync(Guid PatientRegisterId) + public async Task> GetSumSummaryListAsync(Guid patientRegisterId) { List msg = new List(); - + var patientRegister = await _patientRegisterRepository.GetAsync(patientRegisterId); var entlist = (await _sumSummaryHeaderRepository.GetDbSetAsync()) .Include(x => x.SumSummaryContents) - .Where(m => m.PatientRegisterId == PatientRegisterId).OrderBy(o => o.DisplayOrder).ToList(); + .Where(m => m.PatientRegisterId == patientRegisterId).OrderBy(o => o.DisplayOrder).ToList(); - if (entlist.Any()) + if (patientRegister.CompleteFlag == PatientRegisterCompleteFlag.GeneralInspected) { + //已总检取综述中的值 msg = entlist.Select(s => new SumSummaryHeaderOrContentDto { SummaryTitle = s.SummaryTitle, @@ -73,13 +86,9 @@ namespace Shentun.Peis.SumSummaryHeaders } else { - //没有值的情况 - var checklist = (await _registerCheckRepository.GetDbSetAsync()) - .Include(x => x.RegisterCheckAsbitems) - .ThenInclude(x => x.Asbitem) - .Include(x => x.RegisterCheckSummaries) - .Where(m => m.RegisterCheckAsbitems.Select(s => s.PatientRegisterId).Contains(PatientRegisterId) && m.RegisterCheckSummaries.Count > 0) - .ToList(); + //未总检 + var checklist = await _sumSummaryHeaderManager.GetSumSummarysByDoctorCheck(patientRegisterId); + if (checklist.Any() && checklist.Count(c => c.RegisterCheckSummaries.Count > 0) > 0) { msg = checklist.Select(s => new SumSummaryHeaderOrContentDto @@ -110,6 +119,7 @@ namespace Shentun.Peis.SumSummaryHeaders [HttpPost("api/app/sumsummaryheader/createsumsummary")] public async Task CreateSumSummaryAsync(List input) { + throw new UserFriendlyException("禁止使用"); if (input.Any()) { diff --git a/src/Shentun.Peis.Domain.Shared/Enums/SuggestionTypeFlag.cs b/src/Shentun.Peis.Domain.Shared/Enums/SuggestionTypeFlag.cs index d4c1d03..80d4abd 100644 --- a/src/Shentun.Peis.Domain.Shared/Enums/SuggestionTypeFlag.cs +++ b/src/Shentun.Peis.Domain.Shared/Enums/SuggestionTypeFlag.cs @@ -15,9 +15,15 @@ namespace Shentun.Peis.Enums /// - /// 健康指导 + /// 常见原因 + /// + [Description("常见原因")] + public const char CommonReasons = '1'; + + /// + /// 常见原因 /// [Description("健康指导")] - public const char HealthGuidance = '1'; + public const char HealthGuidance = '2'; } } diff --git a/src/Shentun.Peis.Domain/SumSummaryHeaders/SumSummaryHeaderManager.cs b/src/Shentun.Peis.Domain/SumSummaryHeaders/SumSummaryHeaderManager.cs index 4eb2677..e75887e 100644 --- a/src/Shentun.Peis.Domain/SumSummaryHeaders/SumSummaryHeaderManager.cs +++ b/src/Shentun.Peis.Domain/SumSummaryHeaders/SumSummaryHeaderManager.cs @@ -1,15 +1,91 @@ -using Shentun.Peis.Models; +using Microsoft.EntityFrameworkCore; +using Shentun.Peis.Models; +using Shentun.Peis.SysParmValues; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Services; namespace Shentun.Peis.SumSummaryHeaders { public class SumSummaryHeaderManager : DomainService { + private readonly IRepository _sumSummaryContentRepository; + private readonly IRepository _registerCheckRepository; + private readonly IRepository _patientRegisterRepository; + private readonly SysParmValueManager _sysParmValueManager; + public SumSummaryHeaderManager( + IRepository sumSummaryHeaderRepository, + IRepository sumSummaryContentRepository, + IRepository registerCheckRepository, + IRepository patientRegisterRepository, + SysParmValueManager sysParmValueManager + + ) + { + this._sumSummaryContentRepository = sumSummaryContentRepository; + this._registerCheckRepository = registerCheckRepository; + _sysParmValueManager = sysParmValueManager; + _patientRegisterRepository = patientRegisterRepository; + } + + public async Task> GetSumSummarysByDoctorCheck(Guid PatientRegisterId) + { + var patientRegister = await _patientRegisterRepository.GetAsync(PatientRegisterId); + //总检综述包含正常结果 + var isSummaryCheckSummayContainNormalResult = await _sysParmValueManager. + GetSysParmValueInMedicalCenterId(patientRegister.MedicalCenterId, + "summary_check_summay_contain_normal_result"); + //默认综述 + var summaryCheckDefaultSummayContent = await _sysParmValueManager. + GetSysParmValueInMedicalCenterId(patientRegister.MedicalCenterId, + "summary_check_default_summay_content"); + var checklist = (await _registerCheckRepository.GetDbSetAsync()) + .Include(x => x.RegisterCheckAsbitems) + .ThenInclude(x => x.Asbitem).ThenInclude(x=>x.ItemType) + .Include(x => x.RegisterCheckSummaries) + .Where(m => m.RegisterCheckAsbitems.Select(s => s.PatientRegisterId).Contains(PatientRegisterId) && m.RegisterCheckSummaries.Count > 0) + .ToList(); + //排序 + checklist = checklist.OrderBy(o=>o.RegisterCheckAsbitems.Max(x=>x.Asbitem.ItemType.DisplayOrder)). + ToList().OrderBy(o => o.RegisterCheckAsbitems.Max(x => x.Asbitem.DisplayOrder)).ToList(); + if (isSummaryCheckSummayContainNormalResult != "Y") + { + //去掉小结和默认结果一致的小结 + for (var i = 0; i < checklist.Count; i++) + { + var registerCheck = checklist[i]; + var registerCheckSummaries = registerCheck.RegisterCheckSummaries.ToList(); + var registerCheckAsbitems = registerCheck.RegisterCheckAsbitems.ToList(); + if (registerCheck.RegisterCheckSummaries.Count() == 1) + { + if (registerCheckSummaries[0].Summary == registerCheckAsbitems[0].Asbitem.DefaultResult) + { + checklist.Remove(registerCheck); + i--; + } + } + } + } + + if(!checklist.Any()) + { + checklist.Add(new RegisterCheck() + { + RegisterCheckSummaries = new List() + { + new RegisterCheckSummary() + { + Summary = summaryCheckDefaultSummayContent, + } + } + }); + } + return checklist; + } public SumSummaryHeader CreateAsync(Guid patientRegisterId, string summaryTitle,char? summaryFlag,int displayOrder) { diff --git a/test/Shentun.Peis.Application.Tests/PatientRegisterAppServiceTest.cs b/test/Shentun.Peis.Application.Tests/PatientRegisterAppServiceTest.cs index e502d23..a7a9c13 100644 --- a/test/Shentun.Peis.Application.Tests/PatientRegisterAppServiceTest.cs +++ b/test/Shentun.Peis.Application.Tests/PatientRegisterAppServiceTest.cs @@ -510,64 +510,93 @@ namespace Shentun.Peis { using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true)) { - var entity = new CreatePatientRegisterDto() + var entity = new UpdatePatientRegisterSummarySuggestionDto() { - //PatientRegisterId = new Guid("3a11abec-a6aa-e656-16db-cb0bccf8de46"), - MedicalCenterId = new Guid("68f2d834-2bf0-4978-ad54-d2133c12a333"), - PatientId = new Guid("3a119be6-d9aa-2e13-a764-0b363c60169d"), - CustomerOrgId = new Guid("00000000-0000-0000-0000-000000000001"), - CustomerOrgRegisterId = new Guid("00000000-0000-0000-0000-000000000001"), - PatientName = "test", - SexId = SexFlag.UnKnown, - BirthDate = null, - Age = 38, - Telephone = "010-0000001", - MobileTelephone = "18911254911", - JobCardNo = "jobCardNo", - MedicalCardNo = "MedicalCardNo", - MaritalStatusId = MaritalStatusFlag.Married, - MedicalTypeId = new Guid("3a0c5093-6dbf-d29b-cfbc-b1f742ee59d3"), - PersonnelTypeId = new Guid("3a0c5099-a5f3-e41a-dfab-caeae79e0dfe"), - NationId = "001", - JobPost = "JobPost", - JobTitle = "JobTitle", - Salesman = "Salesman", - SexHormoneTermId = new Guid("3a0d38cf-8b3c-95db-1a69-5119f28dc468"), - MedicalConclusionId = new Guid("3a0c50fe-cacf-d3c8-8c3c-9d3495d8bd76"), - IsUpload = 'N', - CompleteFlag = PatientRegisterCompleteFlag.PreRegistration, - IsMedicalStart = 'N', - MedicalStartDate = null, - IsRecoverGuide = 'N', - SummaryDate = null, - IsAudit = 'N', - IsLock = 'N', - IsNameHide = 'N', - IsPhoneFollow = 'N', - IsVip = 'N', - Remark = "Remark", - Address = "Address1", - Email = "83986010@qq.com" - }; - var medicalPackageId = new Guid("3a0c51d4-2c5a-2a05-e4c4-e335012617be"); - entity.MedicalPackageId = medicalPackageId; - var medicalPackageDetails = (await _medicalPackageDetailRepository.GetQueryableAsync()).Include(o => o.Asbitem).Where(o => o.MedicalPackageId == medicalPackageId).ToList(); - foreach (var medicalPackageDetail in medicalPackageDetails) - { - var registerCheckAsbitem = new CreatePatientRegisterRegisterCheckAsbitem() + PatientRegisterId = new Guid("3a11ee70-02cb-c5e6-a087-79ecdd0356b6"), + + SumSummarys = new List() { - AsbitemId = medicalPackageDetail.AsbitemId, - StandardPrice = medicalPackageDetail.Asbitem.Price, - ChargePrice = medicalPackageDetail.Asbitem.Price, - Amount = 1, - PayTypeFlag = PayTypeFlag.PersonPay, - IsCharge = 'N' - }; - entity.RegisterCheckAsbitems.Add(registerCheckAsbitem); - } + new UpdateSumSummaryDto() + { + SummaryTitle ="111", + Details = new List() + { + new UpdateSumSummaryContentDto() + { + SummaryContent = "aaa" + }, + new UpdateSumSummaryContentDto() + { + SummaryContent = "bbb" + } + } + }, + new UpdateSumSummaryDto() + { + SummaryTitle ="222", + Details = new List() + { + new UpdateSumSummaryContentDto() + { + SummaryContent = "ccc" + }, + new UpdateSumSummaryContentDto() + { + SummaryContent = "ddd" + } + } + } + }, + SumSuggestions = new List() + { + new UpdateSumSuggestionDto() + { + DiagnosisIds = new List() + { + new Guid("3a0ec93f-bc7c-bc6b-d8b2-9a1eaeef398d"), + new Guid("3a0ecab2-ee3a-4b32-997b-5979a672cf62") + }, + SuggestionTitle = "ssss", + Details= new List() + { + new UpdateSumSuggestionContentDto() + { + SuggestionContent = "ffff" + }, + new UpdateSumSuggestionContentDto() + { + SuggestionContent = "gggg" + } + } + + }, + new UpdateSumSuggestionDto() + { + DiagnosisIds = new List() + { + new Guid("3a0ed8a2-8e4b-c66f-292f-afffc76d3fd6"), + new Guid("3a0ed8e0-6e1a-4b6a-55ec-a2e87ccdf6a9") + }, + SuggestionTitle = "ttt", + Details= new List() + { + new UpdateSumSuggestionContentDto() + { + SuggestionContent = "hhh" + }, + new UpdateSumSuggestionContentDto() + { + SuggestionContent = "kkk" + } + } + + } + } + }; + - var newEntity = await _appService.CreatePatientRegisterAsync(entity); + var newEntity = await _appService.UpdatePatientRegisterSummarySuggestionAsync(entity); await unitOfWork.CompleteAsync(); } } diff --git a/test/Shentun.Peis.Application.Tests/SumSuggestionHeaderAppServiceTest.cs b/test/Shentun.Peis.Application.Tests/SumSuggestionHeaderAppServiceTest.cs new file mode 100644 index 0000000..0dca32d --- /dev/null +++ b/test/Shentun.Peis.Application.Tests/SumSuggestionHeaderAppServiceTest.cs @@ -0,0 +1,44 @@ +using Shentun.Peis.Models; +using Shentun.Peis.SumSuggestionHeaders; +using Shentun.Peis.SumSummaryHeaders; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.Domain.Repositories; +using Volo.Abp.Uow; +using Xunit; +using Xunit.Abstractions; + +namespace Shentun.Peis +{ + public class SumSuggestionHeaderAppServiceTest : PeisApplicationTestBase + { + private readonly IRepository _repository; + private readonly SumSuggestionHeaderAppService _appService; + private readonly ITestOutputHelper _output; + private readonly IUnitOfWorkManager _unitOfWorkManager; + public SumSuggestionHeaderAppServiceTest(ITestOutputHelper testOutputHelper) + { + _output = testOutputHelper; + _unitOfWorkManager = GetRequiredService(); + _repository = GetRequiredService>(); + _appService = GetRequiredService(); + } + + [Fact] + public async Task GetSumSuggestionListAsync() + { + using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true)) + { + + var result = await _appService.GetSumSuggestionListAsync(new Guid("3a11ee70-02cb-c5e6-a087-79ecdd0356b6")); + foreach (var item in result) + { + _output.WriteLine(item.SuggestionTitle); + } + } + } + } +} diff --git a/test/Shentun.Peis.Application.Tests/SumSummaryHeaderAppServiceTest.cs b/test/Shentun.Peis.Application.Tests/SumSummaryHeaderAppServiceTest.cs new file mode 100644 index 0000000..a9fbb35 --- /dev/null +++ b/test/Shentun.Peis.Application.Tests/SumSummaryHeaderAppServiceTest.cs @@ -0,0 +1,44 @@ +using Shentun.Peis.DiagnosisFunctions; +using Shentun.Peis.Models; +using Shentun.Peis.SumSummaryHeaders; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.Domain.Repositories; +using Volo.Abp.Uow; +using Xunit; +using Xunit.Abstractions; + +namespace Shentun.Peis +{ + public class SumSummaryHeaderAppServiceTest:PeisApplicationTestBase + { + private readonly IRepository _repository; + private readonly SumSummaryHeaderAppService _appService; + private readonly ITestOutputHelper _output; + private readonly IUnitOfWorkManager _unitOfWorkManager; + public SumSummaryHeaderAppServiceTest(ITestOutputHelper testOutputHelper) + { + _output = testOutputHelper; + _unitOfWorkManager = GetRequiredService(); + _repository = GetRequiredService>(); + _appService = GetRequiredService(); + } + + [Fact] + public async Task GetSumSummaryListAsync() + { + using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true)) + { + + var result = await _appService.GetSumSummaryListAsync(new Guid("3a11ee70-02cb-c5e6-a087-79ecdd0356b6")); + foreach (var item in result) + { + _output.WriteLine(item.SummaryTitle); + } + } + } + } +}