diff --git a/packages/esm-commons-lib/package.json b/packages/esm-commons-lib/package.json
index 91272a3f0..c576ded33 100644
--- a/packages/esm-commons-lib/package.json
+++ b/packages/esm-commons-lib/package.json
@@ -39,8 +39,8 @@
"yup": "^0.29.1"
},
"peerDependencies": {
- "@openmrs/esm-framework": "5.x",
- "@openmrs/esm-patient-common-lib": "6.x",
+ "@openmrs/esm-framework": "*",
+ "@openmrs/esm-patient-common-lib": "*",
"dayjs": "1.x",
"react": "18.x",
"react-i18next": "11.x",
diff --git a/packages/esm-commons-lib/src/components/cohort-patient-list/helpers.tsx b/packages/esm-commons-lib/src/components/cohort-patient-list/helpers.tsx
index 4d30c467e..a97c98a7c 100644
--- a/packages/esm-commons-lib/src/components/cohort-patient-list/helpers.tsx
+++ b/packages/esm-commons-lib/src/components/cohort-patient-list/helpers.tsx
@@ -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 };
@@ -62,14 +61,16 @@ export const LaunchableFormMenuItem = ({
{isLoading ? (
) : (
- {
- changeWorkspaceContext(patientUuid);
- launchForm(form, encounterUuid ? 'edit' : 'enter', moduleName, form.name, encounterUuid, null, null);
- navigate({ to: patientUrl });
- }}
- />
+ <>
+ {
+ launchForm(form, encounterUuid ? 'edit' : 'enter', moduleName, form.name, encounterUuid, null, null);
+ navigate({ to: patientUrl });
+ }}
+ />
+
+ >
)}
>
);
@@ -132,7 +133,7 @@ export const ViewTptSummaryMenuItem = ({ patientUuid, ViewTptSummary, encounterT
} else {
setIsLoading(false);
}
- }, []);
+ }, [ViewTptSummary.editLatestEncounter, encounterType, patientUuid, encounterUuid, viewTptSummaryActionText]);
return (
<>
diff --git a/packages/esm-commons-lib/src/components/encounter-list/encounter-list.component.tsx b/packages/esm-commons-lib/src/components/encounter-list/encounter-list.component.tsx
index a849aa717..d8f13b936 100644
--- a/packages/esm-commons-lib/src/components/encounter-list/encounter-list.component.tsx
+++ b/packages/esm-commons-lib/src/components/encounter-list/encounter-list.component.tsx
@@ -61,7 +61,7 @@ export const EncounterList: React.FC = ({
const [pageSize, setPageSize] = useState(10);
const [isLoadingForms, setIsLoadingForms] = useState(true);
const { isDead } = usePatientDeathStatus(patientUuid);
- const formNames = useMemo(() => formList.map((form) => form.name), []);
+ const formNames = useMemo(() => formList.map((form) => form.name), [formList]);
const { formsJson, isLoading: isLoadingFormsJson } = useFormsJson(formNames);
const { encounters, isLoading, onFormSave } = useEncounterRows(patientUuid, encounterType, filter);
const { moduleName, workspaceWindowSize, displayText, hideFormLauncher } = launchOptions;
@@ -96,39 +96,39 @@ export const EncounterList: React.FC = ({
[forms, t],
);
- const handleDeleteEncounter = useCallback((encounterUuid, encounterTypeName) => {
- const close = showModal('delete-encounter-modal', {
- close: () => close(),
- encounterTypeName: encounterTypeName || '',
- onConfirmation: () => {
- const abortController = new AbortController();
- deleteEncounter(encounterUuid, abortController)
- .then(() => {
- mutate(
- (key) =>
- typeof key === "string" && key.startsWith("/ws/rest/v1/encounter"),
- undefined,
- { revalidate: true }
- );
- showSnackbar({
- isLowContrast: true,
- title: t('encounterDeleted', 'Encounter deleted'),
- subtitle: `Encounter ${t('successfullyDeleted', 'successfully deleted')}`,
- kind: 'success',
- });
- })
- .catch(() => {
- showSnackbar({
- isLowContrast: false,
- title: t('error', 'Error'),
- subtitle: `Encounter ${t('failedDeleting', "couldn't be deleted")}`,
- kind: 'error',
+ const handleDeleteEncounter = useCallback(
+ (encounterUuid, encounterTypeName) => {
+ const close = showModal('delete-encounter-modal', {
+ close: () => close(),
+ encounterTypeName: encounterTypeName || '',
+ onConfirmation: () => {
+ const abortController = new AbortController();
+ deleteEncounter(encounterUuid, abortController)
+ .then(() => {
+ mutate((key) => typeof key === 'string' && key.startsWith('/ws/rest/v1/encounter'), undefined, {
+ revalidate: true,
+ });
+ showSnackbar({
+ isLowContrast: true,
+ title: t('encounterDeleted', 'Encounter deleted'),
+ subtitle: `Encounter ${t('successfullyDeleted', 'successfully deleted')}`,
+ kind: 'success',
+ });
+ })
+ .catch(() => {
+ showSnackbar({
+ isLowContrast: false,
+ title: t('error', 'Error'),
+ subtitle: `Encounter ${t('failedDeleting', "couldn't be deleted")}`,
+ kind: 'error',
+ });
});
- });
- close();
- },
- });
- }, [])
+ close();
+ },
+ });
+ },
+ [t],
+ );
useEffect(() => {
if (!isLoadingFormsJson) {
@@ -223,15 +223,15 @@ export const EncounterList: React.FC = ({
// If custom config is available, generate actions accordingly; otherwise, fallback to the default actions.
const actions = tableRow.actions?.length ? tableRow.actions : defaultActions;
tableRow['actions'] = (
-
+
{actions.map((actionItem, index) => (
{
e.preventDefault();
- actionItem.mode == 'delete' ?
- handleDeleteEncounter(encounter.uuid, encounter.encounterType.name)
+ actionItem.mode == 'delete'
+ ? handleDeleteEncounter(encounter.uuid, encounter.encounterType.name)
: launchEncounterForm(
forms.find((form) => form.name == actionItem?.form?.name),
moduleName,
@@ -242,7 +242,7 @@ export const EncounterList: React.FC = ({
actionItem.intent,
workspaceWindowSize,
patientUuid,
- );
+ );
}}
/>
))}
@@ -252,7 +252,7 @@ export const EncounterList: React.FC = ({
});
setPaginatedRows(rows);
},
- [columns, defaultActions, forms, moduleName, workspaceWindowSize, patientUuid, onFormSave],
+ [columns, defaultActions, forms, moduleName, workspaceWindowSize, patientUuid, onFormSave, handleDeleteEncounter],
);
useEffect(() => {
@@ -265,7 +265,7 @@ export const EncounterList: React.FC = ({
if (forms.length == 1 && !forms[0]['availableIntents']?.length) {
// we only have one form with no intents
// just return the "Add" button
- return (
+ return (