pyDeid.phi_types package¶
Submodules¶
pyDeid.phi_types.AddressPHIFinder module¶
- class pyDeid.phi_types.AddressPHIFinder.AddressPHIFinder(local_places_unambig: list[str] = None)¶
Bases:
PHITypeFinder
Concrete implementation of PHITypeFinder for detecting addresses.
- apt_indicators = ['apt', 'suite']¶
- find()¶
Find phand return all occurrences of the PHI type in the given text.
- street_add_suff = ['park', 'drive', 'street', 'road', 'lane', 'boulevard', 'blvd', 'avenue', 'highway', 'circle', 'ave', 'place', 'rd', 'st']¶
- strict_street_add_suff = ['Park', 'Drive', 'Street', 'Road', 'Lane', 'Boulevard', 'Blvd', 'Avenue', 'Highway', 'Ave', 'Rd', 'PARK', 'DRIVE', 'STREET', 'ROAD', 'LANE', 'BOULEVARD', 'BLVD', 'AVENUE', 'HIGHWAY', 'AVE', 'RD']¶
pyDeid.phi_types.AmericanPIIFinder module¶
pyDeid.phi_types.DatesPHIFinder module¶
- class pyDeid.phi_types.DatesPHIFinder.Date(date_string, day, month, year)¶
Bases:
tuple
- date_string¶
Alias for field number 0
- day¶
Alias for field number 1
- month¶
Alias for field number 2
- year¶
Alias for field number 3
- class pyDeid.phi_types.DatesPHIFinder.DatesPHIFinder(two_digit_threshold=30, valid_year_low=1001, valid_year_high=2999, invalid_time_pre_words: List[str] = None, invalid_time_post_words: List[str] = None)¶
Bases:
PHITypeFinder
Concrete implementation of PHITypeFinder for detecting dates, years, holidays, seasons.
- date(text: str)¶
- date_range(text: str)¶
- date_with_context_check(text: str)¶
- days = {'1': 31, '10': 31, '11': 30, '12': 31, '2': 28, '3': 31, '4': 30, '5': 31, '6': 30, '7': 31, '8': 31, '9': 30}¶
- find()¶
Find phand return all occurrences of the PHI type in the given text.
- find_time(text: str)¶
- holiday(text: str)¶
- monthly(text: str)¶
- months = {'Apr': 4, 'April': 4, 'Aug': 8, 'August': 8, 'Dec': 12, 'December': 12, 'Feb': 2, 'February': 2, 'Jan': 1, 'January': 1, 'Jul': 7, 'July': 7, 'Jun': 6, 'June': 6, 'Mar': 3, 'March': 3, 'May': 5, 'Nov': 11, 'November': 11, 'Oct': 10, 'October': 10, 'Sep': 9, 'Sept': 9, 'September': 9}¶
- property name¶
- season_year(text)¶
- seasons = ['winter', 'spring', 'summer', 'autumn', 'fall']¶
- year_with_context_check(text: str)¶
pyDeid.phi_types.EmailPHIFinder module¶
- class pyDeid.phi_types.EmailPHIFinder.EmailPHIFinder¶
Bases:
PHITypeFinder
Concrete implementation of PHITypeFinder for detecting email addresses.
- find() Dict[str, List[str]] ¶
Find phand return all occurrences of the PHI type in the given text.
pyDeid.phi_types.HospitalNamePHIFinder module¶
- class pyDeid.phi_types.HospitalNamePHIFinder.HospitalNamePHIFinder(hospitals: list[str], hospital_acronyms: list[str] = None)¶
Bases:
PHITypeFinder
Concrete implementation of PHITypeFinder for detecting hospital names and their acronyms.
- find() Dict[str, List[str]] ¶
Find phand return all occurrences of the PHI type in the given text.
pyDeid.phi_types.MrnPHIFinder module¶
- class pyDeid.phi_types.MrnPHIFinder.MrnPHIFinder¶
Bases:
PHITypeFinder
Concrete implementation of PHITypeFinder for detecting Medical Record Numbers (MRNs).
- find() Dict[str, List[str]] ¶
Find phand return all occurrences of the PHI type in the given text.
pyDeid.phi_types.NamesPHIFinder module¶
- class pyDeid.phi_types.NamesPHIFinder.NamesPHIFinder(config: Config = None)¶
Bases:
PHITypeFinder
Concrete implementation of PHITypeFinder for detecting names.
- class Config(female_names_unambig: List[str] = <factory>, male_names_unambig: List[str] = <factory>, all_first_names: List[str] = <factory>, last_names_unambig: List[str] = <factory>, all_last_names: List[str] = <factory>, doctor_first_names: List[str] = <factory>, doctor_last_names: List[str] = <factory>, female_names_ambig: List[str] = <factory>, male_names_ambig: List[str] = <factory>, last_names_ambig: List[str] = <factory>, female_names_popular: List[str] = <factory>, male_names_popular: List[str] = <factory>, last_names_popular: List[str] = <factory>, medical_phrases: List[str] = <factory>, custom_dr_first_names: List[str] = <factory>, custom_dr_last_names: List[str] = <factory>, custom_patient_first_names: List[str] = <factory>, custom_patient_last_names: List[str] = <factory>, prefixes_unambig: Set[str] = <factory>, last_name_prefixes: Set[str] = <factory>, ner_model: <built-in function any> = None, name_indicators: List[str] = <factory>, eponym_indicators: List[str] = <factory>)¶
Bases:
object
- all_first_names: List[str]¶
- all_last_names: List[str]¶
- custom_dr_first_names: List[str]¶
- custom_dr_last_names: List[str]¶
- custom_patient_first_names: List[str]¶
- custom_patient_last_names: List[str]¶
- doctor_first_names: List[str]¶
- doctor_last_names: List[str]¶
- eponym_indicators: List[str]¶
- female_names_ambig: List[str]¶
- female_names_popular: List[str]¶
- female_names_unambig: List[str]¶
- last_name_prefixes: Set[str]¶
- last_names_ambig: List[str]¶
- last_names_popular: List[str]¶
- last_names_unambig: List[str]¶
- male_names_ambig: List[str]¶
- male_names_popular: List[str]¶
- male_names_unambig: List[str]¶
- medical_phrases: List[str]¶
- name_indicators: List[str]¶
- ner_model: any = None¶
- prefixes_unambig: Set[str]¶
- find() Dict[str, List[str]] ¶
Find phand return all occurrences of the PHI type in the given text.
pyDeid.phi_types.OhipPHIFinder module¶
- class pyDeid.phi_types.OhipPHIFinder.OhipPHIFinder¶
Bases:
PHITypeFinder
Concrete implementation of PHITypeFinder for detecting OHIP numbers.
- find() Dict[str, List[str]] ¶
Find phand return all occurrences of the PHI type in the given text.
pyDeid.phi_types.PHITypeFinder module¶
pyDeid.phi_types.PostalCodePHIFinder module¶
- class pyDeid.phi_types.PostalCodePHIFinder.PostalCodePHIFinder¶
Bases:
PHITypeFinder
Concrete implementation of PHITypeFinder for detecting postal codes.
- find() Dict[str, List[str]] ¶
Find phand return all occurrences of the PHI type in the given text.
pyDeid.phi_types.SinPHIFinder module¶
- class pyDeid.phi_types.SinPHIFinder.SinPHIFinder¶
Bases:
PHITypeFinder
Concrete implementation of PHITypeFinder for detecting Canadian Social Insurance Numbers (SIN).
- find() Dict[str, List[str]] ¶
Find phand return all occurrences of the PHI type in the given text.
pyDeid.phi_types.TelephoneFaxPHIFinder module¶
- class pyDeid.phi_types.TelephoneFaxPHIFinder.TelephoneFaxPHIFinder(area_codes: List[str] = None, disqualifiers: List[str] = None)¶
Bases:
PHITypeFinder
Concrete implementation of PHITypeFinder for detecting telephone and fax numbers.
- find() Dict[str, List[str]] ¶
Find phand return all occurrences of the PHI type in the given text.
pyDeid.phi_types.utils module¶
- class pyDeid.phi_types.utils.CustomRegex(phi_type, pattern, surrogate_builder_fn, arguments)¶
Bases:
tuple
- arguments¶
Alias for field number 3
- pattern¶
Alias for field number 1
- phi_type¶
Alias for field number 0
- surrogate_builder_fn¶
Alias for field number 2
- class pyDeid.phi_types.utils.PHI(start, end, phi)¶
Bases:
tuple
- end¶
Alias for field number 1
- phi¶
Alias for field number 2
- start¶
Alias for field number 0
- pyDeid.phi_types.utils.add_phi_list(phi_list, phitype, phi)¶
- pyDeid.phi_types.utils.add_type(key, phitype, phi)¶
- pyDeid.phi_types.utils.create_custom_regex(phi_type, pattern, surrogate_builder_fn, arguments=[])¶
- pyDeid.phi_types.utils.is_ambig(key, phi)¶
- pyDeid.phi_types.utils.is_common(x)¶
- pyDeid.phi_types.utils.is_commonest(x)¶
- pyDeid.phi_types.utils.is_medical_eponym(x)¶
- pyDeid.phi_types.utils.is_name_indicator(x)¶
- pyDeid.phi_types.utils.is_probably_measurement(x)¶
- pyDeid.phi_types.utils.is_type(key: str, phitype: str, pattern: bool, phi)¶
- pyDeid.phi_types.utils.is_unambig_common(x)¶
- pyDeid.phi_types.utils.load_file(filename, optimization='lookup')¶
- pyDeid.phi_types.utils.merge_phi_dicts(phi1, phi2, in_place=True)¶
Merge phi2 into phi1. If in_place is True, modify phi1 directly. Otherwise, return a new dict and leave phi1 unmodified.
- pyDeid.phi_types.utils.phi_dict_to_list(x, phi)¶