Skip to content

Commit a622b80

Browse files
author
Luke Sikina
committed
[CHORE] Now they tell me about the consents. smh
1 parent abf9fe4 commit a622b80

File tree

4 files changed

+24
-13
lines changed

4 files changed

+24
-13
lines changed

src/main/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptFilterQueryGenerator.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ public class ConceptFilterQueryGenerator {
1717

1818
private static final String CONSENT_QUERY = """
1919
dataset.dataset_id IN (
20-
SELECT consent.dataset_id
20+
SELECT
21+
consent.dataset_id
2122
FROM consent
22-
WHERE consent.consent_code IN (:consents)
23+
LEFT JOIN dataset ON dataset.dataset_id = consent.dataset_id
24+
WHERE
25+
concat(dataset.ref, '.', consent.consent_code) IN (:consents) OR
26+
(dataset.ref IN (:consents) AND consent.consent_code = '')
2327
) AND
2428
""";
2529

src/main/java/edu/harvard/dbmi/avillach/dictionary/facet/FacetQueryGenerator.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ public class FacetQueryGenerator {
1717

1818
private static final String CONSENT_QUERY = """
1919
dataset.dataset_id IN (
20-
SELECT consent.dataset_id
20+
SELECT
21+
consent.dataset_id
2122
FROM consent
22-
WHERE consent.consent_code IN (:consents)
23+
LEFT JOIN dataset ON dataset.dataset_id = consent.dataset_id
24+
WHERE
25+
concat(dataset.ref, '.', consent.consent_code) IN (:consents) OR
26+
(dataset.ref IN (:consents) AND consent.consent_code = '')
2327
) AND
2428
""";
2529

src/test/java/edu/harvard/dbmi/avillach/dictionary/facet/FacetQueryGeneratorTest.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void shouldCountFacetsWithNoSearchAndNoSelectedFacetsAndNoConsents() {
7474

7575
@Test
7676
void shouldCountFacetsWithNoSearchAndNoSelectedFacetsAndConsents() {
77-
Filter filter = new Filter(List.of(), "", List.of("c2"));
77+
Filter filter = new Filter(List.of(), "", List.of("LOINC.c2", "PhenX.c2", "phs000007.c2"));
7878

7979
MapSqlParameterSource params = new MapSqlParameterSource();
8080
String query = subject.createFacetSQLAndPopulateParams(filter, params);
@@ -107,7 +107,7 @@ void shouldCountFacetsWithSearchAndNoSelectedFacetsAndNoConsents() {
107107

108108
@Test
109109
void shouldCountFacetsWithSearchAndNoSelectedFacetsAndConsents() {
110-
Filter filter = new Filter(List.of(), "age", List.of("c1"));
110+
Filter filter = new Filter(List.of(), "age", List.of("phs002715.c1", "phs000284.c1", "phs002385.c1"));
111111

112112
MapSqlParameterSource params = new MapSqlParameterSource();
113113
String query = subject.createFacetSQLAndPopulateParams(filter, params);
@@ -147,7 +147,7 @@ void shouldCountFacetsWithSearchAndOneSelectedFacetsAndNoConsents() {
147147
void shouldCountFacetsWithSearchAndOneSelectedFacetsAndConsents() {
148148
Filter filter = new Filter(
149149
List.of(new Facet("phs002715", "study_ids_dataset_ids")),
150-
"age", List.of("c1")
150+
"age", List.of("phs002715.c1", "phs000284.c1", "phs002385.c1")
151151
);
152152

153153
MapSqlParameterSource params = new MapSqlParameterSource();
@@ -191,7 +191,7 @@ void shouldCountFacetsNoSearchAndOneSelectedFacetsAndNoConsents() {
191191
void shouldCountFacetsNoSearchAndOneSelectedFacetsAndConsents() {
192192
Filter filter = new Filter(
193193
List.of(new Facet("phs002715", "study_ids_dataset_ids")),
194-
"", List.of("c2")
194+
"", List.of("phs000007.c2")
195195
);
196196

197197
MapSqlParameterSource params = new MapSqlParameterSource();
@@ -235,7 +235,7 @@ void shouldCountFacetsWithSearchAndTwoSelectedFacetsInDifferentCatsAndConsents()
235235
new Facet("phs000007", "study_ids_dataset_ids"),
236236
new Facet("LOINC", "nsrr_harmonized")
237237
),
238-
"cola", List.of("c1")
238+
"cola", List.of("LOINC.c1", "PhenX.c1", "phs000007.c1")
239239
);
240240

241241
MapSqlParameterSource params = new MapSqlParameterSource();
@@ -281,7 +281,7 @@ void shouldCountFacetsNoSearchAndTwoSelectedFacetsInDifferentCatsAndConsents() {
281281
new Facet("phs000007", "study_ids_dataset_ids"),
282282
new Facet("LOINC", "nsrr_harmonized")
283283
),
284-
"", List.of("c1")
284+
"", List.of("LOINC.c1", "PhenX.c1", "phs000007.c1")
285285
);
286286

287287
MapSqlParameterSource params = new MapSqlParameterSource();

src/test/java/edu/harvard/dbmi/avillach/dictionary/filter/ConceptFilterQueryGeneratorTest.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ void shouldGenerateForFHSFacet() {
6868

6969
@Test
7070
void shouldGenerateForFHSFacetWithConsent1() {
71-
Filter f = new Filter(List.of(new Facet("phs000007", "FHS", "", "", null, null, "study_ids_dataset_ids", null)), "", List.of("c1"));
71+
Filter f = new Filter(List.of(new Facet(
72+
"phs000007", "FHS", "", "", null, null, "study_ids_dataset_ids", null)),
73+
"", List.of("phs000007.c1")
74+
);
7275
QueryParamPair pair = subject.generateFilterQuery(f, Pageable.unpaged());
7376

7477
List<Integer> actual = template.queryForList(pair.query(), pair.params(), Integer.class);
@@ -79,7 +82,7 @@ void shouldGenerateForFHSFacetWithConsent1() {
7982

8083
@Test
8184
void shouldGenerateForFHSFacetWithConsent1And2() {
82-
Filter f = new Filter(List.of(new Facet("phs000007", "FHS", "", "", null, null, "study_ids_dataset_ids", null)), "", List.of("c1", "c2"));
85+
Filter f = new Filter(List.of(new Facet("phs000007", "FHS", "", "", null, null, "study_ids_dataset_ids", null)), "", List.of("phs000007.c1", "phs000007.c2"));
8386
QueryParamPair pair = subject.generateFilterQuery(f, Pageable.unpaged());
8487

8588
List<Integer> actual = template.queryForList(pair.query(), pair.params(), Integer.class);
@@ -90,7 +93,7 @@ void shouldGenerateForFHSFacetWithConsent1And2() {
9093

9194
@Test
9295
void shouldGenerateForFHSFacetWithConsent3() {
93-
Filter f = new Filter(List.of(new Facet("phs000007", "FHS", "", "", null, null, "study_ids_dataset_ids", null)), "", List.of("c3"));
96+
Filter f = new Filter(List.of(new Facet("phs000007", "FHS", "", "", null, null, "study_ids_dataset_ids", null)), "", List.of("dne.c3"));
9497
QueryParamPair pair = subject.generateFilterQuery(f, Pageable.unpaged());
9598

9699
List<Integer> actual = template.queryForList(pair.query(), pair.params(), Integer.class);

0 commit comments

Comments
 (0)