Beispiel #1
0
def export_patient(request, patient_id):
    patient = CPatient.get(patient_id)
    count = 1
    form_filenames = []
    for form in patient.xforms():
        form_filenames.append(export.get_form_filename(count,  form))
        count += 1
    return render_to_response(request, "patient/export_instructions.html", 
                              {"patient": patient,
                               "zip_filename": export.get_zip_filename(patient),
                               "foldername": export.get_zip_filename(patient).split(".")[0],
                               "pat_filename": export.get_patient_filename(patient),
                               "forms": form_filenames})
Beispiel #2
0
def export_patient_download(request, patient_id):
    """
    Export a patient's forms to a zip file.
    """
    # this may not perform with huge amounts of data, but for a single 
    # patient should be fine
    patient = CPatient.get(patient_id)
    temp_file = export.export_patient(patient)
    data = temp_file.read()
    response = HttpResponse(data, content_type='application/zip')
    response['Content-Disposition'] = 'attachment; filename=%s' % export.get_zip_filename(patient)
    response['Content-Length'] = len(data)
    return response