Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Healthcare Referral Starter Kit Queries #1

Open
wants to merge 1 commit into
base: 3.7
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CREATE QUERY README() FOR GRAPH MyGraph {
PRINT "Healthcare - Referral networks, Hub (PageRank), & Community Detection";
PRINT "Investigating healthcare referral networks";

PRINT "The queries tg_louvain.gsql and infer_all_referrals.gsql MUST be";
PRINT "run in that order. tg_page_rank.gsql must also be run.";
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
CREATE QUERY get_claims_of_prescriber(VERTEX<Prescriber> input_prescriber) FOR GRAPH MyGraph {
/*
Get the Claims of a given Prescriber

Sample inputs:
input_prescriber: pre6 | pre30 | pre13

Starting from an "input_prescriber",
(1) Grab all the prescriber's claims
Prescriber -(<submitted_by)- Claim
(2) Print the claims and submitted_by edges
*/

ListAccum<EDGE> @@submitted_by_list;

start = {input_prescriber};

claims = SELECT t // select claims connected to the input prescriber
FROM start:s-(<submitted_by:e)-:t
ACCUM @@submitted_by_list += e;

PRINT claims, @@submitted_by_list;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
CREATE QUERY get_common_patients(VERTEX<Prescriber> prescriber1,
VERTEX<Prescriber> prescriber2) FOR GRAPH MyGraph {
/*
Get the Patients that two Prescribers have in common

Sample inputs:
prescriber1: pre6 | pre30 | pre13
prescriber2: pre6 | pre30 | pre13

Starting from "prescriber1",
(1) Mark the connected Claim vertices as visited.
(2) Mark Patient vertices connected to the Claim vertices as visited.
Prescriber -(<submitted_by)- Claim -(associated>)- Patient
Starting from "prescriber2",
(1) Mark the connected Claim vertices as visited.
(2) Find all Patients connected to Claims that has been visited.
Prescriber -(<submitted_by)- Claim -(associated>)- Patient
*/

OrAccum @visited;
SetAccum<EDGE> @@edge_set;

pre1 = {prescriber1};
pre2 = {prescriber2};

/* Step 1 – Start graph Traversal from first prescriber to find all
associated claims. Use visited flag to remember claims visited. */
claims1 = SELECT t
FROM pre1:s -(<submitted_by:e)- Claim:t
ACCUM t.@visited += TRUE;

// Step 2 – For those claims, find all the linked patients.
patients1 = SELECT t
FROM claims1:s -(associated>:e)- Patient:t
ACCUM t.@visited += TRUE;

// Step 3 - Start graph traversal from second prescriber to find all claims
claims2 = SELECT t
FROM pre2:s -(<submitted_by:e)- Claim:t
ACCUM t.@visited += TRUE;

// Step 4 – Find common patients by starting from claims in Step 3
common_patients = SELECT t
FROM claims2:s -(associated>:e)- Patient:t
WHERE t.@visited == TRUE;
PRINT common_patients;

/* Step 5 – From common patients find all claims that have been visited
in earlier steps. Collect the edges so they can be printed. */
claims = SELECT t
FROM common_patients:s -(<associated:e)- Claim:t
WHERE t.@visited == TRUE
ACCUM @@edge_set += e;
PRINT claims;

/* Step 6 – From claims find associated prescribers. Collect and print
edges (claims – prescribers) and prescribers. */
pres = SELECT t
FROM claims:s -(submitted_by>:e)- Prescriber:t
ACCUM @@edge_set += e;

PRINT pres;
PRINT @@edge_set;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
CREATE QUERY get_joint_prescribers(VERTEX<Prescriber> input_prescriber)
FOR GRAPH MyGraph {
/*
Get Prescribers who have treated the same patients of a given Prescriber

Sample inputs:
input_prescriber: pre6 | pre30 | pre13

Starting with an "input_prescriber",
(1) Get the connected claims, accumulate the edges, and mark the claims as visited
(2) Get the patients connected to claims and accumulate the edges
(3) Get the claims connected to the patients that have not been visited and accumulate the edges
(4) Get the prescribers connected to the claims and accumulate the edges
(5) Display the prescribers and edges
Prescriber -(<submitted_by)- Claim -(associated>)- Patient -(<associated)-
Claim -(submitted_by>)- Prescriber
*/

ListAccum<EDGE> @@edge_list; // list will have all edges traversed
OrAccum<BOOL> @visited;

start = {input_prescriber};

claims = SELECT t // select connected claims
FROM start:s-(<submitted_by:e)-:t
ACCUM @@edge_list += e
POST-ACCUM t.@visited = TRUE; // mark the selected claims as visited

patients = SELECT t // select connected patients
FROM claims:s-(associated>:e)-:t
ACCUM @@edge_list +=e;

claims = SELECT t
FROM patients:s-(<associated:e)-:t
WHERE t.@visited == FALSE // select claims not previously visited
ACCUM @@edge_list +=e;

prescribers = SELECT t // select connected prescribers
FROM claims-(submitted_by>:e)-:t
ACCUM @@edge_list +=e;

PRINT prescribers, @@edge_list;
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
CREATE OR REPLACE QUERY get_k_hop_neighbor(int k, vertex input) FOR GRAPH MyGraph {

OrAccum<BOOL> @visited;
ListAccum<EDGE> @@edgeList;

start = {input};

WHILE start.size() > 0 limit k DO
start = SELECT t from start-(:e)-:t
WHERE t.@visited == false
ACCUM @@edgeList += e
POST-ACCUM t.@visited = true;
END;

print @@edgeList;
CREATE QUERY get_k_hop_neighbors(INT k, VERTEX input) FOR GRAPH MyGraph {
/*
Get all the vertices within k hops of a source vertex

Sample inputs:
k: any number > 0
input: (Claim, 9921) | (SubSpecialty, Cardiology) | (Prescriber, pre78)

Starting with the "input",
(1) Traverse to all the vertices connected which was not visited
(2) Accumulate the vertices and edges
(3) Mark the vertices as visited
(4) Repeat the traversal k times
*/

OrAccum<BOOL> @visited;
ListAccum<VERTEX> @@vertex_list;
ListAccum<EDGE> @@edge_list;

start = {input};

WHILE start.size() > 0 LIMIT k DO /* stops either when there are no
vertices or when reaching k */
start = SELECT t
FROM start-(:e)-:t // visit all connected vertices
WHERE t.@visited == FALSE // vertex must be new
ACCUM @@vertex_list += t, @@edge_list += e // add to global lists
POST-ACCUM t.@visited = TRUE; // mark vertices visited
END;

PRINT @@vertex_list, @@edge_list;
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
CREATE QUERY get_patients_of_prescriber(VERTEX<Prescriber> input_prescriber)
FOR GRAPH MyGraph {
/*
Get the Patients of a given Prescriber

Sample inputs:
input_prescriber: pre6 | pre30 | pre13

Starting with the "input_prescriber",
(1) Find all the connected Claim vertices
(2) Find all the connected Patient vertices
(3) Print the Claim vertices and all the edges traversed
Prescriber -(<submitted_by)- Claim -(associated>)- Patient
*/

ListAccum<EDGE> @@edge_list;

start = {input_prescriber};

claims = SELECT t // select connected claims
FROM start:s-(<submitted_by:e)-:t
ACCUM @@edge_list += e;

patients = SELECT t // select connected patients
FROM claims:s-(associated>:e)-:t
ACCUM @@edge_list += e;

PRINT patients, @@edge_list;
}
Loading