def process(self, element, person_id_to_county): """Identifies instances of admission and release from incarceration.""" _, person_entities = element # Get the StateSentenceGroups as a list sentence_groups = list(person_entities['sentence_groups']) # Get the StatePerson person = one(person_entities['person']) # Get the person's county of residence, if present person_id_to_county_fields = person_id_to_county.get( person.person_id, None) county_of_residence = person_id_to_county_fields.get('county_of_residence', None) \ if person_id_to_county_fields else None # Find the IncarcerationEvents incarceration_events = identifier.find_incarceration_events( sentence_groups, county_of_residence) if not incarceration_events: logging.info( "No valid incarceration events for person with id: %d. Excluding them from the " "calculations.", person.person_id) else: yield (person, incarceration_events)
def process(self, element): """Identifies instances of admission and release from incarceration.""" _, person_entities = element person, kwargs = person_and_kwargs_for_identifier(person_entities) # Find the IncarcerationEvents incarceration_events = identifier.find_incarceration_events(**kwargs) if not incarceration_events: logging.info( "No valid incarceration events for person with id: %d. Excluding them from the " "calculations.", person.person_id, ) else: yield person.person_id, (person, incarceration_events)
def process(self, element, person_id_to_county): """Identifies instances of admission and release from incarceration.""" _, person_entities = element person, kwargs = person_and_kwargs_for_identifier(person_entities) # Get the person's county of residence, if present person_id_to_county_fields = person_id_to_county.get(person.person_id, None) county_of_residence = person_id_to_county_fields.get('county_of_residence', None) \ if person_id_to_county_fields else None # Add this arguments to the keyword args for the identifier kwargs['county_of_residence'] = county_of_residence # Find the IncarcerationEvents incarceration_events = identifier.find_incarceration_events(**kwargs) if not incarceration_events: logging.info("No valid incarceration events for person with id: %d. Excluding them from the " "calculations.", person.person_id) else: yield person, incarceration_events