From 78d9b43876702711034af458c6acfc54aabdf009 Mon Sep 17 00:00:00 2001 From: wxd <123@qq.com> Date: Sun, 16 Jun 2024 19:48:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=81=A5=E5=BA=B7=E8=AF=84=E4=BC=B0=E6=8A=A5?= =?UTF-8?q?=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Persons/MedicalHealthReportDto.cs | 53 +++++++++ .../DiseaseRiskLevelAppService.cs | 2 +- .../Persons/PersonAppService.cs | 110 +++++++++++++++++- .../appsettings.json | 5 + 4 files changed, 166 insertions(+), 4 deletions(-) create mode 100644 src/Shentun.WebPeis.Application.Contracts/Persons/MedicalHealthReportDto.cs diff --git a/src/Shentun.WebPeis.Application.Contracts/Persons/MedicalHealthReportDto.cs b/src/Shentun.WebPeis.Application.Contracts/Persons/MedicalHealthReportDto.cs new file mode 100644 index 0000000..ec39a9a --- /dev/null +++ b/src/Shentun.WebPeis.Application.Contracts/Persons/MedicalHealthReportDto.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.WebPeis.Persons +{ + public class MedicalHealthReportListInputDto + { + public int Page { get; set; } + + public int Size { get; set; } + + public string RecordNo { get; set; } + } + + public class MedicalHealthReportListDto + { + public int State { get; set; } + public int Code { get; set; } + public string Message { get; set; } + + public int Page { get; set; } + + public int Size { get; set; } + + public int Total { get; set; } + + public List Data { get; set; } + } + + public class MedicalHealthReportListDetailDto + { + public string ResultId { get; set; } + public string RecordNo { get; set; } + public string PhysicalTime { get; set; } + public string ReportStatus { get; set; } + + public string CreateTime { get; set; } + } + + public class MedicalHealthReportDto + { + public int State { get; set; } + public int Code { get; set; } + public string Message { get; set; } + + public string Remark { get; set; } + + public string Data { get; set; } + + + } +} diff --git a/src/Shentun.WebPeis.Application/DiseaseRiskLevels/DiseaseRiskLevelAppService.cs b/src/Shentun.WebPeis.Application/DiseaseRiskLevels/DiseaseRiskLevelAppService.cs index b0ee610..ebb7525 100644 --- a/src/Shentun.WebPeis.Application/DiseaseRiskLevels/DiseaseRiskLevelAppService.cs +++ b/src/Shentun.WebPeis.Application/DiseaseRiskLevels/DiseaseRiskLevelAppService.cs @@ -88,7 +88,7 @@ namespace Shentun.WebPeis.DiseaseRiskLevels public async Task CreateAsync(CreateDiseaseRiskLevelDto input) { var createEntity = ObjectMapper.Map(input); - createEntity.DiseaseRiskId = GuidGenerator.Create(); + createEntity.DiseaseRiskLevelId = GuidGenerator.Create(); var entity = await _diseaseRiskLevelManager.CreateAsync(createEntity); entity = await _diseaseRiskLevelRepository.InsertAsync(entity); var dto = ObjectMapper.Map(entity); diff --git a/src/Shentun.WebPeis.Application/Persons/PersonAppService.cs b/src/Shentun.WebPeis.Application/Persons/PersonAppService.cs index 32d1ebe..802f5c5 100644 --- a/src/Shentun.WebPeis.Application/Persons/PersonAppService.cs +++ b/src/Shentun.WebPeis.Application/Persons/PersonAppService.cs @@ -214,7 +214,7 @@ namespace Shentun.WebPeis.Persons (await _userManager.AddPasswordAsync(userWithPerson.User, Shentun.Utilities. Encrypt.RandomHelper.CreateRandom(Utilities.Enums.RandomType.NumAndChar, 10) + "0Cz*")).CheckErrors(); - + } await unitOfWork.CompleteAsync(); @@ -358,7 +358,7 @@ namespace Shentun.WebPeis.Persons on user.Id equals person.PersonId join questionRegister in await _questionRegisterRepository.GetQueryableAsync() on person.PersonId equals questionRegister.PersonId into emptyQuestionRegister - from haveQuestionRegister in emptyQuestionRegister.DefaultIfEmpty() + from haveQuestionRegister in emptyQuestionRegister.DefaultIfEmpty() where personKinshipIds.Contains(user.Id) orderby user.CreationTime select new PersonDto @@ -371,7 +371,7 @@ namespace Shentun.WebPeis.Persons MaritalStatusName = _cacheService.GetMaritalStatusNameAsync(person.MaritalStatusId).Result, IdNo = person.IdNo, MobileTelephone = user.PhoneNumber, - IsHaveQuestionRegister = haveQuestionRegister == null ? 'N':'Y' + IsHaveQuestionRegister = haveQuestionRegister == null ? 'N' : 'Y' }).Distinct().ToList(); @@ -409,6 +409,62 @@ namespace Shentun.WebPeis.Persons return returnValue; } + + + /// + /// 获取健康评估报告 + /// + /// + /// + /// + [HttpPost("api/app/Person/GetMedicalHealthReportByPatientRegisterId")] + public async Task GetMedicalHealthReportByPatientRegisterIdAsync(PatientRegisterIdInputDto input) + { + var entity = await _patientRegisterRepository.GetAsync(o => o.PatientRegisterId == input.PatientRegisterId); + string baseAddress = _configuration.GetSection("MedicalHealthReport").GetSection("BaseAddress").Value; + string reportListApiUrl = _configuration.GetSection("MedicalHealthReport").GetSection("ReportListApiUrl").Value; + string reportApiUrl = _configuration.GetSection("MedicalHealthReport").GetSection("ReportApiUrl").Value; + + var medicalHealthReportListInputDto = new MedicalHealthReportListInputDto + { + Page = 1, + Size = 10, + RecordNo = entity.PatientRegisterNo + }; + + var medicalHealthReportListResult = await CallAppServiceAsync(baseAddress, reportListApiUrl, medicalHealthReportListInputDto, "post"); + + if (medicalHealthReportListResult.Code == 200 + || medicalHealthReportListResult.Data.FirstOrDefault() == null + || medicalHealthReportListResult.Data.FirstOrDefault().ReportStatus != "1") + { + throw new UserFriendlyException("没有报告单"); + } + + //报告单ID + var resultId = medicalHealthReportListResult.Data.FirstOrDefault().ResultId; + + reportApiUrl = reportApiUrl + $"?resultId={resultId}"; //获取报告apiurl + + var medicalHealthReportResult = await CallAppServiceAsync(baseAddress, reportApiUrl, null, "get"); + if (medicalHealthReportResult.Code == 200 + || string.IsNullOrWhiteSpace(medicalHealthReportResult.Data) + ) + { + throw new UserFriendlyException("没有报告单"); + } + + string reportUrl= medicalHealthReportResult.Data; + + var returnValue = new MedicalReportDto() + { + FilePath = reportUrl, + FileBase64 = Shentun.Utilities.FileHelper.ToBase64(reportUrl) + }; + return returnValue; + + } + /// /// 获取校验码 /// @@ -591,7 +647,55 @@ namespace Shentun.WebPeis.Persons } + private async static Task CallAppServiceAsync(string baseAddress, string url, TInput? data, string method = "post") + { + + using (var httpClientHandler = new HttpClientHandler()) + { + using (var httpClient = new HttpClient(httpClientHandler)) + { + httpClient.BaseAddress = new Uri(baseAddress); + + httpClient.DefaultRequestHeaders.Accept.Add( + new MediaTypeWithQualityHeaderValue("application/json"));//设置accept标头,告诉JSON是可接受的响应类型 + var jsonOptions = new JsonSerializerOptions + { + WriteIndented = true, // 设置为true以便于可读性更好的JSON输出 + PropertyNamingPolicy = JsonNamingPolicy.CamelCase, + // 如果你想要对日期进行格式化,可以使用JsonConverter + Converters = { new JsonDateTimeConverter("yyyy-MM-dd HH:mm:ss") } + }; + var sendData = System.Text.Json.JsonSerializer.Serialize(data, jsonOptions); + using (HttpContent httpContent = new StringContent(sendData)) + { + httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); + HttpResponseMessage response = null; + if (method == "post") + { + response = await httpClient.PostAsync(url, httpContent); + } + else + { + response = await httpClient.GetAsync(url); + } + + string result; + if (!response.IsSuccessStatusCode) + { + result = response.Content.ReadAsStringAsync().Result; + throw new Exception("http通信错误:" + response.StatusCode + ",结果:" + result); + } + result = await response.Content.ReadAsStringAsync(); + + var resultDto = System.Text.Json.JsonSerializer.Deserialize(result, jsonOptions); + + return resultDto; + } + + } + } + } } } diff --git a/src/Shentun.WebPeis.HttpApi.Host/appsettings.json b/src/Shentun.WebPeis.HttpApi.Host/appsettings.json index ae494be..08e0546 100644 --- a/src/Shentun.WebPeis.HttpApi.Host/appsettings.json +++ b/src/Shentun.WebPeis.HttpApi.Host/appsettings.json @@ -59,5 +59,10 @@ "Redis": { "IsEnabled": "true", "Configuration": "62.156.10.86" + }, + "MedicalHealthReport": { + "BaseAddress": "http://10.1.13.31", + "ReportListApiUrl": "http://10.1.13.31/api/report/page", + "ReportApiUrl": "http://10.1.13.31/api/report/download" } }