Function
find_children
def find_children(database: str, code_list: sql.dataframe.DataFrame, only_children=False, added=False, code_desc=False) ‑> sql.dataframe.DataFrame
-
Description
The find_children function is used to quickly find all the child codes of a parent code so a user does not need to type all child codes out manually. The TriNetX standardized_terminology table contains all definitions of parent and child code relationships.
Inputs
-
database - database name to use
-
code_list - user defined table with 3 mandatory columns:
-
feature - the feature the exact code will roll up to and name of the column in the output dataframe (letters, numbers, underscores only, no spaces, not case sensitive)
-
code - parent or child code
-
code_system - ICD-10-CM, RxNorm, etc
-
code_system rules
-
patient: returns self (use month_year_death as the code value)
-
ICD-10-CM: returns children from ICD-10-CM and ICD-9-CM
-
ICD-9-CM: can only be a child, so returns itself
-
ICD-10-PCS: returns children from ICD-10-PCS and ICD-9-CM
-
CPT: returns children from CPT
-
HCPCS: returns children from HCPCS
-
SNOMEDCT_US: returns children from SNOMED
-
RxNorm: can only be a child, so returns self
-
VA: returns RxNorm children
-
ATC: returns RxNorm children
-
TNX: returns children of TNX rollups
-
LOINC: returns itself, parents are not supported (except for TNX labs)
-
Encounter Type: returns itself
-
-
-
optional columns
-
qualifier_num - the find_children function will populate the value within qualifier_num to all the children of that code
-
qualifier_text - the find_children function will populate the value within qualifier_text to all the children of that code
-
-
-
only_children (optional argument)
-
if True, returns only discovered child codes
-
if False, returns all codes, including original input
-
False by default
-
-
added (optional argument)
-
if True, the function returns an additional column named 'added' that is 0 if the code was present in the input and 1 if the code was not present in the input after find_children was run
-
if False, does nothing
-
False by default
-
-
code_desc (optional argument)
-
if True, the function returns an additional column named 'code_description' that populates the code_description value from the standardized_terminology table
-
if False, does nothing
-
False by default
-
Returns
-
a code list table with all children, same structure as the code_list input table, but with all the children that relate to the code
-
populates the feature value to the children code rows
Example
get_children = find_children(database='covid_db', code_list=code_list, only_children=False, added=True)
-