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) Clean Ohri commons lib, upgrade openmrs, framework and patient-common-lib #1876

Merged
merged 4 commits into from
Jun 20, 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
7 changes: 4 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ const config = {
'^@carbon/charts-react$': path.resolve(__dirname, '__mocks__', '@carbon__charts-react.ts'),
'^dexie$': require.resolve('dexie'),
'^lodash-es/(.*)$': 'lodash/$1',
'^lodash-es$': 'lodash',
'^react-i18next$': path.resolve(__dirname, '__mocks__', 'react-i18next.js'),
},
testEnvironment: 'jsdom',
testPathIgnorePatterns: [
"/node_modules/",
"/e2e/" // Ignore the e2e directory containing Playwright tests
]
'/node_modules/',
'/e2e/', // Ignore the e2e directory containing Playwright tests
],
};

module.exports = config;
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
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,7 @@ export const EncounterList: React.FC<EncounterListProps> = ({
const abortController = new AbortController();
deleteEncounter(encounterUuid, abortController)
.then(() => {
mutate(
(key) =>
typeof key === "string" && key.startsWith("/ws/rest/v1/encounter"),
undefined,
{ revalidate: true }
);
onFormSave();
showSnackbar({
isLowContrast: true,
title: t('encounterDeleted', 'Encounter deleted'),
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
6 changes: 0 additions & 6 deletions packages/esm-tb-app/src/dashboard.meta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@ export const tbClinicalViewDashboardMeta = {
isFolder: true,
title: 'Tuberculosis',
};
export const tbPreventionDashboardMeta = {
name: 'tb-prevention',
slot: 'tb-prevention-dashboard-slot',
config: { columns: 1, type: 'grid', programme: 'tpt', dashboardTitle: 'TB Prevention'},
title: 'TB Prevention',
};

export const tbPreventionDashboardMeta = {
name: 'tb-prevention',
Expand Down
Loading
Loading