From 9b102020dce861236124b7cc9a7d57e57d93fac2 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 12 Aug 2025 18:35:31 +0100 Subject: [PATCH] feat: add edit mode for changing exception status and remove unused --- .../participantInformationPanel.tsx | 22 +++++-------------- .../src/Web/app/lib/utils.test.ts | 15 ------------- .../CohortManager/src/Web/app/lib/utils.ts | 4 ---- .../[exceptionId]/page.tsx | 15 ++++++++----- 4 files changed, 15 insertions(+), 41 deletions(-) diff --git a/application/CohortManager/src/Web/app/components/participantInformationPanel.tsx b/application/CohortManager/src/Web/app/components/participantInformationPanel.tsx index 7f9cf5682e..1fb394c933 100644 --- a/application/CohortManager/src/Web/app/components/participantInformationPanel.tsx +++ b/application/CohortManager/src/Web/app/components/participantInformationPanel.tsx @@ -3,27 +3,28 @@ import { formatDate, formatCompactDate, formatNhsNumber, - formatPhoneNumber, formatGenderValue, } from "@/app/lib/utils"; interface ParticipantInformationPanelProps { readonly exceptionDetails: ExceptionDetails; + readonly isEditMode: boolean; } export default function ParticipantInformationPanel({ exceptionDetails, + isEditMode, }: Readonly) { return ( <>
- {!exceptionDetails.serviceNowId && ( + {(!exceptionDetails.serviceNowId || isEditMode) && ( Portal form: Request to amend incorrect patient PDS record data @@ -80,17 +81,6 @@ export default function ParticipantInformationPanel({ {exceptionDetails.address}
-
-
Contact details
-
-

- {formatPhoneNumber( - exceptionDetails.contactDetails?.phoneNumber ?? "" - )} -

-

{exceptionDetails.contactDetails?.email}

-
-
Registered practice code @@ -135,10 +125,10 @@ export default function ParticipantInformationPanel({
- {exceptionDetails.serviceNowId ? null : ( + {!isEditMode ? null : (
-

Exception status

+

Exception status

Entering a ServiceNow case ID will change the status of the exception to “Raised”.
diff --git a/application/CohortManager/src/Web/app/lib/utils.test.ts b/application/CohortManager/src/Web/app/lib/utils.test.ts index fc36d64eab..919bb982d2 100644 --- a/application/CohortManager/src/Web/app/lib/utils.test.ts +++ b/application/CohortManager/src/Web/app/lib/utils.test.ts @@ -2,7 +2,6 @@ import { formatNhsNumber, formatDate, formatCompactDate, - formatPhoneNumber, getCurrentDate, formatGenderValue, } from "@/app/lib/utils"; @@ -37,20 +36,6 @@ describe("formatCompactDate", () => { }); }); -describe("formatPhoneNumber", () => { - it("should format the phone number as XXXXX XXX XXX", () => { - const input = "01619999999"; - const expectedOutput = "01619 999 999"; - expect(formatPhoneNumber(input)).toBe(expectedOutput); - }); - - it("should return the input if it is not a valid phone number", () => { - const input = "12345"; - const expectedOutput = "12345"; - expect(formatPhoneNumber(input)).toBe(expectedOutput); - }); -}); - describe("getCurrentDate", () => { it("should return the current date in the format YYYY-MM-DD", () => { const date = new Date(); diff --git a/application/CohortManager/src/Web/app/lib/utils.ts b/application/CohortManager/src/Web/app/lib/utils.ts index b34ffd975f..544b67fc75 100644 --- a/application/CohortManager/src/Web/app/lib/utils.ts +++ b/application/CohortManager/src/Web/app/lib/utils.ts @@ -25,10 +25,6 @@ export const formatCompactDate = (dateString: string): string => { return date.toLocaleDateString("en-GB", options); }; -export const formatPhoneNumber = (phoneNumber: string): string => { - return phoneNumber.replace(/(\d{5})(\d{3})(\d{3})/, "$1 $2 $3"); -}; - export function getCurrentDate(): string { const date = new Date(); const year = date.getFullYear(); diff --git a/application/CohortManager/src/Web/app/participant-information/[exceptionId]/page.tsx b/application/CohortManager/src/Web/app/participant-information/[exceptionId]/page.tsx index baf1d2e4b1..92d4a2dfa1 100644 --- a/application/CohortManager/src/Web/app/participant-information/[exceptionId]/page.tsx +++ b/application/CohortManager/src/Web/app/participant-information/[exceptionId]/page.tsx @@ -17,6 +17,7 @@ export default async function Page(props: { readonly params: Promise<{ readonly exceptionId: string; }>; + readonly searchParams?: Promise<{ readonly edit?: string }>; }) { const session = await auth(); const isCohortManager = await canAccessCohortManager(session); @@ -27,6 +28,10 @@ export default async function Page(props: { const params = await props.params; const exceptionId = Number(params.exceptionId); + const resolvedSearchParams = props.searchParams + ? await props.searchParams + : {}; + const isEditMode = resolvedSearchParams.edit === "true"; try { const exception = await fetchExceptions(exceptionId); @@ -58,10 +63,6 @@ export default async function Page(props: { ? `, ${exception.ExceptionDetails.ParticipantAddressLine5}` : "" }, ${exception.ExceptionDetails.ParticipantPostCode}`, - contactDetails: { - phoneNumber: exception.ExceptionDetails.TelephoneNumberHome, - email: exception.ExceptionDetails.EmailAddressHome, - }, primaryCareProvider: exception.ExceptionDetails.PrimaryCareProvider, serviceNowId: exception.ServiceNowId ?? "", serviceNowCreatedDate: exception.ServiceNowCreatedDate, @@ -94,7 +95,7 @@ export default async function Page(props: { Local reference (exception ID): {exceptionDetails.exceptionId} - {exceptionDetails.serviceNowId && ( + {exceptionDetails.serviceNowId && !isEditMode && (

- + Change{" "} ServiceNow Case ID + {isEditMode} @@ -160,6 +162,7 @@ export default async function Page(props: { )}