I am developing a system which will be able to create structured report for PACS.
Obviously in order to create a DICOM instance (file containing Report data), I need three UIDs for Study, Series and Instance. StudyUID and SeriesUID must be the same as that of study and series that report is created for. But for SOPInstanceUID, I need to generate new UID.
I have seen getNewSOPInstanceUID
method in Pixelmed documentation, but I am not familiar with the Pixelmed source. I need an algorithm or Python source.
Advertisement
Answer
I would really suggest you go away from implementing it yourself. Most language do provide a UUID library these days, do not reinvent the wheel. Esp. if you are going to write code to extract MAC adress, this can be very complex writing it in portable C.
UUID do not exactly fit the DICOM definition, so you need to register your own Organisation Root UID, then simply pad with a generated UUID which bring spatial and time uniqueness condition.
YOUR_ORG_ROOT.CONVERTED_UUID
Pay attention that you have 64 bytes (that’s plenty already, see here) for storage in Value Representation UI:
- Convert Hexadecimal notation of UUID to VR: UI definition
([0-9.]+)
- Trim with extreme care (you may introduce redundancy during this operation)
- Choose a short
Org Root
- Pad with
(0 binary) if needed.
Finally since you are using python, use uuid lib python-uuid.
The above should be considered an alternate implementation to what is officially defined in the standard:
When converting directly a UUID to a UID, one must use the “2.25.” root.