Skip to content

Commit 65bcbfe

Browse files
committed
[AEA-5926] tweaks content for patient banner
1 parent a4f63fe commit 65bcbfe

File tree

6 files changed

+63
-41
lines changed

6 files changed

+63
-41
lines changed

packages/cpt-ui/__tests__/BasicDetailsSearchResultsPage.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,8 @@ describe("BasicDetailsSearchResultsPage", () => {
328328
renderWithRouter()
329329

330330
await waitFor(() => {
331-
expect(screen.getAllByText(STRINGS.NOT_AVAILABLE)[0]).toBeInTheDocument()
332-
expect(screen.getAllByText(STRINGS.NOT_AVAILABLE)[1]).toBeInTheDocument()
331+
expect(screen.getAllByText(STRINGS.NOT_ON_RECORD)[0]).toBeInTheDocument()
332+
expect(screen.getAllByText(STRINGS.NOT_ON_RECORD)[1]).toBeInTheDocument()
333333
expect(screen.getByText("123 Brundel Close, Headingley, Leeds, West Yorkshire")).toBeInTheDocument()
334334
expect(screen.getByText("LS6 1JL")).toBeInTheDocument()
335335
})
@@ -364,7 +364,7 @@ describe("BasicDetailsSearchResultsPage", () => {
364364
renderWithRouter()
365365

366366
await waitFor(() => {
367-
expect(screen.getAllByText(STRINGS.NOT_AVAILABLE)).toHaveLength(4)
367+
expect(screen.getAllByText(STRINGS.NOT_ON_RECORD)).toHaveLength(4)
368368
})
369369
})
370370

packages/cpt-ui/__tests__/PatientDetailsBanner.test.tsx

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ describe("PatientDetailsBanner", () => {
6767
expect(screen.getByTestId("patient-details-banner").className).not.toMatch(/patient-details-partial-data/)
6868
})
6969

70-
it("renders partial patient details with missing data message", async () => {
70+
it("renders partial patient details with missing data message when pds call fails", async () => {
7171
render(
7272
<MockPatientDetailsProvider patientDetails={{nhsNumber: "5900009890"}} patientFallback={true}>
7373
<PatientDetailsBanner />
@@ -79,22 +79,44 @@ describe("PatientDetailsBanner", () => {
7979
})
8080

8181
// Minimum details returned is just NHS Number
82-
expect(screen.getByTestId("patient-details-banner-name")).toHaveTextContent(STRINGS.UNKNOWN)
83-
expect(
84-
screen.getByTestId("patient-details-banner-gender")).toHaveTextContent(`${STRINGS.GENDER}: ${STRINGS.UNKNOWN}`)
85-
expect(
86-
screen.getByTestId("patient-details-banner-nhsNumber")).toHaveTextContent(`${STRINGS.NHS_NUMBER}: 590 000 9890`)
87-
expect(
88-
screen.getByTestId("patient-details-banner-dob")).toHaveTextContent(`${STRINGS.DOB}: ${STRINGS.UNKNOWN}`)
89-
expect(
90-
screen.getByTestId("patient-details-banner-address")).toHaveTextContent(`${STRINGS.ADDRESS}: ${STRINGS.UNKNOWN}`)
82+
expect(screen.getByTestId("patient-details-banner-name")).toHaveTextContent(STRINGS.NOT_AVAILABLE)
83+
expect(screen.getByTestId("patient-details-banner-gender")).toHaveTextContent(
84+
`${STRINGS.GENDER}: ${STRINGS.NOT_AVAILABLE}`)
85+
expect(screen.getByTestId("patient-details-banner-nhsNumber")).toHaveTextContent(
86+
`${STRINGS.NHS_NUMBER}: 590 000 9890`)
87+
expect(screen.getByTestId("patient-details-banner-dob")).toHaveTextContent(
88+
`${STRINGS.DOB}: ${STRINGS.NOT_AVAILABLE}`)
89+
expect(screen.getByTestId("patient-details-banner-address")).toHaveTextContent(
90+
`${STRINGS.ADDRESS}: ${STRINGS.NOT_AVAILABLE}`)
9191

9292
// The missing data message should be rendered.
9393
expect(screen.getByTestId("patient-detail-banner-incomplete")).toBeInTheDocument()
9494
expect(screen.getByTestId("patient-detail-banner-incomplete")).toHaveTextContent(STRINGS.MISSING_DATA)
95+
})
9596

96-
// The banner should now have the class for partial data.
97-
expect(screen.getByTestId("patient-details-banner").className).toMatch(/patient-details-partial-data/)
97+
// eslint-disable-next-line max-len
98+
it("does not render the missing data message when details are completed from prescription details after a pds failure", async () => {
99+
render(
100+
<MockPatientDetailsProvider
101+
patientDetails={{
102+
nhsNumber: "5900009890",
103+
givenName: ["William"],
104+
familyName: "Wolderton",
105+
gender: "male",
106+
dateOfBirth: "1988-11-01",
107+
address: ["55 Oak Street", "OAK LANE", "Leeds"],
108+
postcode: "LS1 1XX"
109+
}}
110+
patientFallback={true}>
111+
<PatientDetailsBanner />
112+
</MockPatientDetailsProvider>
113+
)
114+
115+
await waitFor(() => {
116+
expect(screen.getByTestId("patient-details-banner")).toBeInTheDocument()
117+
})
118+
119+
expect(screen.queryByTestId("patient-detail-banner-incomplete")).not.toBeInTheDocument()
98120
})
99121

100122
it("renders not available content for fields when pds record has missing data", async () => {
@@ -116,15 +138,15 @@ describe("PatientDetailsBanner", () => {
116138
expect(screen.getByTestId("patient-details-banner")).toBeInTheDocument()
117139
})
118140

119-
expect(screen.getByTestId("patient-details-banner-name")).toHaveTextContent(STRINGS.NAME_NOT_AVAILABLE)
141+
expect(screen.getByTestId("patient-details-banner-name")).toHaveTextContent(STRINGS.NAME_NOT_ON_RECORD)
120142
expect(screen.getByTestId("patient-details-banner-gender")).toHaveTextContent(
121-
`${STRINGS.GENDER}: ${STRINGS.NOT_AVAILABLE}`)
143+
`${STRINGS.GENDER}: ${STRINGS.NOT_ON_RECORD}`)
122144
expect(screen.getByTestId("patient-details-banner-nhsNumber")).toHaveTextContent(
123145
`${STRINGS.NHS_NUMBER}: 590 000 9890`)
124146
expect(screen.getByTestId("patient-details-banner-dob")).toHaveTextContent(
125-
`${STRINGS.DOB}: ${STRINGS.NOT_AVAILABLE}`)
147+
`${STRINGS.DOB}: ${STRINGS.NOT_ON_RECORD}`)
126148
expect(screen.getByTestId("patient-details-banner-address")).toHaveTextContent(
127-
`${STRINGS.ADDRESS}: ${STRINGS.NOT_AVAILABLE}`)
149+
`${STRINGS.ADDRESS}: ${STRINGS.NOT_ON_RECORD}`)
128150

129151
// // Verify that the missing data message is not rendered
130152
expect(screen.queryByTestId("patient-detail-banner-incomplete")).not.toBeInTheDocument()
@@ -152,7 +174,7 @@ describe("PatientDetailsBanner", () => {
152174
expect(screen.getByTestId("patient-details-banner")).toBeInTheDocument()
153175
})
154176

155-
expect(screen.getByTestId("patient-details-banner-name")).toHaveTextContent(STRINGS.NAME_NOT_AVAILABLE)
177+
expect(screen.getByTestId("patient-details-banner-name")).toHaveTextContent(STRINGS.NAME_NOT_ON_RECORD)
156178
})
157179

158180
it("renders patient details correctly when family name is missing from the pds record", async () => {
@@ -174,7 +196,7 @@ describe("PatientDetailsBanner", () => {
174196
expect(screen.getByTestId("patient-details-banner")).toBeInTheDocument()
175197
})
176198

177-
expect(screen.getByTestId("patient-details-banner-name")).toHaveTextContent(STRINGS.NAME_NOT_AVAILABLE)
199+
expect(screen.getByTestId("patient-details-banner-name")).toHaveTextContent(STRINGS.NAME_NOT_ON_RECORD)
178200
})
179201

180202
it("renders patient details correctly when name is temporary", async () => {

packages/cpt-ui/src/components/PatientDetailsBanner.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import {DOB_FORMAT, NHS_NUMBER_FORMAT_REGEX} from "@/constants/misc"
99

1010
export default function PatientDetailsBanner() {
1111
const emptyPatientDetailsText = {
12-
name: STRINGS.UNKNOWN,
13-
gender: STRINGS.UNKNOWN,
12+
name: STRINGS.NOT_AVAILABLE,
13+
gender: STRINGS.NOT_AVAILABLE,
1414
nhsNumber: "",
15-
dob: STRINGS.UNKNOWN,
16-
address: STRINGS.UNKNOWN
15+
dob: STRINGS.NOT_AVAILABLE,
16+
address: STRINGS.NOT_AVAILABLE
1717
}
1818

1919
const [patientDetailsText, setPatientDetailsText] = useState(emptyPatientDetailsText)
@@ -31,7 +31,7 @@ export default function PatientDetailsBanner() {
3131
const patientDetailsText = structuredClone(emptyPatientDetailsText)
3232
if (patientDetails.givenName && patientDetails.familyName) {
3333
if (patientDetails.givenName === NOT_AVAILABLE || patientDetails.familyName === NOT_AVAILABLE) {
34-
patientDetailsText.name = STRINGS.NAME_NOT_AVAILABLE
34+
patientDetailsText.name = STRINGS.NAME_NOT_ON_RECORD
3535
} else {
3636
patientDetailsText.name =
3737
`${patientDetails.givenName.filter(Boolean).join(" ")} ${patientDetails.familyName.toLocaleUpperCase()}${
@@ -40,20 +40,20 @@ export default function PatientDetailsBanner() {
4040
}
4141

4242
if (patientDetails.gender) {
43-
patientDetailsText.gender = patientDetails.gender === NOT_AVAILABLE ? STRINGS.NOT_AVAILABLE :
43+
patientDetailsText.gender = patientDetails.gender === NOT_AVAILABLE ? STRINGS.NOT_ON_RECORD :
4444
`${patientDetails.gender.charAt(0).toUpperCase()}${patientDetails.gender.slice(1)}`
4545
}
4646

4747
patientDetailsText.nhsNumber = patientDetails.nhsNumber.replace(NHS_NUMBER_FORMAT_REGEX, "$1 $2 $3")
4848

4949
if (patientDetails.dateOfBirth) {
50-
patientDetailsText.dob = patientDetails.dateOfBirth === NOT_AVAILABLE ? STRINGS.NOT_AVAILABLE :
50+
patientDetailsText.dob = patientDetails.dateOfBirth === NOT_AVAILABLE ? STRINGS.NOT_ON_RECORD :
5151
format(new Date(patientDetails.dateOfBirth), DOB_FORMAT)
5252
}
5353

5454
if (patientDetails.address && patientDetails.postcode) {
5555
if (patientDetails.address === NOT_AVAILABLE && patientDetails.postcode === NOT_AVAILABLE) {
56-
patientDetailsText.address = STRINGS.NOT_AVAILABLE
56+
patientDetailsText.address = STRINGS.NOT_ON_RECORD
5757
} else {
5858
const addressParts: Array<string> = []
5959
if (patientDetails.address !== NOT_AVAILABLE){
@@ -78,7 +78,7 @@ export default function PatientDetailsBanner() {
7878

7979
return (
8080
<div
81-
className={`patient-details-banner ${patientFallback ? "patient-details-partial-data" : ""}`}
81+
className={"patient-details-banner"}
8282
data-testid="patient-details-banner">
8383
<div className={"patient-detail-banner-row"}>
8484
<div
@@ -93,7 +93,7 @@ export default function PatientDetailsBanner() {
9393
</div>
9494
{
9595
// Places the missing data message on the next line
96-
patientFallback && (
96+
(patientFallback && Object.values(patientDetailsText).some((v) => v === STRINGS.NOT_AVAILABLE)) && (
9797
<div
9898
className="patient-detail-banner-row"
9999
data-testid="patient-detail-banner-incomplete">
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
export const STRINGS = {
2-
UNKNOWN: "Unavailable",
3-
NOT_AVAILABLE: "Not on patient record",
4-
NAME_NOT_AVAILABLE: "Name not on patient record",
2+
NOT_AVAILABLE: "Not available",
3+
NOT_ON_RECORD: "Not on patient record",
4+
NAME_NOT_ON_RECORD: "Name not on patient record",
55
GENDER: "Gender",
66
NHS_NUMBER: "NHS number",
77
DOB: "Date of birth",
88
ADDRESS: "Address",
9-
MISSING_DATA: "Some information is unavailable right now. It may help to refresh the page or try again later.",
9+
MISSING_DATA: "Some information is not available. Refresh the page or try again later.",
1010
TEMPORARY: " (temporary)"
1111
}

packages/cpt-ui/src/helpers/formatters.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export function formatDobForDisplay({
6060
dobMonth,
6161
dobYear
6262
}: Pick<BasicDetailsSearchType, "dobDay" | "dobMonth" | "dobYear">): string {
63-
if (!dobDay || !dobMonth || !dobYear) return STRINGS.UNKNOWN
63+
if (!dobDay || !dobMonth || !dobYear) return STRINGS.NOT_AVAILABLE
6464

6565
const day = dobDay.padStart(2, "0")
6666
const monthIndex = parseInt(dobMonth, 10) - 1
@@ -74,7 +74,7 @@ export function formatDobForDisplay({
7474
*/
7575
export const formatDobTextForDisplay = (dobText: string): string => {
7676
const date = parseDate(dobText)
77-
return date ? formatDate(date) : STRINGS.UNKNOWN
77+
return date ? formatDate(date) : STRINGS.NOT_AVAILABLE
7878
}
7979

8080
export function formatMessageDateTime(isoDateString: string): string {

packages/cpt-ui/src/pages/BasicDetailsSearchResultsPage.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,23 @@ const TableResultsRow = ({patient}: TableResultsRowProps) => {
3939
const searchContext = useSearchContext()
4040
const navigationContext = useNavigationContext()
4141

42-
let nameText = STRINGS.NOT_AVAILABLE
42+
let nameText = STRINGS.NOT_ON_RECORD
4343
if (patient.givenName !== NOT_AVAILABLE && patient.familyName !== NOT_AVAILABLE) {
4444
nameText = `${patient.givenName?.filter(Boolean).join(" ")} ${patient.familyName}${
4545
patient.nameUse === PatientNameUse.TEMP ? STRINGS.TEMPORARY : ""}`
4646
}
4747

4848
const nhsNumberText = patient.nhsNumber.replace(NHS_NUMBER_FORMAT_REGEX, "$1 $2 $3")
4949

50-
const genderText = patient.gender === NOT_AVAILABLE ? STRINGS.NOT_AVAILABLE :
50+
const genderText = patient.gender === NOT_AVAILABLE ? STRINGS.NOT_ON_RECORD :
5151
`${patient.gender?.charAt(0).toUpperCase()}${patient.gender?.slice(1)}`
5252

53-
const dobText = patient.dateOfBirth === NOT_AVAILABLE ? STRINGS.NOT_AVAILABLE :
53+
const dobText = patient.dateOfBirth === NOT_AVAILABLE ? STRINGS.NOT_ON_RECORD :
5454
format(new Date(patient.dateOfBirth as string), DOB_FORMAT)
5555

5656
let addressText
5757
if (patient.address === NOT_AVAILABLE && patient.postcode === NOT_AVAILABLE) {
58-
addressText = STRINGS.NOT_AVAILABLE
58+
addressText = STRINGS.NOT_ON_RECORD
5959
} else {
6060
const addressParts: Array<string> = []
6161
if (patient.address !== NOT_AVAILABLE){

0 commit comments

Comments
 (0)