Beispiel #1
0
 def run(self):
     """
     Returns WorkflowTasks for creating visits, encounters and observations
     """
     subtasks = []
     provider_uuid = getattr(self.openmrs_config, 'openmrs_provider', None)
     location_uuid = get_openmrs_location_uuid(self.domain,
                                               self.info.case_id)
     self.info.form_question_values.update(self.form_question_values)
     for form_config in self.openmrs_config.form_configs:
         if form_config.xmlns == self.form_json['form']['@xmlns']:
             subtasks.append(
                 CreateVisitTask(
                     self.requests,
                     person_uuid=self.person_uuid,
                     provider_uuid=provider_uuid,
                     visit_datetime=string_to_utc_datetime(
                         self.form_json['form']['meta']['timeEnd']),
                     values_for_concept={
                         obs.concept: [obs.value.get_value(self.info)]
                         for obs in form_config.openmrs_observations
                         if obs.value.get_value(self.info)
                     },
                     encounter_type=form_config.openmrs_encounter_type,
                     openmrs_form=form_config.openmrs_form,
                     visit_type=form_config.openmrs_visit_type,
                     location_uuid=location_uuid,
                 ))
     return subtasks
Beispiel #2
0
    def test_openmrs_location_uuid_none(self):
        """
        get_openmrs_location_uuid should return the OpenMRS location UUID that corresponds to a case's location
        """
        gardens = self.locations['Gardens']
        self.assertIsNone(gardens.metadata.get(LOCATION_OPENMRS_UUID))

        case_id = uuid.uuid4().hex
        form, (case, ) = _create_case(domain=self.domain, case_id=case_id, owner_id=gardens.location_id)

        self.assertIsNone(get_openmrs_location_uuid(self.domain, case_id))
Beispiel #3
0
    def test_openmrs_location_uuid_set(self):
        """
        get_openmrs_location_uuid should return the OpenMRS location UUID that corresponds to a case's location
        """
        openmrs_capetown_uuid = '50017a7f-296d-4ab9-8d3a-b9498bcbf385'
        cape_town = self.locations['Cape Town']
        cape_town.metadata[LOCATION_OPENMRS_UUID] = openmrs_capetown_uuid
        with mock.patch('corehq.apps.locations.document_store.publish_location_saved', mock.Mock()):
            cape_town.save()

        case_id = uuid.uuid4().hex
        form, (case, ) = _create_case(domain=self.domain, case_id=case_id, owner_id=cape_town.location_id)

        self.assertEqual(
            get_openmrs_location_uuid(self.domain, case_id),
            openmrs_capetown_uuid
        )