Skip to content

Commit

Permalink
Merge pull request #410 from icgc-argo/409_chemo_dose_exception
Browse files Browse the repository at this point in the history
409 chemo dose exception
  • Loading branch information
hknahal authored Aug 3, 2023
2 parents 19daa6c + 540c7fa commit 742f767
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 6 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
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

0 comments on commit 742f767

Please sign in to comment.