Skip to content

Commit

Permalink
[CHORE] Now they tell me about the consents. smh
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Sikina committed Sep 17, 2024
1 parent abf9fe4 commit a622b80
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ public class ConceptFilterQueryGenerator {

private static final String CONSENT_QUERY = """
dataset.dataset_id IN (
SELECT consent.dataset_id
SELECT
consent.dataset_id
FROM consent
WHERE consent.consent_code IN (:consents)
LEFT JOIN dataset ON dataset.dataset_id = consent.dataset_id
WHERE
concat(dataset.ref, '.', consent.consent_code) IN (:consents) OR
(dataset.ref IN (:consents) AND consent.consent_code = '')
) AND
""";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ public class FacetQueryGenerator {

private static final String CONSENT_QUERY = """
dataset.dataset_id IN (
SELECT consent.dataset_id
SELECT
consent.dataset_id
FROM consent
WHERE consent.consent_code IN (:consents)
LEFT JOIN dataset ON dataset.dataset_id = consent.dataset_id
WHERE
concat(dataset.ref, '.', consent.consent_code) IN (:consents) OR
(dataset.ref IN (:consents) AND consent.consent_code = '')
) AND
""";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void shouldCountFacetsWithNoSearchAndNoSelectedFacetsAndNoConsents() {

@Test
void shouldCountFacetsWithNoSearchAndNoSelectedFacetsAndConsents() {
Filter filter = new Filter(List.of(), "", List.of("c2"));
Filter filter = new Filter(List.of(), "", List.of("LOINC.c2", "PhenX.c2", "phs000007.c2"));

MapSqlParameterSource params = new MapSqlParameterSource();
String query = subject.createFacetSQLAndPopulateParams(filter, params);
Expand Down Expand Up @@ -107,7 +107,7 @@ void shouldCountFacetsWithSearchAndNoSelectedFacetsAndNoConsents() {

@Test
void shouldCountFacetsWithSearchAndNoSelectedFacetsAndConsents() {
Filter filter = new Filter(List.of(), "age", List.of("c1"));
Filter filter = new Filter(List.of(), "age", List.of("phs002715.c1", "phs000284.c1", "phs002385.c1"));

MapSqlParameterSource params = new MapSqlParameterSource();
String query = subject.createFacetSQLAndPopulateParams(filter, params);
Expand Down Expand Up @@ -147,7 +147,7 @@ void shouldCountFacetsWithSearchAndOneSelectedFacetsAndNoConsents() {
void shouldCountFacetsWithSearchAndOneSelectedFacetsAndConsents() {
Filter filter = new Filter(
List.of(new Facet("phs002715", "study_ids_dataset_ids")),
"age", List.of("c1")
"age", List.of("phs002715.c1", "phs000284.c1", "phs002385.c1")
);

MapSqlParameterSource params = new MapSqlParameterSource();
Expand Down Expand Up @@ -191,7 +191,7 @@ void shouldCountFacetsNoSearchAndOneSelectedFacetsAndNoConsents() {
void shouldCountFacetsNoSearchAndOneSelectedFacetsAndConsents() {
Filter filter = new Filter(
List.of(new Facet("phs002715", "study_ids_dataset_ids")),
"", List.of("c2")
"", List.of("phs000007.c2")
);

MapSqlParameterSource params = new MapSqlParameterSource();
Expand Down Expand Up @@ -235,7 +235,7 @@ void shouldCountFacetsWithSearchAndTwoSelectedFacetsInDifferentCatsAndConsents()
new Facet("phs000007", "study_ids_dataset_ids"),
new Facet("LOINC", "nsrr_harmonized")
),
"cola", List.of("c1")
"cola", List.of("LOINC.c1", "PhenX.c1", "phs000007.c1")
);

MapSqlParameterSource params = new MapSqlParameterSource();
Expand Down Expand Up @@ -281,7 +281,7 @@ void shouldCountFacetsNoSearchAndTwoSelectedFacetsInDifferentCatsAndConsents() {
new Facet("phs000007", "study_ids_dataset_ids"),
new Facet("LOINC", "nsrr_harmonized")
),
"", List.of("c1")
"", List.of("LOINC.c1", "PhenX.c1", "phs000007.c1")
);

MapSqlParameterSource params = new MapSqlParameterSource();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ void shouldGenerateForFHSFacet() {

@Test
void shouldGenerateForFHSFacetWithConsent1() {
Filter f = new Filter(List.of(new Facet("phs000007", "FHS", "", "", null, null, "study_ids_dataset_ids", null)), "", List.of("c1"));
Filter f = new Filter(List.of(new Facet(
"phs000007", "FHS", "", "", null, null, "study_ids_dataset_ids", null)),
"", List.of("phs000007.c1")
);
QueryParamPair pair = subject.generateFilterQuery(f, Pageable.unpaged());

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

@Test
void shouldGenerateForFHSFacetWithConsent1And2() {
Filter f = new Filter(List.of(new Facet("phs000007", "FHS", "", "", null, null, "study_ids_dataset_ids", null)), "", List.of("c1", "c2"));
Filter f = new Filter(List.of(new Facet("phs000007", "FHS", "", "", null, null, "study_ids_dataset_ids", null)), "", List.of("phs000007.c1", "phs000007.c2"));
QueryParamPair pair = subject.generateFilterQuery(f, Pageable.unpaged());

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

@Test
void shouldGenerateForFHSFacetWithConsent3() {
Filter f = new Filter(List.of(new Facet("phs000007", "FHS", "", "", null, null, "study_ids_dataset_ids", null)), "", List.of("c3"));
Filter f = new Filter(List.of(new Facet("phs000007", "FHS", "", "", null, null, "study_ids_dataset_ids", null)), "", List.of("dne.c3"));
QueryParamPair pair = subject.generateFilterQuery(f, Pageable.unpaged());

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

0 comments on commit a622b80

Please sign in to comment.