Skip to content

Commit

Permalink
auto refresh encounter list after form saving/editing (#1864)
Browse files Browse the repository at this point in the history
  • Loading branch information
kajambiya authored Jun 12, 2024
1 parent b64bcee commit 0748556
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
"access": "public"
},
"scripts": {
"start": "openmrs develop --backend https://ohri-dev.globalhealthapp.net/ --sources 'packages/esm-*-app/'",
"start:core": "openmrs develop --backend https://ohri-dev.globalhealthapp.net --sources packages/esm-ohri-core-app",
"start:covid": "openmrs develop --backend https://ohri-dev.globalhealthapp.net --sources packages/esm-covid-app",
"start:hiv": "openmrs develop --backend https://ohri-dev.globalhealthapp.net --sources packages/esm-hiv-app",
"start:cervical-cancer": "openmrs develop --backend https://ohri-dev.globalhealthapp.net --sources packages/esm-cervical-cancer-app",
"start": "openmrs develop --backend https://openmrs-dev.globalhealthapp.net/ --sources 'packages/esm-*-app/'",
"start:core": "openmrs develop --backend https://openmrs-dev.globalhealthapp.net --sources packages/esm-ohri-core-app",
"start:covid": "openmrs develop --backend https://openmrs-dev.globalhealthapp.net --sources packages/esm-covid-app",
"start:hiv": "openmrs develop --backend https://openmrs-dev.globalhealthapp.net --sources packages/esm-hiv-app",
"start:cervical-cancer": "openmrs develop --backend https://openmrs-dev.globalhealthapp.net --sources packages/esm-cervical-cancer-app",
"start:pmtct": "openmrs develop --backend https://ohri-namibia-dev.globalhealthapp.net --sources 'packages/esm-ohri-pmtct-app/'",
"start:form-render": "openmrs develop --backend https://ohri-dev.globalhealthapp.net --sources packages/esm-form-render-app",
"start:tb": "openmrs develop --backend https://ohri-dev.globalhealthapp.net --sources packages/esm-tb-app",
"start:opd": "openmrs develop --backend https://ohri-dev.globalhealthapp.net --sources packages/esm-opd-app",
"start:form-render": "openmrs develop --backend https://openmrs-dev.globalhealthapp.net --sources packages/esm-form-render-app",
"start:tb": "openmrs develop --backend https://openmrs-dev.globalhealthapp.net --sources packages/esm-tb-app",
"start:opd": "openmrs develop --backend https://openmrs-dev.globalhealthapp.net --sources packages/esm-opd-app",
"prettier": "prettier --fix --config prettier.config.js --write \"packages/**/*.{ts,tsx}\"",
"prepare": "husky install",
"test": "jest --config jest.config.js --verbose false --passWithNoTests",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ export function launchEncounterForm(
intent: string = '*',
workspaceWindowSize?: 'minimized' | 'maximized',
patientUuid?: string,
mutateform?: () => void,
) {
launchPatientWorkspace('patient-form-entry-workspace', {
workspaceTitle: form.name,
mutateform: mutateform,
mutateForm: onFormSave,
formInfo: {
encounterUuid,
formUuid: form.name,
Expand Down
9 changes: 5 additions & 4 deletions packages/esm-commons-lib/src/hooks/useEncounterRows.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import useSWRImmutable, { mutate } from 'swr';
import useSWR from 'swr';
import { OpenmrsEncounter } from '../api/types';
import { useCallback, useEffect, useMemo, useState } from 'react';
import { openmrsFetch } from '@openmrs/esm-framework';
Expand All @@ -12,7 +12,8 @@ export function useEncounterRows(patientUuid: string, encounterType: string, enc
data: response,
error,
isLoading,
} = useSWRImmutable<{ data: { results: OpenmrsEncounter[] } }, Error>(url, openmrsFetch);
mutate,
} = useSWR<{ data: { results: OpenmrsEncounter[] } }, Error>(url, openmrsFetch);

useEffect(() => {
if (response) {
Expand All @@ -30,8 +31,8 @@ export function useEncounterRows(patientUuid: string, encounterType: string, enc
}, [encounterFilter, response]);

const onFormSave = useCallback(() => {
mutate(url);
}, [url]);
mutate();
}, [mutate]);

return {
encounters,
Expand Down

0 comments on commit 0748556

Please sign in to comment.