patmun / pynetdicom_legacy

This project is deprecated and no longer maintained. Please switch to https://github.com/pydicom/pynetdicom3
Other
30 stars 25 forks source link

Assumes AffectedSOPClass is returned in C-ECHO-RSP #65

Open gilbahat opened 7 years ago

gilbahat commented 7 years ago

Hi,

pynetdicom assumes that AffectedSOPClass is returned in a C-ECHO-RSP. However, it seems that at least mirth does not return AffectedSOPClass in its response, making pynetdicom unable to properly ping mirth, throwing the following trace:

File "pinger.py", line 38, in st = assoc.VerificationSOPClass.SCU(1) File "/usr/local/lib/python2.7/site-packages/netdicom/SOPclass.py", line 60, in SCU ans, id = self.DIMSE.Receive(Wait=True) File "/usr/local/lib/python2.7/site-packages/netdicom/DIMSEprovider.py", line 75, in Receive return tmp.ToParams(), tmp.ID File "/usr/local/lib/python2.7/site-packages/netdicom/DIMSEmessages.py", line 248, in ToParams tmp.AffectedSOPClassUID = self.CommandSet[(0x0000,0x0002)] File "/usr/local/lib/python2.7/site-packages/pydicom-0.9.9-py2.7.egg/dicom/dataset.py", line 277, in getitem data_elem = dict.getitem(self, tag) KeyError: (0000, 0002)

the quick fix is to change AffectedSOPClassUID to optional, in DIMSEmessages.py line 247:

    if self.CommandSet.has_key((0x0000,0x0002)):
        tmp.AffectedSOPClassUID = self.CommandSet[(0x0000,0x0002)]

I will file a bug with Mirth in parallel, but I believe pynetdicom should be more lenient.

gilbahat commented 7 years ago

Looks like this is affecting more SOP classes and more keys like AffectedSOPInstanceUID. This had better be a more generic thing rather than just those classes.