|
@@ -52,32 +52,60 @@ namespace Worklist_SCP.Model
|
|
|
|
|
|
public static IEnumerable<DicomDataset> FilterWorklistItems(DicomDataset request)
|
|
|
{
|
|
|
- var patientName = request.GetSingleValueOrDefault(DicomTag.PatientName, string.Empty);
|
|
|
- var PatientID = request.GetSingleValueOrDefault(DicomTag.PatientID, string.Empty);
|
|
|
+ var NAME_PHONETIC = request.GetSingleValueOrDefault(DicomTag.PatientName, string.Empty);
|
|
|
+ var PATIENT_ID = request.GetSingleValueOrDefault(DicomTag.PatientID, string.Empty);
|
|
|
+ var PATIENT_SEX = request.GetSingleValueOrDefault(DicomTag.PatientSex, string.Empty);
|
|
|
+ var MODALITY = request.GetSingleValueOrDefault(DicomTag.Modality, WorklistServer.modality);
|
|
|
+ var PATIENT_LOCAL_ID = request.GetSingleValueOrDefault(DicomTag.AccessionNumber, string.Empty);
|
|
|
+
|
|
|
+ var ScheduledProcedureStepStartDate = request.GetSingleValueOrDefault(DicomTag.ScheduledProcedureStepStartDate, string.Empty);
|
|
|
+ var ScheduledProcedureStepEndDate = request.GetSingleValueOrDefault(DicomTag.PerformedProcedureStepEndDate, string.Empty);
|
|
|
+
|
|
|
var api = ConfigurationManager.AppSettings["API"];
|
|
|
- var AETitleConfig = ConfigurationManager.AppSettings["AETitle"];
|
|
|
- var CallingAEConfig = ConfigurationManager.AppSettings["CallingAE"];
|
|
|
- var ModalityConfig = ConfigurationManager.AppSettings["Modality"];
|
|
|
- var paramStr = $"patientName={patientName}&PatientID={PatientID}";
|
|
|
+ var AE_TITLE = WorklistServer.AETitle;
|
|
|
+
|
|
|
+ var sps = request.Get<DicomSequence>(DicomTag.ScheduledProcedureStepSequence);
|
|
|
+ foreach (var item in sps) {
|
|
|
+ MODALITY = item.GetSingleValueOrDefault<string>(DicomTag.Modality, MODALITY);
|
|
|
+ ScheduledProcedureStepStartDate = item.GetSingleValueOrDefault<string>(DicomTag.ScheduledProcedureStepStartDate, ScheduledProcedureStepStartDate);
|
|
|
+ ScheduledProcedureStepEndDate = item.GetSingleValueOrDefault<string>(DicomTag.ScheduledProcedureStepEndDate, ScheduledProcedureStepEndDate);
|
|
|
+ }
|
|
|
+
|
|
|
+ string[] StepDateArray = FormatStepDate(AE_TITLE, ScheduledProcedureStepStartDate,ScheduledProcedureStepEndDate);
|
|
|
+ ScheduledProcedureStepStartDate = StepDateArray[0];
|
|
|
+ ScheduledProcedureStepEndDate = StepDateArray[1];
|
|
|
+
|
|
|
+ // var CallingAEConfig = ConfigurationManager.AppSettings["CallingAE"];
|
|
|
+
|
|
|
+
|
|
|
+ var paramStr = $"AE_TITLE={AE_TITLE}" +
|
|
|
+ $"&PATIENT_LOCAL_ID={PATIENT_LOCAL_ID}" +
|
|
|
+ $"&PATIENT_ID={PATIENT_ID}" +
|
|
|
+ $"&NAME_PHONETIC={NAME_PHONETIC}" +
|
|
|
+ $"&PATIENT_SEX={PATIENT_SEX}" +
|
|
|
+ $"&MODALITY={MODALITY}" +
|
|
|
+ $"&ScheduledProcedureStepStartDate={ScheduledProcedureStepStartDate}" +
|
|
|
+ $"&ScheduledProcedureStepEndDate={ScheduledProcedureStepEndDate}";
|
|
|
DicomDataset procedureStep = null;
|
|
|
|
|
|
- if (request.Contains(DicomTag.ScheduledProcedureStepSequence))
|
|
|
- {
|
|
|
- procedureStep = request.GetSequence(DicomTag.ScheduledProcedureStepSequence).First();
|
|
|
- var scheduledStationAET = procedureStep.GetSingleValueOrDefault(DicomTag.ScheduledStationAETitle, string.Empty);
|
|
|
- var performingPhysician = procedureStep.GetSingleValueOrDefault(DicomTag.PerformingPhysicianName, string.Empty);
|
|
|
- var modality = procedureStep.GetSingleValueOrDefault(DicomTag.Modality, string.Empty);
|
|
|
- var scheduledProcedureStepStartDateTime = procedureStep.GetSingleValueOrDefault(DicomTag.ScheduledProcedureStepStartDateTime, string.Empty);
|
|
|
- var procedureStepLocation = procedureStep.GetSingleValueOrDefault(DicomTag.ScheduledProcedureStepLocation, string.Empty);
|
|
|
- var procedureDescription = procedureStep.GetSingleValueOrDefault(DicomTag.ScheduledProcedureStepDescription, string.Empty);
|
|
|
- paramStr = $"AETitleConfig={AETitleConfig}&CallingAEConfig={CallingAEConfig}&ModalityConfig={ModalityConfig}&patientName={patientName}&PatientID={PatientID}&scheduledStationAET={scheduledStationAET}&performingPhysician={performingPhysician}&modality={modality}&scheduledProcedureStepStartDateTime={scheduledProcedureStepStartDateTime}&procedureStepLocation={procedureStepLocation}&procedureDescription={procedureDescription}";
|
|
|
- }
|
|
|
+ // if (request.Contains(DicomTag.ScheduledProcedureStepSequence))
|
|
|
+ // {
|
|
|
+ // procedureStep = request.GetSequence(DicomTag.ScheduledProcedureStepSequence).First();
|
|
|
+ // var scheduledStationAET = procedureStep.GetSingleValueOrDefault(DicomTag.ScheduledStationAETitle, string.Empty);
|
|
|
+ // var performingPhysician = procedureStep.GetSingleValueOrDefault(DicomTag.PerformingPhysicianName, string.Empty);
|
|
|
+ // var modality = procedureStep.GetSingleValueOrDefault(DicomTag.Modality, string.Empty);
|
|
|
+ // var scheduledProcedureStepStartDateTime = procedureStep.GetSingleValueOrDefault(DicomTag.ScheduledProcedureStepStartDateTime, string.Empty);
|
|
|
+ // var procedureStepLocation = procedureStep.GetSingleValueOrDefault(DicomTag.ScheduledProcedureStepLocation, string.Empty);
|
|
|
+ // var procedureDescription = procedureStep.GetSingleValueOrDefault(DicomTag.ScheduledProcedureStepDescription, string.Empty);
|
|
|
+ // paramStr = $"AETitleConfig={AETitleConfig}&CallingAEConfig={CallingAEConfig}&ModalityConfig={ModalityConfig}&patientName={patientName}&PatientID={PatientID}&scheduledStationAET={scheduledStationAET}&performingPhysician={performingPhysician}&modality={modality}&scheduledProcedureStepStartDateTime={scheduledProcedureStepStartDateTime}&procedureStepLocation={procedureStepLocation}&procedureDescription={procedureDescription}";
|
|
|
+ // }
|
|
|
+ //
|
|
|
Console.Write($"Http request url: {api} paramStr: {paramStr}");
|
|
|
string str = HttpPost(api, paramStr);
|
|
|
Console.Write($"HttpPost results: {str}");
|
|
|
|
|
|
- List<WorklistItem> exams = new List<WorklistItem>();
|
|
|
- exams = JsonConvert.DeserializeObject<List<WorklistItem>>(str);
|
|
|
+ List<PeisWorklistItem> exams = new List<PeisWorklistItem>();
|
|
|
+ exams = JsonConvert.DeserializeObject<List<PeisWorklistItem>>(str);
|
|
|
//List<WorklistItem> thislist = new List<WorklistItem>();
|
|
|
//thislist = JavaScriptConvert.DeserializeObject<List<WorklistItem>>(str);
|
|
|
//string connstr = "data source=127.0.0.1;database=wq_db;user id=wq;password=Wq@2020~!@#;pooling=false;charset=utf8";//pooling代表是否使用连接池
|
|
@@ -158,46 +186,60 @@ namespace Worklist_SCP.Model
|
|
|
var resultingSPS = new DicomDataset();
|
|
|
var resultDataset = new DicomDataset();
|
|
|
var resultingSPSSequence = new DicomSequence(DicomTag.ScheduledProcedureStepSequence, resultingSPS);
|
|
|
-
|
|
|
- if (procedureStep != null)
|
|
|
- {
|
|
|
- resultDataset.Add(resultingSPSSequence);
|
|
|
+
|
|
|
+ // DicomDataset dds = new DicomDataset();
|
|
|
+ string EXAM_NO = result.EXAM_NO.ToString();
|
|
|
+ string PatientID = result.PATIENT_ID.ToString();
|
|
|
+ string AccessionNb = result.PATIENT_LOCAL_ID.ToString();
|
|
|
+ string StudyUid = result.STUDY_INSTANCE_UID.ToString();
|
|
|
+ string PinyinName = result.NAME_PHONETIC.ToString();
|
|
|
+ string HanziName = result.PATIENT_NAME.ToString();
|
|
|
+ string PatientAge = result.PATIENT_AGE.ToString();
|
|
|
+ string PatientSex = result.PATIENT_SEX.ToString();
|
|
|
+ string Patient_Weight = result.Patient_Weight.ToString();
|
|
|
+ DateTime birthDate = DateTime.ParseExact(result.DATE_OF_BIRTH.ToString(), "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);//生日需要date格式时间 dds.Add(DicomTag.PatientBirthDate, row["DATE_OF_BIRTH"].ToString());
|
|
|
+ //
|
|
|
+ PatientSex = FormatSex(PatientSex);
|
|
|
+ PatientAge = FormatAge(PatientAge);
|
|
|
+ //
|
|
|
+ // if (string.IsNullOrEmpty(PinyinName)) {
|
|
|
+ // PinyinName = HanziToPinyin(HanziName);
|
|
|
+ // }
|
|
|
+ if (string.IsNullOrEmpty(AccessionNb)) {
|
|
|
+ AccessionNb = EXAM_NO;
|
|
|
+ }
|
|
|
+ if (string.IsNullOrEmpty(StudyUid)) {
|
|
|
+ StudyUid = "1.3.6.1.4.1.30071.8." + PatientID + "." + EXAM_NO;
|
|
|
+ }
|
|
|
+ AddIfExistsInRequest(resultDataset, request, DicomTag.ScheduledStationAETitle, "CFINDSCP"); // 西门子需要设置aetitle
|
|
|
+ AddIfExistsInRequest(resultDataset, request, DicomTag.AccessionNumber, AccessionNb);
|
|
|
+ AddIfExistsInRequest(resultDataset, request, DicomTag.PatientID, PatientID);
|
|
|
+ AddIfExistsInRequest(resultDataset, request, DicomTag.PatientSex, PatientSex);
|
|
|
+ AddIfExistsInRequest(resultDataset, request, DicomTag.PatientAge, PatientAge);
|
|
|
+ AddIfExistsInRequest(resultDataset, request, DicomTag.PatientName, PinyinName);
|
|
|
+ AddIfExistsInRequest(resultDataset, request, DicomTag.StudyInstanceUID, StudyUid);
|
|
|
+ AddIfExistsInRequest(resultDataset, request, DicomTag.StudyInstanceUID, StudyUid);
|
|
|
+ if (!string.IsNullOrEmpty(Patient_Weight)) {
|
|
|
+ AddIfExistsInRequest(resultDataset, request, DicomTag.PatientWeight, Patient_Weight);
|
|
|
}
|
|
|
-
|
|
|
- // add results to "main" dataset
|
|
|
- AddIfExistsInRequest(resultDataset, request, DicomTag.AccessionNumber, result.AccessionNumber); // T2
|
|
|
- AddIfExistsInRequest(resultDataset, request, DicomTag.InstitutionName, result.HospitalName);
|
|
|
- AddIfExistsInRequest(resultDataset, request, DicomTag.ReferringPhysicianName, result.ReferringPhysician); // T2
|
|
|
-
|
|
|
- AddIfExistsInRequest(resultDataset, request, DicomTag.PatientName, result.Surname + "^" + result.Forename + "^^" + result.Title); //T1
|
|
|
- AddIfExistsInRequest(resultDataset, request, DicomTag.PatientID, result.PatientID); // T1
|
|
|
- AddIfExistsInRequest(resultDataset, request, DicomTag.PatientBirthDate, result.DateOfBirth); // T2
|
|
|
- AddIfExistsInRequest(resultDataset, request, DicomTag.PatientSex, result.Sex); //T2
|
|
|
-
|
|
|
- AddIfExistsInRequest(resultDataset, request, DicomTag.StudyInstanceUID, result.StudyUID); // T1
|
|
|
-
|
|
|
- AddIfExistsInRequest(resultDataset, request, DicomTag.RequestingPhysician, result.ReferringPhysician); //T2
|
|
|
- AddIfExistsInRequest(resultDataset, request, DicomTag.RequestedProcedureDescription, result.ExamDescription); //T1C
|
|
|
-
|
|
|
- AddIfExistsInRequest(resultDataset, request, DicomTag.RequestedProcedureID, result.ProcedureID); // T1
|
|
|
-
|
|
|
- // Scheduled Procedure Step sequence T1
|
|
|
- // add results to procedure step dataset
|
|
|
- // Return if requested
|
|
|
- if (procedureStep != null)
|
|
|
+ else
|
|
|
{
|
|
|
- AddIfExistsInRequest(resultingSPS, procedureStep, DicomTag.ScheduledStationAETitle, result.ScheduledAET); // T1
|
|
|
- AddIfExistsInRequest(resultingSPS, procedureStep, DicomTag.ScheduledProcedureStepStartDate, result.ExamDateAndTime); //T1
|
|
|
- AddIfExistsInRequest(resultingSPS, procedureStep, DicomTag.ScheduledProcedureStepStartTime, result.ExamDateAndTime); //T1
|
|
|
- AddIfExistsInRequest(resultingSPS, procedureStep, DicomTag.Modality, result.Modality); // T1
|
|
|
-
|
|
|
- AddIfExistsInRequest(resultingSPS, procedureStep, DicomTag.ScheduledPerformingPhysicianName, result.PerformingPhysician); //T2
|
|
|
- AddIfExistsInRequest(resultingSPS, procedureStep, DicomTag.ScheduledProcedureStepDescription, result.ExamDescription); // T1C
|
|
|
- AddIfExistsInRequest(resultingSPS, procedureStep, DicomTag.ScheduledProcedureStepID, result.ProcedureStepID); // T1
|
|
|
- AddIfExistsInRequest(resultingSPS, procedureStep, DicomTag.ScheduledStationName, result.ExamRoom); //T2
|
|
|
- AddIfExistsInRequest(resultingSPS, procedureStep, DicomTag.ScheduledProcedureStepLocation, result.ExamRoom); //T2
|
|
|
+ AddIfExistsInRequest(resultDataset, request, DicomTag.PatientWeight, "");
|
|
|
}
|
|
|
-
|
|
|
+ DicomDataset backSR = new DicomDataset();
|
|
|
+ backSR.Add(DicomTag.AccessionNumber, AccessionNb);
|
|
|
+ backSR.Add(DicomTag.ScheduledStationAETitle, "CFINDSCP");
|
|
|
+ resultDataset.Add(DicomTag.ReferencedStudySequence, backSR);
|
|
|
+ DicomDataset backsps = new DicomDataset();
|
|
|
+ // backsps.Add(DicomTag.RequestedProcedureDescription, result.REQ_MEMO.ToString());
|
|
|
+ DateTime spsStartDate = result.SCHEDULED_DATE_TIME;
|
|
|
+ backsps.Add(DicomTag.ScheduledProcedureStepStartDate, spsStartDate);
|
|
|
+ //backsps.Add(DicomTag.ScheduledProcedureStepStartTime, "010203"); //胶囊胃镜需要传
|
|
|
+ backsps.Add(DicomTag.ScheduledProcedureStepEndTime, spsStartDate);
|
|
|
+ backsps.Add(DicomTag.Modality, MODALITY);
|
|
|
+ backsps.Add(DicomTag.ScheduledProcedureStepID, "8008" + result.EXAM_NO.ToString());
|
|
|
+ resultDataset.Add(DicomTag.ScheduledProcedureStepSequence, backsps);
|
|
|
+
|
|
|
// Put blanks in for unsupported fields which are type 2 (i.e. must have a value even if NULL)
|
|
|
// In a real server, you may wish to support some or all of these, but they are not commonly supported
|
|
|
AddIfExistsInRequest(resultDataset, request, DicomTag.ReferencedStudySequence, new DicomDataset()); // Ref//d Study Sequence
|
|
@@ -206,14 +248,85 @@ namespace Worklist_SCP.Model
|
|
|
AddIfExistsInRequest(resultDataset, request, DicomTag.AdmissionID, ""); // Admission ID
|
|
|
AddIfExistsInRequest(resultDataset, request, DicomTag.CurrentPatientLocation, ""); // Patient Location
|
|
|
AddIfExistsInRequest(resultDataset, request, DicomTag.ReferencedPatientSequence, new DicomDataset()); // Ref//d Patient Sequence
|
|
|
- AddIfExistsInRequest(resultDataset, request, DicomTag.PatientWeight, ""); // Weight
|
|
|
AddIfExistsInRequest(resultDataset, request, DicomTag.ConfidentialityConstraintOnPatientDataDescription, ""); // Confidentiality Constraint
|
|
|
+ // AddIfExistsInRequest(resultDataset, request, DicomTag.ScheduledProcedureStepID , "8008" + result.EXAM_NO.ToString()); // Confidentiality Constraint
|
|
|
+ // AddIfExistsInRequest(resultDataset, request, DicomTag.PerformedProcedureStepID , "8008" + result.EXAM_NO.ToString()); // Confidentiality Constraint
|
|
|
|
|
|
// Send Reponse Back
|
|
|
yield return resultDataset;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static string FormatSex(string sex)
|
|
|
+ {
|
|
|
+ // Console.WriteLine(sex);
|
|
|
+ string backsex = "O";
|
|
|
+ if (sex == "男")
|
|
|
+ backsex = "F";
|
|
|
+ if (sex == "女")
|
|
|
+ backsex = "M";
|
|
|
+ if (sex == "1")
|
|
|
+ backsex = "F";
|
|
|
+ if (sex == "2")
|
|
|
+ backsex = "M";
|
|
|
+ if (sex == "F")
|
|
|
+ backsex = "F";
|
|
|
+ if (sex == "M")
|
|
|
+ backsex = "M";
|
|
|
+ // Console.WriteLine(backsex);
|
|
|
+ return backsex;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ *格式年龄000Y
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public static string FormatAge(string age) {
|
|
|
+ int ageInt = int.Parse(age);
|
|
|
+ string prefix = "", suffix = "Y";
|
|
|
+ if(ageInt < 10) {
|
|
|
+ prefix = "00";
|
|
|
+ } else if(ageInt < 100) {
|
|
|
+ prefix = "0";
|
|
|
+ }
|
|
|
+ return prefix + ageInt.ToString() + suffix;
|
|
|
+ }
|
|
|
+ public static string[] FormatStepDate(string CallingAE,string start,string end) {
|
|
|
+ string[] stepDate = new string[2];
|
|
|
+ switch (CallingAE) {
|
|
|
+ case "CT106286":// 西门子16排设备
|
|
|
+ case "XIAFH":// 万登DR
|
|
|
+ case "DEXA":// 豪洛捷骨密度
|
|
|
+ if (string.IsNullOrEmpty(start)) {
|
|
|
+ stepDate[0] = "";
|
|
|
+ stepDate[1] = "";
|
|
|
+ } else {
|
|
|
+ string[] temp = start.Split('-');
|
|
|
+ if(temp == null || temp.Length < 1 || string.IsNullOrEmpty(temp[0])) {
|
|
|
+ stepDate[0] = "";
|
|
|
+ } else {
|
|
|
+ stepDate[0] = temp[0];
|
|
|
+ }
|
|
|
+ if(temp == null || temp.Length < 2 || string.IsNullOrEmpty(temp[1])) {
|
|
|
+ stepDate[1] = "";
|
|
|
+ } else {
|
|
|
+ stepDate[1] = temp[1];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ if (string.IsNullOrEmpty(start)) {
|
|
|
+ start = "";
|
|
|
+ }
|
|
|
+ if (string.IsNullOrEmpty(end)) {
|
|
|
+ end = "";
|
|
|
+ }
|
|
|
+ stepDate[0] = start;
|
|
|
+ stepDate[1] = end;
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+ return stepDate;
|
|
|
+ }
|
|
|
|
|
|
//Splits patient name into 2 separte strings surname and forename and send then to the addstringcondition subroutine.
|
|
|
internal static IQueryable<WorklistItem> AddNameCondition(IQueryable<WorklistItem> exams, string dicomName)
|