DICOM series query fails if returned Series Number is empty string
If the returned Series Number is empty, the following error will follow: <celery-log>:
[2018-12-14 13:05:20,335: ERROR/MainProcess] Task remapp.netdicom.qrscu.qrscu[27eacc68-ccc5-4f96-8ef4-e6bfaeec79ab] raised unexpected: ValueError("invalid literal for int() with base 10: ''",) Traceback (most recent call last): File "c:\program files\python27\lib\site-packages\celery\app\trace.py", line 240, in trace_task R = retval = fun(*args, **kwargs) File "c:\program files\python27\lib\site-packages\celery\app\trace.py", line 438, in __protected_call__ return self.run(*args, **kwargs) File "c:\program files\python27\lib\site-packages\openrem\remapp\netdicom\qrscu.py", line 913, in qrscu _query_series(assoc, d2, rsp, query_id) File "c:\program files\python27\lib\site-packages\openrem\remapp\netdicom\qrscu.py", line 567, in _query_series seriesrsp.save() File "c:\program files\python27\lib\site-packages\django\db\models\base.py", line 734, in save force_update=force_update, update_fields=update_fields) File "c:\program files\python27\lib\site-packages\django\db\models\base.py", line 762, in save_base updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields) File "c:\program files\python27\lib\site-packages\django\db\models\base.py", line 827, in _save_table forced_update) File "c:\program files\python27\lib\site-packages\django\db\models\base.py", line 877, in _do_update return filtered._update(values) > 0 File "c:\program files\python27\lib\site-packages\django\db\models\query.py", line 580, in _update return query.get_compiler(self.db).execute_sql(CURSOR) File "c:\program files\python27\lib\site-packages\django\db\models\sql\compiler.py", line 1062, in execute_sql cursor = super(SQLUpdateCompiler, self).execute_sql(result_type) File "c:\program files\python27\lib\site-packages\django\db\models\sql\compiler.py", line 829, in execute_sql sql, params = self.as_sql() File "c:\program files\python27\lib\site-packages\django\db\models\sql\compiler.py", line 1030, in as_sql val = field.get_db_prep_save(val, connection=self.connection) File "c:\program files\python27\lib\site-packages\django\db\models\fields\__init__.py", line 710, in get_db_prep_save prepared=False) File "c:\program files\python27\lib\site-packages\django\db\models\fields\__init__.py", line 702, in get_db_prep_value value = self.get_prep_value(value) File "c:\program files\python27\lib\site-packages\django\db\models\fields\__init__.py", line 1869, in get_prep_value return int(value) ValueError: invalid literal for int() with base 10: ''
<qr-log>:
[14/Dec/2018 13:01:42] DEBUG [remapp.netdicom.qrscu:528] a4ba9847-a491-4978-adb7-1d618d2c426f series query is (0008, 0005) Specific Character Set CS: '' (0008, 0031) Series Time TM: '' (0008, 0052) Query/Retrieve Level CS: 'SERIES' (0008, 0060) Modality CS: '' (0008, 1010) Station Name SH: '' (0008, 103e) Series Description LO: '' (0020, 000d) Study Instance UID UI: 1.2.3.4. (0020, 000e) Series Instance UID UI: (0020, 0011) Series Number IS: '' (0020, 1209) Number of Series Related Instances IS: '' [14/Dec/2018 13:01:42] DEBUG [remapp.netdicom.qrscu:566] a4ba9847-a491-4978-adb7-1d618d2c426f Series Response 1: Modality CT, StationName rdcttosct21, StudyUID 1.2.3.4., Series No. 8, Series description neck 3.000 ce [14/Dec/2018 13:01:42] DEBUG [remapp.netdicom.qrscu:566] a4ba9847-a491-4978-adb7-1d618d2c426f Series Response 2: Modality CC, StationName rdcttosct21, StudyUID 1.2.3.4., Series No. , Series description None
Replacing the following in _query_series in qrscu
try: seriesrsp.series_number = series[1].SeriesNumber except AttributeError: seriesrsp.series_number = None # integer so can't be ''
with
try: if int(series[1].SeriesNumber) > 0: seriesrsp.series_number = series[1].SeriesNumber else: seriesrsp.series_number = None except ValueError: Reriesrsp.series_number = None # integer so can't be ''
Solves the issue. Is seems an empty string doesn't trigger the AttributeError.
Comments (8)
-
reporter -
@LuukO what do you think of this revision? Refs
#708→ <<cset 4d93273996a9>>
-
Updated changes files - corrected issue number and moved into 0.9.0b3 section anticipating this being renamed to 0.9.0 at some point soon [skip ci]. References issue
#708→ <<cset 907c09337688>>
-
Fixing merge conflicts. References issue
#708→ <<cset 9c1192f966f4>>
-
Merged in Issue708DICOMQRSeriesNumber (pull request #262)
Refs Issue
#708Approved-by: Ed McDonagh ed@mcdonagh.org.uk Approved-by: David Platten dplatten@gmail.com Approved-by: David.Platten@ULH.nhs.uk david.platten@ulh.nhs.uk
Fixes issue
#708→ <<cset 974071ec5eb9>>
-
- changed status to resolved
Merged in Issue708DICOMQRSeriesNumber (pull request #262)
Refs Issue
#708Approved-by: Ed McDonagh ed@mcdonagh.org.uk Approved-by: David Platten dplatten@gmail.com Approved-by: David.Platten@ULH.nhs.uk david.platten@ulh.nhs.uk
Fixes issue
#708→ <<cset 974071ec5eb9>>
-
I am new to OpenREM and have installed version 0.9.0. When I attempt to QR our PACS I get the invalid literal for int() with base 10: '' message similar to that shown in the above thread. Thanks for your help, Rob Ireland, Royal Cornwall Hospital, Truro
-
Hi @robi999 - welcome to OpenREM!
Sorry you have hit an issue so early on. The issue referred to here was fixed, so I expect your error has occurred in a different part of the code.
Would you be able to open a new issue and post the traceback from the Celery log as per the first post here, and the QR log too?
If the error is reproducible, it would also be really useful to set the
remapp.netdicom.qrscu
log level toDEBUG
and show us that too. - Log in to comment
Refs Issue
#708Fixed issue with empty Series Number.
→ <<cset 03972d3e6fbf>>