Skip to content

Commit

Permalink
(fix) Mutate list of patients not in queue on adding new queue entries (
Browse files Browse the repository at this point in the history
  • Loading branch information
CynthiaKamau authored Sep 12, 2023
1 parent 5972681 commit fa12f3f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -48,6 +48,7 @@ const AddVisitToQueue: React.FC<AddVisitToQueueDialogProps> = ({ 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) {
Expand Down Expand Up @@ -86,6 +87,7 @@ const AddVisitToQueue: React.FC<AddVisitToQueueDialogProps> = ({ visitDetails, c
});
closeModal();
mutate();
mutateQueueEntries();
}
},
(error) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ export function useMissingQueueEntries() {
isValidating: visitsIsValidating,
} = useSWR<{ data: { results: Array<Visit> } }, 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<VisitQueueEntry> } }, Error>(apiUrl, openmrsFetch);

const byId = {};
Expand Down Expand Up @@ -82,6 +83,7 @@ export function useMissingQueueEntries() {
isLoading: !data && !visitsError && !queueError,
isError: !visitsError && !queueError,
visitsIsValidating,
mutateQueueEntries,
};
}

Expand Down

0 comments on commit fa12f3f

Please sign in to comment.