reorganize packages, start converting overall app to react (very broken at the moment)
This commit is contained in:
1 parent
024fe1a448
commit
5f30f7bd35
479 files changed
+5364
-11611
No files matched your search
@@ -0,0 +1,188 @@
|
||||
import { ReactiveVar } from 'meteor/reactive-var';
|
||||
import { Tracker } from 'meteor/tracker';
|
||||
import _ from 'underscore';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
import 'meteor/ohif:viewerbase';
|
||||
import { CriteriaEvaluator } from './CriteriaEvaluator';
|
||||
import * as evaluations from './evaluations';
|
||||
|
||||
class ConformanceCriteria {
|
||||
|
||||
constructor(measurementApi, timepointApi) {
|
||||
this.measurementApi = measurementApi;
|
||||
this.timepointApi = timepointApi;
|
||||
this.nonconformities = new ReactiveVar();
|
||||
this.groupedNonConformities = new ReactiveVar();
|
||||
this.maxTargets = new ReactiveVar(null);
|
||||
this.maxNewTargets = new ReactiveVar(null);
|
||||
|
||||
const validate = _.debounce(trialCriteriaType => this.validate(trialCriteriaType), 300);
|
||||
Tracker.autorun(() => {
|
||||
const selectedType = OHIF.lesiontracker.TrialCriteriaTypes.findOne({ selected: true });
|
||||
this.measurementApi.changeObserver.depend();
|
||||
validate(selectedType);
|
||||
});
|
||||
}
|
||||
|
||||
validate(trialCriteriaType) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const baselinePromise = this.getData('baseline');
|
||||
const followupPromise = this.getData('followup');
|
||||
Promise.all([baselinePromise, followupPromise]).then(values => {
|
||||
const [baselineData, followupData] = values;
|
||||
const mergedData = {
|
||||
targets: [],
|
||||
nonTargets: []
|
||||
};
|
||||
|
||||
mergedData.targets = mergedData.targets.concat(baselineData.targets);
|
||||
mergedData.targets = mergedData.targets.concat(followupData.targets);
|
||||
mergedData.nonTargets = mergedData.nonTargets.concat(baselineData.nonTargets);
|
||||
mergedData.nonTargets = mergedData.nonTargets.concat(followupData.nonTargets);
|
||||
|
||||
this.maxTargets.set(null);
|
||||
this.maxNewTargets.set(null);
|
||||
const resultBoth = this.validateTimepoint('both', trialCriteriaType, mergedData);
|
||||
const resultBaseline = this.validateTimepoint('baseline', trialCriteriaType, baselineData);
|
||||
const resultFollowup = this.validateTimepoint('followup', trialCriteriaType, followupData);
|
||||
const nonconformities = resultBaseline.concat(resultFollowup).concat(resultBoth);
|
||||
const groupedNonConformities = this.groupNonConformities(nonconformities);
|
||||
|
||||
// Keep both? Group the data only on viewer/measurementTable views?
|
||||
// Work with not grouped data (worse lookup performance on measurementTableRow)?
|
||||
this.nonconformities.set(nonconformities);
|
||||
this.groupedNonConformities.set(groupedNonConformities);
|
||||
|
||||
resolve(nonconformities);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
groupNonConformities(nonconformities) {
|
||||
const groups = {};
|
||||
const toolsGroupsMap = this.measurementApi.toolsGroupsMap;
|
||||
|
||||
nonconformities.forEach(nonConformity => {
|
||||
if (nonConformity.isGlobal) {
|
||||
groups.globals = groups.globals || { messages: [] };
|
||||
groups.globals.messages.push(nonConformity.message);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
nonConformity.measurements.forEach(measurement => {
|
||||
const groupName = toolsGroupsMap[measurement.toolType];
|
||||
groups[groupName] = groups[groupName] || { measurementNumbers: {} };
|
||||
|
||||
const group = groups[groupName];
|
||||
const measureNumber = measurement.measurementNumber;
|
||||
let measurementNumbers = group.measurementNumbers[measureNumber];
|
||||
|
||||
if (!measurementNumbers) {
|
||||
measurementNumbers = group.measurementNumbers[measureNumber] = {
|
||||
messages: [],
|
||||
measurements: []
|
||||
};
|
||||
}
|
||||
|
||||
measurementNumbers.messages.push(nonConformity.message);
|
||||
measurementNumbers.measurements.push(measurement);
|
||||
});
|
||||
});
|
||||
|
||||
return groups;
|
||||
}
|
||||
|
||||
validateTimepoint(timepointId, trialCriteriaType, data) {
|
||||
const evaluators = this.getEvaluators(timepointId, trialCriteriaType);
|
||||
let nonconformities = [];
|
||||
|
||||
evaluators.forEach(evaluator => {
|
||||
const maxTargets = evaluator.getMaxTargets(false);
|
||||
const maxNewTargets = evaluator.getMaxTargets(true);
|
||||
if (maxTargets) {
|
||||
this.maxTargets.set(maxTargets);
|
||||
}
|
||||
|
||||
if (maxNewTargets) {
|
||||
this.maxNewTargets.set(maxNewTargets);
|
||||
}
|
||||
|
||||
const result = evaluator.evaluate(data);
|
||||
nonconformities = nonconformities.concat(result);
|
||||
});
|
||||
|
||||
return nonconformities;
|
||||
}
|
||||
|
||||
getEvaluators(timepointId, trialCriteriaType) {
|
||||
const evaluators = [];
|
||||
const trialCriteriaTypeId = trialCriteriaType.id.toLowerCase();
|
||||
const evaluation = evaluations[trialCriteriaTypeId];
|
||||
|
||||
if (evaluation) {
|
||||
const evaluationTimepoint = evaluation[timepointId];
|
||||
|
||||
if (evaluationTimepoint) {
|
||||
evaluators.push(new CriteriaEvaluator(evaluationTimepoint));
|
||||
}
|
||||
}
|
||||
|
||||
return evaluators;
|
||||
}
|
||||
|
||||
/*
|
||||
* Build the data that will be used to do the conformance criteria checks
|
||||
*/
|
||||
getData(timepointType) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const data = {
|
||||
targets: [],
|
||||
nonTargets: []
|
||||
};
|
||||
|
||||
const studyPromises = [];
|
||||
|
||||
const fillData = measurementType => {
|
||||
const measurements = this.measurementApi.fetch(measurementType);
|
||||
|
||||
measurements.forEach(measurement => {
|
||||
const { studyInstanceUid } = measurement;
|
||||
|
||||
const timepointId = measurement.timepointId;
|
||||
const timepoint = timepointId && this.timepointApi.timepoints.findOne({ timepointId });
|
||||
|
||||
if (!timepoint || ((timepointType !== 'both') && (timepoint.timepointType !== timepointType))) {
|
||||
return;
|
||||
}
|
||||
|
||||
const promise = OHIF.studies.loadStudy(studyInstanceUid);
|
||||
promise.then(study => {
|
||||
const studyMetadata = OHIF.viewerbase.getStudyMetadata(study);
|
||||
|
||||
data[measurementType].push({
|
||||
measurement,
|
||||
metadata: studyMetadata.getFirstInstance(),
|
||||
timepoint
|
||||
});
|
||||
});
|
||||
studyPromises.push(promise);
|
||||
});
|
||||
};
|
||||
|
||||
fillData('targets');
|
||||
fillData('nonTargets');
|
||||
|
||||
Promise.all(studyPromises).then(() => {
|
||||
resolve(data);
|
||||
}).catch(reject);
|
||||
});
|
||||
}
|
||||
|
||||
static setEvaluationDefinitions(evaluationKey, evaluationDefinitions) {
|
||||
evaluations[evaluationKey] = evaluationDefinitions;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
OHIF.measurements.ConformanceCriteria = ConformanceCriteria;
|
||||
@@ -0,0 +1,90 @@
|
||||
import { BaseCriterion } from './criteria/BaseCriterion';
|
||||
import * as Criteria from './criteria';
|
||||
import _ from 'underscore';
|
||||
import Ajv from 'ajv';
|
||||
|
||||
export class CriteriaEvaluator {
|
||||
|
||||
constructor(criteriaObject) {
|
||||
const criteriaValidator = this.getCriteriaValidator();
|
||||
this.criteria = [];
|
||||
|
||||
if (!criteriaValidator(criteriaObject)) {
|
||||
let message = '';
|
||||
_.each(criteriaValidator.errors, error => {
|
||||
message += `\noptions${error.dataPath} ${error.message}`;
|
||||
});
|
||||
throw new Error(message);
|
||||
}
|
||||
|
||||
_.each(criteriaObject, (optionsObject, criterionkey) => {
|
||||
const Criterion = Criteria[`${criterionkey}Criterion`];
|
||||
const optionsArray = optionsObject instanceof Array ? optionsObject : [optionsObject];
|
||||
_.each(optionsArray, options => this.criteria.push(new Criterion(options)));
|
||||
});
|
||||
}
|
||||
|
||||
getMaxTargets(newTarget=false) {
|
||||
let result = 0;
|
||||
_.each(this.criteria, criterion => {
|
||||
const newTargetMatch = newTarget === !!criterion.options.newTarget;
|
||||
if (criterion instanceof Criteria.MaxTargetsCriterion && newTargetMatch) {
|
||||
const { limit } = criterion.options;
|
||||
if (limit > result) {
|
||||
result = limit;
|
||||
}
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
getCriteriaValidator() {
|
||||
if (CriteriaEvaluator.criteriaValidator) {
|
||||
return CriteriaEvaluator.criteriaValidator;
|
||||
}
|
||||
|
||||
const schema = {
|
||||
properties: {},
|
||||
definitions: {}
|
||||
};
|
||||
|
||||
_.each(Criteria, (Criterion, key) => {
|
||||
if (Criterion.prototype instanceof BaseCriterion) {
|
||||
const criterionkey = key.replace(/Criterion$/, '');
|
||||
const criterionDefinition = `#/definitions/${criterionkey}`;
|
||||
|
||||
schema.definitions[criterionkey] = Criteria[`${criterionkey}Schema`];
|
||||
schema.properties[criterionkey] = {
|
||||
oneOf: [
|
||||
{ $ref: criterionDefinition },
|
||||
{
|
||||
type: 'array',
|
||||
items: {
|
||||
$ref: criterionDefinition
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
CriteriaEvaluator.criteriaValidator = new Ajv().compile(schema);
|
||||
return CriteriaEvaluator.criteriaValidator;
|
||||
}
|
||||
|
||||
evaluate(data) {
|
||||
const nonconformities = [];
|
||||
this.criteria.forEach(criterion => {
|
||||
const criterionResult = criterion.evaluate(data);
|
||||
if (!criterionResult.passed) {
|
||||
nonconformities.push(criterionResult);
|
||||
}
|
||||
});
|
||||
return nonconformities;
|
||||
}
|
||||
|
||||
static setCriterion(criterionKey, criterionDefinitions) {
|
||||
Criteria[criterionKey] = criterionDefinitions;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import _ from 'underscore';
|
||||
|
||||
export class BaseCriterion {
|
||||
|
||||
constructor(options) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
generateResponse(message, measurements) {
|
||||
const passed = !message;
|
||||
const isGlobal = !measurements || !measurements.length;
|
||||
|
||||
return {
|
||||
passed,
|
||||
isGlobal,
|
||||
message,
|
||||
measurements
|
||||
};
|
||||
}
|
||||
|
||||
getNewTargetNumbers(data) {
|
||||
const { options } = this;
|
||||
const baselineMeasurementNumbers = [];
|
||||
const newTargetNumbers = new Set();
|
||||
|
||||
if (options.newTarget) {
|
||||
_.each(data.targets, target => {
|
||||
const { measurementNumber } = target.measurement;
|
||||
if (target.timepoint.timepointType === 'baseline') {
|
||||
baselineMeasurementNumbers.push(measurementNumber);
|
||||
}
|
||||
});
|
||||
_.each(data.targets, target => {
|
||||
const { measurementNumber } = target.measurement;
|
||||
if (target.timepoint.timepointType === 'followup') {
|
||||
if (!_.contains(baselineMeasurementNumbers, measurementNumber)) {
|
||||
newTargetNumbers.add(measurementNumber);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return newTargetNumbers;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import { BaseCriterion } from './BaseCriterion';
|
||||
|
||||
export const LocationSchema = {
|
||||
type: 'object'
|
||||
};
|
||||
|
||||
/* LocationCriterion
|
||||
* Check if the there are non-target measurements with response different than "present" on baseline
|
||||
*/
|
||||
export class LocationCriterion extends BaseCriterion {
|
||||
|
||||
constructor(options) {
|
||||
super(options);
|
||||
}
|
||||
|
||||
evaluate(data) {
|
||||
const items = data.targets.concat(data.nonTargets);
|
||||
const measurements = [];
|
||||
let message;
|
||||
|
||||
items.forEach(item => {
|
||||
const measurement = item.measurement;
|
||||
|
||||
if (!measurement.location) {
|
||||
measurements.push(measurement);
|
||||
}
|
||||
});
|
||||
|
||||
if (measurements.length) {
|
||||
message = 'All measurements should have a location';
|
||||
}
|
||||
|
||||
return this.generateResponse(message, measurements);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
import _ from 'underscore';
|
||||
import { BaseCriterion } from './BaseCriterion';
|
||||
|
||||
export const MaxTargetsSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
limit: {
|
||||
label: 'Max targets allowed in study',
|
||||
type: 'integer',
|
||||
minimum: 0
|
||||
},
|
||||
newTarget: {
|
||||
label: 'Flag to evaluate only new targets',
|
||||
type: 'boolean'
|
||||
},
|
||||
locationIn: {
|
||||
label: 'Filter to evaluate only measurements with the specified locations',
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string'
|
||||
},
|
||||
minItems: 1,
|
||||
uniqueItems: true
|
||||
},
|
||||
locationNotIn: {
|
||||
label: 'Filter to evaluate only measurements without the specified locations',
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string'
|
||||
},
|
||||
minItems: 1,
|
||||
uniqueItems: true
|
||||
}
|
||||
},
|
||||
required: ['limit']
|
||||
};
|
||||
|
||||
/* MaxTargetsCriterion
|
||||
* Check if the number of target measurements exceeded the limit allowed
|
||||
* Options:
|
||||
* limit: Max targets allowed in study
|
||||
* newTarget: Flag to evaluate only new targets (must be evaluated on both)
|
||||
* locationIn: Filter to evaluate only measurements with the specified locations
|
||||
* locationNotIn: Filter to evaluate only measurements without the specified locations
|
||||
* message: Message to be displayed in case of nonconformity
|
||||
*/
|
||||
export class MaxTargetsCriterion extends BaseCriterion {
|
||||
|
||||
constructor(options) {
|
||||
super(options);
|
||||
}
|
||||
|
||||
evaluate(data) {
|
||||
const { options } = this;
|
||||
|
||||
const newTargetNumbers = this.getNewTargetNumbers(data);
|
||||
const measurementNumbers = [];
|
||||
_.each(data.targets, target => {
|
||||
const { location, measurementNumber, isSplitLesion } = target.measurement;
|
||||
if (isSplitLesion) return;
|
||||
if (options.newTarget && !newTargetNumbers.has(measurementNumber)) return;
|
||||
if (options.locationIn && options.locationIn.indexOf(location) === -1) return;
|
||||
if (options.locationNotIn && options.locationNotIn.indexOf(location) > -1) return;
|
||||
measurementNumbers.push(measurementNumber);
|
||||
});
|
||||
|
||||
let message;
|
||||
if (measurementNumbers.length > options.limit) {
|
||||
const increment = options.newTarget ? 'new ' : '';
|
||||
const plural = options.limit === 1 ? '' : 's';
|
||||
const amount = options.limit === 0 ? '' : `more than ${options.limit}`;
|
||||
message = options.message || `The study should not have ${amount} ${increment}target${plural}.`;
|
||||
}
|
||||
|
||||
return this.generateResponse(message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
import _ from 'underscore';
|
||||
import { BaseCriterion } from './BaseCriterion';
|
||||
|
||||
export const MaxTargetsPerOrganSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
limit: {
|
||||
label: 'Max targets allowed per organ',
|
||||
type: 'integer',
|
||||
minimum: 1
|
||||
},
|
||||
newTarget: {
|
||||
label: 'Flag to evaluate only new targets',
|
||||
type: 'boolean'
|
||||
}
|
||||
},
|
||||
required: ['limit']
|
||||
};
|
||||
|
||||
/*
|
||||
* MaxTargetsPerOrganCriterion
|
||||
* Check if the number of target measurements per organ exceeded the limit allowed
|
||||
* Options:
|
||||
* limit: Max targets allowed in study
|
||||
* newTarget: Flag to evaluate only new targets (must be evaluated on both)
|
||||
*/
|
||||
export class MaxTargetsPerOrganCriterion extends BaseCriterion {
|
||||
|
||||
constructor(options) {
|
||||
super(options);
|
||||
}
|
||||
|
||||
evaluate(data) {
|
||||
const { options } = this;
|
||||
const targetsPerOrgan = {};
|
||||
let measurements = [];
|
||||
|
||||
const newTargetNumbers = this.getNewTargetNumbers(data);
|
||||
_.each(data.targets, target => {
|
||||
const { measurement } = target;
|
||||
const { location, measurementNumber, isSplitLesion } = measurement;
|
||||
|
||||
if (isSplitLesion) return;
|
||||
|
||||
if (!targetsPerOrgan[location]) {
|
||||
targetsPerOrgan[location] = new Set();
|
||||
}
|
||||
|
||||
if (!options.newTarget || newTargetNumbers.has(measurementNumber)) {
|
||||
targetsPerOrgan[location].add(measurementNumber);
|
||||
}
|
||||
|
||||
if (targetsPerOrgan[location].size > options.limit) {
|
||||
measurements.push(measurement);
|
||||
}
|
||||
});
|
||||
|
||||
let message;
|
||||
if (measurements.length) {
|
||||
const increment = options.newTarget ? 'new ' : '';
|
||||
message = options.message || `Each organ should not have more than ${options.limit} ${increment}targets.`;
|
||||
}
|
||||
|
||||
return this.generateResponse(message, measurements);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
import { BaseCriterion } from './BaseCriterion';
|
||||
|
||||
export const MeasurementsLengthSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
longAxis: {
|
||||
label: 'Minimum length of long axis',
|
||||
type: 'number',
|
||||
minimum: 0
|
||||
},
|
||||
shortAxis: {
|
||||
label: 'Minimum length of short axis',
|
||||
type: 'number',
|
||||
minimum: 0
|
||||
},
|
||||
longAxisSliceThicknessMultiplier: {
|
||||
label: 'Length of long axis multiplier',
|
||||
type: 'number',
|
||||
minimum: 0
|
||||
},
|
||||
shortAxisSliceThicknessMultiplier: {
|
||||
label: 'Length of short axis multiplier',
|
||||
type: 'number',
|
||||
minimum: 0
|
||||
},
|
||||
modalityIn: {
|
||||
label: 'Filter to evaluate only measurements with the specified modalities',
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string'
|
||||
},
|
||||
minItems: 1,
|
||||
uniqueItems: true
|
||||
},
|
||||
modalityNotIn: {
|
||||
label: 'Filter to evaluate only measurements without the specified modalities',
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string'
|
||||
},
|
||||
minItems: 1,
|
||||
uniqueItems: true
|
||||
},
|
||||
locationIn: {
|
||||
label: 'Filter to evaluate only measurements with the specified locations',
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string'
|
||||
},
|
||||
minItems: 1,
|
||||
uniqueItems: true
|
||||
},
|
||||
locationNotIn: {
|
||||
label: 'Filter to evaluate only measurements without the specified locations',
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string'
|
||||
},
|
||||
minItems: 1,
|
||||
uniqueItems: true
|
||||
},
|
||||
message: {
|
||||
label: 'Message to be displayed in case of nonconformity',
|
||||
type: 'string'
|
||||
}
|
||||
},
|
||||
anyOf: [
|
||||
{ required: ['message', 'longAxis'] },
|
||||
{ required: ['message', 'shortAxis'] },
|
||||
{ required: ['message', 'longAxisSliceThicknessMultiplier'] },
|
||||
{ required: ['message', 'shortAxisSliceThicknessMultiplier'] }
|
||||
]
|
||||
};
|
||||
|
||||
/*
|
||||
* MeasurementsLengthCriterion
|
||||
* Check the measurements of all bidirectional tools based on
|
||||
* short axis, long axis, modalities, location and slice thickness
|
||||
* Options:
|
||||
* longAxis: Minimum length of long axis
|
||||
* shortAxis: Minimum length of short axis
|
||||
* longAxisSliceThicknessMultiplier: Length of long axis multiplier
|
||||
* shortAxisSliceThicknessMultiplier: Length of short axis multiplier
|
||||
* modalityIn: Filter to evaluate only measurements with the specified modalities
|
||||
* modalityNotIn: Filter to evaluate only measurements without the specified modalities
|
||||
* locationIn: Filter to evaluate only measurements with the specified locations
|
||||
* locationNotIn: Filter to evaluate only measurements without the specified locations
|
||||
* message: Message to be displayed in case of nonconformity
|
||||
*/
|
||||
export class MeasurementsLengthCriterion extends BaseCriterion {
|
||||
|
||||
constructor(options) {
|
||||
super(options);
|
||||
}
|
||||
|
||||
evaluate(data) {
|
||||
let message;
|
||||
let measurements = [];
|
||||
const { options } = this;
|
||||
const longMultiplier = options.longAxisSliceThicknessMultiplier;
|
||||
const shortMultiplier = options.shortAxisSliceThicknessMultiplier;
|
||||
|
||||
data.targets.forEach(item => {
|
||||
const { metadata, measurement } = item;
|
||||
const { location } = measurement;
|
||||
|
||||
let { longestDiameter, shortestDiameter } = measurement;
|
||||
if (measurement.childToolsCount) {
|
||||
const child = measurement.bidirectional;
|
||||
longestDiameter = (child && child.longestDiameter) || 0;
|
||||
shortestDiameter = (child && child.shortestDiameter) || 0;
|
||||
}
|
||||
|
||||
const { sliceThickness } = metadata;
|
||||
const modality = (metadata.getRawValue('x00080060') || '').toUpperCase();
|
||||
|
||||
// Stop here if the measurement does not match the modality and location filters
|
||||
if (options.locationIn && options.locationIn.indexOf(location) === -1) return;
|
||||
if (options.modalityIn && options.modalityIn.indexOf(modality) === -1) return;
|
||||
if (options.locationNotIn && options.locationNotIn.indexOf(location) > -1) return;
|
||||
if (options.modalityNotIn && options.modalityNotIn.indexOf(modality) > -1) return;
|
||||
|
||||
// Check the measurement length
|
||||
const failed = (
|
||||
(options.longAxis && longestDiameter < options.longAxis) ||
|
||||
(options.shortAxis && shortestDiameter < options.shortAxis) || (
|
||||
longMultiplier && !isNaN(sliceThickness) &&
|
||||
longestDiameter < (longMultiplier * sliceThickness)
|
||||
) || (
|
||||
shortMultiplier && !isNaN(sliceThickness) &&
|
||||
shortestDiameter < (shortMultiplier * sliceThickness)
|
||||
)
|
||||
);
|
||||
|
||||
// Mark this measurement as invalid if some of the checks have failed
|
||||
if (failed) {
|
||||
measurements.push(measurement);
|
||||
}
|
||||
});
|
||||
|
||||
// Use the options' message if some measurement is invalid
|
||||
if (measurements.length) {
|
||||
message = options.message;
|
||||
}
|
||||
|
||||
return this.generateResponse(message, measurements);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
import { BaseCriterion } from './BaseCriterion';
|
||||
import _ from 'underscore';
|
||||
|
||||
export const ModalitySchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
method: {
|
||||
label: 'Specify if it\'s goinig to "allow" or "deny" the modalities',
|
||||
type: 'string',
|
||||
enum: ['allow', 'deny']
|
||||
},
|
||||
measurementTypes: {
|
||||
label: 'List of measurement types that will be evaluated',
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string'
|
||||
},
|
||||
minItems: 1,
|
||||
uniqueItems: true
|
||||
},
|
||||
modalities: {
|
||||
label: 'List of allowed/denied modalities',
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string'
|
||||
},
|
||||
minItems: 1,
|
||||
uniqueItems: true
|
||||
}
|
||||
},
|
||||
required: ['method', 'modalities']
|
||||
};
|
||||
|
||||
/*
|
||||
* ModalityCriteria
|
||||
* Check if a modality is allowed or denied
|
||||
* Options:
|
||||
* method (string): Specify if it\'s goinig to "allow" or "deny" the modalities
|
||||
* measurementTypes (string[]): List of measurement types that will be evaluated
|
||||
* modalities (string[]): List of allowed/denied modalities
|
||||
*/
|
||||
export class ModalityCriterion extends BaseCriterion {
|
||||
|
||||
constructor(options) {
|
||||
super(options);
|
||||
}
|
||||
|
||||
evaluate(data) {
|
||||
const measurementTypes = this.options.measurementTypes || ['targets'];
|
||||
const modalitiesSet = new Set(this.options.modalities);
|
||||
const validationMethod = this.options.method;
|
||||
const measurements = [];
|
||||
const invalidModalities = [];
|
||||
let message;
|
||||
|
||||
measurementTypes.forEach(measurementType => {
|
||||
const items = data[measurementType];
|
||||
|
||||
items.forEach(item => {
|
||||
const { measurement, metadata } = item;
|
||||
const modality = (metadata.getRawValue('x00080060') || '').toUpperCase();
|
||||
|
||||
if (((validationMethod === 'allow') && !modalitiesSet.has(modality)) ||
|
||||
((validationMethod === 'deny') && modalitiesSet.has(modality))) {
|
||||
measurements.push(measurement);
|
||||
invalidModalities.push(modality);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (measurements.length) {
|
||||
const uniqueModalities = _.uniq(invalidModalities);
|
||||
const uniqueModalitiesText = uniqueModalities.join(', ');
|
||||
const modalityText = uniqueModalities.length > 1 ? 'modalities' : 'modality';
|
||||
|
||||
message = `The ${modalityText} ${uniqueModalitiesText} should not be used as a method of measurement`;
|
||||
}
|
||||
|
||||
return this.generateResponse(message, measurements);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import { BaseCriterion } from './BaseCriterion';
|
||||
|
||||
export const NonTargetResponseSchema = {
|
||||
type: 'object'
|
||||
};
|
||||
|
||||
/* NonTargetResponseCriterion
|
||||
* Check if the there are non-target measurements with response different than "present" on baseline
|
||||
*/
|
||||
export class NonTargetResponseCriterion extends BaseCriterion {
|
||||
|
||||
constructor(options) {
|
||||
super(options);
|
||||
}
|
||||
|
||||
evaluate(data) {
|
||||
const items = data.nonTargets;
|
||||
const measurements = [];
|
||||
let message;
|
||||
|
||||
items.forEach(item => {
|
||||
const measurement = item.measurement;
|
||||
const response = (measurement.response || '').toLowerCase();
|
||||
|
||||
if (response !== 'present') {
|
||||
measurements.push(measurement);
|
||||
}
|
||||
});
|
||||
|
||||
if (measurements.length) {
|
||||
message = 'Non-targets can only be assessed as "present"';
|
||||
}
|
||||
|
||||
return this.generateResponse(message, measurements);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import { BaseCriterion } from './BaseCriterion';
|
||||
|
||||
export const TargetTypeSchema = {
|
||||
type: 'object'
|
||||
};
|
||||
|
||||
/* TargetTypeCriterion
|
||||
* Check if the there are non-bidirectional target measurements on baseline
|
||||
*/
|
||||
export class TargetTypeCriterion extends BaseCriterion {
|
||||
|
||||
constructor(options) {
|
||||
super(options);
|
||||
}
|
||||
|
||||
evaluate(data) {
|
||||
const items = data.targets;
|
||||
const measurements = [];
|
||||
let message;
|
||||
|
||||
items.forEach(item => {
|
||||
const measurement = item.measurement;
|
||||
|
||||
if (measurement.toolType !== 'bidirectional' && !measurement.bidirectional) {
|
||||
measurements.push(measurement);
|
||||
}
|
||||
});
|
||||
|
||||
if (measurements.length) {
|
||||
message = 'Target lesions must have measurements (cannot be assessed as CR, UN/NE, EX)';
|
||||
}
|
||||
|
||||
return this.generateResponse(message, measurements);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
export * from './Location';
|
||||
export * from './MaxTargetsPerOrgan';
|
||||
export * from './MaxTargets';
|
||||
export * from './MeasurementsLength';
|
||||
export * from './Modality';
|
||||
export * from './NonTargetResponse';
|
||||
export * from './TargetType';
|
||||
@@ -0,0 +1,3 @@
|
||||
import * as recistEvaluation from './recist.json';
|
||||
|
||||
export const recist = recistEvaluation;
|
||||
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"both": {
|
||||
"Location": {}
|
||||
},
|
||||
"baseline": {
|
||||
"TargetType": {},
|
||||
"MaxTargetsPerOrgan": {
|
||||
"limit": 2
|
||||
},
|
||||
"MaxTargets": {
|
||||
"limit": 5
|
||||
},
|
||||
"MeasurementsLength": [{
|
||||
"longAxis": 10,
|
||||
"longAxisSliceThicknessMultiplier": 2,
|
||||
"modalityIn": ["CT", "MR"],
|
||||
"locationNotIn": ["Lymph Node"],
|
||||
"message": "Extranodal lesions must be >= 10mm long axis AND >= double the acquisition slice thickness by CT and MR"
|
||||
}, {
|
||||
"shortAxis": 20,
|
||||
"longAxis": 20,
|
||||
"modalityIn": ["PX", "XA"],
|
||||
"locationNotIn": ["Lymph Node"],
|
||||
"message": "Extranodal lesions must be >= 20mm on chest x-ray (although x-rays rarely used for clinical trial assessment)"
|
||||
}, {
|
||||
"shortAxis": 15,
|
||||
"shortAxisSliceThicknessMultiplier": 2,
|
||||
"modalityIn": ["CT", "MR"],
|
||||
"locationIn": ["Lymph Node"],
|
||||
"message": "Nodal lesions must be >= 15mm short axis AND >= double the acquisition slice thickness by CT and MR"
|
||||
}]
|
||||
},
|
||||
"followup": {}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
import './ConformanceCriteria';
|
||||
Reference in new issue
Block a user