3 changed files with 390 additions and 0 deletions
-
140ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ImportElectrocardiogramResults/Mdks/ImportElectrocardiogramResultPlugInsMdks.cs
-
209src/Shentun.Peis.Application/ImportPacsResults/ImportPacsResultAppService.cs
-
41src/Shentun.Utilities/FileHelper.cs
@ -0,0 +1,140 @@ |
|||
using Newtonsoft.Json.Converters; |
|||
using Newtonsoft.Json; |
|||
using Shentun.Peis.ImportPacsResults; |
|||
using Shentun.Peis.PlugIns.Extensions.ImportPacsResults.Hzcy; |
|||
using Shentun.Peis.PlugIns.ImportPacsResults; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Net.Http.Headers; |
|||
using System.Text; |
|||
|
|||
namespace Shentun.Peis.PlugIns.Extensions.ImportElectrocardiogramResults.Mdks |
|||
{ |
|||
|
|||
public class ImportElectrocardiogramResultPlugInsMdks : ImportPacsResultPlugInsBase |
|||
{ |
|||
public ImportElectrocardiogramResultPlugInsMdks(Guid thirdInterfaceId) : base(thirdInterfaceId) |
|||
{ |
|||
} |
|||
public ImportElectrocardiogramResultPlugInsMdks(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/Electrocardiogram/ImportElectrocardiogramResult", 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, 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; |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue