{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "clinical_codes.ipynb",
"provenance": [],
"authorship_tag": "ABX9TyOfVne59Pd6mKkj2ylQyFCz",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"
"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "5yhDXmRSs1es",
"colab_type": "text"
},
"source": [
"# Overview # \n",
"\n",
"Below provides code snippets for using the H-CUP package [(Healthcare Cost and Utilization Project)](https://github.com/yubin-park/hcuppy) that allows you to...\n",
"- interpretting clinical codes\n",
"- calculating the Elixhauser Comorbidity Index \n",
"- ..."
]
},
{
"cell_type": "code",
"metadata": {
"id": "KuvZ7_iGoeBg",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 109
},
"outputId": "31c7453b-b670-4dfe-8de0-da603840f9cf"
},
"source": [
"! pip install hcuppy\n",
"\n",
"from hcuppy.prcls import PrClsEngine\n",
"pce = PrClsEngine()\n"
],
"execution_count": 2,
"outputs": [
{
"output_type": "stream",
"text": [
"Collecting hcuppy\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/da/50/90a7a6b85202281ad4c63fbf03022dedbed8f45ceddfde7c2edb22e3d33d/hcuppy-0.0.7-py3-none-any.whl (2.4MB)\n",
"\u001b[K |████████████████████████████████| 2.4MB 2.4MB/s \n",
"\u001b[?25hInstalling collected packages: hcuppy\n",
"Successfully installed hcuppy-0.0.7\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "ili1_E-cu47q",
"colab_type": "text"
},
"source": [
"## A) Query CCS codes ##"
]
},
{
"cell_type": "code",
"metadata": {
"id": "p_pe8ZeNorLt",
"colab_type": "code",
"colab": {}
},
"source": [
"from hcuppy.ccs import CCSEngine\n",
"ce = CCSEngine(mode=\"dx\")\n",
"\n",
"out = ce.get_ccs([\"E119\", \"I10\"])"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "tG7kjI64otRv",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 238
},
"outputId": "8898fab4-ab67-4091-9a24-4e9fc343c22b"
},
"source": [
"import pandas as pd\n",
"\n",
"df=pd.DataFrame( out )\n",
"df.head(5).transpose()\n"
],
"execution_count": 7,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" 0 | \n",
" 1 | \n",
"
\n",
" \n",
" \n",
" \n",
" ccs | \n",
" 49 | \n",
" 98 | \n",
"
\n",
" \n",
" ccs_desc | \n",
" Diabetes mellitus without complication | \n",
" Essential hypertension | \n",
"
\n",
" \n",
" ccs_lv1 | \n",
" 3 | \n",
" 7 | \n",
"
\n",
" \n",
" ccs_lv1_desc | \n",
" Endocrine; nutritional; and metabolic diseases... | \n",
" Diseases of the circulatory system | \n",
"
\n",
" \n",
" ccs_lv2 | \n",
" 3.2 | \n",
" 7.1 | \n",
"
\n",
" \n",
" ccs_lv2_desc | \n",
" Diabetes mellitus without complication [49.] | \n",
" Hypertension | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" 0 1\n",
"ccs 49 98\n",
"ccs_desc Diabetes mellitus without complication Essential hypertension\n",
"ccs_lv1 3 7\n",
"ccs_lv1_desc Endocrine; nutritional; and metabolic diseases... Diseases of the circulatory system\n",
"ccs_lv2 3.2 7.1\n",
"ccs_lv2_desc Diabetes mellitus without complication [49.] Hypertension"
]
},
"metadata": {
"tags": []
},
"execution_count": 7
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "bHnCIQLyu-fb",
"colab_type": "text"
},
"source": [
"## B) Query procedural codes ##"
]
},
{
"cell_type": "code",
"metadata": {
"id": "mKQLtoh4oxwi",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 112
},
"outputId": "44354acf-dbf6-4d0e-e1d4-bb791f03f46c"
},
"source": [
"from hcuppy.prcls import PrClsEngine\n",
"pce = PrClsEngine()\n",
"out2 = pce.get_prcls([\"B231Y0Z\"])\n",
"\n",
"df2=pd.DataFrame( out2 )\n",
"\n",
"df2.head(5).transpose()"
],
"execution_count": 12,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" 0 | \n",
" 1 | \n",
"
\n",
" \n",
" \n",
" \n",
" class | \n",
" 1 | \n",
" na | \n",
"
\n",
" \n",
" desc | \n",
" Minor Diagnostic | \n",
" na | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" 0 1\n",
"class 1 na\n",
"desc Minor Diagnostic na"
]
},
"metadata": {
"tags": []
},
"execution_count": 12
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "RxxHSZupvGvU",
"colab_type": "text"
},
"source": [
"## C) Calculate scores given certain codes ##"
]
},
{
"cell_type": "code",
"metadata": {
"id": "G00Y_GUUu3BK",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 72
},
"outputId": "32d730ed-a1f2-449c-e2f6-255a9ceed08d"
},
"source": [
"from hcuppy.elixhauser import ElixhauserEngine\n",
"ee = ElixhauserEngine()\n",
"out = ee.get_elixhauser([\"E119\", \"E108\", \"I10\", \"I110\", \"Z944\"])\n",
"\n",
"out"
],
"execution_count": 14,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"{'cmrbdt_lst': ['DMCX', 'LIVER', 'HTNCX', 'CHF'],\n",
" 'mrtlt_scr': 9,\n",
" 'rdmsn_scr': 31}"
]
},
"metadata": {
"tags": []
},
"execution_count": 14
}
]
}
]
}