forked from Luke-Sikina/picsure-search-refinement
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Luke Sikina
committed
Jul 18, 2024
1 parent
1238ed0
commit 5bab91c
Showing
4 changed files
with
170 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
SELECT | ||
facet.facet_id, count(*) as facet_count | ||
FROM | ||
facet | ||
JOIN facet__concept_node fcn ON fcn.facet_id = facet.facet_id | ||
JOIN facet_category fc on fc.facet_category_id = facet.facet_category_id | ||
JOIN concept_node ON concept_node.concept_node_id = fcn.concept_node_id | ||
LEFT JOIN concept_node_meta AS continuous_min ON concept_node.concept_node_id = continuous_min.concept_node_id AND continuous_min.KEY = 'min' | ||
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 | ||
continuous_min.value <> '' OR | ||
continuous_max.value <> '' OR | ||
categorical_values.value <> '' | ||
GROUP BY | ||
facet.facet_id | ||
ORDER BY | ||
facet_count DESC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
( | ||
SELECT | ||
facet.facet_id, count(*) as facet_count | ||
FROM | ||
facet | ||
JOIN facet__concept_node fcn ON fcn.facet_id = facet.facet_id | ||
JOIN facet_category fc on fc.facet_category_id = facet.facet_category_id | ||
JOIN concept_node ON concept_node.concept_node_id = fcn.concept_node_id | ||
LEFT JOIN concept_node_meta AS continuous_min ON concept_node.concept_node_id = continuous_min.concept_node_id AND continuous_min.KEY = 'min' | ||
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 ( | ||
continuous_min.value <> '' OR | ||
continuous_max.value <> '' OR | ||
categorical_values.value <> '' | ||
) | ||
GROUP BY | ||
facet.facet_id | ||
ORDER BY | ||
facet_count DESC | ||
) | ||
UNION | ||
( | ||
WITH matching_concepts AS ( | ||
SELECT | ||
concept_node.concept_node_id AS concept_node_id | ||
FROM | ||
facet | ||
JOIN facet__concept_node fcn ON fcn.facet_id = facet.facet_id | ||
JOIN facet_category fc on fc.facet_category_id = facet.facet_category_id | ||
JOIN concept_node ON concept_node.concept_node_id = fcn.concept_node_id | ||
LEFT JOIN concept_node_meta AS continuous_min ON concept_node.concept_node_id = continuous_min.concept_node_id AND continuous_min.KEY = 'min' | ||
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') | ||
AND ( | ||
continuous_min.value <> '' OR | ||
continuous_max.value <> '' OR | ||
categorical_values.value <> '' | ||
) | ||
) | ||
SELECT | ||
facet.facet_id, count(*) as facet_count | ||
FROM | ||
facet | ||
JOIN facet__concept_node fcn ON fcn.facet_id = facet.facet_id | ||
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' | ||
GROUP BY | ||
facet.facet_id | ||
ORDER BY | ||
facet_count DESC | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
WITH facet_category_cat_0_concepts AS ( | ||
SELECT | ||
concept_node.concept_node_id | ||
FROM | ||
facet | ||
JOIN facet__concept_node fcn ON fcn.facet_id = facet.facet_id | ||
JOIN facet_category fc on fc.facet_category_id = facet.facet_category_id | ||
JOIN concept_node ON concept_node.concept_node_id = fcn.concept_node_id | ||
LEFT JOIN concept_node_meta AS continuous_min ON concept_node.concept_node_id = continuous_min.concept_node_id AND continuous_min.KEY = 'min' | ||
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, facet.name) IN (('nsrr_harmonized', 'LOINC')) | ||
AND ( | ||
continuous_min.value <> '' OR | ||
continuous_max.value <> '' OR | ||
categorical_values.value <> '' | ||
) | ||
) | ||
, | ||
facet_category_cat_1_concepts AS ( | ||
SELECT | ||
concept_node.concept_node_id | ||
FROM | ||
facet | ||
JOIN facet__concept_node fcn ON fcn.facet_id = facet.facet_id | ||
JOIN facet_category fc on fc.facet_category_id = facet.facet_category_id | ||
JOIN concept_node ON concept_node.concept_node_id = fcn.concept_node_id | ||
LEFT JOIN concept_node_meta AS continuous_min ON concept_node.concept_node_id = continuous_min.concept_node_id AND continuous_min.KEY = 'min' | ||
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, facet.name) IN (('study_ids_dataset_ids', 'phs000007')) | ||
AND ( | ||
continuous_min.value <> '' OR | ||
continuous_max.value <> '' OR | ||
categorical_values.value <> '' | ||
) | ||
) | ||
( | ||
SELECT | ||
facet.facet_id, count(*) as facet_count | ||
FROM | ||
facet | ||
JOIN facet__concept_node fcn ON fcn.facet_id = facet.facet_id | ||
JOIN facet_category fc on fc.facet_category_id = facet.facet_category_id | ||
WHERE | ||
fcn.concept_node_id IN (SELECT * FROM facet_category_cat_1_concepts) | ||
AND fc.name = 'study_ids_dataset_ids' | ||
GROUP BY | ||
facet.facet_id | ||
ORDER BY | ||
facet_count DESC | ||
) | ||
|
||
UNION | ||
( | ||
SELECT | ||
facet.facet_id, count(*) as facet_count | ||
FROM | ||
facet | ||
JOIN facet__concept_node fcn ON fcn.facet_id = facet.facet_id | ||
JOIN facet_category fc on fc.facet_category_id = facet.facet_category_id | ||
WHERE | ||
fcn.concept_node_id IN (SELECT * FROM facet_category_cat_0_concepts) | ||
AND fc.name = 'nsrr_harmonized' | ||
GROUP BY | ||
facet.facet_id | ||
ORDER BY | ||
facet_count DESC | ||
) | ||
UNION | ||
( | ||
SELECT | ||
facet.facet_id, count(*) as facet_count | ||
FROM | ||
facet | ||
JOIN facet_category fc on fc.facet_category_id = facet.facet_category_id | ||
JOIN facet__concept_node fcn ON fcn.facet_id = facet.facet_id | ||
WHERE | ||
fc.name NOT IN ('nsrr_harmonized', 'study_ids_dataset_ids') | ||
AND fcn.concept_node_id IN (SELECT * FROM facet_category_cat_0_concepts UNION SELECT * FROM facet_category_cat_1_concepts) | ||
GROUP BY | ||
facet.facet_id | ||
ORDER BY | ||
facet_count DESC | ||
) |