Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

O3-3067: (fix) Incorrect parameters passed to react hook when filtering queues by service uuid #1095

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

donaldkibet
Copy link
Member

@donaldkibet donaldkibet commented Apr 11, 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

PR description here https://openmrs.atlassian.net/browse/O3-3067

Screenshots

Kapture.2024-04-11.at.20.34.01.mp4

Related Issue

Other

Copy link
Contributor

github-actions bot commented Apr 11, 2024

Size Change: -153 kB (-5%) ✅

Total Size: 3.24 MB

Filename Size Change
packages/esm-service-queues-app/dist/745.js 0 B -159 kB (removed) 🏆
ℹ️ View Unchanged
Filename Size Change
packages/esm-active-visits-app/dist/130.js 169 kB 0 B
packages/esm-active-visits-app/dist/255.js 2.21 kB 0 B
packages/esm-active-visits-app/dist/271.js 762 B 0 B
packages/esm-active-visits-app/dist/277.js 13.4 kB 0 B
packages/esm-active-visits-app/dist/316.js 42.9 kB 0 B
packages/esm-active-visits-app/dist/319.js 683 B 0 B
packages/esm-active-visits-app/dist/382.js 1.15 kB 0 B
packages/esm-active-visits-app/dist/448.js 47.1 kB 0 B
packages/esm-active-visits-app/dist/460.js 784 B 0 B
packages/esm-active-visits-app/dist/574.js 588 B 0 B
packages/esm-active-visits-app/dist/588.js 6.66 kB 0 B
packages/esm-active-visits-app/dist/635.js 1.15 kB 0 B
packages/esm-active-visits-app/dist/644.js 762 B 0 B
packages/esm-active-visits-app/dist/729.js 3.1 kB 0 B
packages/esm-active-visits-app/dist/757.js 694 B 0 B
packages/esm-active-visits-app/dist/784.js 2.63 kB 0 B
packages/esm-active-visits-app/dist/788.js 586 B 0 B
packages/esm-active-visits-app/dist/807.js 918 B 0 B
packages/esm-active-visits-app/dist/833.js 732 B 0 B
packages/esm-active-visits-app/dist/879.js 2.94 kB 0 B
packages/esm-active-visits-app/dist/main.js 65 kB 0 B
packages/esm-active-visits-app/dist/openmrs-esm-active-visits-app.js 3.33 kB 0 B
packages/esm-appointments-app/dist/123.js 257 kB 0 B
packages/esm-appointments-app/dist/130.js 169 kB 0 B
packages/esm-appointments-app/dist/152.js 257 B 0 B
packages/esm-appointments-app/dist/255.js 2.22 kB 0 B
packages/esm-appointments-app/dist/271.js 1.97 kB 0 B
packages/esm-appointments-app/dist/286.js 9.34 kB 0 B
packages/esm-appointments-app/dist/303.js 258 B 0 B
packages/esm-appointments-app/dist/319.js 1.89 kB 0 B
packages/esm-appointments-app/dist/390.js 26 kB 0 B
packages/esm-appointments-app/dist/4.js 1.77 kB 0 B
packages/esm-appointments-app/dist/460.js 2.07 kB 0 B
packages/esm-appointments-app/dist/574.js 1.81 kB 0 B
packages/esm-appointments-app/dist/588.js 6.65 kB 0 B
packages/esm-appointments-app/dist/591.js 16.9 kB 0 B
packages/esm-appointments-app/dist/644.js 1.97 kB 0 B
packages/esm-appointments-app/dist/719.js 45.6 kB 0 B
packages/esm-appointments-app/dist/729.js 3.1 kB 0 B
packages/esm-appointments-app/dist/757.js 1.74 kB 0 B
packages/esm-appointments-app/dist/784.js 2.63 kB 0 B
packages/esm-appointments-app/dist/788.js 1.68 kB 0 B
packages/esm-appointments-app/dist/807.js 2.31 kB 0 B
packages/esm-appointments-app/dist/833.js 1.97 kB 0 B
packages/esm-appointments-app/dist/main.js 314 kB 0 B
packages/esm-appointments-app/dist/openmrs-esm-appointments-app.js 3.43 kB 0 B
packages/esm-patient-list-management-app/dist/130.js 169 kB 0 B
packages/esm-patient-list-management-app/dist/255.js 2.21 kB 0 B
packages/esm-patient-list-management-app/dist/271.js 1.55 kB 0 B
packages/esm-patient-list-management-app/dist/295.js 99.3 kB 0 B
packages/esm-patient-list-management-app/dist/319.js 1.52 kB 0 B
packages/esm-patient-list-management-app/dist/382.js 1.15 kB 0 B
packages/esm-patient-list-management-app/dist/460.js 1.7 kB 0 B
packages/esm-patient-list-management-app/dist/574.js 1.34 kB 0 B
packages/esm-patient-list-management-app/dist/588.js 6.66 kB 0 B
packages/esm-patient-list-management-app/dist/591.js 16.9 kB 0 B
packages/esm-patient-list-management-app/dist/635.js 1.15 kB 0 B
packages/esm-patient-list-management-app/dist/644.js 1.55 kB 0 B
packages/esm-patient-list-management-app/dist/716.js 4.66 kB 0 B
packages/esm-patient-list-management-app/dist/729.js 3.1 kB 0 B
packages/esm-patient-list-management-app/dist/757.js 1.5 kB 0 B
packages/esm-patient-list-management-app/dist/784.js 2.64 kB 0 B
packages/esm-patient-list-management-app/dist/788.js 1.34 kB 0 B
packages/esm-patient-list-management-app/dist/807.js 1.84 kB 0 B
packages/esm-patient-list-management-app/dist/833.js 1.58 kB 0 B
packages/esm-patient-list-management-app/dist/995.js 21.9 kB 0 B
packages/esm-patient-list-management-app/dist/main.js 125 kB 0 B
packages/esm-patient-list-management-app/dist/openmrs-esm-patient-list-management-app.js 3.3 kB 0 B
packages/esm-patient-registration-app/dist/130.js 169 kB 0 B
packages/esm-patient-registration-app/dist/152.js 262 B 0 B
packages/esm-patient-registration-app/dist/255.js 2.21 kB 0 B
packages/esm-patient-registration-app/dist/271.js 2.01 kB 0 B
packages/esm-patient-registration-app/dist/303.js 260 B 0 B
packages/esm-patient-registration-app/dist/319.js 1.99 kB 0 B
packages/esm-patient-registration-app/dist/460.js 2.12 kB 0 B
packages/esm-patient-registration-app/dist/481.js 6.75 kB 0 B
packages/esm-patient-registration-app/dist/537.js 2.34 kB 0 B
packages/esm-patient-registration-app/dist/574.js 1.7 kB 0 B
packages/esm-patient-registration-app/dist/591.js 16.9 kB 0 B
packages/esm-patient-registration-app/dist/644.js 2.01 kB 0 B
packages/esm-patient-registration-app/dist/676.js 6.59 kB 0 B
packages/esm-patient-registration-app/dist/686.js 92 kB 0 B
packages/esm-patient-registration-app/dist/729.js 3.1 kB 0 B
packages/esm-patient-registration-app/dist/735.js 464 B 0 B
packages/esm-patient-registration-app/dist/757.js 2.07 kB 0 B
packages/esm-patient-registration-app/dist/783.js 36.3 kB 0 B
packages/esm-patient-registration-app/dist/784.js 2.64 kB 0 B
packages/esm-patient-registration-app/dist/788.js 1.7 kB 0 B
packages/esm-patient-registration-app/dist/807.js 2.43 kB 0 B
packages/esm-patient-registration-app/dist/833.js 1.97 kB 0 B
packages/esm-patient-registration-app/dist/879.js 2.94 kB 0 B
packages/esm-patient-registration-app/dist/main.js 130 kB 0 B
packages/esm-patient-registration-app/dist/openmrs-esm-patient-registration-app.js 3.34 kB 0 B
packages/esm-patient-search-app/dist/130.js 169 kB 0 B
packages/esm-patient-search-app/dist/255.js 2.21 kB 0 B
packages/esm-patient-search-app/dist/271.js 899 B 0 B
packages/esm-patient-search-app/dist/319.js 857 B 0 B
packages/esm-patient-search-app/dist/382.js 1.15 kB 0 B
packages/esm-patient-search-app/dist/460.js 924 B 0 B
packages/esm-patient-search-app/dist/574.js 732 B 0 B
packages/esm-patient-search-app/dist/584.js 21.7 kB 0 B
packages/esm-patient-search-app/dist/588.js 6.66 kB 0 B
packages/esm-patient-search-app/dist/591.js 16.9 kB 0 B
packages/esm-patient-search-app/dist/635.js 1.15 kB 0 B
packages/esm-patient-search-app/dist/644.js 899 B 0 B
packages/esm-patient-search-app/dist/729.js 3.1 kB 0 B
packages/esm-patient-search-app/dist/757.js 864 B 0 B
packages/esm-patient-search-app/dist/778.js 23.2 kB 0 B
packages/esm-patient-search-app/dist/784.js 2.63 kB 0 B
packages/esm-patient-search-app/dist/788.js 726 B 0 B
packages/esm-patient-search-app/dist/807.js 1.03 kB 0 B
packages/esm-patient-search-app/dist/833.js 867 B 0 B
packages/esm-patient-search-app/dist/main.js 48 kB 0 B
packages/esm-patient-search-app/dist/openmrs-esm-patient-search-app.js 3.3 kB 0 B
packages/esm-service-queues-app/dist/130.js 169 kB 0 B
packages/esm-service-queues-app/dist/152.js 262 B 0 B
packages/esm-service-queues-app/dist/233.js 1.73 kB 0 B
packages/esm-service-queues-app/dist/255.js 2.22 kB 0 B
packages/esm-service-queues-app/dist/263.js 3.46 kB 0 B
packages/esm-service-queues-app/dist/271.js 4.12 kB 0 B
packages/esm-service-queues-app/dist/303.js 261 B 0 B
packages/esm-service-queues-app/dist/319.js 3.54 kB 0 B
packages/esm-service-queues-app/dist/328.js 3.01 kB +18 B (+1%)
packages/esm-service-queues-app/dist/389.js 1.9 kB 0 B
packages/esm-service-queues-app/dist/425.js 2.09 kB 0 B
packages/esm-service-queues-app/dist/460.js 4.4 kB 0 B
packages/esm-service-queues-app/dist/574.js 3.54 kB 0 B
packages/esm-service-queues-app/dist/588.js 6.66 kB 0 B
packages/esm-service-queues-app/dist/591.js 16.9 kB 0 B
packages/esm-service-queues-app/dist/616.js 2.72 kB -3 B (0%)
packages/esm-service-queues-app/dist/644.js 4.12 kB 0 B
packages/esm-service-queues-app/dist/647.js 56.9 kB +184 B (0%)
packages/esm-service-queues-app/dist/694.js 2.65 kB 0 B
packages/esm-service-queues-app/dist/696.js 570 B 0 B
packages/esm-service-queues-app/dist/70.js 164 kB 0 B
packages/esm-service-queues-app/dist/729.js 3.1 kB 0 B
packages/esm-service-queues-app/dist/738.js 554 B 0 B
packages/esm-service-queues-app/dist/757.js 3.54 kB 0 B
packages/esm-service-queues-app/dist/784.js 2.63 kB 0 B
packages/esm-service-queues-app/dist/788.js 3.54 kB 0 B
packages/esm-service-queues-app/dist/806.js 1.6 kB 0 B
packages/esm-service-queues-app/dist/807.js 4.83 kB 0 B
packages/esm-service-queues-app/dist/833.js 4.09 kB 0 B
packages/esm-service-queues-app/dist/940.js 21.4 kB +6 B (0%)
packages/esm-service-queues-app/dist/981.js 2.94 kB 0 B
packages/esm-service-queues-app/dist/main.js 224 kB +5.45 kB (+2%)
packages/esm-service-queues-app/dist/openmrs-esm-service-queues-app.js 3.31 kB 0 B

