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

Starter Kit Update #11

Open
wants to merge 93 commits into
base: 3.7
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
730be5a
Update initialization.gsql
kristinezhengx Jul 19, 2022
fcb915b
Update initialization.gsql
kristinezhengx Jul 19, 2022
e6e2667
Update initialization.gsql
kristinezhengx Jul 19, 2022
de16aae
Update weight_initialization.gsql
kristinezhengx Jul 19, 2022
bec6f46
Update training.gsql
kristinezhengx Jul 19, 2022
d8ff974
Update predicting.gsql
kristinezhengx Jul 19, 2022
301c24b
Update predicting.gsql
kristinezhengx Jul 19, 2022
e40dcd3
Update app_impact.gsql
kristinezhengx Jul 20, 2022
aa09c8c
Update storage_impact.gsql
kristinezhengx Jul 20, 2022
2ec86f2
Update warning_impact.gsql
kristinezhengx Jul 20, 2022
a64aa73
Create README.gsql
kristinezhengx Jul 20, 2022
c4776ee
Update README.gsql
kristinezhengx Jul 20, 2022
8465933
Update predicting.gsql
kristinezhengx Jul 21, 2022
02566b5
Update predicting.gsql
kristinezhengx Jul 21, 2022
d352d99
Update README.gsql
kristinezhengx Jul 21, 2022
b688742
Update app_impact.gsql
kristinezhengx Jul 21, 2022
1f4a859
Update training.gsql
kristinezhengx Jul 21, 2022
47a6b0c
Update predicting.gsql
kristinezhengx Jul 21, 2022
b068f14
Update app_impact.gsql
kristinezhengx Jul 21, 2022
7501261
Update warning_impact.gsql
kristinezhengx Jul 21, 2022
1fd16c2
Update storage_impact.gsql
kristinezhengx Jul 21, 2022
8aa444b
Update README.gsql
kristinezhengx Jul 21, 2022
19b2c6c
Update splitData.gsql
kristinezhengx Jul 21, 2022
98f8f5c
Update normalization.gsql
kristinezhengx Jul 21, 2022
f5f6564
Update initialization.gsql
kristinezhengx Jul 21, 2022
d19e507
Update training.gsql
kristinezhengx Aug 2, 2022
dd369b6
Update test.gsql
kristinezhengx Aug 2, 2022
0e25fa6
Update README.gsql
kristinezhengx Aug 2, 2022
d9b65a2
Update cal_avg_rating.gsql
kristinezhengx Aug 2, 2022
4aea2da
Update recommend.gsql
kristinezhengx Aug 2, 2022
02fc845
Update test.gsql
kristinezhengx Aug 2, 2022
aa105ac
Update README.gsql
kristinezhengx Aug 3, 2022
cfb40fe
Update feature_collection.gsql
kristinezhengx Aug 3, 2022
da15c15
Create README.gsql
kristinezhengx Aug 3, 2022
b58e94a
Update compare_approximation.gsql
kristinezhengx Aug 3, 2022
6ba20a7
Update initialization.gsql
kristinezhengx Aug 3, 2022
5344407
Update factorization.gsql
kristinezhengx Aug 3, 2022
74f89bf
Update print_result.gsql
kristinezhengx Aug 3, 2022
4b60eb6
Update README.gsql
kristinezhengx Aug 3, 2022
4c228a6
Update README.gsql
kristinezhengx Aug 3, 2022
e95b2b8
Update README.gsql
kristinezhengx Aug 3, 2022
e56327f
Update README.gsql
kristinezhengx Aug 3, 2022
26cbffa
Update jaccard_nbor_reaction.gsql
kristinezhengx Aug 3, 2022
6d578c9
Update most_reported_drugs_for_company_v2.gsql
kristinezhengx Aug 3, 2022
f9c8702
Update top_side_effects_for_top_drugs.gsql
kristinezhengx Aug 3, 2022
1406695
Create README.gsql
kristinezhengx Aug 3, 2022
5189c4c
Update README.gsql
kristinezhengx Aug 3, 2022
cc1fd59
Update jaccard_nbor_reaction.gsql
kristinezhengx Aug 3, 2022
8950d15
Update jaccard_nbor_reaction.gsql
kristinezhengx Aug 3, 2022
929702d
Update and rename A_README.gsql to README.gsql
kristinezhengx Aug 3, 2022
ebc9b5f
Update add_weights.gsql
kristinezhengx Aug 3, 2022
7519dd0
Update shortest_ss_no_wt.gsql
kristinezhengx Aug 3, 2022
f85b76b
Update shortest_ss_pos_wt.gsql
kristinezhengx Aug 3, 2022
076a3c7
Update shortest_ss_pos_wt_limits.gsql
kristinezhengx Aug 3, 2022
af4ea28
Update shortest_ss_pos_wt_limits.gsql
kristinezhengx Aug 3, 2022
416027a
Update README.gsql
kristinezhengx Aug 3, 2022
0b61cc6
Update initialize_users.gsql
kristinezhengx Aug 3, 2022
ae112d6
Update util_count_vertices.gsql
kristinezhengx Aug 4, 2022
2632488
Update util_delete_users.gsql
kristinezhengx Aug 4, 2022
58edbda
Update util_print_vertices.gsql
kristinezhengx Aug 4, 2022
c30a34b
Update util_set_weights.gsql
kristinezhengx Aug 4, 2022
daab09f
Update connect_jaccard_sim.gsql
kristinezhengx Aug 4, 2022
31231d1
Update merge_connected_users.gsql
kristinezhengx Aug 4, 2022
996a603
Update score_similar_attributes.gsql
kristinezhengx Aug 5, 2022
caaa051
Update connect_weighted_match.gsql
kristinezhengx Aug 5, 2022
d94a74a
Update recommend_videos.gsql
kristinezhengx Aug 5, 2022
dfa7d01
Update README.gsql
kristinezhengx Aug 5, 2022
b922602
Update README.gsql
kristinezhengx Aug 5, 2022
d2268e7
Update README.gsql
kristinezhengx Aug 5, 2022
2648e91
Update get_account_subgraph.gsql
kristinezhengx Aug 5, 2022
25f2099
Update and rename A_README.gsql to README.gsql
kristinezhengx Aug 5, 2022
e25a54b
Update Print_community.gsql
kristinezhengx Aug 5, 2022
afef34e
Update algo_louvain.gsql
kristinezhengx Aug 5, 2022
dfff8c7
Update algo_louvain_enhanced.gsql
kristinezhengx Aug 5, 2022
918fd31
Update algo_louvain.gsql
kristinezhengx Aug 5, 2022
09bf60a
Update algo_page_rank.gsql
kristinezhengx Aug 5, 2022
4bca663
Update conn_comp.gsql
kristinezhengx Aug 5, 2022
489405f
Update conn_comp_enhanced.gsql
kristinezhengx Aug 5, 2022
91b985c
Update conn_comp.gsql
kristinezhengx Aug 5, 2022
6947d51
Update conn_comp_enhanced.gsql
kristinezhengx Aug 5, 2022
ed79834
Update get_community.gsql
kristinezhengx Aug 5, 2022
c2042b9
Update get_community.gsql
kristinezhengx Aug 5, 2022
5365021
Update insert_all_referrals.gsql
kristinezhengx Aug 5, 2022
a7f4e78
Update insert_referrals.gsql
kristinezhengx Aug 5, 2022
fbe5872
Update insert_referrals.gsql
kristinezhengx Aug 5, 2022
cb55029
Update kcore_decomp.gsql
kristinezhengx Aug 5, 2022
2d14fac
Update kcore_max.gsql
kristinezhengx Aug 5, 2022
2676794
Update kcore_sub.gsql
kristinezhengx Aug 5, 2022
3d3069a
Update scc.gsql
kristinezhengx Aug 5, 2022
6829108
Update scc.gsql
kristinezhengx Aug 5, 2022
b5e8bf5
Update scc_enhanced.gsql
kristinezhengx Aug 5, 2022
59dc61e
Update select_subgraph.gsql
kristinezhengx Aug 5, 2022
7eda146
Update README.gsql
kristinezhengx Aug 5, 2022
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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
CREATE QUERY print_community(vertex<Prescriber> input_prescriber) FOR GRAPH MyGraph SYNTAX V2 {
/* Write query logic here */
//PRINT "Print_community works!";
/*

Returns edges of community given prescriber

Sample input:
input_prescriber: pre14 | pre25

Using all Prescribers:
(1) Select presribers where their community id
matches the input_prescriber and the
prescriber they refer
(2) Return referral edges of the community

*/

ListAccum<EDGE> @@edge_list;

Expand All @@ -17,4 +29,4 @@ CREATE QUERY print_community(vertex<Prescriber> input_prescriber) FOR GRAPH MyGr

print start;
print @@edge_list;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
CREATE QUERY README() FOR GRAPH MyGraph {
/*
IMPORANT : PLEASE INSTALL AND RUN the insert_all_referrals QUERY FIRST.

THE REFERRAL EDGE IS USED IN OTHER QUERIES.
*/

STRING name = "Graph-Analytics-Community-Detection-Algorithms";
STRING graph_description = "Find communities of a specific type in your network " +
(Louvain Method, Connected Components, K-Core Decomposition, strongly connected components)";

STRING query_order = "1. insert_all_referrals";

STRING Print_community = "Returns edges of community given prescriber";
STRING algo_louvain = "Louvain Method with Parallelism and Refinement https://arxiv.org/pdf/1304.4453 " +
"The minimum label heuristics are implemented: https://doi.org/10.1016/j.parco.2015.03.003";
STRING algo_louvain_enhanced = "Louvain Method with Parallelism and Refinement https://arxiv.org/pdf/1304.4453 " +
"The minimum label heuristics are implemented: https://doi.org/10.1016/j.parco.2015.03.003";
STRING algo_page_rank = "Compute the pageRank score for each vertex in the GRAPH";
STRING conn_comp = "Identifies the Connected Components (undirected edges)";
STRING conn_comp_enhanced = "Identifies the Connected Components (undirected edges)";
STRING get_community = "Finds the vertices and interconnecting edges associated either with the given prescriber_Id, " +
"or if the prescriber_Id is not provided (empty string), then for the given community_Id.";
STRING insert_all_referrals = "Inserts and returns the total referrals across prescribers";
STRING insert_referrals = "Inserts and returns number of referral insertions from unvisited claims";
STRING kcore_decomp = "Outputs the k-core vertex membership for each value of k from k_min to k_max. ";
STRING kcore_max = "An implementation of Algorithm 2 in Scalable K-Core Decomposition for Static Graphs " +
"Using a Dynamic Graph Data Structure, Tripathy et al., IEEE Big Data 2018.";
STRING kcore_sub = "An implementation of Algorithm 2 in Scalable K-Core Decomposition for Static Graphs " +
"Using a Dynamic Graph Data Structure, Tripathy et al., IEEE Big Data 2018. ";
STRING scc = "Detects strongly connected components based on the following papers: " +
"https://www.sandia.gov/~apinar/papers/irreg00.pdf, " +
"https://www.sciencedirect.com/science/article/pii/S0743731505000535, " +
"https://stanford-ppl.github.io/website/papers/sc13-hong.pdf";
STRING scc_enhanced = "Detects strongly connected components based on the following papers: " +
"https://www.sandia.gov/~apinar/papers/irreg00.pdf, " +
"https://www.sciencedirect.com/science/article/pii/S0743731505000535, " +
"https://stanford-ppl.github.io/website/papers/sc13-hong.pdf";
STRING select_subgraph = "Returns edges and vertices of subgraph";

PRINT name, graph_description, query_order, Print_community, algo_louvain, algo_louvain_enhanced, algo_page_rank;
PRINT conn_comp, conn_comp_enhanced, get_community, insert_all_referrals, insert_referrals;
PRINT kcore_decomp, kcore_max, kcore_sub, scc, scc_enhanced, select_subgraph;

print "I read this!";
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,28 @@ CREATE QUERY algo_louvain(INT iter1 = 10, INT iter2 = 10, INT iter3 = 10, INT sp
Bool sort_by_pre_ID, Bool sort_by_comm_ID) FOR GRAPH MyGraph SYNTAX V2 {

/*
* Louvain Method with Parallelism and Refinement
* https://arxiv.org/pdf/1304.4453
* The minimum label heuristics are implemented: https://doi.org/10.1016/j.parco.2015.03.003
* iter: There are three phases in the algorithm -- move, merge and refine. Their max number of iterations are set by iter1, iter2, iter3 respectively.
* split: To save memory, split number is 10 by default. When the split number is larger, the query is closer to sequential Louvain Method, which is slower. When the split number is 1, the query is parallel, but requires more memory.
* output_level: 0, only list number; 1, also list members
* fComm, fDist: files to store community label and community distribution
Louvain Method with Parallelism and Refinement
https://arxiv.org/pdf/1304.4453
The minimum label heuristics are implemented: https://doi.org/10.1016/j.parco.2015.03.003

Inputs:
iter: There are three phases in the algorithm -- move, merge and refine. Their max number of iterations are set by iter1, iter2, iter3 respectively.
split: To save memory, split number is 10 by default. When the split number is larger, the query is closer to sequential Louvain Method, which is slower. When the split number is 1, the query is parallel, but requires more memory.
output_level: 0, only list number; 1, also list members
fComm, fDist: files to store community label and community distribution

(1) Initialize: count edges and set a unique cluster ID for each vertex
(2) Phase 1 -- Move: incrementally calculates the modularity change of moving a vertex into every other community
and moves the vertex to the community with the highest modularity change
(a) For each vertex, calculate the change in modularity FROM adding it to each of the nearby clusters
(b) Add vertex to cluster with highest positive change in modularity
(c) Repeat the above until no vertices change cluster anymore
(3) Phase 2 -- Merge: Coarsen the graph by aggregating the vertices which are assigned in the same community into one vertex
(a) Select the vertices with minimal internal id to represent the coarsened graph
(b) Get @cweight from totalIncident
(c) Calculate.num_patient incident from vertex to cluster in coarsened graph; change every interation
(4) Phase 3 -- Refinement: run the first phase again on each vertex to do some small adjustments for the resulting communities

*/
TYPEDEF TUPLE <INT csize, INT number> Cluster_Num;
TYPEDEF TUPLE <VERTEX node, INT cid, FLOAT deltaQ> V_Delta_Q;
Expand Down Expand Up @@ -242,7 +257,6 @@ CREATE QUERY algo_louvain(INT iter1 = 10, INT iter2 = 10, INT iter3 = 10, INT sp
log(debug > 0, "[redrain]#2_merge", iteration2, @@modularity2);
END; // outer WHILE


# Phase 3 -- Refinement
iteration = 0;
@@modularity = 0;
Expand Down Expand Up @@ -317,4 +331,4 @@ CREATE QUERY algo_louvain(INT iter1 = 10, INT iter2 = 10, INT iter3 = 10, INT sp
END;
PRINT start [start.communityId];
PRINT "Community Detection Done";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,27 @@ CREATE QUERY algo_louvain_enhanced(STRING vertex_type, STRING edge_type,
FOR GRAPH MyGraph SYNTAX V2 {

/*
* Louvain Method with Parallelism and Refinement
* https://arxiv.org/pdf/1304.4453
* The minimum label heuristics are implemented: https://doi.org/10.1016/j.parco.2015.03.003
* iter: There are three phases in the algorithm -- move, merge and refine. Their max number of iterations are set by iter1, iter2, iter3 respectively.
* split: To save memory, split number is 10 by default. When the split number is larger, the query is closer to sequential Louvain Method, which is slower. When the split number is 1, the query is parallel, but requires more memory.
* output_level: 0, only list number; 1, also list members
* fComm, fDist: files to store community label and community distribution
Louvain Method with Parallelism and Refinement
https://arxiv.org/pdf/1304.4453
The minimum label heuristics are implemented: https://doi.org/10.1016/j.parco.2015.03.003

Inputs:
iter: There are three phases in the algorithm -- move, merge and refine. Their max number of iterations are set by iter1, iter2, iter3 respectively.
split: To save memory, split number is 10 by default. When the split number is larger, the query is closer to sequential Louvain Method, which is slower. When the split number is 1, the query is parallel, but requires more memory.
output_level: 0, only list number; 1, also list members
fComm, fDist: files to store community label and community distribution


(1) Initialize: count edges and set a unique cluster ID for each vertex
(2) Phase 1 -- Move: incrementally calculates the modularity change of moving a vertex into every other community
and moves the vertex to the community with the highest modularity change
(a) For each vertex, calculate the change in modularity FROM adding it to each of the nearby clusters
(b) Add vertex to cluster with highest positive change in modularity
(c) Repeat the above until no vertices change cluster anymore
(3) Phase 2 -- Merge: Coarsen the graph by aggregating the vertices which are assigned in the same community into one vertex
(4) Phase 3 -- Refinement: run the first phase again on each vertex to do some small adjustments for the resulting communities


*/
TYPEDEF TUPLE <INT csize, INT number> Cluster_Num;
TYPEDEF TUPLE <VERTEX node, INT cid, FLOAT delta_Q> V_Delta_Q;
Expand Down Expand Up @@ -317,4 +331,4 @@ CREATE QUERY algo_louvain_enhanced(STRING vertex_type, STRING edge_type,
END;
PRINT start [start.@cid];
PRINT "Community Detection Done";
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
CREATE QUERY algo_page_rank(FLOAT max_change = 0.001, INT max_iter = 25,
FLOAT damping = 0.85, INT output_limit) FOR GRAPH MyGraph SYNTAX V2 {

# Compute the pageRank score for each vertex in the GRAPH
# In each iteration, compute a score for each vertex:
# score = (1-damping) + damping*sum(received scores FROM its neighbors).
# The pageRank algorithm stops when either of the following is true:
# a) it reaches max_iter iterations;
# b) the max score change for any vertex compared to the last iteration <= max_change.
/*
Compute the pageRank score for each vertex in the GRAPH

No inputs

From all Prescribers:
(1) In each iteration, compute a score for each vertex:
score = (1-damping) + damping*sum(received scores FROM its neighbors).
(2) The pageRank algorithm stops when either of the following is true:
a) it reaches max_iter iterations;
b) the max score change for any vertex compared to the last iteration <= max_change.
*/

TYPEDEF TUPLE<vertex Vertex_ID, FLOAT score> Vertex_Score;
HeapAccum<Vertex_Score>(output_limit, score DESC) @@top_scores;
Expand Down Expand Up @@ -34,4 +40,4 @@ CREATE QUERY algo_page_rank(FLOAT max_change = 0.001, INT max_iter = 25,
PRINT @@top_scores;
END;

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
CREATE QUERY conn_comp (STRING vertex_type, STRING edge_type, STRING rev_edge_type)
FOR GRAPH MyGraph SYNTAX V2 {
# This query identifies the Connected Components (undirected edges)
/*
Identifies the Connected Components (undirected edges)

Sample inputs:
vertex_type: claim
edge_type: associated
rev_edge_type: reverse_associated

Start from given vertex_type:
(1) Initialize: Label each vertex with its own internal ID
(2) Propagate smaller internal IDs until no more ID changes can be Done

*/

MinAccum<int> @cc_id = 0; //each vertex's tentative component id
SumAccum<int> @old_id = 0;
Expand All @@ -16,7 +28,7 @@ CREATE QUERY conn_comp (STRING vertex_type, STRING edge_type, STRING rev_edge_ty
x.@old_id = getvid(x)
;

# Propagate smaller internal IDs until no more ID changes can be DOne
# Propagate smaller internal IDs until no more ID changes can be Done
WHILE (start.size()>0) DO
start = SELECT t
FROM start:s -((edge_type|rev_edge_type):e)- :t
Expand All @@ -38,4 +50,4 @@ CREATE QUERY conn_comp (STRING vertex_type, STRING edge_type, STRING rev_edge_ty
POST-ACCUM @@comp_sizes += (s.@cc_id -> 1);
PRINT @@comp_sizes;
PRINT start [start.@cc_id];
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
CREATE QUERY conn_comp_enhanced (SET<VERTEX> vertex_types, STRING vt2,
STRING edge_type, STRING rev_edge_type, INT output_level) FOR GRAPH MyGraph SYNTAX V2 {
# This query identifies the Connected Components (undirected edges)
/*
Identifies the Connected Components (undirected edges)

Sample inputs:
vertex_type: claim
vt2: N/A
edge_type: associated
rev_edge_type: reverse_associated
output_level: 1

Start from given vertex_type:
(1) Initialize: Label each vertex with its own internal ID
(2) Propagate smaller internal IDs until no more ID changes can be Done
*/

MinAccum<int> @cc_id = 0; //each vertex's tentative component id
SumAccum<int> @old_id = 0;
Expand All @@ -16,7 +29,7 @@ CREATE QUERY conn_comp_enhanced (SET<VERTEX> vertex_types, STRING vt2,
x.@old_id = getvid(x)
;

# Propagate smaller internal IDs until no more ID changes can be DOne
# Propagate smaller internal IDs until no more ID changes can be Done
WHILE (start.size()>0) DO
start = SELECT t
FROM start:s -((edge_type|rev_edge_type):e)- :t
Expand All @@ -41,4 +54,4 @@ CREATE QUERY conn_comp_enhanced (SET<VERTEX> vertex_types, STRING vt2,
IF output_level > 0 THEN
PRINT start [start.@cc_id];
END;
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
CREATE QUERY get_community(STRING prescriber_Id, INT community_Id) FOR GRAPH MyGraph SYNTAX V2 {
/* This query finds the vertices and interconnecting edges associated either with the given
* prescriber_Id, or if the prescriber_Id is not provided (empty string), then
* for the given community_Id.
* NOTE: This algorithm requires that the community_Id attribute has been set,
* by running the alg_louvain query,
/*

Finds the vertices and interconnecting edges associated either with the given
prescriber_Id, or if the prescriber_Id is not provided (empty string), then
for the given community_Id.
NOTE: This algorithm requires that the community_Id attribute has been set,
by running the alg_louvain query,

Sample inputs:
prescriber_Id: pre78 | pre30
community_Id: 10

Start from all Prescribers:
(1) Select prescribers where the id equals the given prescriber_id and set comm_Id
(2) Get all the vertices and intercomnnecting edges with the give comm_Id

*/

SetAccum<EDGE> @@edge_list;
INT comm_Id;

Expand All @@ -20,11 +32,11 @@ CREATE QUERY get_community(STRING prescriber_Id, INT community_Id) FOR GRAPH MyG
END;
PRINT comm_Id;

// Get all the vertices and intercomnnecting edges with the give comm_Id
// Get all the vertices and intercomnnecting edges with the given comm_Id
comm_vertices = SELECT s
FROM start:s -(referral>:e)- :t
WHERE s.communityId == comm_Id AND t.communityId == comm_Id
ACCUM @@edge_list += e;
PRINT comm_vertices[comm_vertices.Prescriber_id];
PRINT @@edge_list;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
CREATE QUERY insert_all_referrals () FOR GRAPH MyGraph SYNTAX V2 {

/*

Inserts and returns the total referrals across prescribers

No inputs

From all Prescriber vertices:
(1) Select all prescribers, insert referrals, and count the number of referrals
*/

SumAccum<INT> @@num_insertions;

Expand All @@ -8,4 +18,4 @@ CREATE QUERY insert_all_referrals () FOR GRAPH MyGraph SYNTAX V2 {
ACCUM @@num_insertions += insert_referrals(s);

PRINT @@num_insertions;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
CREATE QUERY insert_referrals(VERTEX<Prescriber> input_prescriber)
FOR GRAPH MyGraph RETURNS (INT) SYNTAX V2 {

/*

Inserts and returns number of referral insertions from unvisited claims

Sample input:
input_prescriber: pre38

Start from the input_prescriber:
(1) Select claims from input_prescriber and mark as visited
(2) Select patients from the claims and update date lists
(3) Select other claims from patients in (2) that are unvisited
(4) Select claims from (3) and insert into referral


*/

OrAccum<BOOL> @visited, @is_referred_claim;
ListAccum<DATETIME> @date_list;
SumAccum<INT> @@num_insertions;
Expand All @@ -27,4 +43,4 @@ CREATE QUERY insert_referrals(VERTEX<Prescriber> input_prescriber)
@@num_insertions += 1;
print start_set;
RETURN @@num_insertions;
}
}
Loading