Example #1
0
 def allowed_to_forward(self, test_case):
     # test.date_reported populates and test.nikshay_registered is false
     # test.test_type_value = microscopy-zn or test.test_type_value = microscopy-fluorescent
     # and episode.nikshay_registered is true
     allowed_case_types_and_users = self._allowed_case_type(
         test_case) and self._allowed_user(test_case)
     if allowed_case_types_and_users:
         try:
             occurence_case = get_occurrence_case_from_test(
                 test_case.domain, test_case.get_id)
             episode_case = get_open_episode_case_from_occurrence(
                 test_case.domain, occurence_case.get_id)
         except ENikshayCaseNotFound:
             return False
         test_case_properties = test_case.dynamic_case_properties()
         episode_case_properties = episode_case.dynamic_case_properties()
         return (
             test_case_properties.get('nikshay_registered', 'false')
             == 'false' and test_case_properties.get('test_type_value', '')
             in ['microscopy-zn', 'microscopy-fluorescent']
             and episode_case_properties.get('nikshay_id') and
             (test_case_properties.get('purpose_of_testing') == 'diagnostic'
              or test_case_properties.get('follow_up_test_reason')
              in self.followup_for_tests
              or test_case_properties.get('rft_general')
              in ['diagnosis_dstb', 'diagnosis_drtb']
              or test_case_properties.get('rft_dstb_followup')
              in self.followup_for_tests)
             and case_properties_changed(test_case, 'date_reported')
             and not is_valid_test_submission(test_case))
     else:
         return False
Example #2
0
 def existing_episode_case(self):
     """
     Get the existing episode case for this nikshay ID, or None if no episode case exists
     """
     if self.existing_occurrence_case:
         try:
             return get_open_episode_case_from_occurrence(
                 self.domain, self.existing_occurrence_case.case_id)
         except ENikshayCaseNotFound:
             return None
Example #3
0
 def existing_episode_case(self):
     """
     Get the existing episode case for this nikshay ID, or None if no episode case exists
     """
     if self.existing_occurrence_case:
         try:
             return get_open_episode_case_from_occurrence(
                 self.domain, self.existing_occurrence_case.case_id
             )
         except ENikshayCaseNotFound:
             return None
Example #4
0
    def get_payload(self, repeat_record, test_case):
        occurence_case = get_occurrence_case_from_test(test_case.domain,
                                                       test_case.get_id)
        episode_case = get_open_episode_case_from_occurrence(
            test_case.domain, occurence_case.get_id)
        person_case = get_person_case_from_occurrence(test_case.domain,
                                                      occurence_case.get_id)

        test_case_properties = test_case.dynamic_case_properties()
        episode_case_properties = episode_case.dynamic_case_properties()
        use_2b_app_structure = self.use_2b_app_structure(
            person_case, episode_case)

        interval_id, lab_serial_number, result_grade, dmc_code = self._get_mandatory_fields(
            test_case, test_case_properties, occurence_case,
            use_2b_app_structure)

        test_reported_on = _format_date_or_null_date(test_case_properties,
                                                     'date_reported')
        properties_dict = self._base_properties(repeat_record)
        properties_dict.update({
            "PatientID":
            episode_case_properties.get('nikshay_id'),
            "TestDate":
            test_reported_on,
            "LabNo":
            lab_serial_number,
            "Local_ID":
            person_case.get_id,
            "IntervalId":
            interval_id,
            # since weight is not taken and is mandatory we send 1
            "PatientWeight":
            test_case_properties.get('weight', 1),
            "SmearResult":
            result_grade,
            "DMC":
            dmc_code
        })

        return json.dumps(properties_dict)
Example #5
0
 def test_get_open_episode_case_from_occurrence(self):
     self.assertEqual(
         get_open_episode_case_from_occurrence(self.domain,
                                               self.occurrence_id).case_id,
         self.episode_id)
Example #6
0
 def test_get_open_episode_case_from_occurrence(self):
     self.assertEqual(
         get_open_episode_case_from_occurrence(self.domain, self.occurrence_id).case_id,
         self.episode_id
     )