def test_create_missing_default(self): """ PatientFinder.create_missing should default to false """ finder = PatientFinder.wrap({ 'doc_type': 'WeightedPropertyPatientFinder', 'searchable_properties': [], 'property_weights': [], }) self.assertFalse(finder.create_missing)
def test_wrap_subclass(self): """ PatientFinder.wrap() should return the type of subclass determined by "doc_type" """ finder = PatientFinder.wrap({ 'doc_type': 'WeightedPropertyPatientFinder', 'searchable_properties': [], 'property_weights': [], }) self.assertIsInstance(finder, WeightedPropertyPatientFinder)
def test_create_missing_default(self): """ PatientFinder.create_missing should default to false """ finder = PatientFinder.wrap({ 'doc_type': 'WeightedPropertyPatientFinder', 'searchable_properties': [], 'property_weights': [], }) self.assertFalse(finder.create_missing)
def test_wrap_subclass(self): """ PatientFinder.wrap() should return the type of subclass determined by "doc_type" """ finder = PatientFinder.wrap({ 'doc_type': 'WeightedPropertyPatientFinder', 'searchable_properties': [], 'property_weights': [], }) self.assertIsInstance(finder, WeightedPropertyPatientFinder)
def test_create_missing_true(self): finder = PatientFinder.wrap({ 'doc_type': 'WeightedPropertyPatientFinder', 'searchable_properties': [], 'property_weights': [], 'create_missing': True, }) self.assertEqual(finder.create_missing, { "external_data_type": OPENMRS_DATA_TYPE_BOOLEAN, "value": 'True', })
def test_create_missing_default(self): """ PatientFinder.create_missing should default to false """ finder = PatientFinder.wrap({ 'doc_type': 'WeightedPropertyPatientFinder', 'searchable_properties': [], 'property_weights': [], }) self.assertEqual(finder.create_missing, { "external_data_type": OPENMRS_DATA_TYPE_BOOLEAN, "value": 'False', })
def test_create_missing_true(self): finder = PatientFinder.wrap({ 'doc_type': 'WeightedPropertyPatientFinder', 'searchable_properties': [], 'property_weights': [], 'create_missing': True, }) self.assertEqual( finder.create_missing, ConstantString( external_data_type=OPENMRS_DATA_TYPE_BOOLEAN, commcare_data_type=None, direction=None, doc_type='ConstantString', value='True', ) )
identifier = response.json()['identifiers'][0] except (ValueError, IndexError, KeyError): raise OpenmrsException() except OpenmrsException: requests.notify_exception( 'OpenMRS idgen module returned an unexpected response', details= (f'OpenMRS idgen module at "{response.url}" ' f'returned an unexpected response {response.status_code}: \r\n' f'{response.content}')) return identifier def find_or_create_patient(requests, domain, info, openmrs_config): case = CaseAccessors(domain).get_case(info.case_id) patient_finder = PatientFinder.wrap( openmrs_config.case_config.patient_finder) if patient_finder is None: return patients = patient_finder.find_patients(requests, case, openmrs_config.case_config) if len(patients) == 1: patient, = patients elif not patients and patient_finder.create_missing.get_value(info): patient = create_patient(requests, info, openmrs_config.case_config) else: # If PatientFinder can't narrow down the number of candidate # patients, don't guess. Just admit that we don't know. return None try: save_match_ids(case, openmrs_config.case_config, patient) except DuplicateCaseMatch as err: