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

Fix : Cancelled requests in appointments page and Remove files button from actions #10219

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
73 changes: 38 additions & 35 deletions src/components/Patient/PatientHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import { useTranslation } from "react-i18next";
import CareIcon from "@/CAREUI/icons/CareIcon";

import { Button } from "@/components/ui/button";
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "@/components/ui/tooltip";

import { Avatar } from "@/components/Common/Avatar";
import Loading from "@/components/Common/Loading";
Expand Down Expand Up @@ -137,21 +143,6 @@ export const PatientHome = (props: {
<div className="mt-2 h-full space-y-2">
<div className="space-y-3 text-left text-lg font-semibold text-secondary-900">
<div className="space-y-2">
<Button
className="w-full bg-white font-semibold text-green-800 hover:bg-secondary-200"
id="upload-patient-files"
onClick={() =>
navigate(
`/facility/${facilityId}/patient/${id}/files`,
)
}
>
<span className="flex w-full items-center justify-start gap-2">
<CareIcon icon="l-file-upload" className="text-xl" />
{t("view_update_patient_files")}
</span>
</Button>

<PLUGIN_Component
__name="PatientHomeActions"
patient={patientData}
Expand All @@ -177,16 +168,22 @@ export const PatientHome = (props: {
</span>
</div>
<div className="whitespace-normal text-sm font-semibold text-gray-900">
<div className="tooltip">
<span className={`tooltip-text tooltip`}>
{patientData.modified_date
? formatDateTime(patientData.modified_date)
: "--:--"}
</span>
{patientData.modified_date
? relativeDate(patientData.modified_date)
: "--:--"}
</div>
<TooltipProvider delayDuration={1}>
<Tooltip>
<TooltipTrigger asChild>
<span>
{patientData.modified_date
? relativeDate(patientData.modified_date)
: "--:--"}
</span>
</TooltipTrigger>
<TooltipContent>
{patientData.modified_date
? formatDateTime(patientData.modified_date)
: "--:--"}
</TooltipContent>
</Tooltip>
</TooltipProvider>
</div>
</div>

Expand All @@ -199,16 +196,22 @@ export const PatientHome = (props: {
</span>
</div>
<div className="whitespace-normal text-sm font-semibold text-gray-900">
<div className="tooltip">
<span className={`tooltip-text tooltip`}>
{patientData.created_date
? formatDateTime(patientData.created_date)
: "--:--"}
</span>
{patientData.created_date
? relativeDate(patientData.created_date)
: "--:--"}
</div>
<TooltipProvider delayDuration={1}>
<Tooltip>
<TooltipTrigger asChild>
<span>
{patientData.created_date
? relativeDate(patientData.created_date)
: "--:--"}
</span>
</TooltipTrigger>
<TooltipContent>
{patientData.created_date
? formatDateTime(patientData.created_date)
: "--:--"}
</TooltipContent>
</Tooltip>
</TooltipProvider>
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Appointments/AppointmentsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ function AppointmentColumn(props: {
props.date_from,
props.date_to,
],
queryFn: query(scheduleApis.appointments.list, {
queryFn: query.debounced(scheduleApis.appointments.list, {
Copy link
Member

Choose a reason for hiding this comment

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

this is not the right solution. this just hides the root cause of firing duplicate issues by leveraging cancellations. let's solve the root issue instead of solving the side-effect.

Copy link
Contributor Author

@Mahendar0701 Mahendar0701 Jan 29, 2025

Choose a reason for hiding this comment

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

@rithviknishad

The root cause here is , qParams are not loaded on initially render, later qParams are fully loaded and then the query is being triggered again and causing cancelling of previous queries. This is happening only on initial visit of encounter tab.

image

  const isQParamsLoaded = Object.keys(qParams).length > 0;
    if (!isQParamsLoaded || schedulableUsersQuery.isLoading) {
    return <Loading />;
  }
  1. Adding query.debounced

Which approach you will prefer??

Copy link
Contributor

@Jacobjeevan Jacobjeevan Jan 30, 2025

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

yup, agree with @Jacobjeevan

let's enable appointments fetch only when date params are present.

pathParams: { facility_id: props.facilityId },
queryParams: {
status: props.status,
Expand Down Expand Up @@ -775,7 +775,7 @@ function AppointmentRow(props: {
props.date_from,
props.date_to,
],
queryFn: query(scheduleApis.appointments.list, {
queryFn: query.debounced(scheduleApis.appointments.list, {
pathParams: { facility_id: props.facilityId },
queryParams: {
status: status,
Expand Down
Loading