From f5924ab3415eb0609ea65b68af58a1bf61e4225d Mon Sep 17 00:00:00 2001 From: Luke Sikina Date: Sun, 21 Jul 2024 11:46:08 -0400 Subject: [PATCH] distinct --- one_facet.sql | 12 ++++++++---- .../dictionary/facet/FacetQueryGenerator.java | 8 ++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/one_facet.sql b/one_facet.sql index 9414727..6c0ee94 100644 --- a/one_facet.sql +++ b/one_facet.sql @@ -1,3 +1,7 @@ +{"facets":[ +{"name":"LOINC","display":"LOINC","description":null,"count":1,"children":null,"category":"nsrr_harmonized","meta":null,"categoryRef":{"display":"Common Data Element Collection","name":"nsrr_harmonized","description":""}}, +{"name":"PhenX","display":"PhenX","description":null,"count":1,"children":null,"category":"nsrr_harmonized","meta":null,"categoryRef":{"display":"Common Data Element Collection","name":"nsrr_harmonized","description":""}}],"search":""} + ( SELECT facet.facet_id, count(*) as facet_count @@ -10,7 +14,7 @@ LEFT JOIN concept_node_meta AS continuous_max ON concept_node.concept_node_id = continuous_max.concept_node_id AND continuous_max.KEY = 'max' LEFT JOIN concept_node_meta AS categorical_values ON concept_node.concept_node_id = categorical_values.concept_node_id AND categorical_values.KEY = 'values' WHERE - fc.name = 'study_ids_dataset_ids' + fc.name = 'nsrr_harmonized' AND ( continuous_min.value <> '' OR continuous_max.value <> '' OR @@ -35,8 +39,8 @@ UNION LEFT JOIN concept_node_meta AS continuous_max ON concept_node.concept_node_id = continuous_max.concept_node_id AND continuous_max.KEY = 'max' LEFT JOIN concept_node_meta AS categorical_values ON concept_node.concept_node_id = categorical_values.concept_node_id AND categorical_values.KEY = 'values' WHERE - fc.name = 'study_ids_dataset_ids' - AND facet.name IN ('phs000007') + fc.name = 'nsrr_harmonized' + AND facet.name IN ('LOINC', 'PhenX') AND ( continuous_min.value <> '' OR continuous_max.value <> '' OR @@ -51,7 +55,7 @@ UNION JOIN facet_category fc on fc.facet_category_id = facet.facet_category_id JOIN matching_concepts ON fcn.concept_node_id = matching_concepts.concept_node_id WHERE - fc.name <> 'study_ids_dataset_ids' + fc.name <> 'nsrr_harmonized' GROUP BY facet.facet_id ORDER BY diff --git a/src/main/java/edu/harvard/dbmi/avillach/dictionary/facet/FacetQueryGenerator.java b/src/main/java/edu/harvard/dbmi/avillach/dictionary/facet/FacetQueryGenerator.java index bbc68fe..dd69957 100644 --- a/src/main/java/edu/harvard/dbmi/avillach/dictionary/facet/FacetQueryGenerator.java +++ b/src/main/java/edu/harvard/dbmi/avillach/dictionary/facet/FacetQueryGenerator.java @@ -67,7 +67,7 @@ private String createMultiCategorySQLWithSearch(Map> facets, return """ facet_category_%s_concepts AS ( SELECT - concept_node.concept_node_id + DISTINCT(concept_node.concept_node_id) FROM facet JOIN facet__concept_node fcn ON fcn.facet_id = facet.facet_id @@ -163,7 +163,7 @@ private String createMultiCategorySQLNoSearch(Map> facets, M return """ facet_category_%s_concepts AS ( SELECT - concept_node.concept_node_id + DISTINCT(concept_node.concept_node_id) FROM facet JOIN facet__concept_node fcn ON fcn.facet_id = facet.facet_id @@ -283,7 +283,7 @@ facet.facet_id, count(*) as facet_count ( WITH matching_concepts AS ( SELECT - concept_node.concept_node_id AS concept_node_id + DISTINCT(concept_node.concept_node_id AS concept_node_id) FROM facet JOIN facet_category fc on fc.facet_category_id = facet.facet_category_id @@ -352,7 +352,7 @@ facet.facet_id, count(*) as facet_count ( WITH matching_concepts AS ( SELECT - concept_node.concept_node_id AS concept_node_id + DISTINCT(concept_node.concept_node_id AS concept_node_id) FROM facet JOIN facet__concept_node fcn ON fcn.facet_id = facet.facet_id