using System.Threading.Channels ;
namespace DicomTool.Utils
{
public static class PacsSqlHelper
{
public static List < ReportPacs > GetPacsReportList ( )
{
var dayBetween = $@"> '{DateTime.Today.AddDays(-45):yyyy-MM-dd}'" ;
// var dayBetween = $@"BETWEEN '{DateTime.Today:yyyy-MM-dd}' AND '{DateTime.Today.AddDays(1):yyyy-MM-dd}'";
var reportList = DAOHelp . GetDataBySQL < ReportPacs > ( $ @ "
SELECT A . PatientCode , A . ExamFeeitem_Code , A . AccessionNumber
FROM PACS . DICOMSERVER . DBO . PEIS_PacsResult A
where A . ExamDatetime IS NOT NULL and a . ExamDatetime { dayBetween }
AND EXISTS ( SELECT 1 FROM PACS . DICOMSERVER . DBO . ImgForReport WHERE AccessionNumber = A . AccessionNumber )
AND NOT EXISTS ( SELECT 1 FROM Exam_PacsImage WHERE EID = A . PatientCode AND ReportNo = A . ExamFeeitem_Code )
");
Console . WriteLine ( $"【待同步的PACS报告】{dayBetween}至今,{reportList.Count}" ) ;
return reportList ;
}
public static List < string > GetReportUidList ( string reportAccessionNumber )
{
// 已选图片UID
var selectedList = DAOHelp . GetDataBySQL < ReportPacs >
( $@"SELECT SopInstanceUID FROM PACS.DICOMSERVER.DBO.ImgForReport WHERE AccessionNumber='{reportAccessionNumber}'" )
. Select ( s = > s . SopInstanceUID ) . ToList ( ) ;
return selectedList ;
}
public static string GetPacsImageFile ( string reportPatientCode , string reportExamFeeitemCode )
{
return DAOHelp . GetDataBySQL < ReportPacs >
( $@"SELECT ImageFile FROM PACS.DICOMSERVER.DBO.PEIS_PacsResult WHERE PatientCode='{reportPatientCode}' and ExamFeeitem_Code='{reportExamFeeitemCode}'" )
? . FirstOrDefault ( ) ? . ImageFile ;
}
}
}