FNNDSC / pypx

Python wrapper to interact with a PACS (based off DCMTK and PyDicom)
90 stars 25 forks source link

Impossible to pass numerical value for query #4

Closed alexattia closed 5 years ago

alexattia commented 5 years ago

Hello,
I am trying pypx and I am facing some errors.
Indeed, via command line it works fine (it returns a long list):

px-find --aet MYNAME --aec DCM4CHEE --serverIP SERVERIP --serverPort 11112 --patientID 1240084

But, when I try it via the module

pacs_settings = {
  'executable': '/usr/local/bin/echoscu',
  'aec': 'DCM4CHEE',
  'aet': 'MYNAME',
  'server_ip': 'SERVERIP',
  'server_port': '11112',
}
query_settings = {
    'PatientID': 1240084,
 }

output = pypx.find({**pacs_settings, **query_settings})

I have the error :

~/Desktop/Work/workenv/lib/python3.6/site-packages/pypx/find.py in query(self, opt)
     51             # update query
     52             if value != '':
---> 53                 query += ' -k "' + key + '=' + value + '"'
     54             else:
     55                 query += ' -k ' + key

TypeError: must be str, not int

And when, I change the PatientId value to string, it returns an empty list.

Thank you in advance,

NicolasRannou commented 5 years ago

Hi @alexattia ,

Try to put quotes around the patient ID "number" in the query settings. (see error returned: TypeError: must be str, not int)


query_settings = {
    'PatientID': '1240084',
 }
`
alexattia commented 5 years ago

I did it and it returns an empty list. When I check server-side, on the PACS logs, nothing was computed. Although, when I run px-find with the command line, the logs aren't empty.

alexattia commented 5 years ago

My bad. I forgot to change the pacs_settings from px-echo, it should be :

pacs_settings = {
  'executable': '/usr/local/bin/findscu',
  'aec': 'DCM4CHEE',
  'aet': 'MYNAME',
  'server_ip': 'SERVERIP',
  'server_port': '11112',
}