LT-61: Record actions that create, modify, delete, associate timepoints, remove associations and login
- Show Last Login Date popup after login successful (WIP)
This commit is contained in:
1 parent
e277c4b484
commit
83e067b701
12 files changed
+187
-52
No files matched your search
@@ -59,6 +59,10 @@ Template.associationModal.events({
|
||||
// Sort the study dates, so we can get a range for these values
|
||||
studyDates = studyDates.sort();
|
||||
|
||||
// HipaaEventType to log changes in collections
|
||||
var hipaaEventType;
|
||||
var hipaaEvent;
|
||||
|
||||
// Check if these studies are already associated with an existing Timepoint
|
||||
var existingTimepoint;
|
||||
if (timepointType === 'baseline') {
|
||||
@@ -91,6 +95,7 @@ Template.associationModal.events({
|
||||
}
|
||||
});
|
||||
timepointId = existingTimepoint.timepointId;
|
||||
hipaaEventType = 'modify';
|
||||
} else {
|
||||
// Create a new timepoint to represent the (baseline or follow-up) studies
|
||||
var timepoint = {
|
||||
@@ -105,8 +110,20 @@ Template.associationModal.events({
|
||||
// Insert this timepoint into the Timepoints Collection
|
||||
Timepoints.insert(timepoint);
|
||||
timepointId = timepoint.timepointId;
|
||||
hipaaEventType = 'create';
|
||||
}
|
||||
|
||||
// Log
|
||||
hipaaEvent = {
|
||||
eventType: hipaaEventType,
|
||||
userId: Meteor.userId(),
|
||||
userName: Meteor.user().profile.fullName,
|
||||
collectionName: "Timepoints",
|
||||
recordId: timepointId,
|
||||
patientId: relatedStudies[0].patientId,
|
||||
patientName: relatedStudies[0].patientName
|
||||
};
|
||||
|
||||
// Loop through these studies to associate them with the newly created timepoint
|
||||
relatedStudies.forEach(function(study) {
|
||||
// Check if a study already exists in the Studies collection
|
||||
@@ -121,6 +138,8 @@ Template.associationModal.events({
|
||||
timepointId: timepointId
|
||||
}
|
||||
});
|
||||
// Log modify
|
||||
hipaaEventType = 'modify';
|
||||
} else {
|
||||
// If no such study exists, update the entry with the new timepointId
|
||||
|
||||
@@ -130,7 +149,22 @@ Template.associationModal.events({
|
||||
// Attach the timepointId and insert it into the Studies Collection
|
||||
study.timepointId = timepointId;
|
||||
Studies.insert(study);
|
||||
|
||||
// Log create
|
||||
hipaaEventType = 'create';
|
||||
}
|
||||
|
||||
// Log
|
||||
hipaaEvent = {
|
||||
eventType: hipaaEventType,
|
||||
userId: Meteor.userId(),
|
||||
userName: Meteor.user().profile.fullName,
|
||||
collectionName: "Studies",
|
||||
recordId: study.studyInstanceUid,
|
||||
patientId: study.patientId,
|
||||
patientName: study.patientName
|
||||
};
|
||||
HipaaLogger.logEvent(hipaaEvent);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<template name="lastLoginModal">
|
||||
<div class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-body" style="padding: 0;">
|
||||
<div class="alert alert-info" style="margin: 0 auto;">
|
||||
<a href="#" class="close" data-dismiss="modal">×</a>
|
||||
{{#if lastLoginDate}}
|
||||
<h5>You last logged in on <strong>{{lastLoginDate}}</strong></h5>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,9 @@
|
||||
Template.lastLoginModal.helpers({
|
||||
lastLoginDate: function() {
|
||||
var userLoginDate = ReactiveMethod.call('getPriorLoginDate');
|
||||
if (userLoginDate && userLoginDate.priorLoginDate) {
|
||||
return moment(userLoginDate.priorLoginDate).format("MMMM Do YYYY, HH:mm:ss A");
|
||||
}
|
||||
return;
|
||||
}
|
||||
});
|
||||
+51
-37
@@ -1,42 +1,5 @@
|
||||
Session.set('defaultSignInMessage', 'Tumor tracking in your browser.');
|
||||
|
||||
Template.lesionTrackerLayout.helpers({
|
||||
fullName: function() {
|
||||
return Meteor.user().profile.fullName;
|
||||
},
|
||||
|
||||
showWorklistMenu: function() {
|
||||
return Template.instance().showWorklistMenu.get();
|
||||
},
|
||||
|
||||
currentUser: function() {
|
||||
var verifyEmail = Meteor.settings && Meteor.settings.public && Meteor.settings.public.verifyEmail || false;
|
||||
|
||||
if (!Meteor.user() || !Meteor.userId()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!verifyEmail) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Meteor.user().emails[0].verified) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
Template.lesionTrackerLayout.onCreated(function() {
|
||||
// showViewer to go to viewer from audit
|
||||
this.showWorklistMenu = new ReactiveVar(true);
|
||||
// Get url and check worklist
|
||||
var currentPath = Router.current().route.path(this);
|
||||
if (currentPath === '/' || currentPath === '/worklist') {
|
||||
this.showWorklistMenu.set(false);
|
||||
}
|
||||
|
||||
// Show countdown dialog
|
||||
var handle;
|
||||
$(document).on('TriggerOpenTimeoutCountdownDialog', function(e, leftTime) {
|
||||
@@ -68,3 +31,54 @@ Template.lesionTrackerLayout.onCreated(function() {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Template.lesionTrackerLayout.onRendered(function() {
|
||||
var oldUserId = undefined;
|
||||
var userName;
|
||||
var lastLoginModalInterval;
|
||||
|
||||
Tracker.autorun(function() {
|
||||
// Hook login/logout
|
||||
var newUserId = Meteor.userId();
|
||||
if (oldUserId === null && newUserId) {
|
||||
Session.set('showLastLoginModal', true);
|
||||
userName = Meteor.user().profile.fullName;
|
||||
// Log
|
||||
HipaaLogger.logEvent({
|
||||
eventType: 'init',
|
||||
userId: Meteor.userId(),
|
||||
userName: userName
|
||||
});
|
||||
} else if (newUserId === null && oldUserId) {
|
||||
// Set showLastLoginModal as null
|
||||
Session.set('showLastLoginModal', null);
|
||||
// Destroy interval for last login modal
|
||||
Meteor.clearInterval(lastLoginModalInterval);
|
||||
console.log('The user logged out');
|
||||
|
||||
// Log
|
||||
// TODO: eventype is not defined for logout in hipaa-audit-log
|
||||
/*HipaaLogger.logEvent({
|
||||
eventType: 'logout',
|
||||
userId: oldUserId,
|
||||
userName: userName
|
||||
});*/
|
||||
|
||||
// Remove the user from Reviewers
|
||||
Meteor.call('removeUserFromReviewers', oldUserId);
|
||||
}
|
||||
oldUserId = Meteor.userId();
|
||||
|
||||
// Trigger last login date popup
|
||||
if (Session.get('showLastLoginModal')) {
|
||||
Modal.show('lastLoginModal');
|
||||
lastLoginModalInterval = Meteor.setInterval( function() {
|
||||
Modal.hide('lastLoginModal');
|
||||
Session.set("showLastLoginModal", null);
|
||||
}, 3000);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
+46
-8
@@ -37,7 +37,20 @@ function removeTimepointAssociations() {
|
||||
Meteor.call('removeAssociatedStudy', study._id, function(error) {
|
||||
if (error) {
|
||||
log.warn(error);
|
||||
return;
|
||||
}
|
||||
|
||||
// Log
|
||||
var hipaaEvent = {
|
||||
eventType: 'delete',
|
||||
userId: Meteor.userId(),
|
||||
userName: Meteor.user().profile.fullName,
|
||||
collectionName: "Studies",
|
||||
recordId: study.studyInstanceUid,
|
||||
patientId: study.patientId,
|
||||
patientName: study.patientName
|
||||
};
|
||||
HipaaLogger.logEvent(hipaaEvent);
|
||||
});
|
||||
|
||||
// Find the Timepoint that was previously referenced
|
||||
@@ -64,13 +77,38 @@ function removeTimepointAssociations() {
|
||||
studyInstanceUids: timepoint.studyInstanceUids
|
||||
}
|
||||
});
|
||||
|
||||
// Log
|
||||
var hipaaEvent = {
|
||||
eventType: 'modify',
|
||||
userId: Meteor.userId(),
|
||||
userName: Meteor.user().profile.fullName,
|
||||
collectionName: "Timepoints",
|
||||
recordId: study.timepointId,
|
||||
patientId: study.patientId,
|
||||
patientName: study.patientName
|
||||
};
|
||||
HipaaLogger.logEvent(hipaaEvent);
|
||||
} else {
|
||||
// If no more Studies are associated with this Timepoint, we should remove it
|
||||
// from the Timepoints Collection via a server call
|
||||
Meteor.call('removeTimepoint', timepoint._id, function(error) {
|
||||
if (error) {
|
||||
log.warn(error);
|
||||
return;
|
||||
}
|
||||
|
||||
// Log
|
||||
var hipaaEvent = {
|
||||
eventType: 'delete',
|
||||
userId: Meteor.userId(),
|
||||
userName: Meteor.user().profile.fullName,
|
||||
collectionName: "Timepoints",
|
||||
recordId: study.timepointId,
|
||||
patientId: study.patientId,
|
||||
patientName: study.patientName
|
||||
};
|
||||
HipaaLogger.logEvent(hipaaEvent);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -81,10 +119,10 @@ function removeTimepointAssociations() {
|
||||
*/
|
||||
function exportSelectedStudies() {
|
||||
var selectedStudies = WorklistSelectedStudies.find({}, {
|
||||
sort: {
|
||||
studyDate: 1
|
||||
}
|
||||
}).fetch();
|
||||
sort: {
|
||||
studyDate: 1
|
||||
}
|
||||
}).fetch();
|
||||
|
||||
if (!selectedStudies) {
|
||||
return;
|
||||
@@ -98,10 +136,10 @@ function exportSelectedStudies() {
|
||||
*/
|
||||
function viewStudies() {
|
||||
var selectedStudies = WorklistSelectedStudies.find({}, {
|
||||
sort: {
|
||||
studyDate: 1
|
||||
}
|
||||
}).fetch();
|
||||
sort: {
|
||||
studyDate: 1
|
||||
}
|
||||
}).fetch();
|
||||
|
||||
if (!selectedStudies) {
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user