MWL python script

Happy to report that we finally got a MRI Scanner installed (delayed by COVID) to interface with the a dev RIS. I’m using a modified version of the Python Script that I posted on GitHub repo. It actually almost works out-of-the box with some issue yet regarding the StudyDescription tag not getting populated from the MWL, but it looks like I can use the StudyID tag, and then vendor should be able to help with the rest.

The RIS creates an order in the RIS database and then sends a HL7 message to the python script via the REST API. That creates a .txt file template for the .wl file and then creates the .wl using dcmtk. So, bottom line is that the .wl file is put in the WorkLists folder so that the scanner can query it.

The whole setup is running in Docker.

Example from the log:

T0422 20:01:11.002915 FindScp.cpp:215] (dicom) Received C-FIND Request:

Dicom-Data-Set

Used TransferSyntax: Little Endian Implicit

(0008,0050) SH (no value available) # 0, 0 AccessionNumber
(0008,0090) PN (no value available) # 0, 0 ReferringPhysicianName
(0008,1080) LO (no value available) # 0, 0 AdmittingDiagnosesDescription
(0008,1110) SQ (Sequence with explicit length #=0) # 0, 1 ReferencedStudySequence
(fffe,e0dd) na (SequenceDelimitationItem for re-encod.) # 0, 0 SequenceDelimitationItem
(0010,0010) PN (no value available) # 0, 0 PatientName
(0010,0020) LO (no value available) # 0, 0 PatientID
(0010,0030) DA (no value available) # 0, 0 PatientBirthDate
(0010,0040) CS (no value available) # 0, 0 PatientSex
(0010,1020) DS (no value available) # 0, 0 PatientSize
(0010,1030) DS (no value available) # 0, 0 PatientWeight
(0010,2180) SH (no value available) # 0, 0 Occupation
(0010,21b0) LT (no value available) # 0, 0 AdditionalPatientHistory
(0010,4000) LT (no value available) # 0, 0 PatientComments
(0020,000d) UI (no value available) # 0, 0 StudyInstanceUID
(0032,1060) LO (no value available) # 0, 0 RequestedProcedureDescription
(0032,1064) SQ (Sequence with explicit length #=0) # 0, 1 RequestedProcedureCodeSequence
(fffe,e0dd) na (SequenceDelimitationItem for re-encod.) # 0, 0 SequenceDelimitationItem
(0040,0100) SQ (Sequence with undefined length #=1) # u/l, 1 ScheduledProcedureStepSequence
(fffe,e000) na (Item with undefined length #=7) # u/l, 1 Item
(0008,0060) CS [MR] # 2, 1 Modality
(0040,0001) AE [NmrEsaote] # 10, 1 ScheduledStationAETitle
(0040,0002) DA [20210422-20210422] # 18, 1 ScheduledProcedureStepStartDate
(0040,0003) TM (no value available) # 0, 0 ScheduledProcedureStepStartTime
(0040,0007) LO (no value available) # 0, 0 ScheduledProcedureStepDescription
(0040,0008) SQ (Sequence with explicit length #=0) # 0, 1 ScheduledProtocolCodeSequence
(fffe,e0dd) na (SequenceDelimitationItem for re-encod.) # 0, 0 SequenceDelimitationItem
(0040,0009) SH (no value available) # 0, 0 ScheduledProcedureStepID
(fffe,e00d) na (ItemDelimitationItem) # 0, 0 ItemDelimitationItem
(fffe,e0dd) na (SequenceDelimitationItem) # 0, 0 SequenceDelimitationItem
(0040,1001) SH (no value available) # 0, 0 RequestedProcedureID

I0422 14:30:58.352145 PluginsManager.cpp:172] (plugins) Received worklist query from remote modality NmrEsaote:
{
“0008,0050” : “”,
“0008,0090” : “”,
“0008,1080” : “”,
“0008,1110” : [],
“0010,0010” : “”,
“0010,0020” : “”,
“0010,0030” : “”,
“0010,0040” : “”,
“0010,1020” : “”,
“0010,1030” : “”,
“0010,2180” : “”,
“0010,21b0” : “”,
“0010,4000” : “”,
“0020,000d” : “”,
“0032,1060” : “”,
“0032,1064” : [],
“0040,0100” : [
{
“0008,0060” : “MR”,
“0040,0001” : “NmrEsaote”,
“0040,0002” : “20210422-20210422”,
“0040,0003” : “”,
“0040,0007” : “”,
“0040,0008” : [],
“0040,0009” : “”
}
],
“0040,1001” : “”
}

T0422 20:01:11.009674 FindScp.cpp:326] (dicom) Sending C-FIND Response 1/8:

Dicom-Data-Set

Used TransferSyntax: Little Endian Explicit

(0008,0005) CS [ISO_IR 192] # 10, 1 SpecificCharacterSet
(0008,0050) SH [DEVACC00000008] # 14, 1 AccessionNumber
(0008,0090) PN [0002:.] # 30, 1 ReferringPhysicianName
(0010,0010) PN [Test^Patient 10^] # 16, 1 PatientName
(0010,0020) LO [DEV0000005] # 10, 1 PatientID
(0010,0030) DA [19621219] # 8, 1 PatientBirthDate
(0010,0040) CS [F] # 2, 1 PatientSex
(0010,21b0) LT [Hip pain] # 8, 1 AdditionalPatientHistory
(0020,000d) UI [1.3.6.1.4.1.56016.1.20210422100000] # 34, 1 StudyInstanceUID
(0040,0100) SQ (Sequence with explicit length #=1) # 0, 1 ScheduledProcedureStepSequence
(fffe,e000) na (Item with undefined length #=6) # u/l, 1 Item
(0008,0060) CS [MR] # 2, 1 Modality
(0040,0001) AE [NmrEsaote] # 10, 1 ScheduledStationAETitle
(0040,0002) DA [20210422] # 8, 1 ScheduledProcedureStepStartDate
(0040,0003) TM [100000] # 6, 1 ScheduledProcedureStepStartTime
(0040,0007) LO [MRI RIGHT HIP] # 14, 1 ScheduledProcedureStepDescription
(0040,0009) SH [0019] # 4, 1 ScheduledProcedureStepID
(fffe,e00d) na (ItemDelimitationItem) # 0, 0 ItemDelimitationItem
(fffe,e0dd) na (SequenceDelimitationItem for re-encod.) # 0, 0 SequenceDelimitationItem

Except for the issue with the StudyDescription things seem to be working. The .wl file actually has more info, but some of those tags are not being returned in the response. Can probably work that all out with the vendor.

I will tidy up the script and update after further testing.