pydicom / pynetdicom

A Python implementation of the DICOM networking protocol
https://pydicom.github.io/pynetdicom
MIT License
500 stars 176 forks source link

[Help needed] - How a SCP can return a .dcm file data? #949

Closed victornassif closed 1 month ago

victornassif commented 1 month ago

Hi! I'm starting with pynetdicom (hopefully, this is a very basic question), but I couldn't find anything about it in the documentation.

I was already able to set up an SCP server and handle C-FIND events from a PACS. Now, I'm trying to figure out how to add all the data the PACS needs to my Dataset. Is it a manual process? Should I manually add all the properties I have available in my .dcm file? Or do we have something like a "return file"?

Please let me know if this is too abstract! Thanks for the attention.

victornassif commented 1 month ago

actually I found a way to do it dinamically:

    identifier = Dataset()
    for tag in instance.keys():
        element = instance.get(tag)
        try:
            if not element.is_private:
                identifier.add_new(element.tag, element.VR,element.value)
        except Exception as e:
            print(e)
scaramallion commented 1 month ago

You can do it this way, but it's not going to be very efficient. That might be OK for you, depending on how many instances you're expecting to manage.

If you have a lot of instances you might consider switching to storing the relevant dataset values in a database instead.

victornassif commented 1 month ago

Thank you for the suggestion! Do you have a "base" about what would be the most used dataset values/more relevant for most cases?

scaramallion commented 1 month ago

You need to check the DICOM Standard. There are different required query keys you must support for a given query level/root (see here for example).