Skip to content

Conversation

@PiusKariuki
Copy link
Contributor

@PiusKariuki PiusKariuki commented Jun 22, 2024

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. If there is a ticket, make sure your PR title includes a conventional commit label. See existing PR titles for inspiration.
  • My work conforms to the OpenMRS 3.0 Styleguide and design documentation.
  • My work includes tests or is validated by existing tests.

Summary

This PR addresses an incosistency in re-retching the table contents in the services queues page when a write operation like adding a patient, clearing the queue or transitioning the patient fails to repopulate the table with the updated data.
We achieve this by employing custom events

export const emitRefetchQueuesEvent = (queueUUID: string = '') => {
  const event = new CustomEvent('refetchQueues', { detail: queueUUID });
  window.dispatchEvent(event);
};

Screenshots

Related Issue

https://openmrs.atlassian.net/browse/O3-3418

Other

@moshonk moshonk requested a review from brandones June 23, 2024 13:43
return () => {
window.removeEventListener('refetchQueues', handlePatientAddedToQueue);
};
}, []);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mutate will be added as a dependency`

@vasharma05
Copy link
Member

vasharma05 commented Jun 24, 2024

Hi @PiusKariuki!
I reviewed the changes you made in the PR and have the following points to put forward:
useQueueEntries is the hook that fetches the queue entries. I see you are calling the mutate for the default queue table. Now, if you note, the mutate function not only needs to revalidate the response for the given service and status but for all the statuses and services.

Alongside, please note that the default queue table is only used on the service queues home page, but we have more pages in the service queues (refer to packages/esm-service-queues-app/src/root.component.tsx) which will not be refreshed in this scenario. The QueueTable component is the reusable component for every table rendered inside the service queues app.

Thanks!

@PiusKariuki
Copy link
Contributor Author

Thanks @vasharma05 for these pointers that I had not taken into account. I am going to use them to rethink my implementation then try again.
Thank you!

Copy link
Contributor

@brandones brandones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs documentation. I commented in the ticket to this effect. There is no documentation of the bug—screenshots, video, reproduction instructions, nothing. And there is no documentation that this fixes any bug (video or screenshots that show it working). Finally, if we are getting rid of useMutateQueueEntries, we should do a proper job and delete it entirely. However it's likely that if there is a bug, the thing we want to do is simply to fix useMutateQueueEntries and ensure it is used correctly everywhere.

@PiusKariuki PiusKariuki deleted the chore/more-robust-refetch-mechanism branch June 24, 2024 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants