pyDeid.process_note package¶
Submodules¶
pyDeid.process_note.PHIFinder module¶
- class pyDeid.process_note.PHIFinder.PHIFinder(config: Config)¶
Bases:
object
A class representing all operations to find PHI values in a given note.
- Parameters:
custom_regexes (-) – These are named arguments that will be taken as regexes to be scrubbed from the given note. The keyword/argument name itself will be used to label the PHI in the phi_output. Note that all custom patterns will be replaced with <PHI>.
model (-) – The model loaded if named entity recognition (NER) is used
types (-) – Various PHIs we want to identify
- class Config(phi_types: List[str] = <factory>, custom_regexes: List[pyDeid.phi_types.utils.CustomRegex] = <factory>, two_digit_threshold: int = 30, valid_year_low: int = 1900, valid_year_high: int = 2050, 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>, ner_model: Any = None)¶
Bases:
object
- custom_dr_first_names: List[str]¶
- custom_dr_last_names: List[str]¶
- custom_patient_first_names: List[str]¶
- custom_patient_last_names: List[str]¶
- custom_regexes: List[CustomRegex]¶
- ner_model: Any = None¶
- phi_types: List[str]¶
- two_digit_threshold: int = 30¶
- valid_year_high: int = 2050¶
- valid_year_low: int = 1900¶
- find_phi(row_from_mll=None) Dict[PHI, List[str]] ¶
Returns mutated PHI object containing PHIs of various types identified from the note
- set_note(new_note: str) None ¶
- set_phis(new_phis) None ¶
pyDeid.process_note.PHIHandler module¶
- class pyDeid.process_note.PHIHandler.PHIHandler(regex_replace=True, mll_rows={})¶
Bases:
object
Responsible for managing the current the current note and associated PHIs.
Manages relationship between find, prune and replace operations for the current note
- handle_csv_row(row: Dict[str, str], errors: List[str], encounter_id_varname: str = 'genc_id', note_id_varname: str = None, note_varname: str = 'note_text') Tuple[int, int, List[str]] ¶
Handle the note - with find, prune, and replace
- handle_string(note: str, row_from_mll: str = None) Tuple[List[Dict[str, str]], str] ¶
- set_finder(finder)¶
- set_note(new_note: str) None ¶
- set_phis(new_phis) None ¶
- set_pruner(pruner)¶
- set_replacer(replacer=None)¶
pyDeid.process_note.PHIPruner module¶
- class pyDeid.process_note.PHIPruner.PHIPruner¶
Bases:
object
A class representing all operations required to prune the PHIs for a given note
- prune_phi() Dict[PHI, List[str]] ¶
Returns mutated PHI object containing a reduced set of PHIs after removing paradoxes and redundencies among the PHIs that exist from the note
- set_note(new_note: str) None ¶
- set_phis(new_phis) None ¶
pyDeid.process_note.PHIReplacer module¶
- class pyDeid.process_note.PHIReplacer.PHIReplacer(return_surrogates=False)¶
Bases:
object
Handles replacement of PHI values with surrogate values.
- load_phi_types(finder)¶
- replace_phi()¶
Replaces PHI in the text with surrogate values, ensuring no overlapping replacements.
- set_note(new_note: str) None ¶
- set_phis(new_phis) None ¶