def single_patient(request, patient_id): patient = loader.get_patient(patient_id) xforms = CXFormInstance.view("patient/xforms", key=patient.get_id, include_docs=True) encounter_types = get_encounters(patient) options = TouchscreenOptions.default() # TODO: are we upset about how this breaks MVC? options.nextbutton.show = False options.backbutton = ButtonOptions(text="BACK", link=reverse("patient_select")) encounters = sorted(patient.encounters, key=lambda encounter: encounter.visit_date, reverse=True) # TODO: figure out a way to do this more centrally # Inject cases into encounters so we can show them linked in the view for encounter in patient.encounters: if encounter.get_xform(): encounter.dynamic_data["classification"] = get_classification(encounter.get_xform().namespace) encounter.dynamic_data["cases"] = [] for case in patient.cases: if case.encounter_id == encounter.get_id: encounter.dynamic_data["cases"].append(case) return render_to_response(request, "patient/single_patient_touchscreen.html", {"patient": patient, "encounters": encounters, "xforms": xforms, "encounter_types": encounter_types, "options": options })
def delete_all_xforms(): for form in CXFormInstance.view(const.VIEW_XFORMS_BY_XMLNS, include_docs=True).all(): form.delete()