From fd14b5d4edd0d74c18365e5f342591612d419202 Mon Sep 17 00:00:00 2001 From: Anthony Brown <121869075+anthony-nhs@users.noreply.github.com> Date: Thu, 25 Apr 2024 14:47:56 +0000 Subject: [PATCH 1/3] trigger build From e31aa2f0abe39be9f242a79be385d2828ca0053c Mon Sep 17 00:00:00 2001 From: Anthony Brown <121869075+anthony-nhs@users.noreply.github.com> Date: Thu, 25 Apr 2024 15:46:36 +0000 Subject: [PATCH 2/3] safe get for array --- packages/updatePrescriptionStatus/src/validation/fields.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/updatePrescriptionStatus/src/validation/fields.ts b/packages/updatePrescriptionStatus/src/validation/fields.ts index 75cd83103..1bec77133 100644 --- a/packages/updatePrescriptionStatus/src/validation/fields.ts +++ b/packages/updatePrescriptionStatus/src/validation/fields.ts @@ -22,7 +22,7 @@ export function taskFields(task: Task): Array { (t: Task) => (t.focus?.identifier?.value ? undefined : "LineItemID"), (t: Task) => (t.for?.identifier?.value ? undefined : "PatientNHSNumber"), (t: Task) => (t.owner?.identifier?.value ? undefined : "PharmacyODSCode"), - (t: Task) => (t.basedOn?.[0].identifier?.value ? undefined : "PrescriptionID"), + (t: Task) => (t.basedOn?.[0]?.identifier?.value ? undefined : "PrescriptionID"), (t: Task) => (t.businessStatus?.coding?.[0].code ? undefined : "Status"), (t: Task) => (t.id ? undefined : "TaskID"), (t: Task) => (t.status ? undefined : "TerminalStatus") From ac51a65d572de7281a260db18fd00052f76b2531 Mon Sep 17 00:00:00 2001 From: Anthony Brown <121869075+anthony-nhs@users.noreply.github.com> Date: Fri, 26 Apr 2024 06:53:42 +0000 Subject: [PATCH 3/3] fix other missing array --- .../updatePrescriptionStatus/src/validation/fields.ts | 2 +- .../tests/validation/testRequestFieldValidation.test.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/updatePrescriptionStatus/src/validation/fields.ts b/packages/updatePrescriptionStatus/src/validation/fields.ts index 1bec77133..594d7179c 100644 --- a/packages/updatePrescriptionStatus/src/validation/fields.ts +++ b/packages/updatePrescriptionStatus/src/validation/fields.ts @@ -23,7 +23,7 @@ export function taskFields(task: Task): Array { (t: Task) => (t.for?.identifier?.value ? undefined : "PatientNHSNumber"), (t: Task) => (t.owner?.identifier?.value ? undefined : "PharmacyODSCode"), (t: Task) => (t.basedOn?.[0]?.identifier?.value ? undefined : "PrescriptionID"), - (t: Task) => (t.businessStatus?.coding?.[0].code ? undefined : "Status"), + (t: Task) => (t.businessStatus?.coding?.[0]?.code ? undefined : "Status"), (t: Task) => (t.id ? undefined : "TaskID"), (t: Task) => (t.status ? undefined : "TerminalStatus") ] diff --git a/packages/updatePrescriptionStatus/tests/validation/testRequestFieldValidation.test.ts b/packages/updatePrescriptionStatus/tests/validation/testRequestFieldValidation.test.ts index 0364fc3ee..ca43fd3a5 100644 --- a/packages/updatePrescriptionStatus/tests/validation/testRequestFieldValidation.test.ts +++ b/packages/updatePrescriptionStatus/tests/validation/testRequestFieldValidation.test.ts @@ -74,6 +74,14 @@ describe("Unit tests for validation of individual fields", () => { { missingField: "TaskID", operation: (t: Task) => delete t.id + }, + { + missingField: "PrescriptionID", + operation: (t: Task) => (t.basedOn = []) + }, + { + missingField: "Status", + operation: (t: Task) => (t.businessStatus = {coding: []}) } ])("When $missingField is missing, should return expected issue.", async ({operation, missingField}) => { const task = validTask()