a b/vital_signs.ipynb
1
{
2
 "cells": [
3
  {
4
   "cell_type": "code",
5
   "execution_count": 2,
6
   "id": "a570f68c-d378-4716-b1ff-1b50f4acd8a3",
7
   "metadata": {},
8
   "outputs": [],
9
   "source": [
10
    "filepath = './data/csv/observations.csv'"
11
   ]
12
  },
13
  {
14
   "cell_type": "code",
15
   "execution_count": 3,
16
   "id": "f717307c-ddd5-4e7e-9e7f-440b2b009835",
17
   "metadata": {},
18
   "outputs": [],
19
   "source": [
20
    "import pandas as pd"
21
   ]
22
  },
23
  {
24
   "cell_type": "code",
25
   "execution_count": 4,
26
   "id": "833a7f9c-d3a1-4743-ae12-602576e92ce2",
27
   "metadata": {},
28
   "outputs": [],
29
   "source": [
30
    "df = pd.read_csv(filepath)"
31
   ]
32
  },
33
  {
34
   "cell_type": "code",
35
   "execution_count": 5,
36
   "id": "33ea73db-da7a-4621-9910-c646c0271a6f",
37
   "metadata": {},
38
   "outputs": [
39
    {
40
     "name": "stdout",
41
     "output_type": "stream",
42
     "text": [
43
      "<class 'pandas.core.frame.DataFrame'>\n",
44
      "RangeIndex: 20742 entries, 0 to 20741\n",
45
      "Data columns (total 9 columns):\n",
46
      " #   Column       Non-Null Count  Dtype \n",
47
      "---  ------       --------------  ----- \n",
48
      " 0   DATE         20742 non-null  object\n",
49
      " 1   PATIENT      20742 non-null  object\n",
50
      " 2   ENCOUNTER    19194 non-null  object\n",
51
      " 3   CATEGORY     19194 non-null  object\n",
52
      " 4   CODE         20742 non-null  object\n",
53
      " 5   DESCRIPTION  20742 non-null  object\n",
54
      " 6   VALUE        20742 non-null  object\n",
55
      " 7   UNITS        14744 non-null  object\n",
56
      " 8   TYPE         20742 non-null  object\n",
57
      "dtypes: object(9)\n",
58
      "memory usage: 1.4+ MB\n"
59
     ]
60
    }
61
   ],
62
   "source": [
63
    "df.info()"
64
   ]
65
  },
66
  {
67
   "cell_type": "code",
68
   "execution_count": 6,
69
   "id": "9b2aae31-6744-448e-bf8a-385dc52fac8c",
70
   "metadata": {},
71
   "outputs": [
72
    {
73
     "data": {
74
      "text/plain": [
75
       "array(['vital-signs', 'social-history', 'survey', 'laboratory', nan,\n",
76
       "       'exam', 'procedure'], dtype=object)"
77
      ]
78
     },
79
     "execution_count": 6,
80
     "metadata": {},
81
     "output_type": "execute_result"
82
    }
83
   ],
84
   "source": [
85
    "df[\"CATEGORY\"].unique()"
86
   ]
87
  },
88
  {
89
   "cell_type": "code",
90
   "execution_count": 7,
91
   "id": "7c14585b-e91a-4467-87c3-dbb82ae24857",
92
   "metadata": {},
93
   "outputs": [],
94
   "source": [
95
    "def isnumber(num):\n",
96
    "    try:\n",
97
    "        float(num)\n",
98
    "        return True\n",
99
    "    except ValueError:\n",
100
    "        return False"
101
   ]
102
  },
103
  {
104
   "cell_type": "code",
105
   "execution_count": 12,
106
   "id": "d096f972-5cbe-434b-a640-6d77fcb76b2c",
107
   "metadata": {},
108
   "outputs": [],
109
   "source": [
110
    "df = df[df[\"VALUE\"].apply(lambda x: isnumber(x))]"
111
   ]
112
  },
113
  {
114
   "cell_type": "code",
115
   "execution_count": null,
116
   "id": "e27de5af-ffc1-473c-a4b4-514b38a4feb3",
117
   "metadata": {},
118
   "outputs": [],
119
   "source": []
120
  },
121
  {
122
   "cell_type": "code",
123
   "execution_count": 14,
124
   "id": "ecafbe81-3d34-40dc-b670-4ee6a507fda5",
125
   "metadata": {},
126
   "outputs": [
127
    {
128
     "name": "stdout",
129
     "output_type": "stream",
130
     "text": [
131
      "<class 'pandas.core.frame.DataFrame'>\n",
132
      "Int64Index: 18 entries, 0 to 13685\n",
133
      "Data columns (total 2 columns):\n",
134
      " #   Column       Non-Null Count  Dtype \n",
135
      "---  ------       --------------  ----- \n",
136
      " 0   DESCRIPTION  18 non-null     object\n",
137
      " 1   UNITS        18 non-null     object\n",
138
      "dtypes: object(2)\n",
139
      "memory usage: 432.0+ bytes\n"
140
     ]
141
    }
142
   ],
143
   "source": [
144
    "df[df[\"CATEGORY\"] == 'vital-signs'][['DESCRIPTION', 'UNITS']].drop_duplicates().info()"
145
   ]
146
  },
147
  {
148
   "cell_type": "code",
149
   "execution_count": 18,
150
   "id": "dfb869f3-ec6e-4484-8ddb-93b913fd7dfd",
151
   "metadata": {},
152
   "outputs": [
153
    {
154
     "data": {
155
      "text/html": [
156
       "<div>\n",
157
       "<style scoped>\n",
158
       "    .dataframe tbody tr th:only-of-type {\n",
159
       "        vertical-align: middle;\n",
160
       "    }\n",
161
       "\n",
162
       "    .dataframe tbody tr th {\n",
163
       "        vertical-align: top;\n",
164
       "    }\n",
165
       "\n",
166
       "    .dataframe thead th {\n",
167
       "        text-align: right;\n",
168
       "    }\n",
169
       "</style>\n",
170
       "<table border=\"1\" class=\"dataframe\">\n",
171
       "  <thead>\n",
172
       "    <tr style=\"text-align: right;\">\n",
173
       "      <th></th>\n",
174
       "      <th>DATE</th>\n",
175
       "      <th>PATIENT</th>\n",
176
       "      <th>ENCOUNTER</th>\n",
177
       "      <th>CATEGORY</th>\n",
178
       "      <th>CODE</th>\n",
179
       "      <th>DESCRIPTION</th>\n",
180
       "      <th>VALUE</th>\n",
181
       "      <th>UNITS</th>\n",
182
       "      <th>TYPE</th>\n",
183
       "    </tr>\n",
184
       "  </thead>\n",
185
       "  <tbody>\n",
186
       "    <tr>\n",
187
       "      <th>19203</th>\n",
188
       "      <td>2021-05-18T06:00:31Z</td>\n",
189
       "      <td>ba193b51-efb6-4323-51df-db3877751e4b</td>\n",
190
       "      <td>61df5560-7382-462b-7b98-23c1ef382ed7</td>\n",
191
       "      <td>laboratory</td>\n",
192
       "      <td>20454-5</td>\n",
193
       "      <td>Protein [Presence] in Urine by Test strip</td>\n",
194
       "      <td>1.0</td>\n",
195
       "      <td>{presence}</td>\n",
196
       "      <td>numeric</td>\n",
197
       "    </tr>\n",
198
       "  </tbody>\n",
199
       "</table>\n",
200
       "</div>"
201
      ],
202
      "text/plain": [
203
       "                       DATE                               PATIENT  \\\n",
204
       "19203  2021-05-18T06:00:31Z  ba193b51-efb6-4323-51df-db3877751e4b   \n",
205
       "\n",
206
       "                                  ENCOUNTER    CATEGORY     CODE  \\\n",
207
       "19203  61df5560-7382-462b-7b98-23c1ef382ed7  laboratory  20454-5   \n",
208
       "\n",
209
       "                                     DESCRIPTION VALUE       UNITS     TYPE  \n",
210
       "19203  Protein [Presence] in Urine by Test strip   1.0  {presence}  numeric  "
211
      ]
212
     },
213
     "execution_count": 18,
214
     "metadata": {},
215
     "output_type": "execute_result"
216
    }
217
   ],
218
   "source": [
219
    "df[df[\"DESCRIPTION\"] == 'Protein [Presence] in Urine by Test strip']"
220
   ]
221
  },
222
  {
223
   "cell_type": "code",
224
   "execution_count": 19,
225
   "id": "bf60d2a8-252f-4bcc-82d5-8a5265d67b9b",
226
   "metadata": {
227
    "tags": []
228
   },
229
   "outputs": [
230
    {
231
     "data": {
232
      "text/plain": [
233
       "[{'DESCRIPTION': 'Glucose', 'UNITS': 'mg/dL'},\n",
234
       " {'DESCRIPTION': 'Urea Nitrogen', 'UNITS': 'mg/dL'},\n",
235
       " {'DESCRIPTION': 'Creatinine', 'UNITS': 'mg/dL'},\n",
236
       " {'DESCRIPTION': 'Calcium', 'UNITS': 'mg/dL'},\n",
237
       " {'DESCRIPTION': 'Sodium', 'UNITS': 'mmol/L'},\n",
238
       " {'DESCRIPTION': 'Potassium', 'UNITS': 'mmol/L'},\n",
239
       " {'DESCRIPTION': 'Chloride', 'UNITS': 'mmol/L'},\n",
240
       " {'DESCRIPTION': 'Carbon Dioxide', 'UNITS': 'mmol/L'},\n",
241
       " {'DESCRIPTION': 'Total Cholesterol', 'UNITS': 'mg/dL'},\n",
242
       " {'DESCRIPTION': 'Triglycerides', 'UNITS': 'mg/dL'},\n",
243
       " {'DESCRIPTION': 'Low Density Lipoprotein Cholesterol', 'UNITS': 'mg/dL'},\n",
244
       " {'DESCRIPTION': 'High Density Lipoprotein Cholesterol', 'UNITS': 'mg/dL'},\n",
245
       " {'DESCRIPTION': 'Hemoglobin A1c/Hemoglobin.total in Blood', 'UNITS': '%'},\n",
246
       " {'DESCRIPTION': 'Leukocytes [#/volume] in Blood by Automated count',\n",
247
       "  'UNITS': '10*3/uL'},\n",
248
       " {'DESCRIPTION': 'Erythrocytes [#/volume] in Blood by Automated count',\n",
249
       "  'UNITS': '10*6/uL'},\n",
250
       " {'DESCRIPTION': 'Hemoglobin [Mass/volume] in Blood', 'UNITS': 'g/dL'},\n",
251
       " {'DESCRIPTION': 'Hematocrit [Volume Fraction] of Blood by Automated count',\n",
252
       "  'UNITS': '%'},\n",
253
       " {'DESCRIPTION': 'MCV [Entitic volume] by Automated count', 'UNITS': 'fL'},\n",
254
       " {'DESCRIPTION': 'MCH [Entitic mass] by Automated count', 'UNITS': 'pg'},\n",
255
       " {'DESCRIPTION': 'MCHC [Mass/volume] by Automated count', 'UNITS': 'g/dL'},\n",
256
       " {'DESCRIPTION': 'Erythrocyte distribution width [Entitic volume] by Automated count',\n",
257
       "  'UNITS': 'fL'},\n",
258
       " {'DESCRIPTION': 'Platelets [#/volume] in Blood by Automated count',\n",
259
       "  'UNITS': '10*3/uL'},\n",
260
       " {'DESCRIPTION': 'Platelet distribution width [Entitic volume] in Blood by Automated count',\n",
261
       "  'UNITS': 'fL'},\n",
262
       " {'DESCRIPTION': 'Platelet mean volume [Entitic volume] in Blood by Automated count',\n",
263
       "  'UNITS': 'fL'},\n",
264
       " {'DESCRIPTION': 'Glomerular filtration rate/1.73 sq M.predicted',\n",
265
       "  'UNITS': 'mL/min'},\n",
266
       " {'DESCRIPTION': 'Glucose [Mass/volume] in Urine by Test strip',\n",
267
       "  'UNITS': 'mg/dL'},\n",
268
       " {'DESCRIPTION': 'Bilirubin.total [Mass/volume] in Urine by Test strip',\n",
269
       "  'UNITS': 'mg/dL'},\n",
270
       " {'DESCRIPTION': 'Ketones [Mass/volume] in Urine by Test strip',\n",
271
       "  'UNITS': 'mg/dL'},\n",
272
       " {'DESCRIPTION': 'Specific gravity of Urine by Test strip',\n",
273
       "  'UNITS': '{nominal}'},\n",
274
       " {'DESCRIPTION': 'pH of Urine by Test strip', 'UNITS': 'pH'},\n",
275
       " {'DESCRIPTION': 'Protein [Mass/volume] in Urine by Test strip',\n",
276
       "  'UNITS': 'mg/dL'},\n",
277
       " {'DESCRIPTION': 'Erythrocyte distribution width [Ratio] by Automated count',\n",
278
       "  'UNITS': '%'},\n",
279
       " {'DESCRIPTION': 'Neutrophils/100 leukocytes in Blood by Automated count',\n",
280
       "  'UNITS': '%'},\n",
281
       " {'DESCRIPTION': 'Lymphocytes/100 leukocytes in Blood by Automated count',\n",
282
       "  'UNITS': '%'},\n",
283
       " {'DESCRIPTION': 'Monocytes/100 leukocytes in Blood by Automated count',\n",
284
       "  'UNITS': '%'},\n",
285
       " {'DESCRIPTION': 'Eosinophils/100 leukocytes in Blood by Automated count',\n",
286
       "  'UNITS': '%'},\n",
287
       " {'DESCRIPTION': 'Basophils/100 leukocytes in Blood by Automated count',\n",
288
       "  'UNITS': '%'},\n",
289
       " {'DESCRIPTION': 'Neutrophils [#/volume] in Blood by Automated count',\n",
290
       "  'UNITS': '10*3/uL'},\n",
291
       " {'DESCRIPTION': 'Lymphocytes [#/volume] in Blood by Automated count',\n",
292
       "  'UNITS': '10*3/uL'},\n",
293
       " {'DESCRIPTION': 'Monocytes [#/volume] in Blood by Automated count',\n",
294
       "  'UNITS': '10*3/uL'},\n",
295
       " {'DESCRIPTION': 'Eosinophils [#/volume] in Blood by Automated count',\n",
296
       "  'UNITS': '10*3/uL'},\n",
297
       " {'DESCRIPTION': 'Basophils [#/volume] in Blood by Automated count',\n",
298
       "  'UNITS': '10*3/uL'},\n",
299
       " {'DESCRIPTION': 'Glucose [Mass/volume] in Serum or Plasma', 'UNITS': 'mg/dL'},\n",
300
       " {'DESCRIPTION': 'Urea nitrogen [Mass/volume] in Serum or Plasma',\n",
301
       "  'UNITS': 'mg/dL'},\n",
302
       " {'DESCRIPTION': 'Creatinine [Mass/volume] in Serum or Plasma',\n",
303
       "  'UNITS': 'mg/dL'},\n",
304
       " {'DESCRIPTION': 'Calcium [Mass/volume] in Serum or Plasma', 'UNITS': 'mg/dL'},\n",
305
       " {'DESCRIPTION': 'Sodium [Moles/volume] in Serum or Plasma',\n",
306
       "  'UNITS': 'mmol/L'},\n",
307
       " {'DESCRIPTION': 'Potassium [Moles/volume] in Serum or Plasma',\n",
308
       "  'UNITS': 'mmol/L'},\n",
309
       " {'DESCRIPTION': 'Chloride [Moles/volume] in Serum or Plasma',\n",
310
       "  'UNITS': 'mmol/L'},\n",
311
       " {'DESCRIPTION': 'Carbon dioxide  total [Moles/volume] in Serum or Plasma',\n",
312
       "  'UNITS': 'mmol/L'},\n",
313
       " {'DESCRIPTION': 'Protein [Mass/volume] in Serum or Plasma', 'UNITS': 'g/dL'},\n",
314
       " {'DESCRIPTION': 'Albumin [Mass/volume] in Serum or Plasma', 'UNITS': 'g/dL'},\n",
315
       " {'DESCRIPTION': 'Bilirubin.total [Mass/volume] in Serum or Plasma',\n",
316
       "  'UNITS': 'mg/dL'},\n",
317
       " {'DESCRIPTION': 'Alkaline phosphatase [Enzymatic activity/volume] in Serum or Plasma',\n",
318
       "  'UNITS': 'U/L'},\n",
319
       " {'DESCRIPTION': 'Alanine aminotransferase [Enzymatic activity/volume] in Serum or Plasma',\n",
320
       "  'UNITS': 'U/L'},\n",
321
       " {'DESCRIPTION': 'Aspartate aminotransferase [Enzymatic activity/volume] in Serum or Plasma',\n",
322
       "  'UNITS': 'U/L'},\n",
323
       " {'DESCRIPTION': 'Fibrin D-dimer FEU [Mass/volume] in Platelet poor plasma',\n",
324
       "  'UNITS': 'ug/mL'},\n",
325
       " {'DESCRIPTION': 'Ferritin [Mass/volume] in Serum or Plasma', 'UNITS': 'ug/L'},\n",
326
       " {'DESCRIPTION': 'Troponin I.cardiac [Mass/volume] in Serum or Plasma by High sensitivity method',\n",
327
       "  'UNITS': 'pg/mL'},\n",
328
       " {'DESCRIPTION': 'Lactate dehydrogenase [Enzymatic activity/volume] in Serum or Plasma by Lactate to pyruvate reaction',\n",
329
       "  'UNITS': 'U/L'},\n",
330
       " {'DESCRIPTION': 'Creatine kinase [Enzymatic activity/volume] in Serum or Plasma',\n",
331
       "  'UNITS': 'U/L'},\n",
332
       " {'DESCRIPTION': 'C reactive protein [Mass/volume] in Serum or Plasma',\n",
333
       "  'UNITS': 'mg/L'},\n",
334
       " {'DESCRIPTION': 'Prothrombin time (PT)', 'UNITS': 's'},\n",
335
       " {'DESCRIPTION': 'INR in Platelet poor plasma by Coagulation assay',\n",
336
       "  'UNITS': '{INR}'},\n",
337
       " {'DESCRIPTION': 'Procalcitonin [Mass/volume] in Serum or Plasma',\n",
338
       "  'UNITS': 'ng/mL'},\n",
339
       " {'DESCRIPTION': 'NT-proBNP', 'UNITS': 'pg/mL'},\n",
340
       " {'DESCRIPTION': 'Magnesium [Mass/volume] in Serum or Plasma',\n",
341
       "  'UNITS': 'mg/dL'},\n",
342
       " {'DESCRIPTION': 'Iron [Mass/volume] in Serum or Plasma', 'UNITS': 'ug/dL'},\n",
343
       " {'DESCRIPTION': 'Iron binding capacity [Mass/volume] in Serum or Plasma',\n",
344
       "  'UNITS': 'ug/dL'},\n",
345
       " {'DESCRIPTION': 'Iron saturation [Mass Fraction] in Serum or Plasma',\n",
346
       "  'UNITS': '%'},\n",
347
       " {'DESCRIPTION': 'Left ventricular Ejection fraction', 'UNITS': '%'},\n",
348
       " {'DESCRIPTION': 'Hematocrit [Volume Fraction] of Blood', 'UNITS': '%'},\n",
349
       " {'DESCRIPTION': 'WBC Auto (Bld) [#/Vol]', 'UNITS': '10*3/uL'},\n",
350
       " {'DESCRIPTION': 'RBC Auto (Bld) [#/Vol]', 'UNITS': '10*6/uL'},\n",
351
       " {'DESCRIPTION': 'RDW - Erythrocyte distribution width Auto (RBC) [Entitic vol]',\n",
352
       "  'UNITS': 'fL'},\n",
353
       " {'DESCRIPTION': 'Globulin [Mass/volume] in Serum by calculation',\n",
354
       "  'UNITS': 'g/L'},\n",
355
       " {'DESCRIPTION': 'Hemoglobin.gastrointestinal [Presence] in Stool by Immunologic method',\n",
356
       "  'UNITS': 'ng/mL'},\n",
357
       " {'DESCRIPTION': 'Microalbumin Creatinine Ratio', 'UNITS': 'mg/g'},\n",
358
       " {'DESCRIPTION': 'Estimated Glomerular Filtration Rate',\n",
359
       "  'UNITS': 'mL/min/{1.73_m2}'},\n",
360
       " {'DESCRIPTION': 'Peanut IgE Ab in Serum', 'UNITS': 'kU/L'},\n",
361
       " {'DESCRIPTION': 'Walnut IgE Ab in Serum', 'UNITS': 'kU/L'},\n",
362
       " {'DESCRIPTION': 'Codfish IgE Ab in Serum', 'UNITS': 'kU/L'},\n",
363
       " {'DESCRIPTION': 'Shrimp IgE Ab in Serum', 'UNITS': 'kU/L'},\n",
364
       " {'DESCRIPTION': 'Wheat IgE Ab in Serum', 'UNITS': 'kU/L'},\n",
365
       " {'DESCRIPTION': 'Egg white IgE Ab in Serum', 'UNITS': 'kU/L'},\n",
366
       " {'DESCRIPTION': 'Soybean IgE Ab in Serum', 'UNITS': 'kU/L'},\n",
367
       " {'DESCRIPTION': 'Cow milk IgE Ab in Serum', 'UNITS': 'kU/L'},\n",
368
       " {'DESCRIPTION': 'White oak IgE Ab in Serum', 'UNITS': 'kU/L'},\n",
369
       " {'DESCRIPTION': 'Common Ragweed IgE Ab in Serum', 'UNITS': 'kU/L'},\n",
370
       " {'DESCRIPTION': 'Cat dander IgE Ab in Serum', 'UNITS': 'kU/L'},\n",
371
       " {'DESCRIPTION': 'American house dust mite IgE Ab in Serum', 'UNITS': 'kU/L'},\n",
372
       " {'DESCRIPTION': 'Cladosporium herbarum IgE Ab in Serum', 'UNITS': 'kU/L'},\n",
373
       " {'DESCRIPTION': 'Honey bee IgE Ab in Serum', 'UNITS': 'kU/L'},\n",
374
       " {'DESCRIPTION': 'Latex IgE Ab in Serum', 'UNITS': 'kU/L'},\n",
375
       " {'DESCRIPTION': 'Lactate [Moles/volume] in Blood', 'UNITS': 'mmol/L'},\n",
376
       " {'DESCRIPTION': 'Diastolic Blood Pressure', 'UNITS': 'mm[Hg]'},\n",
377
       " {'DESCRIPTION': 'Magnesium [Mass/volume] in Blood', 'UNITS': 'mg/dL'},\n",
378
       " {'DESCRIPTION': 'aPTT in Blood by Coagulation assay', 'UNITS': 's'},\n",
379
       " {'DESCRIPTION': 'Troponin I.cardiac [Mass/volume] in Serum or Plasma by High sensitivity method',\n",
380
       "  'UNITS': 'ng/L'},\n",
381
       " {'DESCRIPTION': 'Phosphate [Mass/volume] in Serum or Plasma',\n",
382
       "  'UNITS': 'mg/dL'},\n",
383
       " {'DESCRIPTION': 'pH of Arterial blood', 'UNITS': '[pH]'},\n",
384
       " {'DESCRIPTION': 'Carbon dioxide [Partial pressure] in Arterial blood',\n",
385
       "  'UNITS': 'mm[Hg]'},\n",
386
       " {'DESCRIPTION': 'Oxygen [Partial pressure] in Arterial blood',\n",
387
       "  'UNITS': 'mm[Hg]'},\n",
388
       " {'DESCRIPTION': 'Bicarbonate [Moles/volume] in Arterial blood',\n",
389
       "  'UNITS': 'mmol/L'},\n",
390
       " {'DESCRIPTION': 'Activated clotting time (ACT) of Blood by Coagulation assay',\n",
391
       "  'UNITS': 's'},\n",
392
       " {'DESCRIPTION': 'pH of Venous blood', 'UNITS': '[pH]'},\n",
393
       " {'DESCRIPTION': 'Carbon dioxide [Partial pressure] in Venous blood',\n",
394
       "  'UNITS': 'mm[Hg]'},\n",
395
       " {'DESCRIPTION': 'Oxygen [Partial pressure] in Venous blood',\n",
396
       "  'UNITS': 'mm[Hg]'},\n",
397
       " {'DESCRIPTION': 'Bicarbonate [Moles/volume] in Venous blood',\n",
398
       "  'UNITS': 'mmol/L'},\n",
399
       " {'DESCRIPTION': 'Carbon dioxide  total [Moles/volume] in Venous blood',\n",
400
       "  'UNITS': 'mmol/L'},\n",
401
       " {'DESCRIPTION': 'Thyrotropin [Units/volume] in Serum or Plasma',\n",
402
       "  'UNITS': 'm[IU]/L'},\n",
403
       " {'DESCRIPTION': 'Glucose [Presence] in Urine by Test strip',\n",
404
       "  'UNITS': '{presence}'},\n",
405
       " {'DESCRIPTION': 'Bilirubin.total [Presence] in Urine by Test strip',\n",
406
       "  'UNITS': '{presence}'},\n",
407
       " {'DESCRIPTION': 'Ketones [Presence] in Urine by Test strip',\n",
408
       "  'UNITS': '{presence}'},\n",
409
       " {'DESCRIPTION': 'Specific gravity of Urine by Test strip', 'UNITS': '{SG}'},\n",
410
       " {'DESCRIPTION': 'pH of Urine by Test strip', 'UNITS': '[pH]'},\n",
411
       " {'DESCRIPTION': 'Protein [Presence] in Urine by Test strip',\n",
412
       "  'UNITS': '{presence}'},\n",
413
       " {'DESCRIPTION': 'Nitrite [Presence] in Urine by Test strip',\n",
414
       "  'UNITS': '{presence}'},\n",
415
       " {'DESCRIPTION': 'Hemoglobin [Presence] in Urine by Test strip',\n",
416
       "  'UNITS': '{presence}'},\n",
417
       " {'DESCRIPTION': 'Leukocyte esterase [Presence] in Urine by Test strip',\n",
418
       "  'UNITS': '{presence}'}]"
419
      ]
420
     },
421
     "execution_count": 19,
422
     "metadata": {},
423
     "output_type": "execute_result"
424
    }
425
   ],
426
   "source": [
427
    "df[df[\"CATEGORY\"] == 'laboratory'][['DESCRIPTION', 'UNITS']].dropna().drop_duplicates().to_dict('records')"
428
   ]
429
  },
430
  {
431
   "cell_type": "code",
432
   "execution_count": 45,
433
   "id": "d1688233-f642-4001-988a-7a55d6b198e4",
434
   "metadata": {},
435
   "outputs": [
436
    {
437
     "data": {
438
      "text/html": [
439
       "<div>\n",
440
       "<style scoped>\n",
441
       "    .dataframe tbody tr th:only-of-type {\n",
442
       "        vertical-align: middle;\n",
443
       "    }\n",
444
       "\n",
445
       "    .dataframe tbody tr th {\n",
446
       "        vertical-align: top;\n",
447
       "    }\n",
448
       "\n",
449
       "    .dataframe thead th {\n",
450
       "        text-align: right;\n",
451
       "    }\n",
452
       "</style>\n",
453
       "<table border=\"1\" class=\"dataframe\">\n",
454
       "  <thead>\n",
455
       "    <tr style=\"text-align: right;\">\n",
456
       "      <th></th>\n",
457
       "      <th>DATE</th>\n",
458
       "      <th>PATIENT</th>\n",
459
       "      <th>ENCOUNTER</th>\n",
460
       "      <th>CATEGORY</th>\n",
461
       "      <th>CODE</th>\n",
462
       "      <th>DESCRIPTION</th>\n",
463
       "      <th>VALUE</th>\n",
464
       "      <th>UNITS</th>\n",
465
       "      <th>TYPE</th>\n",
466
       "    </tr>\n",
467
       "  </thead>\n",
468
       "  <tbody>\n",
469
       "    <tr>\n",
470
       "      <th>0</th>\n",
471
       "      <td>2020-12-23T09:39:51Z</td>\n",
472
       "      <td>068eef5f-34ae-7fc9-6c6c-a5af808089dc</td>\n",
473
       "      <td>6bcbdd0b-7a02-384d-80ac-c520fb3ab179</td>\n",
474
       "      <td>vital-signs</td>\n",
475
       "      <td>8302-2</td>\n",
476
       "      <td>Body Height</td>\n",
477
       "      <td>170.1</td>\n",
478
       "      <td>cm</td>\n",
479
       "      <td>numeric</td>\n",
480
       "    </tr>\n",
481
       "    <tr>\n",
482
       "      <th>1</th>\n",
483
       "      <td>2020-12-23T09:39:51Z</td>\n",
484
       "      <td>068eef5f-34ae-7fc9-6c6c-a5af808089dc</td>\n",
485
       "      <td>6bcbdd0b-7a02-384d-80ac-c520fb3ab179</td>\n",
486
       "      <td>vital-signs</td>\n",
487
       "      <td>72514-3</td>\n",
488
       "      <td>Pain severity - 0-10 verbal numeric rating [Sc...</td>\n",
489
       "      <td>3.0</td>\n",
490
       "      <td>{score}</td>\n",
491
       "      <td>numeric</td>\n",
492
       "    </tr>\n",
493
       "    <tr>\n",
494
       "      <th>2</th>\n",
495
       "      <td>2021-05-25T23:58:21Z</td>\n",
496
       "      <td>0e11fbdf-a5f4-75fd-241c-039c9d4eedb2</td>\n",
497
       "      <td>240bad83-5e31-bb5e-f6d9-9b0d0542d9fa</td>\n",
498
       "      <td>vital-signs</td>\n",
499
       "      <td>8302-2</td>\n",
500
       "      <td>Body Height</td>\n",
501
       "      <td>153.2</td>\n",
502
       "      <td>cm</td>\n",
503
       "      <td>numeric</td>\n",
504
       "    </tr>\n",
505
       "    <tr>\n",
506
       "      <th>3</th>\n",
507
       "      <td>2021-05-25T23:58:21Z</td>\n",
508
       "      <td>0e11fbdf-a5f4-75fd-241c-039c9d4eedb2</td>\n",
509
       "      <td>240bad83-5e31-bb5e-f6d9-9b0d0542d9fa</td>\n",
510
       "      <td>vital-signs</td>\n",
511
       "      <td>72514-3</td>\n",
512
       "      <td>Pain severity - 0-10 verbal numeric rating [Sc...</td>\n",
513
       "      <td>3.0</td>\n",
514
       "      <td>{score}</td>\n",
515
       "      <td>numeric</td>\n",
516
       "    </tr>\n",
517
       "    <tr>\n",
518
       "      <th>4</th>\n",
519
       "      <td>2021-05-25T23:58:21Z</td>\n",
520
       "      <td>0e11fbdf-a5f4-75fd-241c-039c9d4eedb2</td>\n",
521
       "      <td>240bad83-5e31-bb5e-f6d9-9b0d0542d9fa</td>\n",
522
       "      <td>vital-signs</td>\n",
523
       "      <td>29463-7</td>\n",
524
       "      <td>Body Weight</td>\n",
525
       "      <td>42.5</td>\n",
526
       "      <td>kg</td>\n",
527
       "      <td>numeric</td>\n",
528
       "    </tr>\n",
529
       "  </tbody>\n",
530
       "</table>\n",
531
       "</div>"
532
      ],
533
      "text/plain": [
534
       "                   DATE                               PATIENT  \\\n",
535
       "0  2020-12-23T09:39:51Z  068eef5f-34ae-7fc9-6c6c-a5af808089dc   \n",
536
       "1  2020-12-23T09:39:51Z  068eef5f-34ae-7fc9-6c6c-a5af808089dc   \n",
537
       "2  2021-05-25T23:58:21Z  0e11fbdf-a5f4-75fd-241c-039c9d4eedb2   \n",
538
       "3  2021-05-25T23:58:21Z  0e11fbdf-a5f4-75fd-241c-039c9d4eedb2   \n",
539
       "4  2021-05-25T23:58:21Z  0e11fbdf-a5f4-75fd-241c-039c9d4eedb2   \n",
540
       "\n",
541
       "                              ENCOUNTER     CATEGORY     CODE  \\\n",
542
       "0  6bcbdd0b-7a02-384d-80ac-c520fb3ab179  vital-signs   8302-2   \n",
543
       "1  6bcbdd0b-7a02-384d-80ac-c520fb3ab179  vital-signs  72514-3   \n",
544
       "2  240bad83-5e31-bb5e-f6d9-9b0d0542d9fa  vital-signs   8302-2   \n",
545
       "3  240bad83-5e31-bb5e-f6d9-9b0d0542d9fa  vital-signs  72514-3   \n",
546
       "4  240bad83-5e31-bb5e-f6d9-9b0d0542d9fa  vital-signs  29463-7   \n",
547
       "\n",
548
       "                                         DESCRIPTION  VALUE    UNITS     TYPE  \n",
549
       "0                                        Body Height  170.1       cm  numeric  \n",
550
       "1  Pain severity - 0-10 verbal numeric rating [Sc...    3.0  {score}  numeric  \n",
551
       "2                                        Body Height  153.2       cm  numeric  \n",
552
       "3  Pain severity - 0-10 verbal numeric rating [Sc...    3.0  {score}  numeric  \n",
553
       "4                                        Body Weight   42.5       kg  numeric  "
554
      ]
555
     },
556
     "execution_count": 45,
557
     "metadata": {},
558
     "output_type": "execute_result"
559
    }
560
   ],
561
   "source": [
562
    "df.head()"
563
   ]
564
  },
565
  {
566
   "cell_type": "code",
567
   "execution_count": 23,
568
   "id": "2fdae325-04d7-4edc-b114-db9663452cb0",
569
   "metadata": {},
570
   "outputs": [
571
    {
572
     "name": "stdout",
573
     "output_type": "stream",
574
     "text": [
575
      "<class 'pandas.core.frame.DataFrame'>\n",
576
      "Int64Index: 3527 entries, 0 to 20711\n",
577
      "Data columns (total 9 columns):\n",
578
      " #   Column       Non-Null Count  Dtype \n",
579
      "---  ------       --------------  ----- \n",
580
      " 0   DATE         3527 non-null   object\n",
581
      " 1   PATIENT      3527 non-null   object\n",
582
      " 2   ENCOUNTER    3527 non-null   object\n",
583
      " 3   CATEGORY     3527 non-null   object\n",
584
      " 4   CODE         3527 non-null   object\n",
585
      " 5   DESCRIPTION  3527 non-null   object\n",
586
      " 6   VALUE        3527 non-null   object\n",
587
      " 7   UNITS        3527 non-null   object\n",
588
      " 8   TYPE         3527 non-null   object\n",
589
      "dtypes: object(9)\n",
590
      "memory usage: 275.5+ KB\n"
591
     ]
592
    }
593
   ],
594
   "source": [
595
    "df.info()"
596
   ]
597
  },
598
  {
599
   "cell_type": "code",
600
   "execution_count": 29,
601
   "id": "357470c4-15e6-4d60-8584-1435ffea4924",
602
   "metadata": {},
603
   "outputs": [
604
    {
605
     "data": {
606
      "text/plain": [
607
       "array(['Body Height',\n",
608
       "       'Pain severity - 0-10 verbal numeric rating [Score] - Reported',\n",
609
       "       'Body Weight', 'Body Mass Index',\n",
610
       "       'Body mass index (BMI) [Percentile] Per age and gender',\n",
611
       "       'Diastolic Blood Pressure', 'Systolic Blood Pressure',\n",
612
       "       'Heart rate', 'Respiratory rate', 'Body temperature',\n",
613
       "       'Oxygen saturation in Arterial blood',\n",
614
       "       'Weight-for-length Per age and sex',\n",
615
       "       'Head Occipital-frontal circumference Percentile',\n",
616
       "       'Head Occipital-frontal circumference', 'Body Temperature',\n",
617
       "       'Oxygen Saturation', 'Mean blood pressure',\n",
618
       "       'Natriuretic peptide.B prohormone N-Terminal [Mass/volume] in Blood by Immunoassay'],\n",
619
       "      dtype=object)"
620
      ]
621
     },
622
     "execution_count": 29,
623
     "metadata": {},
624
     "output_type": "execute_result"
625
    }
626
   ],
627
   "source": [
628
    "df[\"DESCRIPTION\"].unique()"
629
   ]
630
  },
631
  {
632
   "cell_type": "code",
633
   "execution_count": null,
634
   "id": "d4b6b3ef-7e94-4fee-90ab-b9fb4c701545",
635
   "metadata": {},
636
   "outputs": [],
637
   "source": []
638
  }
639
 ],
640
 "metadata": {
641
  "kernelspec": {
642
   "display_name": "Python 3 (ipykernel)",
643
   "language": "python",
644
   "name": "python3"
645
  },
646
  "language_info": {
647
   "codemirror_mode": {
648
    "name": "ipython",
649
    "version": 3
650
   },
651
   "file_extension": ".py",
652
   "mimetype": "text/x-python",
653
   "name": "python",
654
   "nbconvert_exporter": "python",
655
   "pygments_lexer": "ipython3",
656
   "version": "3.10.8"
657
  }
658
 },
659
 "nbformat": 4,
660
 "nbformat_minor": 5
661
}