Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#185 - add readingDate to BP and pulse logs and audit trail #186

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/edu/ohsu/cmp/coach/model/QuantityModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ public void setUnit(String unit) {

@Override
public String toString() {
return value + unit;
return value + " " + unit;
}
}
21 changes: 13 additions & 8 deletions src/main/java/edu/ohsu/cmp/coach/service/BloodPressureService.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,18 @@ public BloodPressureModel create(String sessionId, BloodPressureModel bpm) throw
workspace.getRemoteBloodPressures().add(bpm2);
}

auditService.doAudit(sessionId, AuditLevel.INFO, "wrote BP remotely", bpm.getSystolic() + "/" + bpm.getDiastolic());
auditService.doAudit(sessionId, AuditLevel.INFO, "wrote BP remotely", bpm.getSystolic() + "/" +
bpm.getDiastolic() + " at " + bpm.getReadingDateString());

} catch (Exception e) {
// remote errors are tolerable, since we will always store locally too
logger.warn("caught " + e.getClass().getSimpleName() + " attempting to create BP remotely - " + e.getMessage(), e);
logger.warn("caught " + e.getClass().getSimpleName() + " attempting to create BP remotely - " +
"BP=" + bpm.getSystolic() + "/" + bpm.getDiastolic() + " at " + bpm.getReadingDateString() +
", message=" + e.getMessage(), e);

auditService.doAudit(sessionId, AuditLevel.WARN, "failed to write BP remotely",
"BP=" + bpm.getSystolic() + "/" + bpm.getDiastolic() + ", message=" + e.getMessage());
auditService.doAudit(sessionId, AuditLevel.WARN, "failed to write BP remotely", "BP=" +
bpm.getSystolic() + "/" + bpm.getDiastolic() + " at " + bpm.getReadingDateString() +
", message=" + e.getMessage());
}
}

Expand All @@ -153,14 +157,15 @@ public BloodPressureModel create(String sessionId, BloodPressureModel bpm) throw
}

auditService.doAudit(sessionId, AuditLevel.INFO, "created BP", "id=" + response.getId() +
", BP=" + bpm.getSystolic() + "/" + bpm.getDiastolic());
", BP=" + bpm.getSystolic() + "/" + bpm.getDiastolic() + " at " + bpm.getReadingDateString());

} catch (DataException de) {
// okay if it's failing to write locally, that's a problem.
logger.error("caught " + de.getClass().getName() + " attempting to create BloodPressureModel " + bpm);
logger.error("caught " + de.getClass().getName() + " attempting to create BloodPressureModel " + bpm, de);

auditService.doAudit(sessionId, AuditLevel.ERROR, "failed to create BP",
"BP=" + bpm.getSystolic() + "/" + bpm.getDiastolic() + ", message=" + de.getMessage());
auditService.doAudit(sessionId, AuditLevel.ERROR, "failed to create BP", "BP=" +
bpm.getSystolic() + "/" + bpm.getDiastolic() + " at " + bpm.getReadingDateString() +
", message=" + de.getMessage());
}

return bpm2;
Expand Down
18 changes: 11 additions & 7 deletions src/main/java/edu/ohsu/cmp/coach/service/PulseService.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,18 @@ public PulseModel create(String sessionId, PulseModel pm) throws DataException,
workspace.getRemotePulses().add(pm2);
}

auditService.doAudit(sessionId, AuditLevel.INFO, "wrote pulse remotely", String.valueOf(pm.getPulse()));
auditService.doAudit(sessionId, AuditLevel.INFO, "wrote pulse remotely", pm.getPulse() +
" at " + pm.getReadingDateString());

} catch (Exception e) {
// remote errors are tolerable, since we will always store locally too
logger.warn("caught " + e.getClass().getSimpleName() + " attempting to create Pulse remotely - " + e.getMessage(), e);
logger.warn("caught " + e.getClass().getSimpleName() + " attempting to create Pulse remotely - " +
"pulse=" + pm.getPulse() + " at " + pm.getReadingDateString() +
", message=" + e.getMessage(), e);

auditService.doAudit(sessionId, AuditLevel.WARN, "failed to write pulse remotely",
"pulse=" + pm.getPulse() + ", message=" + e.getMessage());
"pulse=" + pm.getPulse() + " at " + pm.getReadingDateString() +
", message=" + e.getMessage());
}
}

Expand All @@ -142,14 +146,14 @@ public PulseModel create(String sessionId, PulseModel pm) throws DataException,
}

auditService.doAudit(sessionId, AuditLevel.INFO, "created pulse", "id=" + response.getId() +
", pulse=" + pm.getPulse());
", pulse=" + pm.getPulse() + " at " + pm.getReadingDateString());

} catch (DataException de) {
// okay if it's failing to write locally, that's a problem.
logger.error("caught " + de.getClass().getName() + " attempting to create PulseModel " + pm);
logger.error("caught " + de.getClass().getName() + " attempting to create PulseModel " + pm, de);

auditService.doAudit(sessionId, AuditLevel.ERROR, "failed to create pulse",
"pulse=" + pm.getPulse() + ", message=" + de.getMessage());
auditService.doAudit(sessionId, AuditLevel.ERROR, "failed to create pulse", "pulse=" +
pm.getPulse() + " at " + pm.getReadingDateString() + ", message=" + de.getMessage());
}

return pm2;
Expand Down
Loading