Skip to content

Commit

Permalink
Adding a metrics card to return the patient count in the queue alloca…
Browse files Browse the repository at this point in the history
…ted to the user logged in (#167)

* U4X-401 Aligning the checkin Tile tagged to a specific location

* UXX-401 Using parent location instead of creator uuid

* Adding a metrics card to show the number of patients waiting to be served by the provider logged in
  • Loading branch information
Daphne210 authored Feb 19, 2024
1 parent 55d4cb6 commit b1e7597
Show file tree
Hide file tree
Showing 4 changed files with 285 additions and 269 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const PatientQueueHeader: React.FC<{ title?: string }> = ({ title }) => {
<div className={styles['left-justified-items']}>
<PatientQueueIllustration />
<div className={styles['page-labels']}>
<p>{t('queues', 'Patient queues ')}</p>
<p className={styles['page-name']}>{title ?? t('home', 'Home')}</p>
<p>{title ?? t('home', 'Home')}</p>
<p className={styles['page-name']}>{t('queues', 'Patient Queues ')}</p>
</div>
</div>
<div className={styles['right-justified-items']}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ function ClinicMetrics() {
const { t } = useTranslation();

const session = useSession();
const creatorUuid = session?.user?.uuid;
const creatorUuid = session?.user?.person?.display;

const { location: locations, isLoading: loading } = useParentLocation(session?.sessionLocation?.uuid);

const { patientQueueCount, isLoading } = usePatientsBeingServed(session?.sessionLocation?.uuid, 'pending');
const { patientQueueCount, isLoading } = usePatientsBeingServed(
session?.sessionLocation?.uuid,
'pending',
creatorUuid,
);

const { servedCount } = usePatientsServed(session?.sessionLocation?.uuid, 'picked');

Expand Down Expand Up @@ -58,7 +62,7 @@ function ClinicMetrics() {
/>
<MetricsCard
values={[{ label: 'Expected Appointments', value: appointmentList?.length }]}
headerLabel={t('noOfExpectedAppointments', 'No. Of Expected Appointments')}
headerLabel={t('noOfExpectedAppointments', 'No. of Expected Appointments')}
/>
<MetricsCard
values={[
Expand All @@ -74,12 +78,16 @@ function ClinicMetrics() {

<UserHasAccess privilege={PRIVILIGE_TRIAGE_METRIC}>
<MetricsCard
values={[{ label: 'Patients waiting to be Served', value: pendingCount }]}
values={[{ label: 'In Queue', value: pendingCount }]}
headerLabel={t('inQueueTriage', 'Patients Waiting')}
/>
<MetricsCard
values={[{ label: t('byTriage', 'By you'), value: patientQueueCount }]}
headerLabel={t('pendingTriageServing', 'Patients waiting to be Served')}
/>
<MetricsCard
values={[{ label: 'Patients Served', value: servedCount }]}
headerLabel={t('noOfPatientsServed', 'No. Of Patients Served')}
headerLabel={t('noOfPatientsServed', 'No. of Patients Served')}
/>
</UserHasAccess>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,14 +385,18 @@ export function usePatientBeingServed(currentQueueLocationUuid: string, status:
};
}

export function usePatientsBeingServed(currentQueueLocationUuid: string, status: string) {
export function usePatientsBeingServed(currentQueueLocationUuid: string, status: string, loggedInProviderUuid: string) {
const apiUrl = `/ws/rest/v1/patientqueue?v=full&location=${currentQueueLocationUuid}&status=${status}`;
const { data, error, isLoading, isValidating, mutate } = useSWR<{ data: { results: Array<PatientQueue> } }, Error>(
apiUrl,
openmrsFetch,
);

const mapppedQueues = data?.data?.results.map((queue: PatientQueue) => {
const filteredQueues = data?.data?.results.filter(
(queue: PatientQueue) => queue.provider?.person.display === loggedInProviderUuid,
);

const mapppedQueues = filteredQueues?.map((queue: PatientQueue) => {
return {
...queue,
id: queue.uuid,
Expand Down
Loading

0 comments on commit b1e7597

Please sign in to comment.