Dockerized Synthetic Healthcare Graph
Tags: healthcare, docker, tigergraph, synthea
Published: 2020-11-16 21:07:41

#### TL;DR
Adjust your Docker resources to:
```
Min 4    CPUs
Min 8GB  Memory
Min 2GB  Swap
Min 50GB Disk
```
With Docker Desktop running execute this command (CLI):
```
wget https://bit.ly/tg_workshop -O deploy_ws.sh && chmod +x deploy_ws.sh && ./deploy_ws.sh 2

```
> *Note: you should read this blog to set up your environment correctly or it might fail*

## Context
You might be thinking...

* What is this blog about?
* Why should this interest me? 
* What is a graph database?
* What is Synthea?

> *Note: skip to next to get started if you don't care about context*

Let's answer those questions first before moving on to how you can launch your own healthcare graph solution.


### What is this blog about?

A walkthrough of deploying a synthetic healthcare graph that mimics what a real healthcare graph solution would be modeled like using Docker, Gradle, and TigerGraph.

### Why should this interest me?

You might have heard of graph databases, but didn't know where to start. This project will help you with building a fully scripted graph solution. You can use this project as a template for building your own graph solutions. 

### What is a graph database?

A database that uses graph structures for semantic queries with nodes, edges, and properties to represent and store data.[1] 

A key concept of the system is the graph (or edge or relationship). The graph relates the data items in the store to a collection of nodes and edges, the edges representing the relationships between the nodes. 

The relationships allow data in the store to be linked together directly and, in many cases, retrieved with one operation. 

Graph databases hold the relationships between data as a priority. Querying relationships is fast because they are perpetually stored in the database.

### What is Synthea?

Synthea is an open-source, synthetic patient generator that models the medical history of synthetic patients. The aim is to provide high-quality, synthetic, realistic but not real, patient data and associated health records covering every aspect of healthcare. 


## Getting Started

### Pre-requirements

* wget
* docker
* docker-compose

#### wget
You will need to download `wget` if it's not already installed. To do that go to the appropriate download instructions:
* [Linux](https://www.tecmint.com/install-wget-in-linux/)
* [Windows](https://builtvisible.com/download-your-website-with-wget/)
* [Mac](https://www.cyberciti.biz/faq/howto-install-wget-om-mac-os-x-mountain-lion-mavericks-snow-leopard/)

#### Docker

If, you're looking for the easiest way to get docker running with a nice GUI interface is fetching the latest version of the Docker Desktop which you can download here: [https://www.docker.com/products/docker-desktop](https://www.docker.com/products/docker-desktop). 

> *Note: for this tutorial, we will be showing Docker Desktop screen captures*

Else, you can grab the Docker Engine and Compose separately with these links: [Docker](https://docs.docker.com/engine/install/) & [Docker-Compose](https://docs.docker.com/compose/install/)
 
> *Note: you will want Version > 1.25 of Docker Compose*

### Docker Configuration Settings

#### Setup Resources
Click the **settings** button (top right of Docker Desktop). Next, click on **Resources** and click **Advanced**. You should be seeing a screen that looks similar to this:

![Resources_Advanced](https://dev-to-uploads.s3.amazonaws.com/i/em0ekp0hcsjvbs7m0rf1.png)

To accommodate the resources need to run TigerGraph we will want to bump up the following:
```
Min 4    CPUs
Min 8GB  Memory
Min 2GB  Swap
Min 50GB Disk
```
Next, click **Apply & Restart**. Your settings should look like this:

![Resources_Advanced_2](https://dev-to-uploads.s3.amazonaws.com/i/g2su6jscmc9bqe6rbhsl.png)

#### Setup Bindings
Let's add some binding. Here is an example of what the default bindings look like. For this project, we will also add our new directory to the bindings.
![Resources_File_Sharing](https://dev-to-uploads.s3.amazonaws.com/i/13gubb78ydpg77ipx8eh.png)

It's recommended that you have a dedicated directory that this project will reside. If you don't have a directory built follow these few steps:

```
# Choose the appropriate location
# For this example we will just use a directory of the user
# Open Terminal and run the following:
$ cd
$ mkdir workspace
# cd workspace
#If you plan to do a few different builds you can make separate project folders in your new directory. Ex:
$ mkdir synthea
```

Next, click the "**+**" button and enter the path to the directory you're created. Once finished, hit *Apply & Restart*. Here is an example of what the bindings would look like:
![Resources_File_Sharing_2](https://dev-to-uploads.s3.amazonaws.com/i/t8cro5jvmmtl3r4fpgym.png)

### Run Installalation

Now for the last step. With Docker Desktop running execute this command in the terminal:
```
wget https://bit.ly/tg_workshop -O deploy_ws.sh && chmod +x deploy_ws.sh && ./deploy_ws.sh 2
```

Here is what you will start to see. The shell script starts to execute, download the latest TigerGraph image and boot it up before building the Healthcare Graph Solution:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/zq73qvs7brt339fw0chf.png)

Next, you will see that TigerGraph is running. Grab the URL http://localhost:14240 and paste that in your browser
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/7nt2sw1mwwf0vy8657e1.png)

Once you open up that URL and see the GraphStudio you will know your TigerGraph box is running properly:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ov5n0dltv1dzddkhgq50.png)

The next thing you will see in your Terminal is data files being added and the load will start
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/2nw0p2wfu0x2efwsvbwa.png)

Lastly, you will see some premade queries being installed:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/tkl7gacxg8qsumfgytca.png)

The whole process will take around 5-10 minutes. You can watch your data being loaded by going back to GraphStudio and clicking on **Load Data**. On the right-hand side, you should notice numbers climbing up. 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/rdlheal9a71npwxtervv.png)

## Want to Learn More?
This concludes the project build. If you are looking for a deep-dive into how the Sythea solution was developed, I highly suggest you check out these two blogs by [Akash Kaul:](http://akashkaul.com/)

#### [Modeling Healthcare Data with Graph Databases](https://towardsdatascience.com/modeling-healthcare-data-with-graph-databases-3e3695bcae3c)
*Using TigerGraph and Synthea to Create a Synthetic Healthcare System*

#### [Designing a 3D Healthcare Network Graph](https://towardsdatascience.com/designing-a-3d-healthcare-network-graph-291e4f75e9a5)
*A Cool Way To Model Healthcare Data using TigerGraph, Python, and JavaScript*


**Resources**
* [**TG Community Forum**](https://community.tigergraph.com)
* [**TG Community Chat**](https://discord.gg/F2c9b9v)
* [**TG Developer Portal**](https://dev.tigergraph.com)
* [**Reddit**](https://reddit.com/r/tigergraph)
* [**YouTube**](https://youtube.com/tigergraph)
* [**LinkedIn**](https://linkedin.com/company/tigergraph)
* [**Twitter**](https://twitter.com/tigergraphdb)
* [**Twitch**](https://twitch.tv/tigergraph)
* [**GitHub**](https://github.com/tigergraph/ecosys)

**Citations**

[1] *Nikolaos G. Bourbakis (1998). Artificial Intelligence and Automation. World Scientific. p. 381. ISBN 9789810226374. Retrieved 2018-04-20.*
[2] *https://en.wikipedia.org/wiki/Graph_database*