def new_form_received(patient_id, form): """ A new form was received for a patient. This usually just adds the form to the patient object, but will fully reprocess the patient data if the form is from the past, so that previously-entered but later-occurring changes can be applied to the data """ patient = CPatient.get(patient_id) encounter_date = Encounter.get_visit_date(form) full_reprocess = False for encounter in patient.encounters: if encounter.visit_date > encounter_date: full_reprocess = True break if full_reprocess: reprocess(patient_id) else: add_form_to_patient(patient_id, form)
def comparison_date(form): # get a date from the form return Encounter.get_visit_date(form)