From 316f2e2755d9deee2a38b1453d863ac7af831711 Mon Sep 17 00:00:00 2001 From: mahendar Date: Wed, 11 Dec 2024 15:00:10 +0530 Subject: [PATCH 01/20] patient header and other fixes --- .../Patient/PatientDetailsTab/Demography.tsx | 2 +- src/components/Patient/PatientHome.tsx | 300 +++++++++--------- 2 files changed, 150 insertions(+), 152 deletions(-) diff --git a/src/components/Patient/PatientDetailsTab/Demography.tsx b/src/components/Patient/PatientDetailsTab/Demography.tsx index b9d2b8fece4..69029d9a292 100644 --- a/src/components/Patient/PatientDetailsTab/Demography.tsx +++ b/src/components/Patient/PatientDetailsTab/Demography.tsx @@ -226,7 +226,7 @@ export const Demography = (props: PatientProps) => { }, { label: t("state"), - value: patientData.state, + value: patientData?.state_object?.name, }, { label: t("district"), diff --git a/src/components/Patient/PatientHome.tsx b/src/components/Patient/PatientHome.tsx index a63f3202f98..2aebf2887e4 100644 --- a/src/components/Patient/PatientHome.tsx +++ b/src/components/Patient/PatientHome.tsx @@ -39,7 +39,6 @@ import Loading from "../Common/Loading"; import Page from "../Common/Page"; import { SkillModel, UserBareMinimum } from "../Users/models"; import { patientTabs } from "./PatientDetailsTab"; -import { isPatientMandatoryDataFilled } from "./Utils"; import { AssignedToObjectModel, PatientModel, SampleTestModel } from "./models"; export const parseOccupation = (occupation: string | undefined) => { @@ -266,172 +265,171 @@ export const PatientHome = (props: { -
-
- {isPatientMandatoryDataFilled(patientData) && - (!patientData.last_consultation || - patientData.last_consultation?.facility !== - patientData.facility || - (patientData.last_consultation?.discharge_date && - patientData.is_active)) && ( - - - - - +
+
+
+

+ {t("facility")}: +

+

+ {patientData.facility_object?.name || "-"} +

+
+ + {patientData?.last_consultation + ?.treating_physician_object && ( +
+

+ {t("treating_doctor")}: +

+
+

+ {formatName( + patientData.last_consultation + .treating_physician_object, + )} +

+ + {!!skillsQuery.data?.results?.length && + formatSkills(skillsQuery.data?.results)} + {(skillsQuery.data?.results?.length || 0) > 3 && ( +
    + {skillsQuery.data?.results.map((skill) => ( +
  • + {skill.skill_object.name} +
  • + ))} +
+ )}
- - )} - {patientData.is_vaccinated && ( - +
+
)} - {patientData.allow_transfer ? ( - - ) : ( - + {patientData?.last_consultation?.assigned_to_object && ( +
+

+ {t("assigned_doctor")}: +

+
+

+ {formatName( + patientData.last_consultation.assigned_to_object, + )} +

+ {patientData?.last_consultation?.assigned_to_object + .alt_phone_number && ( + + {" "} + {t("video_call")} + + )} +
+
+ )} + + {patientData.assigned_to_object && ( +
+

+ {t("assigned_volunteer")}: +

+

+ {formatName(patientData.assigned_to_object)} +

+
)} +
- {patientData.gender === 2 && ( - <> - {patientData.is_antenatal && - isAntenatal( - patientData.last_menstruation_start_date, - ) && ( +
+
+ {!patientData?.last_consultation && ( + + )} + {patientData.is_vaccinated && ( + + )} + {patientData.allow_transfer ? ( + + ) : ( + + )} + + {patientData.gender === 2 && ( + <> + {patientData.is_antenatal && + isAntenatal( + patientData.last_menstruation_start_date, + ) && ( + + )} + {isPostPartum(patientData.date_of_delivery) && ( )} - {isPostPartum(patientData.date_of_delivery) && ( + + )} + {patientData.last_consultation?.is_telemedicine && ( + + )} + {patientData.allergies && ( + + )} + {patientData.state_object && + patientData.district_object && ( )} - - )} - {patientData.last_consultation?.is_telemedicine && ( - - )} - {patientData.allergies && ( - - )} -
-
- -
-
-

- {t("facility")}: -

-

- {patientData.facility_object?.name || "-"} -

-
- - {patientData?.last_consultation?.treating_physician_object && ( -
-

- {t("treating_doctor")}: -

-
-

- {formatName( - patientData.last_consultation - .treating_physician_object, - )} -

- - {!!skillsQuery.data?.results?.length && - formatSkills(skillsQuery.data?.results)} - {(skillsQuery.data?.results?.length || 0) > 3 && ( -
    - {skillsQuery.data?.results.map((skill) => ( -
  • - {skill.skill_object.name} -
  • - ))} -
- )} -
-
- )} - {patientData?.last_consultation?.assigned_to_object && ( -
-

- {t("assigned_doctor")}: -

-
-

- {formatName( - patientData.last_consultation.assigned_to_object, - )} -

- {patientData?.last_consultation?.assigned_to_object - .alt_phone_number && ( - - {" "} - {t("video_call")} - - )} -
-
- )} - - {patientData.assigned_to_object && ( -
-

- {t("assigned_volunteer")}: -

-

- {formatName(patientData.assigned_to_object)} -

-
- )} +
From 38bcda5ee208e372067f06d8b2960f5ca9b84358 Mon Sep 17 00:00:00 2001 From: mahendar Date: Wed, 11 Dec 2024 17:06:52 +0530 Subject: [PATCH 02/20] changes --- public/locale/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/locale/en.json b/public/locale/en.json index 9f0bc5ecf12..2514f346cf1 100644 --- a/public/locale/en.json +++ b/public/locale/en.json @@ -1116,7 +1116,7 @@ "patient_consultation__treatment__summary__spo2": "SpO2", "patient_consultation__treatment__summary__temperature": "Temperature", "patient_created": "Patient Created", - "patient_details": "Patient Details", + "patient_details": "Details of Patient", "patient_details_incomplete": "Patient Details Incomplete", "patient_face": "Patient Face", "patient_name": "Patient name", From b6621a57f9b3b7ba15548d321ab1aed926468a4b Mon Sep 17 00:00:00 2001 From: mahendar Date: Thu, 12 Dec 2024 00:03:51 +0530 Subject: [PATCH 03/20] transfer label position updated --- src/components/Patient/PatientHome.tsx | 30 +++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/components/Patient/PatientHome.tsx b/src/components/Patient/PatientHome.tsx index 2aebf2887e4..636a5bf7a24 100644 --- a/src/components/Patient/PatientHome.tsx +++ b/src/components/Patient/PatientHome.tsx @@ -365,20 +365,6 @@ export const PatientHome = (props: { text={t("vaccinated")} /> )} - {patientData.allow_transfer ? ( - - ) : ( - - )} {patientData.gender === 2 && ( <> @@ -561,7 +547,21 @@ export const PatientHome = (props: { -
+
+ {patientData.allow_transfer ? ( + + ) : ( + + )}
Date: Thu, 12 Dec 2024 23:41:59 +0530 Subject: [PATCH 04/20] allergies --- src/components/Patient/PatientHome.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/components/Patient/PatientHome.tsx b/src/components/Patient/PatientHome.tsx index 3191e109f12..3ddca0128c1 100644 --- a/src/components/Patient/PatientHome.tsx +++ b/src/components/Patient/PatientHome.tsx @@ -414,13 +414,14 @@ export const PatientHome = (props: { text={t("TELEMEDICINE")} /> )} - {patientData.allergies && ( - - )} + {patientData.allergies && + patientData.allergies.trim().length > 0 && ( + + )} {patientData.state_object && patientData.district_object && ( Date: Fri, 13 Dec 2024 00:12:21 +0530 Subject: [PATCH 05/20] changes --- src/components/Patient/PatientDetailsTab/Demography.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Patient/PatientDetailsTab/Demography.tsx b/src/components/Patient/PatientDetailsTab/Demography.tsx index b14546686ec..da1b2a91c01 100644 --- a/src/components/Patient/PatientDetailsTab/Demography.tsx +++ b/src/components/Patient/PatientDetailsTab/Demography.tsx @@ -104,7 +104,7 @@ export const Demography = (props: PatientProps) => { const EmergencyContact = (props: { number?: string; name?: string }) => (
- {/* Emergency Contact Section */} + {/* Emergency contact Section */}
{t("emergency_contact")} From 83d2fb86ef7ce329f8c7da1e96ebebd12de48ce9 Mon Sep 17 00:00:00 2001 From: mahendar Date: Fri, 13 Dec 2024 14:16:03 +0530 Subject: [PATCH 06/20] adjusted margin --- src/components/Patient/PatientHome.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Patient/PatientHome.tsx b/src/components/Patient/PatientHome.tsx index 4a2fe7cee01..16d00db1b78 100644 --- a/src/components/Patient/PatientHome.tsx +++ b/src/components/Patient/PatientHome.tsx @@ -283,8 +283,8 @@ export const PatientHome = (props: {
-
-
+
+

{t("facility")}: @@ -366,7 +366,7 @@ export const PatientHome = (props: {

-
+
{!patientData?.last_consultation && ( Date: Sat, 14 Dec 2024 00:05:31 +0530 Subject: [PATCH 07/20] added varients to badge --- src/components/Patient/PatientHome.tsx | 111 ++++++++++++------------- src/components/ui/badge.tsx | 26 +++++- 2 files changed, 75 insertions(+), 62 deletions(-) diff --git a/src/components/Patient/PatientHome.tsx b/src/components/Patient/PatientHome.tsx index 16d00db1b78..188f5944aef 100644 --- a/src/components/Patient/PatientHome.tsx +++ b/src/components/Patient/PatientHome.tsx @@ -2,8 +2,23 @@ import { Link, navigate } from "raviger"; import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; +import CareIcon from "@/CAREUI/icons/CareIcon"; + +import { Badge } from "@/components/ui/badge"; + +import { Avatar } from "@/components/Common/Avatar"; +import ButtonV2 from "@/components/Common/ButtonV2"; import ConfirmDialog from "@/components/Common/ConfirmDialog"; +import Loading from "@/components/Common/Loading"; +import Page from "@/components/Common/Page"; import UserAutocomplete from "@/components/Common/UserAutocompleteFormField"; +import { patientTabs } from "@/components/Patient/PatientDetailsTab"; +import { + AssignedToObjectModel, + PatientModel, + SampleTestModel, +} from "@/components/Patient/models"; +import { SkillModel, UserBareMinimum } from "@/components/Users/models"; import useAuthUser from "@/hooks/useAuthUser"; @@ -14,16 +29,13 @@ import { SAMPLE_TEST_STATUS, } from "@/common/constants"; +import { triggerGoal } from "@/Integrations/Plausible"; +import { NonReadOnlyUsers } from "@/Utils/AuthorizeFor"; +import * as Notification from "@/Utils/Notifications"; import dayjs from "@/Utils/dayjs"; import routes from "@/Utils/request/api"; - -import Chip from "../../CAREUI/display/Chip"; -import CareIcon from "../../CAREUI/icons/CareIcon"; -import { triggerGoal } from "../../Integrations/Plausible"; -import { NonReadOnlyUsers } from "../../Utils/AuthorizeFor"; -import * as Notification from "../../Utils/Notifications"; -import request from "../../Utils/request/request"; -import useTanStackQueryInstead from "../../Utils/request/useQuery"; +import request from "@/Utils/request/request"; +import useTanStackQueryInstead from "@/Utils/request/useQuery"; import { formatDateTime, formatName, @@ -32,14 +44,7 @@ import { isAntenatal, isPostPartum, relativeDate, -} from "../../Utils/utils"; -import { Avatar } from "../Common/Avatar"; -import ButtonV2 from "../Common/ButtonV2"; -import Loading from "../Common/Loading"; -import Page from "../Common/Page"; -import { SkillModel, UserBareMinimum } from "../Users/models"; -import { patientTabs } from "./PatientDetailsTab"; -import { AssignedToObjectModel, PatientModel, SampleTestModel } from "./models"; +} from "@/Utils/utils"; export const parseOccupation = (occupation: string | undefined) => { return OCCUPATION_TYPES.find((i) => i.value === occupation)?.text; @@ -368,20 +373,21 @@ export const PatientHome = (props: {
{!patientData?.last_consultation && ( - + > + {t("Initial visit")} + )} {patientData.is_vaccinated && ( - + > + {t("vaccinated")} + )} {patientData.gender === 2 && ( @@ -390,48 +396,39 @@ export const PatientHome = (props: { isAntenatal( patientData.last_menstruation_start_date, ) && ( - + > + {t("antenatal")} + )} {isPostPartum(patientData.date_of_delivery) && ( - + > + {t("post_partum")} + )} )} {patientData.last_consultation?.is_telemedicine && ( - + + {t("TELEMEDICINE")} + )} {patientData.allergies && patientData.allergies.trim().length > 0 && ( - + {t("has_allergies")} )} {patientData.state_object && patientData.district_object && ( - + + {`${t("Location: ")} ${patientData?.district_object?.name}, ${patientData?.state_object?.name}`} + )}
@@ -570,19 +567,15 @@ export const PatientHome = (props: {
{patientData.allow_transfer ? ( - + + {t("transfer_allowed")} + ) : ( - + + {t("transfer_blocked")} + )} +
, - VariantProps {} + VariantProps { + startIcon?: IconName; + endIcon?: IconName; +} -function Badge({ className, variant, ...props }: BadgeProps) { +function Badge({ + className, + variant, + startIcon, + endIcon, + ...props +}: BadgeProps) { return (
+ > + {startIcon && } + {props.children} + {endIcon && } +
); } From be0183fe60157651086fb8fd9483b513f1d98cbb Mon Sep 17 00:00:00 2001 From: mahendar Date: Sun, 15 Dec 2024 15:10:36 +0530 Subject: [PATCH 08/20] replaced ButtonV2 with Button --- src/components/Patient/PatientHome.tsx | 49 ++++++++++++++------------ src/components/ui/button.tsx | 30 ++++++++++++++-- 2 files changed, 55 insertions(+), 24 deletions(-) diff --git a/src/components/Patient/PatientHome.tsx b/src/components/Patient/PatientHome.tsx index d620dbbaf55..7283ecfb29f 100644 --- a/src/components/Patient/PatientHome.tsx +++ b/src/components/Patient/PatientHome.tsx @@ -5,9 +5,9 @@ import { useTranslation } from "react-i18next"; import CareIcon from "@/CAREUI/icons/CareIcon"; import { Badge } from "@/components/ui/badge"; +import { Button } from "@/components/ui/button"; import { Avatar } from "@/components/Common/Avatar"; -import ButtonV2 from "@/components/Common/ButtonV2"; import ConfirmDialog from "@/components/Common/ConfirmDialog"; import Loading from "@/components/Common/Loading"; import Page from "@/components/Common/Page"; @@ -222,10 +222,11 @@ export const PatientHome = (props: { (!patientData?.last_consultation || patientData?.last_consultation?.discharge_date) && (
- navigate( `/facility/${patientData?.facility}/patient/${id}/consultation`, @@ -239,7 +240,7 @@ export const PatientHome = (props: { /> {t("add_consultation")} - +
)}
@@ -437,11 +438,12 @@ export const PatientHome = (props: { {t("actions")}
-
+
- navigate(`/patient/${id}/investigation_reports`) } @@ -453,13 +455,14 @@ export const PatientHome = (props: { /> {t("investigations_summary")} - +
- navigate( `/facility/${patientData?.facility}/patient/${id}/files`, @@ -470,18 +473,19 @@ export const PatientHome = (props: { {t("view_update_patient_files")} - +
{NonReadOnlyUsers && (
- setOpenAssignVolunteerDialog(true)} disabled={false} + variant="outline" authorizeFor={NonReadOnlyUsers} - className="w-full bg-white font-semibold text-green-800 hover:bg-secondary-200" - size="large" + className="w-full text-green-800 font-semibold hover:text-green-900" + size="lg" > {" "} @@ -489,15 +493,16 @@ export const PatientHome = (props: { ? t("update_volunteer") : t("assign_to_volunteer")} - +
)}
- - +
@@ -647,7 +652,7 @@ export const PatientHome = (props: { {patientData.last_consultation?.new_discharge_reason === DISCHARGE_REASONS.find((i) => i.text == "Expired")?.id && (
- {t("death_report")} - +
)}
diff --git a/src/components/ui/button.tsx b/src/components/ui/button.tsx index 0125726ce73..9ec7b20d54b 100644 --- a/src/components/ui/button.tsx +++ b/src/components/ui/button.tsx @@ -4,6 +4,10 @@ import * as React from "react"; import { cn } from "@/lib/utils"; +import AuthorizedChild from "@/CAREUI/misc/AuthorizedChild"; + +import { AuthorizedElementProps } from "@/Utils/AuthorizeFor"; + const buttonVariants = cva( "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-gray-950 disabled:pointer-events-none disabled:opacity-50 dark:focus-visible:ring-gray-300", { @@ -24,6 +28,8 @@ const buttonVariants = cva( link: "text-gray-900 underline-offset-4 hover:underline dark:text-gray-50", outline_primary: "border border-primary-700 text-primary-700 bg-white shadow-sm hover:bg-primary-700 hover:text-white dark:border-primary-700 dark:bg-primary-700 dark:text-white", + success: + "bg-green-500 text-white shadow hover:bg-green-600 dark:bg-green-700 dark:text-white dark:hover:bg-green-800", }, size: { default: "h-9 px-4 py-2", @@ -42,13 +48,33 @@ const buttonVariants = cva( export interface ButtonProps extends React.ButtonHTMLAttributes, - VariantProps { + VariantProps, + AuthorizedElementProps { asChild?: boolean; } const Button = React.forwardRef( - ({ className, variant, size, asChild = false, ...props }, ref) => { + ( + { className, variant, size, asChild = false, authorizeFor, ...props }, + ref, + ) => { const Comp = asChild ? Slot : "button"; + + if (authorizeFor) { + return ( + + {({ isAuthorized }) => ( + + )} + + ); + } + return ( Date: Mon, 16 Dec 2024 11:06:50 +0530 Subject: [PATCH 09/20] added primary varient --- src/components/Patient/PatientHome.tsx | 2 +- src/components/ui/badge.tsx | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/Patient/PatientHome.tsx b/src/components/Patient/PatientHome.tsx index 7283ecfb29f..5dcdaaa6739 100644 --- a/src/components/Patient/PatientHome.tsx +++ b/src/components/Patient/PatientHome.tsx @@ -531,7 +531,7 @@ export const PatientHome = (props: {
{patientData.allow_transfer ? ( - + {t("transfer_allowed")} ) : ( diff --git a/src/components/ui/badge.tsx b/src/components/ui/badge.tsx index e90715ee1da..386524ba454 100644 --- a/src/components/ui/badge.tsx +++ b/src/components/ui/badge.tsx @@ -12,6 +12,8 @@ const badgeVariants = cva( variant: { default: "border-transparent bg-gray-900 text-gray-50 shadow hover:bg-gray-900/80 dark:bg-gray-50 dark:text-gray-900 dark:hover:bg-gray-50/80", + primary: + "border-transparent bg-primary-500 text-white shadow hover:bg-primary-500/80 dark:bg-primary-900 dark:text-white dark:hover:bg-primary-900/80", secondary: "border-transparent bg-gray-100 text-gray-900 hover:bg-gray-100/80 dark:bg-gray-800 dark:text-gray-50 dark:hover:bg-gray-800/80", destructive: @@ -21,8 +23,7 @@ const badgeVariants = cva( warning: "border-transparent bg-yellow-400 text-gray-900 shadow hover:bg-yellow-500 dark:bg-yellow-400 dark:text-gray-900 dark:hover:bg-yellow-500", outline: "text-gray-950 dark:text-gray-50", - success: - "border-transparent bg-green-500 text-white shadow hover:bg-green-500/80 dark:bg-green-900 dark:text-white dark:hover:bg-green-900/80", + custom: "", }, }, From 923bd7a502cb1cca50c8b70fec75eb7c19a60a30 Mon Sep 17 00:00:00 2001 From: mahendar Date: Mon, 16 Dec 2024 11:26:18 +0530 Subject: [PATCH 10/20] added authorized button --- src/components/Patient/PatientHome.tsx | 12 +++---- src/components/ui/button.tsx | 43 +++++++++++--------------- 2 files changed, 24 insertions(+), 31 deletions(-) diff --git a/src/components/Patient/PatientHome.tsx b/src/components/Patient/PatientHome.tsx index 5dcdaaa6739..c3d02f37263 100644 --- a/src/components/Patient/PatientHome.tsx +++ b/src/components/Patient/PatientHome.tsx @@ -5,7 +5,7 @@ import { useTranslation } from "react-i18next"; import CareIcon from "@/CAREUI/icons/CareIcon"; import { Badge } from "@/components/ui/badge"; -import { Button } from "@/components/ui/button"; +import { AuthorizedButton, Button } from "@/components/ui/button"; import { Avatar } from "@/components/Common/Avatar"; import ConfirmDialog from "@/components/Common/ConfirmDialog"; @@ -226,7 +226,7 @@ export const PatientHome = (props: { id="create-consultation" className="w-full" size="default" - variant={"success"} + variant={"primary"} onClick={() => navigate( `/facility/${patientData?.facility}/patient/${id}/consultation`, @@ -478,7 +478,7 @@ export const PatientHome = (props: { {NonReadOnlyUsers && (
- +
)}
- +
diff --git a/src/components/ui/button.tsx b/src/components/ui/button.tsx index 9ec7b20d54b..0d26b121e93 100644 --- a/src/components/ui/button.tsx +++ b/src/components/ui/button.tsx @@ -28,8 +28,6 @@ const buttonVariants = cva( link: "text-gray-900 underline-offset-4 hover:underline dark:text-gray-50", outline_primary: "border border-primary-700 text-primary-700 bg-white shadow-sm hover:bg-primary-700 hover:text-white dark:border-primary-700 dark:bg-primary-700 dark:text-white", - success: - "bg-green-500 text-white shadow hover:bg-green-600 dark:bg-green-700 dark:text-white dark:hover:bg-green-800", }, size: { default: "h-9 px-4 py-2", @@ -48,33 +46,13 @@ const buttonVariants = cva( export interface ButtonProps extends React.ButtonHTMLAttributes, - VariantProps, - AuthorizedElementProps { + VariantProps { asChild?: boolean; } const Button = React.forwardRef( - ( - { className, variant, size, asChild = false, authorizeFor, ...props }, - ref, - ) => { + ({ className, variant, size, asChild = false, ...props }, ref) => { const Comp = asChild ? Slot : "button"; - - if (authorizeFor) { - return ( - - {({ isAuthorized }) => ( - - )} - - ); - } - return ( ( ); Button.displayName = "Button"; -export { Button, buttonVariants }; +const AuthorizedButton: React.FC = ({ + authorizeFor = () => true, + ...props +}) => { + return ( + + {({ isAuthorized }) => ( + + )} + + ); +}; + +export { Button, buttonVariants, AuthorizedButton }; From 24ad7acee45bf6d8bcf5944ecc3423e21e94e332 Mon Sep 17 00:00:00 2001 From: mahendar Date: Mon, 16 Dec 2024 12:50:25 +0530 Subject: [PATCH 11/20] removed overriding --- src/components/Patient/PatientHome.tsx | 19 ++++++++++--------- src/components/ui/badge.tsx | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/components/Patient/PatientHome.tsx b/src/components/Patient/PatientHome.tsx index c3d02f37263..8862c6c6f3c 100644 --- a/src/components/Patient/PatientHome.tsx +++ b/src/components/Patient/PatientHome.tsx @@ -441,9 +441,9 @@ export const PatientHome = (props: {