Search in sources :

Example 1 with AdherenceRecord

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

the class TestUtils method getAdherenceRecord.

public static AdherenceRecord getAdherenceRecord(String instanceGuid) {
    AdherenceRecord record = new AdherenceRecord();
    record.setStudyId(TEST_STUDY_ID);
    record.setUserId(TEST_USER_ID);
    record.setEventTimestamp(CREATED_ON);
    record.setClientTimeZone("America/Los_Angeles");
    record.setStartedOn(MODIFIED_ON);
    record.setInstanceGuid(instanceGuid);
    return record;
}
Also used : AdherenceRecord(org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceRecord)

Example 2 with AdherenceRecord

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

the class TestUtils method mockAdherenceRecord.

public static AdherenceRecord mockAdherenceRecord(String instanceGuid) {
    AdherenceRecord record = new AdherenceRecord();
    record.setStudyId(TEST_STUDY_ID);
    record.setUserId(TEST_USER_ID);
    record.setEventTimestamp(CREATED_ON);
    record.setClientTimeZone("America/Los_Angeles");
    record.setStartedOn(MODIFIED_ON);
    record.setInstanceGuid(instanceGuid);
    record.setClientTimeZone("America/Los_Angeles");
    return record;
}
Also used : AdherenceRecord(org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceRecord)

Example 3 with AdherenceRecord

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

the class AdherenceController method updateAdherenceRecordsForSelf.

@PostMapping("/v5/studies/{studyId}/participants/self/adherence")
public StatusMessage updateAdherenceRecordsForSelf(@PathVariable String studyId) {
    UserSession session = getAuthenticatedAndConsentedSession();
    AdherenceRecordList recordsList = parseJson(AdherenceRecordList.class);
    for (AdherenceRecord oneRecord : recordsList.getRecords()) {
        oneRecord.setAppId(session.getAppId());
        oneRecord.setUserId(session.getId());
        oneRecord.setStudyId(studyId);
    }
    service.updateAdherenceRecords(session.getAppId(), recordsList);
    return SAVED_MSG;
}
Also used : AdherenceRecordList(org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceRecordList) UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) AdherenceRecord(org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceRecord) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 4 with AdherenceRecord

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

the class AdherenceController method deleteAdherenceRecord.

@DeleteMapping("/v5/studies/{studyId}/participants/{userIdToken}/adherence/{instanceGuid}/{eventTimestamp}/{startedOn}")
public StatusMessage deleteAdherenceRecord(@PathVariable String studyId, @PathVariable String userIdToken, @PathVariable String instanceGuid, @PathVariable String eventTimestamp, @PathVariable String startedOn) {
    UserSession session = getAuthenticatedSession(DEVELOPER, RESEARCHER, STUDY_DESIGNER, STUDY_COORDINATOR);
    String userId = accountService.getAccountId(session.getAppId(), userIdToken).orElseThrow(() -> new EntityNotFoundException(Account.class));
    AdherenceRecord record = new AdherenceRecord();
    record.setAppId(session.getAppId());
    record.setUserId(userId);
    record.setStudyId(studyId);
    record.setInstanceGuid(instanceGuid);
    record.setEventTimestamp(BridgeUtils.getDateTimeOrDefault(eventTimestamp, null));
    record.setStartedOn(BridgeUtils.getDateTimeOrDefault(startedOn, null));
    service.deleteAdherenceRecord(record);
    return DELETED_MSG;
}
Also used : Account(org.sagebionetworks.bridge.models.accounts.Account) UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) AdherenceRecord(org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceRecord) EntityNotFoundException(org.sagebionetworks.bridge.exceptions.EntityNotFoundException) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping)

Example 5 with AdherenceRecord

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

the class AdherenceRecordListValidatorTest method studyIdBlank.

@Test
public void studyIdBlank() {
    AdherenceRecord record = new AdherenceRecord();
    record.setStudyId(" ");
    assertValidatorMessage(INSTANCE, asList(record), asField(STUDY_ID_FIELD), CANNOT_BE_BLANK);
}
Also used : AdherenceRecord(org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceRecord) Test(org.testng.annotations.Test)

Aggregations

AdherenceRecord (org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceRecord)106 Test (org.testng.annotations.Test)83 StudyAdherenceReportGeneratorTest (org.sagebionetworks.bridge.models.schedules2.adherence.study.StudyAdherenceReportGeneratorTest)28 StudyActivityEvent (org.sagebionetworks.bridge.models.activities.StudyActivityEvent)25 AdherenceRecordList (org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceRecordList)22 AdherenceState (org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceState)20 MetadataContainer (org.sagebionetworks.bridge.models.schedules2.timelines.MetadataContainer)13 TimelineMetadata (org.sagebionetworks.bridge.models.schedules2.timelines.TimelineMetadata)12 RequestContext (org.sagebionetworks.bridge.RequestContext)10 PagedResourceList (org.sagebionetworks.bridge.models.PagedResourceList)10 Account (org.sagebionetworks.bridge.models.accounts.Account)8 TestUtils.getAdherenceRecord (org.sagebionetworks.bridge.TestUtils.getAdherenceRecord)7 AdherenceRecordsSearch (org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceRecordsSearch)7 Study (org.sagebionetworks.bridge.models.studies.Study)7 ResourceList (org.sagebionetworks.bridge.models.ResourceList)6 UserSession (org.sagebionetworks.bridge.models.accounts.UserSession)5 WeeklyAdherenceReport (org.sagebionetworks.bridge.models.schedules2.adherence.weekly.WeeklyAdherenceReport)4 PostMapping (org.springframework.web.bind.annotation.PostMapping)4 EntityNotFoundException (org.sagebionetworks.bridge.exceptions.EntityNotFoundException)3 StatusMessage (org.sagebionetworks.bridge.models.StatusMessage)3