diff --git a/netforce_clinic/models/sickbed.py b/netforce_clinic/models/sickbed.py index 64f80c6..693c414 100644 --- a/netforce_clinic/models/sickbed.py +++ b/netforce_clinic/models/sickbed.py @@ -14,7 +14,8 @@ class SickBed(Model): image=None date='' set_active_user(1) #FIXME permission denined because of department of patient - for hd_case in sorted(obj.hd_cases, key=lambda a: a.id): + if obj.hd_cases: + hd_case=sorted(obj.hd_cases, key=lambda a: a.id)[-1] patient=hd_case.patient_id patient_id=patient.id image=patient.image