Skip to content

Commit

Permalink
(fix) O3-3643: Number of Providers Metrics (#1298)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucyjemutai authored Aug 30, 2024
1 parent 91a72e8 commit 494b05e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/esm-appointments-app/src/hooks/useClinicalMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ export function useAllAppointmentsByDate() {
openmrsFetch,
);

const providersArray = data?.data?.filter(({ providers }) => providers !== null) ?? [];
const providersCount = uniqBy(
providersArray.map(({ providers }) => providers).flat(),
(provider) => provider.uuid,
).length;
const providersArray = data?.data?.flatMap(({ providers }) => providers ?? []) ?? [];

const validProviders = providersArray.filter((provider) => provider.response === 'ACCEPTED');

const uniqueProviders = uniqBy(validProviders, (provider) => provider.uuid);
const providersCount = uniqueProviders.length;

return {
totalProviders: providersCount ? providersCount : 0,
isLoading,
Expand Down

0 comments on commit 494b05e

Please sign in to comment.