Skip to content

Instantly share code, notes, and snippets.

@minrk
Created October 31, 2025 06:25
Show Gist options
  • Save minrk/f94da285bb8c6b947a947bcef0ca09cb to your computer and use it in GitHub Desktop.
Save minrk/f94da285bb8c6b947a947bcef0ca09cb to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"id": "bdd26a6d-5bab-4837-a5e9-7b8ec1853438",
"metadata": {},
"outputs": [],
"source": [
"patient_id = 40079\n",
"study_id = 30017"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "1e0046c6-9fc4-46a0-bf66-4dfb7413e8aa",
"metadata": {},
"outputs": [],
"source": [
"from jupyterhealth_client import JupyterHealthClient, Code\n",
"\n",
"jh_client = JupyterHealthClient()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "6538b63c-e7ee-4f4e-8c8e-82ad668f112c",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'id': 40079,\n",
" 'jheUserId': 10070,\n",
" 'identifier': '010101',\n",
" 'nameFamily': 'Doe',\n",
" 'nameGiven': 'Jane',\n",
" 'birthDate': '1998-01-01',\n",
" 'telecomPhone': None,\n",
" 'telecomEmail': '[email protected]',\n",
" 'organizations': [{'id': 20029,\n",
" 'name': 'JupyterCon Tutorial',\n",
" 'type': 'other',\n",
" 'partOf': 20028,\n",
" 'currentUserRole': None,\n",
" 'children': []}]}"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"jh_client.get_patient(patient_id)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "0ca50c78-c54a-48b7-9709-0bae745b74c9",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'id': 30017,\n",
" 'name': 'CGM sample data',\n",
" 'description': 'sample CGM data for JupyterCon tutorial',\n",
" 'organization': {'id': 20029, 'name': 'JupyterCon Tutorial', 'type': 'other'},\n",
" 'iconUrl': None}"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"jh_client.get_study(study_id)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "52c78b8b-5bad-4ff0-9611-d90dfc0465dd",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"4018\n"
]
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>resource_type</th>\n",
" <th>code</th>\n",
" <th>resourceType</th>\n",
" <th>id</th>\n",
" <th>meta_lastUpdated</th>\n",
" <th>status</th>\n",
" <th>subject_reference</th>\n",
" <th>code_coding_0_code</th>\n",
" <th>code_coding_0_system</th>\n",
" <th>uuid</th>\n",
" <th>...</th>\n",
" <th>external_datasheets_0_datasheet_type</th>\n",
" <th>external_datasheets_0_datasheet_reference</th>\n",
" <th>external_datasheets_1_datasheet_type</th>\n",
" <th>external_datasheets_1_datasheet_reference</th>\n",
" <th>source_creation_date_time</th>\n",
" <th>blood_glucose_unit</th>\n",
" <th>blood_glucose_value</th>\n",
" <th>effective_time_frame_date_time</th>\n",
" <th>source_creation_date_time_local</th>\n",
" <th>effective_time_frame_date_time_local</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>omh:blood-glucose:4.0</td>\n",
" <td>omh:blood-glucose:4.0</td>\n",
" <td>Observation</td>\n",
" <td>158214</td>\n",
" <td>2025-10-31 04:43:00.293695+00:00</td>\n",
" <td>final</td>\n",
" <td>Patient/40079</td>\n",
" <td>omh:blood-glucose:4.0</td>\n",
" <td>https://w3id.org/openmhealth</td>\n",
" <td>e0229319-528b-51b4-a696-b1d05209a0d9</td>\n",
" <td>...</td>\n",
" <td>data source</td>\n",
" <td>https://www.libreview.com/</td>\n",
" <td>measuring device</td>\n",
" <td>https://www.freestyle.abbott/us-en/products/fr...</td>\n",
" <td>2025-10-29 20:16:53+00:00</td>\n",
" <td>mg/dL</td>\n",
" <td>102.0</td>\n",
" <td>2025-02-11 09:06:00+00:00</td>\n",
" <td>2025-10-29 20:16:53</td>\n",
" <td>2025-02-11 09:06:00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>omh:blood-glucose:4.0</td>\n",
" <td>omh:blood-glucose:4.0</td>\n",
" <td>Observation</td>\n",
" <td>158213</td>\n",
" <td>2025-10-31 04:43:00.250402+00:00</td>\n",
" <td>final</td>\n",
" <td>Patient/40079</td>\n",
" <td>omh:blood-glucose:4.0</td>\n",
" <td>https://w3id.org/openmhealth</td>\n",
" <td>fedeb1e5-9789-5400-9981-6e05a8167117</td>\n",
" <td>...</td>\n",
" <td>data source</td>\n",
" <td>https://www.libreview.com/</td>\n",
" <td>measuring device</td>\n",
" <td>https://www.freestyle.abbott/us-en/products/fr...</td>\n",
" <td>2025-10-29 20:16:53+00:00</td>\n",
" <td>mg/dL</td>\n",
" <td>107.0</td>\n",
" <td>2025-02-11 09:01:00+00:00</td>\n",
" <td>2025-10-29 20:16:53</td>\n",
" <td>2025-02-11 09:01:00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>omh:blood-glucose:4.0</td>\n",
" <td>omh:blood-glucose:4.0</td>\n",
" <td>Observation</td>\n",
" <td>158212</td>\n",
" <td>2025-10-31 04:43:00.198434+00:00</td>\n",
" <td>final</td>\n",
" <td>Patient/40079</td>\n",
" <td>omh:blood-glucose:4.0</td>\n",
" <td>https://w3id.org/openmhealth</td>\n",
" <td>79571954-4b52-55a3-a2ef-d14dda039e82</td>\n",
" <td>...</td>\n",
" <td>data source</td>\n",
" <td>https://www.libreview.com/</td>\n",
" <td>measuring device</td>\n",
" <td>https://www.freestyle.abbott/us-en/products/fr...</td>\n",
" <td>2025-10-29 20:16:53+00:00</td>\n",
" <td>mg/dL</td>\n",
" <td>102.0</td>\n",
" <td>2025-02-11 08:56:00+00:00</td>\n",
" <td>2025-10-29 20:16:53</td>\n",
" <td>2025-02-11 08:56:00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>omh:blood-glucose:4.0</td>\n",
" <td>omh:blood-glucose:4.0</td>\n",
" <td>Observation</td>\n",
" <td>158211</td>\n",
" <td>2025-10-31 04:43:00.155407+00:00</td>\n",
" <td>final</td>\n",
" <td>Patient/40079</td>\n",
" <td>omh:blood-glucose:4.0</td>\n",
" <td>https://w3id.org/openmhealth</td>\n",
" <td>e7a41631-9dde-5dc2-832a-06375e8437bf</td>\n",
" <td>...</td>\n",
" <td>data source</td>\n",
" <td>https://www.libreview.com/</td>\n",
" <td>measuring device</td>\n",
" <td>https://www.freestyle.abbott/us-en/products/fr...</td>\n",
" <td>2025-10-29 20:16:53+00:00</td>\n",
" <td>mg/dL</td>\n",
" <td>97.0</td>\n",
" <td>2025-02-11 08:51:00+00:00</td>\n",
" <td>2025-10-29 20:16:53</td>\n",
" <td>2025-02-11 08:51:00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>omh:blood-glucose:4.0</td>\n",
" <td>omh:blood-glucose:4.0</td>\n",
" <td>Observation</td>\n",
" <td>158210</td>\n",
" <td>2025-10-31 04:43:00.018684+00:00</td>\n",
" <td>final</td>\n",
" <td>Patient/40079</td>\n",
" <td>omh:blood-glucose:4.0</td>\n",
" <td>https://w3id.org/openmhealth</td>\n",
" <td>fb817f20-b18b-52e8-b82e-c93c463bfdea</td>\n",
" <td>...</td>\n",
" <td>data source</td>\n",
" <td>https://www.libreview.com/</td>\n",
" <td>measuring device</td>\n",
" <td>https://www.freestyle.abbott/us-en/products/fr...</td>\n",
" <td>2025-10-29 20:16:53+00:00</td>\n",
" <td>mg/dL</td>\n",
" <td>93.0</td>\n",
" <td>2025-02-11 08:46:00+00:00</td>\n",
" <td>2025-10-29 20:16:53</td>\n",
" <td>2025-02-11 08:46:00</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5 rows × 27 columns</p>\n",
"</div>"
],
"text/plain": [
" resource_type code resourceType id \\\n",
"0 omh:blood-glucose:4.0 omh:blood-glucose:4.0 Observation 158214 \n",
"1 omh:blood-glucose:4.0 omh:blood-glucose:4.0 Observation 158213 \n",
"2 omh:blood-glucose:4.0 omh:blood-glucose:4.0 Observation 158212 \n",
"3 omh:blood-glucose:4.0 omh:blood-glucose:4.0 Observation 158211 \n",
"4 omh:blood-glucose:4.0 omh:blood-glucose:4.0 Observation 158210 \n",
"\n",
" meta_lastUpdated status subject_reference \\\n",
"0 2025-10-31 04:43:00.293695+00:00 final Patient/40079 \n",
"1 2025-10-31 04:43:00.250402+00:00 final Patient/40079 \n",
"2 2025-10-31 04:43:00.198434+00:00 final Patient/40079 \n",
"3 2025-10-31 04:43:00.155407+00:00 final Patient/40079 \n",
"4 2025-10-31 04:43:00.018684+00:00 final Patient/40079 \n",
"\n",
" code_coding_0_code code_coding_0_system \\\n",
"0 omh:blood-glucose:4.0 https://w3id.org/openmhealth \n",
"1 omh:blood-glucose:4.0 https://w3id.org/openmhealth \n",
"2 omh:blood-glucose:4.0 https://w3id.org/openmhealth \n",
"3 omh:blood-glucose:4.0 https://w3id.org/openmhealth \n",
"4 omh:blood-glucose:4.0 https://w3id.org/openmhealth \n",
"\n",
" uuid ... \\\n",
"0 e0229319-528b-51b4-a696-b1d05209a0d9 ... \n",
"1 fedeb1e5-9789-5400-9981-6e05a8167117 ... \n",
"2 79571954-4b52-55a3-a2ef-d14dda039e82 ... \n",
"3 e7a41631-9dde-5dc2-832a-06375e8437bf ... \n",
"4 fb817f20-b18b-52e8-b82e-c93c463bfdea ... \n",
"\n",
" external_datasheets_0_datasheet_type \\\n",
"0 data source \n",
"1 data source \n",
"2 data source \n",
"3 data source \n",
"4 data source \n",
"\n",
" external_datasheets_0_datasheet_reference \\\n",
"0 https://www.libreview.com/ \n",
"1 https://www.libreview.com/ \n",
"2 https://www.libreview.com/ \n",
"3 https://www.libreview.com/ \n",
"4 https://www.libreview.com/ \n",
"\n",
" external_datasheets_1_datasheet_type \\\n",
"0 measuring device \n",
"1 measuring device \n",
"2 measuring device \n",
"3 measuring device \n",
"4 measuring device \n",
"\n",
" external_datasheets_1_datasheet_reference \\\n",
"0 https://www.freestyle.abbott/us-en/products/fr... \n",
"1 https://www.freestyle.abbott/us-en/products/fr... \n",
"2 https://www.freestyle.abbott/us-en/products/fr... \n",
"3 https://www.freestyle.abbott/us-en/products/fr... \n",
"4 https://www.freestyle.abbott/us-en/products/fr... \n",
"\n",
" source_creation_date_time blood_glucose_unit blood_glucose_value \\\n",
"0 2025-10-29 20:16:53+00:00 mg/dL 102.0 \n",
"1 2025-10-29 20:16:53+00:00 mg/dL 107.0 \n",
"2 2025-10-29 20:16:53+00:00 mg/dL 102.0 \n",
"3 2025-10-29 20:16:53+00:00 mg/dL 97.0 \n",
"4 2025-10-29 20:16:53+00:00 mg/dL 93.0 \n",
"\n",
" effective_time_frame_date_time source_creation_date_time_local \\\n",
"0 2025-02-11 09:06:00+00:00 2025-10-29 20:16:53 \n",
"1 2025-02-11 09:01:00+00:00 2025-10-29 20:16:53 \n",
"2 2025-02-11 08:56:00+00:00 2025-10-29 20:16:53 \n",
"3 2025-02-11 08:51:00+00:00 2025-10-29 20:16:53 \n",
"4 2025-02-11 08:46:00+00:00 2025-10-29 20:16:53 \n",
"\n",
" effective_time_frame_date_time_local \n",
"0 2025-02-11 09:06:00 \n",
"1 2025-02-11 09:01:00 \n",
"2 2025-02-11 08:56:00 \n",
"3 2025-02-11 08:51:00 \n",
"4 2025-02-11 08:46:00 \n",
"\n",
"[5 rows x 27 columns]"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cgm = jh_client.list_observations_df(\n",
" patient_id=patient_id,\n",
" study_id=study_id,\n",
" code=Code.BLOOD_GLUCOSE.value,\n",
" limit=10_000,\n",
")\n",
"print(len(cgm))\n",
"cgm.head()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "623eb956-f590-4149-8d09-1f1583a88b5f",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"64\n"
]
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>resource_type</th>\n",
" <th>code</th>\n",
" <th>resourceType</th>\n",
" <th>id</th>\n",
" <th>meta_lastUpdated</th>\n",
" <th>status</th>\n",
" <th>subject_reference</th>\n",
" <th>code_coding_0_code</th>\n",
" <th>code_coding_0_system</th>\n",
" <th>uuid</th>\n",
" <th>...</th>\n",
" <th>calories_unit</th>\n",
" <th>calories_value</th>\n",
" <th>food_name</th>\n",
" <th>food_amount_value</th>\n",
" <th>carbohydrate_unit</th>\n",
" <th>carbohydrate_value</th>\n",
" <th>effective_time_frame_date_time</th>\n",
" <th>source_creation_date_time_local</th>\n",
" <th>effective_time_frame_date_time_local</th>\n",
" <th>food_amount_unit</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>ieee:food-entry:0.1</td>\n",
" <td>ieee:food-entry:0.1</td>\n",
" <td>Observation</td>\n",
" <td>158278</td>\n",
" <td>2025-10-31 04:43:32.393599+00:00</td>\n",
" <td>final</td>\n",
" <td>Patient/40079</td>\n",
" <td>ieee:food-entry:0.1</td>\n",
" <td>https://w3id.org/openmhealth</td>\n",
" <td>5def8bb4-92e3-5cf0-9666-6a9c8deac30f</td>\n",
" <td>...</td>\n",
" <td>kcal</td>\n",
" <td>317.71</td>\n",
" <td>Pumpkin Pie, single crust - 1/8 of 9\" pie</td>\n",
" <td>1.0</td>\n",
" <td>g</td>\n",
" <td>46.0</td>\n",
" <td>2025-02-11 10:30:00+00:00</td>\n",
" <td>2025-10-29 20:16:53</td>\n",
" <td>2025-02-11 10:30:00</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>ieee:food-entry:0.1</td>\n",
" <td>ieee:food-entry:0.1</td>\n",
" <td>Observation</td>\n",
" <td>158277</td>\n",
" <td>2025-10-31 04:43:32.368413+00:00</td>\n",
" <td>final</td>\n",
" <td>Patient/40079</td>\n",
" <td>ieee:food-entry:0.1</td>\n",
" <td>https://w3id.org/openmhealth</td>\n",
" <td>646fb4d4-8bea-5e66-ba08-56b67583e766</td>\n",
" <td>...</td>\n",
" <td>kcal</td>\n",
" <td>147.67</td>\n",
" <td>Soy Milk, Vanilla or Other Flavors, Unsweetene...</td>\n",
" <td>2.0</td>\n",
" <td>g</td>\n",
" <td>6.0</td>\n",
" <td>2025-02-11 07:30:00+00:00</td>\n",
" <td>2025-10-29 20:16:53</td>\n",
" <td>2025-02-11 07:30:00</td>\n",
" <td>Cup</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>ieee:food-entry:0.1</td>\n",
" <td>ieee:food-entry:0.1</td>\n",
" <td>Observation</td>\n",
" <td>158276</td>\n",
" <td>2025-10-31 04:43:32.341884+00:00</td>\n",
" <td>final</td>\n",
" <td>Patient/40079</td>\n",
" <td>ieee:food-entry:0.1</td>\n",
" <td>https://w3id.org/openmhealth</td>\n",
" <td>7396d38b-f46e-5081-b478-211e2d80c767</td>\n",
" <td>...</td>\n",
" <td>kcal</td>\n",
" <td>350.00</td>\n",
" <td>Sobey's, Nana's, Samosas, Chicken</td>\n",
" <td>1.0</td>\n",
" <td>g</td>\n",
" <td>35.0</td>\n",
" <td>2025-02-10 15:00:00+00:00</td>\n",
" <td>2025-10-29 20:16:53</td>\n",
" <td>2025-02-10 15:00:00</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>ieee:food-entry:0.1</td>\n",
" <td>ieee:food-entry:0.1</td>\n",
" <td>Observation</td>\n",
" <td>158275</td>\n",
" <td>2025-10-31 04:43:32.314491+00:00</td>\n",
" <td>final</td>\n",
" <td>Patient/40079</td>\n",
" <td>ieee:food-entry:0.1</td>\n",
" <td>https://w3id.org/openmhealth</td>\n",
" <td>e1e27af0-2b18-5a00-b510-77a83f15b802</td>\n",
" <td>...</td>\n",
" <td>kcal</td>\n",
" <td>1.12</td>\n",
" <td>Lettuce, Iceberg, medium leaf</td>\n",
" <td>1.0</td>\n",
" <td>g</td>\n",
" <td>0.2</td>\n",
" <td>2025-02-10 15:00:00+00:00</td>\n",
" <td>2025-10-29 20:16:53</td>\n",
" <td>2025-02-10 15:00:00</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>ieee:food-entry:0.1</td>\n",
" <td>ieee:food-entry:0.1</td>\n",
" <td>Observation</td>\n",
" <td>158274</td>\n",
" <td>2025-10-31 04:43:32.287750+00:00</td>\n",
" <td>final</td>\n",
" <td>Patient/40079</td>\n",
" <td>ieee:food-entry:0.1</td>\n",
" <td>https://w3id.org/openmhealth</td>\n",
" <td>f0a9087f-e55a-5377-ade9-04c269775212</td>\n",
" <td>...</td>\n",
" <td>kcal</td>\n",
" <td>317.71</td>\n",
" <td>Pumpkin Pie, single crust - 1/8 of 9\" pie</td>\n",
" <td>1.0</td>\n",
" <td>g</td>\n",
" <td>46.0</td>\n",
" <td>2025-02-10 10:10:00+00:00</td>\n",
" <td>2025-10-29 20:16:53</td>\n",
" <td>2025-02-10 10:10:00</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5 rows × 27 columns</p>\n",
"</div>"
],
"text/plain": [
" resource_type code resourceType id \\\n",
"0 ieee:food-entry:0.1 ieee:food-entry:0.1 Observation 158278 \n",
"1 ieee:food-entry:0.1 ieee:food-entry:0.1 Observation 158277 \n",
"2 ieee:food-entry:0.1 ieee:food-entry:0.1 Observation 158276 \n",
"3 ieee:food-entry:0.1 ieee:food-entry:0.1 Observation 158275 \n",
"4 ieee:food-entry:0.1 ieee:food-entry:0.1 Observation 158274 \n",
"\n",
" meta_lastUpdated status subject_reference \\\n",
"0 2025-10-31 04:43:32.393599+00:00 final Patient/40079 \n",
"1 2025-10-31 04:43:32.368413+00:00 final Patient/40079 \n",
"2 2025-10-31 04:43:32.341884+00:00 final Patient/40079 \n",
"3 2025-10-31 04:43:32.314491+00:00 final Patient/40079 \n",
"4 2025-10-31 04:43:32.287750+00:00 final Patient/40079 \n",
"\n",
" code_coding_0_code code_coding_0_system \\\n",
"0 ieee:food-entry:0.1 https://w3id.org/openmhealth \n",
"1 ieee:food-entry:0.1 https://w3id.org/openmhealth \n",
"2 ieee:food-entry:0.1 https://w3id.org/openmhealth \n",
"3 ieee:food-entry:0.1 https://w3id.org/openmhealth \n",
"4 ieee:food-entry:0.1 https://w3id.org/openmhealth \n",
"\n",
" uuid ... calories_unit calories_value \\\n",
"0 5def8bb4-92e3-5cf0-9666-6a9c8deac30f ... kcal 317.71 \n",
"1 646fb4d4-8bea-5e66-ba08-56b67583e766 ... kcal 147.67 \n",
"2 7396d38b-f46e-5081-b478-211e2d80c767 ... kcal 350.00 \n",
"3 e1e27af0-2b18-5a00-b510-77a83f15b802 ... kcal 1.12 \n",
"4 f0a9087f-e55a-5377-ade9-04c269775212 ... kcal 317.71 \n",
"\n",
" food_name food_amount_value \\\n",
"0 Pumpkin Pie, single crust - 1/8 of 9\" pie 1.0 \n",
"1 Soy Milk, Vanilla or Other Flavors, Unsweetene... 2.0 \n",
"2 Sobey's, Nana's, Samosas, Chicken 1.0 \n",
"3 Lettuce, Iceberg, medium leaf 1.0 \n",
"4 Pumpkin Pie, single crust - 1/8 of 9\" pie 1.0 \n",
"\n",
" carbohydrate_unit carbohydrate_value effective_time_frame_date_time \\\n",
"0 g 46.0 2025-02-11 10:30:00+00:00 \n",
"1 g 6.0 2025-02-11 07:30:00+00:00 \n",
"2 g 35.0 2025-02-10 15:00:00+00:00 \n",
"3 g 0.2 2025-02-10 15:00:00+00:00 \n",
"4 g 46.0 2025-02-10 10:10:00+00:00 \n",
"\n",
" source_creation_date_time_local effective_time_frame_date_time_local \\\n",
"0 2025-10-29 20:16:53 2025-02-11 10:30:00 \n",
"1 2025-10-29 20:16:53 2025-02-11 07:30:00 \n",
"2 2025-10-29 20:16:53 2025-02-10 15:00:00 \n",
"3 2025-10-29 20:16:53 2025-02-10 15:00:00 \n",
"4 2025-10-29 20:16:53 2025-02-10 10:10:00 \n",
"\n",
" food_amount_unit \n",
"0 NaN \n",
"1 Cup \n",
"2 NaN \n",
"3 NaN \n",
"4 NaN \n",
"\n",
"[5 rows x 27 columns]"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"food = jh_client.list_observations_df(\n",
" patient_id=patient_id,\n",
" study_id=study_id,\n",
" code=Code.FOOD_ENTRY.value,\n",
")\n",
"print(len(food))\n",
"food.head()"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "61ffb15d-7b8d-4dc7-8a89-c64d06ed5c7c",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"14\n"
]
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>resource_type</th>\n",
" <th>code</th>\n",
" <th>resourceType</th>\n",
" <th>id</th>\n",
" <th>meta_lastUpdated</th>\n",
" <th>status</th>\n",
" <th>subject_reference</th>\n",
" <th>code_coding_0_code</th>\n",
" <th>code_coding_0_system</th>\n",
" <th>uuid</th>\n",
" <th>...</th>\n",
" <th>sleep_stage_episodes_90_sleep_stage_time_frame_time_interval_end_date_time_local</th>\n",
" <th>sleep_stage_episodes_90_sleep_stage_time_frame_time_interval_start_date_time_local</th>\n",
" <th>sleep_stage_episodes_91_sleep_stage_time_frame_time_interval_end_date_time_local</th>\n",
" <th>sleep_stage_episodes_91_sleep_stage_time_frame_time_interval_start_date_time_local</th>\n",
" <th>sleep_stage_episodes_92_sleep_stage_time_frame_time_interval_end_date_time_local</th>\n",
" <th>sleep_stage_episodes_92_sleep_stage_time_frame_time_interval_start_date_time_local</th>\n",
" <th>sleep_stage_episodes_93_sleep_stage_time_frame_time_interval_end_date_time_local</th>\n",
" <th>sleep_stage_episodes_93_sleep_stage_time_frame_time_interval_start_date_time_local</th>\n",
" <th>sleep_stage_episodes_94_sleep_stage_time_frame_time_interval_end_date_time_local</th>\n",
" <th>sleep_stage_episodes_94_sleep_stage_time_frame_time_interval_start_date_time_local</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>ieee:sleep-stage-summary:1.0</td>\n",
" <td>ieee:sleep-stage-summary:1.0</td>\n",
" <td>Observation</td>\n",
" <td>158292</td>\n",
" <td>2025-10-31 04:43:34.221920+00:00</td>\n",
" <td>final</td>\n",
" <td>Patient/40079</td>\n",
" <td>ieee:sleep-stage-summary:1.0</td>\n",
" <td>https://w3id.org/openmhealth</td>\n",
" <td>16fd8f95-8255-51ed-a323-32f1393a143d</td>\n",
" <td>...</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>ieee:sleep-stage-summary:1.0</td>\n",
" <td>ieee:sleep-stage-summary:1.0</td>\n",
" <td>Observation</td>\n",
" <td>158291</td>\n",
" <td>2025-10-31 04:43:34.162794+00:00</td>\n",
" <td>final</td>\n",
" <td>Patient/40079</td>\n",
" <td>ieee:sleep-stage-summary:1.0</td>\n",
" <td>https://w3id.org/openmhealth</td>\n",
" <td>18271f53-14f1-5a81-968f-6a71a77dd9e3</td>\n",
" <td>...</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>ieee:sleep-stage-summary:1.0</td>\n",
" <td>ieee:sleep-stage-summary:1.0</td>\n",
" <td>Observation</td>\n",
" <td>158290</td>\n",
" <td>2025-10-31 04:43:34.109303+00:00</td>\n",
" <td>final</td>\n",
" <td>Patient/40079</td>\n",
" <td>ieee:sleep-stage-summary:1.0</td>\n",
" <td>https://w3id.org/openmhealth</td>\n",
" <td>715ba3ff-0d88-5887-872c-9fc09f298586</td>\n",
" <td>...</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>ieee:sleep-stage-summary:1.0</td>\n",
" <td>ieee:sleep-stage-summary:1.0</td>\n",
" <td>Observation</td>\n",
" <td>158289</td>\n",
" <td>2025-10-31 04:43:34.050193+00:00</td>\n",
" <td>final</td>\n",
" <td>Patient/40079</td>\n",
" <td>ieee:sleep-stage-summary:1.0</td>\n",
" <td>https://w3id.org/openmhealth</td>\n",
" <td>df15ccd3-a49c-5159-9c9b-9e32e7c485d9</td>\n",
" <td>...</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>ieee:sleep-stage-summary:1.0</td>\n",
" <td>ieee:sleep-stage-summary:1.0</td>\n",
" <td>Observation</td>\n",
" <td>158288</td>\n",
" <td>2025-10-31 04:43:33.991443+00:00</td>\n",
" <td>final</td>\n",
" <td>Patient/40079</td>\n",
" <td>ieee:sleep-stage-summary:1.0</td>\n",
" <td>https://w3id.org/openmhealth</td>\n",
" <td>6706ebf5-2f34-541f-a184-f62dcc55b078</td>\n",
" <td>...</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" <td>NaT</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5 rows × 506 columns</p>\n",
"</div>"
],
"text/plain": [
" resource_type code resourceType \\\n",
"0 ieee:sleep-stage-summary:1.0 ieee:sleep-stage-summary:1.0 Observation \n",
"1 ieee:sleep-stage-summary:1.0 ieee:sleep-stage-summary:1.0 Observation \n",
"2 ieee:sleep-stage-summary:1.0 ieee:sleep-stage-summary:1.0 Observation \n",
"3 ieee:sleep-stage-summary:1.0 ieee:sleep-stage-summary:1.0 Observation \n",
"4 ieee:sleep-stage-summary:1.0 ieee:sleep-stage-summary:1.0 Observation \n",
"\n",
" id meta_lastUpdated status subject_reference \\\n",
"0 158292 2025-10-31 04:43:34.221920+00:00 final Patient/40079 \n",
"1 158291 2025-10-31 04:43:34.162794+00:00 final Patient/40079 \n",
"2 158290 2025-10-31 04:43:34.109303+00:00 final Patient/40079 \n",
"3 158289 2025-10-31 04:43:34.050193+00:00 final Patient/40079 \n",
"4 158288 2025-10-31 04:43:33.991443+00:00 final Patient/40079 \n",
"\n",
" code_coding_0_code code_coding_0_system \\\n",
"0 ieee:sleep-stage-summary:1.0 https://w3id.org/openmhealth \n",
"1 ieee:sleep-stage-summary:1.0 https://w3id.org/openmhealth \n",
"2 ieee:sleep-stage-summary:1.0 https://w3id.org/openmhealth \n",
"3 ieee:sleep-stage-summary:1.0 https://w3id.org/openmhealth \n",
"4 ieee:sleep-stage-summary:1.0 https://w3id.org/openmhealth \n",
"\n",
" uuid ... \\\n",
"0 16fd8f95-8255-51ed-a323-32f1393a143d ... \n",
"1 18271f53-14f1-5a81-968f-6a71a77dd9e3 ... \n",
"2 715ba3ff-0d88-5887-872c-9fc09f298586 ... \n",
"3 df15ccd3-a49c-5159-9c9b-9e32e7c485d9 ... \n",
"4 6706ebf5-2f34-541f-a184-f62dcc55b078 ... \n",
"\n",
" sleep_stage_episodes_90_sleep_stage_time_frame_time_interval_end_date_time_local \\\n",
"0 NaT \n",
"1 NaT \n",
"2 NaT \n",
"3 NaT \n",
"4 NaT \n",
"\n",
" sleep_stage_episodes_90_sleep_stage_time_frame_time_interval_start_date_time_local \\\n",
"0 NaT \n",
"1 NaT \n",
"2 NaT \n",
"3 NaT \n",
"4 NaT \n",
"\n",
" sleep_stage_episodes_91_sleep_stage_time_frame_time_interval_end_date_time_local \\\n",
"0 NaT \n",
"1 NaT \n",
"2 NaT \n",
"3 NaT \n",
"4 NaT \n",
"\n",
" sleep_stage_episodes_91_sleep_stage_time_frame_time_interval_start_date_time_local \\\n",
"0 NaT \n",
"1 NaT \n",
"2 NaT \n",
"3 NaT \n",
"4 NaT \n",
"\n",
" sleep_stage_episodes_92_sleep_stage_time_frame_time_interval_end_date_time_local \\\n",
"0 NaT \n",
"1 NaT \n",
"2 NaT \n",
"3 NaT \n",
"4 NaT \n",
"\n",
" sleep_stage_episodes_92_sleep_stage_time_frame_time_interval_start_date_time_local \\\n",
"0 NaT \n",
"1 NaT \n",
"2 NaT \n",
"3 NaT \n",
"4 NaT \n",
"\n",
" sleep_stage_episodes_93_sleep_stage_time_frame_time_interval_end_date_time_local \\\n",
"0 NaT \n",
"1 NaT \n",
"2 NaT \n",
"3 NaT \n",
"4 NaT \n",
"\n",
" sleep_stage_episodes_93_sleep_stage_time_frame_time_interval_start_date_time_local \\\n",
"0 NaT \n",
"1 NaT \n",
"2 NaT \n",
"3 NaT \n",
"4 NaT \n",
"\n",
" sleep_stage_episodes_94_sleep_stage_time_frame_time_interval_end_date_time_local \\\n",
"0 NaT \n",
"1 NaT \n",
"2 NaT \n",
"3 NaT \n",
"4 NaT \n",
"\n",
" sleep_stage_episodes_94_sleep_stage_time_frame_time_interval_start_date_time_local \n",
"0 NaT \n",
"1 NaT \n",
"2 NaT \n",
"3 NaT \n",
"4 NaT \n",
"\n",
"[5 rows x 506 columns]"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sleep = jh_client.list_observations_df(\n",
" patient_id=patient_id,\n",
" study_id=study_id,\n",
" code=Code.SLEEP_STAGE_SUMMARY.value,\n",
")\n",
"print(len(sleep))\n",
"sleep.head()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment