Healthcare Journey

For this section, we will use Healthcare Journey as the example to show how to integrate your own PMML model with Project Journey. This tutorial will guide you to build the following architecture step by step

healthcare architecture

First we will build your own tgdb for healthcare then create a Spotfire mod for visualization. After that, we will create a liveapp for case management, also create your own model to do suspicious claim detection. Then create a Spotfire dahsboard to visualize all component and pack into one application by TIBCO Cloud Composer. Let’s start!

1. Build your own Graph Database

a. Switch to the tgdb example folder and create a folder “healthcare-journey”

cd /home/ec2-user/tgdb/3.0/example
mkdir healthcare-journey
cd healthcare-journey

b. Copy the default configuration file from “routes” example to modify

cp /home/ec2-user/tgdb/3.0/example/routes/routesdb.conf healthcaredb.conf

c. Modify the configuration base on your data

The configuration under the following section should be replaced with your own configuration.
・[database]: The basic information for your graph database
・[attrtypes]: The definition about the attribute
・[nodetypes]: Define the attribute for nodes
・[edgetypes]: Define the attribute for edges
・[indices]: Define the indices for nodes
・[import]: Define the import data path for nodes and edges

[database]

#Database name, path, locale and timezone.
name = healthcaredb # name of the database
dbPath = ../data # path of the database. Full or relative path.
locale = en_US.UTF-8
timezone = UTC

#############################################################################
########### I N I T I Z A T I O N C O N F I G U R A T I O N S ###########
#############################################################################
……

[attrtypes]
doctorID = @type:string
departmentID = @type:string
dr_firstname = @type:string
dr_lastname = @type:string
dr_gender = @type:string
dr_title = @type:string
patientID = @type:string
p_firstname = @type:string
p_lastname = @type:string
p_gender = @type:string
claimID = @type:string
c_name = @type:string
treatID = @type:string
t_name = @type:string
addressID = @type:string
addressdetail = @type:string
relation = @type:string

[nodetypes]

doctor = @attrs:doctorID,departmentID,dr_firstname,dr_lastname,dr_gender,dr_title @pkey:doctorID
patient = @attrs:patientID,p_firstname,p_lastname,p_gender @pkey:patientID
claim = @attrs:claimID,c_name @pkey:claimID
treatment = @attrs:treatID,t_name @pkey:treatID
address = @attrs:addressID,addressdetail @pkey:addressID

[edgetypes]

claimfollow = @direction:Directed @fromnode:claim @tonode:claim @attrs:relation
claimfortreat = @direction:Directed @fromnode:claim @tonode:treatment @attrs:relation
claimwith = @direction:Directed @fromnode:claim @tonode:doctor @attrs:relation
has = @direction:Directed @fromnode:patient @tonode:claim @attrs:relation
register = @direction:Directed @fromnode:doctor @tonode:address @attrs:relation
treatlocate = @direction:Directed @fromnode:treatment @tonode:address @attrs:relation

[indices]

doctorIdx = @attrs:doctorID @unique:true @ontype:doctor
patientIdx = @attrs:patientID @unique:true @ontype:patient
claimIdx = @attrs:claimID @unique:true @ontype:claim
treatIdx = @attrs:treatID @unique:true @ontype:treatment
addressIdx = @attrs:addressID @unique:true @ontype:address

[import]

dir = ./import
loadopts = insert
erroropts = stop
dtformat = ymd
doctor = @attrs:doctorID,departmentID,dr_firstname,dr_lastname,dr_gender,dr_title @files:N_doctorType.csv
patient = @attrs:patientID,p_firstname,p_lastname,p_gender @files:N_patientType.csv
claim = @attrs:claimID,c_name @files:N_claimType.csv
treatment = @attrs:treatID,t_name @files:N_treatmentcenterType.csv
address = @attrs:addressID,addressdetail @files:N_addressType.csv
claimfollow = @attrs:relation @files:E_claimfollowType.csv
claimfortreat = @attrs:relation @files:E_claimfortreatType.csv
claimwith = @attrs:relation @files:E_claimwithType.csv
has = @attrs:relation @files:E_hasType.csv
register = @attrs:relation @files:E_registerType.csv
treatlocate = @attrs:relation @files:E_treatlocateType.csv

d. Create the “import” folder at the same place with healthcaredb.conf and put your data files into it. For this tutorial, you can use the files on GitHub

mkdir import

