From 6e6d4b9759ff740807b806cc9f4543ff60b24f81 Mon Sep 17 00:00:00 2001 From: "DESKTOP-G961P6V\\Zhh" <839860190@qq.com> Date: Thu, 20 Jun 2024 01:33:13 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=AE=E5=8D=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PersonAppointInputDto.cs | 29 ++ .../PersonDiseaseRiskIdInputDto.cs | 33 ++ .../QuestionRegisterDiseaseRiskSingleDto.cs | 64 ++++ .../Questions/CreateQuestionDto.cs | 5 + .../Questions/QuestionTreeListDto.cs | 6 + .../Questions/UpdateQuestionDto.cs | 5 + .../AppointPatientRegisterAppService.cs | 5 +- .../QuestionRegisterAppService.cs | 357 ++++++++++-------- .../Questions/QuestionAppService.cs | 2 + .../AppointPatientRegisterManager.cs | 50 ++- src/Shentun.WebPeis.Domain/Models/Question.cs | 5 + .../Questions/QuestionManager.cs | 2 + .../Configures/QuestionConfigure.cs | 6 + .../QuestionRegisterAppServiceTest.cs | 41 +- 14 files changed, 433 insertions(+), 177 deletions(-) create mode 100644 src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/PersonAppointInputDto.cs create mode 100644 src/Shentun.WebPeis.Application.Contracts/QuestionRegisters/PersonDiseaseRiskIdInputDto.cs create mode 100644 src/Shentun.WebPeis.Application.Contracts/QuestionRegisters/QuestionRegisterDiseaseRiskSingleDto.cs diff --git a/src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/PersonAppointInputDto.cs b/src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/PersonAppointInputDto.cs new file mode 100644 index 0000000..0e35e82 --- /dev/null +++ b/src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/PersonAppointInputDto.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.WebPeis.AppointPatientRegisters +{ + public class PersonAppointInputDto + { + /// + /// 人员ID + /// + public Guid PersonId { get; set; } + + /// + /// 备孕标志 + /// + public char PregnantFlag { get; set; } + /// + /// 身高 + /// + + public decimal? Height { get; set; } + /// + /// 体重 + /// + + public decimal? Weight { get; set; } + } +} diff --git a/src/Shentun.WebPeis.Application.Contracts/QuestionRegisters/PersonDiseaseRiskIdInputDto.cs b/src/Shentun.WebPeis.Application.Contracts/QuestionRegisters/PersonDiseaseRiskIdInputDto.cs new file mode 100644 index 0000000..16869b8 --- /dev/null +++ b/src/Shentun.WebPeis.Application.Contracts/QuestionRegisters/PersonDiseaseRiskIdInputDto.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.WebPeis.QuestionRegisters +{ + public class PersonDiseaseRiskIdInputDto + { + /// + /// 人员ID + /// + public Guid PersonId { get; set; } + /// + /// 疾病风险ID + /// + public Guid DiseaseRiskId { get; set; } + + /// + /// 备孕标志 + /// + public char PregnantFlag { get; set; } + /// + /// 身高 + /// + + public decimal? Height { get; set; } + /// + /// 体重 + /// + + public decimal? Weight { get; set; } + } +} diff --git a/src/Shentun.WebPeis.Application.Contracts/QuestionRegisters/QuestionRegisterDiseaseRiskSingleDto.cs b/src/Shentun.WebPeis.Application.Contracts/QuestionRegisters/QuestionRegisterDiseaseRiskSingleDto.cs new file mode 100644 index 0000000..c2e6fa1 --- /dev/null +++ b/src/Shentun.WebPeis.Application.Contracts/QuestionRegisters/QuestionRegisterDiseaseRiskSingleDto.cs @@ -0,0 +1,64 @@ +using Shentun.WebPeis.DiseaseRiskLevels; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.WebPeis.QuestionRegisters +{ + public class QuestionRegisterDiseaseRiskSingleDto + { + /// + /// 主键 + /// + public Guid DiseaseRiskId { get; set; } + /// + /// 名称 + /// + + public string DiseaseRiskName { get; set; } = null!; + + + /// + /// 风险级别ID + /// + public Guid? DiseaseRiskLevelId { get; set; } + /// + /// 风险级别名称 + /// + + public string DiseaseRiskLevelName { get; set; } + + /// + /// 解释 + /// + + public string? Explain { get; set; } + /// + /// 建议 + /// + + public string? Suggestion { get; set; } + /// + /// 推荐组合项目列表 + /// + + public List Asbitems { get; set; } = new List(); + + /// + /// 疾病风险级别列表 + /// + public List DiseaseRiskLevels { get; set; } = new List(); + + /// + /// 风险因素 + /// + public List Answers { get; set; } = new List(); + } + + public class QuestionRegisterDiseaseRiskAsbitem + { + public Guid AsbitemId { get; set; } + public string AsbitemName { get; set; } + public int DisplayOrder { get; set; } + } +} diff --git a/src/Shentun.WebPeis.Application.Contracts/Questions/CreateQuestionDto.cs b/src/Shentun.WebPeis.Application.Contracts/Questions/CreateQuestionDto.cs index e7a3994..53116ee 100644 --- a/src/Shentun.WebPeis.Application.Contracts/Questions/CreateQuestionDto.cs +++ b/src/Shentun.WebPeis.Application.Contracts/Questions/CreateQuestionDto.cs @@ -39,6 +39,11 @@ namespace Shentun.WebPeis.Questions /// public Guid? ParentId { get; set; } + /// + /// 是否显示 + /// + + public char IsShow { get; set; } } diff --git a/src/Shentun.WebPeis.Application.Contracts/Questions/QuestionTreeListDto.cs b/src/Shentun.WebPeis.Application.Contracts/Questions/QuestionTreeListDto.cs index 1e762fa..9a2a22c 100644 --- a/src/Shentun.WebPeis.Application.Contracts/Questions/QuestionTreeListDto.cs +++ b/src/Shentun.WebPeis.Application.Contracts/Questions/QuestionTreeListDto.cs @@ -37,6 +37,12 @@ namespace Shentun.WebPeis.Questions /// public char? IsActive { get; set; } + + /// + /// 是否显示 + /// + + public char IsShow { get; set; } /// /// 父问卷ID /// diff --git a/src/Shentun.WebPeis.Application.Contracts/Questions/UpdateQuestionDto.cs b/src/Shentun.WebPeis.Application.Contracts/Questions/UpdateQuestionDto.cs index 4d2779b..6bb12e5 100644 --- a/src/Shentun.WebPeis.Application.Contracts/Questions/UpdateQuestionDto.cs +++ b/src/Shentun.WebPeis.Application.Contracts/Questions/UpdateQuestionDto.cs @@ -37,6 +37,11 @@ namespace Shentun.WebPeis.Questions /// public char? IsActive { get; set; } + /// + /// 是否显示 + /// + + public char IsShow { get; set; } } diff --git a/src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs b/src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs index 78a0027..4b9ba5c 100644 --- a/src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs +++ b/src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs @@ -840,7 +840,9 @@ namespace Shentun.WebPeis.AppointPatientRegisters //----推荐组合项目 var personDiseaseRiskLevelDtos = await GetDiseaseRiskListByPersonIdAsync(input.PersonId); - //去掉基本套餐中已经包含的组合项目 + //var pregnancyAsbitems = await _asbitemRepository.GetListAsync(o => + //o.ForPregnantFlag == ForPregnantFlag.PreparePregnancy || o.ForPregnantFlag == ForPregnantFlag.Pregnancy); + //去掉基本套餐已经包含的组合项目和和怀孕禁止检查的项目 foreach (var personDiseaseRiskLevelDto in personDiseaseRiskLevelDtos) { for (var i = 0; i< personDiseaseRiskLevelDto.Asbitems.Count; i++ ) @@ -851,6 +853,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters personDiseaseRiskLevelDto.Asbitems.Remove(personDiseaseRiskLevelAsbitem); i --; } + } } diff --git a/src/Shentun.WebPeis.Application/QuestionRegisters/QuestionRegisterAppService.cs b/src/Shentun.WebPeis.Application/QuestionRegisters/QuestionRegisterAppService.cs index b2734d8..996e989 100644 --- a/src/Shentun.WebPeis.Application/QuestionRegisters/QuestionRegisterAppService.cs +++ b/src/Shentun.WebPeis.Application/QuestionRegisters/QuestionRegisterAppService.cs @@ -1,14 +1,19 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using NPOI.SS.Formula.Functions; using Org.BouncyCastle.Math.EC.Rfc7748; +using Shentun.WebPeis.AppointPatientRegisters; +using Shentun.WebPeis.DiseaseRiskLevels; using Shentun.WebPeis.Enums; using Shentun.WebPeis.Models; using Shentun.WebPeis.Persons; +using Shentun.WebPeis.SysParmValues; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Volo.Abp; using Volo.Abp.Application.Services; using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Repositories; @@ -29,8 +34,11 @@ namespace Shentun.WebPeis.QuestionRegisters private readonly IRepository _diseaseRiskRepository; private readonly IRepository _diseaseRiskLevelRepository; private readonly IRepository _diseaseRiskLevelAnswerRepository; + private readonly IRepository _diseaseRiskLevelAsbitemRepository; + private readonly IRepository _asbitemRepository; private readonly QuestionRegisterManager _questionRegisterManager; private readonly IUnitOfWorkManager _unitOfWorkManager; + private readonly SysParmValueManager _sysParmValueManager; public QuestionRegisterAppService(IRepository repository, IRepository questionRegisterItemRepository, IRepository questionRegisterAnswerRrepository, @@ -41,7 +49,10 @@ namespace Shentun.WebPeis.QuestionRegisters IRepository questionSubjectTypeRepository, IRepository diseaseRiskRepository, IRepository diseaseRiskLevelRepository, - IRepository diseaseRiskLevelAnswerRepository) + IRepository diseaseRiskLevelAnswerRepository, + IRepository diseaseRiskLevelAsbitemRepository, + IRepository asbitemRepository, + SysParmValueManager sysParmValueManager) { _repository = repository; _questionRegisterItemRepository = questionRegisterItemRepository; @@ -54,6 +65,9 @@ namespace Shentun.WebPeis.QuestionRegisters _diseaseRiskRepository = diseaseRiskRepository; _diseaseRiskLevelRepository = diseaseRiskLevelRepository; _diseaseRiskLevelAnswerRepository = diseaseRiskLevelAnswerRepository; + _diseaseRiskLevelAsbitemRepository = diseaseRiskLevelAsbitemRepository; + _asbitemRepository = asbitemRepository; + _sysParmValueManager = sysParmValueManager; } @@ -130,7 +144,7 @@ namespace Shentun.WebPeis.QuestionRegisters } /// - /// + /// 获取生育计划、危险因素、疾病等列表 /// /// /// @@ -183,6 +197,12 @@ namespace Shentun.WebPeis.QuestionRegisters { continue; } + if (questionRegisterItems.Where(o => + (o.questionAnswer.PathCode.StartsWith(questionRegisterItem.questionAnswer.PathCode + ".") && + questionRegisterItem.questionAnswer.PathCode.Length == 5)).Any()) + { + continue; + } string answer; if (questionRegisterItem.questionAnswer.AnswerResultType == AnswerResultTypeFlag.Choice) { @@ -215,12 +235,12 @@ namespace Shentun.WebPeis.QuestionRegisters } /// - /// + /// 获取问卷结果列表 /// /// /// [HttpPost("api/app/QuestionRegister/GetQuestionRegisterListByPersonId")] - public async Task> GetQuestionRegisterListByPersonIdAsync(PersonIdInputDto input) + public async Task> GetQuestionRegisterListByPersonIdAsync(PersonAppointInputDto input) { var questionRegister = (await _repository.GetQueryableAsync()) .Where(o => o.PersonId == input.PersonId) @@ -264,6 +284,13 @@ namespace Shentun.WebPeis.QuestionRegisters .OrderBy(o => o.questionAnswer.DisplayOrder).ToList(); foreach (var questionRegisterItem in questionAnswers) { + if (questionRegisterItems.Where(o => + (o.questionAnswer.PathCode.StartsWith(questionRegisterItem.questionAnswer.PathCode + ".") && + questionRegisterItem.questionAnswer.PathCode.Length == 5)).Any()) + { + continue; + } + string answer; if (questionRegisterItem.questionAnswer.AnswerResultType == AnswerResultTypeFlag.Choice) { @@ -296,12 +323,12 @@ namespace Shentun.WebPeis.QuestionRegisters } /// - /// + /// 获取疾病风险列表 /// /// /// [HttpPost("api/app/QuestionRegister/GetDiseaseRiskListByPersonId")] - public async Task> GetDiseaseRiskListByPersonIdAsync(PersonIdInputDto input) + public async Task> GetDiseaseRiskListByPersonIdAsync(PersonAppointInputDto input) { var questionRegister = (await _repository.GetQueryableAsync()) .Where(o => o.PersonId == input.PersonId) @@ -312,7 +339,7 @@ namespace Shentun.WebPeis.QuestionRegisters { return null; } - + //获取人员登记问卷 var questionRegisterItems = (from questionRegisterItem in await _questionRegisterItemRepository.GetQueryableAsync() join questionRegisterAnswer in await _questionRegisterAnswerRrepository.GetQueryableAsync() on questionRegisterItem.QuestionRegisterItemId equals questionRegisterAnswer.QuestionRegisterItemId @@ -332,7 +359,7 @@ namespace Shentun.WebPeis.QuestionRegisters questionRegisterAnswer, questionAnswer }).ToList(); - + //获取疾病风险基础字典信息 var diseaseRisks = (from diseaseRisk in await _diseaseRiskRepository.GetQueryableAsync() join diseaseRiskLevel in await _diseaseRiskLevelRepository.GetQueryableAsync() on diseaseRisk.DiseaseRiskId equals diseaseRiskLevel.DiseaseRiskId into emptyDiseaseRiskLevel @@ -359,27 +386,28 @@ namespace Shentun.WebPeis.QuestionRegisters foreach (var diseaseRisk in questionRegisterDiseaseRiskDtos) { //疾病级别必须按优先级别排序,取顺序最高的作为最高风险级 - var diseaseRiskLevels = diseaseRisks.Where(o=>o.diseaseRisk.DiseaseRiskId == diseaseRisk.DiseaseRiskId - && o.haveDiseaseRiskLevel != null) - .OrderByDescending(o=> o.haveDiseaseRiskLevel==null?1:o.haveDiseaseRiskLevel.DisplayOrder).ToList(); + var diseaseRiskLevels = diseaseRisks.Where(o => o.diseaseRisk.DiseaseRiskId == diseaseRisk.DiseaseRiskId + && o.haveDiseaseRiskLevel != null) + .OrderByDescending(o => o.haveDiseaseRiskLevel == null ? 1 : o.haveDiseaseRiskLevel.DisplayOrder).ToList(); DiseaseRiskLevel matchDiseaseRiskLevel = null; foreach (var diseaseRiskLevel in diseaseRiskLevels) { - if(questionRegisterItems.Where(o => diseaseRiskLevel.haveDiseaseRiskLevelAnswer!= null && + if (questionRegisterItems.Where(o => diseaseRiskLevel.haveDiseaseRiskLevelAnswer != null && o.questionRegisterAnswer.QuestionAnswerId == diseaseRiskLevel.haveDiseaseRiskLevelAnswer.QuestionAnswerId).Any()) { - if(diseaseRiskLevel.haveDiseaseRiskLevel != null) + if (diseaseRiskLevel.haveDiseaseRiskLevel != null) { matchDiseaseRiskLevel = diseaseRiskLevel.haveDiseaseRiskLevel; break; } - - } + + } } - if(matchDiseaseRiskLevel == null) + if (matchDiseaseRiskLevel == null) { - matchDiseaseRiskLevel = diseaseRiskLevels.LastOrDefault()==null?null: diseaseRiskLevels.LastOrDefault().haveDiseaseRiskLevel; + //因为是倒叙排序,所以最后一个疾病风险就是最低级别疾病风险 + matchDiseaseRiskLevel = diseaseRiskLevels.LastOrDefault() == null ? null : diseaseRiskLevels.LastOrDefault().haveDiseaseRiskLevel; } if (matchDiseaseRiskLevel == null) { @@ -390,14 +418,135 @@ namespace Shentun.WebPeis.QuestionRegisters diseaseRisk.DiseaseRiskLevelId = matchDiseaseRiskLevel.DiseaseRiskLevelId; diseaseRisk.DiseaseRiskLevelName = matchDiseaseRiskLevel.DiseaseRiskLevelName; } - - + + } return questionRegisterDiseaseRiskDtos; } + + /// + /// 获取人员单个疾病风险明细 + /// + /// + /// + [HttpPost("api/app/QuestionRegister/GetDiseaseRiskByPersonDiseaseRiskId")] + public async Task GetDiseaseRiskByPersonDiseaseRiskIdAsync(PersonDiseaseRiskIdInputDto input) + { + if (input == null) { throw new UserFriendlyException("input参数不能为空"); } + + var diseaseRisk = await _diseaseRiskRepository.GetAsync(o => o.DiseaseRiskId == input.DiseaseRiskId); + var diseaseRiskLevels = (await _diseaseRiskLevelRepository.GetListAsync(o => o.DiseaseRiskId == input.DiseaseRiskId)) + .OrderBy(o => o.DisplayOrder); + + //获取人员疾病风险列表 + var diseaseRiskList = await GetDiseaseRiskListByPersonIdAsync(new PersonAppointInputDto() { PersonId = input.PersonId }); + var personDiseaseRisk = diseaseRiskList.Where(o => o.DiseaseRiskId == input.DiseaseRiskId).First(); + var diseaseRiskLevel = diseaseRiskLevels.Where(o => o.DiseaseRiskLevelId == personDiseaseRisk.DiseaseRiskLevelId).FirstOrDefault(); + var asbitems = (from diseaseRiskLevelAsbitem in await _diseaseRiskLevelAsbitemRepository.GetQueryableAsync() + join asbitem in await _asbitemRepository.GetQueryableAsync() + on diseaseRiskLevelAsbitem.AsbitemId equals asbitem.AsbitemId + where diseaseRiskLevelAsbitem.DiseaseRiskLevelId == diseaseRiskLevel.DiseaseRiskLevelId + orderby asbitem.DisplayOrder + select asbitem).ToList(); + + var questionRegisterDiseaseRiskSingleDto = new QuestionRegisterDiseaseRiskSingleDto() + { + DiseaseRiskId = diseaseRisk.DiseaseRiskId, + DiseaseRiskName = diseaseRisk.DiseaseRiskName, + DiseaseRiskLevelId = personDiseaseRisk.DiseaseRiskLevelId, + DiseaseRiskLevelName = personDiseaseRisk.DiseaseRiskLevelName, + Explain = diseaseRiskLevel.Explain, + Suggestion = diseaseRiskLevel.Suggestion, + DiseaseRiskLevels = diseaseRiskLevels.Select(o => new DiseaseRiskLevelDto() + { + DiseaseRiskLevelId = o.DiseaseRiskLevelId, + DiseaseRiskLevelName = o.DiseaseRiskLevelName, + DisplayOrder = o.DisplayOrder, + }).ToList(), + Asbitems = asbitems.Select(o => new QuestionRegisterDiseaseRiskAsbitem() + { + AsbitemId = o.AsbitemId, + AsbitemName = o.AsbitemName, + DisplayOrder = o.DisplayOrder + }).ToList() + }; + + + var questionRegister = (await _repository.GetQueryableAsync()) + .Where(o => o.PersonId == input.PersonId) + .OrderByDescending(o => o.CreationTime) + .FirstOrDefault(); + if (questionRegister == null) + { + return null; + } + + var questionRegisterItems = (from questionRegisterItem in await _questionRegisterItemRepository.GetQueryableAsync() + join questionRegisterAnswer in await _questionRegisterAnswerRrepository.GetQueryableAsync() + on questionRegisterItem.QuestionRegisterItemId equals questionRegisterAnswer.QuestionRegisterItemId + join questionAnswer in await _questionAnswerRepository.GetQueryableAsync() + on questionRegisterAnswer.QuestionAnswerId equals questionAnswer.QuestionAnswerId + join question in await _questionRepository.GetQueryableAsync() + on questionRegisterItem.QuestionId equals question.QuestionId + join questionSubjectType in await _questionSubjectTypeRepository.GetQueryableAsync() + on question.QuestionSubjectTypeId equals questionSubjectType.QuestionSubjectTypeId + join diseaseRiskLevelAnswer in await _diseaseRiskLevelAnswerRepository.GetQueryableAsync() + on questionAnswer.QuestionAnswerId equals diseaseRiskLevelAnswer.QuestionAnswerId + where questionRegisterItem.QuestionRegisterId == questionRegister.QuestionRegisterId && + diseaseRiskLevelAnswer.DiseaseRiskLevelId == diseaseRiskLevel.DiseaseRiskLevelId && + questionAnswer.IsNone == 'N' + orderby questionSubjectType.DisplayOrder + select new + { + questionSubjectType, + questionRegisterItem, + questionRegisterAnswer, + questionAnswer + }).ToList(); + + foreach (var questionRegisterItem in questionRegisterItems) + { + if (questionRegisterItems.Where(o => + (o.questionAnswer.PathCode.StartsWith(questionRegisterItem.questionAnswer.PathCode + ".") && + questionRegisterItem.questionAnswer.PathCode.Length == 5)).Any()) + { + continue; + } + + string answer; + if (questionRegisterItem.questionAnswer.AnswerResultType == AnswerResultTypeFlag.Choice) + { + if (string.IsNullOrWhiteSpace(questionRegisterItem.questionAnswer.Aliases)) + { + answer = questionRegisterItem.questionAnswer.QuestionAnswerName; + } + else + { + answer = questionRegisterItem.questionAnswer.Aliases; + } + } + else + { + answer = questionRegisterItem.questionRegisterAnswer.Content; + } + if (string.IsNullOrWhiteSpace(answer)) + { + continue; + } + questionRegisterDiseaseRiskSingleDto.Answers.Add(new QuestionRegisterItemResultAnswer() + { + Answer = answer, + DisplayOrder = questionRegisterItem.questionAnswer.DisplayOrder, + }); + + } + + + return questionRegisterDiseaseRiskSingleDto; + } /// - /// + /// 创建问卷 /// /// /// @@ -464,7 +613,7 @@ namespace Shentun.WebPeis.QuestionRegisters } /// - /// 更新 + /// 更新问卷 /// /// /// @@ -552,9 +701,14 @@ namespace Shentun.WebPeis.QuestionRegisters } await _repository.UpdateAsync(questionRegister); } + /// + /// 获取问卷所有题目 + /// + /// + /// private async Task GetBasicDataAsync(PersonIdInputDto input) { - var questions = (await _questionRepository.GetListAsync(o => o.IsActive == 'Y')).OrderBy(o=>o.DisplayOrder); + var questions = (await _questionRepository.GetListAsync(o => o.IsActive == 'Y')).OrderBy(o => o.DisplayOrder); var questionAnswers = await _questionAnswerRepository.GetListAsync(); var questionRegisterDto = new QuestionRegisterDto() @@ -579,7 +733,7 @@ namespace Shentun.WebPeis.QuestionRegisters }; //一级答案 var firstLevelQuestionAnswers = questionAnswers.Where(o => o.QuestionId == question.QuestionId && - o.PathCode.Length == 5).OrderBy(o=>o.DisplayOrder).ToList(); + o.PathCode.Length == 5).OrderBy(o => o.DisplayOrder).ToList(); foreach (var questionAnswer in firstLevelQuestionAnswers) { var questionRegisterAnswer = new QuestionRegisterAnswerDto() @@ -599,8 +753,8 @@ namespace Shentun.WebPeis.QuestionRegisters }; //二级答案 - var childQuestionAnswers = questionAnswers.Where(o => - o.ParentId == questionAnswer.QuestionAnswerId).OrderBy(o=>o.DisplayOrder).ToList(); + var childQuestionAnswers = questionAnswers.Where(o => + o.ParentId == questionAnswer.QuestionAnswerId).OrderBy(o => o.DisplayOrder).ToList(); foreach (var ChilduestionAnswer in childQuestionAnswers) { var childQuestionRegisterAnswer = new QuestionRegisterAnswerDto() @@ -630,140 +784,33 @@ namespace Shentun.WebPeis.QuestionRegisters return questionRegisterDto; } - private async Task GetTest(PersonIdInputDto input) - { - var questionRegisterDto = new QuestionRegisterDto() - { - QuestionRegisterId = Guid.NewGuid(), - PersonId = input.PersonId, - }; - // - var questionRegisterItemDto = new QuestionRegisterItemDto() - { - QuestionId = Guid.NewGuid(), - QuestionName = "你最近3-6个月是否有生育计划", - AnswerType = AnswerTypeFlag.SingleChoice, - DisplayOrder = 1 - }; - questionRegisterDto.QuestionRegisterItems.Add(questionRegisterItemDto); - - var questionRegisterAnswerDto = new QuestionRegisterAnswerDto() - { - QuestionAnswerId = Guid.NewGuid(), - QuestionAnswerName = "无", - DisplayOrder = 1, - AnswerResultType = '0' - }; - - questionRegisterAnswerDto = new QuestionRegisterAnswerDto() - { - QuestionAnswerId = Guid.NewGuid(), - QuestionAnswerName = "有", - DisplayOrder = 2, - AnswerResultType = '0' - }; - questionRegisterItemDto.QuestionRegisterAnswers.Add(questionRegisterAnswerDto); - // - questionRegisterItemDto = new QuestionRegisterItemDto() - { - QuestionId = Guid.NewGuid(), - QuestionName = "您的父亲、母亲、兄弟、姐妹、目前或曾经是否有以下明确诊断的病?", - AnswerType = AnswerTypeFlag.MultipleChoice, - DisplayOrder = 2 - }; - questionRegisterDto.QuestionRegisterItems.Add(questionRegisterItemDto); - - questionRegisterAnswerDto = new QuestionRegisterAnswerDto() - { - QuestionAnswerId = Guid.NewGuid(), - QuestionAnswerName = "恶性肿瘤", - DisplayOrder = 1, - AnswerResultType = '0' - }; - questionRegisterItemDto.QuestionRegisterAnswers.Add(questionRegisterAnswerDto); - questionRegisterAnswerDto = new QuestionRegisterAnswerDto() - { - QuestionAnswerId = Guid.NewGuid(), - QuestionAnswerName = "心脏病", - DisplayOrder = 2, - AnswerResultType = '0' - }; - questionRegisterItemDto.QuestionRegisterAnswers.Add(questionRegisterAnswerDto); - - questionRegisterAnswerDto = new QuestionRegisterAnswerDto() - { - QuestionAnswerId = Guid.NewGuid(), - QuestionAnswerName = "脑血管病", - DisplayOrder = 3, - AnswerResultType = '0' - }; - questionRegisterItemDto.QuestionRegisterAnswers.Add(questionRegisterAnswerDto); - - // - questionRegisterItemDto = new QuestionRegisterItemDto() - { - QuestionId = Guid.NewGuid(), - QuestionName = "您目前或曾经是否有以下明确诊断的疾病", - AnswerType = AnswerTypeFlag.MultipleChoice, - DisplayOrder = 3 - }; - questionRegisterDto.QuestionRegisterItems.Add(questionRegisterItemDto); - - questionRegisterAnswerDto = new QuestionRegisterAnswerDto() - { - QuestionAnswerId = Guid.NewGuid(), - QuestionAnswerName = "头部疾病", - DisplayOrder = 1, - AnswerResultType = '0', - ChildAnswerType = AnswerTypeFlag.MultipleChoice, - }; - questionRegisterAnswerDto.Childs.Add(new QuestionRegisterAnswerDto() - { - QuestionAnswerId = Guid.NewGuid(), - QuestionAnswerName = "脑中风", - DisplayOrder = 1, - AnswerResultType = '0', - }); - questionRegisterAnswerDto.Childs.Add(new QuestionRegisterAnswerDto() - { - QuestionAnswerId = Guid.NewGuid(), - QuestionAnswerName = "抑郁症", - DisplayOrder = 1, - AnswerResultType = '0', - }); - questionRegisterAnswerDto.Childs.Add(new QuestionRegisterAnswerDto() - { - QuestionAnswerId = Guid.NewGuid(), - QuestionAnswerName = "癫痫", - DisplayOrder = 1, - AnswerResultType = '0', - }); - questionRegisterAnswerDto.Childs.Add(new QuestionRegisterAnswerDto() + /// + /// 是否超重 + /// + /// + /// + /// + private async Task IsOverweight(decimal? height, decimal? weight) + { + if (height == null || weight == null || height <= 0 || weight <= 0) { - QuestionAnswerId = Guid.NewGuid(), - QuestionAnswerName = "其它", - DisplayOrder = 1, - AnswerResultType = '1', - }); - questionRegisterItemDto.QuestionRegisterAnswers.Add(questionRegisterAnswerDto); - questionRegisterAnswerDto = new QuestionRegisterAnswerDto() + return false; + } + + var tzzs = (weight / ((height / 100) * (height / 100))); + var sysTzzsStr = await _sysParmValueManager.GetSysParmValueAsync(Guid.Empty, "question_overweight"); + decimal sysTzzs; + if (!decimal.TryParse(sysTzzsStr, out sysTzzs)) { - QuestionAnswerId = Guid.NewGuid(), - QuestionAnswerName = "甲状腺疾病", - DisplayOrder = 2, - AnswerResultType = '0' - }; - questionRegisterItemDto.QuestionRegisterAnswers.Add(questionRegisterAnswerDto); - - questionRegisterAnswerDto = new QuestionRegisterAnswerDto() + sysTzzs = (decimal)24.5; + } + if (tzzs >= sysTzzs) { - QuestionAnswerId = Guid.NewGuid(), - QuestionAnswerName = "肺部疾病", - DisplayOrder = 3, - AnswerResultType = '0' - }; - questionRegisterItemDto.QuestionRegisterAnswers.Add(questionRegisterAnswerDto); + return true; + } + return false; } + } } diff --git a/src/Shentun.WebPeis.Application/Questions/QuestionAppService.cs b/src/Shentun.WebPeis.Application/Questions/QuestionAppService.cs index 1d8da58..2da1ee4 100644 --- a/src/Shentun.WebPeis.Application/Questions/QuestionAppService.cs +++ b/src/Shentun.WebPeis.Application/Questions/QuestionAppService.cs @@ -87,6 +87,7 @@ namespace Shentun.WebPeis.Questions CreatorId = p.CreatorId, CreatorName = _cacheService.GetSurnameAsync(p.CreatorId).Result, IsActive = p.IsActive, + IsShow = p.IsShow, LastModificationTime = p.LastModificationTime, LastModifierId = p.LastModifierId, LastModifierName = _cacheService.GetSurnameAsync(p.LastModifierId).Result, @@ -192,6 +193,7 @@ namespace Shentun.WebPeis.Questions CreatorId = p.CreatorId, CreatorName = _cacheService.GetSurnameAsync(p.CreatorId).Result, IsActive = p.IsActive, + IsShow = p.IsShow, LastModificationTime = p.LastModificationTime, LastModifierId = p.LastModifierId, LastModifierName = _cacheService.GetSurnameAsync(p.LastModifierId).Result, diff --git a/src/Shentun.WebPeis.Domain/AppointPatientRegisters/AppointPatientRegisterManager.cs b/src/Shentun.WebPeis.Domain/AppointPatientRegisters/AppointPatientRegisterManager.cs index 7f883b8..b01643f 100644 --- a/src/Shentun.WebPeis.Domain/AppointPatientRegisters/AppointPatientRegisterManager.cs +++ b/src/Shentun.WebPeis.Domain/AppointPatientRegisters/AppointPatientRegisterManager.cs @@ -85,12 +85,12 @@ namespace Shentun.WebPeis.AppointPatientRegisters Check.NotNull(entity.MedicalCenterId, "体检中心"); Check.NotDefaultOrNull(entity.CustomerOrgId, "单位"); Check.NotNull(entity.AppointDate, "体检日期"); - var person = await _personRepository.GetAsync(o=>o.PersonId == entity.PersonId); + var person = await _personRepository.GetAsync(o => o.PersonId == entity.PersonId); if (entity.AppointDate < DateTime.Now.Date) { throw new UserFriendlyException("预约日期不能小于当前日期"); } - if (entity.PregnantFlag != PregnantFlag.None && entity.PregnantFlag != PregnantFlag.PreparePregnancy + if (entity.PregnantFlag != PregnantFlag.None && entity.PregnantFlag != PregnantFlag.PreparePregnancy && entity.PregnantFlag != PregnantFlag.Pregnancy) { throw new UserFriendlyException("备孕标志错误"); @@ -105,12 +105,12 @@ namespace Shentun.WebPeis.AppointPatientRegisters { throw new UserFriendlyException("单位分组ID不存在"); } - if(customerOrgGroup.ForSexId != ForSexFlag.All && - customerOrgGroup.ForSexId != person.SexId ) + if (customerOrgGroup.ForSexId != ForSexFlag.All && + customerOrgGroup.ForSexId != person.SexId) { throw new UserFriendlyException("套餐的性别和人员性别不一致"); } - if(customerOrgGroup.MaritalStatusId != MaritalStatusFlag.All && + if (customerOrgGroup.MaritalStatusId != MaritalStatusFlag.All && person.MaritalStatusId == MaritalStatusFlag.UnMarried && customerOrgGroup.MaritalStatusId != MaritalStatusFlag.UnMarried) { @@ -163,7 +163,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters { throw new UserFriendlyException("单位体检不能选套餐"); } - if(entity.PatientRegisterId == null || entity.PatientRegisterId == Guid.Empty) + if (entity.PatientRegisterId == null || entity.PatientRegisterId == Guid.Empty) { throw new UserFriendlyException("团检预约必须有人员备案登记编号"); } @@ -189,18 +189,18 @@ namespace Shentun.WebPeis.AppointPatientRegisters { throw new UserFriendlyException("必须预约组合项目"); } - if (entity.MedicalPackageId != null) + if (entity.MedicalPackageId != null) { - var medicalPackageDetails = await _medicalPackageDetailRepository.GetListAsync(o=>o.MedicalPackageId == entity.MedicalPackageId); + var medicalPackageDetails = await _medicalPackageDetailRepository.GetListAsync(o => o.MedicalPackageId == entity.MedicalPackageId); medicalPackageDetails.ForEach(o => { - if (!entity.AppointRegisterAsbitems.Where(x=>x.AsbitemId == o.AsbitemId).Any()) + if (!entity.AppointRegisterAsbitems.Where(x => x.AsbitemId == o.AsbitemId).Any()) { throw new UserFriendlyException("套餐项目不能取消"); } }); } - + if (entity.CustomerOrgGroupId != null) { var customerOrgGroupDetails = await _customerOrgGroupDetailRepository @@ -214,20 +214,21 @@ namespace Shentun.WebPeis.AppointPatientRegisters }); decimal addMoney = 0; var customerOrgGroup = await _customerOrgGroupRepository.GetAsync(o => o.CustomerOrgGroupId == entity.CustomerOrgGroupId); - foreach (var asbitem in entity.AppointRegisterAsbitems) + foreach (var asbitem in entity.AppointRegisterAsbitems) { - + var customerOrgGroupDetail = customerOrgGroupDetails.Where(o => o.AsbitemId == asbitem.AsbitemId).FirstOrDefault(); - if(customerOrgGroupDetail == null) + if (customerOrgGroupDetail == null) { addMoney += asbitem.ChargePrice; } - if(addMoney > 0) + if (addMoney > 0) { - if(addMoney > customerOrgGroup.CanAddMoney) + if (addMoney > customerOrgGroup.CanAddMoney) { - throw new UserFriendlyException($"自选的单位支付金额不能超过{customerOrgGroup.CanAddMoney}元"); + //暂时屏蔽 + //throw new UserFriendlyException($"自选的单位支付金额不能超过{customerOrgGroup.CanAddMoney}元"); } } } @@ -235,6 +236,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters + var asbitems = await _asbitemRepository.GetListAsync(); foreach (var appointRegisterAsbitem in entity.AppointRegisterAsbitems) { @@ -268,7 +270,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters if (customerOrg.CustomerOrgId == GuidFlag.PersonCustomerOrgId) { appointRegisterAsbitem.PayTypeFlag = PayTypeFlag.PersonPay; - + } else { @@ -280,16 +282,28 @@ namespace Shentun.WebPeis.AppointPatientRegisters } } + if (entity.PregnantFlag == PregnantFlag.PreparePregnancy && asbitem.ForPregnantFlag == ForPregnantFlag.PreparePregnancy) + { + throw new UserFriendlyException($"备孕期间禁检{asbitem.AsbitemName}"); + } + + if (entity.PregnantFlag == PregnantFlag.Pregnancy && + (asbitem.ForPregnantFlag == ForPregnantFlag.PreparePregnancy|| asbitem.ForPregnantFlag == ForPregnantFlag.Pregnancy)) + { + throw new UserFriendlyException($"怀孕期间禁检{asbitem.AsbitemName}"); + } + appointRegisterAsbitem.IsCharge = 'N'; } var appoentPatientRegisters = await _repository.GetListAsync(o => o.PersonId == entity.PersonId && o.AppointDate >= DateTime.Now.Date && o.CompleteFlag != AppointPatientRegisterCompleteFlag.CancelAppoint); - if(appoentPatientRegisters.Count >= 1) + if (appoentPatientRegisters.Count >= 1) { throw new UserFriendlyException("已有今天及之后的预约订单,必须先取消订单"); } + } } } diff --git a/src/Shentun.WebPeis.Domain/Models/Question.cs b/src/Shentun.WebPeis.Domain/Models/Question.cs index dafb1ba..4193b25 100644 --- a/src/Shentun.WebPeis.Domain/Models/Question.cs +++ b/src/Shentun.WebPeis.Domain/Models/Question.cs @@ -42,6 +42,11 @@ public partial class Question : AuditedEntity, IHasConcurrencyStamp, IDisplayOrd public char? IsActive { get; set; } /// + /// 是否显示 + /// + + public char IsShow { get; set; } + /// /// 父问卷ID /// diff --git a/src/Shentun.WebPeis.Domain/Questions/QuestionManager.cs b/src/Shentun.WebPeis.Domain/Questions/QuestionManager.cs index c0b7df1..8ade630 100644 --- a/src/Shentun.WebPeis.Domain/Questions/QuestionManager.cs +++ b/src/Shentun.WebPeis.Domain/Questions/QuestionManager.cs @@ -39,6 +39,7 @@ namespace Shentun.WebPeis.Questions { AnswerType = entity.AnswerType, IsActive = entity.IsActive, + IsShow = entity.IsShow, ParentId = entity.ParentId, PathCode = await CreatePathCode(entity.ParentId), QuestionId = entity.QuestionId, @@ -69,6 +70,7 @@ namespace Shentun.WebPeis.Questions targetEntity.AnswerType = sourceEntity.AnswerType; targetEntity.IsActive = sourceEntity.IsActive; + targetEntity.IsShow = sourceEntity.IsShow; targetEntity.QuestionName = sourceEntity.QuestionName; targetEntity.QuestionSubjectTypeId = sourceEntity.QuestionSubjectTypeId; targetEntity.SimpleCode = LanguageConverter.GetPYSimpleCode(sourceEntity.QuestionName); diff --git a/src/Shentun.WebPeis.EntityFrameworkCore/Configures/QuestionConfigure.cs b/src/Shentun.WebPeis.EntityFrameworkCore/Configures/QuestionConfigure.cs index 15e989b..5eeb4da 100644 --- a/src/Shentun.WebPeis.EntityFrameworkCore/Configures/QuestionConfigure.cs +++ b/src/Shentun.WebPeis.EntityFrameworkCore/Configures/QuestionConfigure.cs @@ -44,6 +44,12 @@ namespace Shentun.WebPeis.Configures entity.Property(e => e.IsActive) .HasMaxLength(1) .HasColumnName("is_active"); + + entity.Property(e => e.IsShow) + .HasMaxLength(1) + .HasDefaultValueSql("'Y'::bpchar") + .HasColumnName("is_show"); + entity.Property(e => e.LastModificationTime) .HasColumnType("timestamp(6) without time zone") .HasColumnName("last_modification_time"); diff --git a/test/Shentun.WebPeis.Application.Tests/QuestionRegisterAppServiceTest.cs b/test/Shentun.WebPeis.Application.Tests/QuestionRegisterAppServiceTest.cs index 36027c8..ab67c93 100644 --- a/test/Shentun.WebPeis.Application.Tests/QuestionRegisterAppServiceTest.cs +++ b/test/Shentun.WebPeis.Application.Tests/QuestionRegisterAppServiceTest.cs @@ -1,4 +1,5 @@ -using Shentun.WebPeis.Asbitems; +using Shentun.WebPeis.AppointPatientRegisters; +using Shentun.WebPeis.Asbitems; using Shentun.WebPeis.Models; using Shentun.WebPeis.Persons; using Shentun.WebPeis.QuestionRegisters; @@ -100,7 +101,7 @@ namespace Shentun.WebPeis using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true)) { - var entity = await _appService.GetQuestionRegisterListByPersonIdAsync(new PersonIdInputDto() + var entity = await _appService.GetQuestionRegisterListByPersonIdAsync(new PersonAppointInputDto() { PersonId = new Guid("3a12d72c-19d9-e8b2-71f6-cf283103e191") // 3a12d7fa-63f1-d549-c2f8-01123e5b7a8a }); @@ -126,7 +127,7 @@ namespace Shentun.WebPeis using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true)) { - var entity = await _appService.GetDiseaseRiskListByPersonIdAsync(new PersonIdInputDto() + var entity = await _appService.GetDiseaseRiskListByPersonIdAsync(new PersonAppointInputDto() { PersonId = new Guid("3a12d72c-19d9-e8b2-71f6-cf283103e191") // 3a12d7fa-63f1-d549-c2f8-01123e5b7a8a }); @@ -138,5 +139,39 @@ namespace Shentun.WebPeis await unitOfWork.CompleteAsync(); } } + + [Fact] + public async Task GetDiseaseRiskByPersonDiseaseRiskIdAsync() + { + using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true)) + { + + var entity = await _appService.GetDiseaseRiskByPersonDiseaseRiskIdAsync(new PersonDiseaseRiskIdInputDto() + { + PersonId = new Guid("3a12d72c-19d9-e8b2-71f6-cf283103e191"), // 3a12d7fa-63f1-d549-c2f8-01123e5b7a8a + DiseaseRiskId = new Guid("81c57075-4809-488b-aaa4-7e717c9f74a2") + }); + _output.WriteLine(entity.DiseaseRiskName + entity.DiseaseRiskLevelName + entity.Explain + entity.Suggestion); + foreach (var item in entity.DiseaseRiskLevels) + { + _output.WriteLine(item.DiseaseRiskLevelName); + + } + _output.WriteLine("----推荐项目----"); + foreach (var item in entity.Asbitems) + { + _output.WriteLine(item.AsbitemName ); + + } + _output.WriteLine("----风险因素----"); + + foreach (var item in entity.Answers) + { + _output.WriteLine(item.Answer); + + } + await unitOfWork.CompleteAsync(); + } + } } }