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) UHM-8352 add ward patient banner to top of O2 Visit Summary wor… #12

Merged
merged 1 commit into from
Jan 14, 2025
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
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import { ExtensionSlot } from '@openmrs/esm-framework';
import React from 'react';
import { useTranslation } from 'react-i18next';
import O2IFrame from './o2-iframe.component';
import { type WardPatientWorkspaceProps } from './types';
import type { WardPatient, WardPatientWorkspaceProps } from './types';

const LABOUR_DELIVERY_SUMMARY_ENCOUNTER_TYPE = 'fec2cc56-e35f-42e1-8ae3-017142c1ca59';
const MATERNAL_ADMISSION_ENCOUNTER_TYPE = '0ef67d23-0cf4-4a3e-8617-ac9d55bdd005';
const POSTPARTUM_DAILY_PROGRESS = '37f04ddf-9653-4a02-98b4-1c23734c2f15';

const toClass = (encounterUuid: string) => '.encounterType-' + encounterUuid;

const O2VisitSummaryWorkspace: React.FC<WardPatientWorkspaceProps> = ({ wardPatient }) => {
// partial type defined in esm-ward-app
interface WardViewContext {
WardPatientHeader: React.FC<{ wardPatient: WardPatient }>;
}

const O2VisitSummaryWorkspace: React.FC<WardPatientWorkspaceProps> = (props) => {
const { wardPatient } = props;
const { patient, visit } = wardPatient ?? {};

const { t } = useTranslation();
Expand All @@ -30,12 +37,21 @@ const O2VisitSummaryWorkspace: React.FC<WardPatientWorkspaceProps> = ({ wardPati
jQuery('#nav-buttons').hide();
`;

if (patient && visit) {
const src = `${window.openmrsBase}/pihcore/visit/visit.page?patient=${patient.uuid}&visit=${visit.uuid}`;
return <O2IFrame src={src} elementsToHide={elementsToHide} customJavaScript={customJavaScript} />;
} else {
return <div>{t('patientHasNoActiveVisit', 'Patient has no active visit')}</div>;
}
const iframeSrc =
patient && visit
? `${window.openmrsBase}/pihcore/visit/visit.page?patient=${patient.uuid}&visit=${visit.uuid}`
: null;

return (
<>
<ExtensionSlot name="ward-workspace-patient-banner-slot" state={{ wardPatient }} />
{iframeSrc ? (
<O2IFrame src={iframeSrc} elementsToHide={elementsToHide} customJavaScript={customJavaScript} />
) : (
<div>{t('patientHasNoActiveVisit', 'Patient has no active visit')}</div>
)}
</>
);
};

export default O2VisitSummaryWorkspace;
3 changes: 2 additions & 1 deletion packages/esm-commons-app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"delete": "Delete",
"edit": "Edit",
"errorLoadingPatientForm": "Error loading patient form",
"fullInfantProgram": "Full infant program",
"fullPatientChart": "Full patient chart",
"fullPregnancyProgram": "Full pregnancy program",
"patientHasNoActiveVisit": "Patient has no active visit",
"patientNotEnrolledInInfantOrPregnancyProgram": "Patient not enrolled in either Infant or Pregnancy Program",
"patientVisitSummary": "Patient visit summary",
"removePatient": "Remove patient",
"transition": "Transition",
Expand Down
Loading