e. Modify the configuration of [databases] section in tgdb.conf

cd /home/ec2-user/tgdb/3.0/bin
cp tgdb.conf tgdb.conf.orig
vi tgdb.conf

[databases]
#demodb = ./demodb.conf
#routesdb = ../examples/routes/routesdb.conf
#tracedb = ../examples/trace/tracedb.conf
#housedb = ../examples/hierarchy/housedb.conf
healthcaredb = ../examples/healthcare-journey/healthcaredb.conf

f. Initiate your graph database

cd /home/ec2-user/tgdb/3.0/bin
./tgdb -i -c tgdb.conf

You will see the successful message as below

healthcare tgdb init

g. Start your graph database

 ./tgdb -s -c tgdb.conf

You will see the graph database started with the message below

healthcare tgdb start

h. Open another windows and use tgdb-admin to verify graph database

./tgdb-admin --url tcp://localhost:8222 --db healthcaredb --uid scott --pwd scott

You can use the example Gremlin query as below: g.V().has(‘doctor’,‘doctorID’,‘D175961135’).repeat(bothE().bothV()).times(3).path();

healthcare tgdb test

i. Start the REST service of graph database for Spotfire connect later

./tgdb-rest --dburl tcp://localhost:8222/{dbName=healthcaredb} --listen <your hostname>:9500

You will see the successful message as below

healthcare tgdb rest server

j. Start nginx as reverse proxy
Download and unzip file from GitHub and put on the tgdb instance.
Config your tgdb hostname and port in nginx.conf. Generate the certificate by running gen_cert.sh.

vi nginx/nginx.conf


server {
listen 9505;
server_name ec2-X-X-X-X.us-east-2.compute.amazonaws.com;

proxy_ssl_name X.X.X.X;

proxy_pass http://ec2-X-X-X-X.us-east-2.compute.amazonaws.com:9500;

proxy_redirect http://ec2-X-X-X-X.us-east-2.compute.amazonaws.com:9504 https://ec2-X-X-X-X.us-east-2.compute.amazonaws.com:9505;
}

sh gen_cert.sh

Then, use the following command to start nginx

docker run --name my-custom-nginx-container -v <<your nginx folder location>>:/etc/nginx -p 9504-9505:9504-9505 -d nginx
docker container ls -a

You will see the nginx container status is up

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6dc721149b93 nginx “/docker-entrypoint.…” 12 seconds ago Up 11 seconds 80/tcp, 0.0.0.0:9504-9505->9504-9505/tcp, :::9504-9505->9504-9505/tcp my-custom-nginx-container f0a56e912506 nginx

2. Build your own Spotfire Mods

Spotfire Mod is built by Typescript with Angular, you can custom your mod function with Javascript. In this section, we modify the Spotfire Mod base on the Mod file on GitHub to custom a mod for Healthcare Journey.

a. Download the files from GitHub and extract on your local laptop then copy the folder from journey-tgdb-mods to journey-healthcare-mods

cd labs-journey/src/journey_mods
cp -r journey-tgdb-mods journey-healthcare-mods
cd journey-healthcare-mods

b. Modify main.js Comment out createTerminal function (the code from Line 181 to Line 254 and 416) to remove the query function


/*function createTerminal(url, token, entities, restSslPort) {
console.log(“term:”, term);
if (term == null) {
//const term = new Terminal({
term = new Terminal({
cursorStyle: “block”,
cursorBlink: true,
rendererType: ‘dom’,
});
… }*/

//createTerminal(url, token, entities, restSslPort);

Comment out the textContent (Line 289 to Line 291)


//container.textContent = `windowSize: ${windowSize.width}x${windowSize.height}\r\n`;
//container.textContent += `should render: ${rows.length} rows\r\n`;
//container.textContent += `${prop.name}: ${prop.value()}`;

Change the carPlateNumber variable to DoctorID (Line 322, 348, 385-388)


let DoctorID = “”;

DoctorID = row.categorical(axis.name).formattedValue();

if (DoctorID != null && DoctorID != "" && DoctorID != “(Empty)”) {
query = “g.V().has(‘doctor’,‘doctorID’,’” + DoctorID + “’).repeat(bothE().bothV()).times(3).path();”;
console.log(query);
}

c. Modify mod-manifest.json

Modify the content in the “Properties” to change your default query


