def _submit_delivery_form(self, form_date, case_id, nutrition_status=None, case_id_2=None): form = ElementTree.Element('data') form.attrib['xmlns'] = XMLNS_DELIVERY_FORM form.attrib['xmlns:jrm'] = 'http://openrosa.org/jr/xforms' meta = ElementTree.Element('meta') add_element(meta, 'timeEnd', form_date.isoformat()) form.append(meta) child_repeat1 = ElementTree.Element('child') child_open_child_health_repeat1 = ElementTree.Element( 'case_open_child_health_3') case_repeat1 = ElementTree.Element('case') case_repeat1.attrib['date_modified'] = form_date.isoformat() case_repeat1.attrib['case_id'] = case_id case_repeat1.attrib[ 'xmlns'] = 'http://commcarehq.org/case/transaction/v2' if nutrition_status is not None: case_update_repeat1 = ElementTree.Element('update') add_element(case_update_repeat1, 'zscore_grading_wfa', nutrition_status) case_repeat1.append(case_update_repeat1) child_open_child_health_repeat1.append(case_repeat1) child_repeat1.append(child_open_child_health_repeat1) add_element(child_repeat1, 'zscore_grading_wfa', nutrition_status) form.append(child_repeat1) if case_id_2 is not None: child_repeat2 = ElementTree.Element('child') child_open_child_health_repeat2 = ElementTree.Element( 'case_open_child_health_3') case_repeat2 = ElementTree.Element('case') case_repeat2.attrib['date_modified'] = form_date.isoformat() case_repeat2.attrib['case_id'] = case_id_2 case_repeat2.attrib[ 'xmlns'] = 'http://commcarehq.org/case/transaction/v2' case_update_repeat2 = ElementTree.Element('update') add_element(case_update_repeat2, 'zscore_grading_wfa', nutrition_status) case_repeat2.append(case_update_repeat2) child_open_child_health_repeat2.append(case_repeat2) child_repeat2.append(child_open_child_health_repeat2) add_element(child_repeat2, 'zscore_grading_wfa', NUTRITION_STATUS_SEVERE) form.append(child_repeat2) ElementTree.dump(form) self._submit_form(form)
def _submit_dailyfeeding_form(self, form_date, case_id): form = ElementTree.Element('data') form.attrib['xmlns'] = XMLNS_DAILYFEEDING_FORM form.attrib['xmlns:jrm'] = 'http://openrosa.org/jr/xforms' meta = ElementTree.Element('meta') add_element(meta, 'timeEnd', form_date.isoformat()) form.append(meta) case = ElementTree.Element('case') case.attrib['date_modified'] = form_date.isoformat() case.attrib['case_id'] = case_id case.attrib['xmlns'] = 'http://commcarehq.org/case/transaction/v2' form.append(case) self._submit_form(form)
def _submit_ebf_form(self, form_date, case_id, counsel_methods='no'): form = ElementTree.Element('data') form.attrib['xmlns'] = XMLNS_EBF_FORM form.attrib['xmlns:jrm'] = 'http://openrosa.org/jr/xforms' meta = ElementTree.Element('meta') add_element(meta, 'timeEnd', form_date.isoformat()) form.append(meta) case = ElementTree.Element('case') case.attrib['date_modified'] = form_date.isoformat() case.attrib['case_id'] = case_id case.attrib['xmlns'] = 'http://commcarehq.org/case/transaction/v2' form.append(case) add_element(form, 'counsel_methods', counsel_methods) submit_form_locally(ElementTree.tostring(form), self.domain, **{})
def _submit_thr_rations_form(self, form_date, case_id, thr_given_mother='0', rations_distributed=0): form = ElementTree.Element('data') form.attrib['xmlns'] = XMLNS_THR_FORM form.attrib['xmlns:jrm'] = 'http://openrosa.org/jr/xforms' meta = ElementTree.Element('meta') add_element(meta, 'timeEnd', form_date.isoformat()) form.append(meta) case = ElementTree.Element('case') case.attrib['date_modified'] = form_date.isoformat() case.attrib['case_id'] = case_id case.attrib['xmlns'] = 'http://commcarehq.org/case/transaction/v2' form.append(case) add_element(form, 'thr_given_mother', thr_given_mother) if thr_given_mother == '1': mother_thr = ElementTree.Element('mother_thr') add_element(mother_thr, 'days_ration_given_mother', rations_distributed) form.append(mother_thr) submit_form_locally(ElementTree.tostring(form), self.domain, **{})
def _submit_gmp_form(self, form_date, case_id, nutrition_status=None): form = ElementTree.Element('data') form.attrib['xmlns'] = XMLNS_GMP_FORM form.attrib['xmlns:jrm'] = 'http://openrosa.org/jr/xforms' meta = ElementTree.Element('meta') add_element(meta, 'timeEnd', form_date.isoformat()) form.append(meta) case = ElementTree.Element('case') case.attrib['date_modified'] = form_date.isoformat() case.attrib['case_id'] = case_id case.attrib['xmlns'] = 'http://commcarehq.org/case/transaction/v2' if nutrition_status is not None: case_update = ElementTree.Element('update') add_element(case_update, 'zscore_grading_wfa', nutrition_status) case.append(case_update) form.append(case) add_element(form, 'zscore_grading_wfa', nutrition_status) self._submit_form(form)
def _submit_bp_form(self, form_date, case_id, using_ifa='no', num_ifa_consumed_last_seven_days=0, anemia=None, extra_meal='no', resting_during_pregnancy='no', counsel_immediate_bf='no', counsel_bp_vid='no', counsel_preparation='no', counsel_fp_vid='no', counsel_immediate_conception='no', counsel_accessible_postpartum_fp='no'): form = ElementTree.Element('data') form.attrib['xmlns'] = XMNLS_BP_FORM form.attrib['xmlns:jrm'] = 'http://openrosa.org/jr/xforms' meta = ElementTree.Element('meta') add_element(meta, 'timeEnd', form_date.isoformat()) form.append(meta) case = ElementTree.Element('case') case.attrib['date_modified'] = form_date.isoformat() case.attrib['case_id'] = case_id case.attrib['xmlns'] = 'http://commcarehq.org/case/transaction/v2' form.append(case) add_element(form, 'play_family_planning_vid', counsel_fp_vid) add_element(form, 'conceive', counsel_immediate_conception) bp1 = ElementTree.Element('bp1') add_element(bp1, 'using_ifa', using_ifa) if using_ifa == 'yes': add_element(bp1, 'ifa_last_seven_days', num_ifa_consumed_last_seven_days) add_element(bp1, 'anemia', anemia) add_element(bp1, 'eating_extra', extra_meal) add_element(bp1, 'resting', resting_during_pregnancy) form.append(bp1) bp2 = ElementTree.Element('bp2') add_element(bp2, 'immediate_breastfeeding', counsel_immediate_bf) add_element(bp2, 'play_birth_preparedness_vid', counsel_bp_vid) add_element(bp2, 'counsel_preparation', counsel_preparation) form.append(bp2) fp_group = ElementTree.Element('family_planning_group') add_element(fp_group, 'counsel_accessible_ppfp', counsel_accessible_postpartum_fp) form.append(fp_group) submit_form_locally(ElementTree.tostring(form), self.domain, **{})
def _submit_thr_rations_form(self, form_date, case_id, rations_distributed=0, case_id_2=None): form = ElementTree.Element('data') form.attrib['xmlns'] = XMLNS_THR_FORM form.attrib['xmlns:jrm'] = 'http://openrosa.org/jr/xforms' meta = ElementTree.Element('meta') add_element(meta, 'timeEnd', form_date.isoformat()) form.append(meta) case = ElementTree.Element('case') case.attrib['date_modified'] = form_date.isoformat() case.attrib['case_id'] = case_id case.attrib['xmlns'] = 'http://commcarehq.org/case/transaction/v2' form.append(case) add_element(form, 'thr_given_child', '1') child_thr = ElementTree.Element('child_thr') child_thr_persons = ElementTree.Element('child_persons') child_thr_repeat1 = ElementTree.Element('item') add_element(child_thr_repeat1, 'child_health_case_id', case_id) if rations_distributed > 0: add_element(child_thr_repeat1, 'days_ration_given_child', rations_distributed) add_element(child_thr_repeat1, 'distribute_ration_child', 'yes') else: add_element(child_thr_repeat1, 'distribute_ration_child', 'no') child_thr_persons.append(child_thr_repeat1) if case_id_2 is not None: child_thr_repeat2 = ElementTree.Element('item') add_element(child_thr_repeat2, 'child_health_case_id', case_id_2) add_element(child_thr_repeat2, 'days_ration_given_child', 25) add_element(child_thr_repeat2, 'distribute_ration_child', 'yes') child_thr_persons.append(child_thr_repeat2) child_thr.append(child_thr_persons) form.append(child_thr) self._submit_form(form)