Skip to content

Commit

Permalink
Clean Ohri commons lib, upgrade openmrs, framework and patient-common…
Browse files Browse the repository at this point in the history
…-lib
  • Loading branch information
kajambiya committed Jun 20, 2024
1 parent 555becb commit 0e75ba2
Show file tree
Hide file tree
Showing 4 changed files with 244 additions and 160 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import localizedFormat from 'dayjs/plugin/localizedFormat';
import relativeTime from 'dayjs/plugin/relativeTime';
import { AddPatientToListOverflowMenuItem } from '../modals/add-patient-to-list-modal.component';
import { fetchPatientLastEncounter } from '../../api/api';
import { changeWorkspaceContext } from '@openmrs/esm-patient-common-lib';
import { launchForm } from '../../utils/ohri-forms-commons';
import { navigate } from '@openmrs/esm-framework';
import { navigate, WorkspaceWindow } from '@openmrs/esm-framework';

interface PatientMetaConfig {
location: { name: string };
Expand Down Expand Up @@ -55,21 +54,23 @@ export const LaunchableFormMenuItem = ({
} else {
setIsLoading(false);
}
}, []);
}, [continueEncounterActionText, encounterType, encounterUuid, launchableForm.editLatestEncounter, patientUuid]);

return (
<>
{isLoading ? (
<InlineLoading style={{ margin: '0 auto', width: '16px' }} />
) : (
<OverflowMenuItem
itemText={actionText}
onClick={() => {
changeWorkspaceContext(patientUuid);
launchForm(form, encounterUuid ? 'edit' : 'enter', moduleName, form.name, encounterUuid, null, null);
navigate({ to: patientUrl });
}}
/>
<>
<OverflowMenuItem
itemText={actionText}
onClick={() => {
launchForm(form, encounterUuid ? 'edit' : 'enter', moduleName, form.name, encounterUuid, null, null);
navigate({ to: patientUrl });
}}
/>
<WorkspaceWindow contextKey={`patient/${patientUuid}`} />
</>
)}
</>
);
Expand All @@ -94,7 +95,7 @@ export const ViewSummaryMenuItem = ({ patientUuid, ViewSummary, encounterType })
} else {
setIsLoading(false);
}
}, []);
}, [ViewSummary.editLatestEncounter, encounterType, encounterUuid, patientUuid, viewSummaryActionText]);

return (
<>
Expand Down Expand Up @@ -132,7 +133,7 @@ export const ViewTptSummaryMenuItem = ({ patientUuid, ViewTptSummary, encounterT
} else {
setIsLoading(false);
}
}, []);
}, [ViewTptSummary.editLatestEncounter, encounterType, patientUuid, encounterUuid, viewTptSummaryActionText]);

return (
<>
Expand Down
21 changes: 5 additions & 16 deletions packages/esm-commons-lib/src/workspace/ohri-workspace-utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { getSyncLifecycle } from '@openmrs/esm-framework';
import { BehaviorSubject } from 'rxjs';
import { closeWorkspace, launchPatientWorkspace, registerWorkspace } from '@openmrs/esm-patient-common-lib';
import { FormEngine, SessionMode } from '@openmrs/openmrs-form-engine-lib';
import { closeWorkspace } from '@openmrs/esm-framework';
import { launchPatientWorkspace } from '@openmrs/esm-patient-common-lib';
import { SessionMode } from '@openmrs/openmrs-form-engine-lib';

export interface WorkspaceContextProps {
title: string;
encounterUuid?: string;
Expand All @@ -18,26 +19,14 @@ let counter = 0;

export const launchOHRIWorkSpace = (props: WorkspaceContextProps) => {
const workspaceName = props.workspaceName || 'ohri-forms-' + counter++;

const close = () => {
return closeWorkspace(workspaceName, { ignoreChanges: true });
};

const onFormSubmit = () => {
props.state?.updateParent?.();
close();
};
registerWorkspace({
name: workspaceName,
title: props.title,
preferredWindowSize: <any>props.screenSize,
load: getSyncLifecycle(FormEngine, {
featureName: 'ohri-forms-workspace-item',
moduleName: props.moduleName,
}),
canMaximize: true,
canHide: true,
width: 'wider',
});
launchPatientWorkspace(workspaceName, {
...props.state,
mode: props.mode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { launchFormWithCustomTitle } from '@ohri/openmrs-esm-ohri-commons-lib';
import { getForm, applyFormIntent } from '@openmrs/openmrs-form-engine-lib';
import styles from './tabs/patient-list.scss';
import { OverflowMenu, OverflowMenuItem } from '@carbon/react';
import { changeWorkspaceContext, closeAllWorkspaces, resetWorkspaceStore } from '@openmrs/esm-patient-common-lib';
import { navigate } from '@openmrs/esm-framework';
import { useTranslation } from 'react-i18next';
import { moduleName } from '../../../index';
Expand Down Expand Up @@ -47,7 +46,6 @@ export const LabresultsFormViewer: React.FC<LabresultsFormViewerProps> = ({
itemText={t('viewResult', 'View Result')}
onClick={(e) => {
e.preventDefault();
changeWorkspaceContext(patientUuid);
launchEncounterForm(applyFormIntent('*', getForm(form.package, form.name)), '*', 'view', encounterUuid);
navigate({ to: patientUrl });
}}
Expand Down
Loading

0 comments on commit 0e75ba2

Please sign in to comment.