DICOM series query fails if returned Series Number is empty string

Issue #708 resolved
created an issue

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
  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
  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
  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: ''


[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:
(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, 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, Series No. , Series description None

Replacing the following in _query_series in qrscu

            seriesrsp.series_number = series[1].SeriesNumber
        except AttributeError:
            seriesrsp.series_number = None  # integer so can't be ''


            if int(series[1].SeriesNumber) > 0:
                seriesrsp.series_number = series[1].SeriesNumber
                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)

  1. Rob Ireland

    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

  2. Ed McDonagh

    Hi @Rob Ireland - 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 to DEBUG and show us that too.

  3. Log in to comment