Skip to content

Instantly share code, notes, and snippets.

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!');
}
};
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) {
function Dose() {
var _min = null;
var _max = null;
this.setMin = function(min) {
_min = min;
};
this.setMax = function(max) {
_max = max;
};
this.getMin = function() {
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
{
"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]
}
}
{
"id": "example_drug_two",
"name": "Drug Two",
"description": "Description of a Drug Two",
"dose": {
"type": "simple",
"a": [0.5, 0.6],
"b": 10
}
}
{
"id": "example_drug_one",
"name": "Drug One",
"description": "Description of a Drug One",
"dose": {
"type": "simple",
"a": 1,
"b": 2
}
}
[
{
"id": "example_drug_one",
"name": "Drug one"
},
{
"id": "example_drug_two",
"name": "Drug two"
},
{