Skip to content

Commit

Permalink
Merge pull request #411 from icgc-argo/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
hknahal committed Aug 25, 2023
2 parents d586d5b + 742f767 commit 05e1adf
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 7 deletions.
23 changes: 17 additions & 6 deletions references/validationFunctions/chemotherapy/drugDose.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,23 @@ const validation = () =>

// checks for a string just consisting of whitespace
const checkforEmpty = (entry) => {return /^\s+$/g.test(decodeURI(entry).replace(/^"(.*)"$/, '$1'))};

if ( (!$field || $field === null || checkforEmpty($field)) && (!($row[checkField]) || $row[checkField] === null || checkforEmpty(!($row[checkField])))) {
result = {
valid: false,
message: `Either the 'actual_cumulative_drug_dose' or the 'prescribed_cumulative_drug_dose' fields must be submitted.`
};

// Check for when chemotherapy dose has a clinical exception value of 'not applicable'
if ($row.chemotherapy_drug_dose_units && $row.chemotherapy_drug_dose_units != null && !(checkforEmpty($row.chemotherapy_drug_dose_units)) && $row.chemotherapy_drug_dose_units.trim().toLowerCase() === 'not applicable') {
if ($field && $field != null && !(checkforEmpty($field))) {
result = {
valid: false,
message: `The '${$name}' field cannot be submitted when 'chemotherapy_drug_dose_units' = 'Not applicable'`
};
}
}
else {
if ( (!$field || $field === null || checkforEmpty($field)) && (!($row[checkField]) || $row[checkField] === null || checkforEmpty(!($row[checkField])))) {
result = {
valid: false,
message: `Either the 'actual_cumulative_drug_dose' or the 'prescribed_cumulative_drug_dose' fields must be submitted.`
};
}
}
return result;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const validation = () =>
const {$row, $name, $field} = inputs;
let result = {valid: true, message: "Ok"};

const notExamined = ['cannot be determined', 'no', 'no lymph nodes found in resected specimen', 'not applicable'];
const notExamined = ['cannot be determined', 'no', 'no lymph nodes found in resected specimen', 'not applicable', 'unknown'];
/* checks for a string just consisting of whitespace */
const checkforEmpty = (entry) => {return /^\s+$/g.test(decodeURI(entry).replace(/^"(.*)"$/, '$1'))};

Expand Down
6 changes: 6 additions & 0 deletions references/validationFunctions/specimen/tumourGrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ const validation = () =>
case 'nuclear grading system for dcis':
codeList = tieredGradingList;
break;
case 'unknown':
codeList = ['unknown'];
break;
case 'not applicable':
codeList = ['not applicable'];
break;
}

if (!codeList.includes($field.trim().toLowerCase())) {
Expand Down
2 changes: 2 additions & 0 deletions schemas/chemotherapy.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
"meta": {
"core": true,
"displayName": "Prescribed Cumulative Drug Dose",
"validationDependency": true,
"dependsOn": "chemotherapy.actual_cumulative_drug_dose",
"notes": "Either the 'actual_cumulative_drug_dose' or the 'prescribed_cumulative_drug_dose' field must be submitted."
}
Expand All @@ -120,6 +121,7 @@
"meta": {
"core": true,
"displayName": "Actual Cumulative Drug Dose",
"validationDependency": true,
"dependsOn": "chemotherapy.prescribed_cumulative_drug_dose",
"notes": "Either the 'actual_cumulative_drug_dose' or the 'prescribed_cumulative_drug_dose' field must be submitted."
}
Expand Down
38 changes: 38 additions & 0 deletions tests/chemotherapy/drugDose.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,25 @@ const myUnitTests = {
"prescribed_cumulative_drug_dose": 350
}
)
],
[
'chemotherapy_drug_dose_units is not applicable and actual_cumulative_drug_dose is submitted',
false,
loadObjects(chemotherapy,
{
"chemotherapy_drug_dose_units": 'not applicable',
"actual_cumulative_drug_dose": 300,
}
)
],
[
'chemotherapy_drug_dose_units is not applicable and actual_cumulative_drug_dose is not submitted',
true,
loadObjects(chemotherapy,
{
"chemotherapy_drug_dose_units": 'not applicable'
}
)
]
],
'prescribed_cumulative_drug_dose': [
Expand Down Expand Up @@ -88,6 +107,25 @@ const myUnitTests = {
}
)
],
[
'chemotherapy_drug_dose_units is not applicable and prescribed_cumulative_drug_dose is submitted',
false,
loadObjects(chemotherapy,
{
"chemotherapy_drug_dose_units": 'not applicable',
"prescribed_cumulative_drug_dose": 350
}
)
],
[
'chemotherapy_drug_dose_units is not applicable and prescribed_cumulative_drug_dose is not submitted',
true,
loadObjects(chemotherapy,
{
"chemotherapy_drug_dose_units": 'not applicable'
}
)
],
[
'Both cumulative_drug_dose and prescribed_cumulative_drug_dose are missing',
false,
Expand Down
20 changes: 20 additions & 0 deletions tests/primary_diagnosis/lymphNodesExaminedMethod.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,26 @@ const myUnitTests = {
}
)
],
[
'lymph nodes examined status is unknown and lymph_nodes_examined_method is left blank',
true,
loadObjects(primary_diagnosis,
{
"lymph_nodes_examined_status": "Unknown",
"lymph_nodes_examined_method": ""
}
)
],
[
'lymph nodes examined status is unknown and lymph_nodes_examined_method is submitted',
false,
loadObjects(primary_diagnosis,
{
"lymph_nodes_examined_status": "Unknown",
"lymph_nodes_examined_method": "Imaging"
}
)
],
[
'lymph nodes were examined and lymph_nodes_examined_method not submitted',
false,
Expand Down
16 changes: 16 additions & 0 deletions tests/specimen/tumourGrade.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,22 @@ const unitTests = [
tumour_grade: 'g4'
}),
],
[
'tumour_grading_system has an exception value of "not applicable", while tumour_grade is submitted as "G3"',
false,
loadObjects(specimen, {
tumour_grading_system: 'Not applicable',
tumour_grade: 'G3',
}),
],
[
'tumour_grading_system has an exception value of "unknown", while tumour_grade is submitted as "G2"',
false,
loadObjects(specimen, {
tumour_grading_system: 'unknown',
tumour_grade: 'G2',
}),
],
// [
// 'both grade system and grade are undefined',
// false,
Expand Down

0 comments on commit 05e1adf

Please sign in to comment.