Browse Source

健康评估报告

master
wxd 1 year ago
parent
commit
78d9b43876
  1. 53
      src/Shentun.WebPeis.Application.Contracts/Persons/MedicalHealthReportDto.cs
  2. 2
      src/Shentun.WebPeis.Application/DiseaseRiskLevels/DiseaseRiskLevelAppService.cs
  3. 104
      src/Shentun.WebPeis.Application/Persons/PersonAppService.cs
  4. 5
      src/Shentun.WebPeis.HttpApi.Host/appsettings.json

53
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<MedicalHealthReportListDetailDto> 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; }
}
}

2
src/Shentun.WebPeis.Application/DiseaseRiskLevels/DiseaseRiskLevelAppService.cs

@ -88,7 +88,7 @@ namespace Shentun.WebPeis.DiseaseRiskLevels
public async Task<DiseaseRiskLevelDto> CreateAsync(CreateDiseaseRiskLevelDto input) public async Task<DiseaseRiskLevelDto> CreateAsync(CreateDiseaseRiskLevelDto input)
{ {
var createEntity = ObjectMapper.Map<CreateDiseaseRiskLevelDto, DiseaseRiskLevel>(input); var createEntity = ObjectMapper.Map<CreateDiseaseRiskLevelDto, DiseaseRiskLevel>(input);
createEntity.DiseaseRiskId = GuidGenerator.Create();
createEntity.DiseaseRiskLevelId = GuidGenerator.Create();
var entity = await _diseaseRiskLevelManager.CreateAsync(createEntity); var entity = await _diseaseRiskLevelManager.CreateAsync(createEntity);
entity = await _diseaseRiskLevelRepository.InsertAsync(entity); entity = await _diseaseRiskLevelRepository.InsertAsync(entity);
var dto = ObjectMapper.Map<DiseaseRiskLevel, DiseaseRiskLevelDto>(entity); var dto = ObjectMapper.Map<DiseaseRiskLevel, DiseaseRiskLevelDto>(entity);

104
src/Shentun.WebPeis.Application/Persons/PersonAppService.cs

@ -409,6 +409,62 @@ namespace Shentun.WebPeis.Persons
return returnValue; return returnValue;
} }
/// <summary>
/// 获取健康评估报告
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="UserFriendlyException"></exception>
[HttpPost("api/app/Person/GetMedicalHealthReportByPatientRegisterId")]
public async Task<MedicalReportDto> 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<MedicalHealthReportListInputDto, MedicalHealthReportListDto>(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<MedicalHealthReportDto, MedicalHealthReportDto>(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;
}
/// <summary> /// <summary>
/// 获取校验码 /// 获取校验码
/// </summary> /// </summary>
@ -591,7 +647,55 @@ namespace Shentun.WebPeis.Persons
} }
private async static Task<TOut> CallAppServiceAsync<TInput, TOut>(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<TOut>(result, jsonOptions);
return resultDto;
}
}
}
}
} }
} }

5
src/Shentun.WebPeis.HttpApi.Host/appsettings.json

@ -59,5 +59,10 @@
"Redis": { "Redis": {
"IsEnabled": "true", "IsEnabled": "true",
"Configuration": "62.156.10.86" "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"
} }
} }
Loading…
Cancel
Save