Skip to content

Commit

Permalink
add new columns for query building to query table (#201)
Browse files Browse the repository at this point in the history
Co-authored-by: Rob Mitchell <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 12, 2024
1 parent 3cd6853 commit 201c857
Show file tree
Hide file tree
Showing 14 changed files with 76,011 additions and 115,152 deletions.
41 changes: 4 additions & 37 deletions query-connector/flyway/sql/V01_01__tcr_custom_query_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -51,41 +51,18 @@ CREATE TABLE IF NOT EXISTS valueset_to_concept (
FOREIGN KEY (concept_id) REFERENCES concepts(id)
);

CREATE TABLE IF NOT EXISTS icd_crosswalk (
id TEXT PRIMARY KEY,
icd10_code TEXT,
icd9_code TEXT,
match_flags TEXT);


CREATE TABLE IF NOT EXISTS query (
id UUID DEFAULT uuid_generate_v4 (),
query_name VARCHAR(255),
query_name VARCHAR(255) UNIQUE,
query_data JSON,
conditions_list TEXT[],
author VARCHAR(255),
date_created TIMESTAMP,
date_last_modified TIMESTAMP,
time_window_number INT,
time_window_unit VARCHAR(80),
PRIMARY KEY (id));

CREATE TABLE IF NOT EXISTS query_to_valueset (
id TEXT PRIMARY KEY,
query_id UUID,
valueset_id TEXT,
valueset_oid TEXT,
FOREIGN KEY (query_id) REFERENCES query(id),
FOREIGN KEY (valueset_id) REFERENCES valuesets(id)
);

CREATE TABLE IF NOT EXISTS query_included_concepts (
id TEXT PRIMARY KEY,
query_by_valueset_id TEXT,
concept_id TEXT,
include BOOLEAN,
FOREIGN KEY (query_by_valueset_id) REFERENCES query_to_valueset(id),
FOREIGN KEY (concept_id) REFERENCES concepts(id)
);

-- Create indexes for all primary and foreign keys

CREATE INDEX IF NOT EXISTS conditions_id_index ON conditions (id);
Expand All @@ -103,15 +80,5 @@ CREATE INDEX IF NOT EXISTS valueset_to_concept_id_index ON valueset_to_concept (
CREATE INDEX IF NOT EXISTS valueset_to_concept_valueset_id_index ON valueset_to_concept (valueset_id);
CREATE INDEX IF NOT EXISTS valueset_to_concept_concept_id_index ON valueset_to_concept (concept_id);

CREATE INDEX IF NOT EXISTS icd_crosswalk_id_index ON icd_crosswalk (id);

CREATE INDEX IF NOT EXISTS query_id_index ON query (id);
CREATE INDEX IF NOT EXISTS query_name_index ON query (query_name);

CREATE INDEX IF NOT EXISTS query_to_valueset_id_index ON query_to_valueset (id);
CREATE INDEX IF NOT EXISTS query_to_valueset_query_id_index ON query_to_valueset (query_id);
CREATE INDEX IF NOT EXISTS query_to_valueset_valueset_id_index ON query_to_valueset (valueset_id);

CREATE INDEX IF NOT EXISTS query_included_concepts_id_index ON query_included_concepts (id);
CREATE INDEX IF NOT EXISTS query_included_concepts_query_by_valueset_id_index ON query_included_concepts (query_by_valueset_id);
CREATE INDEX IF NOT EXISTS query_included_concepts_concept_id_index ON query_included_concepts (concept_id);
CREATE INDEX IF NOT EXISTS query_name_index ON query (query_name);
2 changes: 1 addition & 1 deletion query-connector/src/app/api/query/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export async function POST(request: NextRequest) {
// Lookup default parameters for particular use-case search
const queryName = UseCaseToQueryName[use_case as USE_CASES];
const queryResults = await getSavedQueryByName(queryName);
const valueSets = await mapQueryRowsToValueSets(queryResults);
const valueSets = mapQueryRowsToValueSets(queryResults);

// Add params & patient identifiers to UseCaseRequest
const UseCaseRequest: UseCaseQueryRequest = {
Expand Down
Loading

0 comments on commit 201c857

Please sign in to comment.