def copy_name_to_alias(_file_tag: str, _row: Dict[str, str], extracted_objects: List[IngestObject], _cache: IngestObjectCache): """Copy all name fields stored on a StatePerson object to a new StateAlias child object. """ for extracted_object in extracted_objects: if isinstance(extracted_object, StatePerson): alias_to_create = StateAlias( full_name=extracted_object.full_name, surname=extracted_object.surname, given_names=extracted_object.given_names, middle_names=extracted_object.middle_names, name_suffix=extracted_object.name_suffix, alias_type=StatePersonAliasType.GIVEN_NAME.value) create_if_not_exists(alias_to_create, extracted_object, 'state_aliases')
def test_populate_data_dbo_IcsDoc(self): expected = IngestInfo(state_people=[ StatePerson( state_person_id='1', surname='RUSSELL', given_names='BERTRAND', gender='2', birthdate='19760318', current_address='123 Easy Street, PITTSBURGH, PA 16161', state_person_external_ids=[ StatePersonExternalId(state_person_external_id_id='1', id_type=US_PA_DOC), StatePersonExternalId(state_person_external_id_id='123456', id_type=US_PA_CONT), StatePersonExternalId(state_person_external_id_id='AB7413', id_type=US_PA_INMATE), StatePersonExternalId(state_person_external_id_id='123A', id_type=US_PA_PBPP), StatePersonExternalId( state_person_external_id_id='12345678', id_type=US_PA_SID), ], state_person_races=[StatePersonRace(race='2')], state_aliases=[ StateAlias(surname='RUSSELL', given_names='BERTRAND', alias_type='GIVEN_NAME') ]), StatePerson( state_person_id='2', surname='SARTRE', given_names='JEAN-PAUL', gender='2', birthdate='19821002', current_address='555 FLATBUSH DR, NEW YORK, NY 10031', state_person_external_ids=[ StatePersonExternalId(state_person_external_id_id='2', id_type=US_PA_DOC), StatePersonExternalId(state_person_external_id_id='654321', id_type=US_PA_CONT), StatePersonExternalId(state_person_external_id_id='GF3374', id_type=US_PA_INMATE), StatePersonExternalId(state_person_external_id_id='456B', id_type=US_PA_PBPP), StatePersonExternalId( state_person_external_id_id='55554444', id_type=US_PA_SID), ], state_person_races=[StatePersonRace(race='2')], state_aliases=[ StateAlias(surname='SARTRE', given_names='JEAN-PAUL', alias_type='GIVEN_NAME') ]), StatePerson( state_person_id='3', surname='KIERKEGAARD', given_names='SOREN', name_suffix='JR ', gender='1', birthdate='19911120', current_address= '5000 SUNNY LANE, APT. 55D, PHILADELPHIA, PA 19129', state_person_external_ids=[ StatePersonExternalId(state_person_external_id_id='3', id_type=US_PA_DOC), StatePersonExternalId(state_person_external_id_id='445566', id_type=US_PA_CONT), StatePersonExternalId(state_person_external_id_id='CJ1991', id_type=US_PA_INMATE), StatePersonExternalId(state_person_external_id_id='012D', id_type=US_PA_PBPP), StatePersonExternalId( state_person_external_id_id='99990000', id_type=US_PA_SID), ], state_person_races=[StatePersonRace(race='6')], state_aliases=[ StateAlias(surname='KIERKEGAARD', given_names='SOREN', name_suffix='JR ', alias_type='GIVEN_NAME') ]), StatePerson( state_person_id='4', surname='RAWLS', given_names='JOHN', gender='2', birthdate='19890617', current_address='214 HAPPY PLACE, PHILADELPHIA, PA 19129', state_person_external_ids=[ StatePersonExternalId(state_person_external_id_id='4', id_type=US_PA_DOC), StatePersonExternalId(state_person_external_id_id='778899', id_type=US_PA_CONT), StatePersonExternalId(state_person_external_id_id='JE1989', id_type=US_PA_INMATE), StatePersonExternalId(state_person_external_id_id='345E', id_type=US_PA_PBPP), StatePersonExternalId( state_person_external_id_id='09876543', id_type=US_PA_SID), ], state_person_ethnicities=[StatePersonEthnicity(ethnicity='3')], state_aliases=[ StateAlias(surname='RAWLS', given_names='JOHN', alias_type='GIVEN_NAME') ]), ]) self.run_parse_file_test(expected, 'dbo_IcsDoc')