diff --git a/src/pages/Appointments/AppointmentDetail.tsx b/src/pages/Appointments/AppointmentDetail.tsx index ad009ef14cf..ab46fa0b7f9 100644 --- a/src/pages/Appointments/AppointmentDetail.tsx +++ b/src/pages/Appointments/AppointmentDetail.tsx @@ -43,6 +43,7 @@ import { AppointmentRead, AppointmentStatus, AppointmentUpdateRequest, + CancelledAppointmentStatuses, SchedulableResourceType, formatScheduleResourceName, } from "@/types/scheduling/schedule"; @@ -306,9 +307,9 @@ export default function AppointmentDetail(props: Props) { facility={facility} />
-

{t("token")}

{appointment.token?.number ? ( <> +

{t("token")}

) : ( - !["fulfilled"].includes(appointment.status) && + !AppointmentFinalStatuses.includes(appointment.status) && canWriteToken && ( -
- -
-
- {t("token_not_generated")} -
-

- {t("token_not_generated_description")} -

-
-
- - - {t("generate_token")} - - - } - onSuccess={() => { - queryClient.invalidateQueries({ - queryKey: ["appointment", appointment.id], - }); - }} - /> + <> +

{t("token")}

+
+ +
+
+ {t("token_not_generated")} +
+

+ {t("token_not_generated_description")} +

+
+
+ + + {t("generate_token")} + + + } + onSuccess={() => { + queryClient.invalidateQueries({ + queryKey: ["appointment", appointment.id], + }); + }} + /> +
-
+ ) )} {appointment.associated_encounter?.id && ( @@ -457,79 +461,83 @@ export default function AppointmentDetail(props: Props) { )} - {/* Lets only show encounter details if the appointment is not in a final status or if there is an encounter linked to the appointment */} - {![...AppointmentFinalStatuses].includes(appointment.status) && ( -
-

- {t("quick_actions")} -

-
- {/* Start Consultation - For booked and checked in appointments */} - {["booked", "checked_in"].includes(currentStatus) && - canCheckIn && - (appointment.associated_encounter?.id ? ( - // When encounter exists: set status to in_consultation and redirect - } - title={t("start_consultation")} - actionId="start-consultation" - onClick={() => { - updateAppointment({ - status: AppointmentStatus.IN_CONSULTATION, - note: appointment.note, - }); - navigate( - `/facility/${facilityId}/patient/${appointment.patient.id}/encounter/${appointment.associated_encounter!.id}/updates`, - ); - }} - /> - ) : ( - // When no encounter exists: create encounter and set status to in_consultation +
+

+ {t("quick_actions")} +

+
+ {!AppointmentFinalStatuses.includes(appointment.status) && ( + <> + {/* Start Consultation - For booked and checked in appointments */} + {["booked", "checked_in"].includes(currentStatus) && + canCheckIn && + (appointment.associated_encounter?.id ? ( + // When encounter exists: set status to in_consultation and redirect + } + title={t("start_consultation")} + actionId="start-consultation" + onClick={() => { + updateAppointment({ + status: AppointmentStatus.IN_CONSULTATION, + note: appointment.note, + }); + navigate( + `/facility/${facilityId}/patient/${appointment.patient.id}/encounter/${appointment.associated_encounter!.id}/updates`, + ); + }} + /> + ) : ( + // When no encounter exists: create encounter and set status to in_consultation + } + title={t("start_consultation")} + actionId="start-consultation" + /> + } + onSuccess={() => { + updateAppointment({ + status: AppointmentStatus.IN_CONSULTATION, + note: appointment.note, + }); + }} + /> + ))} + + {!appointment.associated_encounter?.id && ( } - title={t("start_consultation")} - actionId="start-consultation" + icon={ + + } + title={t("create_planned_encounter")} + actionId="create-encounter" /> } onSuccess={() => { - updateAppointment({ - status: AppointmentStatus.IN_CONSULTATION, - note: appointment.note, + queryClient.invalidateQueries({ + queryKey: ["appointment", appointment.id], }); }} /> - ))} - - {!appointment.associated_encounter?.id && ( - } - title={t("create_planned_encounter")} - actionId="create-encounter" - /> - } - onSuccess={() => { - queryClient.invalidateQueries({ - queryKey: ["appointment", appointment.id], - }); - }} - /> - )} - {/* Print Appointment */} + )} + + )} + {!CancelledAppointmentStatuses.includes(appointment.status) && ( } title={t("print_appointment")} @@ -537,17 +545,16 @@ export default function AppointmentDetail(props: Props) { basePath="/" href={`/facility/${facilityId}/patient/${appointment.patient.id}/appointments/${appointment.id}/print`} /> - - } - title={t("accounts")} - actionId="goto-account" - basePath="/" - href={`/facility/${facilityId}/billing/account?status=active&patient_filter=${appointment.patient.id}&patient_name=${appointment.patient.name}`} - /> -
+ )} + } + title={t("accounts")} + actionId="goto-account" + basePath="/" + href={`/facility/${facilityId}/billing/account?status=active&patient_filter=${appointment.patient.id}&patient_name=${encodeURIComponent(appointment.patient.name || "")}`} + />
- )} +