PWV-1: Refactoring ohif:studylist package
This commit is contained in:
1 parent
984ef94403
commit
4d79bf84a8
79 files changed
+450
-551
No files matched your search
+25
-35
@@ -1,3 +1,7 @@
|
||||
import { Template } from 'meteor/templating';
|
||||
import { moment } from 'meteor/momentjs:moment';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
/**
|
||||
* Finds related studies within defined time window of =/- 14 days of selected studies
|
||||
* @param selectedStudies
|
||||
@@ -14,13 +18,13 @@ function getDateRange(selectedStudies, range) {
|
||||
return;
|
||||
}
|
||||
|
||||
var earliestStudy = selectedStudies[0];
|
||||
var latestStudy = selectedStudies[selectedStudies.length - 1];
|
||||
const earliestStudy = selectedStudies[0];
|
||||
const latestStudy = selectedStudies[selectedStudies.length - 1];
|
||||
|
||||
var earliestDate = moment(earliestStudy.studyDate, 'YYYYMMDD');
|
||||
const earliestDate = moment(earliestStudy.studyDate, 'YYYYMMDD');
|
||||
earliestDate.subtract(range);
|
||||
|
||||
var latestDate = moment(latestStudy.studyDate, 'YYYYMMDD');
|
||||
const latestDate = moment(latestStudy.studyDate, 'YYYYMMDD');
|
||||
latestDate.add(range);
|
||||
|
||||
return {
|
||||
@@ -43,12 +47,12 @@ function autoSelectStudies(selectedStudies) {
|
||||
return;
|
||||
}
|
||||
|
||||
var range = getDateRange(selectedStudies);
|
||||
const range = getDateRange(selectedStudies);
|
||||
|
||||
// Fetch autoselected studies based on the date range
|
||||
// Note that we used MongoDB's fetch here so we have a mutable array,
|
||||
// rather than a Cursor
|
||||
var autoselected = StudyListStudies.find({
|
||||
const autoselected = StudyListStudies.find({
|
||||
studyDate: {
|
||||
$gte: range.earliestDate.format('YYYYMMDD'),
|
||||
$lte: range.latestDate.format('YYYYMMDD')
|
||||
@@ -60,12 +64,10 @@ function autoSelectStudies(selectedStudies) {
|
||||
}).fetch();
|
||||
|
||||
// Make an array of studyInstanceUids in selectedStudies
|
||||
var studyInstanceUids = selectedStudies.map(function(selectedStudy) {
|
||||
return selectedStudy.studyInstanceUid;
|
||||
});
|
||||
const studyInstanceUids = selectedStudies.map(selectedStudy => selectedStudy.studyInstanceUid);
|
||||
|
||||
autoselected.forEach(function(study) {
|
||||
var exists = studyInstanceUids.indexOf(study.studyInstanceUid);
|
||||
autoselected.forEach(study => {
|
||||
const exists = studyInstanceUids.indexOf(study.studyInstanceUid);
|
||||
if (exists > -1) {
|
||||
study.autoselected = false;
|
||||
return;
|
||||
@@ -84,12 +86,8 @@ Template.studyAssociationTable.helpers({
|
||||
*
|
||||
* @returns {Array.<T>}
|
||||
*/
|
||||
relevantStudies: function() {
|
||||
var selectedStudies = StudyListSelectedStudies.find({}, {
|
||||
sort: {
|
||||
studyDate: 1
|
||||
}
|
||||
}).fetch() || [];
|
||||
relevantStudies() {
|
||||
const selectedStudies = OHIF.studylist.getSelectedStudies();
|
||||
|
||||
return autoSelectStudies(selectedStudies);
|
||||
},
|
||||
@@ -98,7 +96,7 @@ Template.studyAssociationTable.helpers({
|
||||
*
|
||||
* @returns {Array.<T>}
|
||||
*/
|
||||
timepointOptions: function() {
|
||||
timepointOptions() {
|
||||
return [{
|
||||
value: 'baseline',
|
||||
name: 'Baseline',
|
||||
@@ -109,26 +107,18 @@ Template.studyAssociationTable.helpers({
|
||||
checked: false
|
||||
}];
|
||||
},
|
||||
earliestDate: function() {
|
||||
var selectedStudies = StudyListSelectedStudies.find({}, {
|
||||
sort: {
|
||||
studyDate: 1
|
||||
}
|
||||
}).fetch();
|
||||
earliestDate() {
|
||||
const selectedStudies = OHIF.studylist.getSelectedStudies();
|
||||
|
||||
var range = getDateRange(selectedStudies);
|
||||
const range = getDateRange(selectedStudies);
|
||||
if (range) {
|
||||
return range.earliestDate;
|
||||
}
|
||||
},
|
||||
latestDate: function() {
|
||||
var selectedStudies = StudyListSelectedStudies.find({}, {
|
||||
sort: {
|
||||
studyDate: 1
|
||||
}
|
||||
}).fetch();
|
||||
latestDate() {
|
||||
const selectedStudies = OHIF.studylist.getSelectedStudies();
|
||||
|
||||
var range = getDateRange(selectedStudies);
|
||||
const range = getDateRange(selectedStudies);
|
||||
if (range) {
|
||||
return range.latestDate;
|
||||
}
|
||||
@@ -136,9 +126,9 @@ Template.studyAssociationTable.helpers({
|
||||
});
|
||||
|
||||
Template.studyAssociationTable.events({
|
||||
'change input.includeStudy': function(e) {
|
||||
var checkbox = e.currentTarget;
|
||||
var studyDataCells = $(checkbox).parents('tr').find('td.studyDataCell');
|
||||
'change input.includeStudy'(event, instance) {
|
||||
const checkbox = event.currentTarget;
|
||||
const studyDataCells = $(checkbox).parents('tr').find('td.studyDataCell');
|
||||
if (checkbox.checked === true) {
|
||||
studyDataCells.removeClass('disabled');
|
||||
studyDataCells.find('input').attr('disabled', false);
|
||||
|
||||
+18
-28
@@ -1,30 +1,20 @@
|
||||
<template name="longitudinalStudyListContextMenu">
|
||||
{{#if uiSettings.studyListFunctionsEnabled}}
|
||||
<div id="studyContextMenu" class="studyContextMenu noselect"
|
||||
oncontextmenu='return false;'
|
||||
unselectable='on'
|
||||
onselectstart='return false;'>
|
||||
<ul>
|
||||
<li>
|
||||
<a id="viewStudies" type="button" title="View Studies">View</a>
|
||||
<hr/>
|
||||
<!-- {{#link action='associate'}}Associate{{/link}} -->
|
||||
<a id="launchStudyAssociation" title="Launch Study Association">Associate</a>
|
||||
<a id="launchRemoveAssociation" type="button"
|
||||
data-toggle="modal"
|
||||
data-target="#confirmRemoveTimepointAssociation"
|
||||
title="Remove Timepoint Association">Remove Association</a>
|
||||
<hr/>
|
||||
<a id="viewSeriesDetails" type="button"
|
||||
title="View Series Details">View Series Details</a>
|
||||
<a class="disabled">Anonymize</a>
|
||||
<a class="disabled">Send</a>
|
||||
<hr/>
|
||||
<a id="exportSelectedStudies"
|
||||
title="Export Selected Studies">Export</a>
|
||||
<a class="disabled">Delete</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#dropdownForm}}
|
||||
<li><a id="viewStudies" type="button" title="View Studies">View</a></li>
|
||||
<li class="divider" role="separator"></li>
|
||||
<!-- {{#link action='associate'}}Associate{{/link}} -->
|
||||
<li><a id="launchStudyAssociation" title="Launch Study Association">Associate</a></li>
|
||||
<li><a id="launchRemoveAssociation" type="button" data-toggle="modal"
|
||||
data-target="#confirmRemoveTimepointAssociation" title="Remove Timepoint Association"
|
||||
>Remove Association</a></li>
|
||||
<li class="divider" role="separator"></li>
|
||||
<li><a id="viewSeriesDetails" type="button"
|
||||
title="View Series Details"
|
||||
>View Series Details</a></li>
|
||||
<li class="disabled"><a class="disabled">Anonymize</a></li>
|
||||
<li class="disabled"><a class="disabled">Send</a></li>
|
||||
<li class="divider" role="separator"></li>
|
||||
<li><a id="exportSelectedStudies" title="Export Selected Studies">Export</a></li>
|
||||
<li class="disabled"><a class="disabled">Delete</a></li>
|
||||
{{/dropdownForm}}
|
||||
</template>
|
||||
+26
-38
@@ -1,3 +1,6 @@
|
||||
import { Template } from 'meteor/templating';
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { Random } from 'meteor/random';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
// Use Aldeed's meteor-template-extension package to replace the
|
||||
@@ -7,21 +10,17 @@ const defaultTemplate = 'studyContextMenu';
|
||||
|
||||
Template.longitudinalStudyListContextMenu.replaces(defaultTemplate);
|
||||
|
||||
StudyList.functions['launchStudyAssociation'] = () => OHIF.ui.showFormDialog('dialogStudyAssociation');
|
||||
StudyList.functions['removeTimepointAssociations'] = removeTimepointAssociations;
|
||||
StudyList.functions['exportSelectedStudies'] = exportSelectedStudies;
|
||||
StudyList.functions['viewStudies'] = viewStudies;
|
||||
StudyList.functions.launchStudyAssociation = () => OHIF.ui.showFormDialog('dialogStudyAssociation');
|
||||
StudyList.functions.removeTimepointAssociations = removeTimepointAssociations;
|
||||
StudyList.functions.exportSelectedStudies = exportSelectedStudies;
|
||||
StudyList.functions.viewStudies = viewStudies;
|
||||
|
||||
/**
|
||||
* Removes all present study / timepoint associations from the Clinical Trial
|
||||
*/
|
||||
function removeTimepointAssociations() {
|
||||
// Get a Cursor pointing to the selected Studies from the StudyList
|
||||
const selectedStudies = StudyListSelectedStudies.find({}, {
|
||||
sort: {
|
||||
studyDate: 1
|
||||
}
|
||||
});
|
||||
const selectedStudies = OHIF.studylist.getSelectedStudies();
|
||||
|
||||
// Loop through the Cursor of Selected Studies
|
||||
selectedStudies.forEach(function(selectedStudy) {
|
||||
@@ -31,14 +30,14 @@ function removeTimepointAssociations() {
|
||||
return;
|
||||
}
|
||||
|
||||
let timepoint = timepointApi.study(data.study.studyInstanceUid)[0];
|
||||
let timepoint = timepointApi.study(selectedStudy.studyInstanceUid)[0];
|
||||
if (!timepoint) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the index of the current studyInstanceUid in the array
|
||||
// of reference studyInstanceUids
|
||||
var index = timepoint.studyInstanceUids.indexOf(study.studyInstanceUid);
|
||||
const index = timepoint.studyInstanceUids.indexOf(selectedStudy.studyInstanceUid);
|
||||
if (index < 0) {
|
||||
return;
|
||||
}
|
||||
@@ -57,14 +56,14 @@ function removeTimepointAssociations() {
|
||||
});
|
||||
|
||||
// Log
|
||||
var hipaaEvent = {
|
||||
const hipaaEvent = {
|
||||
eventType: 'modify',
|
||||
userId: Meteor.userId(),
|
||||
userName: Meteor.user().profile.fullName,
|
||||
collectionName: "Timepoints",
|
||||
recordId: study.timepointId,
|
||||
patientId: study.patientId,
|
||||
patientName: study.patientName
|
||||
collectionName: 'Timepoints',
|
||||
recordId: selectedStudy.timepointId,
|
||||
patientId: selectedStudy.patientId,
|
||||
patientName: selectedStudy.patientName
|
||||
};
|
||||
HipaaLogger.logEvent(hipaaEvent);
|
||||
} else {
|
||||
@@ -77,14 +76,14 @@ function removeTimepointAssociations() {
|
||||
}
|
||||
|
||||
// Log
|
||||
var hipaaEvent = {
|
||||
const hipaaEvent = {
|
||||
eventType: 'delete',
|
||||
userId: Meteor.userId(),
|
||||
userName: Meteor.user().profile.fullName,
|
||||
collectionName: "Timepoints",
|
||||
recordId: study.timepointId,
|
||||
patientId: study.patientId,
|
||||
patientName: study.patientName
|
||||
collectionName: 'Timepoints',
|
||||
recordId: selectedStudy.timepointId,
|
||||
patientId: selectedStudy.patientId,
|
||||
patientName: selectedStudy.patientName
|
||||
};
|
||||
HipaaLogger.logEvent(hipaaEvent);
|
||||
});
|
||||
@@ -94,43 +93,32 @@ function removeTimepointAssociations() {
|
||||
|
||||
// ---------- TODO: Remove these duplicated functions below -------------
|
||||
|
||||
|
||||
/**
|
||||
* Exports all selected studies on the studylist
|
||||
*/
|
||||
function exportSelectedStudies() {
|
||||
const selectedStudies = StudyListSelectedStudies.find({}, {
|
||||
sort: {
|
||||
studyDate: 1
|
||||
}
|
||||
}).fetch();
|
||||
const selectedStudies = OHIF.studylist.getSelectedStudies();
|
||||
|
||||
if (!selectedStudies || !selectedStudies.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
exportStudies(selectedStudies);
|
||||
OHIF.studylist.exportStudies(selectedStudies);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads multiple unassociated studies in the Viewer
|
||||
*/
|
||||
function viewStudies() {
|
||||
console.log('viewStudies');
|
||||
const selectedStudies = StudyListSelectedStudies.find({}, {
|
||||
sort: {
|
||||
studyDate: 1
|
||||
}
|
||||
}).fetch();
|
||||
OHIF.log.info('viewStudies');
|
||||
const selectedStudies = OHIF.studylist.getSelectedStudies();
|
||||
|
||||
if (!selectedStudies || !selectedStudies.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
var title = selectedStudies[0].patientName;
|
||||
var studyInstanceUids = selectedStudies.map(function(study) {
|
||||
return study.studyInstanceUid;
|
||||
});
|
||||
const title = selectedStudies[0].patientName;
|
||||
const studyInstanceUids = selectedStudies.map(study => study.studyInstanceUid);
|
||||
|
||||
// Generate a unique ID to represent this tab
|
||||
// We can't just use the Mongo entry ID because
|
||||
|
||||
Reference in new issue
Block a user