medicaid_utils.adapted_algorithms.py_cdpsmrx package¶
Submodules¶
medicaid_utils.adapted_algorithms.py_cdpsmrx.cdps_rx_risk_adjustment module¶
- class medicaid_utils.adapted_algorithms.py_cdpsmrx.cdps_rx_risk_adjustment.CdpsRxRiskAdjustment[source]¶
Bases:
object- classmethod add_age_and_gender_cols(df: DataFrame) Tuple[DataFrame, List[str]][source]¶
Adds age & gender related covariates used in CDPS Rx Risk Adjustment model. Returns a dataframe with the below columns:
a_under1 - 0 or 1, age<=1
a_1_4 - 0 or 1, 1<age<5
a_5_14m - 0 or 1, 5<=age<15 male
a_5_14f - 0 or 1, 5<=age<15 female
a_15_24m - 0 or 1, 15<=age<25 male
a_15_24f - 0 or 1, 15<=age<25 female
a_25_44m - 0 or 1, 25<=age<45 male
a_25_44f - 0 or 1, 25<=age<45 female
a_45_64m - 0 or 1, 45<=age<65 male
a_45_64f - 0 or 1, 45<=age<65 female
a_65 - 0 or 1, 65<=age
- Parameters:
dask.DataFrame (df -)
- Returns:
dask.DataFrame
list of str – List of age and gender column names added.
Examples
>>> # Requires a dask DataFrame with 'Female' and 'age' columns >>> df, lst_cols = CdpsRxRiskAdjustment.add_age_and_gender_cols(df) >>> 'a_under1' in lst_cols True
- classmethod add_cdps_category_cols(df: DataFrame, lst_diag_cd_col_name: str) Tuple[DataFrame, List[str]][source]¶
Adds CDPS category columns
- Parameters:
df (dask.DataFrame) – PS Dataframe with LST_DIAG_CD column
lst_diag_cd_col_name (str)
- Returns:
dask.DataFrame
list of str – List of CDPS category column names added.
Examples
>>> # Requires a dask DataFrame with diagnosis code list and aid columns >>> df, lst_cols = CdpsRxRiskAdjustment.add_cdps_category_cols( ... df, 'LST_DIAG_CD')
- classmethod add_mrx_cat_cols(df: DataFrame, lst_ndc_col_name: str = 'LST_NDC') Tuple[DataFrame, List[str]][source]¶
Adds MRX category columns
- Parameters:
df (dask.DataFrame)
lst_ndc_col_name (str, default='LST_NDC')
- Returns:
dask.DataFrame
list of str – List of MRX category column names added.
Examples
>>> # Requires a dask DataFrame with an NDC code list column >>> df, lst_cols = CdpsRxRiskAdjustment.add_mrx_cat_cols( ... df, 'LST_NDC')
- classmethod calculate_risk(df: DataFrame, lst_cov: List[str], score_col_name: str = 'risk') DataFrame[source]¶
Calculates CDPS risk adjustment score. The returned dataframe has the following new columns:
risk - CDPS risk score, dtype: float64
- Parameters:
- Return type:
dask.DataFrame
Examples
>>> # Requires a dask DataFrame with covariate columns and aid column >>> df = CdpsRxRiskAdjustment.calculate_risk( ... df, lst_cov=['a_under1', 'a_1_4'], score_col_name='risk')
- classmethod combine_cdps_mrx_hierarchies(df: DataFrame) DataFrame[source]¶
Apply CDPS MRX hierarchical rollups
- Parameters:
df (dask.DataFrame)
- Return type:
dask.DataFrame
Examples
>>> # Requires a dask DataFrame with CDPS and MRX category columns >>> df = CdpsRxRiskAdjustment.combine_cdps_mrx_hierarchies(df)
- data_folder = '/home/runner/work/medicaid-utils/medicaid-utils/medicaid_utils/adapted_algorithms/py_cdpsmrx/data'¶
- filename = 'cdps_rx_risk_adjustment.py'¶
- package_folder = '/home/runner/work/medicaid-utils/medicaid-utils/medicaid_utils/adapted_algorithms/py_cdpsmrx'¶
- medicaid_utils.adapted_algorithms.py_cdpsmrx.cdps_rx_risk_adjustment.cdps_rx_risk_adjust(df: DataFrame, lst_diag_col_name: str = 'LST_DIAG_CD', lst_ndc_col_name: str = 'LST_NDC', score_col_name: str = 'risk') DataFrame[source]¶
Calculate CDPS MRX risk adjustment score. This function expects the input dataframe to be aggregated to patient level, with columns containing comma separated lists of diagnosis codes & NDC codes during the observed time period.
- Parameters:
df (dask.DataFrame) – BENE level Dataframe with diagnosis code & ndc_code list columns
lst_diag_col_name (str, default='LST_DIAG_CD') – Name of diagnosis code list column.
lst_ndc_col_name (str, default='LST_NDC') – Name of NDC code list column
score_col_name (str, default='risk') – CDPS MRX score output column name
- Return type:
dask.DataFrame
Examples
>>> # Requires a patient-level dask DataFrame with diagnosis and NDC columns >>> df = cdps_rx_risk_adjust(df, 'LST_DIAG_CD', 'LST_NDC')