LT-92: Adding validation to RecistApi
This commit is contained in:
parent
d1e0695a4b
commit
5605133517
@ -101,8 +101,9 @@ Template.viewer.onCreated(() => {
|
|||||||
|
|
||||||
const timepointIds = timepoints.map(t => t.timepointId);
|
const timepointIds = timepoints.map(t => t.timepointId);
|
||||||
instance.data.measurementApi = new OHIF.measurements.MeasurementApi(instance.data.timepointApi);
|
instance.data.measurementApi = new OHIF.measurements.MeasurementApi(instance.data.timepointApi);
|
||||||
console.warn('>>>>REMOVE THE LINE BELOW');
|
console.warn('>>>>REMOVE THE LINES BELOW');
|
||||||
window.measurementApi = instance.data.measurementApi;
|
window.measurementApi = instance.data.measurementApi;
|
||||||
|
window.recistApi = new OHIF.measurements.RecistApi(window.measurementApi);
|
||||||
const measurementsPromise = instance.data.measurementApi.retrieveMeasurements(patientId, timepointIds);
|
const measurementsPromise = instance.data.measurementApi.retrieveMeasurements(patientId, timepointIds);
|
||||||
measurementsPromise.then(() => {
|
measurementsPromise.then(() => {
|
||||||
Session.set('MeasurementsReady', true);
|
Session.set('MeasurementsReady', true);
|
||||||
|
|||||||
@ -1,3 +1,2 @@
|
|||||||
import './measurements.js';
|
import './measurements.js';
|
||||||
import './recist.js';
|
|
||||||
import './timepoints.js';
|
import './timepoints.js';
|
||||||
|
|||||||
@ -326,6 +326,21 @@ class MeasurementApi {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getMeasurementById(measurementId) {
|
||||||
|
let foundGroup;
|
||||||
|
_.find(this.toolGroups, toolGroup => {
|
||||||
|
foundGroup = toolGroup.findOne({ toolItemId: measurementId });
|
||||||
|
return !!foundGroup;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Stop here if no group was found or if the record is a placeholder
|
||||||
|
if (!foundGroup || !foundGroup.toolId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.tools[foundGroup.toolId].findOne(measurementId);
|
||||||
|
}
|
||||||
|
|
||||||
fetch(toolGroupId, selector, options) {
|
fetch(toolGroupId, selector, options) {
|
||||||
if (!this.toolGroups[toolGroupId]) {
|
if (!this.toolGroups[toolGroupId]) {
|
||||||
throw 'MeasurementApi: No Collection with the id: ' + toolGroupId;
|
throw 'MeasurementApi: No Collection with the id: ' + toolGroupId;
|
||||||
@ -336,7 +351,7 @@ class MeasurementApi {
|
|||||||
const result = [];
|
const result = [];
|
||||||
const items = this.toolGroups[toolGroupId].find(selector, options).fetch();
|
const items = this.toolGroups[toolGroupId].find(selector, options).fetch();
|
||||||
items.forEach(item => {
|
items.forEach(item => {
|
||||||
if(item.toolId) {
|
if (item.toolId) {
|
||||||
result.push(this.tools[item.toolId].findOne(item.toolItemId));
|
result.push(this.tools[item.toolId].findOne(item.toolItemId));
|
||||||
} else {
|
} else {
|
||||||
result.push({ measurementNumber: item.measurementNumber });
|
result.push({ measurementNumber: item.measurementNumber });
|
||||||
|
|||||||
@ -1,22 +0,0 @@
|
|||||||
import { OHIF } from 'meteor/ohif:core';
|
|
||||||
|
|
||||||
class RecistApi {
|
|
||||||
|
|
||||||
constructor(measurementApi) {
|
|
||||||
if (measurementApi) {
|
|
||||||
this.measurementApi = measurementApi;
|
|
||||||
}
|
|
||||||
this.warnings = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
validate() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
getModalities() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
OHIF.measurements.RecistApi = RecistApi;
|
|
||||||
1
Packages/ohif-measurements/client/api/index.js
Normal file
1
Packages/ohif-measurements/client/api/index.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
import './recist';
|
||||||
64
Packages/ohif-measurements/client/api/recist.js
Normal file
64
Packages/ohif-measurements/client/api/recist.js
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
import { OHIF } from 'meteor/ohif:core';
|
||||||
|
import { _ } from 'meteor/underscore';
|
||||||
|
|
||||||
|
class RecistApi {
|
||||||
|
|
||||||
|
constructor(measurementApi) {
|
||||||
|
if (measurementApi) {
|
||||||
|
this.measurementApi = measurementApi;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.warnings = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
validate() {
|
||||||
|
const measurements = this.getMeasurements();
|
||||||
|
|
||||||
|
measurements.targets.forEach(measurement => {
|
||||||
|
const image = this.getImageById(measurement.studyInstanceUid, measurement.imageId);
|
||||||
|
console.warn('>>>>modality', image, image.modality);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getMeasurements() {
|
||||||
|
const targets = this.measurementApi.fetch('targets');
|
||||||
|
const nonTargets = this.measurementApi.fetch('nonTargets');
|
||||||
|
return {
|
||||||
|
targets,
|
||||||
|
nonTargets
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
getModalities() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
getImageById(studyInstanceUid, imageId) {
|
||||||
|
const study = ViewerStudies.findOne({ studyInstanceUid });
|
||||||
|
|
||||||
|
// Stop here if the study was not found
|
||||||
|
if (!study) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let foundImage;
|
||||||
|
_.each(study.displaySets, displaySet => {
|
||||||
|
if (foundImage) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_.each(displaySet.images, image => {
|
||||||
|
if (foundImage) {
|
||||||
|
return;
|
||||||
|
} else if (getImageId(image) === imageId) {
|
||||||
|
foundImage = image;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return foundImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
OHIF.measurements.RecistApi = RecistApi;
|
||||||
@ -1,3 +1,4 @@
|
|||||||
|
import './api';
|
||||||
import './lib';
|
import './lib';
|
||||||
import './helpers';
|
import './helpers';
|
||||||
import './components';
|
import './components';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user