コード例 #1
0
ファイル: views.py プロジェクト: dimagi/bhoma
 def callback(doc):
     try:
         # only post-process forms that aren't duplicates
         new_form_workflow(doc,SENDER_PHONE)
         
         # find out how many forms they have submitted
         def forms_submitted_count(user):
             forms_submitted = get_db().view("centralreports/chw_submission_counts", 
                                             startkey=["ud", user], 
                                             endkey=["ud", user, {}]).one()
             return forms_submitted["value"] if forms_submitted else "at least 1"
         
         def forms_submitted_today_count(user):
             today = datetime.today()
             key = ["ud", user, today.year, today.month - 1, today.day]
             forms_submitted_today = get_db().view("centralreports/chw_submission_counts", 
                                                   key=key).one()
             return forms_submitted_today["value"] if forms_submitted_today else "at least 1"
             
         if doc.metadata and doc.metadata.user_id:
             return HttpResponse(xml.get_response(doc, 
                                                  forms_submitted_today_count(doc.metadata.user_id), 
                                                  forms_submitted_count(doc.metadata.user_id)))
         else:
             return HttpResponse(xml.get_response(doc))
     except Exception, e:
         logging.exception("problem post processing phone submission")
         return HttpResponse(xml.get_response(doc))
コード例 #2
0
ファイル: test_chw_referrals.py プロジェクト: dimagi/bhoma
 def testUnmatchedPatient(self):
     folder_name = os.path.join(os.path.dirname(__file__), "data", "chw")
     with open(os.path.join(folder_name, "non_life_threatening_referral.xml"), "r") as f:
         formbody = f.read()
     formdoc = post_xform_to_couch(formbody)
     new_form_workflow(formdoc, SENDER_PHONE, None)
     self.assertFalse("#patient_guid" in formdoc)
コード例 #3
0
ファイル: test_chw_referrals.py プロジェクト: dimagi/bhoma
 def testMissingPatientId(self):
     folder_name = os.path.join(os.path.dirname(__file__), "data", "chw")
     with open(os.path.join(folder_name, "referral_no_pat_id.xml"), "r") as f:
         formbody = f.read()
     formdoc = post_xform_to_couch(formbody)
     new_form_workflow(formdoc, SENDER_PHONE, None)
     self.assertFalse("#patient_guid" in formdoc)
コード例 #4
0
ファイル: export.py プロジェクト: dimagi/bhoma
def add_form_to_patient(patient_id, form):
    """
    From a handle to a patient and xform instance xml, 
    add that form to the patient.
    Returns the updated patient and newly created form.
    This will OVERRIDE any existing form with the same ID.
    """
    formdoc = post_xform_to_couch(form)
    new_form_workflow(formdoc, SENDER_EXPORT, patient_id)
    pat =  CPatient.get(patient_id) if patient_id is not None else None
    return pat, formdoc
コード例 #5
0
ファイル: test_chw_referrals.py プロジェクト: dimagi/bhoma
 def testRegeneratePatient(self):
     folder_name = os.path.join(os.path.dirname(__file__), "data", "chw")
     patient = export.import_patient_json_file(os.path.join(folder_name, "patient.json"))
     self.assertEqual(0, len(patient.encounters))
     with open(os.path.join(folder_name, "non_life_threatening_referral.xml"), "r") as f:
         formbody = f.read()
     formdoc = post_xform_to_couch(formbody)
     new_form_workflow(formdoc, SENDER_PHONE, None)
     patient = CPatient.get(patient.get_id)
     self.assertEqual(1, len(patient.encounters))
     self.assertTrue(reprocess(patient.get_id))
     patient = CPatient.get(patient.get_id)
     self.assertEqual(1, len(patient.encounters))
コード例 #6
0
ファイル: test_pregnancy.py プロジェクト: dimagi/bhoma
def post_and_process_xform(filename, patient):
    doc = post_xform(filename, patient.get_id)
    new_form_workflow(doc, "unit_tests", patient.get_id)
    return doc
コード例 #7
0
ファイル: test_phone_followups.py プロジェクト: dimagi/bhoma
 def testFollowNoPatient(self):
     # no assertions necessary, this should just not throw an exception
     with open(os.path.join(os.path.dirname(__file__), "data", "bhoma", "chw_followup_nopatient.xml"), "r") as f:
         formdoc = post_xform_to_couch(f.read())
         new_form_workflow(formdoc, None, None)
コード例 #8
0
ファイル: views.py プロジェクト: dimagi/bhoma
 def callback(xform, doc):
     if doc:
         new_form_workflow(doc, SENDER_CLINIC, patient_id)
     return HttpResponseRedirect(reverse("single_patient", args=(patient_id,)))