Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


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();
Expand Down Expand Up @@ -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>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<Button 
  onClick={} 
  kind="primary" 
  className={}
>
  {t('addPatientToQueue', 'Add patient to queue')}
</Button>
  • import { Button } from '@carbon/react';

Copy link
Contributor Author

@jwnasambu jwnasambu Mar 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Muppasanipraneeth, thanks for the review! However, based on @denniskigen's advice during the coffee break, the discussion about this implementation is still ongoing and there is a likelihood the changes may be required or not. He suggested that I use a normal button for now to help the team gain a clearer understanding of the requirements. Additionally, if I were to implement the button, I believe I would use a button slot rather than the button imported from Carbon.

)}
</div>
</div>
Expand All @@ -162,6 +178,14 @@ const PatientBanner: React.FC<PatientBannerProps> = ({ patient, patientUuid, hid
)}
</div>
</div>

{showStartVisitConfirmationModal && (
<StartVisitConfirmationModal
closeModal={handleCloseModal}
startVisit={handleStartVisit}
patientName={patientName}
/>
)}
</>
);
};
Expand Down
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';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://o3-docs.openmrs.org/docs/modal-system.en-US

  • in this docs we can observe that Implementation of the modal
  • Registering the modal (when the modal is created it should be also register in index.ts and routes.ts
  • And also close model in the header is misaligned

screenshot

Screenshot 2025-03-15 at 10 11 44 PM

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and also while Clicking on the start visit is not opening startVisit form workspace

Copy link
Contributor Author

@jwnasambu jwnasambu Mar 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right! Kindly since I am using a normal button you won't see the Start Visit form. Its the "start-visit-button-slot" with extension point in the OpenMRS microfrontend framework, that dynamically loads and renders a component from patient chart module that contains the logic to open the "Start Visit" form and handle visit creation so replacing it with a plain will remove this behavior unless I explicitly re-implement it. There are somethings missing that need to be clarified by the team before I proceed with work.

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;
Loading