-
Notifications
You must be signed in to change notification settings - Fork 188
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
base: main
Are you sure you want to change the base?
O3-3067: (fix) Incorrect parameters passed to react hook when filtering queues by service uuid #1095
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,7 @@ import DefaultQueueTable from '../queue-table/default-queue-table.component'; | |
import { type QueueEntry } from '../types'; | ||
import { mapVisitQueueEntryProperties, type MappedVisitQueueEntry } from './active-visits-table.resource'; | ||
import styles from './active-visits-table.scss'; | ||
import uniqBy from 'lodash-es/uniqBy'; | ||
|
||
/** | ||
* FIXME Temporarily moved here | ||
|
@@ -92,10 +93,10 @@ interface PaginationData { | |
} | ||
|
||
function ActiveVisitsTable() { | ||
const selectedQueueUuid = useSelectedServiceUuid(); | ||
const selectedServiceUuid = useSelectedServiceUuid(); | ||
const currentLocationUuid = useSelectedQueueLocationUuid(); | ||
const { queueEntries, isLoading, error } = useQueueEntries({ | ||
queue: selectedQueueUuid, | ||
service: selectedServiceUuid, | ||
location: currentLocationUuid, | ||
isEnded: false, | ||
}); | ||
|
@@ -126,13 +127,13 @@ function OldQueueTable({ queueEntries }: { queueEntries: QueueEntry[] }) { | |
const { t } = useTranslation(); | ||
const currentServiceName = useSelectedServiceName(); | ||
const currentQueueLocation = useSelectedQueueLocationUuid(); | ||
const { queues } = useQueues(currentQueueLocation); | ||
const { visitQueueNumberAttributeUuid } = useConfig<ConfigObject>(); | ||
const currentServiceUuid = useSelectedServiceUuid(); | ||
const visitQueueEntries = queueEntries.map((entry) => | ||
mapVisitQueueEntryProperties(entry, visitQueueNumberAttributeUuid), | ||
); | ||
const queues = uniqBy(queueEntries?.flatMap((entry) => entry.queue) ?? [], 'uuid'); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
const currentServiceUuid = useSelectedServiceUuid(); | ||
const [showOverlay, setShowOverlay] = useState(false); | ||
const [viewState, setViewState] = useState<{ selectedPatientUuid: string }>(null); | ||
const layout = useLayoutType(); | ||
|
@@ -144,7 +145,7 @@ function OldQueueTable({ queueEntries }: { queueEntries: QueueEntry[] }) { | |
new Date(localStorage.getItem('lastUpdatedQueueRoomTimestamp')), | ||
); | ||
const { queueLocations } = useQueueLocations(); | ||
const { rooms, isLoading: loading } = useQueueRooms(queueLocations[0]?.id, currentServiceUuid); | ||
const { rooms, isLoading: loading } = useQueueRooms(queueLocations[0]?.id, currentQueueLocation); | ||
|
||
const isPermanentProviderQueueRoom = useIsPermanentProviderQueueRoom(); | ||
const pageSizes = [10, 20, 30, 40, 50]; | ||
|
@@ -199,8 +200,11 @@ function OldQueueTable({ queueEntries }: { queueEntries: QueueEntry[] }) { | |
); | ||
|
||
const handleServiceChange = ({ selectedItem }) => { | ||
updateSelectedServiceUuid(selectedItem.uuid); | ||
updateSelectedServiceName(selectedItem.display); | ||
const { | ||
service: { display, uuid }, | ||
} = selectedItem ?? {}; | ||
updateSelectedServiceUuid(uuid); | ||
updateSelectedServiceName(display); | ||
}; | ||
|
||
const tableRows = useMemo(() => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 = '') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This technically works, but we should use |
||
const apiUrl = queueUuid | ||
? `${restBaseUrl}/queueroom?location=${location}&queue=${queueUuid}` | ||
: `${restBaseUrl}/queueroom?location=${location}`; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,9 @@ import { | |
import { useActiveVisits, useAverageWaitTime } from './clinic-metrics.resource'; | ||
import { useServiceMetricsCount } from './queue-metrics.resource'; | ||
import styles from './clinic-metrics.scss'; | ||
import { useQueues } from '../helpers/useQueues'; | ||
import { useQueueEntries } from '../hooks/useQueueEntries'; | ||
import unionBy from 'lodash/unionBy'; | ||
import { useQueues } from '../hooks/useQueues'; | ||
|
||
export interface Service { | ||
uuid: string; | ||
|
@@ -26,6 +27,7 @@ function ClinicMetrics() { | |
|
||
const currentQueueLocation = useSelectedQueueLocationUuid(); | ||
const { queues } = useQueues(currentQueueLocation); | ||
const uniqueQueues = unionBy(queues ?? [], ({ service }) => service?.uuid); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
const currentServiceUuid = useSelectedServiceUuid(); | ||
const currentServiceName = useSelectedServiceName(); | ||
const { serviceCount } = useServiceMetricsCount(currentServiceUuid, currentQueueLocation); | ||
|
@@ -39,15 +41,15 @@ function ClinicMetrics() { | |
} | ||
}); | ||
const { queueEntries, totalCount } = useQueueEntries({ | ||
queue: currentServiceUuid, | ||
service: currentServiceUuid, | ||
location: currentQueueLocation, | ||
isEnded: false, | ||
}); | ||
const { activeVisitsCount, isLoading: loading } = useActiveVisits(); | ||
const { waitTime } = useAverageWaitTime(currentServiceUuid, ''); | ||
|
||
const handleServiceChange = ({ selectedItem }) => { | ||
updateSelectedServiceUuid(selectedItem.uuid); | ||
updateSelectedServiceUuid(selectedItem?.service?.uuid); | ||
updateSelectedServiceName(selectedItem.display); | ||
if (selectedItem.uuid == undefined) { | ||
setInitialSelectItem(true); | ||
|
@@ -77,7 +79,7 @@ function ClinicMetrics() { | |
id="inline" | ||
type="inline" | ||
label={currentServiceName ?? `${t('all', 'All')}`} | ||
items={[{ display: `${t('all', 'All')}` }, ...queues]} | ||
items={[{ display: `${t('all', 'All')}` }, ...uniqueQueues]} | ||
itemToString={(item) => (item ? item.display : '')} | ||
onChange={handleServiceChange} | ||
/> | ||
|
There was a problem hiding this comment.
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.