@ -34,68 +34,94 @@ namespace Shentun.Peis.PlugIns
}
var result = new LisResultImportPlugInsOut ( ) ;
var execOrganizationUnitIdStr = InterfaceConfig . GetSection ( "Interface" ) . GetSection ( "ExecOrganizationUnitId" ) . Value ;
if ( string . IsNullOrWhiteSpace ( execOrganizationUnitIdStr ) )
if ( string . IsNullOrWhiteSpace ( execOrganizationUnitIdStr ) )
{
throw new Exception ( "执行科室配置不能为空" ) ;
}
if ( ! Guid . TryParse ( execOrganizationUnitIdStr , out Guid execOrganizationUnitId ) )
if ( ! Guid . TryParse ( execOrganizationUnitIdStr , out Guid execOrganizationUnitId ) )
{
throw new Exception ( "执行科室配置不是有效的GUID值" ) ;
}
var lisRequests = await GetLisRequestForResultImportPlugInssAsync ( input . PatientRegisterId ) ;
using ( DbConnection conn = CreateInterfaceDbConnect ( ) )
{
var lisResultFromInterfaces = ( await conn . QueryAsync < LisResultFromInterface > ( InterfaceSql ) ) . ToList ( ) ;
//设置结果,生成小结
await LoginAsync ( ) ;
var createImportLisResultDtos = new List < CreateImportLisResultDto > ( ) ;
foreach ( var lisResult in lisResultFromInterfaces )
foreach ( var lisReque st in lisRequest s )
{
if ( string . IsNullOrWhiteSpace ( lisResult . ItemName ) )
{
throw new Exception ( "第三方接口数据项目名称不能为空" ) ;
}
var columnReferenceCodes = await GetColumnReferenceCodeValuesAsync ( ItemColumnReferenceId , lisResult . ItemId ) ;
if ( columnReferenceCodes = = null | | ! columnReferenceCodes . Any ( ) )
createImportLisResultDtos . Clear ( ) ;
string sql ;
sql = InterfaceSql + " where " + InterfaceSqlKeyColumn + " = '" + lisRequest . LisRequestNo + "'" ;
var lisResultFromInterfaces = ( await conn . QueryAsync < LisResultFromInterface > ( sql ) ) . ToList ( ) ;
try
{
throw new Exception ( $"{lisResult.ItemName}没有对照编码" ) ;
}
foreach ( var columnReferenceCode in columnReferenceCodes )
{
if ( string . IsNullOrWhiteSpace ( columnReferenceCode . CodeValue ) )
foreach ( var lisResult in lisResultFromInterfaces )
{
continue ;
if ( string . IsNullOrWhiteSpace ( lisResult . ItemName ) )
{
throw new Exception ( "第三方接口数据项目名称不能为空" ) ;
}
if ( string . IsNullOrWhiteSpace ( lisResult . CheckDoctorName ) )
{
throw new Exception ( "检验医生不能为空" ) ;
}
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 ( ! Guid . TryParse ( columnReferenceCode . CodeValue , out var appItemId ) )
if ( ! createImportLisResultDtos . Any ( ) )
{
throw new Exception ( $"{lisResult.ItemName}对照的编码无效" ) ;
return result ;
}
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 ) ;
var callResult = await CallAppServiceAsync < List < CreateImportLisResultDto > , object > ( "api/app/ImportLisResult/ImportResult" , createImportLisResultDtos ) ;
}
catch ( Exception ex )
{
//throw ex;
}
}
if ( ! createImportLisResultDtos . Any ( ) )
{
return result ;
}
await LoginAsync ( ) ;
await CallAppServiceAsync < List < CreateImportLisResultDto > , object > ( "api/app/ImportLisResult/ImportResult" , createImportLisResultDtos ) ;
}
return result ;