Skip to content
Permalink
Browse files
add project files
  • Loading branch information
frank committed May 4, 2022
1 parent 236bab8 commit d9b0918131dbd46a9b353a700249486dd5c6fc5b
Showing with 476 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +34 −0 README.md
  3. +6 −0 config.py
  4. +211 −0 hapi_fhir.ipynb
  5. BIN images/1.png
  6. BIN images/2.png
  7. BIN images/hapi_fhir_logo_new.jpeg
  8. BIN images/hapifhir.png
  9. +148 −0 resources.py
  10. +75 −0 util.py
@@ -0,0 +1,2 @@
.ipynb*
__py*
@@ -0,0 +1,34 @@
# CSE 5810 Biomedical Informatics (Spring 2022)

[![N|Solid](https://ddfoqzqsu0zvp.cloudfront.net/media/documents/school-of-engineering-wordmark-side-blue.png)](https://www.cse.uconn.edu/)

---

## Implementation Project Final Status
### **Frank Zappulla**
---

#### Requirements

- *For Windows Users Only* - [install WSL2](https://www.youtube.com/watch?v=n-J9438Mv-s&t=51s)
- This will give you a real linux terminal where you can use conda
- Conda
- If you don't have Conda, you should install [miniconda](https://docs.conda.io/en/latest/miniconda.html)
- [Docker](https://docs.docker.com/get-docker/)

---
### Getting Started Instructions
1. Start your local instance of [HAPI FHIR](https://github.uconn.edu/frz02001/HAPI_FHIR)
2. clone this repository
- `git clone https://github.uconn.edu/frz02001/cse5810_implementation.git`
3. Change directory into this repository
- `cd cse5810_implementation`
4. Create your conda environment using the included yaml file
- `conda env create --file=hapi_fhir.yaml`
5. Activate the conda environment you just created
- `conda activate hapi_fhir`
6. Launch jupyter lab
- `jupyter lab`
7. Copy and paste the url in the terminal into your browser
8. Double click on the `hapi_fhir.ipynb` file to open the developer's notebook
9. You should now be using the notebook that was demonstrated during class
@@ -0,0 +1,6 @@

app_id = 'my_web_app'
api_base = 'http://localhost:8080/fhir'
swagger_url = "http://hapi.fhir.org/baseR4/swagger-ui/#/"
format_ = "_format=json"
pretty = "_pretty=true"
@@ -0,0 +1,211 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "48b1ba4f-ccb9-4889-840f-72440cd35d8a",
"metadata": {},
"source": [
"![hapi fhir logo](images/hapi_fhir_logo_new.jpeg)"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "0342149e-30b3-466f-8140-ca74002b9568",
"metadata": {},
"outputs": [],
"source": [
"from fhirclient import client\n",
"import json\n",
"import requests"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "5fcec681-274a-4bdb-b576-7709fd1e120b",
"metadata": {},
"outputs": [],
"source": [
"# settings\n",
"%run util.py"
]
},
{
"cell_type": "markdown",
"id": "6b1b75e6-6641-4463-aefa-7b2cfeb0ebb3",
"metadata": {},
"source": [
"### Check If HAPI Is Live\n",
"\n",
"check every available resource for a 200 status code"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "20fca573-2e6f-42c2-8a5a-94108bf57450",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"True\n"
]
}
],
"source": [
"print(is_hapi_live())"
]
},
{
"cell_type": "markdown",
"id": "48172346-a366-438b-9b9b-f5ffaea05e9f",
"metadata": {},
"source": [
"### Swagger Page"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "cb587bd6-1efc-4eae-a959-ff4a4160f94c",
"metadata": {},
"outputs": [],
"source": [
"# open the swagger web page to view all endpoints\n",
"open_swagger()"
]
},
{
"cell_type": "markdown",
"id": "2c49c504-b75b-4e6d-ae94-2f452b3a9581",
"metadata": {},
"source": [
"### Get Resource List"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7685af34-5956-46ae-a2d7-caa2504d1299",
"metadata": {},
"outputs": [],
"source": [
"# get resource list from hapi fhir running instance\n",
"\n",
"resources = get_resource_list()\n",
"print(f\"There are {len(resources)} resources available\")\n",
"print(\"The available resources are: \")\n",
"\n",
"idx = 0\n",
"for resource in resources:\n",
" print(f\"{idx}. {resource}\")\n",
" idx += 1\n"
]
},
{
"cell_type": "markdown",
"id": "4a8c5db7-2f09-4125-9fb0-3842fe97320c",
"metadata": {},
"source": [
"## Basic Functions"
]
},
{
"cell_type": "markdown",
"id": "bed91136-1210-4d11-ba72-da6f8bc6e89e",
"metadata": {},
"source": [
"### Check index"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "88e6ac2b-9f12-4dd5-84ad-c760830dabd0",
"metadata": {},
"outputs": [],
"source": [
"# test that getting index by name works\n",
"observation_index = get_resource_index(\"observation\")\n",
"patient_index = get_resource_index(\"PaTiEnT\")\n",
"\n",
"print(f\"\\nThe list index for Patient is {patient_index}\")\n"
]
},
{
"cell_type": "markdown",
"id": "78fc9a1e-f928-4cf1-99e7-692e361970e2",
"metadata": {},
"source": [
"### Get resource using index"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "53ae44ff-2710-4027-b28c-c0bc0ffbe600",
"metadata": {},
"outputs": [],
"source": [
"# Get resource using the index\n",
"\n",
"all_observations = get_json(resource=resources[observation_index])\n",
"all_patients = get_json(resource=resources[patient_index])\n",
"all_observations_json = json.loads(all_observations)\n",
"\n",
"print(f\"Observation keys: {all_observations_json.keys()}\")\n",
"\n",
"for k,v in all_observations_json.items():\n",
" print(f\"\\nkey: {k}\\nvalue: {v}\\n\")"
]
},
{
"cell_type": "markdown",
"id": "601e59a5-b39c-4e6f-b978-51294098b34e",
"metadata": {},
"source": [
"### Print JSON"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b33366a4-09db-40d8-b9a3-d982a0048f93",
"metadata": {},
"outputs": [],
"source": [
"\n",
"all_patients_json = json.loads(all_patients)\n",
"print(all_patients_json.keys())\n",
"\n",
"print(\"PATIENT\")\n",
"for elem in all_patients_json['entry']:\n",
" print(f\"\\n{elem}\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
BIN +14.5 KB images/1.png
Binary file not shown.
BIN +170 KB images/2.png
Binary file not shown.
Binary file not shown.
BIN +367 KB images/hapifhir.png
Binary file not shown.

0 comments on commit d9b0918

Please sign in to comment.