use of org.sagebionetworks.bridge.models.schedules2.adherence.study.StudyAdherenceReport in project BridgeServer2 by Sage-Bionetworks.
the class AdherenceService method getWeeklyAdherenceReport.
public WeeklyAdherenceReport getWeeklyAdherenceReport(String appId, String studyId, Account account) {
Stopwatch watch = Stopwatch.createStarted();
DateTime createdOn = getDateTime();
String timeZone = null;
if (account.getClientTimeZone() != null) {
timeZone = account.getClientTimeZone();
} else {
timeZone = getDefaultTimeZoneId();
}
StudyAdherenceReport report = generateReport(appId, studyId, account.getId(), createdOn, timeZone, (state) -> StudyAdherenceReportGenerator.INSTANCE.generate(state));
report.setParticipant(new AccountRef(account, studyId));
report.setTestAccount(account.getDataGroups().contains(TEST_USER_GROUP));
report.setCreatedOn(createdOn);
report.setClientTimeZone(timeZone);
WeeklyAdherenceReport weeklyReport = deriveWeeklyAdherenceFromStudyAdherenceReport(studyId, account, report);
watch.stop();
LOG.info("Weekly adherence report took " + watch.elapsed(TimeUnit.MILLISECONDS) + "ms");
return weeklyReport;
}
use of org.sagebionetworks.bridge.models.schedules2.adherence.study.StudyAdherenceReport in project BridgeServer2 by Sage-Bionetworks.
the class StudyAdherenceReportGeneratorTest method timestampBeforeSchedule.
@Test
public void timestampBeforeSchedule() throws Exception {
AdherenceState state = createAdherenceState().withNow(DateTime.parse("2020-01-01T00:00:00.000-08:00")).build();
StudyAdherenceReport report = INSTANCE.generate(state);
for (StudyReportWeek week : report.getWeeks()) {
for (List<EventStreamDay> days : week.getByDayEntries().values()) {
for (EventStreamDay oneDay : days) {
for (EventStreamWindow win : oneDay.getTimeWindows()) {
assertEquals(win.getState(), NOT_YET_AVAILABLE);
}
}
}
}
}
use of org.sagebionetworks.bridge.models.schedules2.adherence.study.StudyAdherenceReport in project BridgeServer2 by Sage-Bionetworks.
the class StudyAdherenceReportGeneratorTest method participantStudyProgress_done.
@Test
public void participantStudyProgress_done() throws Exception {
AdherenceState state = createAdherenceState().withNow(DateTime.parse("2022-05-01T00:00:00.000-08:00")).build();
StudyAdherenceReport report = INSTANCE.generate(state);
assertEquals(report.getProgression(), ParticipantStudyProgress.DONE);
}
use of org.sagebionetworks.bridge.models.schedules2.adherence.study.StudyAdherenceReport in project BridgeServer2 by Sage-Bionetworks.
the class StudyAdherenceReportGeneratorTest method participantStudyProgress_unstarted.
@Test
public void participantStudyProgress_unstarted() throws Exception {
AdherenceState state = createAdherenceState().withNow(DateTime.parse("2020-01-01T00:00:00.000-08:00")).build();
StudyAdherenceReport report = INSTANCE.generate(state);
assertEquals(report.getProgression(), ParticipantStudyProgress.IN_PROGRESS);
}
use of org.sagebionetworks.bridge.models.schedules2.adherence.study.StudyAdherenceReport in project BridgeServer2 by Sage-Bionetworks.
the class StudyAdherenceReportGeneratorTest method week_correct.
@Test
public void week_correct() throws Exception {
AdherenceState state = createAdherenceState().withAdherenceRecords(createAdherenceRecords()).build();
StudyAdherenceReport report = INSTANCE.generate(state);
StudyReportWeek week = report.getWeeks().iterator().next();
assertEquals(week.getSearchableLabels(), ImmutableSet.of(":Initial Survey:Week 1:", ":Baseline Tapping Test:Week 1:"));
assertEquals(week.getWeekInStudy(), 1);
assertEquals(week.getStartDate().toString(), "2022-03-01");
assertEquals(week.getAdherencePercent(), Integer.valueOf(100));
assertEquals(week.getByDayEntries().get(1).get(1).getTimeWindows().get(0).getState(), COMPLETED);
assertEquals(week.getByDayEntries().get(2).get(0).getTimeWindows().get(0).getState(), COMPLETED);
}
Aggregations