From 0797a24c2580e8e64e80a15a3314cc46819d9336 Mon Sep 17 00:00:00 2001 From: Brian Walsh Date: Tue, 11 Feb 2025 15:54:31 -0800 Subject: [PATCH] adds notebook --- notebooks/fhir_aggregator.ipynb | 807 ++++++++++++++++++++++++++++++++ 1 file changed, 807 insertions(+) create mode 100644 notebooks/fhir_aggregator.ipynb diff --git a/notebooks/fhir_aggregator.ipynb b/notebooks/fhir_aggregator.ipynb new file mode 100644 index 0000000..6764237 --- /dev/null +++ b/notebooks/fhir_aggregator.ipynb @@ -0,0 +1,807 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "qZrFN770uyCY" + }, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "source": [ + "# FHIR-Aggregator\n", + "## Explore data in the test google fhir service" + ], + "metadata": { + "id": "ozTxO5B6yjHU" + } + }, + { + "cell_type": "markdown", + "source": [ + "### install and test dependencies" + ], + "metadata": { + "id": "0Zo-EUoeJXYv" + } + }, + { + "cell_type": "code", + "source": [ + "pip install dtale" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "i_zWmIibWdbV", + "outputId": "aeb1b044-856d-4ae8-eba1-e11dd3a1d93c" + }, + "execution_count": 1, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Collecting dtale\n", + " Downloading dtale-3.16.1-py2.py3-none-any.whl.metadata (16 kB)\n", + "Collecting dash-colorscales (from dtale)\n", + " Downloading dash_colorscales-0.0.4.tar.gz (62 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m62.3/62.3 kB\u001b[0m \u001b[31m2.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25h Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n", + "Collecting dash-daq (from dtale)\n", + " Downloading dash_daq-0.5.0.tar.gz (642 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m642.7/642.7 kB\u001b[0m \u001b[31m20.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25h Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n", + "Requirement already satisfied: future>=0.14.0 in /usr/local/lib/python3.11/dist-packages (from dtale) (1.0.0)\n", + "Requirement already satisfied: missingno in /usr/local/lib/python3.11/dist-packages (from dtale) (0.5.2)\n", + "Requirement already satisfied: pandas in /usr/local/lib/python3.11/dist-packages (from dtale) (2.2.2)\n", + "Collecting squarify (from dtale)\n", + " Downloading squarify-0.4.4-py3-none-any.whl.metadata (600 bytes)\n", + "Collecting strsimpy (from dtale)\n", + " Downloading strsimpy-0.2.1-py3-none-any.whl.metadata (20 kB)\n", + "Requirement already satisfied: six in /usr/local/lib/python3.11/dist-packages (from dtale) (1.17.0)\n", + "Requirement already satisfied: xlrd in /usr/local/lib/python3.11/dist-packages (from dtale) (2.0.1)\n", + "Requirement already satisfied: beautifulsoup4!=4.13.0b2 in /usr/local/lib/python3.11/dist-packages (from dtale) (4.13.3)\n", + "Requirement already satisfied: certifi in /usr/local/lib/python3.11/dist-packages (from dtale) (2025.1.31)\n", + "Collecting dash-bootstrap-components (from dtale)\n", + " Downloading dash_bootstrap_components-1.7.1-py3-none-any.whl.metadata (17 kB)\n", + "Collecting lz4 (from dtale)\n", + " Downloading lz4-4.4.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (3.8 kB)\n", + "Requirement already satisfied: cycler in /usr/local/lib/python3.11/dist-packages (from dtale) (0.12.1)\n", + "Collecting dash (from dtale)\n", + " Downloading dash-2.18.2-py3-none-any.whl.metadata (10 kB)\n", + "Requirement already satisfied: seaborn in /usr/local/lib/python3.11/dist-packages (from dtale) (0.13.2)\n", + "Requirement already satisfied: werkzeug in /usr/local/lib/python3.11/dist-packages (from dtale) (3.1.3)\n", + "Collecting Flask-Compress (from dtale)\n", + " Downloading Flask_Compress-1.17-py3-none-any.whl.metadata (8.8 kB)\n", + "Requirement already satisfied: scikit-learn in /usr/local/lib/python3.11/dist-packages (from dtale) (1.6.1)\n", + "Requirement already satisfied: statsmodels in /usr/local/lib/python3.11/dist-packages (from dtale) (0.14.4)\n", + "Requirement already satisfied: networkx in /usr/local/lib/python3.11/dist-packages (from dtale) (3.4.2)\n", + "Requirement already satisfied: numpy in /usr/local/lib/python3.11/dist-packages (from dtale) (1.26.4)\n", + "Requirement already satisfied: openpyxl!=3.2.0b1 in /usr/local/lib/python3.11/dist-packages (from dtale) (3.1.5)\n", + "Requirement already satisfied: xarray in /usr/local/lib/python3.11/dist-packages (from dtale) (2025.1.2)\n", + "Requirement already satisfied: scipy!=1.12.0rc1,!=1.14.0,!=1.14.0rc1,!=1.14.0rc2 in /usr/local/lib/python3.11/dist-packages (from dtale) (1.13.1)\n", + "Requirement already satisfied: et-xmlfile in /usr/local/lib/python3.11/dist-packages (from dtale) (2.0.0)\n", + "Requirement already satisfied: plotly in /usr/local/lib/python3.11/dist-packages (from dtale) (5.24.1)\n", + "Requirement already satisfied: Flask in /usr/local/lib/python3.11/dist-packages (from dtale) (3.1.0)\n", + "Requirement already satisfied: itsdangerous in /usr/local/lib/python3.11/dist-packages (from dtale) (2.2.0)\n", + "Requirement already satisfied: requests in /usr/local/lib/python3.11/dist-packages (from dtale) (2.32.3)\n", + "Collecting kaleido (from dtale)\n", + " Downloading kaleido-0.2.1-py2.py3-none-manylinux1_x86_64.whl.metadata (15 kB)\n", + "Requirement already satisfied: matplotlib in /usr/local/lib/python3.11/dist-packages (from dtale) (3.10.0)\n", + "Requirement already satisfied: soupsieve>1.2 in /usr/local/lib/python3.11/dist-packages (from beautifulsoup4!=4.13.0b2->dtale) (2.6)\n", + "Requirement already satisfied: typing-extensions>=4.0.0 in /usr/local/lib/python3.11/dist-packages (from beautifulsoup4!=4.13.0b2->dtale) (4.12.2)\n", + "Collecting Flask (from dtale)\n", + " Downloading flask-3.0.3-py3-none-any.whl.metadata (3.2 kB)\n", + "Collecting werkzeug (from dtale)\n", + " Downloading werkzeug-3.0.6-py3-none-any.whl.metadata (3.7 kB)\n", + "Collecting dash-html-components==2.0.0 (from dash->dtale)\n", + " Downloading dash_html_components-2.0.0-py3-none-any.whl.metadata (3.8 kB)\n", + "Collecting dash-core-components==2.0.0 (from dash->dtale)\n", + " Downloading dash_core_components-2.0.0-py3-none-any.whl.metadata (2.9 kB)\n", + "Collecting dash-table==5.0.0 (from dash->dtale)\n", + " Downloading dash_table-5.0.0-py3-none-any.whl.metadata (2.4 kB)\n", + "Requirement already satisfied: importlib-metadata in /usr/local/lib/python3.11/dist-packages (from dash->dtale) (8.6.1)\n", + "Collecting retrying (from dash->dtale)\n", + " Downloading retrying-1.3.4-py3-none-any.whl.metadata (6.9 kB)\n", + "Requirement already satisfied: nest-asyncio in /usr/local/lib/python3.11/dist-packages (from dash->dtale) (1.6.0)\n", + "Requirement already satisfied: setuptools in /usr/local/lib/python3.11/dist-packages (from dash->dtale) (75.1.0)\n", + "Requirement already satisfied: Jinja2>=3.1.2 in /usr/local/lib/python3.11/dist-packages (from Flask->dtale) (3.1.5)\n", + "Requirement already satisfied: click>=8.1.3 in /usr/local/lib/python3.11/dist-packages (from Flask->dtale) (8.1.8)\n", + "Requirement already satisfied: blinker>=1.6.2 in /usr/local/lib/python3.11/dist-packages (from Flask->dtale) (1.9.0)\n", + "Requirement already satisfied: tenacity>=6.2.0 in /usr/local/lib/python3.11/dist-packages (from plotly->dtale) (9.0.0)\n", + "Requirement already satisfied: packaging in /usr/local/lib/python3.11/dist-packages (from plotly->dtale) (24.2)\n", + "Requirement already satisfied: MarkupSafe>=2.1.1 in /usr/local/lib/python3.11/dist-packages (from werkzeug->dtale) (3.0.2)\n", + "Collecting brotli (from Flask-Compress->dtale)\n", + " Downloading Brotli-1.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (5.5 kB)\n", + "Requirement already satisfied: zstandard in /usr/local/lib/python3.11/dist-packages (from Flask-Compress->dtale) (0.23.0)\n", + "Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.11/dist-packages (from matplotlib->dtale) (1.3.1)\n", + "Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.11/dist-packages (from matplotlib->dtale) (4.55.8)\n", + "Requirement already satisfied: kiwisolver>=1.3.1 in /usr/local/lib/python3.11/dist-packages (from matplotlib->dtale) (1.4.8)\n", + "Requirement already satisfied: pillow>=8 in /usr/local/lib/python3.11/dist-packages (from matplotlib->dtale) (11.1.0)\n", + "Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.11/dist-packages (from matplotlib->dtale) (3.2.1)\n", + "Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.11/dist-packages (from matplotlib->dtale) (2.8.2)\n", + "Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.11/dist-packages (from pandas->dtale) (2025.1)\n", + "Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.11/dist-packages (from pandas->dtale) (2025.1)\n", + "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.11/dist-packages (from requests->dtale) (3.4.1)\n", + "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.11/dist-packages (from requests->dtale) (3.10)\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.11/dist-packages (from requests->dtale) (2.3.0)\n", + "Requirement already satisfied: joblib>=1.2.0 in /usr/local/lib/python3.11/dist-packages (from scikit-learn->dtale) (1.4.2)\n", + "Requirement already satisfied: threadpoolctl>=3.1.0 in /usr/local/lib/python3.11/dist-packages (from scikit-learn->dtale) (3.5.0)\n", + "Requirement already satisfied: patsy>=0.5.6 in /usr/local/lib/python3.11/dist-packages (from statsmodels->dtale) (1.0.1)\n", + "Requirement already satisfied: zipp>=3.20 in /usr/local/lib/python3.11/dist-packages (from importlib-metadata->dash->dtale) (3.21.0)\n", + "Downloading dtale-3.16.1-py2.py3-none-any.whl (14.7 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m14.7/14.7 MB\u001b[0m \u001b[31m37.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading dash-2.18.2-py3-none-any.whl (7.8 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m7.8/7.8 MB\u001b[0m \u001b[31m62.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading dash_core_components-2.0.0-py3-none-any.whl (3.8 kB)\n", + "Downloading dash_html_components-2.0.0-py3-none-any.whl (4.1 kB)\n", + "Downloading dash_table-5.0.0-py3-none-any.whl (3.9 kB)\n", + "Downloading flask-3.0.3-py3-none-any.whl (101 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m101.7/101.7 kB\u001b[0m \u001b[31m6.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading werkzeug-3.0.6-py3-none-any.whl (227 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m228.0/228.0 kB\u001b[0m \u001b[31m12.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading dash_bootstrap_components-1.7.1-py3-none-any.whl (229 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m229.3/229.3 kB\u001b[0m \u001b[31m10.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading Flask_Compress-1.17-py3-none-any.whl (8.7 kB)\n", + "Downloading kaleido-0.2.1-py2.py3-none-manylinux1_x86_64.whl (79.9 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m79.9/79.9 MB\u001b[0m \u001b[31m8.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading lz4-4.4.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.3/1.3 MB\u001b[0m \u001b[31m30.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading squarify-0.4.4-py3-none-any.whl (4.1 kB)\n", + "Downloading strsimpy-0.2.1-py3-none-any.whl (45 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m45.9/45.9 kB\u001b[0m \u001b[31m2.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading Brotli-1.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.9 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.9/2.9 MB\u001b[0m \u001b[31m35.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading retrying-1.3.4-py3-none-any.whl (11 kB)\n", + "Building wheels for collected packages: dash-colorscales, dash-daq\n", + " Building wheel for dash-colorscales (setup.py) ... \u001b[?25l\u001b[?25hdone\n", + " Created wheel for dash-colorscales: filename=dash_colorscales-0.0.4-py3-none-any.whl size=62568 sha256=75abd6b6f71668a2a65093d53036a75a4320c820292bb3c6ad7abb3737b2e6de\n", + " Stored in directory: /root/.cache/pip/wheels/a8/c3/fd/eaaa499af5a62e4f31c6e9ee0a32c05ece15176c4ea4d68398\n", + " Building wheel for dash-daq (setup.py) ... \u001b[?25l\u001b[?25hdone\n", + " Created wheel for dash-daq: filename=dash_daq-0.5.0-py3-none-any.whl size=669692 sha256=cca3699026343f85605e5cf478733676910c36a15e2d33fece08e93f8629b9e5\n", + " Stored in directory: /root/.cache/pip/wheels/9a/e1/a3/ef7c3fa914e4df214fdcb64529c44669e3e72ebdb784db10e0\n", + "Successfully built dash-colorscales dash-daq\n", + "Installing collected packages: strsimpy, squarify, kaleido, dash-table, dash-html-components, dash-core-components, dash-colorscales, brotli, werkzeug, retrying, lz4, Flask, Flask-Compress, dash, dash-daq, dash-bootstrap-components, dtale\n", + " Attempting uninstall: werkzeug\n", + " Found existing installation: Werkzeug 3.1.3\n", + " Uninstalling Werkzeug-3.1.3:\n", + " Successfully uninstalled Werkzeug-3.1.3\n", + " Attempting uninstall: Flask\n", + " Found existing installation: Flask 3.1.0\n", + " Uninstalling Flask-3.1.0:\n", + " Successfully uninstalled Flask-3.1.0\n", + "Successfully installed Flask-3.0.3 Flask-Compress-1.17 brotli-1.1.0 dash-2.18.2 dash-bootstrap-components-1.7.1 dash-colorscales-0.0.4 dash-core-components-2.0.0 dash-daq-0.5.0 dash-html-components-2.0.0 dash-table-5.0.0 dtale-3.16.1 kaleido-0.2.1 lz4-4.4.3 retrying-1.3.4 squarify-0.4.4 strsimpy-0.2.1 werkzeug-3.0.6\n" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "# install the query tool" + ], + "metadata": { + "id": "EzE6coYdXiz9" + } + }, + { + "cell_type": "code", + "source": [ + "pip install git+https://github.com/FHIR-Aggregator/fhir-query.git" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "qKNu-WeEyzC0", + "outputId": "cfb495ed-9e26-403e-c5d1-2a5933d12147" + }, + "execution_count": 3, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Collecting git+https://github.com/FHIR-Aggregator/fhir-query.git\n", + " Cloning https://github.com/FHIR-Aggregator/fhir-query.git to /tmp/pip-req-build-fbiwv6ak\n", + " Running command git clone --filter=blob:none --quiet https://github.com/FHIR-Aggregator/fhir-query.git /tmp/pip-req-build-fbiwv6ak\n", + " Resolved https://github.com/FHIR-Aggregator/fhir-query.git to commit 0358fc754a44d9ae55fd16575e5a314dc8c1917d\n", + " Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n", + " Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n", + " Preparing metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n", + "Requirement already satisfied: click in /usr/local/lib/python3.11/dist-packages (from fhir_query==0.1.0) (8.1.8)\n", + "Requirement already satisfied: requests in /usr/local/lib/python3.11/dist-packages (from fhir_query==0.1.0) (2.32.3)\n", + "Requirement already satisfied: pyyaml in /usr/local/lib/python3.11/dist-packages (from fhir_query==0.1.0) (6.0.2)\n", + "Collecting halo (from fhir_query==0.1.0)\n", + " Downloading halo-0.0.31.tar.gz (11 kB)\n", + " Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n", + "Requirement already satisfied: httpx in /usr/local/lib/python3.11/dist-packages (from fhir_query==0.1.0) (0.28.1)\n", + "Collecting fhir.resources==8.0.0b4 (from fhir_query==0.1.0)\n", + " Downloading fhir.resources-8.0.0b4-py2.py3-none-any.whl.metadata (47 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m47.4/47.4 kB\u001b[0m \u001b[31m2.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hCollecting dotty-dict (from fhir_query==0.1.0)\n", + " Downloading dotty_dict-1.3.1-py3-none-any.whl.metadata (5.3 kB)\n", + "Collecting pyvis (from fhir_query==0.1.0)\n", + " Downloading pyvis-0.3.2-py3-none-any.whl.metadata (1.7 kB)\n", + "Collecting click_default_group (from fhir_query==0.1.0)\n", + " Downloading click_default_group-1.2.4-py2.py3-none-any.whl.metadata (2.8 kB)\n", + "Collecting inflection (from fhir_query==0.1.0)\n", + " Downloading inflection-0.5.1-py2.py3-none-any.whl.metadata (1.7 kB)\n", + "Requirement already satisfied: pandas in /usr/local/lib/python3.11/dist-packages (from fhir_query==0.1.0) (2.2.2)\n", + "Collecting fhir-core>=0.1.3 (from fhir.resources==8.0.0b4->fhir_query==0.1.0)\n", + " Downloading fhir_core-1.0.0-py2.py3-none-any.whl.metadata (10 kB)\n", + "Collecting log_symbols>=0.0.14 (from halo->fhir_query==0.1.0)\n", + " Downloading log_symbols-0.0.14-py3-none-any.whl.metadata (523 bytes)\n", + "Collecting spinners>=0.0.24 (from halo->fhir_query==0.1.0)\n", + " Downloading spinners-0.0.24-py3-none-any.whl.metadata (576 bytes)\n", + "Requirement already satisfied: termcolor>=1.1.0 in /usr/local/lib/python3.11/dist-packages (from halo->fhir_query==0.1.0) (2.5.0)\n", + "Collecting colorama>=0.3.9 (from halo->fhir_query==0.1.0)\n", + " Downloading colorama-0.4.6-py2.py3-none-any.whl.metadata (17 kB)\n", + "Requirement already satisfied: six>=1.12.0 in /usr/local/lib/python3.11/dist-packages (from halo->fhir_query==0.1.0) (1.17.0)\n", + "Requirement already satisfied: anyio in /usr/local/lib/python3.11/dist-packages (from httpx->fhir_query==0.1.0) (3.7.1)\n", + "Requirement already satisfied: certifi in /usr/local/lib/python3.11/dist-packages (from httpx->fhir_query==0.1.0) (2025.1.31)\n", + "Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.11/dist-packages (from httpx->fhir_query==0.1.0) (1.0.7)\n", + "Requirement already satisfied: idna in /usr/local/lib/python3.11/dist-packages (from httpx->fhir_query==0.1.0) (3.10)\n", + "Requirement already satisfied: h11<0.15,>=0.13 in /usr/local/lib/python3.11/dist-packages (from httpcore==1.*->httpx->fhir_query==0.1.0) (0.14.0)\n", + "Requirement already satisfied: numpy>=1.23.2 in /usr/local/lib/python3.11/dist-packages (from pandas->fhir_query==0.1.0) (1.26.4)\n", + "Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.11/dist-packages (from pandas->fhir_query==0.1.0) (2.8.2)\n", + "Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.11/dist-packages (from pandas->fhir_query==0.1.0) (2025.1)\n", + "Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.11/dist-packages (from pandas->fhir_query==0.1.0) (2025.1)\n", + "Requirement already satisfied: ipython>=5.3.0 in /usr/local/lib/python3.11/dist-packages (from pyvis->fhir_query==0.1.0) (7.34.0)\n", + "Requirement already satisfied: jinja2>=2.9.6 in /usr/local/lib/python3.11/dist-packages (from pyvis->fhir_query==0.1.0) (3.1.5)\n", + "Requirement already satisfied: jsonpickle>=1.4.1 in /usr/local/lib/python3.11/dist-packages (from pyvis->fhir_query==0.1.0) (4.0.1)\n", + "Requirement already satisfied: networkx>=1.11 in /usr/local/lib/python3.11/dist-packages (from pyvis->fhir_query==0.1.0) (3.4.2)\n", + "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.11/dist-packages (from requests->fhir_query==0.1.0) (3.4.1)\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.11/dist-packages (from requests->fhir_query==0.1.0) (2.3.0)\n", + "Requirement already satisfied: pydantic<3.0,>=2.7.4 in /usr/local/lib/python3.11/dist-packages (from fhir-core>=0.1.3->fhir.resources==8.0.0b4->fhir_query==0.1.0) (2.10.6)\n", + "Requirement already satisfied: setuptools>=18.5 in /usr/local/lib/python3.11/dist-packages (from ipython>=5.3.0->pyvis->fhir_query==0.1.0) (75.1.0)\n", + "Collecting jedi>=0.16 (from ipython>=5.3.0->pyvis->fhir_query==0.1.0)\n", + " Downloading jedi-0.19.2-py2.py3-none-any.whl.metadata (22 kB)\n", + "Requirement already satisfied: decorator in /usr/local/lib/python3.11/dist-packages (from ipython>=5.3.0->pyvis->fhir_query==0.1.0) (4.4.2)\n", + "Requirement already satisfied: pickleshare in /usr/local/lib/python3.11/dist-packages (from ipython>=5.3.0->pyvis->fhir_query==0.1.0) (0.7.5)\n", + "Requirement already satisfied: traitlets>=4.2 in /usr/local/lib/python3.11/dist-packages (from ipython>=5.3.0->pyvis->fhir_query==0.1.0) (5.7.1)\n", + "Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in /usr/local/lib/python3.11/dist-packages (from ipython>=5.3.0->pyvis->fhir_query==0.1.0) (3.0.50)\n", + "Requirement already satisfied: pygments in /usr/local/lib/python3.11/dist-packages (from ipython>=5.3.0->pyvis->fhir_query==0.1.0) (2.18.0)\n", + "Requirement already satisfied: backcall in /usr/local/lib/python3.11/dist-packages (from ipython>=5.3.0->pyvis->fhir_query==0.1.0) (0.2.0)\n", + "Requirement already satisfied: matplotlib-inline in /usr/local/lib/python3.11/dist-packages (from ipython>=5.3.0->pyvis->fhir_query==0.1.0) (0.1.7)\n", + "Requirement already satisfied: pexpect>4.3 in /usr/local/lib/python3.11/dist-packages (from ipython>=5.3.0->pyvis->fhir_query==0.1.0) (4.9.0)\n", + "Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.11/dist-packages (from jinja2>=2.9.6->pyvis->fhir_query==0.1.0) (3.0.2)\n", + "Requirement already satisfied: sniffio>=1.1 in /usr/local/lib/python3.11/dist-packages (from anyio->httpx->fhir_query==0.1.0) (1.3.1)\n", + "Requirement already satisfied: parso<0.9.0,>=0.8.4 in /usr/local/lib/python3.11/dist-packages (from jedi>=0.16->ipython>=5.3.0->pyvis->fhir_query==0.1.0) (0.8.4)\n", + "Requirement already satisfied: ptyprocess>=0.5 in /usr/local/lib/python3.11/dist-packages (from pexpect>4.3->ipython>=5.3.0->pyvis->fhir_query==0.1.0) (0.7.0)\n", + "Requirement already satisfied: wcwidth in /usr/local/lib/python3.11/dist-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->ipython>=5.3.0->pyvis->fhir_query==0.1.0) (0.2.13)\n", + "Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.11/dist-packages (from pydantic<3.0,>=2.7.4->fhir-core>=0.1.3->fhir.resources==8.0.0b4->fhir_query==0.1.0) (0.7.0)\n", + "Requirement already satisfied: pydantic-core==2.27.2 in /usr/local/lib/python3.11/dist-packages (from pydantic<3.0,>=2.7.4->fhir-core>=0.1.3->fhir.resources==8.0.0b4->fhir_query==0.1.0) (2.27.2)\n", + "Requirement already satisfied: typing-extensions>=4.12.2 in /usr/local/lib/python3.11/dist-packages (from pydantic<3.0,>=2.7.4->fhir-core>=0.1.3->fhir.resources==8.0.0b4->fhir_query==0.1.0) (4.12.2)\n", + "Downloading fhir.resources-8.0.0b4-py2.py3-none-any.whl (2.5 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.5/2.5 MB\u001b[0m \u001b[31m9.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading click_default_group-1.2.4-py2.py3-none-any.whl (4.1 kB)\n", + "Downloading dotty_dict-1.3.1-py3-none-any.whl (7.0 kB)\n", + "Downloading inflection-0.5.1-py2.py3-none-any.whl (9.5 kB)\n", + "Downloading pyvis-0.3.2-py3-none-any.whl (756 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m756.0/756.0 kB\u001b[0m \u001b[31m34.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading colorama-0.4.6-py2.py3-none-any.whl (25 kB)\n", + "Downloading fhir_core-1.0.0-py2.py3-none-any.whl (29 kB)\n", + "Downloading log_symbols-0.0.14-py3-none-any.whl (3.1 kB)\n", + "Downloading spinners-0.0.24-py3-none-any.whl (5.5 kB)\n", + "Downloading jedi-0.19.2-py2.py3-none-any.whl (1.6 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.6/1.6 MB\u001b[0m \u001b[31m52.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hBuilding wheels for collected packages: fhir_query, halo\n", + " Building wheel for fhir_query (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n", + " Created wheel for fhir_query: filename=fhir_query-0.1.0-py3-none-any.whl size=21448 sha256=113a26fbb387e07b1213b4e64e23c8e0ad23771aba71e493f8b4dfb785caf99c\n", + " Stored in directory: /tmp/pip-ephem-wheel-cache-49mrxawv/wheels/bd/1c/ed/2a7d815d865da44b126c27d1cc954bb09f65eba557e4f4de43\n", + " Building wheel for halo (setup.py) ... \u001b[?25l\u001b[?25hdone\n", + " Created wheel for halo: filename=halo-0.0.31-py3-none-any.whl size=11233 sha256=8b7f423d8f3309f5ffeb806ffae35ab74d0f8b4027dec017749f0b18963fad06\n", + " Stored in directory: /root/.cache/pip/wheels/2e/b1/0a/62566170555f623c8327d47df1f53b6e4311ec9dd0ea70a99c\n", + "Successfully built fhir_query halo\n", + "Installing collected packages: spinners, jedi, inflection, dotty-dict, colorama, click_default_group, log_symbols, pyvis, halo, fhir-core, fhir.resources, fhir_query\n", + "Successfully installed click_default_group-1.2.4 colorama-0.4.6 dotty-dict-1.3.1 fhir-core-1.0.0 fhir.resources-8.0.0b4 fhir_query-0.1.0 halo-0.0.31 inflection-0.5.1 jedi-0.19.2 log_symbols-0.0.14 pyvis-0.3.2 spinners-0.0.24\n" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "# verify the tool was installed" + ], + "metadata": { + "id": "bE5wRXQLXq9q" + } + }, + { + "cell_type": "code", + "source": [ + "!fq" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "Tv_zSM8QzhFe", + "outputId": "4b23fdc1-f6ec-42ff-fb53-8b67af8df251" + }, + "execution_count": 4, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "\u001b[0mUsage: fq [OPTIONS] COMMAND [ARGS]...\n", + "\n", + " Run FHIR GraphDefinition traversal.\n", + "\n", + "Options:\n", + " --help Show this message and exit.\n", + "\n", + "Commands:\n", + " main* Run FHIR GraphDefinition traversal.\n", + " dataframe Create dataframes from the local db.\n", + " summarize Summarize the aggregation results.\n", + " visualize Visualize the aggregation results.\n", + " vocabulary Retrieve Vocabulary Observation and ResearchStudy resources...\n", + "\u001b[0m\u001b[0m" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "# retrieve vocabularies used on commonly used resources" + ], + "metadata": { + "id": "RMOiiooTX2O7" + } + }, + { + "cell_type": "code", + "source": [ + "%env FHIR_BASE=https://google-fhir.test-fhir-aggregator.org\n", + "!fq vocabulary vocabulary.tsv --fhir-base-url $FHIR_BASE" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "F3f8LCBVzrau", + "outputId": "a62b97f4-e71d-485c-f972-3f9e36c9cbaa" + }, + "execution_count": 5, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "env: FHIR_BASE=https://google-fhir.test-fhir-aggregator.org\n", + "\u001b[0m\u001b[K\u001b[0m\u001b[?25h\u001b[0m\u001b[32m✔\u001b[39m Wrote 155 vocabularies to vocabulary.tsv\n", + "\u001b[0m\u001b[K\u001b[0m\u001b[?25h\u001b[0m\u001b[0m" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "### show vocabularies" + ], + "metadata": { + "id": "eL23EtowK-uW" + } + }, + { + "cell_type": "code", + "source": [ + "import pandas as pd\n", + "import dtale.app as dtale_app\n", + "import dtale\n", + "df = pd.read_csv('vocabulary.tsv', sep='\\t')\n", + "dtale_app.USE_COLAB = True\n", + "dtale.show(df)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 35 + }, + "id": "7Vr_-finLFY4", + "outputId": "6e76a6b5-b48b-48d5-b5c4-24ff850a9e4c" + }, + "execution_count": 10, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "https://zuqdi8bb94-496ff2e9c6d22116-40000-colab.googleusercontent.com/dtale/main/2" + ] + }, + "metadata": {}, + "execution_count": 10 + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "# retrieve a pre-defined set of queries, a GraphDefinition\n", + "## in this case, retrieve an entire study" + ], + "metadata": { + "id": "rC0RUQB7YqLs" + } + }, + { + "cell_type": "code", + "source": [ + "!wget https://raw.githubusercontent.com/FHIR-Aggregator/fhir-query/refs/heads/main/graph-definitions/R5/ResearchStudyGraph.yaml\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "YIfuKz6u64Zt", + "outputId": "395587d4-226f-4bed-dd2b-61c81fed4c80" + }, + "execution_count": 27, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "--2025-02-11 23:24:35-- https://raw.githubusercontent.com/FHIR-Aggregator/fhir-query/refs/heads/main/graph-definitions/R5/ResearchStudyGraph.yaml\n", + "Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.108.133, 185.199.111.133, 185.199.110.133, ...\n", + "Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.108.133|:443... connected.\n", + "HTTP request sent, awaiting response... 200 OK\n", + "Length: 1840 (1.8K) [text/plain]\n", + "Saving to: ‘ResearchStudyGraph.yaml.2’\n", + "\n", + "\r ResearchS 0%[ ] 0 --.-KB/s \rResearchStudyGraph. 100%[===================>] 1.80K --.-KB/s in 0s \n", + "\n", + "2025-02-11 23:24:36 (25.0 MB/s) - ‘ResearchStudyGraph.yaml.2’ saved [1840/1840]\n", + "\n" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "# export the data to a local database" + ], + "metadata": { + "id": "tp9q7SP3Y50J" + } + }, + { + "cell_type": "code", + "source": [ + "%env FHIR_BASE=https://google-fhir.test-fhir-aggregator.org\n", + "# export a study using a set of stored queries\n", + "!fq --fhir-base-url $FHIR_BASE --graph-definition-file-path ResearchStudyGraph.yaml --path '/ResearchStudy?identifier=TCGA-KIRC'" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "q7aoCQEZ6nEs", + "outputId": "cdb9138a-d41d-4423-8a64-b5f0779afe52" + }, + "execution_count": 28, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "env: FHIR_BASE=https://google-fhir.test-fhir-aggregator.org\n", + "research-study-graph is valid FHIR R5 GraphDefinition\n", + "\u001b[0m\u001b[K\u001b[0m\u001b[?25h\u001b[0m\u001b[32m✔\u001b[39m Fetching https://google-fhir.test-fhir-aggregator.org/ResearchStudy?identifier=TCGA-KIRC\n", + "\u001b[0m\u001b[K\u001b[0m\u001b[?25h\u001b[0m\u001b[32m✔\u001b[39m Processing link: ResearchSubject/study={path} with 1 ResearchStudy(s)\n", + "\u001b[0m\u001b[K\u001b[0m\u001b[?25h\u001b[0m\u001b[32m✔\u001b[39m Processing link: Group/part-of-study={path}&_count=1000&_total=accurate with 1 ResearchStudy(s)\n", + "\u001b[0m\u001b[K\u001b[0m\u001b[?25h\u001b[0m\u001b[32m✔\u001b[39m Processing link: Patient/part-of-study={path}&_count=1000&_total=accurate with 1 ResearchStudy(s)\n", + "\u001b[0m\u001b[K\u001b[0m\u001b[?25h\u001b[0m\u001b[32m✔\u001b[39m Processing link: Specimen/part-of-study={path}&_count=1000&_total=accurate with 1 ResearchStudy(s)\n", + "\u001b[0m\u001b[K\u001b[0m\u001b[?25h\u001b[0m\u001b[32m✔\u001b[39m Processing link: Observation/part-of-study={path}&_count=1000&_total=accurate with 1 ResearchStudy(s)\n", + "\u001b[0m\u001b[K\u001b[0m\u001b[?25h\u001b[0m\u001b[32m✔\u001b[39m Processing link: Procedure/part-of-study={path}&_count=1000&_total=accurate with 1 ResearchStudy(s)\n", + "\u001b[0m\u001b[K\u001b[0m\u001b[?25h\u001b[0m\u001b[32m✔\u001b[39m Processing link: DocumentReference/part-of-study={path}&_count=1000&_total=accurate with 1 ResearchStudy(s)\n", + "\u001b[1m\u001b[36m⠹\u001b[0m Processing link: ServiceRequest/part-of-study={path}&_count=1000&_total=accurate with 1 Rese (...)" + ] + }, + { + "output_type": "stream", + "name": "stderr", + "text": [ + "/usr/local/lib/python3.11/dist-packages/dtale/column_analysis.py:402: FutureWarning:\n", + "\n", + "pandas.value_counts is deprecated and will be removed in a future version. Use pd.Series(obj).value_counts() instead.\n", + "\n" + ] + }, + { + "output_type": "stream", + "name": "stdout", + "text": [ + "\u001b[1m\u001b[36m⠹\u001b[0m Processing link: ServiceRequest/part-of-study={path}&_count=1000&_total=accurate with 1 Rese (...)" + ] + }, + { + "output_type": "stream", + "name": "stderr", + "text": [ + "/usr/local/lib/python3.11/dist-packages/dtale/column_analysis.py:511: FutureWarning:\n", + "\n", + "pandas.value_counts is deprecated and will be removed in a future version. Use pd.Series(obj).value_counts() instead.\n", + "\n" + ] + }, + { + "output_type": "stream", + "name": "stdout", + "text": [ + "\u001b[1m\u001b[36m⠋\u001b[0m Processing link: ServiceRequest/part-of-study={path}&_count=1000&_total=accurate with 1 Rese (...)" + ] + }, + { + "output_type": "stream", + "name": "stderr", + "text": [ + "/usr/local/lib/python3.11/dist-packages/dtale/column_analysis.py:402: FutureWarning:\n", + "\n", + "pandas.value_counts is deprecated and will be removed in a future version. Use pd.Series(obj).value_counts() instead.\n", + "\n" + ] + }, + { + "output_type": "stream", + "name": "stdout", + "text": [ + "\u001b[1m\u001b[36m⠧\u001b[0m Processing link: ServiceRequest/part-of-study={path}&_count=1000&_total=accurate with 1 Rese (...)" + ] + }, + { + "output_type": "stream", + "name": "stderr", + "text": [ + "/usr/local/lib/python3.11/dist-packages/dtale/column_analysis.py:402: FutureWarning:\n", + "\n", + "pandas.value_counts is deprecated and will be removed in a future version. Use pd.Series(obj).value_counts() instead.\n", + "\n" + ] + }, + { + "output_type": "stream", + "name": "stdout", + "text": [ + "\u001b[0m\u001b[K\u001b[0m\u001b[?25h\u001b[0m\u001b[32m✔\u001b[39m Processing link: ServiceRequest/part-of-study={path}&_count=1000&_total=accurate with 1 ResearchStudy(s)\n", + "\u001b[0m\u001b[K\u001b[0m\u001b[?25h\u001b[0m\u001b[32m✔\u001b[39m Processing link: ImagingStudy/part-of-study={path}&_count=1000&_total=accurate with 1 ResearchStudy(s)\n", + "\u001b[0m\u001b[K\u001b[0m\u001b[?25h\u001b[0m\u001b[32m✔\u001b[39m Processing link: Condition/part-of-study={path}&_count=1000&_total=accurate with 1 ResearchStudy(s)\n", + "\u001b[0m\u001b[K\u001b[0m\u001b[?25h\u001b[0m\u001b[31m✖\u001b[39m Could not find any resources for MedicationAdministration->Medication link: {'params': '_id={path}&_count=1000&_total=accurate', 'path': 'MedicationAdministration.medication.reference.reference', 'sourceId': 'MedicationAdministration', 'targetId': 'Medication'}\n", + "\u001b[0m\u001b[K\u001b[0m\u001b[?25h\u001b[0mAggregated Results: {'Condition': 537, 'DocumentReference': 29352, 'Group': 16, 'ImagingStudy': 2177, 'MedicationAdministration': 1074, 'Observation': 27286, 'Patient': 537, 'Procedure': 1616, 'ResearchStudy': 1, 'ResearchSubject': 537, 'ServiceRequest': 27163, 'Specimen': 17121}\n", + "\u001b[0mdatabase available at: /tmp/fhir-graph.sqlite\n", + "\u001b[0m\u001b[K\u001b[0m\u001b[?25h\u001b[0m\u001b[0m" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "# summarize the extracted data\n", + "!fq summarize" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "DPFNAP3PX4GA", + "outputId": "8d784299-8975-43d3-c7eb-e77b45db4056" + }, + "execution_count": 29, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Condition\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m537\u001b[0m\n", + "\u001b[0m \u001b[0mreferences\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mEncounter\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m537\u001b[0m\n", + "\u001b[0m \u001b[0mObservation\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m4889\u001b[0m\n", + "\u001b[0m \u001b[0mPatient\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m537\u001b[0m\n", + "\u001b[0m \u001b[0mResearchStudy\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m537\u001b[0m\n", + "\u001b[0mDocumentReference\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m29352\u001b[0m\n", + "\u001b[0m \u001b[0mreferences\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mGroup\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m16\u001b[0m\n", + "\u001b[0m \u001b[0mPatient\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m29336\u001b[0m\n", + "\u001b[0m \u001b[0mResearchStudy\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m29352\u001b[0m\n", + "\u001b[0m \u001b[0mServiceRequest\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m27163\u001b[0m\n", + "\u001b[0m \u001b[0mSpecimen\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m35332\u001b[0m\n", + "\u001b[0mGroup\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m16\u001b[0m\n", + "\u001b[0m \u001b[0mreferences\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mPatient\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m8592\u001b[0m\n", + "\u001b[0m \u001b[0mResearchStudy\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m16\u001b[0m\n", + "\u001b[0mImagingStudy\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m2177\u001b[0m\n", + "\u001b[0m \u001b[0mreferences\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mPatient\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m2177\u001b[0m\n", + "\u001b[0m \u001b[0mResearchStudy\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m2177\u001b[0m\n", + "\u001b[0m \u001b[0mSpecimen\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m2177\u001b[0m\n", + "\u001b[0mMedicationAdministration\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m1074\u001b[0m\n", + "\u001b[0m \u001b[0mreferences\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mPatient\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m1074\u001b[0m\n", + "\u001b[0m \u001b[0mResearchStudy\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m1074\u001b[0m\n", + "\u001b[0mObservation\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m27286\u001b[0m\n", + "\u001b[0m \u001b[0mreferences\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mCondition\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m3242\u001b[0m\n", + "\u001b[0m \u001b[0mDocumentReference\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m2375\u001b[0m\n", + "\u001b[0m \u001b[0mEncounter\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m537\u001b[0m\n", + "\u001b[0m \u001b[0mImagingStudy\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m2177\u001b[0m\n", + "\u001b[0m \u001b[0mObservation\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m3815\u001b[0m\n", + "\u001b[0m \u001b[0mPatient\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m29657\u001b[0m\n", + "\u001b[0m \u001b[0mResearchStudy\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m27286\u001b[0m\n", + "\u001b[0m \u001b[0mSpecimen\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m36419\u001b[0m\n", + "\u001b[0mPatient\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m537\u001b[0m\n", + "\u001b[0m \u001b[0mreferences\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mResearchStudy\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m537\u001b[0m\n", + "\u001b[0mProcedure\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m1616\u001b[0m\n", + "\u001b[0m \u001b[0mreferences\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mEncounter\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m1616\u001b[0m\n", + "\u001b[0m \u001b[0mPatient\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m1616\u001b[0m\n", + "\u001b[0m \u001b[0mResearchStudy\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m1616\u001b[0m\n", + "\u001b[0mResearchStudy\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m1\u001b[0m\n", + "\u001b[0m \u001b[0mreferences\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mResearchStudy\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m1\u001b[0m\n", + "\u001b[0mResearchSubject\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m537\u001b[0m\n", + "\u001b[0m \u001b[0mreferences\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mPatient\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m537\u001b[0m\n", + "\u001b[0m \u001b[0mResearchStudy\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m1074\u001b[0m\n", + "\u001b[0mServiceRequest\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m27163\u001b[0m\n", + "\u001b[0m \u001b[0mreferences\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mPatient\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m27163\u001b[0m\n", + "\u001b[0m \u001b[0mResearchStudy\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m27163\u001b[0m\n", + "\u001b[0m \u001b[0mSpecimen\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m35332\u001b[0m\n", + "\u001b[0mSpecimen\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m17121\u001b[0m\n", + "\u001b[0m \u001b[0mreferences\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mPatient\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m17121\u001b[0m\n", + "\u001b[0m \u001b[0mResearchStudy\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m17121\u001b[0m\n", + "\u001b[0m \u001b[0mSpecimen\u001b[0m:\u001b[0m\n", + "\u001b[0m \u001b[0mcount\u001b[0m:\u001b[0m \u001b[0m15505\u001b[0m\n", + "\u001b[0m\u001b[0m" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "# create a dataframe from the extracted data\n", + "!fq dataframe\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "Tw-f40aaYLF-", + "outputId": "719db063-141b-4e34-877c-e7be7ae8c457" + }, + "execution_count": 31, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Saved /tmp/fhir-graph.tsv\u001b[0m\n", + "\u001b[0mSaved /tmp/fhir-graph.tsv\u001b[0m\n", + "\u001b[0m\u001b[0m" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "import pandas as pd\n", + "import dtale.app as dtale_app\n", + "import dtale\n", + "df = pd.read_csv('/tmp/fhir-graph.tsv')\n", + "dtale_app.USE_COLAB = True\n", + "dtale.show(df)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 106 + }, + "id": "eeTfa9I_YZK3", + "outputId": "077b394a-85a5-4d4d-cd86-36482b9584f9" + }, + "execution_count": 33, + "outputs": [ + { + "output_type": "stream", + "name": "stderr", + "text": [ + ":4: DtypeWarning:\n", + "\n", + "Columns (36) have mixed types. Specify dtype option on import or set low_memory=False.\n", + "\n" + ] + }, + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "https://zuqdi8bb94-496ff2e9c6d22116-40000-colab.googleusercontent.com/dtale/main/4" + ] + }, + "metadata": {}, + "execution_count": 33 + } + ] + } + ] +} \ No newline at end of file