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.
155 lines
6.5 KiB
155 lines
6.5 KiB
using Dapper;
|
|
using Microsoft.Data.SqlClient;
|
|
using Newtonsoft.Json;
|
|
using Npgsql;
|
|
using NPOI.Util;
|
|
using NUglify.Helpers;
|
|
using Oracle.ManagedDataAccess.Client;
|
|
using Shentun.Peis.ImportLisResults;
|
|
using Shentun.Peis.LisRequests;
|
|
using Shentun.Utilities;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.Common;
|
|
using System.Linq;
|
|
using System.Net.Http.Headers;
|
|
using System.Security.Policy;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Shentun.Peis.PlugIns.ImportLisResults
|
|
{
|
|
public class ImportLisResultPlugInsDbBase : ImportLisResultPlugInsBase
|
|
{
|
|
public ImportLisResultPlugInsDbBase(Guid thirdInterfaceId) : base(thirdInterfaceId)
|
|
{
|
|
|
|
}
|
|
|
|
public ImportLisResultPlugInsDbBase(string parmValue) : base(parmValue)
|
|
{
|
|
}
|
|
|
|
public override async Task<ImportLisResultPlugInsOut> ImportResultByPatientRegisterIdAsync(Guid patientRegisterId)
|
|
{
|
|
if (ItemColumnReferenceId == null || ItemColumnReferenceId == Guid.Empty)
|
|
{
|
|
throw new Exception("没有设置项目编码对照");
|
|
}
|
|
var result = new ImportLisResultPlugInsOut();
|
|
var execOrganizationUnitIdStr = InterfaceConfig.GetSection("Interface").GetSection("ExecOrganizationUnitId").Value;
|
|
if (string.IsNullOrWhiteSpace(execOrganizationUnitIdStr))
|
|
{
|
|
throw new Exception("执行科室配置不能为空");
|
|
}
|
|
if (!Guid.TryParse(execOrganizationUnitIdStr, out Guid execOrganizationUnitId))
|
|
{
|
|
throw new Exception("执行科室配置不是有效的GUID值");
|
|
}
|
|
var lisRequests = await GetLisRequestForImportResultPlugInssAsync(patientRegisterId);
|
|
using (DbConnection conn = CreateInterfaceDbConnect())
|
|
{
|
|
|
|
//设置结果,生成小结
|
|
|
|
//await LoginAsync();
|
|
var createImportLisResultDtos = new List<CreateImportLisResultDto>();
|
|
foreach (var lisRequest in lisRequests)
|
|
{
|
|
//if (lisRequest.LisRequestNo == "2405090117")
|
|
//{
|
|
// ;
|
|
//}
|
|
createImportLisResultDtos.Clear();
|
|
string sql;
|
|
sql = InterfaceSql + " where " + InterfaceSqlKeyColumn + " = '" + lisRequest.LisRequestNo + "'";
|
|
var lisResultFromInterfaces = (await conn.QueryAsync<LisResultFromImportInterface>(sql)).ToList();
|
|
try
|
|
{
|
|
foreach (var lisResult in lisResultFromInterfaces)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(lisResult.Result))
|
|
{
|
|
continue;
|
|
}
|
|
if (string.IsNullOrWhiteSpace(lisResult.ItemId))
|
|
{
|
|
throw new Exception("第三方接口数据项目编码不能为空");
|
|
}
|
|
|
|
if (string.IsNullOrWhiteSpace(lisResult.ItemName))
|
|
{
|
|
throw new Exception("第三方接口数据项目名称不能为空");
|
|
}
|
|
if (string.IsNullOrWhiteSpace(lisResult.CheckDoctorName))
|
|
{
|
|
throw new Exception("检验医生不能为空");
|
|
}
|
|
|
|
//if(lisResult.ItemId == "435")
|
|
//{
|
|
// ;
|
|
//}
|
|
var columnReferenceCodes = await GetColumnReferenceCodeValuesAsync(ItemColumnReferenceId, lisResult.ItemId);
|
|
if (columnReferenceCodes == null || !columnReferenceCodes.Any())
|
|
{
|
|
//throw new Exception($"LIS系统中项目名:{lisResult.ItemName} 编码:{lisResult.ItemId}没有与体检系统对照编码");
|
|
continue;
|
|
|
|
}
|
|
foreach (var columnReferenceCode in columnReferenceCodes)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(columnReferenceCode.CodeValue))
|
|
{
|
|
continue;
|
|
}
|
|
if (!Guid.TryParse(columnReferenceCode.CodeValue, out var appItemId))
|
|
{
|
|
throw new Exception($"{lisResult.ItemName}对照的编码无效");
|
|
}
|
|
|
|
var createImportLisResultDto = new CreateImportLisResultDto()
|
|
{
|
|
LisRequestNo = lisResult.LisRequestNo,
|
|
ItemId = appItemId,
|
|
ItemName = lisResult.ItemName,
|
|
Result = lisResult.Result,
|
|
Unit = lisResult.Unit,
|
|
ReferenceRangeValue = lisResult.ReferenceRangeValue,
|
|
CriticalRangeValue = lisResult.CriticalRangeValue,
|
|
ResultStatusId = lisResult.ResultStatusId,
|
|
ReportPrompt = lisResult.ReportPrompt,
|
|
CheckDoctorName = lisResult.CheckDoctorName,
|
|
CheckDate = lisResult.CheckDate,
|
|
ExecOrganizationUnitId = execOrganizationUnitId
|
|
};
|
|
createImportLisResultDtos.Add(createImportLisResultDto);
|
|
}
|
|
|
|
|
|
}
|
|
if (!createImportLisResultDtos.Any())
|
|
{
|
|
continue;
|
|
}
|
|
|
|
var callResult = await CallAppServiceAsync<List<CreateImportLisResultDto>, object>("api/app/ImportLisResult/ImportResult", createImportLisResultDtos);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//throw ex;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|