diff --git a/study/src/org/labkey/study/controllers/StudyController.java b/study/src/org/labkey/study/controllers/StudyController.java index ee8f5c75b14..bcbb2cd2b0e 100644 --- a/study/src/org/labkey/study/controllers/StudyController.java +++ b/study/src/org/labkey/study/controllers/StudyController.java @@ -652,6 +652,7 @@ public static class OverviewForm extends DatasetFilterForm { private String _qcState; private String[] _visitStatistic = new String[0]; + private String _cohortFilterType; public String getQCState() { @@ -686,6 +687,16 @@ private Set getVisitStatistics() return set; } + + public String getCohortFilterType() + { + return _cohortFilterType; + } + + public void setCohortFilterType(String cohortFilterType) + { + _cohortFilterType = cohortFilterType; + } } @@ -715,6 +726,17 @@ public ModelAndView getView(OverviewForm form, BindException errors) throws Exce bean.cohortFilter = CohortFilterFactory.getFromURL(getContainer(), getUser(), getViewContext().getActionURL(), DatasetQueryView.DATAREGION); VisitManager visitManager = StudyManager.getInstance().getVisitManager(bean.study); + + if (null != bean.cohortFilter) + { + if (!visitManager.supportedCohortFilterTypes().contains(bean.cohortFilter.getType())) + { + errors.rejectValue("cohortFilterType", ERROR_MSG, bean.cohortFilter.getType() + " is not supported."); + // CohortFilterFactory.getFromURL() returns NULL for unrecognized and continues, let's do the same + bean.cohortFilter = null; + } + } + bean.visitMapSummary = visitManager.getVisitSummary(getUser(), bean.cohortFilter, bean.qcStates, bean.stats, bean.showAll); return new StudyJspView<>(_study, "/org/labkey/study/view/overview.jsp", bean, errors); diff --git a/study/src/org/labkey/study/view/overview.jsp b/study/src/org/labkey/study/view/overview.jsp index bb4bf3c8b83..227a24230ff 100644 --- a/study/src/org/labkey/study/view/overview.jsp +++ b/study/src/org/labkey/study/view/overview.jsp @@ -180,6 +180,7 @@ out.print(unsafe("\n")); } %> +

diff --git a/study/src/org/labkey/study/visitmanager/RelativeDateVisitManager.java b/study/src/org/labkey/study/visitmanager/RelativeDateVisitManager.java index b74e4e06b37..b11070ae838 100644 --- a/study/src/org/labkey/study/visitmanager/RelativeDateVisitManager.java +++ b/study/src/org/labkey/study/visitmanager/RelativeDateVisitManager.java @@ -74,6 +74,11 @@ public String getPluralLabel() return "Timepoints"; } + @Override + public Set supportedCohortFilterTypes() + { + return Set.of(CohortFilter.Type.PTID_CURRENT, CohortFilter.Type.PTID_INITIAL); + } @Override @Nullable diff --git a/study/src/org/labkey/study/visitmanager/SequenceVisitManager.java b/study/src/org/labkey/study/visitmanager/SequenceVisitManager.java index 18dcb9144c1..184e744e187 100644 --- a/study/src/org/labkey/study/visitmanager/SequenceVisitManager.java +++ b/study/src/org/labkey/study/visitmanager/SequenceVisitManager.java @@ -70,6 +70,12 @@ public SequenceVisitManager(StudyImpl study) super(study); } + @Override + public Set supportedCohortFilterTypes() + { + return Set.of(CohortFilter.Type.PTID_CURRENT, CohortFilter.Type.PTID_INITIAL, CohortFilter.Type.DATA_COLLECTION); + } + @Override @Nullable protected SQLFragment getVisitSummarySql(StudyQuerySchema sqs, CohortFilter cohortFilter, QCStateSet qcStates, Set stats, boolean showAll) diff --git a/study/src/org/labkey/study/visitmanager/VisitManager.java b/study/src/org/labkey/study/visitmanager/VisitManager.java index d476746bb7d..60ab0de44f7 100644 --- a/study/src/org/labkey/study/visitmanager/VisitManager.java +++ b/study/src/org/labkey/study/visitmanager/VisitManager.java @@ -212,6 +212,8 @@ protected void updateParticipantVisitTableAfterInsert(@Nullable User user, @Null */ protected abstract @NotNull ValidationException updateVisitTable(User user, @Nullable Logger logger, boolean failForUndefinedVisits); + public abstract Set supportedCohortFilterTypes(); + // Produce appropriate SQL for getVisitSummary(). The SQL must select dataset ID, sequence number, and then the specified statistics; // it also needs to filter by cohort and qcstates. @Nullable