Python Script to Create MWL files from JSON - sample and notes

366 views
Skip to first unread message

Stephen Douglas Scotti

unread,
Aug 19, 2021, 6:42:31 PM8/19/21
to Orthanc Users
I've been working on this for awhile and have it partially integrated with our system now as an Orthanc Python Plug-in.  I pulled out the essential parts of that in regards to creating an MWL from JSON and made it into a free-standing python script that can be easily plugged into an Orthanc Python Script.  It can also just be run from the CLI, which is really convenient for development purposes.

I left part of that in there, and there is more that allows for storing into a database, etc. that I can provide later if there is interest.  This is just sort of a free-standing demo.  I have attached the script as a file.

Basically, what it does is take a JSON description of a MWL file and creates the DICOM version and writes it to a MWL folder on the file system, although optionally really easy to also store in a database with some other columns to index on.

To run the script from the CLI:

1.  python3 json_to_mwl.py (however change WORKLIST_DIR = to the absolute path where you want to save the file on your system)

2.  There is a sample JSON description already in there, and still working on that to abstract it a bit, and some tags are a little different, like PregnancyStatus.  You can play around with the tags there is see what works and what does not.

3.  After running the script you should see a file in your MWL named 'DEVACC00000077.wl' because the accession number for the sample.  You can adjust to whatever you want to use really.

4.  To verify, you could do:
      - dcmdump path/to/file and it will spit out a dcmdump in dicom format.
      -  Dave Clunie has a set of tools also that are helpful to check the file here:  DICOM Tools

I'm actually very motivated to develop of full package for MWL's, but haven't learned C++ yet and Python only about 6 months ago.  Getting easier to code with Python.

json_to_mwl.py

Stephen Douglas Scotti

unread,
Aug 20, 2021, 6:43:17 PM8/20/21
to Orthanc Users
I put it on a repo on Github:  https://github.com/sscotti/python_script_library

Reply all
Reply to author
Forward
0 new messages