Skip to content

Commit

Permalink
Amend diagnostic messages for the validation failures
Browse files Browse the repository at this point in the history
  • Loading branch information
kris-szlapa committed May 29, 2024
1 parent 1f37f50 commit 60f1472
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
10 changes: 8 additions & 2 deletions packages/updatePrescriptionStatus/src/validation/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,15 @@ export function statuses(task: Task): string | undefined {
const lowercaseCode = code.toLowerCase()

if (status === "completed" && IN_PROGRESS_BUSINESS_STATUSES.includes(lowercaseCode)) {
return "Completed state indicated for a prescription status requiring patient action."
return (
"Task.status field set to 'completed' but Task.businessStatus value of '" + code + "' requires follow up action."
)
} else if (status === "in-progress" && COMPLETED_BUSINESS_STATUSES.includes(lowercaseCode)) {
return "In-progress state indicated for a prescription status that should be completed."
return (
"Task.status field set to 'in-progress' but Task.businessStatus value of '" +
code +
"' has no possible follow up action."
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,32 +220,38 @@ describe("Unit tests for validation of status against business status", () => {
generateTestCase(
"completed",
"With Pharmacy",
"Completed state indicated for a prescription status requiring patient action."
"Task.status field set to 'completed' but Task.businessStatus value of 'With Pharmacy' " +
"requires follow up action."
),
generateTestCase(
"completed",
"With Pharmacy - preparing remainder",
"Completed state indicated for a prescription status requiring patient action."
"Task.status field set to 'completed' but Task.businessStatus value of 'With Pharmacy - preparing remainder' " +
"requires follow up action."
),
generateTestCase(
"completed",
"Ready to collect",
"Completed state indicated for a prescription status requiring patient action."
"Task.status field set to 'completed' but Task.businessStatus value of 'Ready to collect' " +
"requires follow up action."
),
generateTestCase(
"completed",
"ReAdY tO cOlLeCt",
"Completed state indicated for a prescription status requiring patient action."
"Task.status field set to 'completed' but Task.businessStatus value of 'ReAdY tO cOlLeCt' " +
"requires follow up action."
),
generateTestCase(
"completed",
"Ready to collect - partial",
"Completed state indicated for a prescription status requiring patient action."
"Task.status field set to 'completed' but Task.businessStatus value of 'Ready to collect - partial' " +
"requires follow up action."
),
generateTestCase(
"completed",
"rEaDy To ColLEcT - pArtIAl",
"Completed state indicated for a prescription status requiring patient action."
"Task.status field set to 'completed' but Task.businessStatus value of 'rEaDy To ColLEcT - pArtIAl' " +
"requires follow up action."
),
generateTestCase("in-progress", "With Pharmacy", undefined),
generateTestCase("in-progress", "With Pharmacy - preparing remainder", undefined),
Expand All @@ -254,17 +260,20 @@ describe("Unit tests for validation of status against business status", () => {
generateTestCase(
"in-progress",
"Collected",
"In-progress state indicated for a prescription status that should be completed."
"Task.status field set to 'in-progress' but Task.businessStatus value of 'Collected' " +
"has no possible follow up action."
),
generateTestCase(
"in-progress",
"Not dispensed",
"In-progress state indicated for a prescription status that should be completed."
"Task.status field set to 'in-progress' but Task.businessStatus value of 'Not dispensed' " +
"has no possible follow up action."
),
generateTestCase(
"in-progress",
"Dispatched",
"In-progress state indicated for a prescription status that should be completed."
"Task.status field set to 'in-progress' but Task.businessStatus value of 'Dispatched' " +
"has no possible follow up action."
),
generateTestCase("completed", "Collected", undefined),
generateTestCase("completed", "Not dispensed", undefined),
Expand Down

0 comments on commit 60f1472

Please sign in to comment.