diff --git a/references/list.json b/references/list.json
index cee5072..66c628a 100644
--- a/references/list.json
+++ b/references/list.json
@@ -35,6 +35,7 @@
"St Jude staging system"
],
"drug_dose_units": ["mg/m2", "IU/m2", "ug/m2", "g/m2", "mg/kg", "mg"],
+ "drug_database": ["KEGG", "PubChem", "NCI Thesaurus"],
"stage_groups": ["Occult Carcinoma", "Stage 0", "Stage 0a", "Stage 0is", "Stage 1", "Stage 1A", "Stage 1B", "Stage A", "Stage B", "Stage C", "Stage I", "Stage IA", "Stage IA1", "Stage IA2", "Stage IA3", "Stage IAB", "Stage IAE", "Stage IAES", "Stage IAS", "Stage IB", "Stage IB1", "Stage IB2", "Stage IBE", "Stage IBES", "Stage IBS", "Stage IC", "Stage IE", "Stage IEA", "Stage IEB", "Stage IES", "Stage II", "Stage II bulky", "Stage IIA", "Stage IIA1", "Stage IIA2", "Stage IIAE", "Stage IIAES", "Stage IIAS", "Stage IIB", "Stage IIBE", "Stage IIBES", "Stage IIBS", "Stage IIC", "Stage IIE", "Stage IIEA", "Stage IIEB", "Stage IIES", "Stage III", "Stage IIIA", "Stage IIIA1", "Stage IIIA2", "Stage IIIAE", "Stage IIIAES", "Stage IIIAS", "Stage IIIB", "Stage IIIBE", "Stage IIIBES", "Stage IIIBS", "Stage IIIC", "Stage IIIC1", "Stage IIIC2", "Stage IIID", "Stage IIIE", "Stage IIIES", "Stage IIIS", "Stage IIS", "Stage IS", "Stage IV", "Stage IVA", "Stage IVA1", "Stage IVA2", "Stage IVAE", "Stage IVAES", "Stage IVAS", "Stage IVB", "Stage IVBE", "Stage IVBES", "Stage IVBS", "Stage IVC", "Stage IVE", "Stage IVES", "Stage IVS", "Cannot be assessed"],
"t_categories": ["T0","T1","T1a","T1a1","T1a2","T1a(s)","T1a(m)","T1b","T1b1","T1b2","T1b(s)","T1b(m)","T1c","T1d","T1mi","T2","T2(s)","T2(m)","T2a","T2a1","T2a2","T2b","T2c","T2d","T3","T3(s)","T3(m)","T3a","T3b","T3c","T3d","T3e","T4","T4a","T4a(s)","T4a(m)","T4b","T4b(s)","T4b(m)","T4c","T4d","T4e","Ta","Tis","Tis(DCIS)","Tis(LAMN)","Tis(LCIS)","Tis(Paget)","Tis(Paget’s)","Tis pd","Tis pu","TX"],
"n_categories": ["N0","N0a","N0a (biopsy)","N0b","N0b (no biopsy)","N0(i+)","N0(i-)","N0(mol+)","N0(mol-)","N1","N1a","N1a(sn)","N1b","N1c","N1mi","N2","N2a","N2b","N2c","N2mi","N3","N3a","N3b","N3c","N4","NX"],
diff --git a/references/validationFunctions/common/drugDatabase.js b/references/validationFunctions/common/drugDatabase.js
new file mode 100644
index 0000000..aca9972
--- /dev/null
+++ b/references/validationFunctions/common/drugDatabase.js
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2024 The Ontario Institute for Cancer Research. All rights reserved
+ *
+ * This program and the accompanying materials are made available under the terms of the GNU Affero General Public License v3.0.
+ * You should have received a copy of the GNU Affero General Public License along with
+ * this program. If not, see .
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+ * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ */
+
+/**
+ * Requirement to submit either drug_rxnormcui, drug_name or drug_database, drug_id, drug_term.
+ */
+
+const validation = () =>
+ (function validate(inputs) {
+ const {$row, $name, $field} = inputs;
+ let result = {valid: true, message: "Ok"};
+
+ // Extract related fields from the row
+ const drug_rxnormcui = $row.drug_rxnormcui;
+ const drug_name = $row.drug_name;
+ const drug_database = $row.drug_database;
+ const drug_id = $row.drug_id;
+ const drug_term = $row.drug_term;
+
+ // checks for empty fields
+ const checkforEmpty = (entry) => {
+ // Check if entry is null or undefined
+ if (entry === null || entry === undefined) {
+ return true;
+ }
+ // Logic to check if the entry is an empty string or contains only whitespace
+ return /^\s*$/.test(decodeURI(entry).replace(/^"(.*)"$/, '$1'));
+ };
+
+ // Validate based on the field name
+ switch ($name) {
+ case 'drug_rxnormcui':
+ // If drug_rxnormcui is provided
+ if (!checkforEmpty($field)) {
+ if (checkforEmpty(drug_name)) {
+ result = {
+ valid: false,
+ message: `drug_name is required when drug_rxnormcui is provided.`
+ };
+ }
+ if (!checkforEmpty(drug_database) || !checkforEmpty(drug_id) || !checkforEmpty(drug_term) ) {
+ result = {
+ valid: false,
+ message: `drug_database, drug_id and drug_term should be blank when drug_rxnormcui is provided.`
+ };
+ }
+ } else {
+ // If drug_rxnormcui is not provided
+ if (!checkforEmpty(drug_name)) {
+ result = {
+ valid: false,
+ message: `drug_name should not be populated when drug_rxnormcui is not provided.`
+ };
+ }
+ if (checkforEmpty(drug_database) || checkforEmpty(drug_id) || checkforEmpty(drug_term) ) {
+ result = {
+ valid: false,
+ message: `drug_database, drug_id and drug_term must be populated when drug_rxnormcui is not provided.`
+ };
+ }
+ }
+ break;
+
+ case 'drug_name':
+ // If drug_rxnormcui is provided, drug_name must be populated
+ if (!checkforEmpty(drug_rxnormcui) && checkforEmpty($field)) {
+ result = {
+ valid: false,
+ message: `drug_name is required when drug_rxnormcui is provided.`
+ };
+ }
+ // If drug_rxnormcui is not provided, drug_name should be empty
+ if (checkforEmpty(drug_rxnormcui) && !checkforEmpty($field)) {
+ result = {
+ valid: false,
+ message: `drug_name should not be populated when drug_rxnormcui is not provided.`
+ };
+ }
+ break;
+
+ case 'drug_database':
+ case 'drug_id':
+ case 'drug_term':
+ // If drug_rxnormcui is provided, these fields should be empty
+ if (!checkforEmpty(drug_rxnormcui) && !checkforEmpty($field)) {
+ result = {
+ valid: false,
+ message: `'${$name}' should be blank when drug_rxnormcui is provided.`
+ };
+ }
+ // If drug_rxnormcui is not provided, these fields must be populated
+ if (checkforEmpty(drug_rxnormcui) && checkforEmpty($field)) {
+ result = {
+ valid: false,
+ message: `'${$name}' must be populated when drug_rxnormcui is not provided.`
+ };
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return result;
+ });
+
+
+module.exports = validation;
diff --git a/schemas/biomarker.json b/schemas/biomarker.json
index 2cd0cc0..134c946 100644
--- a/schemas/biomarker.json
+++ b/schemas/biomarker.json
@@ -103,9 +103,6 @@
"name": "test_interval",
"valueType": "integer",
"restrictions": {
- "range": {
- "exclusiveMin": 0
- },
"script": "#/script/biomarker/intervalOrId"
},
"meta": {
diff --git a/schemas/chemotherapy.json b/schemas/chemotherapy.json
index d0bdb4c..bf64ed3 100644
--- a/schemas/chemotherapy.json
+++ b/schemas/chemotherapy.json
@@ -54,13 +54,14 @@
"description": "The unique RxNormID assigned to the treatment regimen drug.",
"valueType": "string",
"meta": {
- "validationDependency": true,
"core": true,
- "notes": "This field uses standardized vocabulary from the RxNorm database (https://www.nlm.nih.gov/research/umls/rxnorm), provided by the NIH.\n\nYou can search for RX Norm values through the web interface (https://mor.nlm.nih.gov/RxNav/) or API (https://mor.nlm.nih.gov/download/rxnav/RxNormAPIs.html).\n\nFor example, to find the rxnormcui based on drug name, you can use: https://rxnav.nlm.nih.gov/REST/rxcui.json?name=leucovorin or https://mor.nlm.nih.gov/RxNav/search?searchBy=String&searchTerm=leucovorin",
+ "validationDependency": true,
+ "dependsOn": "chemotherapy.drug_database",
+ "notes": "This field uses standardized vocabulary from the RxNorm database (https://www.nlm.nih.gov/research/umls/rxnorm), provided by the NIH.\n\nYou can search for RX Norm values through the web interface (https://mor.nlm.nih.gov/RxNav/) or API (https://mor.nlm.nih.gov/download/rxnav/RxNormAPIs.html).\n\nFor example, to find the rxnormcui based on drug name, you can use: https://rxnav.nlm.nih.gov/REST/rxcui.json?name=leucovorin or https://mor.nlm.nih.gov/RxNav/search?searchBy=String&searchTerm=leucovorin. \n\nIf the drugs don't exist in RxNorm, please indicate drug_database, drug_id and drug_term where the drugs information can be found.",
"displayName": "RxNormCUI"
},
"restrictions": {
- "required": true
+ "script": "#/script/common/drugDatabase"
}
},
{
@@ -68,13 +69,60 @@
"description": "Name of agent or drug administered to donor as part of the treatment regimen.",
"valueType": "string",
"meta": {
- "validationDependency": true,
"core": true,
- "notes": "This field uses standardized vocabulary from the RxNorm database (https://www.nlm.nih.gov/research/umls/rxnorm), provided by the NIH.\n\nYou can search for RX Norm values through the web interface (https://mor.nlm.nih.gov/RxNav/) or API (https://mor.nlm.nih.gov/download/rxnav/RxNormAPIs.html).\n\nFor example, to find the rxnormcui based on drug name, you can use: https://rxnav.nlm.nih.gov/REST/rxcui.json?name=leucovorin or https://mor.nlm.nih.gov/RxNav/search?searchBy=String&searchTerm=leucovorin",
+ "validationDependency": true,
+ "dependsOn": "chemotherapy.drug_rxnormcui",
+ "notes": "This field uses standardized vocabulary from the RxNorm database (https://www.nlm.nih.gov/research/umls/rxnorm), provided by the NIH.\n\nYou can search for RX Norm values through the web interface (https://mor.nlm.nih.gov/RxNav/) or API (https://mor.nlm.nih.gov/download/rxnav/RxNormAPIs.html).\n\nFor example, to find the rxnormcui based on drug name, you can use: https://rxnav.nlm.nih.gov/REST/rxcui.json?name=leucovorin or https://mor.nlm.nih.gov/RxNav/search?searchBy=String&searchTerm=leucovorin. \n\nIf the drugs don't exist in RxNorm, please indicate drug_database, drug_id and drug_term where the drugs information can be found.",
"displayName": "Chemotherapy Drug Name"
},
"restrictions": {
- "required": true
+ "script": "#/script/common/drugDatabase"
+ }
+ },
+ {
+ "name": "drug_database",
+ "description": "Indicate the drug database where drug term is found.",
+ "valueType": "string",
+ "meta": {
+ "core": true,
+ "validationDependency": true,
+ "dependsOn": "chemotherapy.drug_rxnormcui",
+ "notes": "If the drugs don't exist in RxNorm, please indicate drug_database, drug_id and drug_term where the drugs information can be found.",
+ "displayName": "Drug Database"
+ },
+ "restrictions": {
+ "script": "#/script/common/drugDatabase",
+ "codeList": "#/list/drug_database"
+ }
+ },
+ {
+ "name": "drug_id",
+ "description": "Indicate the identifier from the drug_database for the drug.",
+ "valueType": "string",
+ "meta": {
+ "core": true,
+ "validationDependency": true,
+ "dependsOn": "chemotherapy.drug_rxnormcui",
+ "notes": "If the drugs don't exist in RxNorm, please indicate drug_database, drug_id and drug_term where the drugs information can be found.",
+ "displayName": "Drug ID"
+ },
+ "restrictions": {
+ "script": "#/script/common/drugDatabase"
+ }
+ },
+ {
+ "name": "drug_term",
+ "description": "Indicate the drug term as it exists in the database specified in the drug_database.",
+ "valueType": "string",
+ "meta": {
+ "core": true,
+ "validationDependency": true,
+ "dependsOn": "chemotherapy.drug_rxnormcui",
+ "notes": "If the drugs don't exist in RxNorm, please indicate drug_database, drug_id and drug_term where the drugs information can be found.",
+ "displayName": "Drug Term"
+ },
+ "restrictions": {
+ "script": "#/script/common/drugDatabase"
}
},
{
diff --git a/schemas/follow_up.json b/schemas/follow_up.json
index 2cc731a..0d7838f 100644
--- a/schemas/follow_up.json
+++ b/schemas/follow_up.json
@@ -53,10 +53,7 @@
"name": "interval_of_followup",
"valueType": "integer",
"restrictions": {
- "required": true,
- "range": {
- "exclusiveMin": 0
- }
+ "required": true
},
"meta": {
"core": true,
@@ -153,10 +150,7 @@
"name": "relapse_interval",
"valueType": "integer",
"restrictions": {
- "script": "#/script/follow_up/relapse_interval",
- "range": {
- "exclusiveMin": 0
- }
+ "script": "#/script/follow_up/relapse_interval"
},
"meta": {
"core": true,
diff --git a/schemas/hormone_therapy.json b/schemas/hormone_therapy.json
index 948529d..6fb68be 100644
--- a/schemas/hormone_therapy.json
+++ b/schemas/hormone_therapy.json
@@ -55,11 +55,13 @@
"valueType": "string",
"meta": {
"core": true,
- "notes": "This field uses standardized vocabulary from the RxNorm database (https://www.nlm.nih.gov/research/umls/rxnorm), provided by the NIH.\n\nYou can search for RX Norm values through the web interface (https://mor.nlm.nih.gov/RxNav/) or API (https://mor.nlm.nih.gov/download/rxnav/RxNormAPIs.html).\n\nFor example, to find the rxnormcui based on drug name, you can use: https://rxnav.nlm.nih.gov/REST/rxcui.json?name=leucovorin or https://mor.nlm.nih.gov/RxNav/search?searchBy=String&searchTerm=leucovorin",
+ "validationDependency": true,
+ "dependsOn": "hormone_therapy.drug_database",
+ "notes": "This field uses standardized vocabulary from the RxNorm database (https://www.nlm.nih.gov/research/umls/rxnorm), provided by the NIH.\n\nYou can search for RX Norm values through the web interface (https://mor.nlm.nih.gov/RxNav/) or API (https://mor.nlm.nih.gov/download/rxnav/RxNormAPIs.html).\n\nFor example, to find the rxnormcui based on drug name, you can use: https://rxnav.nlm.nih.gov/REST/rxcui.json?name=leucovorin or https://mor.nlm.nih.gov/RxNav/search?searchBy=String&searchTerm=leucovorin. \n\nIf the drugs don't exist in RxNorm, please indicate drug_database, drug_id and drug_term where the drugs information can be found.",
"displayName": "RxNormCUI"
},
"restrictions": {
- "required": true
+ "script": "#/script/common/drugDatabase"
}
},
{
@@ -68,11 +70,59 @@
"valueType": "string",
"meta": {
"core": true,
- "notes": "This field uses standardized vocabulary from the RxNorm database (https://www.nlm.nih.gov/research/umls/rxnorm), provided by the NIH.\n\nYou can search for RX Norm values through the web interface (https://mor.nlm.nih.gov/RxNav/) or API (https://mor.nlm.nih.gov/download/rxnav/RxNormAPIs.html).\n\nFor example, to find the rxnormcui based on drug name, you can use: https://rxnav.nlm.nih.gov/REST/rxcui.json?name=leucovorin or https://mor.nlm.nih.gov/RxNav/search?searchBy=String&searchTerm=leucovorin",
+ "validationDependency": true,
+ "dependsOn": "hormone_therapy.drug_rxnormcui",
+ "notes": "This field uses standardized vocabulary from the RxNorm database (https://www.nlm.nih.gov/research/umls/rxnorm), provided by the NIH.\n\nYou can search for RX Norm values through the web interface (https://mor.nlm.nih.gov/RxNav/) or API (https://mor.nlm.nih.gov/download/rxnav/RxNormAPIs.html).\n\nFor example, to find the rxnormcui based on drug name, you can use: https://rxnav.nlm.nih.gov/REST/rxcui.json?name=leucovorin or https://mor.nlm.nih.gov/RxNav/search?searchBy=String&searchTerm=leucovorin. \n\nIf the drugs don't exist in RxNorm, please indicate drug_database, drug_id and drug_term where the drugs information can be found.",
"displayName": "Hormone Therapy Drug Name"
},
"restrictions": {
- "required": true
+ "script": "#/script/common/drugDatabase"
+ }
+ },
+ {
+ "name": "drug_database",
+ "description": "Indicate the drug database where drug term is found.",
+ "valueType": "string",
+ "meta": {
+ "core": true,
+ "validationDependency": true,
+ "dependsOn": "hormone_therapy.drug_rxnormcui",
+ "notes": "If the drugs don't exist in RxNorm, please indicate drug_database, drug_id and drug_term where the drugs information can be found.",
+ "displayName": "Drug Database"
+ },
+ "restrictions": {
+ "script": "#/script/common/drugDatabase",
+ "codeList": "#/list/drug_database"
+ }
+ },
+ {
+ "name": "drug_id",
+ "description": "Indicate the identifier from the drug_database for the drug.",
+ "valueType": "string",
+ "meta": {
+ "core": true,
+ "validationDependency": true,
+ "dependsOn": "hormone_therapy.drug_rxnormcui",
+ "notes": "If the drugs don't exist in RxNorm, please indicate drug_database, drug_id and drug_term where the drugs information can be found.",
+ "displayName": "Drug ID"
+ },
+ "restrictions": {
+ "script": "#/script/common/drugDatabase"
+ }
+ },
+ {
+ "name": "drug_term",
+ "description": "Indicate the drug term as it exists in the database specified in the drug_database.",
+ "valueType": "string",
+ "meta": {
+ "core": true,
+ "validationDependency": true,
+ "dependsOn": "hormone_therapy.drug_rxnormcui",
+ "notes": "If the drugs don't exist in RxNorm, please indicate drug_database, drug_id and drug_term where the drugs information can be found.",
+ "displayName": "Drug Term"
+ },
+ "restrictions": {
+ "script": "#/script/common/drugDatabase"
}
},
{
diff --git a/schemas/immunotherapy.json b/schemas/immunotherapy.json
index 9fe1b3a..cd412b1 100644
--- a/schemas/immunotherapy.json
+++ b/schemas/immunotherapy.json
@@ -72,13 +72,14 @@
"description": "The unique RxNormID assigned to the treatment regimen drug.",
"valueType": "string",
"meta": {
- "validationDependency": true,
"core": true,
- "notes": "This field uses standardized vocabulary from the RxNorm database (https://www.nlm.nih.gov/research/umls/rxnorm), provided by the NIH.\n\nYou can search for RX Norm values through the web interface (https://mor.nlm.nih.gov/RxNav/) or API (https://mor.nlm.nih.gov/download/rxnav/RxNormAPIs.html).\n\nFor example, to find the rxnormcui based on drug name, you can use: https://rxnav.nlm.nih.gov/REST/rxcui.json?name=leucovorin or https://mor.nlm.nih.gov/RxNav/search?searchBy=String&searchTerm=leucovorin",
+ "validationDependency": true,
+ "dependsOn": "immunotherapy.drug_database",
+ "notes": "This field uses standardized vocabulary from the RxNorm database (https://www.nlm.nih.gov/research/umls/rxnorm), provided by the NIH.\n\nYou can search for RX Norm values through the web interface (https://mor.nlm.nih.gov/RxNav/) or API (https://mor.nlm.nih.gov/download/rxnav/RxNormAPIs.html).\n\nFor example, to find the rxnormcui based on drug name, you can use: https://rxnav.nlm.nih.gov/REST/rxcui.json?name=leucovorin or https://mor.nlm.nih.gov/RxNav/search?searchBy=String&searchTerm=leucovorin. \n\nIf the drugs don't exist in RxNorm, please indicate drug_database, drug_id and drug_term where the drugs information can be found.",
"displayName": "RxNormCUI"
},
"restrictions": {
- "required": true
+ "script": "#/script/common/drugDatabase"
}
},
{
@@ -86,13 +87,60 @@
"description": "Name of agent or drug administered to donor as part of the treatment regimen.",
"valueType": "string",
"meta": {
+ "core": true,
"validationDependency": true,
+ "dependsOn": "immunotherapy.drug_rxnormcui",
+ "notes": "This field uses standardized vocabulary from the RxNorm database (https://www.nlm.nih.gov/research/umls/rxnorm), provided by the NIH.\n\nYou can search for RX Norm values through the web interface (https://mor.nlm.nih.gov/RxNav/) or API (https://mor.nlm.nih.gov/download/rxnav/RxNormAPIs.html).\n\nFor example, to find the rxnormcui based on drug name, you can use: https://rxnav.nlm.nih.gov/REST/rxcui.json?name=leucovorin or https://mor.nlm.nih.gov/RxNav/search?searchBy=String&searchTerm=leucovorin. \n\nIf the drugs don't exist in RxNorm, please indicate drug_database, drug_id and drug_term where the drugs information can be found.",
+ "displayName": "Chemotherapy Drug Name"
+ },
+ "restrictions": {
+ "script": "#/script/common/drugDatabase"
+ }
+ },
+ {
+ "name": "drug_database",
+ "description": "Indicate the drug database where drug term is found.",
+ "valueType": "string",
+ "meta": {
"core": true,
- "notes": "This field uses standardized vocabulary from the RxNorm database (https://www.nlm.nih.gov/research/umls/rxnorm), provided by the NIH.\n\nYou can search for RX Norm values through the web interface (https://mor.nlm.nih.gov/RxNav/) or API (https://mor.nlm.nih.gov/download/rxnav/RxNormAPIs.html).\n\nFor example, to find the rxnormcui based on drug name, you can use: https://rxnav.nlm.nih.gov/REST/rxcui.json?name=leucovorin or https://mor.nlm.nih.gov/RxNav/search?searchBy=String&searchTerm=leucovorin",
- "displayName": "Immunotherapy Drug Name"
+ "validationDependency": true,
+ "dependsOn": "immunotherapy.drug_rxnormcui",
+ "notes": "If the drugs don't exist in RxNorm, please indicate drug_database, drug_id and drug_term where the drugs information can be found.",
+ "displayName": "Drug Database"
},
"restrictions": {
- "required": true
+ "script": "#/script/common/drugDatabase",
+ "codeList": "#/list/drug_database"
+ }
+ },
+ {
+ "name": "drug_id",
+ "description": "Indicate the identifier from the drug_database for the drug.",
+ "valueType": "string",
+ "meta": {
+ "core": true,
+ "validationDependency": true,
+ "dependsOn": "immunotherapy.drug_rxnormcui",
+ "notes": "If the drugs don't exist in RxNorm, please indicate drug_database, drug_id and drug_term where the drugs information can be found.",
+ "displayName": "Drug ID"
+ },
+ "restrictions": {
+ "script": "#/script/common/drugDatabase"
+ }
+ },
+ {
+ "name": "drug_term",
+ "description": "Indicate the drug term as it exists in the database specified in the drug_database.",
+ "valueType": "string",
+ "meta": {
+ "core": true,
+ "validationDependency": true,
+ "dependsOn": "immunotherapy.drug_rxnormcui",
+ "notes": "If the drugs don't exist in RxNorm, please indicate drug_database, drug_id and drug_term where the drugs information can be found.",
+ "displayName": "Drug Term"
+ },
+ "restrictions": {
+ "script": "#/script/common/drugDatabase"
}
},
{
diff --git a/schemas/treatment.json b/schemas/treatment.json
index ded341b..ba7fcc7 100644
--- a/schemas/treatment.json
+++ b/schemas/treatment.json
@@ -126,10 +126,7 @@
"description": "The interval between the primary diagnosis and initiation of treatment, in days.",
"valueType": "integer",
"restrictions": {
- "script": "#/script/treatment/checkWhenNoTreatment",
- "range": {
- "exclusiveMin": 0
- }
+ "script": "#/script/treatment/checkWhenNoTreatment"
},
"meta": {
"core": true,
diff --git a/tests/common/drugDatabase.test.js b/tests/common/drugDatabase.test.js
new file mode 100644
index 0000000..9880c68
--- /dev/null
+++ b/tests/common/drugDatabase.test.js
@@ -0,0 +1,567 @@
+/*
+ * Copyright (c) 2024 The Ontario Institute for Cancer Research. All rights reserved
+ *
+ * This program and the accompanying materials are made available under the terms of the GNU Affero General Public License v3.0.
+ * You should have received a copy of the GNU Affero General Public License along with
+ * this program. If not, see .
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+ * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ */
+
+const validation = require('./../../references/validationFunctions/common/drugDatabase.js');
+const universalTest = require('../universal');
+const loadObjects = require('../loadObjects');
+
+// load in all fields with entries prepopulated to null
+const dummy = require('../constructDummyData');
+const chemotherapy = require('../constructDummyData').getSchemaDummy('chemotherapy');
+const immunotherapy = require('../constructDummyData').getSchemaDummy('immunotherapy');
+const hormone_therapy = require('../constructDummyData').getSchemaDummy('hormone_therapy');
+// the name of the field being validateds
+
+const unitTests = {
+ 'Chemotherapy': [
+ [
+ 'drug_rxnormcui & drug_name are provided, drug_database, drug_id, drug_term are blank.',
+ true,
+ {
+ row: loadObjects(chemotherapy, {
+ drug_rxnormcui: '6313',
+ drug_name: 'leucovorin',
+ drug_database: ' ',
+ drug_id: undefined,
+ drug_term: null
+ }),
+ name: 'drug_rxnormcui',
+ },
+ ],
+ [
+ 'drug_rxnormcui & drug_name are not provided, drug_database, drug_id, drug_term are provided.',
+ true,
+ {
+ row: loadObjects(chemotherapy, {
+ drug_rxnormcui: '',
+ drug_name: ' ',
+ drug_database: 'KEGG',
+ drug_id: '123',
+ drug_term: 'test'
+ }),
+ name: 'drug_rxnormcui',
+ },
+ ],
+ [
+ 'drug_rxnormcui is provided, drug_name is blank.',
+ false,
+ {
+ row: loadObjects(chemotherapy, {
+ drug_rxnormcui: '6313',
+ drug_name: ''
+ }),
+ name: 'drug_rxnormcui',
+ },
+ ],
+ [
+ 'drug_rxnormcui is not provided, drug_name is not blank.',
+ false,
+ {
+ row: loadObjects(chemotherapy, {
+ drug_rxnormcui: ' ',
+ drug_name: 'leucovorin'
+ }),
+ name: 'drug_rxnormcui',
+ },
+ ],
+ [
+ 'drug_rxnormcui & drug_name are provided, drug_database, drug_id, drug_term are not blank.',
+ false,
+ {
+ row: loadObjects(chemotherapy, {
+ drug_rxnormcui: '6313',
+ drug_name: 'leucovorin',
+ drug_database: 'KEGG',
+ drug_id: '123',
+ drug_term: 'S-1'
+ }),
+ name: 'drug_rxnormcui',
+ },
+ ],
+ [
+ 'drug_rxnormcui is provided, drug_name is blank.',
+ false,
+ {
+ row: loadObjects(chemotherapy, {
+ drug_rxnormcui: '6313',
+ drug_name: ''
+ }),
+ name: 'drug_name',
+ },
+ ],
+ [
+ 'drug_rxnormcui is not provided, drug_name is not blank.',
+ false,
+ {
+ row: loadObjects(chemotherapy, {
+ drug_rxnormcui: ' ',
+ drug_name: 'leucovorin'
+ }),
+ name: 'drug_name',
+ },
+ ],
+ [
+ 'drug_rxnormcui & drug_name are provided, drug_database, drug_id, drug_term are not blank.',
+ false,
+ {
+ row: loadObjects(chemotherapy, {
+ drug_rxnormcui: '6313',
+ drug_name: 'leucovorin',
+ drug_database: 'KEGG',
+ drug_id: '123',
+ drug_term: 'S-1'
+ }),
+ name: 'drug_database',
+ },
+ ],
+ [
+ 'drug_rxnormcui & drug_name are not provided, drug_database, drug_id, drug_term are blank.',
+ false,
+ {
+ row: loadObjects(chemotherapy, {
+ drug_rxnormcui: '',
+ drug_name: ' ',
+ drug_database: ''
+ }),
+ name: 'drug_database',
+ },
+ ],
+ [
+ 'drug_rxnormcui & drug_name are provided, drug_database, drug_id, drug_term are not blank.',
+ false,
+ {
+ row: loadObjects(chemotherapy, {
+ drug_rxnormcui: '6313',
+ drug_name: 'leucovorin',
+ drug_database: 'KEGG',
+ drug_id: '123',
+ drug_term: 'S-1'
+ }),
+ name: 'drug_id',
+ },
+ ],
+ [
+ 'drug_rxnormcui & drug_name are provided, drug_database, drug_id, drug_term are not blank.',
+ false,
+ {
+ row: loadObjects(chemotherapy, {
+ drug_rxnormcui: null,
+ drug_name: ' ',
+ drug_id: ' '
+ }),
+ name: 'drug_id',
+ },
+ ],
+ [
+ 'drug_rxnormcui & drug_name are provided, drug_database, drug_id, drug_term are not blank.',
+ false,
+ {
+ row: loadObjects(chemotherapy, {
+ drug_rxnormcui: '6313',
+ drug_name: 'leucovorin',
+ drug_database: 'KEGG',
+ drug_id: '123',
+ drug_term: 'S-1'
+ }),
+ name: 'drug_term',
+ },
+ ],
+ [
+ 'drug_rxnormcui & drug_name are not provided, drug_database, drug_id, drug_term are blank.',
+ false,
+ {
+ row: loadObjects(chemotherapy, {
+ drug_rxnormcui: '',
+ drug_name: '',
+ drug_term: null
+ }),
+ name: 'drug_term',
+ },
+ ]
+ ],
+ 'Hormone Therapy': [
+ [
+ 'drug_rxnormcui & drug_name are provided, drug_database, drug_id, drug_term are blank.',
+ true,
+ {
+ row: loadObjects(hormone_therapy, {
+ drug_rxnormcui: '6313',
+ drug_name: 'leucovorin',
+ drug_database: null,
+ drug_id: ' ',
+ drug_term: ''
+ }),
+ name: 'drug_rxnormcui',
+ },
+ ],
+ [
+ 'drug_rxnormcui & drug_name are not provided, drug_database, drug_id, drug_term are provided.',
+ true,
+ {
+ row: loadObjects(hormone_therapy, {
+ drug_rxnormcui: '',
+ drug_name: ' ',
+ drug_database: 'KEGG',
+ drug_id: '123',
+ drug_term: 'test'
+ }),
+ name: 'drug_rxnormcui',
+ },
+ ],
+ [
+ 'drug_rxnormcui is provided, drug_name is blank.',
+ false,
+ {
+ row: loadObjects(hormone_therapy, {
+ drug_rxnormcui: '6313',
+ drug_name: ''
+ }),
+ name: 'drug_rxnormcui',
+ },
+ ],
+ [
+ 'drug_rxnormcui is not provided, drug_name is not blank.',
+ false,
+ {
+ row: loadObjects(hormone_therapy, {
+ drug_rxnormcui: ' ',
+ drug_name: 'leucovorin'
+ }),
+ name: 'drug_rxnormcui',
+ },
+ ],
+ [
+ 'drug_rxnormcui & drug_name are provided, drug_database, drug_id, drug_term are not blank.',
+ false,
+ {
+ row: loadObjects(hormone_therapy, {
+ drug_rxnormcui: '6313',
+ drug_name: 'leucovorin',
+ drug_database: 'KEGG',
+ drug_id: '123',
+ drug_term: 'S-1'
+ }),
+ name: 'drug_rxnormcui',
+ },
+ ],
+ [
+ 'drug_rxnormcui is provided, drug_name is blank.',
+ false,
+ {
+ row: loadObjects(hormone_therapy, {
+ drug_rxnormcui: '6313',
+ drug_name: ''
+ }),
+ name: 'drug_name',
+ },
+ ],
+ [
+ 'drug_rxnormcui is not provided, drug_name is not blank.',
+ false,
+ {
+ row: loadObjects(hormone_therapy, {
+ drug_rxnormcui: ' ',
+ drug_name: 'leucovorin'
+ }),
+ name: 'drug_name',
+ },
+ ],
+ [
+ 'drug_rxnormcui & drug_name are provided, drug_database, drug_id, drug_term are not blank.',
+ false,
+ {
+ row: loadObjects(hormone_therapy, {
+ drug_rxnormcui: '6313',
+ drug_name: 'leucovorin',
+ drug_database: 'KEGG',
+ drug_id: '123',
+ drug_term: 'S-1'
+ }),
+ name: 'drug_database',
+ },
+ ],
+ [
+ 'drug_rxnormcui & drug_name are not provided, drug_database, drug_id, drug_term are blank.',
+ false,
+ {
+ row: loadObjects(hormone_therapy, {
+ drug_rxnormcui: '',
+ drug_name: ' ',
+ drug_database: ''
+ }),
+ name: 'drug_database',
+ },
+ ],
+ [
+ 'drug_rxnormcui & drug_name are provided, drug_database, drug_id, drug_term are not blank.',
+ false,
+ {
+ row: loadObjects(hormone_therapy, {
+ drug_rxnormcui: '6313',
+ drug_name: 'leucovorin',
+ drug_database: 'KEGG',
+ drug_id: '123',
+ drug_term: 'S-1'
+ }),
+ name: 'drug_id',
+ },
+ ],
+ [
+ 'drug_rxnormcui & drug_name are not provided, drug_database, drug_id, drug_term are blank.',
+ false,
+ {
+ row: loadObjects(hormone_therapy, {
+ drug_rxnormcui: null,
+ drug_name: ' ',
+ drug_id: ' '
+ }),
+ name: 'drug_id',
+ },
+ ],
+ [
+ 'drug_rxnormcui & drug_name are provided, drug_database, drug_id, drug_term are not blank.',
+ false,
+ {
+ row: loadObjects(hormone_therapy, {
+ drug_rxnormcui: '6313',
+ drug_name: 'leucovorin',
+ drug_database: 'KEGG',
+ drug_id: '123',
+ drug_term: 'S-1'
+ }),
+ name: 'drug_term',
+ },
+ ],
+ [
+ 'drug_rxnormcui & drug_name are not provided, drug_database, drug_id, drug_term are blank.',
+ false,
+ {
+ row: loadObjects(hormone_therapy, {
+ drug_rxnormcui: '',
+ drug_name: '',
+ drug_term: null
+ }),
+ name: 'drug_term',
+ },
+ ]
+ ],
+ 'Immunotherapy': [
+ [
+ 'drug_rxnormcui & drug_name are provided, drug_database, drug_id, drug_term are blank.',
+ true,
+ {
+ row: loadObjects(immunotherapy, {
+ drug_rxnormcui: '6313',
+ drug_name: 'leucovorin',
+ drug_database: null,
+ drug_id: ' ',
+ drug_term: ''
+ }),
+ name: 'drug_rxnormcui',
+ },
+ ],
+ [
+ 'drug_rxnormcui & drug_name are not provided, drug_database, drug_id, drug_term are provided.',
+ true,
+ {
+ row: loadObjects(immunotherapy, {
+ drug_rxnormcui: '',
+ drug_name: ' ',
+ drug_database: 'KEGG',
+ drug_id: '123',
+ drug_term: 'test'
+ }),
+ name: 'drug_rxnormcui',
+ },
+ ],
+ [
+ 'drug_rxnormcui is provided, drug_name is blank.',
+ false,
+ {
+ row: loadObjects(immunotherapy, {
+ drug_rxnormcui: '6313',
+ drug_name: ''
+ }),
+ name: 'drug_rxnormcui',
+ },
+ ],
+ [
+ 'drug_rxnormcui is not provided, drug_name is not blank.',
+ false,
+ {
+ row: loadObjects(immunotherapy, {
+ drug_rxnormcui: ' ',
+ drug_name: 'leucovorin'
+ }),
+ name: 'drug_rxnormcui',
+ },
+ ],
+ [
+ 'drug_rxnormcui & drug_name are provided, drug_database, drug_id, drug_term are not blank.',
+ false,
+ {
+ row: loadObjects(immunotherapy, {
+ drug_rxnormcui: '6313',
+ drug_name: 'leucovorin',
+ drug_database: 'KEGG',
+ drug_id: '123',
+ drug_term: 'S-1'
+ }),
+ name: 'drug_rxnormcui',
+ },
+ ],
+ [
+ 'drug_rxnormcui is provided, drug_name is blank.',
+ false,
+ {
+ row: loadObjects(immunotherapy, {
+ drug_rxnormcui: '6313',
+ drug_name: ''
+ }),
+ name: 'drug_name',
+ },
+ ],
+ [
+ 'drug_rxnormcui is not provided, drug_name is not blank.',
+ false,
+ {
+ row: loadObjects(immunotherapy, {
+ drug_rxnormcui: ' ',
+ drug_name: 'leucovorin'
+ }),
+ name: 'drug_name',
+ },
+ ],
+ [
+ 'drug_rxnormcui & drug_name are provided, drug_database, drug_id, drug_term are not blank.',
+ false,
+ {
+ row: loadObjects(immunotherapy, {
+ drug_rxnormcui: '6313',
+ drug_name: 'leucovorin',
+ drug_database: 'KEGG',
+ drug_id: '123',
+ drug_term: 'S-1'
+ }),
+ name: 'drug_database',
+ },
+ ],
+ [
+ 'drug_rxnormcui & drug_name are not provided, drug_database, drug_id, drug_term are blank.',
+ false,
+ {
+ row: loadObjects(immunotherapy, {
+ drug_rxnormcui: '',
+ drug_name: ' ',
+ drug_database: ''
+ }),
+ name: 'drug_database',
+ },
+ ],
+ [
+ 'drug_rxnormcui & drug_name are provided, drug_database, drug_id, drug_term are not blank.',
+ false,
+ {
+ row: loadObjects(immunotherapy, {
+ drug_rxnormcui: '6313',
+ drug_name: 'leucovorin',
+ drug_database: 'KEGG',
+ drug_id: '123',
+ drug_term: 'S-1'
+ }),
+ name: 'drug_id',
+ },
+ ],
+ [
+ 'drug_rxnormcui & drug_name are not provided, drug_database, drug_id, drug_term are blank.',
+ false,
+ {
+ row: loadObjects(immunotherapy, {
+ drug_rxnormcui: null,
+ drug_name: ' ',
+ drug_id: ' '
+ }),
+ name: 'drug_id',
+ },
+ ],
+ [
+ 'drug_rxnormcui & drug_name are provided, drug_database, drug_id, drug_term are not blank.',
+ false,
+ {
+ row: loadObjects(immunotherapy, {
+ drug_rxnormcui: '6313',
+ drug_name: 'leucovorin',
+ drug_database: 'KEGG',
+ drug_id: '123',
+ drug_term: 'S-1'
+ }),
+ name: 'drug_term',
+ },
+ ],
+ [
+ 'drug_rxnormcui & drug_name are not provided, drug_database, drug_id, drug_term are blank.',
+ false,
+ {
+ row: loadObjects(immunotherapy, {
+ drug_rxnormcui: '',
+ drug_name: '',
+ drug_term: null
+ }),
+ name: 'drug_term',
+ },
+ ]
+ ]
+};
+
+describe('Common Tests', () => {
+ Object.entries(unitTests).forEach(schema => {
+ schema[1].forEach(testSuite => {
+ const testIndex = 2;
+ const testInputs = testSuite[testIndex];
+ universalTest(validation()({$row: testInputs, $name: name, $field: testInputs[name]}));
+ });
+ });
+});
+
+
+describe('Unit Tests for Drug Database script', () => {
+ // Using .each to reduce repetition. Each array entry is its own test.
+ // Entry 0: Used as test description
+ // Entry 1: The target result.
+ // Entry 2: The object containing the inputs to the validate function.
+
+ // the index for accessing the name of the type of unit tests what will run
+ const nameIndex = 0;
+ // the index for accessing the array of arrays that hold the test information
+ const testsIndex = 1;
+
+ Object.entries(unitTests).forEach(schema => {
+ describe(`${schema[nameIndex]} Tests`, () => {
+ test.each(schema[testsIndex])(
+ '\n Test %# : %s \nExpecting result.valid to be: %s',
+ (description, target, inputs) => {
+ const scriptOutput = validation()({ $row: inputs.row, $name: inputs.name, $field: inputs.row[inputs.name]});
+
+ expect(scriptOutput.valid).toBe(target);
+ },
+ );
+ });
+ });
+});