Skip to content

Commit

Permalink
Merge pull request #231 from OHSUCMP/feature/issue230
Browse files Browse the repository at this point in the history
#230 - renamed AuditLevel to AuditSeverity, with corresponding schema changes for VUMC
  • Loading branch information
mattStorer authored Dec 4, 2024
2 parents 1c645db + f1357fc commit 9191358
Show file tree
Hide file tree
Showing 25 changed files with 96 additions and 91 deletions.
4 changes: 2 additions & 2 deletions src/main/java/edu/ohsu/cmp/coach/GlobalExceptionHandler.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package edu.ohsu.cmp.coach;

import edu.ohsu.cmp.coach.exception.SessionMissingException;
import edu.ohsu.cmp.coach.model.AuditLevel;
import edu.ohsu.cmp.coach.model.AuditSeverity;
import edu.ohsu.cmp.coach.service.AuditService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -32,7 +32,7 @@ public Object handleException(HttpSession session, HttpServletRequest request, H
logger.error("trapped " + e.getClass().getName() + " at " + request.getRequestURI() +
" for session " + session.getId() + " - " + e.getMessage(), e);

auditService.doAudit(session.getId(), AuditLevel.ERROR, "application exception", "encountered " +
auditService.doAudit(session.getId(), AuditSeverity.ERROR, "application exception", "encountered " +
e.getClass().getSimpleName() + " at " + request.getRequestURI() + " - " + e.getMessage());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import edu.ohsu.cmp.coach.entity.ContactMessage;
import edu.ohsu.cmp.coach.exception.DataException;
import edu.ohsu.cmp.coach.model.AuditLevel;
import edu.ohsu.cmp.coach.model.AuditSeverity;
import edu.ohsu.cmp.coach.model.BloodPressureSummaryModel;
import edu.ohsu.cmp.coach.model.MedicationModel;
import edu.ohsu.cmp.coach.service.BloodPressureService;
Expand Down Expand Up @@ -83,7 +83,7 @@ public String view(HttpSession session, Model model, @RequestParam("token") Stri

model.addAttribute("pageStyles", new String[] { "contact.css" });

auditService.doAudit(sessionId, AuditLevel.INFO, "visited contact page", "token=" + token);
auditService.doAudit(sessionId, AuditSeverity.INFO, "visited contact page", "token=" + token);

return "contact";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package edu.ohsu.cmp.coach.controller;

import edu.ohsu.cmp.coach.entity.Counseling;
import edu.ohsu.cmp.coach.model.AuditLevel;
import edu.ohsu.cmp.coach.model.AuditSeverity;
import edu.ohsu.cmp.coach.model.CounselingPageModel;
import edu.ohsu.cmp.coach.service.CounselingService;
import org.slf4j.Logger;
Expand Down Expand Up @@ -32,7 +32,7 @@ public String view(HttpSession session, Model model, @PathVariable(value="key")

model.addAttribute("page", page);

auditService.doAudit(session.getId(), AuditLevel.INFO, "received counseling", "key=" + key);
auditService.doAudit(session.getId(), AuditSeverity.INFO, "received counseling", "key=" + key);

return "counseling";
}
Expand All @@ -50,7 +50,7 @@ public ResponseEntity<Counseling> create(HttpSession session,
c = counselingService.create(session.getId(),
new Counseling(extCounselingId, referenceSystem, referenceCode, counselingText));

auditService.doAudit(session.getId(), AuditLevel.INFO, "created counseling record", "id=" + c.getId());
auditService.doAudit(session.getId(), AuditSeverity.INFO, "created counseling record", "id=" + c.getId());

return new ResponseEntity<>(c, HttpStatus.OK);

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/edu/ohsu/cmp/coach/controller/GoalsController.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import edu.ohsu.cmp.coach.entity.MyGoal;
import edu.ohsu.cmp.coach.model.redcap.RandomizationGroup;
import edu.ohsu.cmp.coach.model.AchievementStatus;
import edu.ohsu.cmp.coach.model.AuditLevel;
import edu.ohsu.cmp.coach.model.AuditSeverity;
import edu.ohsu.cmp.coach.model.GoalHistoryModel;
import edu.ohsu.cmp.coach.model.GoalModel;
import edu.ohsu.cmp.coach.service.GoalService;
Expand Down Expand Up @@ -52,7 +52,7 @@ public String view(HttpSession session, Model model) {
"inputmask/dist/bindings/inputmask.binding.js"
});

auditService.doAudit(sessionId, AuditLevel.INFO, "visited goals page");
auditService.doAudit(sessionId, AuditSeverity.INFO, "visited goals page");

return "goals";
}
Expand Down Expand Up @@ -85,7 +85,7 @@ public ResponseEntity<GoalModel> create(HttpSession session,
myGoal = new MyGoal(extGoalId, referenceSystem, referenceCode, referenceDisplay, goalText, targetDate);
myGoal = goalService.create(session.getId(), myGoal);

auditService.doAudit(session.getId(), AuditLevel.INFO, "created goal", "id=" + myGoal.getId());
auditService.doAudit(session.getId(), AuditSeverity.INFO, "created goal", "id=" + myGoal.getId());

// the goal was created in response to a suggestion.
// they took the suggestion, so remove it from the list to consider
Expand Down Expand Up @@ -119,14 +119,14 @@ public ResponseEntity<GoalModel> updatebp(HttpSession session,
goal.setDiastolicTarget(diastolicTarget);
goal = goalService.update(goal);

auditService.doAudit(session.getId(), AuditLevel.INFO, "updated BP goal", "id=" + goal.getId() +
auditService.doAudit(session.getId(), AuditSeverity.INFO, "updated BP goal", "id=" + goal.getId() +
", new target=" + systolicTarget + "/" + diastolicTarget);

} else {
goal = goalService.create(session.getId(), new MyGoal(fcm.getBpPanelCommonCoding(),
systolicTarget, diastolicTarget));

auditService.doAudit(session.getId(), AuditLevel.INFO, "created BP goal", "id=" + goal.getId() +
auditService.doAudit(session.getId(), AuditSeverity.INFO, "created BP goal", "id=" + goal.getId() +
", target=" + systolicTarget + "/" + diastolicTarget);
}

Expand All @@ -152,7 +152,7 @@ public ResponseEntity<GoalHistoryModel> updateStatus(HttpSession session,
GoalHistory gh = new GoalHistory(AchievementStatus.valueOf(achievementStatusStr), g);
gh = goalService.createHistory(gh);

auditService.doAudit(session.getId(), AuditLevel.INFO, "updated goal status", "goalId=" + g.getId() +
auditService.doAudit(session.getId(), AuditSeverity.INFO, "updated goal status", "goalId=" + g.getId() +
", historyId=" + gh.getId() + ", achievementStatus=" + achievementStatusStr);

return new ResponseEntity<>(new GoalHistoryModel(gh), HttpStatus.OK);
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/edu/ohsu/cmp/coach/controller/HomeController.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public String view(HttpSession session, Model model,
model.addAttribute("systemStatusMessage", systemStatusMessage);
}

auditService.doAudit(sessionId, AuditLevel.INFO, "visited home page");
auditService.doAudit(sessionId, AuditSeverity.INFO, "visited home page");

return "home";

Expand All @@ -167,7 +167,7 @@ public String view(HttpSession session, Model model,
String recordId = redCapService.createSubjectInfoRecord(redcapParticipantInfo.getCoachId());
String entrySurveyLink = redCapService.getEntrySurveyLink(recordId);

auditService.doAudit(patient, AuditLevel.INFO, "accessed REDCap entry survey", "participant info did not exist");
auditService.doAudit(patient, AuditSeverity.INFO, "accessed REDCap entry survey", "participant info did not exist");

return "redirect:" + entrySurveyLink;

Expand All @@ -176,7 +176,7 @@ public String view(HttpSession session, Model model,
logger.info("REDCap workflow: Forwarding " + redcapParticipantInfo.getCoachId() + " to the entry survey");
String entrySurveyLink = redCapService.getEntrySurveyLink(redcapParticipantInfo.getRecordId());

auditService.doAudit(patient, AuditLevel.INFO, "accessed REDCap entry survey", "information sheet was incomplete");
auditService.doAudit(patient, AuditSeverity.INFO, "accessed REDCap entry survey", "information sheet was incomplete");

return "redirect:" + entrySurveyLink;

Expand All @@ -185,7 +185,7 @@ public String view(HttpSession session, Model model,
logger.info("REDCap workflow: Participant " + redcapParticipantInfo.getCoachId() + " denied consent. Forwarding to consent-previously-denied.");
setCommonViewComponents(model);

auditService.doAudit(patient, AuditLevel.INFO, "access denied", "participant did not grant consent");
auditService.doAudit(patient, AuditSeverity.INFO, "access denied", "participant did not grant consent");

return "consent-previously-denied";

Expand All @@ -194,7 +194,7 @@ public String view(HttpSession session, Model model,
logger.info("REDCap workflow: Forwarding " + redcapParticipantInfo.getCoachId() + " to the survey queue to complete enrollment.");
String surveyQueueLink = redCapService.getSurveyQueueLink(redcapParticipantInfo.getRecordId());

auditService.doAudit(patient, AuditLevel.INFO, "accessed REDCap survey queue", "participant has no consent record, or has not been randomized");
auditService.doAudit(patient, AuditSeverity.INFO, "accessed REDCap survey queue", "participant has no consent record, or has not been randomized");

return "redirect:" + surveyQueueLink;

Expand All @@ -203,7 +203,7 @@ public String view(HttpSession session, Model model,
logger.info("REDCap workflow: Participant " + redcapParticipantInfo.getCoachId() + " has withdrawn. Forwarding to withdrawn page.");
setCommonViewComponents(model);

auditService.doAudit(patient, AuditLevel.INFO, "access denied", "participant has withdrawn from the study");
auditService.doAudit(patient, AuditSeverity.INFO, "access denied", "participant has withdrawn from the study");

return "withdrawn";

Expand All @@ -222,14 +222,14 @@ public String view(HttpSession session, Model model,

patientService.setConfirmedEndOfStudy(patient.getId(), true);

auditService.doAudit(patient, AuditLevel.INFO, "access denied", "participant has completed their participation in the COACH study");
auditService.doAudit(patient, AuditSeverity.INFO, "access denied", "participant has completed their participation in the COACH study");

return "end-of-study";

} else {
logger.error("REDCap workflow: Participant " + redcapParticipantInfo.getRecordId() + "is actively enrolled but cannot access COACH.");

auditService.doAudit(patient, AuditLevel.ERROR, "enrolled but cannot access COACH");
auditService.doAudit(patient, AuditSeverity.ERROR, "enrolled but cannot access COACH");

return "error";
}
Expand Down Expand Up @@ -273,7 +273,7 @@ public ResponseEntity<List<Card>> call() throws Exception {
logger.error("caught " + re.getClass().getName() + " getting recommendations for " + hookId + " - " +
re.getMessage(), re);

auditService.doAudit(session.getId(), AuditLevel.ERROR, "recommendation exception", "encountered " +
auditService.doAudit(session.getId(), AuditSeverity.ERROR, "recommendation exception", "encountered " +
re.getClass().getSimpleName() + " getting recommendations for " + hookId + " - " +
re.getMessage());

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package edu.ohsu.cmp.coach.controller;

import edu.ohsu.cmp.coach.model.AuditLevel;
import edu.ohsu.cmp.coach.model.AuditSeverity;
import edu.ohsu.cmp.coach.model.MedicationModel;
import edu.ohsu.cmp.coach.service.MedicationService;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -40,7 +40,7 @@ public String view(HttpSession session, Model model) {
model.addAttribute("antihypertensiveMedications", antihypertensiveMedications);
model.addAttribute("otherMedications", otherMedications);

auditService.doAudit(session.getId(), AuditLevel.INFO, "visited medications page");
auditService.doAudit(session.getId(), AuditSeverity.INFO, "visited medications page");

return "medications";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package edu.ohsu.cmp.coach.controller;

import edu.ohsu.cmp.coach.model.redcap.RandomizationGroup;
import edu.ohsu.cmp.coach.model.AuditLevel;
import edu.ohsu.cmp.coach.model.AuditSeverity;
import edu.ohsu.cmp.coach.workspace.UserWorkspace;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -30,7 +30,7 @@ public String faq(HttpSession session, Model model) {
userWorkspaceService.get(session.getId()); // don't need it, but we do want to blow out with an error if the user's session doesn't exist
setCommonViewComponents(model);

auditService.doAudit(session.getId(), AuditLevel.INFO, "viewed resources: faq");
auditService.doAudit(session.getId(), AuditSeverity.INFO, "viewed resources: faq");

return "faq";
}
Expand All @@ -40,7 +40,7 @@ public String symptoms(HttpSession session, Model model) {
userWorkspaceService.get(session.getId()); // don't need it, but we do want to blow out with an error if the user's session doesn't exist
setCommonViewComponents(model);

auditService.doAudit(session.getId(), AuditLevel.INFO, "viewed resources: symptoms-911");
auditService.doAudit(session.getId(), AuditSeverity.INFO, "viewed resources: symptoms-911");

return "symptoms";
}
Expand All @@ -50,7 +50,7 @@ public String sideEffects(HttpSession session, Model model) {
userWorkspaceService.get(session.getId()); // don't need it, but we do want to blow out with an error if the user's session doesn't exist
setCommonViewComponents(model);

auditService.doAudit(session.getId(), AuditLevel.INFO, "viewed resources: side-effects");
auditService.doAudit(session.getId(), AuditSeverity.INFO, "viewed resources: side-effects");

return "side-effects";
}
Expand All @@ -64,7 +64,7 @@ public String welcomeVideo(HttpSession session, Model model) {
WELCOME_VIDEO_ID_CONTROL;
model.addAttribute("videoId", videoId);

auditService.doAudit(session.getId(), AuditLevel.INFO, "viewed resources: welcome-video");
auditService.doAudit(session.getId(), AuditSeverity.INFO, "viewed resources: welcome-video");

return "embedded-video";
}
Expand Down Expand Up @@ -96,7 +96,7 @@ public String risksOfHypertensionStudyResults(HttpSession session, Model model)
setCommonViewComponents(model);
model.addAttribute("pdfUrl", "/resources/pdf/Risks_of_Hypertension_Study_Results.pdf");

auditService.doAudit(session.getId(), AuditLevel.INFO, "viewed resources: risks-of-hypertension-study-results");
auditService.doAudit(session.getId(), AuditSeverity.INFO, "viewed resources: risks-of-hypertension-study-results");

return "embedded-pdf";
}
Expand All @@ -107,7 +107,7 @@ public String coachWrittenInstructions(HttpSession session, Model model) {
setCommonViewComponents(model);
model.addAttribute("pdfUrl", "/resources/pdf/COACH_Written_Instructions.pdf");

auditService.doAudit(session.getId(), AuditLevel.INFO, "viewed resources: coach-written-instructions");
auditService.doAudit(session.getId(), AuditSeverity.INFO, "viewed resources: coach-written-instructions");

return "embedded-pdf";
}
Expand All @@ -118,7 +118,7 @@ public String omronInstructions(HttpSession session, Model model) {
setCommonViewComponents(model);
model.addAttribute("pdfUrl", "/resources/pdf/OMRON_Instructions.pdf");

auditService.doAudit(session.getId(), AuditLevel.INFO, "viewed resources: omron-instructions");
auditService.doAudit(session.getId(), AuditSeverity.INFO, "viewed resources: omron-instructions");

return "embedded-pdf";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import edu.ohsu.cmp.coach.exception.ConfigurationException;
import edu.ohsu.cmp.coach.exception.REDCapException;
import edu.ohsu.cmp.coach.model.Audience;
import edu.ohsu.cmp.coach.model.AuditLevel;
import edu.ohsu.cmp.coach.model.AuditSeverity;
import edu.ohsu.cmp.coach.model.RedcapDataAccessGroup;
import edu.ohsu.cmp.coach.model.fhir.FHIRCredentials;
import edu.ohsu.cmp.coach.service.PatientService;
Expand Down Expand Up @@ -218,14 +218,14 @@ public String patientNotActive(HttpSession session, Model model) {

@GetMapping("logout")
public String logout(HttpSession session) {
auditService.doAudit(session.getId(), AuditLevel.INFO, "logged out"); // must occur before expire action
auditService.doAudit(session.getId(), AuditSeverity.INFO, "logged out"); // must occur before expire action
sessionService.expireAll(session.getId());
return "logout";
}

@GetMapping("inactivity-logout")
public String inactivityLogout(HttpSession session) {
auditService.doAudit(session.getId(), AuditLevel.INFO, "logged out due to inactivity"); // must occur before expire action
auditService.doAudit(session.getId(), AuditSeverity.INFO, "logged out due to inactivity"); // must occur before expire action
sessionService.expireAll(session.getId());
return "inactivity-logout";
}
Expand Down Expand Up @@ -259,14 +259,14 @@ public ResponseEntity<?> clearSupplementalData(HttpSession session) {
logger.info("clearing supplemental data for session=" + session.getId());
workspace.clearSupplementalData();

auditService.doAudit(session.getId(), AuditLevel.INFO, "cleared supplemental data");
auditService.doAudit(session.getId(), AuditSeverity.INFO, "cleared supplemental data");

return ResponseEntity.ok("supplemental data cleared");

} else {
logger.warn("attempted to clear supplemental data for session=" + session.getId() + ", but this action is not permitted.");

auditService.doAudit(session.getId(), AuditLevel.WARN, "unauthorized attempt to clear supplemental data");
auditService.doAudit(session.getId(), AuditSeverity.WARN, "unauthorized attempt to clear supplemental data");

return ResponseEntity.badRequest().build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public String view(HttpSession session, Model model) throws DataException {
"inputmask/dist/bindings/inputmask.binding.js"
});

auditService.doAudit(session.getId(), AuditLevel.INFO, "visited vitals page");
auditService.doAudit(session.getId(), AuditSeverity.INFO, "visited vitals page");

return "vitals";
}
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/edu/ohsu/cmp/coach/entity/Audit.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package edu.ohsu.cmp.coach.entity;

import edu.ohsu.cmp.coach.model.AuditLevel;
import edu.ohsu.cmp.coach.model.AuditSeverity;

import javax.persistence.*;
import java.util.Date;
Expand All @@ -15,7 +15,7 @@ public class Audit {
private Long patId;

@Enumerated(EnumType.STRING)
private AuditLevel level;
private AuditSeverity severity;

private String event;

Expand All @@ -26,13 +26,13 @@ public class Audit {
protected Audit() {
}

public Audit(Long patId, AuditLevel level, String event) {
this(patId, level, event, null);
public Audit(Long patId, AuditSeverity severity, String event) {
this(patId, severity, event, null);
}

public Audit(Long patId, AuditLevel level, String event, String details) {
public Audit(Long patId, AuditSeverity severity, String event, String details) {
this.patId = patId;
this.level = level;
this.severity = severity;
this.event = event;
this.details = details;
this.created = new Date();
Expand All @@ -43,7 +43,7 @@ public String toString() {
return "Audit{" +
"id=" + id +
", patId=" + patId +
", level=" + level +
", severity=" + severity +
", event='" + event + '\'' +
", details='" + details + '\'' +
", created=" + created +
Expand All @@ -66,12 +66,12 @@ public void setPatId(Long patId) {
this.patId = patId;
}

public AuditLevel getLevel() {
return level;
public AuditSeverity getSeverity() {
return severity;
}

public void setLevel(AuditLevel level) {
this.level = level;
public void setSeverity(AuditSeverity severity) {
this.severity = severity;
}

public String getEvent() {
Expand Down
Loading

0 comments on commit 9191358

Please sign in to comment.