compressed-size-action

Copy link

@ojwanganto ojwanganto left a comment

Choose a reason for hiding this comment

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

Thanks @donaldkibet. I find this good already. I have left just one comment to be addressed.

@@ -61,7 +61,7 @@ const AddProviderQueueRoom: React.FC<AddProviderQueueRoomProps> = ({ providerUui

const { mutate } = useProvidersQueueRoom(providerUuid);
const { queues } = useQueues(currentLocationUuid);
const { rooms } = useQueueRooms(currentLocationUuid, currentServiceUuid);
const { rooms } = useQueueRooms(currentLocationUuid, currentLocationUuid);

Choose a reason for hiding this comment

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

we are passing the same parameter. Is there a possibility to filter by service as well?

@ojwanganto
Copy link

ojwanganto commented Apr 11, 2024

image
This is the error that this PR is addressing. You can also reproduce it in dev3

Copy link
Contributor

@chibongho chibongho left a comment

Choose a reason for hiding this comment

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

We have had a bad naming for updateSelectedServiceUuid and updateSelectedServiceName to be set to queueUuid / queueName instead of serviceUuid / serviceName, This PR addresses that, which is great.

However, if we go with this, we must update all places that call updateSelectedServiceUuid to take in the serviceUuid instead of queueUuid. There are places missed in this PR. Also, we should change updateSelectedServiceName to also take in the service name instead of queue name.

It might be less dangerous to just rename useSelectedServiceUuid / updateSelectedServiceName to updateSelectedQueueUuid / updateSelectedQueueName. If we want to be selecting on a particular queue, I think selecting by queueUuid is preferable to selecting by serviceUuid (even if there is a one-to-one relationship between queue and service). Then fix the queue-entry-metrics call to use the right params.

Copy link
Member

@mseaton mseaton left a comment

Choose a reason for hiding this comment

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

See comments.

@@ -92,10 +92,10 @@ interface PaginationData {
}

function ActiveVisitsTable() {
const selectedQueueUuid = useSelectedServiceUuid();
const selectedServiceQueueUuid = useSelectedServiceUuid();
Copy link
Member

Choose a reason for hiding this comment

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

Let's name this variable selectedServiceUuid, not selectedServiceQueueUuid

const visitQueueEntries = queueEntries
.map((entry) => mapVisitQueueEntryProperties(entry, visitQueueNumberAttributeUuid))
.filter((entry) => (currentServiceUuid ? entry.queue.service.uuid === currentServiceUuid : true));

Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't think this filter is needed at all. We should just be able to use queueEntries as-is, since it is already filtering by both the selected service and location. So let's get rid of this visitQueueEntries and just use the queueEntries returned from the hook.

@donaldkibet
Copy link
Member Author

We have had a bad naming for updateSelectedServiceUuid and updateSelectedServiceName to be set to queueUuid / queueName instead of serviceUuid / serviceName, This PR addresses that, which is great.

However, if we go with this, we must update all places that call updateSelectedServiceUuid to take in the serviceUuid instead of queueUuid. There are places missed in this PR. Also, we should change updateSelectedServiceName to also take in the service name instead of queue name.

It might be less dangerous to just rename useSelectedServiceUuid / updateSelectedServiceName to updateSelectedQueueUuid / updateSelectedQueueName. If we want to be selecting on a particular queue, I think selecting by queueUuid is preferable to selecting by serviceUuid (even if there is a one-to-one relationship between queue and service). Then fix the queue-entry-metrics call to use the right params.

@chibongho i have updated the function to pick correct parameters

@donaldkibet donaldkibet force-pushed the fix/queueFiltering branch 2 times, most recently from 8373bff to 076b084 Compare April 15, 2024 16:11
Copy link
Contributor

@chibongho chibongho left a comment

Choose a reason for hiding this comment

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

There are still places using the updateSelectedServiceUuid() function that needs updating, namely in add-provider-queue-room.component.tsx and default-queue-table.component.tsx

const visitQueueEntries = queueEntries.map((entry) =>
mapVisitQueueEntryProperties(entry, visitQueueNumberAttributeUuid),
);
const queues = uniqBy(queueEntries?.flatMap((entry) => entry.queue) ?? [], 'uuid');
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this will make the dropdown list display only queues that have at least one queue entry. Are we sure we want that? The order of those queues can be unpredictable based on the order of the returned queue entries.

@@ -26,6 +27,7 @@ function ClinicMetrics() {

const currentQueueLocation = useSelectedQueueLocationUuid();
const { queues } = useQueues(currentQueueLocation);
const uniqueQueues = unionBy(queues ?? [], ({ service }) => service?.uuid);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm guessing we need this because there can be multiple queues for the same service?

@@ -2,7 +2,7 @@ import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
import useSWR from 'swr';
import { type ProvidersQueueRoom, type QueueRoom } from '../types';

export function useQueueRooms(location: string, queueUuid: string) {
export function useQueueRooms(location: string, queueUuid: string = '') {
Copy link
Contributor

Choose a reason for hiding this comment

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

This technically works, but we should use null to denote absence of a value instead of empty string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants