Search in sources :

Example 26 with AdherenceState

use of org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceState in project BridgeServer2 by Sage-Bionetworks.

the class StudyAdherenceReportGeneratorTest method participantStudyProgress_noSchedule.

@Test
public void participantStudyProgress_noSchedule() throws Exception {
    AdherenceState state = createAdherenceState().withMetadata(null).build();
    StudyAdherenceReport report = INSTANCE.generate(state);
    assertEquals(report.getProgression(), ParticipantStudyProgress.NO_SCHEDULE);
}
Also used : AdherenceState(org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceState) Test(org.testng.annotations.Test)

Example 27 with AdherenceState

use of org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceState in project BridgeServer2 by Sage-Bionetworks.

the class StudyAdherenceReportGeneratorTest method adherenceNotCalculatedForFutureWeeks.

@Test
public void adherenceNotCalculatedForFutureWeeks() throws Exception {
    AdherenceState state = new AdherenceState.Builder().withStudyStartEventId("timeline_retrieved").withMetadata(createTimelineMetadata()).withEvents(createEvents()).withNow(DateTime.parse("2022-03-7T01:00:00.000-08:00")).build();
    StudyAdherenceReport report = StudyAdherenceReportGenerator.INSTANCE.generate(state);
    List<StudyReportWeek> weeks = ImmutableList.copyOf(report.getWeeks());
    assertEquals(weeks.get(0).getAdherencePercent(), Integer.valueOf(0));
    assertNull(weeks.get(1).getAdherencePercent());
    assertNull(weeks.get(2).getAdherencePercent());
    assertNull(weeks.get(3).getAdherencePercent());
}
Also used : AdherenceState(org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceState) Test(org.testng.annotations.Test)

Example 28 with AdherenceState

use of org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceState in project BridgeServer2 by Sage-Bionetworks.

the class StudyAdherenceReportGeneratorTest method eventStreamsWithNoEventsTransferredToUnused.

@Test
public void eventStreamsWithNoEventsTransferredToUnused() throws Exception {
    AdherenceState state = createAdherenceState().withEvents(null).build();
    StudyAdherenceReport report = INSTANCE.generate(state);
    assertTrue(report.getWeeks().isEmpty());
    assertTrue(report.getEventTimestamps().isEmpty());
    assertEquals(report.getUnsetEventIds(), ImmutableSet.of("study_burst:Study Burst:02", "study_burst:Study Burst:01", "study_burst:Study Burst:03", "custom:event1", "timeline_retrieved"));
    assertEquals(report.getUnscheduledSessions(), ImmutableSet.of("Supplemental Survey", "Initial Survey", "Baseline Tapping Test", "Study Burst Tapping Test", "Final Survey"));
}
Also used : AdherenceState(org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceState) Test(org.testng.annotations.Test)

Example 29 with AdherenceState

use of org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceState in project BridgeServer2 by Sage-Bionetworks.

the class StudyAdherenceReportGeneratorTest method todaySet.

@Test
public void todaySet() throws Exception {
    AdherenceState state = createAdherenceState().build();
    StudyAdherenceReport report = INSTANCE.generate(state);
    for (StudyReportWeek week : report.getWeeks()) {
        for (List<EventStreamDay> days : week.getByDayEntries().values()) {
            for (EventStreamDay oneDay : days) {
                if (oneDay.isToday()) {
                    assertEquals(oneDay.getStartDate().toString(), "2022-03-15");
                } else if (oneDay.getStartDate() != null) {
                    assertNotEquals(oneDay.getStartDate().toString(), "2022-03-15");
                }
            }
        }
    }
}
Also used : AdherenceState(org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceState) EventStreamDay(org.sagebionetworks.bridge.models.schedules2.adherence.eventstream.EventStreamDay) Test(org.testng.annotations.Test)

Example 30 with AdherenceState

use of org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceState in project BridgeServer2 by Sage-Bionetworks.

the class StudyAdherenceReportGeneratorTest method emptyEventStreamReportGeneratesEmptyStudyAdherenceReport.

@Test
public void emptyEventStreamReportGeneratesEmptyStudyAdherenceReport() throws Exception {
    AdherenceState state = new AdherenceState.Builder().withNow(DateTime.parse("2022-03-01T00:00:00.000-08:00")).build();
    StudyAdherenceReport report = INSTANCE.generate(state);
    // these fields are not set in the generator, they are set in the service.
    // participant, testAccount, createdOn, timestamp, clientTimeZone
    assertEquals(report.getProgression(), ParticipantStudyProgress.NO_SCHEDULE);
    assertEquals(report.getUnsetEventIds(), ImmutableSet.of());
    assertEquals(report.getUnscheduledSessions(), ImmutableSet.of());
    assertTrue(report.getWeeks().isEmpty());
    assertNull(report.getCurrentWeek());
    assertNull(report.getNextActivity());
    assertTrue(report.getEventTimestamps().isEmpty());
}
Also used : AdherenceState(org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceState) Test(org.testng.annotations.Test)

Aggregations

AdherenceState (org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceState)42 Test (org.testng.annotations.Test)40 StudyActivityEvent (org.sagebionetworks.bridge.models.activities.StudyActivityEvent)25 AdherenceRecord (org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceRecord)20 EventStreamDay (org.sagebionetworks.bridge.models.schedules2.adherence.eventstream.EventStreamDay)5 Schedule2 (org.sagebionetworks.bridge.models.schedules2.Schedule2)4 Timeline (org.sagebionetworks.bridge.models.schedules2.timelines.Timeline)4 DateTime (org.joda.time.DateTime)3 LocalDate (org.joda.time.LocalDate)3 DateRange (org.sagebionetworks.bridge.models.DateRange)3 EventStreamWindow (org.sagebionetworks.bridge.models.schedules2.adherence.eventstream.EventStreamWindow)3 ParticipantSchedule (org.sagebionetworks.bridge.models.schedules2.participantschedules.ParticipantSchedule)3 HashMap (java.util.HashMap)2 Schedule2Test (org.sagebionetworks.bridge.models.schedules2.Schedule2Test)2 TimelineMetadata (org.sagebionetworks.bridge.models.schedules2.timelines.TimelineMetadata)2 Study (org.sagebionetworks.bridge.models.studies.Study)2 Stopwatch (com.google.common.base.Stopwatch)1 ImmutableList (com.google.common.collect.ImmutableList)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1