diff --git a/packages/updatePrescriptionStatus/src/validation/fields.ts b/packages/updatePrescriptionStatus/src/validation/fields.ts index 75cd83103..594d7179c 100644 --- a/packages/updatePrescriptionStatus/src/validation/fields.ts +++ b/packages/updatePrescriptionStatus/src/validation/fields.ts @@ -22,8 +22,8 @@ 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.businessStatus?.coding?.[0].code ? undefined : "Status"), + (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") ] 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()