From 310a8651ec59f6a66aedfc4578246bd508cdcd3e Mon Sep 17 00:00:00 2001 From: Khavin Shankar Date: Wed, 8 Jan 2025 23:48:29 +0530 Subject: [PATCH 01/56] added patient home actions plugin hook --- .../ConsultationDetails/EncounterContext.tsx | 2 -- src/components/Patient/PatientHome.tsx | 11 +++++-- src/pluginTypes.ts | 32 +++---------------- 3 files changed, 14 insertions(+), 31 deletions(-) diff --git a/src/components/Facility/ConsultationDetails/EncounterContext.tsx b/src/components/Facility/ConsultationDetails/EncounterContext.tsx index e0ba1d6228a..07d76a7f538 100644 --- a/src/components/Facility/ConsultationDetails/EncounterContext.tsx +++ b/src/components/Facility/ConsultationDetails/EncounterContext.tsx @@ -1,6 +1,5 @@ import { ReactNode, createContext, useContext, useState } from "react"; -import { PLUGIN_Component } from "@/PluginEngine"; import { Encounter } from "@/types/emr/encounter"; import { Patient } from "@/types/emr/newPatient"; @@ -65,7 +64,6 @@ export const EncounterProvider = ({ } as EncounterContextType } > - {children} ); diff --git a/src/components/Patient/PatientHome.tsx b/src/components/Patient/PatientHome.tsx index 1f149b82365..4ccdfc13f48 100644 --- a/src/components/Patient/PatientHome.tsx +++ b/src/components/Patient/PatientHome.tsx @@ -11,6 +11,7 @@ import Loading from "@/components/Common/Loading"; import Page from "@/components/Common/Page"; import { patientTabs } from "@/components/Patient/PatientDetailsTab"; +import { PLUGIN_Component } from "@/PluginEngine"; import routes from "@/Utils/request/api"; import query from "@/Utils/request/query"; import { formatPatientAge } from "@/Utils/utils"; @@ -230,8 +231,8 @@ export const PatientHome = (props: { {t("actions")}
-
-
+
+
+ +
{/* {NonReadOnlyUsers && ( diff --git a/src/pluginTypes.ts b/src/pluginTypes.ts index 28511669887..0697a24e902 100644 --- a/src/pluginTypes.ts +++ b/src/pluginTypes.ts @@ -4,15 +4,10 @@ import { FacilityModel } from "@/components/Facility/models"; import { UserAssignedModel } from "@/components/Users/models"; import { EncounterTabProps } from "@/pages/Encounters/EncounterShow"; +import { Patient } from "@/types/emr/newPatient"; import { AppRoutes } from "./Routers/AppRouter"; -import { FormContextValue } from "./components/Form/FormContext"; -import { PatientMeta } from "./components/Patient/models"; import { pluginMap } from "./pluginMap"; -import { PatientModel } from "./types/emr/patient"; - -export type PatientForm = PatientModel & - PatientMeta & { age?: number; is_postpartum?: boolean }; export type DoctorConnectButtonComponentType = React.FC<{ user: UserAssignedModel; @@ -23,33 +18,16 @@ export type ManageFacilityOptionsComponentType = React.FC<{ facility?: FacilityModel; }>; -export type ExtendFacilityConfigureComponentType = React.FC<{ - facilityId: string; -}>; - -export type ExtendPatientRegisterFormComponentType = React.FC<{ - facilityId: string; - patientId?: string; - state: { - form: { - [key: string]: any; - }; - errors: { - [key: string]: string; - }; - }; - dispatch: React.Dispatch; - field: FormContextValue; +export type PatientHomeActionsComponentType = React.FC<{ + patient: Patient; + className?: string; }>; // Define supported plugin components export type SupportedPluginComponents = { DoctorConnectButtons: DoctorConnectButtonComponentType; Scribe: ScribeComponentType; - ManageFacilityOptions: ManageFacilityOptionsComponentType; - EncounterContextEnabler: React.FC; - ExtendFacilityConfigure: ExtendFacilityConfigureComponentType; - ExtendPatientRegisterForm: ExtendPatientRegisterFormComponentType; + PatientHomeActions: PatientHomeActionsComponentType; }; // Create a type for lazy-loaded components From 5d481c8306622996da3dc0d96ec868855853be03 Mon Sep 17 00:00:00 2001 From: Khavin Shankar Date: Wed, 8 Jan 2025 23:49:53 +0530 Subject: [PATCH 02/56] expose core app env in global scope --- vite.config.mts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/vite.config.mts b/vite.config.mts index 61046ba878d..142ff8cde38 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -182,6 +182,7 @@ export default defineConfig(({ mode }) => { __CUSTOM_DESCRIPTION_HTML__: getDescriptionHtml( env.REACT_CUSTOM_DESCRIPTION || "", ), + __CORE_ENV__: { ...env }, }, plugins: [ federation({ @@ -194,7 +195,12 @@ export default defineConfig(({ mode }) => { // from: "vite", // }, // }, - shared: ["react", "react-dom"], + shared: [ + "react", + "react-dom", + "react-i18next", + "@tanstack/react-query", + ], }), ValidateEnv({ validator: "zod", From 34580bc32c35529df14e2c30acc4c65f1931f8c3 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Fri, 3 Jan 2025 19:08:34 +0000 Subject: [PATCH 03/56] enable heatmap and fix appointments column size (#9713) --- care.config.ts | 2 +- src/components/Schedule/Appointments/AppointmentsPage.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/care.config.ts b/care.config.ts index e6ace8bbdea..1498de9bb18 100644 --- a/care.config.ts +++ b/care.config.ts @@ -107,7 +107,7 @@ const careConfig = { // Kill switch in-case the heatmap API doesn't scale as expected useAvailabilityStatsAPI: boolean( "REACT_APPOINTMENTS_USE_AVAILABILITY_STATS_API", - false, + true, ), }, diff --git a/src/components/Schedule/Appointments/AppointmentsPage.tsx b/src/components/Schedule/Appointments/AppointmentsPage.tsx index 75ebbe19881..bd12619aea3 100644 --- a/src/components/Schedule/Appointments/AppointmentsPage.tsx +++ b/src/components/Schedule/Appointments/AppointmentsPage.tsx @@ -385,7 +385,7 @@ function AppointmentColumn(props: {
{appointments.length === 0 ? ( -
+

{t("no_appointments")}

) : ( From c4380eae79c888fa98291e5b05c29f6040fe3172 Mon Sep 17 00:00:00 2001 From: Abhimanyu Rajeesh <63541653+abhimanyurajeesh@users.noreply.github.com> Date: Sat, 4 Jan 2025 02:16:40 +0530 Subject: [PATCH 04/56] Fix: Forgot password error should be handled properly (#9707) * forgot password mutation * updated --- src/components/Auth/Login.tsx | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/components/Auth/Login.tsx b/src/components/Auth/Login.tsx index 392fe43db70..531093588e4 100644 --- a/src/components/Auth/Login.tsx +++ b/src/components/Auth/Login.tsx @@ -4,6 +4,7 @@ import { Link } from "raviger"; import { useEffect, useState } from "react"; import ReCaptcha from "react-google-recaptcha"; import { useTranslation } from "react-i18next"; +import { toast } from "sonner"; import { cn } from "@/lib/utils"; @@ -98,20 +99,10 @@ const Login = (props: { forgot?: boolean }) => { }); // Forgot Password Mutation - const forgotPasswordMutation = useMutation({ - mutationFn: async (data: { username: string }) => { - const response = await request(routes.forgotPassword, { - body: data, - }); - return response; - }, + const { mutate: submitForgetPassword } = useMutation({ + mutationFn: mutate(routes.forgotPassword), onSuccess: () => { - Notification.Success({ - msg: t("password_sent"), - }); - }, - onError: (error: any) => { - setErrors(error); + toast.success(t("password_sent")); }, }); @@ -292,7 +283,7 @@ const Login = (props: { forgot?: boolean }) => { const valid = validateForgetData(); if (!valid) return; - forgotPasswordMutation.mutate(valid); + submitForgetPassword(valid); }; const onCaptchaChange = (value: any) => { @@ -322,10 +313,7 @@ const Login = (props: { forgot?: boolean }) => { // Loading state derived from mutations const isLoading = - staffLoginMutation.isPending || - forgotPasswordMutation.isPending || - sendOtpPending || - verifyOtpPending; + staffLoginMutation.isPending || sendOtpPending || verifyOtpPending; const logos = [stateLogo, customLogo].filter( (logo) => logo?.light || logo?.dark, From 5de0532bfb9a7de89c1de2bb3004c4d3f1c3280b Mon Sep 17 00:00:00 2001 From: Anvesh Nalimela <151531961+AnveshNalimela@users.noreply.github.com> Date: Sat, 4 Jan 2025 21:06:41 +0530 Subject: [PATCH 05/56] Added no user assingned message (#9666) Co-authored-by: Rithvik Nishad --- public/locale/en.json | 9 + .../PatientDetailsTab/PatientUsers.tsx | 165 ++++++++++-------- 2 files changed, 101 insertions(+), 73 deletions(-) diff --git a/public/locale/en.json b/public/locale/en.json index 65093b6acae..1a858bb77a8 100644 --- a/public/locale/en.json +++ b/public/locale/en.json @@ -376,6 +376,7 @@ "are_you_still_watching": "Are you still watching?", "are_you_sure_want_to_delete": "Are you sure you want to delete {{name}}?", "are_you_sure_want_to_delete_this_record": "Are you sure want to delete this record?", + "are_you_sure_want_to_remove": "Are you sure you want to remove {{name}} from the patient? This action cannot be undone", "ari": "ARI - Acute Respiratory illness", "arrived": "Arrived", "asset_class": "Asset Class", @@ -388,7 +389,10 @@ "assign": "Assign", "assign_a_volunteer_to": "Assign a volunteer to {{name}}", "assign_bed": "Assign Bed", + "assign_to_patient": "Assign to Patient", "assign_to_volunteer": "Assign to a Volunteer", + "assign_user": "Assign User", + "assign_user_to_patient": "Assign User to Patient", "assigned_doctor": "Assigned Doctor", "assigned_facility": "Facility assigned", "assigned_to": "Assigned to", @@ -1239,6 +1243,7 @@ "no_staff": "No staff found", "no_tests_taken": "No tests taken", "no_treating_physicians_available": "This facility does not have any home facility doctors. Please contact your admin.", + "no_user_assigned": "No User Assigned to this patient", "no_users_found": "No Users Found", "no_vitals_present": "No Vitals Monitor present in this location or facility", "none": "None", @@ -1482,6 +1487,7 @@ "rejected": "Rejected", "reload": "Reload", "remove": "Remove", + "remove_user": "Remove User", "rename": "Rename", "replace_home_facility": "Replace Home Facility", "replace_home_facility_confirm": "Are you sure you want to replace", @@ -1570,6 +1576,8 @@ "search_medication": "Search Medication", "search_patients": "Search Patients", "search_resource": "Search Resource", + "search_user": "Search User", + "search_user_description": "Search for a user and assign a role to add them to the patient.", "searching": "Searching...", "see_attachments": "See Attachments", "select": "Select", @@ -1588,6 +1596,7 @@ "select_policy_to_add_items": "Select a Policy to Add Items", "select_practitioner": "Select Practicioner", "select_register_patient": "Select/Register Patient", + "select_role": "Select Role", "select_seven_day_period": "Select a seven day period", "select_skills": "Select and add some skills", "select_time": "Select time", diff --git a/src/components/Patient/PatientDetailsTab/PatientUsers.tsx b/src/components/Patient/PatientDetailsTab/PatientUsers.tsx index e494b13fe9d..989b3ed0ac3 100644 --- a/src/components/Patient/PatientDetailsTab/PatientUsers.tsx +++ b/src/components/Patient/PatientDetailsTab/PatientUsers.tsx @@ -1,4 +1,5 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; +import { t } from "i18next"; import { useState } from "react"; import { toast } from "sonner"; @@ -38,6 +39,7 @@ import UserSelector from "@/components/Common/UserSelector"; import routes from "@/Utils/request/api"; import mutate from "@/Utils/request/mutate"; import query from "@/Utils/request/query"; +import { formatDisplayName } from "@/Utils/utils"; import { UserBase } from "@/types/user/user"; import { PatientProps } from "."; @@ -103,19 +105,17 @@ function AddUserSheet({ patientId }: AddUserSheetProps) { - Add User to Patient - - Search for a user and assign a role to add them to the patient. - + {t("assign_user_to_patient")} + {t("search_user_description")}
-

Search User

+

{t("search_user")}

- {selectedUser.first_name} {selectedUser.last_name} + {formatDisplayName(selectedUser)} {selectedUser.email} @@ -144,13 +144,17 @@ function AddUserSheet({ patientId }: AddUserSheetProps) {
- Username + + {t("username")} +

{selectedUser.username}

- User Type + + {t("user_type")} +

{selectedUser.user_type}

@@ -159,7 +163,9 @@ function AddUserSheet({ patientId }: AddUserSheetProps) {
- + +
+ {/* Basic Information */} +
+

Basic Information

+
+ ( + + Facility Type + + + + )} + /> + + ( + + Facility Name - - - + - - {FACILITY_TYPES.map((type) => ( - - {type.text} - - ))} - - - - - )} - /> + + + )} + /> +
( - Facility Name + Description - +