Skip to content
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

(fix) O3-4004 - ward app - better way to fix patient action menu button in workspace #1346

Merged
merged 6 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions packages/esm-ward-app/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,5 @@ export interface WardViewContext {
export interface MaternalWardViewContext {
motherChildrenRelationshipsByPatient: Map<string, MotherAndChild[]>;
}

export type PatientWorkspaceAdditionalProps = Omit<WardPatientWorkspaceProps, keyof DefaultWorkspaceProps>;
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { getPatientName, useAppContext } from '@openmrs/esm-framework';
import { getPatientName, launchWorkspace, useAppContext } from '@openmrs/esm-framework';
import React, { type ReactNode } from 'react';
import { type WardViewContext, type WardPatient } from '../types';
import { type WardViewContext, type WardPatient,type PatientWorkspaceAdditionalProps } from '../types';
import styles from './ward-patient-card.scss';
import { launchPatientWorkspace, setPatientWorkspaceProps } from './ward-patient-resource';

interface Props {
children: ReactNode;
Expand All @@ -19,12 +18,11 @@ const WardPatientCard: React.FC<Props> = ({ children, wardPatient }) => {
<button
className={styles.wardPatientCardButton}
onClick={() => {
setPatientWorkspaceProps({
launchWorkspace<PatientWorkspaceAdditionalProps>('ward-patient-workspace', {
wardPatient,
WardPatientHeader,
WardPatientHeader
});
launchPatientWorkspace();
}}>
}}>
{/* Name will not be displayed; just there for a11y */}
{getPatientName(patient.person)}
</button>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { useTranslation } from 'react-i18next';
import { UserAvatarIcon } from '@openmrs/esm-framework';
import { ActionMenuButton, launchWorkspace } from '@openmrs/esm-framework';
import { launchPatientWorkspace } from '../../ward-patient-card/ward-patient-resource';
import type { WardPatientWorkspaceProps } from '../../types';

export default function WardPatientActionButton() {
const { t } = useTranslation();
Expand All @@ -12,7 +12,7 @@ export default function WardPatientActionButton() {
getIcon={(props) => <UserAvatarIcon {...props} />}
label={t('Patient', 'patient')}
iconDescription={t('Patient', 'patient')}
handler={() => launchPatientWorkspace()}
handler={() => launchWorkspace<WardPatientWorkspaceProps>('ward-patient-workspace')}
type={'ward'}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,22 @@ import { getGender } from '../../ward-patient-card/row-elements/ward-patient-gen

attach('ward-patient-workspace-header-slot', 'patient-vitals-info');

export default function WardPatientWorkspace({ setTitle, wardPatient: { patient } }: WardPatientWorkspaceProps) {
export default function WardPatientWorkspace({ setTitle, wardPatient }: WardPatientWorkspaceProps) {
useEffect(() => {
setTitle(patient.person.display, <PatientWorkspaceTitle key={patient.uuid} patient={patient} />);
}, [patient.uuid]);
if (wardPatient) {
const { patient } = wardPatient;
setTitle(patient.person.display, <PatientWorkspaceTitle key={patient.uuid} patient={patient} />);
}
}, [wardPatient]);

return (
<div className={styles.workspaceContainer}>
<WardPatientWorkspaceView patient={patient} />
</div>
<>
{wardPatient && (
<div className={styles.workspaceContainer}>
<WardPatientWorkspaceView patient={wardPatient.patient} />
</div>
)}
</>
);
}

Expand Down
Loading