I am trying to code a simple DICOM MWL Worklist SCP using pynetdicom. There is no example provided from the documentation besides saying its the same as C-FIND.
Below code only sends the status SUCCESS but the dataset/patient don't appear from list on testing MWL SCU. I am using miele-wl-scu to simulate modality to query the Worklist.
import pydicom
from pydicom.dataset import Dataset
from pydicom.uid import UID
from pynetdicom import AE, evt, debug_logger
from pynetdicom.sop_class import ModalityWorklistInformationFind
debug_logger()
def on_c_find(dataset, context= None, info= None):
"""Handle a C-FIND request event."""
# Check if ScheduledProcedureStepSequence exists
# Create the response dataset
identifier = Dataset()
identifier.PatientName = 'Hahah'
identifier.AccessionNumber = 'asa'
identifier.RequestedProcedureDescription = 'asa'
identifier.is_little_endian = True
identifier.is_implicit_VR = True
# Yield the response dataset
yield (0x0000, identifier) # Success
def main():
ae = AE()
# Add supported presentation contexts
ae.add_supported_context(ModalityWorklistInformationFind) # C FIND
ae.add_supported_context(UID('1.2.840.10008.1.1')) # ECHO
# Set callback functions
handlers = [(evt.EVT_C_FIND, on_c_find)]
print("Starting DICOM Worklist Server...")
# Start the DICOM server
ae.start_server(('localhost', 11112), evt_handlers=handlers)
if __name__ == "__main__":
main()
I never used the toolkit but I think following line of code is the problem:
The
0x0000isSUCCESSwhich should be sent at the end without any dataset (identifierin your case) attached to it. Before that, with each dataset, your status should be0xFF00which isPENDING.I am not aware about the syntax of programming language in question; correct me if I am wrong. Your code MAY be something like below:
Please refer to this answer for more details. Following is the quote: