def handle(self, *args, **options): asof = datetime.utcnow().date() cases = get_open_lost_cases(asof) for case in cases: assert(not case.closed and case.ltfu_date < asof) close_as_lost(case) case.patient.update_cases([case]) case.patient.save()
def close_ltfu_cases(sender, patient_id, **kwargs): """ Checks if any open cases in the patient are passed the LTFU date and if they are closes them with status lost to followup. """ from bhoma.apps.patient.models import CPatient from bhoma.apps.case.bhomacaselogic.ltfu import close_as_lost patient = CPatient.get(patient_id) save_pat = False for case in patient.cases: today = datetime.utcnow().date() if not case.closed and case.ltfu_date and case.ltfu_date < today: close_as_lost(case) save_pat = True if save_pat: patient.save()