LT-291: Re-implementing the Non-Target tool behavior
This commit is contained in:
1 parent
e348ff1d4d
commit
5d8a99dc5f
12 files changed
+195
-56
No files matched your search
@@ -0,0 +1,9 @@
|
||||
<template name="dialogNonTargetMeasurement">
|
||||
{{#dialogForm (extend this dialogClass='modal-sm' schema=(choose this.schema instance.schema))}}
|
||||
{{>inputHidden key='measurementNumber'}}
|
||||
{{>inputSelect labelClass='form-group' key='location' hideSearch=true
|
||||
options=(clone placeholder='Choose a lesion location')}}
|
||||
{{>inputSelect labelClass='form-group' key='response' hideSearch=true
|
||||
options=(clone placeholder='Choose a lesion location response')}}
|
||||
{{/dialogForm}}
|
||||
</template>
|
||||
@@ -0,0 +1,69 @@
|
||||
import { Template } from 'meteor/templating';
|
||||
import { Blaze } from 'meteor/blaze';
|
||||
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
|
||||
import { _ } from 'meteor/underscore';
|
||||
import { FieldLesionLocation, FieldLesionLocationResponse } from 'meteor/ohif:lesiontracker/both/schema/fields';
|
||||
|
||||
Template.dialogNonTargetMeasurement.onCreated(() => {
|
||||
const instance = Template.instance();
|
||||
|
||||
instance.schema = new SimpleSchema({
|
||||
location: FieldLesionLocation,
|
||||
response: FieldLesionLocationResponse,
|
||||
measurementNumber: {
|
||||
type: Number
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Template.dialogNonTargetMeasurement.onRendered(() => {
|
||||
const instance = Template.instance();
|
||||
|
||||
const form = instance.$('form').data('component');
|
||||
|
||||
const viewerMain = $(instance.data.eventData.element).closest('.viewerMain')[0];
|
||||
const viewerData = Blaze.getData(viewerMain);
|
||||
console.warn('>>>>dialogData/viewerData', instance.data, viewerData);
|
||||
|
||||
const measurementApi = viewerData.measurementApi;
|
||||
|
||||
const measurementTypeId = 'nonTargets';
|
||||
const measurementData = instance.data.measurementData;
|
||||
const collection = measurementApi[measurementTypeId];
|
||||
|
||||
// Get the current inserted measurement from the collection
|
||||
const currentMeasurement = collection.findOne({
|
||||
_id: measurementData._id
|
||||
});
|
||||
|
||||
// Synchronize the measurement number with the one inserted in the collection
|
||||
measurementData.measurementNumber = currentMeasurement.measurementNumber;
|
||||
|
||||
// Delete the measurement if dialog is closed
|
||||
instance.data.promise.catch(() => {
|
||||
viewerData.measurementApi.deleteMeasurements('nonTargets', {
|
||||
_id: measurementData._id
|
||||
});
|
||||
|
||||
// Repaint the images on all viewports without the removed measurements
|
||||
_.each($('.imageViewerViewport'), element => cornerstone.updateImage(element));
|
||||
});
|
||||
|
||||
// Update the location and response after confirming the dialog data
|
||||
instance.data.promise.then(formData => {
|
||||
collection.update({
|
||||
_id: measurementData._id,
|
||||
}, {
|
||||
$set: {
|
||||
location: formData.location,
|
||||
response: formData.response
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Inject the measurement number in form data to enable the tool from getting the value
|
||||
form.value({
|
||||
measurementNumber: currentMeasurement.measurementNumber
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,3 +1,6 @@
|
||||
import './dialog/nonTargetMeasurement.html';
|
||||
import './dialog/nonTargetMeasurement.js';
|
||||
|
||||
import './optionsModal/optionsModal.html';
|
||||
import './optionsModal/optionsModal.styl';
|
||||
import './optionsModal/optionsModal.js';
|
||||
|
||||
+4
-4
@@ -68,11 +68,10 @@ function selectNonTargetResponse(responseCode) {
|
||||
// If there already exists a measurement with this specific measurement number,
|
||||
// related to the chosen location.
|
||||
function getMeasurementLocationCallback(measurementData, eventData) {
|
||||
return 'Test Location';
|
||||
Template.nonTargetMeasurementDialog.measurementData = measurementData;
|
||||
|
||||
// Get the non-target measurement location dialog
|
||||
var dialog = $('#nonTargetMeasurementLocationDialog');
|
||||
var dialog = $('#nonTargetMeasurementDialog');
|
||||
Template.nonTargetMeasurementDialog.dialog = dialog;
|
||||
|
||||
// Show the backdrop
|
||||
@@ -89,7 +88,7 @@ function getMeasurementLocationCallback(measurementData, eventData) {
|
||||
selectorLocation.find('option:first').prop('selected', 'selected');
|
||||
|
||||
// LT-112 "Non-target response shall default to non-measurable on baseline, present on follow-up"
|
||||
var timepoint = Timepoints.findOne({
|
||||
var timepoint = StudyList.timepointApi.timepoints.findOne({
|
||||
timepointId: measurementData.timepointId
|
||||
});
|
||||
|
||||
@@ -104,7 +103,7 @@ function getMeasurementLocationCallback(measurementData, eventData) {
|
||||
|
||||
// Find out if this measurement number is already added in the measurement manager for another timepoint
|
||||
// If it is, disable selector location
|
||||
var locationId = OHIF.measurements.MeasurementManager.getLocationIdIfMeasurementExists(measurementData);
|
||||
var locationId = OHIF.measurements.MeasurementManager.getLocationIdIfMeasurementExists(measurementData, StudyList.timepointApi.timepoints);
|
||||
if (locationId) {
|
||||
// Add an ID value to the tool data to link it to the Measurements collection
|
||||
measurementData.id = 'notready';
|
||||
@@ -156,6 +155,7 @@ function getMeasurementLocationCallback(measurementData, eventData) {
|
||||
dialogProperty.margin = 'auto';
|
||||
}
|
||||
|
||||
console.warn('>>>>SHOW DIALOG', dialog);
|
||||
dialog.css(dialogProperty);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user