You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
142 lines
6.2 KiB
142 lines
6.2 KiB
using Newtonsoft.Json.Converters;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net.Http.Headers;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Shentun.Peis.ImportPacsResults;
|
|
using NPOI.SS.Formula.Functions;
|
|
using Shentun.Peis.ImportLisResults;
|
|
using System.Security.Policy;
|
|
using Shentun.Peis.PlugIns.ImportPacsResults;
|
|
|
|
namespace Shentun.Peis.PlugIns.Gem
|
|
{
|
|
public class ImportPacsResultPlugInsGem : ImportPacsResultPlugInsBase
|
|
{
|
|
public ImportPacsResultPlugInsGem(Guid thirdInterfaceId) : base(thirdInterfaceId)
|
|
{
|
|
}
|
|
public ImportPacsResultPlugInsGem(string parmValue) : base(parmValue)
|
|
{
|
|
}
|
|
|
|
public override async Task<ImportPacsResultPlugInsOut> ImportResultByPatientRegisterIdAsync(Guid patientRegisterId)
|
|
{
|
|
//if (DepartmentColumnReferenceId == null || DepartmentColumnReferenceId == Guid.Empty)
|
|
//{
|
|
// throw new Exception("没有设置科室编码对照");
|
|
//}
|
|
var pacsRequests = await GetPacsRequestForImportResultPlugInssAsync(patientRegisterId);
|
|
|
|
var beginTime = DateTime.Now.Date.AddDays(-30);
|
|
foreach (var pacsRequest in pacsRequests)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(pacsRequest.CheckRequestNo))
|
|
{
|
|
continue;
|
|
}
|
|
var interfaceInpu = new ImportPacsResultInterfaceInput()
|
|
{
|
|
tjNum = pacsRequest.CheckRequestNo,
|
|
organizeCode = "1",
|
|
patientType = "3",
|
|
////requestId = pacsRequest.CheckRequestNo,
|
|
//beginTime = beginTime.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
//endTime=DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
pageNo = 1,
|
|
pageSize = 20
|
|
};
|
|
//if(interfaceInpu.tjNum == "2405112185")
|
|
//{
|
|
// ;
|
|
//}
|
|
var apiResult = await CallInterfaceServiceAsync<ImportPacsResultInterfaceInput,
|
|
ImportPacsResultInterfaceOut>(interfaceInpu);
|
|
if (apiResult == null || !apiResult.data.Any())
|
|
{
|
|
continue;
|
|
}
|
|
var firstData = apiResult.data[0];
|
|
if (!DateTime.TryParse(firstData.reportDateTime, out var checkDate))
|
|
{
|
|
throw new Exception("报告时间格式不正确");
|
|
}
|
|
var createImportPacsResultDto = new CreateImportPacsResultDto()
|
|
{
|
|
CheckRequestNo = pacsRequest.CheckRequestNo,
|
|
PatientName = pacsRequest.PatientName,
|
|
Result = firstData.examDescript,
|
|
Summary = firstData.examDiagnosis,
|
|
Suggestion = firstData.suggestion,
|
|
CheckDate = checkDate,
|
|
CheckDoctorName = firstData.reportDoctorName,
|
|
Files = new List<CreateImportPacsResultPictureDto>()
|
|
{
|
|
new CreateImportPacsResultPictureDto()
|
|
{
|
|
IsPrint = 'Y',
|
|
FileTransMode = "1",//0-json,1-url
|
|
FileName = firstData.reportUrl,
|
|
FileFormat = "1",//0-图片,1-pdf
|
|
FileUrl = firstData.reportUrl,
|
|
//FileBase64 = Shentun.Utilities.FileHelper.ToBase64(firstData.reportUrl)
|
|
},
|
|
|
|
}
|
|
};
|
|
|
|
|
|
var callResult = await CallAppServiceAsync<CreateImportPacsResultDto, object>("api/app/ImportPacsResult/ImportResult", createImportPacsResultDto);
|
|
|
|
}
|
|
var result = new ImportPacsResultPlugInsOut();
|
|
return result;
|
|
}
|
|
|
|
|
|
public async Task<TOut> CallInterfaceServiceAsync<TInput, TOut>(TInput data)
|
|
{
|
|
string baseAddress = InterfaceWebApiUrl;
|
|
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是可接受的响应类型
|
|
//httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _accesToken);
|
|
IsoDateTimeConverter timeFormat = new IsoDateTimeConverter();
|
|
timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
|
|
var sendData = JsonConvert.SerializeObject(data, Newtonsoft.Json.Formatting.Indented, timeFormat);
|
|
using (HttpContent httpContent = new StringContent(sendData))
|
|
{
|
|
httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
|
|
HttpResponseMessage response = await httpClient.PostAsync("", httpContent);
|
|
string result;
|
|
if (!response.IsSuccessStatusCode)
|
|
{
|
|
result = response.Content.ReadAsStringAsync().Result;
|
|
throw new Exception("http通信错误:" + response.StatusCode + ",结果:" + result);
|
|
}
|
|
result = await response.Content.ReadAsStringAsync();
|
|
|
|
dynamic resultDto = JsonConvert.DeserializeObject<TOut>(result);
|
|
if (resultDto != null)
|
|
{
|
|
if (resultDto.code != "200")
|
|
{
|
|
throw new Exception($"调用WebApi失败,返回错误,消息:" + resultDto.code + resultDto.msg);
|
|
}
|
|
}
|
|
return resultDto;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|