PWV-1: Refactoring ohif:studylist package

This commit is contained in:
Bruno Alves de Faria authored and Erik Ziegler committed 2016-11-15 08:24:01 +01:00
1 parent 984ef94403
commit 4d79bf84a8
79 files changed
+450 -551

No files matched your search

@@ -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>
@@ -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