external-link R functions

trinetx.clean_feature API documentation

Function clean_feature

def clean_feature(code_list: sql.dataframe.DataFrame) ‑> sql.dataframe.DataFrame

Description


The clean_feature functions quickly converts all of the feature names (variables) of your code list into feature names that are compatible with Lucid functions.

Inputs


  • code_list - user defined table with 1 mandatory column:

    • 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)

    • optional columns

      • code - parent or child code

      • code_system - ICD-10-CM, RxNorm, etc

      • qualifier_num - numeric qualifier

      • qualifier_text - text qualifier

Returns


  • a spark dataframe that contains all of the up to 5 columns allowed to be used in the code_list input, plus a new column called feature and the column the user calls feature in the input table is returned as feature_old

  • any spaces in any of the values of the feature column are replaced with an underscore (_) in the feature column

  • all letters of the feature column are forced to lowercase in the feature column

  • strip anything in the feature column that is not a number or letter

  • trim all leading & trailing spaces

Example


code list:

| feature         | code     | code_system |
|-----------------|----------|-------------|
| Lung Transplant | T86.81   | ICD-10-CM   |
| Lung Transplant | Z48.24   | ICD-10-CM   |
| Lung Transplant | Z94.2    | ICD-10-CM   |
| Lung Transplant | T86.81   | ICD-10-CM   |
| Lung Transplant | 1006036  | CPT         |
| Lung Transplant | 88039007 | CPT         |

example = tnx.clean_feature(code_list)

example.head()

| feature         | feature_old     | code     | code_system |
|-----------------|-----------------|----------|-------------|
| lung_transplant | Lung Transplant | T86.81   | ICD-10-CM   |
| lung_transplant | Lung Transplant | Z48.24   | ICD-10-CM   |
| lung_transplant | Lung Transplant | Z94.2    | ICD-10-CM   |
| lung_transplant | Lung Transplant | T86.81   | ICD-10-CM   |
| lung_transplant | Lung Transplant | 1006036  | CPT         |
| lung_transplant | Lung Transplant | 88039007 | CPT         |