“properties”: [
{
“name”: “myProperty”,
“type”: “string”,
“defaultValue”: “myValue”
},
{
“name”: “restSslPort”,
“type”: “string”,
“defaultValue”: “9505”
},
{
“name”: “defaultQuery”,
“type”: “string”,
“defaultValue”: “g.V().has(‘doctor’,‘doctorID’,‘D351297720’).bothE().bothV().bothE().bothV().bothE().bothV().path();”
}
]

Modify the content in the “externalResources” section to make sure put your own hostname

“externalResources”: [
“https:/ /ec2-X-X-X-X.us-east-2.compute.amazonaws.com:9505/TGDB/Query/”,
“https://jsonplaceholder.typicode.com/users”,
“https://cdnjs.cloudflare.com/ajax/libs/xterm/3.14.5/xterm.min.js”,
“ws://localhost:3000/”,
“http://127.0.0.1:9001/xterm-addon-fit/lib/xterm-addon-fit.js”,
“http://localhost:9501/TGDB/Query/”
]

d. Start you Spotfire mod

npm run server

You would see the message below healthcare mod start

3. Build your own LiveApp

Project Journey would utilize the TIBCO Cloud Live Apps to build an application for case investigation function

a. Login to TIBCO Cloud Live Apps - Designer healthcare login liveapp

b. Click New Application on the top right then select Blank Application with the name Healthcare and click Add healthcare add new liveapp

c. Click on the Case Data icon on the right side of the menu then create the data fields with the following information healthcare case data

CaseID
healthcare case data - CaseID

FraudType
healthcare case data - FraudType

DoctorID
healthcare case data - DoctorID

DoctorName
healthcare case data - DoctorName

Description
healthcare case data - Description

d. Click on the States on the right side of the menu and create the state list as the following information

Investigated: active state
Cancel: end state
Close: end state

healthcare state

e. Click on the Application on the right side of the menu, you will see two default actions on the list. Rename them to CreateCase and Decide healthcare state action

f. Click into CreateCase and configure with the following information healthcare state action - CreateCase
healthcare state action - CreateCase

g. Click into Decide and configure with the following information healthcare state action - Decide

h. Click on the App flow viewer on the right side of the menu to check the flow healthcare app flow viewer

i. Now you can click on the Test App icon on the top right to verify your Live app. If there is no error, then you can click the Lock for publication to publish your application. healthcare test app

j. Switch to the TIBCO Cloud Live Apps - Administrator to publish your application healthcare publish app healthcare publish app healthcare publish app

4. Build your own healthcare fraud detection service and sent the results to Spotfire

Project Journey supports any runtime service, in this tutorial, we would use the fraud detection PMML model trained by TIBCO Data Science - Team Studio and publish the model as the runtime service by following the guide of openscoring. Then, the prediction result would be sent to TIBCO Spotfire through TIBCO Cloud Messaging and TIBCO Cloud Data Streams. You can reference the script on GitHub for detail.

a. Start and verify the runtime service by the Postman
healthcare verify the model runtime service

b. Connect to TIBCO Cloud Messaging
Download example script on the TIBCO Cloud Messaging portal according to your preferred language (use python3 in this tutorial). Follow the Quick Start Guide to connect the TCM. Then, you can modify the example script you downloaded to send prediction results to TCM.
You need to go to TCM portal -> Authentication to create the role with appropreate permission and download the tcm-config.yaml for connection used.
Please reference the script on GitHub for detail. healthcare tcm-config

c. Create a TIBCO Cloud Data Stream
Login the the TIBCO Cloud Data Streams
healthcare login data stream

Click Create New on the top left to create a new Data Stream
healthcare create new data stream

Select TIBCO Cloud Messaging as data source
healthcare select data source

Select Other channel and type the connection information, the connection information will be in the tcm-config.yaml file which you downloaded from TCM portal -> Authentication. healthcare connect data source

Modify the Content Matcher setting if need, we use the default setting in this tutorial
healthcare content matcher

Define your data stream schema
You can use the script you built at the previous step(b. Connect to TIBCO Cloud Messaging ) to inject data then the data stream schema would be generated automatically. You can also type the schema manually.
healthcare create data streams schema

Modify the retention policy if need, we use the default setting in this tutorial
healthcare data streams retention policy

Set the data stream name to Healthcare_Fraud_Stream and your own password
healthcare data streams password

Check the configurations are correct then click finish
healthcare data streams summary

Start the data stream and wait a few minutes and check the status is running.
healthcare data streams start

