Skip to content

Commit

Permalink
U4X-456 : fix queue statistics flickering (#189)
Browse files Browse the repository at this point in the history
U4X-456 : fix queue statistics flickering (#189)
  • Loading branch information
jabahum authored Mar 17, 2024
1 parent a85c2ac commit 6291e88
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ const ActiveVisitsTable: React.FC<ActiveVisitsTableProps> = ({ status }) => {
{session?.user && userHasAccess(PRIVILEGE_ENABLE_EDIT_DEMOGRAPHICS, session.user) && (
<EditActionsMenu to={`\${openmrsSpaBase}/patient/${entry?.patientUuid}/edit`} from={fromPage} />
)}
<ViewActionsMenu to={`\${openmrsSpaBase}/patient/${entry?.patientUuid}/chart`} from={fromPage} />
</>
))}
<ViewActionsMenu to={`\${openmrsSpaBase}/patient/${entry?.patientUuid}/chart`} from={fromPage} />
<NotesActionsMenu note={entry} />
</>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ const ChangeStatus: React.FC<ChangeStatusDialogProps> = ({ queueEntry, currentEn
subtitle: t('visitEndSuccessfully', `${response?.data?.visitType?.display} ended successfully`),
title: t('visitEnded', 'Visit ended'),
});
navigate({ to: `\${openmrsSpaBase}/home/patient-queues` });

closeModal();
mutate();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ const ChangeStatusMoveToNext: React.FC<ChangeStatusDialogProps> = ({ patientUuid
subtitle: t('visitEndSuccessfully', `${response?.data?.visitType?.display} ended successfully`),
title: t('visitEnded', 'Visit ended'),
});

navigate({ to: `\${openmrsSpaBase}/home/patient-queues` });

closeModal();
mutate();
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { UserHasAccess, useSession } from '@openmrs/esm-framework';
import React from 'react';
import React, { useCallback, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { PRIVILEGE_RECEPTION_METRIC, PRIVILIGE_TRIAGE_METRIC } from '../constants';

Expand All @@ -15,6 +15,7 @@ import { useParentLocation } from '../active-visits/patient-queues.resource';
import { usePatientQueuesList } from '../active-visit-patient-reception/active-visits-reception.resource';
import { CheckmarkOutline, Pending, ProgressBarRound } from '@carbon/react/icons';
import { Tooltip as ReactTooltip } from 'react-tooltip';
import dayjs from 'dayjs';

const ClinicMetrics: React.FC = () => {
const { t } = useTranslation();
Expand All @@ -26,7 +27,11 @@ const ClinicMetrics: React.FC = () => {
const creatorUuid = session?.user?.person?.display;
const { patientQueueCount } = usePatientsBeingServed(session?.sessionLocation?.uuid, 'pending', creatorUuid);

const { stats } = useServicePointCount(location?.parentLocation?.uuid, new Date(), new Date());
const { stats } = useServicePointCount(
location?.parentLocation?.uuid,
dayjs(new Date()).format('YYYY-MM-DD'),
dayjs(new Date()).format('YYYY-MM-DD'),
);

return (
<div className={styles.cardContainer}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ export interface Link {
resourceAlias: string;
}

export function useServicePointCount(parentLocation: string, beforeDate: Date, afterDate: Date) {
export function useServicePointCount(parentLocation: string, beforeDate: String, afterDate: String) {
const apiUrl = `/ws/rest/v1/queuestatistics?parentLocation=${parentLocation}&toDate=${afterDate}&fromDate=${beforeDate}`;
const { data, error, isLoading, isValidating, mutate } = useSWR<{ data: { results: Array<PatientStats> } }, Error>(
apiUrl,
Expand Down

0 comments on commit 6291e88

Please sign in to comment.