This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": "example_drug_one", | |
"name": "Drug one" | |
}, | |
{ | |
"id": "example_drug_two", | |
"name": "Drug two" | |
}, | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": "example_drug_two", | |
"name": "Drug Two", | |
"description": "Description of a Drug Two", | |
"dose": { | |
"type": "simple", | |
"a": [0.5, 0.6], | |
"b": 10 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": "example_drug_one", | |
"name": "Drug One", | |
"description": "Description of a Drug One", | |
"dose": { | |
"type": "simple", | |
"a": 1, | |
"b": 2 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": "example_drug_three", | |
"name": "Drug Three", | |
"description": "Description of a Drug Three", | |
"dose": { | |
"type": "complex", | |
"ranges": [12, 13, 14, 15], | |
"doses": [0.5, 1, 1.25, 1,30] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Dose() { | |
this.min = null; | |
this.max = null; | |
} | |
Dose.prototype = new Dose(); | |
var drug_dose = new Dose(); | |
drug_dose.min = 1; // OK | |
drug_dose.max = 'string'; // OK, but does not make sense |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Dose() { | |
var _min = null; | |
var _max = null; | |
this.setMin = function(min) { | |
_min = min; | |
}; | |
this.setMax = function(max) { | |
_max = max; | |
}; | |
this.getMin = function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Dose() { | |
var _min = null; | |
var _max = null; | |
var checkType = function(value) { | |
if (!(value instanceof Number) && !(typeof value === 'number')) { | |
throw new TypeError('Dose value must be numeric!'); | |
} | |
}; | |
var checkRange = function(value) { | |
if (value < 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function DoseComplexStrategy() { | |
var that = this; | |
var checkWeightIsInRange = function(weight) { | |
var ranges = that.getDoseParameters().getRanges(); | |
var min = ranges[0]; | |
var max = ranges[ranges.length - 1]; | |
if (!(weight >= min && weight <= max)) { | |
throw new RangeError('Weight out of range!'); | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function DoseComplexStrategy() { | |
var that = this; | |
var checkWeightIsInRange = function(weight) { | |
var ranges = that.getDoseParameters().getRanges(); | |
var min = ranges[0]; | |
var max = ranges[ranges.length - 1]; | |
if (!(weight >= min && weight <= max)) { | |
throw new RangeError('Weight out of range!'); | |
} | |
}; |