Skip to content

Commit

Permalink
add mapping for icu admit source, ref #14
Browse files Browse the repository at this point in the history
  • Loading branch information
alistairewj committed Dec 13, 2017
1 parent c362869 commit 3702563
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 4 deletions.
25 changes: 22 additions & 3 deletions anzics/load-data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@
"df['data_source'] = 'anzics'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"print([x for x in df.columns])"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -209,15 +220,23 @@
" 4: 'Unknown'\n",
"}\n",
"\n",
"# below is the original definition according to ANZICS\n",
"dict_icuadmit = {\n",
" 1: 'OT/Recovery',\n",
" 2: 'Accident & Emergency',\n",
" 3: 'Ward',\n",
" 4: 'Other ICU, same Hospital',\n",
" 5: 'Other Hospital',\n",
" 6: 'Other Hospital ICU'}\n",
"\n",
"\n",
"# we merge the above fields into a standard set\n",
"dict_icuadmit_gossis = {\n",
" 1: 'Operating Room / Recovery',\n",
" 2: 'Accident & Emergency',\n",
" 3: 'Floor', # was: Ward\n",
" 4: 'Other ICU', # was: 'Other ICU, same Hospital',\n",
" 5: 'Other Hospital',\n",
" 6: 'Other ICU' # was: 'Other Hospital ICU'\n",
"}\n",
"apsFcn = lambda x: x['albuminscore'] + x['bilirubinscore'] + x['creatininescore'] + \\\n",
"x['glucosescore'] + x['haematocritscore'] + x['heartratescore'] + x['meanarterialpressurescore'] + \\\n",
"x['sodiumscore'] + x['neurologicalscore'] + x['oxygenationscore'] + x['phscore'] + \\\n",
Expand Down Expand Up @@ -305,7 +324,7 @@
", ['hospital_disch_location', lambda x: x['hosp_outcm'].map(dict_hospoutcome)]\n",
", ['hospital_los_days', lambda x: x['hosp_hrs']/24.0]\n",
", ['hospital_death', lambda x: x['died_hosp'].map(dict_hospdied)]\n",
", ['icu_admit_source', lambda x: x['icu_srce'].map(dict_icuadmit)]\n",
", ['icu_admit_source', lambda x: x['icu_srce'].map(dict_icuadmit_gossis)]\n",
", ['icu_admit_type', None]\n",
", ['icu_disch_location', lambda x: x['icu_outcm'].map(dict_icuoutcome)]\n",
", ['pre_icu_los_days', lambda x: x['pre_icu_hrs']/24.0]\n",
Expand Down
33 changes: 32 additions & 1 deletion eicu/sql/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,38 @@ select
else null end as hospital_death


, pt.unitadmitsource as icu_admit_source
, case
when pt.unitadmitsource in
(
, 'Direct Admit'
, 'Emergency Department'
) then 'Accident & Emergency'
when pt.unitadmitsource in
(
'Operating Room'
, 'Recovery Room'
, 'PACU'
) then 'Operating Room / Recovery'
when pt.unitadmitsource in
(
'Acute Care/Floor'
, 'Chest Pain Center'
, 'Floor'
, 'Step-Down Unit (SDU)'
, 'Observation'
, 'Other'
) then 'Floor'
when pt.unitadmitsource in
(
'ICU'
, 'ICU to SDU'
, 'Other ICU'
) then 'Other ICU'
when pt.unitadmitsource in
(
'Other Hospital'
) then 'Other Hospital'
else null end as icu_admit_source
--, pt.unittype as icu_stay_type
, pt.unitdischargelocation as icu_disch_location
, -(pt.hospitaladmitoffset/60.0/24.0) as pre_icu_los_days
Expand Down

0 comments on commit 3702563

Please sign in to comment.