skin dose map code throws an error if there are no irradiation events

Issue #642 resolved
David Platten
created an issue
[2018-07-18 15:30:16,742: ERROR/MainProcess] Task[090f0149-baa9-42aa-8389-2dddf0b6e140] raised unexpected: IndexError('list index out of range',)
Traceback (most recent call last):
  File "d:\server_apps\python27\lib\site-packages\celery\app\", line 368, in trace_task
    R = retval = fun(*args, **kwargs)
  File "d:\server_apps\python27\lib\site-packages\celery\app\", line 623, in __protected_call__
    return*args, **kwargs)
  File "D:\Server_Apps\python27\Lib\site-packages\openrem\remapp\tools\", line 91, in make_skin_map
  File "d:\server_apps\python27\lib\site-packages\django\db\models\", line 201, in __getitem__
    return list(qs)[0]
IndexError: list index out of range

This is a result of the following code in (the first line after the try causes the error):

            ptr_meaning = study.projectionxrayradiationdose_set.get().irradeventxraydata_set.all()[
            if ptr_meaning in u"headfirst":
                ptr = u"H"
            elif ptr_meaning in u"feet-first":
                ptr = u"F"
      "Study PK {0}: Patient table relationship not recognised ({1}). "
                            u"Assuming head first.".format(study_pk, ptr_meaning))
        except AttributeError:
  "Study PK {0}: Patient table relationship not found. Assuming head first.".format(study_pk))

There needs to be an additional except clause for index errors.

Comments (5)

  1. Log in to comment