From fa12f3f986e7f30e481f5ee658ba7c7793bbefb8 Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Tue, 12 Sep 2023 19:04:27 +0300 Subject: [PATCH] (fix) Mutate list of patients not in queue on adding new queue entries (#807) --- .../add-patient-toqueue-dialog.component.tsx | 4 +++- .../visits-missing-inqueue/visits-missing-inqueue.resource.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/esm-outpatient-app/src/add-patient-toqueue/add-patient-toqueue-dialog.component.tsx b/packages/esm-outpatient-app/src/add-patient-toqueue/add-patient-toqueue-dialog.component.tsx index 03b32f1ce..d7bd40b5c 100644 --- a/packages/esm-outpatient-app/src/add-patient-toqueue/add-patient-toqueue-dialog.component.tsx +++ b/packages/esm-outpatient-app/src/add-patient-toqueue/add-patient-toqueue-dialog.component.tsx @@ -21,7 +21,7 @@ import { useVisitQueueEntries, } from '../active-visits/active-visits-table.resource'; import styles from './add-patient-toqueue-dialog.scss'; -import { ActiveVisit } from '../visits-missing-inqueue/visits-missing-inqueue.resource'; +import { ActiveVisit, useMissingQueueEntries } from '../visits-missing-inqueue/visits-missing-inqueue.resource'; import { useQueueLocations } from '../patient-search/hooks/useQueueLocations'; interface AddVisitToQueueDialogProps { @@ -48,6 +48,7 @@ const AddVisitToQueue: React.FC = ({ visitDetails, c const config = useConfig() as ConfigObject; const { mutate } = useVisitQueueEntries('', selectedQueueLocation); const [priority, setPriority] = useState(config.concepts.defaultPriorityConceptUuid); + const { mutateQueueEntries } = useMissingQueueEntries(); const addVisitToQueue = useCallback(() => { if (!queueUuid) { @@ -86,6 +87,7 @@ const AddVisitToQueue: React.FC = ({ visitDetails, c }); closeModal(); mutate(); + mutateQueueEntries(); } }, (error) => { diff --git a/packages/esm-outpatient-app/src/visits-missing-inqueue/visits-missing-inqueue.resource.ts b/packages/esm-outpatient-app/src/visits-missing-inqueue/visits-missing-inqueue.resource.ts index d79bd081b..416738f1a 100644 --- a/packages/esm-outpatient-app/src/visits-missing-inqueue/visits-missing-inqueue.resource.ts +++ b/packages/esm-outpatient-app/src/visits-missing-inqueue/visits-missing-inqueue.resource.ts @@ -39,11 +39,12 @@ export function useMissingQueueEntries() { isValidating: visitsIsValidating, } = useSWR<{ data: { results: Array } }, Error>(sessionLocation ? url : null, openmrsFetch); - const apiUrl = `/ws/rest/v1/visit-queue-entry?v=full`; + const apiUrl = `/ws/rest/v1/visit-queue-entry`; const { data: queueData, error: queueError, isValidating: queueIsValidating, + mutate: mutateQueueEntries, } = useSWR<{ data: { results: Array } }, Error>(apiUrl, openmrsFetch); const byId = {}; @@ -82,6 +83,7 @@ export function useMissingQueueEntries() { isLoading: !data && !visitsError && !queueError, isError: !visitsError && !queueError, visitsIsValidating, + mutateQueueEntries, }; }