Use the script you built in the previous step to verify the data can get into the Data stream successfully. If yes, the data will show in the Data Stream Preview on the right side
healthcare data streams test

Look up the connection information, would use it in the next section
healthcare data streams connection information healthcare data streams connection information

5. Build your own Dashboard

Before we start, let’s check if all the following components are prepared.
・Healthcare journey graph database
・Healthcare journey spotfire mod
・Healthcare journey Live App
・Healthcare journey Data Stream

Now we are going to put all the components together in Spotfire.

a. Connect the graph database

Please follow the steps in Add data from TGDB by Spotfire Analytics/Desktop section to connect the graph database.

b. Connect the Live App

Add a new data source from TIBCO Cloud Live Apps connector then click New connection
healthcare spotfire liveapp connection

Type the connection information then connect
healthcare spotfire liveapp connection info

Find the Healthcare Live App and click OK to add the data source as new table healthcare spotfire add liveapp table

In this tutorial, we would need an extra column for searching the graph database dynamically when the specific ID be marked. Click Transform data
healthcare spotfire transform liveapp table

Select Calculate the new column in the drop-down menu then click Insert
healthcare spotfire transform liveapp table

Insert the DoctorID column and name it as searchText
healthcare spotfire add searchtext column

You can preview it at the Data Canvas
healthcare spotfire check searchtext column

Drag and drop the Table to visualize the Live App Data
healthcare spotfire visualize liveapp table
healthcare spotfire visualize liveapp table

Add the Live App data as new rows to tgdb data
Click the Data Canvas and select the tgdb data source then add Live App data as new rows to tgdb data. In the preview table, the tgdb also has the column searchText column now.

healthcare spotfire add liveapp table to tgdb conn info table

c. Connect the Data Stream

Add a new data source from TIBCO Cloud Spotfire Data Streams connector then click New connection
Use the connection information you get at the last step in the section Build your own healthcare fraud detection service

healthcare spotfire data stream connect
healthcare spotfire data stream connect

Select the Healthcare_Fraud_Stream and add as a new table
healthcare spotfire data stream import table
healthcare spotfire data stream import table

Drag and drop the Table to visualize the Data Stream data. You can only see the schema since the data do not inject into Data Streams yet.
healthcare spotfire data stream schema

Run the script to inject data to verify
healthcare spotfire data stream test

d. Link the all tables by DoctorID

We need to link the tables by DoctorID, so all the related data would be marked if we mark the specific DoctorID.
Choose one of the data sources and select “DoctorID” and click “Link data tables”. Do the same setting for every data source.
healthcare spotfire link tables

Save the dxp

e. Connect the Healthcare Spotfire Mod

Login to the TIBCO Cloud Spotfire and open the dxp file. You will be asked to type the credential information to connect the data.

Follow the same steps in the section Configure Spotfire Mod on Spotfire Cloud to load your spotfire mod. You can see the graph for the default query show in the dashboard. If the graph do not show successfully, please follow the Troubleshooting section to check the certification.
healthcare spotfire mod start

Now inject the data to Data streams and mark one specific row. For example, Doctor ID: D1375503918 Neil Kade. You can see the graph change dynamically.

healthcare spotfire mod test

Of cource, you can add any components you want (like investigation case numbers, geo-map to show the location and etc.) to make the dahsboard more beautiful!
healthcare journey

Save the dashboard to TIBCO Cloud Spotfire library. healthcare spotfire save library

6. Integrate your dashboard into the application

After we get the dashboard, we also would like to pack it with the Live app function( create/update the case in time) into the application. TIBCO Cloud Composer is a good tool to quickly build an application based on Angular and also integrate the Live app function and your dashboard into one application. You can follow the tutorial to pack your dashboard into the application.

7. Test Healthcare Journey

a. Turn on the UI on the browser (e.g. https://localhost:4200)

b. Check the tcm-config.yaml (locate at labs-journey/src/reference/HealthcareJourney/scripts) has correct connection information

c. Turn on the Suspicious Detection Service

cd labs-journey/src/reference/HealthcareJourney/scripts
sh start_healthcare_model.sh

d. Inject the Testing data

cd labs-journey/src/reference/HealthcareJourney/scripts
python healthcare_data_publisher.py

e. Back to check the UI, you will see the model results come in

f. Mark one of data then the graph will change dynamically

healthcare journey


Last modified May 17, 2022: update src and doc (86fdab08)