def _compare_name_fields( project, rdr_dataset, pii_dataset, hpo, concept_id, pii_field ): """ For an hpo, compare all first, middle, and last name fields to omop settings. This compares a site's name field values found in their uploaded PII tables with the values in the OMOP observation table. :param project: project to search for the datasets :param rdr_dataset: contains datasets from the rdr group :param pii_dataset: dataset created from submitted hpo sites. the pii tables :param hpo: string identifier of hpo :param concept_id: integer value of concept id for concept in the rdr_dataset :param pii_field: string value of field name with data matching the concept_id. used to extract the correct values from the pii tables :return: a match_values dictionary. """ match_values = {} rdr_names = readers.get_rdr_match_values( project, rdr_dataset, consts.ID_MATCH_TABLE, concept_id ) pii_names = readers.get_pii_values( project, pii_dataset, hpo, consts.PII_NAME_TABLE, pii_field ) for person_id, pii_name in pii_names: rdr_name = rdr_names.get(person_id) if rdr_name is None or pii_name is None: match_str = consts.MISSING else: pii_name = normalizer.normalize_name(pii_name) rdr_name = normalizer.normalize_name(rdr_name) match_str = consts.MATCH if rdr_name == pii_name else consts.MISMATCH match_values[person_id] = match_str return match_values
def _compare_name_fields(project, rdr_dataset, pii_dataset, hpo, concept_id, pii_field, pii_tables): """ For an hpo, compare all first, middle, and last name fields to omop settings. This compares a site's name field values found in their uploaded PII tables with the values in the OMOP observation table. :param project: project to search for the datasets :param rdr_dataset: contains datasets from the rdr group :param pii_dataset: dataset created from submitted hpo sites. the pii tables :param hpo: string identifier of hpo :param concept_id: integer value of concept id for concept in the rdr_dataset :param pii_field: string value of field name with data matching the concept_id. used to extract the correct values from the pii tables :return: a match_values dictionary. """ match_values = {} table_name = hpo + consts.PII_NAME_TABLE if table_name in pii_tables: rdr_names = readers.get_rdr_match_values(project, rdr_dataset, consts.ID_MATCH_TABLE, concept_id) try: pii_names = readers.get_pii_values(project, pii_dataset, hpo, consts.PII_NAME_TABLE, pii_field) except (oauth2client.client.HttpAccessTokenRefreshError, googleapiclient.errors.HttpError): LOGGER.exception( f"Unable to read PII for: {hpo}\tdata field:\t{pii_field}") raise for person_id, pii_name in pii_names: rdr_name = rdr_names.get(person_id) if rdr_name is None or pii_name is None: match_str = consts.MISSING else: pii_name = normalizer.normalize_name(pii_name) rdr_name = normalizer.normalize_name(rdr_name) match_str = consts.MATCH if rdr_name == pii_name else consts.MISMATCH match_values[person_id] = match_str else: raise RuntimeError('Table {} doesnt exist.'.format(table_name)) return match_values
def test_normalize_spaced_name(self): # test actual = normalizer.normalize_name('Jo Anne') # post condition expected = 'joanne' self.assertEqual(actual, expected)
def test_normalize_hyphenated_name(self): # test actual = normalizer.normalize_name('Foo-Bar') # post condition expected = 'foobar' self.assertEqual(actual, expected)
def test_normalize_name_mixed_case(self): # test actual = normalizer.normalize_name('O\'Keefe') # post condition expected = 'okeefe' self.assertEqual(actual, expected)
def test_normalize_non_string_name(self): # test actual = normalizer.normalize_name(11) # post-condition expected = '' self.assertEqual(actual, expected)
def test_normalize_None_name(self): # test actual = normalizer.normalize_name(None) # post condition expected = '' self.assertEqual(actual, expected)