I am developing a system which is able to create structured report for a PACS. Obviously in order to create a DICOM file (containing Report data), I need three UIDs for Study, Series and file. StudyUID and SeriesUID must be the same as the study and series that report is created for it, but for SOPInstanceUID I need to generate a UID.
I have seen a method in Pixelmed documentation (getNewSOPInstanceUID), but I am not familiar with the Pixelmed source. I need an algorithm or Python source.
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.
Pay attention that you have 64 bytes (that's plenty already, see here) for storage in Value Representation UI:
\0(0 binary) if needed.
Finally since you are using python, use uuid lib python-uuid.