use of org.sagebionetworks.bridge.models.accounts.UserSession in project BridgeServer2 by Sage-Bionetworks.
the class AdherenceController method getWeeklyAdherenceReport.
@GetMapping("/v5/studies/{studyId}/participants/{userIdToken}/adherence/weekly")
public WeeklyAdherenceReport getWeeklyAdherenceReport(@PathVariable String studyId, @PathVariable String userIdToken) {
UserSession session = getAuthenticatedSession(DEVELOPER, RESEARCHER, STUDY_DESIGNER, STUDY_COORDINATOR);
AccountId accountId = BridgeUtils.parseAccountId(session.getAppId(), userIdToken);
Account account = accountService.getAccount(accountId).orElseThrow(() -> new EntityNotFoundException(Account.class));
return service.getWeeklyAdherenceReport(session.getAppId(), studyId, account);
}
use of org.sagebionetworks.bridge.models.accounts.UserSession 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;
}
use of org.sagebionetworks.bridge.models.accounts.UserSession 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;
}
use of org.sagebionetworks.bridge.models.accounts.UserSession in project BridgeServer2 by Sage-Bionetworks.
the class AdherenceController method getStudyAdherenceReport.
@GetMapping("/v5/studies/{studyId}/participants/{userIdToken}/adherence/study")
public StudyAdherenceReport getStudyAdherenceReport(@PathVariable String studyId, @PathVariable String userIdToken) {
UserSession session = getAuthenticatedSession(DEVELOPER, RESEARCHER, STUDY_DESIGNER, STUDY_COORDINATOR);
AccountId accountId = BridgeUtils.parseAccountId(session.getAppId(), userIdToken);
Account account = accountService.getAccount(accountId).orElseThrow(() -> new EntityNotFoundException(Account.class));
return service.getStudyAdherenceReport(session.getAppId(), studyId, account);
}
use of org.sagebionetworks.bridge.models.accounts.UserSession in project BridgeServer2 by Sage-Bionetworks.
the class AdherenceController method getEventStreamAdherenceReportForSelf.
@GetMapping("/v5/studies/{studyId}/participants/self/adherence/eventstream")
public EventStreamAdherenceReport getEventStreamAdherenceReportForSelf(@PathVariable String studyId, @RequestParam(required = false) String datetime, @RequestParam(required = false) String activeOnly) {
UserSession session = getAuthenticatedAndConsentedSession();
DateTime now = BridgeUtils.getDateTimeOrDefault(datetime, getDateTime());
Boolean showActiveOnly = "true".equalsIgnoreCase(activeOnly);
return service.getEventStreamAdherenceReport(session.getAppId(), studyId, session.getId(), now, session.getParticipant().getClientTimeZone(), showActiveOnly);
}
Aggregations