Beispiel #1
0
    def test_invalid_cases(self):
        """Invalid cases shouldn't be triggered
        """
        person = get_person_case_structure(self.person_id, self.user.user_id)

        occurrence = get_occurrence_case_structure(self.occurrence_id, person)

        episode_structure = get_episode_case_structure(self.episode_id, occurrence)
        self.factory.create_or_update_case(episode_structure)

        archived_person = get_person_case_structure("person_2", self.user.user_id, owner_id="_archive_")
        occurrence = get_occurrence_case_structure('occurrence_2', archived_person)
        invalid_episode_structure = get_episode_case_structure('episode_2', occurrence)
        self.factory.create_or_update_case(invalid_episode_structure)

        closed_person = get_person_case_structure("person_3", self.user.user_id)
        occurrence = get_occurrence_case_structure('occurrence_3', closed_person)
        closed_episode_structure = get_episode_case_structure('episode_3', occurrence)
        self.factory.create_or_update_case(closed_episode_structure)
        self.factory.create_or_update_case(CaseStructure(
            case_id="person_3",
            attrs={'close': True}
        ))
        case_ids = [
            item for batch in self.case_updater._get_case_id_batches()
            for item in batch
        ]
        episode_ids = [episode.case_id
                       for episode in self.case_updater._get_open_episode_cases(case_ids)]
        self.assertEqual(episode_ids, [self.episode_id])
    def _create_episode_case(
        self,
        adherence_schedule_date_start=None,
        adherence_schedule_id=None,
        extra_properties=None,
    ):
        person = get_person_case_structure(
            self.person_id,
            self.user.user_id,
        )

        occurrence = get_occurrence_case_structure(self.occurrence_id, person)

        extra_update = {
            'adherence_schedule_date_start': adherence_schedule_date_start,
            'adherence_schedule_id': adherence_schedule_id
        }
        extra_update.update(extra_properties or {})

        episode_structure = get_episode_case_structure(
            self.episode_id,
            occurrence,
            extra_update=extra_update,
        )
        cases = {
            case.case_id: case
            for case in self.factory.create_or_update_cases(
                [episode_structure])
        }
Beispiel #3
0
    def _setup_casedata(cls):
        cls.episode_id = "episode"
        factory = CaseFactory(domain=cls.domain)

        person = get_person_case_structure(
            "person",
            cls.user.user_id,
        )

        occurrence = get_occurrence_case_structure("occurence", person)

        episode_structure = get_episode_case_structure(cls.episode_id,
                                                       occurrence)

        cases = {
            case.case_id: case
            for case in factory.create_or_update_cases([episode_structure])
        }
Beispiel #4
0
 def _get_episode_structure(self, occurrence):
     case_id = occurrence.case_id + '-episode'
     episode = get_episode_case_structure(case_id, occurrence)
     episode.attrs['update'].update({
         'episode_type':
         "confirmed_tb",
         'alcohol_history':
         "alcohol_history",
         'alcohol_deaddiction':
         "alcohol_deaddiction",
         'tobacco_user':
         "******",
         'occupation':
         "occupation",
         'phone_number_other':
         "phone_number_other",
         'disease_classification':
         'disease_classification',
         'site_choice':
         'site_choice',
         'site_detail':
         'site_detail',
         'key_population_status':
         'key_population_status',
         'key_populations':
         'key_populations',
         'treatment_status':
         'second_line_treatment',
         'date_of_diagnosis':
         '',
         'date_reported':
         'date_reported',
         'full_dosage':
         'full_dosage',
         'test_confirming_diagnosis':
         'chest_x-ray',
     })
     return episode