Skip to content

Commit 0cb2ba4

Browse files
author
jwnasambu
committed
fix/O3-4115: Add patient to list button missing from search results in service queues
1 parent e5d056c commit 0cb2ba4

File tree

2 files changed

+70
-7
lines changed

2 files changed

+70
-7
lines changed

packages/esm-patient-search-app/src/patient-search-page/patient-banner/banner/patient-banner.component.tsx

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { type PatientSearchConfig } from '../../../config-schema';
1818
import { type FHIRPatientType, type SearchedPatient } from '../../../types';
1919
import { PatientSearchContext } from '../../../patient-search-context';
2020
import styles from './patient-banner.scss';
21+
import StartVisitConfirmationModal from './start-visit-confirmation.modal';
2122

2223
interface ClickablePatientContainerProps {
2324
children: React.ReactNode;
@@ -54,11 +55,29 @@ const PatientBanner: React.FC<PatientBannerProps> = ({ patient, patientUuid, hid
5455
const isDeceased = !!patient.person.deathDate;
5556

5657
const [showContactDetails, setShowContactDetails] = useState(false);
58+
const [showStartVisitConfirmationModal, setStartVisitConfirmationModal] = useState(false);
5759

5860
const handleToggleContactDetails = useCallback(() => {
5961
setShowContactDetails((value) => !value);
6062
}, []);
6163

64+
const handleAddToQueueClick = () => {
65+
if (!currentVisit && !isDeceased) {
66+
setStartVisitConfirmationModal(true);
67+
} else {
68+
nonNavigationSelectPatientAction(patientUuid);
69+
}
70+
};
71+
72+
const handleStartVisit = () => {
73+
setStartVisitConfirmationModal(false);
74+
nonNavigationSelectPatientAction(patientUuid);
75+
};
76+
77+
const handleCloseModal = () => {
78+
setStartVisitConfirmationModal(false);
79+
};
80+
6281
const fhirMappedPatient: FHIRPatientType = useMemo(() => {
6382
const preferredAddress = patient.person.addresses?.find((address) => address.preferred);
6483
const addressId = uuidv4();
@@ -140,13 +159,10 @@ const PatientBanner: React.FC<PatientBannerProps> = ({ patient, patientUuid, hid
140159
patientUuid={patientUuid}
141160
/>
142161
) : null}
143-
{!isDeceased && !currentVisit && (
144-
<ExtensionSlot
145-
name="start-visit-button-slot"
146-
state={{
147-
patientUuid,
148-
}}
149-
/>
162+
{!isDeceased && (
163+
<button onClick={handleAddToQueueClick} className={`${styles.addToQueueButton} ${styles.primary}`}>
164+
Add patient to queue
165+
</button>
150166
)}
151167
</div>
152168
</div>
@@ -162,6 +178,14 @@ const PatientBanner: React.FC<PatientBannerProps> = ({ patient, patientUuid, hid
162178
)}
163179
</div>
164180
</div>
181+
182+
{showStartVisitConfirmationModal && (
183+
<StartVisitConfirmationModal
184+
closeModal={handleCloseModal}
185+
startVisit={handleStartVisit}
186+
patientName={patientName}
187+
/>
188+
)}
165189
</>
166190
);
167191
};
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React from 'react';
2+
import { useTranslation } from 'react-i18next';
3+
import { Modal, Button } from '@carbon/react';
4+
import styles from './start-visit-confirmation.scss';
5+
6+
interface StartVisitConfirmationModalProps {
7+
closeModal: () => void;
8+
startVisit: () => void;
9+
patientName: string;
10+
}
11+
12+
const StartVisitConfirmationModal: React.FC<StartVisitConfirmationModalProps> = ({
13+
closeModal,
14+
startVisit,
15+
patientName,
16+
}) => {
17+
const { t } = useTranslation();
18+
19+
return (
20+
<Modal
21+
open
22+
danger
23+
modalHeading={t('startVisitModalHeading', 'Start Visit?')}
24+
primaryButtonText={t('startVisitButton', 'Start Visit')}
25+
secondaryButtonText={t('cancel', 'Cancel')}
26+
onRequestClose={closeModal}
27+
onRequestSubmit={startVisit}>
28+
<p>
29+
{t(
30+
'startVisitMessage',
31+
'You must start a visit for {{name}} before adding them to the Queue list. Do you want to start a visit now?',
32+
{ name: patientName },
33+
)}
34+
</p>
35+
</Modal>
36+
);
37+
};
38+
39+
export default StartVisitConfirmationModal;

0 commit comments

Comments
 (0)