'Actions after deleting appointments
- Update last_seen_on in the corresponding case(s)
@param row: the deleted Row'

@staticmethod
def case_appointment_ondelete(row):

    if current.deployment_settings.get_dvr_appointments_update_last_seen_on():
        table = current.s3db.dvr_case_appointment
        row = current.db((table.id == row.id)).select(table.deleted_fk, limitby=(0, 1)).first()
        if (row and row.deleted_fk):
            try:
                deleted_fk = json.loads(row.deleted_fk)
            except (ValueError, TypeError):
                person_id = None
            else:
                person_id = deleted_fk.get('person_id')
            if person_id:
                dvr_update_last_seen(person_id)
