def METHOD_NAME(environ):
    patients = {}
    for s in studies_getter(BASE_DIR):
        patients.setdefault(s.patient_name_or_uid(), []).append(s)
    template = template_env.from_string(index_template)
    return template.render(patients=patients).encode('utf-8')