Skip to content

Commit

Permalink
fix dups
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Sikina committed Jul 18, 2024
1 parent d3d93c2 commit 69dc831
Show file tree
Hide file tree
Showing 4 changed files with 655 additions and 200 deletions.
169 changes: 169 additions & 0 deletions out.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
[
{
"name": "study_ids_dataset_ids",
"display": "Study IDs/Dataset IDs",
"description": "",
"facets": [
{
"name": "1",
"display": "GIC",
"description": null,
"count": 0,
"children": null,
"category": "study_ids_dataset_ids",
"meta": null
},
{
"name": "2",
"display": "National Health and Nutrition Examination Survey",
"description": null,
"count": 0,
"children": null,
"category": "study_ids_dataset_ids",
"meta": null
},
{
"name": "3",
"display": "1000 Genomes Project",
"description": null,
"count": 0,
"children": null,
"category": "study_ids_dataset_ids",
"meta": null
},
{
"name": "phs002715",
"display": "NSRR CFS",
"description": null,
"count": 0,
"children": null,
"category": "study_ids_dataset_ids",
"meta": null
},
{
"name": "phs000284",
"display": "CFS",
"description": null,
"count": 0,
"children": null,
"category": "study_ids_dataset_ids",
"meta": null
},
{
"name": "phs000007",
"display": "FHS",
"description": null,
"count": 3,
"children": null,
"category": "study_ids_dataset_ids",
"meta": null
},
{
"name": "phs000007",
"display": "FHS",
"description": null,
"count": 1,
"children": null,
"category": "study_ids_dataset_ids",
"meta": null
},
{
"name": "phs002385",
"display": "HCT_for_SCD",
"description": null,
"count": 0,
"children": null,
"category": "study_ids_dataset_ids",
"meta": null
},
{
"name": "phs003463",
"display": "RECOVER_Adult",
"description": null,
"count": 0,
"children": null,
"category": "study_ids_dataset_ids",
"meta": null
},
{
"name": "phs003543",
"display": "NSRR_HSHC",
"description": null,
"count": 0,
"children": null,
"category": "study_ids_dataset_ids",
"meta": null
},
{
"name": "phs002808",
"display": "nuMoM2b",
"description": null,
"count": 0,
"children": null,
"category": "study_ids_dataset_ids",
"meta": null
},
{
"name": "phs003566",
"display": "SPRINT",
"description": null,
"count": 0,
"children": null,
"category": "study_ids_dataset_ids",
"meta": null
},
{
"name": "phs001963",
"display": "DEMENTIA-SEQ",
"description": null,
"count": 0,
"children": null,
"category": "study_ids_dataset_ids",
"meta": null
}
]
},
{
"name": "nsrr_harmonized",
"display": "Common Data Element Collection",
"description": "",
"facets": [
{
"name": "LOINC",
"display": "LOINC",
"description": null,
"count": 1,
"children": null,
"category": "nsrr_harmonized",
"meta": null
},
{
"name": "PhenX",
"display": "PhenX",
"description": null,
"count": 1,
"children": null,
"category": "nsrr_harmonized",
"meta": null
},
{
"name": "gad_7",
"display": "Generalized Anxiety Disorder Assessment (GAD-7)",
"description": null,
"count": 0,
"children": null,
"category": "nsrr_harmonized",
"meta": null
},
{
"name": "taps_tool",
"display": "NIDA CTN Common Data Elements = TAPS Tool",
"description": null,
"count": 0,
"children": null,
"category": "nsrr_harmonized",
"meta": null
}
]
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -184,24 +184,27 @@ private String createMultiCategorySQLNoSearch(Map<String, List<Facet>> facets, M
and INTERSECT them. This creates the concepts for this category
*/
String selectedFacetsQuery = facets.keySet().stream().map(category -> {
String allConceptsForCategory = categoryKeys.values().stream()
.filter(key -> !categoryKeys.get(category).equals(key))
.map(key -> "SELECT * FROM facet_category_" + key + "_concepts")
.collect(Collectors.joining(" UNION "));
params.addValue("", "");
return """
(
SELECT
facet.facet_id, count(*) as facet_count
FROM
facet
JOIN facet__concept_node fcn ON fcn.facet_id = facet.facet_id
WHERE
fcn.concept_node_id IN (%s)
GROUP BY
facet.facet_id
)
""".formatted(allConceptsForCategory);
params.addValue("facet_category_" + categoryKeys.get(category), category);
String allConceptsForCategory = categoryKeys.values().stream()
.filter(key -> !categoryKeys.get(category).equals(key))
.map(key -> "SELECT * FROM facet_category_" + key + "_concepts")
.collect(Collectors.joining(" UNION "));
params.addValue("", "");
return """
(
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 (%s)
AND fc.name = :facet_category_%s
GROUP BY
facet.facet_id
)
""".formatted(allConceptsForCategory, categoryKeys.get(category));
})
.collect(Collectors.joining("\n\tUNION\n"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class FacetQueryGeneratorTest {
void shouldaaa() {
Filter jim = new Filter(List.of(
new Facet("phs000007", "", "", null, null, "study_ids_dataset_ids", null),
new Facet("PhenX", "", "", null, null, "nsrr_harmonized", null)
new Facet("LOINC", "", "", null, null, "nsrr_harmonized", null)
), "");
String query = generator.createFacetSQLAndPopulateParams(jim, new MapSqlParameterSource());
System.out.println(query);
Expand Down
Loading

0 comments on commit 69dc831

Please sign in to comment.