diff --git a/query-connector/flyway/sql/V01_02__load_tcr_data.sql b/query-connector/flyway/sql/V01_02__load_tcr_data.sql index 760a1c22e..177efbb79 100644 --- a/query-connector/flyway/sql/V01_02__load_tcr_data.sql +++ b/query-connector/flyway/sql/V01_02__load_tcr_data.sql @@ -175312,3 +175312,4 @@ INSERT INTO icd_crosswalk VALUES('81590','Z993','V463','00000'); INSERT INTO icd_crosswalk VALUES('81591','Z9981','V462','00000'); INSERT INTO icd_crosswalk VALUES('81592','Z9989','V468','10000'); INSERT INTO icd_crosswalk VALUES('81593','Z9989','V469','10000'); + diff --git a/query-connector/flyway/sql/V01_03__insert_hardcoded_values.sql b/query-connector/flyway/sql/V01_03__insert_hardcoded_values.sql index 4a7ad0669..1bc49e493 100644 --- a/query-connector/flyway/sql/V01_03__insert_hardcoded_values.sql +++ b/query-connector/flyway/sql/V01_03__insert_hardcoded_values.sql @@ -1,6 +1,6 @@ INSERT INTO conditions VALUES('1','DIBBs Local Code System','Newborn Screening','20240909'); INSERT INTO conditions VALUES('2','DIBBs Local Code System','Cancer (Leukemia)','20240909'); -INSERT INTO conditions VALUES('3','DIBBs Local Code System','Social Determinants of Health','20240909'); -- has no valuesets +INSERT INTO conditions VALUES('3','DIBBs Local Code System','Social Determinants of Health','20240909'); -- Newborn Screening valueset(s) INSERT INTO valuesets VALUES('1_20240909','1','20240909','Newborn Screening','DIBBs','lotc'); diff --git a/query-connector/flyway/sql/V01_06__insert_sdoh_hardcoded_values.sql b/query-connector/flyway/sql/V01_06__insert_sdoh_hardcoded_values.sql new file mode 100644 index 000000000..fedd398ae --- /dev/null +++ b/query-connector/flyway/sql/V01_06__insert_sdoh_hardcoded_values.sql @@ -0,0 +1,41 @@ +-- Insert hardcoded values for Social Determinants of Health +INSERT INTO valuesets VALUES('17_20241028','17','20241028','Social Determinants of Health','DIBBs','lrtc'); + +-- Add SDOH concepts related to housing +INSERT INTO concepts VALUES('1_71802-3','71802-3','http://loinc.org','Housing status','','2024-10'); + +-- These 3 are already in the data +-- INSERT INTO concepts VALUES('1_11350-6','11350-6','http://loinc.org','History of Sexual behavior Narrative','','2024-10'); +-- INSERT INTO concepts VALUES('1_82810-3','82810-3','http://loinc.org','Pregnancy status','','2024-10'); --already in the data +-- INSERT INTO concepts VALUES('1_83317-8','83317-8','http://loinc.org','Sexual activity with anonymous partner in the past year','','2024-10'); + +-- Add SDOH as valueset belonging to SDOH condition +INSERT INTO condition_to_valueset VALUES('1530','1','17_20241028','DIBBs'); + +-- Add SDOH "labs" valueset to concept mappings +INSERT INTO valueset_to_concept VALUES('45507','17_20241028','1_71802-3'); +INSERT INTO valueset_to_concept VALUES('45508','17_20241028','1_11350-6'); +INSERT INTO valueset_to_concept VALUES('45509','17_20241028','1_82810-3'); +INSERT INTO valueset_to_concept VALUES('45510','17_20241028','1_83317-8'); + +-- Insert relevant query data +-- Map the new valueset to the SDOH query & get the newly created id +WITH inserted AS ( + INSERT INTO query_to_valueset (id, query_id, valueset_id, valueset_oid) + VALUES ( + uuid_generate_v4(), + (SELECT id FROM query WHERE query_name = 'Social Determinants of Health'), + '17_20241028', + '17' + ) + RETURNING id +) +-- Insert the concepts from the valueset into the query_included_concepts table +INSERT INTO query_included_concepts (id, query_by_valueset_id, concept_id, include) +SELECT + uuid_generate_v4(), + (SELECT id FROM inserted), + concept_id, + true +FROM valueset_to_concept +WHERE valueset_id = '17_20241028'; diff --git a/query-connector/flyway/sql/V01_06__add_dibbsConceptType.sql b/query-connector/flyway/sql/V01_07__add_dibbsConceptType.sql similarity index 100% rename from query-connector/flyway/sql/V01_06__add_dibbsConceptType.sql rename to query-connector/flyway/sql/V01_07__add_dibbsConceptType.sql