コード例 #1
0
ファイル: views.py プロジェクト: dimagi/bhoma
def search_results(request):
    query = request.GET.get('q', '')
    if not query:
        return HttpResponseRedirect(reverse("patient_search"))
    patients = CPatient.view(VIEW_PATIENT_SEARCH, key=query.lower(), include_docs=True)
    minus_duplicates = SortedDict()
    for patient in patients:
        if not patient.get_id in minus_duplicates:
            minus_duplicates[patient.get_id] = patient
    return render_to_response(request, "patient/search_results.html", 
                              {"patients": minus_duplicates.values(), 
                               "query": query} ) 
コード例 #2
0
ファイル: views.py プロジェクト: dimagi/bhoma
def patient_excel(request):  
    # we have to make sure to update any patients without export tags
    # before redirecting to the export view.
    for pat in CPatient.view("patient/missing_export_tag", include_docs=True):
        try:
            pat.save()
        except ResourceConflict:
            # workaround potential conflicts by trying twice
            pat = CPatient.get(pat.get_id)
            pat.save()
    
    return HttpResponseRedirect("%s?export_tag=CPatient&filename=Patients" % reverse("export_data_async"))
コード例 #3
0
ファイル: api_views.py プロジェクト: dimagi/bhoma
def lookup_by_id(request):
    """
    Get a patient by ID, returning the json representation of the patient
    """
    pat_id = request.GET.get('id')
    if pat_id != None:
        patients = CPatient.view(VIEW_PATIENT_BY_BHOMA_ID, key=pat_id, reduce=False, include_docs=True).all()
        return _patient_list_response(patients)
    else:
        pat_uuid = request.GET.get('uuid')
        patient = loader.get_patient(pat_uuid)
        return HttpResponse(json.dumps(patient.to_json()), mimetype='text/json')
コード例 #4
0
ファイル: api_views.py プロジェクト: dimagi/bhoma
def fuzzy_match(request):
    # TODO this currently always returns nothing
    fname = request.POST.get('fname')
    lname = request.POST.get('lname')
    gender = request.POST.get('sex')
    dob = request.POST.get('dob')
    def prep(val):
        return val.strip().lower() if val and isinstance(val, basestring) else val
    
    startkey = map(prep, [gender, lname, fname, dob])
    endkey = map(prep, [gender, lname, fname, dob, {}])
    pats = CPatient.view(VIEW_PATIENT_FUZZY_SEARCH, startkey=startkey,
                         endkey=endkey, reduce=False, include_docs=True).all()
    return _patient_list_response(pats)
コード例 #5
0
ファイル: cleanup.py プロジェクト: dimagi/bhoma
def delete_all_patients():
    for pat in CPatient.view(const.VIEW_PATIENT_BY_BHOMA_ID, reduce=False, include_docs=True).all():
        pat.delete()