def get_payload(self, repeat_record, person_case): """ https://docs.google.com/document/d/1yUWf3ynHRODyVVmMrhv5fDhaK_ufZSY7y0h9ke5rBxU/edit#heading=h.hxfnqahoeag """ episode_case = get_open_episode_case_from_person( person_case.domain, person_case.get_id) episode_case_properties = episode_case.dynamic_case_properties() person_case_properties = person_case.dynamic_case_properties() base_properties = self._base_properties(repeat_record) base_properties.update({ "PatientID": episode_case_properties.get('nikshay_id'), "HIVStatus": hiv_status.get(person_case_properties.get('hiv_status')), "HIVTestDate": _format_date_or_null_date(person_case_properties, 'hiv_test_date'), "CPTDeliverDate": _format_date_or_null_date(person_case_properties, 'cpt_1_date'), "ARTCentreDate": _format_date_or_null_date(person_case_properties, 'art_initiation_date'), "InitiatedOnART": art_initiated.get( person_case_properties.get('art_initiated', 'no'), art_initiated['no']), "InitiatedDate": _format_date_or_null_date(person_case_properties, 'art_initiation_date'), }) return json.dumps(base_properties)
def get_payload(self, repeat_record, person_case): """ https://docs.google.com/document/d/1yUWf3ynHRODyVVmMrhv5fDhaK_ufZSY7y0h9ke5rBxU/edit#heading=h.hxfnqahoeag """ episode_case = get_open_episode_case_from_person( person_case.domain, person_case.get_id) episode_case_properties = episode_case.dynamic_case_properties() person_case_properties = person_case.dynamic_case_properties() properties_dict = { "PatientID": episode_case_properties.get('nikshay_id'), "HIVStatus": hiv_status.get(person_case_properties.get('hiv_status')), "HIVTestDate": datetime.datetime.strptime( person_case_properties.get('hiv_test_date', NIKSHAY_NULL_DATE), '%Y-%m-%d').strftime('%d/%m/%Y'), "CPTDeliverDate": datetime.datetime.strptime( person_case_properties.get('cpt_initiation_date', NIKSHAY_NULL_DATE), '%Y-%m-%d').strftime('%d/%m/%Y'), "ARTCentreDate": datetime.datetime.strptime( person_case_properties.get('art_initiation_date', NIKSHAY_NULL_DATE), '%Y-%m-%d').strftime('%d/%m/%Y'), "InitiatedOnART": art_initiated.get(person_case_properties.get( 'art_initiated', 'no')), "InitiatedDate": datetime.datetime.strptime( person_case_properties.get('art_initiation_date', NIKSHAY_NULL_DATE), '%Y-%m-%d').strftime('%d/%m/%Y'), "Source": ENIKSHAY_ID, "regby": repeat_record.repeater.username, "password": repeat_record.repeater.password, "IP_FROM": "127.0.0.1", } return json.dumps(properties_dict)