-
Notifications
You must be signed in to change notification settings - Fork 334
(fix) O3-4115: Add patient to list button missing from search results in service queues #1526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ import { type PatientSearchConfig } from '../../../config-schema'; | |
| import { type FHIRPatientType, type SearchedPatient } from '../../../types'; | ||
| import { PatientSearchContext } from '../../../patient-search-context'; | ||
| import styles from './patient-banner.scss'; | ||
| import StartVisitConfirmationModal from './start-visit-confirmation.modal'; | ||
|
|
||
| interface ClickablePatientContainerProps { | ||
| children: React.ReactNode; | ||
|
|
@@ -54,11 +55,29 @@ const PatientBanner: React.FC<PatientBannerProps> = ({ patient, patientUuid, hid | |
| const isDeceased = !!patient.person.deathDate; | ||
|
|
||
| const [showContactDetails, setShowContactDetails] = useState(false); | ||
| const [showStartVisitConfirmationModal, setStartVisitConfirmationModal] = useState(false); | ||
|
|
||
| const handleToggleContactDetails = useCallback(() => { | ||
| setShowContactDetails((value) => !value); | ||
| }, []); | ||
|
|
||
| const handleAddToQueueClick = () => { | ||
| if (!currentVisit && !isDeceased) { | ||
| setStartVisitConfirmationModal(true); | ||
| } else { | ||
| nonNavigationSelectPatientAction(patientUuid); | ||
| } | ||
| }; | ||
|
|
||
| const handleStartVisit = () => { | ||
| setStartVisitConfirmationModal(false); | ||
| nonNavigationSelectPatientAction(patientUuid); | ||
| }; | ||
|
|
||
| const handleCloseModal = () => { | ||
| setStartVisitConfirmationModal(false); | ||
| }; | ||
|
|
||
| const fhirMappedPatient: FHIRPatientType = useMemo(() => { | ||
| const preferredAddress = patient.person.addresses?.find((address) => address.preferred); | ||
| const addressId = uuidv4(); | ||
|
|
@@ -140,13 +159,10 @@ const PatientBanner: React.FC<PatientBannerProps> = ({ patient, patientUuid, hid | |
| patientUuid={patientUuid} | ||
| /> | ||
| ) : null} | ||
| {!isDeceased && !currentVisit && ( | ||
| <ExtensionSlot | ||
| name="start-visit-button-slot" | ||
| state={{ | ||
| patientUuid, | ||
| }} | ||
| /> | ||
| {!isDeceased && ( | ||
| <button onClick={handleAddToQueueClick} className={`${styles.addToQueueButton} ${styles.primary}`}> | ||
| Add patient to queue | ||
| </button> | ||
|
||
| )} | ||
| </div> | ||
| </div> | ||
|
|
@@ -162,6 +178,14 @@ const PatientBanner: React.FC<PatientBannerProps> = ({ patient, patientUuid, hid | |
| )} | ||
| </div> | ||
| </div> | ||
|
|
||
| {showStartVisitConfirmationModal && ( | ||
| <StartVisitConfirmationModal | ||
| closeModal={handleCloseModal} | ||
| startVisit={handleStartVisit} | ||
| patientName={patientName} | ||
| /> | ||
| )} | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import React from 'react'; | ||
| import { useTranslation } from 'react-i18next'; | ||
| import { Modal, Button } from '@carbon/react'; | ||
|
||
| import styles from './start-visit-confirmation.scss'; | ||
|
|
||
| interface StartVisitConfirmationModalProps { | ||
| closeModal: () => void; | ||
| startVisit: () => void; | ||
| patientName: string; | ||
| } | ||
|
|
||
| const StartVisitConfirmationModal: React.FC<StartVisitConfirmationModalProps> = ({ | ||
| closeModal, | ||
| startVisit, | ||
| patientName, | ||
| }) => { | ||
| const { t } = useTranslation(); | ||
|
|
||
| return ( | ||
| <Modal | ||
| open | ||
| danger | ||
| modalHeading={t('startVisitModalHeading', 'Start Visit?')} | ||
| primaryButtonText={t('startVisitButton', 'Start Visit')} | ||
| secondaryButtonText={t('cancel', 'Cancel')} | ||
| onRequestClose={closeModal} | ||
| onRequestSubmit={startVisit}> | ||
| <p> | ||
| {t( | ||
| 'startVisitMessage', | ||
| 'You must start a visit for {{name}} before adding them to the Queue list. Do you want to start a visit now?', | ||
| { name: patientName }, | ||
| )} | ||
| </p> | ||
| </Modal> | ||
| ); | ||
| }; | ||
|
|
||
| export default StartVisitConfirmationModal; | ||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.