@kenyaemr/esm-express-workflow-app 5.4.5-pre.621 → 5.4.5-pre.625

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,10 +17,9 @@ interface EnhancedPatientBannerPatientInfoProps {
17
17
  eligibilityData?: EligibilityResponse;
18
18
  isEligibilityLoading?: boolean;
19
19
  crNumber?: string;
20
+ isVerified?: boolean;
20
21
  }
21
22
 
22
- type Gender = 'female' | 'male';
23
-
24
23
  const GENDER_ICONS = {
25
24
  Female: <GenderFemale />,
26
25
  Male: <GenderMale />,
@@ -49,6 +48,7 @@ export const EnhancedPatientBannerPatientInfo: React.FC<EnhancedPatientBannerPat
49
48
  eligibilityData,
50
49
  isEligibilityLoading = false,
51
50
  crNumber,
51
+ isVerified,
52
52
  }) => {
53
53
  const { t } = useTranslation();
54
54
  const name = getPatientName(patient);
@@ -72,7 +72,7 @@ export const EnhancedPatientBannerPatientInfo: React.FC<EnhancedPatientBannerPat
72
72
  <div className={styles.patientInfo}>
73
73
  <div className={classNames(styles.row, styles.patientNameRow)}>
74
74
  <div className={styles.flexRow}>
75
- <span className={styles.patientName}>{maskName(name)}</span>
75
+ <span className={styles.patientName}>{isVerified ? name : maskName(name)}</span>
76
76
 
77
77
  {genderInfo && (
78
78
  <div className={styles.gender}>
@@ -0,0 +1,80 @@
1
+ import React from 'react';
2
+ import { render, screen } from '@testing-library/react';
3
+ import '@testing-library/jest-dom';
4
+ import { beforeEach, describe, expect, test, vi } from 'vitest';
5
+ import { getEligibilityTags } from '../helper';
6
+ import { EnhancedPatientBannerPatientInfo } from './patient-banner.component';
7
+
8
+ vi.mock('@openmrs/esm-framework', () => ({
9
+ age: vi.fn(() => '34 years'),
10
+ formatDate: vi.fn(() => '15 Jul 1992'),
11
+ getPatientName: vi.fn(() => 'Jane Wanjiku Doe'),
12
+ parseDate: vi.fn((date: string) => new Date(date)),
13
+ ExtensionSlot: () => null,
14
+ }));
15
+
16
+ vi.mock('react-i18next', () => ({
17
+ useTranslation: () => ({ t: (_key: string, fallback: string) => fallback }),
18
+ }));
19
+
20
+ vi.mock('../helper', () => ({
21
+ getEligibilityTags: vi.fn(),
22
+ maskName: vi.fn(() => 'J*** W****** D**'),
23
+ }));
24
+
25
+ const mockGetEligibilityTags = vi.mocked(getEligibilityTags);
26
+
27
+ describe('EnhancedPatientBannerPatientInfo', () => {
28
+ const patient: fhir.Patient = {
29
+ resourceType: 'Patient',
30
+ id: 'patient-uuid',
31
+ gender: 'female',
32
+ birthDate: '1992-07-15',
33
+ name: [{ given: ['Jane', 'Wanjiku'], family: 'Doe' }],
34
+ };
35
+
36
+ beforeEach(() => {
37
+ vi.clearAllMocks();
38
+ mockGetEligibilityTags.mockReturnValue([]);
39
+ });
40
+
41
+ test('protects an unverified patient identity while showing identifying demographics', () => {
42
+ render(<EnhancedPatientBannerPatientInfo patient={patient} crNumber="CR-1234" />);
43
+
44
+ expect(screen.getByText('J*** W****** D**')).toBeInTheDocument();
45
+ expect(screen.queryByText('Jane Wanjiku Doe')).not.toBeInTheDocument();
46
+ expect(screen.getByText('Female')).toBeInTheDocument();
47
+ expect(screen.getByText('34 years')).toBeInTheDocument();
48
+ expect(screen.getByText('15 Jul 1992')).toBeInTheDocument();
49
+ expect(screen.getByText('CR Number: CR-1234')).toBeInTheDocument();
50
+ });
51
+
52
+ test('reveals the patient identity after verification', () => {
53
+ render(<EnhancedPatientBannerPatientInfo patient={patient} isVerified />);
54
+
55
+ expect(screen.getByText('Jane Wanjiku Doe')).toBeInTheDocument();
56
+ expect(screen.queryByText('J*** W****** D**')).not.toBeInTheDocument();
57
+ expect(screen.getByText('CR Number: --')).toBeInTheDocument();
58
+ });
59
+
60
+ test('tells the user when the eligibility check is in progress', () => {
61
+ render(<EnhancedPatientBannerPatientInfo patient={patient} eligibilityData={{} as never} isEligibilityLoading />);
62
+
63
+ expect(screen.getByText('Checking eligibility...')).toBeInTheDocument();
64
+ expect(screen.queryByText('SHIF | Eligible')).not.toBeInTheDocument();
65
+ });
66
+
67
+ test('shows the patient eligibility results after the check completes', () => {
68
+ const eligibilityData = {} as never;
69
+ mockGetEligibilityTags.mockReturnValue([
70
+ { text: 'SHIF | Eligible', type: 'green' },
71
+ { text: 'UHC | Not Eligible', type: 'red' },
72
+ ]);
73
+
74
+ render(<EnhancedPatientBannerPatientInfo patient={patient} eligibilityData={eligibilityData} />);
75
+
76
+ expect(screen.getByText('SHIF | Eligible')).toBeInTheDocument();
77
+ expect(screen.getByText('UHC | Not Eligible')).toBeInTheDocument();
78
+ expect(screen.queryByText('Checking eligibility...')).not.toBeInTheDocument();
79
+ });
80
+ });
@@ -61,7 +61,6 @@
61
61
  "call": "Call",
62
62
  "cancel": "Cancel",
63
63
  "cannotStartVisitCoverageExhausted": "One or more selected interventions have exhausted their coverage limit. Remove them to proceed.",
64
- "careAuthorization": "Care Authorizations",
65
64
  "carePanel": "Care Panel",
66
65
  "Cervical Dilation": "",
67
66
  "Cervix data saved successfully": "",
@@ -61,7 +61,6 @@
61
61
  "call": "Call",
62
62
  "cancel": "Cancel",
63
63
  "cannotStartVisitCoverageExhausted": "One or more selected interventions have exhausted their coverage limit. Remove them to proceed.",
64
- "careAuthorization": "Care Authorizations",
65
64
  "carePanel": "Care Panel",
66
65
  "Cervical Dilation": "",
67
66
  "Cervix data saved successfully": "",
@@ -61,7 +61,6 @@
61
61
  "call": "Appeler",
62
62
  "cancel": "Annuler",
63
63
  "cannotStartVisitCoverageExhausted": "One or more selected interventions have exhausted their coverage limit. Remove them to proceed.",
64
- "careAuthorization": "Autorisations de soins",
65
64
  "carePanel": "Panneau de soins",
66
65
  "Cervical Dilation": "Dilatation cervicale",
67
66
  "Cervix data saved successfully": "Les données du col ont été enregistrées avec succès",
@@ -61,7 +61,6 @@
61
61
  "call": "Call",
62
62
  "cancel": "Cancel",
63
63
  "cannotStartVisitCoverageExhausted": "One or more selected interventions have exhausted their coverage limit. Remove them to proceed.",
64
- "careAuthorization": "Care Authorizations",
65
64
  "carePanel": "Care Panel",
66
65
  "Cervical Dilation": "",
67
66
  "Cervix data saved successfully": "",