@@ -18,6 +18,7 @@ import { type PatientSearchConfig } from '../../../config-schema';
1818import { type FHIRPatientType , type SearchedPatient } from '../../../types' ;
1919import { PatientSearchContext } from '../../../patient-search-context' ;
2020import styles from './patient-banner.scss' ;
21+ import StartVisitConfirmationModal from './start-visit-confirmation.modal' ;
2122
2223interface 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} ;
0 commit comments