Fix a bug by sorting the studies by study date and time instead of only study date in prior function (to add prior indicator)
This commit is contained in:
parent
b0f9426015
commit
c511edd419
@ -135,6 +135,10 @@ function getImage(viewportIndex) {
|
||||
return enabledElement.image;
|
||||
}
|
||||
|
||||
function formatDateTime(date, time) {
|
||||
return `${date} ${time}`;
|
||||
}
|
||||
|
||||
Template.viewportOverlay.helpers({
|
||||
wwwc: function() {
|
||||
Session.get('CornerstoneImageRendered' + this.viewportIndex);
|
||||
@ -306,19 +310,18 @@ Template.viewportOverlay.helpers({
|
||||
}
|
||||
|
||||
// Make sure there are more than two studies loaded in the viewer
|
||||
//
|
||||
var viewportStudies = ViewerStudies.find();
|
||||
if (viewportStudies.count() < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Here we sort the collection in ascending order by study date, so
|
||||
// that we can obtain the oldest study as the first element of the array
|
||||
//
|
||||
// TODO= Find out if we should encode studyDate as a Date in the ViewerStudies Collection
|
||||
var viewportStudies = ViewerStudies.find({}, {
|
||||
sort: {
|
||||
studyDate: 1
|
||||
}
|
||||
var viewportStudiesArray = _.sortBy(viewportStudies.fetch(), function(study) {
|
||||
return formatDateTime(study.studyDate, study.studyTime);
|
||||
});
|
||||
if (viewportStudies.count() < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get study data
|
||||
var study = cornerstoneTools.metaData.get('study', this.imageId);
|
||||
@ -326,8 +329,8 @@ Template.viewportOverlay.helpers({
|
||||
return;
|
||||
}
|
||||
|
||||
var oldestStudy = viewportStudies.fetch()[0];
|
||||
if ((study.studyDate + " " + study.studyTime) <= (oldestStudy.studyDate + " " + oldestStudy.studyTime)) {
|
||||
var oldestStudy = viewportStudiesArray[0];
|
||||
if (formatDateTime(study.studyDate, study.studyTime) <= formatDateTime(oldestStudy.studyDate, oldestStudy.studyTime)) {
|
||||
return 'Prior';
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user