From 095c9fa6f33aaa6a6587bd12a9d394fa6c00f123 Mon Sep 17 00:00:00 2001 From: Sanchari singh Date: Wed, 18 Dec 2024 18:29:53 +0530 Subject: [PATCH 1/8] Adds support for review missed logic #8607 --- src/components/Patient/ManagePatients.tsx | 38 +++++++++++++---------- src/components/ui/badge.tsx | 4 +++ 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/components/Patient/ManagePatients.tsx b/src/components/Patient/ManagePatients.tsx index 0cae44163b2..e4cfd414578 100644 --- a/src/components/Patient/ManagePatients.tsx +++ b/src/components/Patient/ManagePatients.tsx @@ -3,6 +3,8 @@ import { Link, navigate } from "raviger"; import { ReactNode, useCallback, useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; +import { Badge } from "@/components/ui/badge"; + import { Avatar } from "@/components/Common/Avatar"; import ButtonV2 from "@/components/Common/ButtonV2"; import { ExportMenu } from "@/components/Common/Export"; @@ -589,24 +591,26 @@ export const PatientManager = () => { )} {patient.review_time && !patient.last_consultation?.discharge_date && - Number(patient.last_consultation?.review_interval) > 0 && - dayjs().isAfter(patient.review_time) && ( - + Number(patient.last_consultation?.review_interval) > 0 && ( + + + {dayjs().isAfter(patient.review_time) + ? `Review Missed ${Math.abs( + dayjs().diff(dayjs(patient.review_time), "days"), + )} days ago` + : `Review Due in ${Math.abs( + dayjs(patient.review_time).diff(dayjs(), "days"), + )} days`} + )} - {patient.last_consultation?.is_readmission && ( - - )} + {patient.last_consultation?.suggestion === "A" && patient.last_consultation.facility === patient.facility && !patient.last_consultation.discharge_date && ( diff --git a/src/components/ui/badge.tsx b/src/components/ui/badge.tsx index 99b8f3bbda4..2c8d526dc10 100644 --- a/src/components/ui/badge.tsx +++ b/src/components/ui/badge.tsx @@ -17,6 +17,10 @@ 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", + purple: + "border-transparent bg-purple-200 text-purple-800 shadow hover:bg-purple-300 dark:bg-purple-900 dark:text-purple-100 dark:hover:bg-purple-900", + success: + "border-transparent bg-green-500 text-gray-50 shadow hover:bg-green-500/80 dark:bg-green-900 dark:text-gray-50 dark:hover:bg-green-900/80", }, }, defaultVariants: { From c2634f27870b7ac28d6613169d7e58867eb32560 Mon Sep 17 00:00:00 2001 From: SANCHARI SINGH <123357539+Sancharisingh@users.noreply.github.com> Date: Thu, 19 Dec 2024 13:27:40 +0530 Subject: [PATCH 2/8] Remove purple and change success to primary --- src/components/ui/badge.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/components/ui/badge.tsx b/src/components/ui/badge.tsx index 2c8d526dc10..9d85059e0f4 100644 --- a/src/components/ui/badge.tsx +++ b/src/components/ui/badge.tsx @@ -17,9 +17,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", - purple: - "border-transparent bg-purple-200 text-purple-800 shadow hover:bg-purple-300 dark:bg-purple-900 dark:text-purple-100 dark:hover:bg-purple-900", - success: + primary: "border-transparent bg-green-500 text-gray-50 shadow hover:bg-green-500/80 dark:bg-green-900 dark:text-gray-50 dark:hover:bg-green-900/80", }, }, From 35bb102bba3cc8672b0d38f311ca32269ef2449e Mon Sep 17 00:00:00 2001 From: SANCHARI SINGH <123357539+Sancharisingh@users.noreply.github.com> Date: Thu, 19 Dec 2024 13:32:23 +0530 Subject: [PATCH 3/8] Change purple and success with destructive and primary. --- src/components/Patient/ManagePatients.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Patient/ManagePatients.tsx b/src/components/Patient/ManagePatients.tsx index e4cfd414578..09878b2c13b 100644 --- a/src/components/Patient/ManagePatients.tsx +++ b/src/components/Patient/ManagePatients.tsx @@ -595,8 +595,8 @@ export const PatientManager = () => { From 7e672189abc27b916324a579931260dcbea25772 Mon Sep 17 00:00:00 2001 From: SANCHARI SINGH <123357539+Sancharisingh@users.noreply.github.com> Date: Thu, 19 Dec 2024 13:43:53 +0530 Subject: [PATCH 4/8] Update badge.tsx From 1256abb58832271a133afd63a7969b2c9bbe318d Mon Sep 17 00:00:00 2001 From: SANCHARI SINGH <123357539+Sancharisingh@users.noreply.github.com> Date: Thu, 19 Dec 2024 19:57:13 +0530 Subject: [PATCH 5/8] Add primary variant. --- src/components/ui/badge.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ui/badge.tsx b/src/components/ui/badge.tsx index 9d85059e0f4..4490788e5d2 100644 --- a/src/components/ui/badge.tsx +++ b/src/components/ui/badge.tsx @@ -18,7 +18,7 @@ const badgeVariants = cva( "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", primary: - "border-transparent bg-green-500 text-gray-50 shadow hover:bg-green-500/80 dark:bg-green-900 dark:text-gray-50 dark:hover:bg-green-900/80", + "border-transparent bg-primary-500 text-gray-50 shadow hover:bg-primary-500/80 dark:bg-primary-900 dark:text-gray-50 dark:hover:bg-primary-900/80", }, }, defaultVariants: { From 4f5a10d889245a1ccf2f3c8531a9a470bb8a692c Mon Sep 17 00:00:00 2001 From: SANCHARI SINGH <123357539+Sancharisingh@users.noreply.github.com> Date: Fri, 20 Dec 2024 00:03:17 +0530 Subject: [PATCH 6/8] switch existing chips in the component to badge --- src/components/Patient/ManagePatients.tsx | 261 +++++++++++----------- 1 file changed, 136 insertions(+), 125 deletions(-) diff --git a/src/components/Patient/ManagePatients.tsx b/src/components/Patient/ManagePatients.tsx index 09878b2c13b..187660c84e9 100644 --- a/src/components/Patient/ManagePatients.tsx +++ b/src/components/Patient/ManagePatients.tsx @@ -31,7 +31,7 @@ import { parseOptionId } from "@/common/utils"; import routes from "@/Utils/request/api"; -import Chip from "../../CAREUI/display/Chip"; +// import Chip from "../../CAREUI/display/Chip"; import CountBlock from "../../CAREUI/display/Count"; import FilterBadge from "../../CAREUI/display/FilterBadge"; import RecordMeta from "../../CAREUI/display/RecordMeta"; @@ -110,7 +110,7 @@ export const PatientManager = () => { const tabValue = qParams.last_consultation__new_discharge_reason || - qParams.is_active === "False" + qParams.is_active === "False" ? 1 : 0; @@ -460,7 +460,7 @@ export const PatientManager = () => {
{patient?.last_consultation?.current_bed && - patient?.last_consultation?.discharge_date === null ? ( + patient?.last_consultation?.discharge_date === null ? (
{ @@ -546,12 +546,14 @@ export const PatientManager = () => {
{!isPatientMandatoryDataFilled(patient) && ( - + > + {t("patient_details_incomplete")} + + @@ -560,17 +562,19 @@ export const PatientManager = () => { )} {isPatientMandatoryDataFilled(patient) && - (!patient.last_consultation || - patient.last_consultation?.facility !== patient.facility || - (patient.last_consultation?.discharge_date && - patient.is_active)) ? ( + (!patient.last_consultation || + patient.last_consultation?.facility !== patient.facility || + (patient.last_consultation?.discharge_date && + patient.is_active)) ? ( - + > + No Consultation Filed + + @@ -579,13 +583,14 @@ export const PatientManager = () => { ) : ( <> {patient.last_consultation?.patient_no && ( - + > + {`${patient.last_consultation?.suggestion === "A" ? "IP No:" : "OP No:"} ${patient.last_consultation?.patient_no + }`} + + )} )} @@ -603,44 +608,48 @@ export const PatientManager = () => { {dayjs().isAfter(patient.review_time) ? `Review Missed ${Math.abs( - dayjs().diff(dayjs(patient.review_time), "days"), - )} days ago` + dayjs().diff(dayjs(patient.review_time), "days"), + )} days ago` : `Review Due in ${Math.abs( - dayjs(patient.review_time).diff(dayjs(), "days"), - )} days`} + dayjs(patient.review_time).diff(dayjs(), "days"), + )} days`} )} {patient.last_consultation?.suggestion === "A" && patient.last_consultation.facility === patient.facility && !patient.last_consultation.discharge_date && ( - + > + {`IP Day No: ${dayjs().diff(patient.last_consultation.encounter_date, "day") + 1}`} + + )} {patient.gender === 2 && patient.is_antenatal && isAntenatal(patient.last_menstruation_start_date) && patient.is_active && ( - + > + Antenatal + )} {patient.is_medical_worker && patient.is_active && ( - + > + Medical Worker + )} {!( patient.last_consultation?.facility !== patient.facility @@ -653,12 +662,14 @@ export const PatientManager = () => { new Date().getTime() - 24 * 60 * 60 * 1000, ) && ( - + > + No update in 24 hours + + @@ -1021,97 +1032,97 @@ export const PatientManager = () => { range, ordering, }) => [ - phoneNumber("Primary number", "phone_number"), - phoneNumber("Emergency number", "emergency_phone_number"), - badge("Patient name", "name"), - badge("IP/OP number", "patient_no"), - ...dateRange("Modified", "modified_date"), - ...dateRange("Created", "created_date"), - ...dateRange("Admitted", "last_consultation_encounter_date"), - ...dateRange("Discharged", "last_consultation_discharge_date"), - // Admitted to type badges - badge("No. of vaccination doses", "number_of_doses"), - kasp(), - badge("COWIN ID", "covin_id"), - badge("Is Antenatal", "is_antenatal"), - badge("Review Missed", "review_missed"), - badge( - "Is Medico-Legal Case", - "last_consultation_medico_legal_case", - ), - value( - "Ration Card Category", - "ration_card_category", - qParams.ration_card_category - ? t(`ration_card__${qParams.ration_card_category}`) - : "", - ), - value( - "Facility", - "facility", - qParams.facility ? facilityData?.name || "" : "", - ), - value( - "Location", - "last_consultation_current_bed__location", - qParams.last_consultation_current_bed__location - ? facilityAssetLocationData?.name || - qParams.last_consultation_current_bed__locations - : "", - ), - badge("Facility Type", "facility_type"), - value( - "District", - "district", - qParams.district ? districtData?.name || "" : "", - ), - ordering(), - value("Category", "category", getTheCategoryFromId()), - value( - "Respiratory Support", - "ventilator_interface", - qParams.ventilator_interface && + phoneNumber("Primary number", "phone_number"), + phoneNumber("Emergency number", "emergency_phone_number"), + badge("Patient name", "name"), + badge("IP/OP number", "patient_no"), + ...dateRange("Modified", "modified_date"), + ...dateRange("Created", "created_date"), + ...dateRange("Admitted", "last_consultation_encounter_date"), + ...dateRange("Discharged", "last_consultation_discharge_date"), + // Admitted to type badges + badge("No. of vaccination doses", "number_of_doses"), + kasp(), + badge("COWIN ID", "covin_id"), + badge("Is Antenatal", "is_antenatal"), + badge("Review Missed", "review_missed"), + badge( + "Is Medico-Legal Case", + "last_consultation_medico_legal_case", + ), + value( + "Ration Card Category", + "ration_card_category", + qParams.ration_card_category + ? t(`ration_card__${qParams.ration_card_category}`) + : "", + ), + value( + "Facility", + "facility", + qParams.facility ? facilityData?.name || "" : "", + ), + value( + "Location", + "last_consultation_current_bed__location", + qParams.last_consultation_current_bed__location + ? facilityAssetLocationData?.name || + qParams.last_consultation_current_bed__locations + : "", + ), + badge("Facility Type", "facility_type"), + value( + "District", + "district", + qParams.district ? districtData?.name || "" : "", + ), + ordering(), + value("Category", "category", getTheCategoryFromId()), + value( + "Respiratory Support", + "ventilator_interface", + qParams.ventilator_interface && t(`RESPIRATORY_SUPPORT_SHORT__${qParams.ventilator_interface}`), - ), - value( - "Gender", - "gender", - parseOptionId(GENDER_TYPES, qParams.gender) || "", - ), - { - name: "Admitted to", - value: ADMITTED_TO[qParams.last_consultation_admitted_to], - paramKey: "last_consultation_admitted_to", - }, - ...range("Age", "age"), - { - name: "LSG Body", - value: qParams.lsgBody ? LocalBodyData?.name || "" : "", - paramKey: "lsgBody", - }, - ...FILTER_BY_DIAGNOSES_KEYS.map((key) => + ), + value( + "Gender", + "gender", + parseOptionId(GENDER_TYPES, qParams.gender) || "", + ), + { + name: "Admitted to", + value: ADMITTED_TO[qParams.last_consultation_admitted_to], + paramKey: "last_consultation_admitted_to", + }, + ...range("Age", "age"), + { + name: "LSG Body", + value: qParams.lsgBody ? LocalBodyData?.name || "" : "", + paramKey: "lsgBody", + }, + ...FILTER_BY_DIAGNOSES_KEYS.map((key) => + value( + DIAGNOSES_FILTER_LABELS[key], + key, + humanizeStrings(getDiagnosisFilterValue(key)), + ), + ), + badge("Declared Status", "is_declared_positive"), + ...dateRange("Declared positive", "date_declared_positive"), + ...dateRange("Last vaccinated", "last_vaccinated_date"), + { + name: "Telemedicine", + paramKey: "last_consultation_is_telemedicine", + }, value( - DIAGNOSES_FILTER_LABELS[key], - key, - humanizeStrings(getDiagnosisFilterValue(key)), + "Discharge Reason", + "last_consultation__new_discharge_reason", + parseOptionId( + DISCHARGE_REASONS, + qParams.last_consultation__new_discharge_reason, + ) || "", ), - ), - badge("Declared Status", "is_declared_positive"), - ...dateRange("Declared positive", "date_declared_positive"), - ...dateRange("Last vaccinated", "last_vaccinated_date"), - { - name: "Telemedicine", - paramKey: "last_consultation_is_telemedicine", - }, - value( - "Discharge Reason", - "last_consultation__new_discharge_reason", - parseOptionId( - DISCHARGE_REASONS, - qParams.last_consultation__new_discharge_reason, - ) || "", - ), - ]} + ]} children={ (qParams.last_consultation_admitted_bed_type_list || qParams.last_consultation__consent_types) && ( From 091b72e1265c4beec644c139273f871d78013603 Mon Sep 17 00:00:00 2001 From: SANCHARI SINGH <123357539+Sancharisingh@users.noreply.github.com> Date: Fri, 20 Dec 2024 00:04:09 +0530 Subject: [PATCH 7/8] Update badge.tsx --- src/components/ui/badge.tsx | 38 +++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/src/components/ui/badge.tsx b/src/components/ui/badge.tsx index 4490788e5d2..69f17b0687a 100644 --- a/src/components/ui/badge.tsx +++ b/src/components/ui/badge.tsx @@ -1,5 +1,6 @@ import { type VariantProps, cva } from "class-variance-authority"; import * as React from "react"; +import CareIcon, { IconName } from "@/CAREUI/icons/CareIcon"; import { cn } from "@/lib/utils"; @@ -18,27 +19,52 @@ const badgeVariants = cva( "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", primary: - "border-transparent bg-primary-500 text-gray-50 shadow hover:bg-primary-500/80 dark:bg-primary-900 dark:text-gray-50 dark:hover:bg-primary-900/80", + "border-transparent bg-green-500 text-gray-50 shadow hover:bg-green-500/80 dark:bg-green-900 dark:text-gray-50 dark:hover:bg-green-900/80", + custom: "", + }, + size: { + small: "rounded px-2 py-1 text-xs", + medium: "rounded-lg px-3 py-2 text-xs", + large: "rounded-lg px-4 py-3 text-sm", }, }, defaultVariants: { variant: "default", + size: "medium", }, }, ); export interface BadgeProps extends React.HTMLAttributes, - VariantProps {} + VariantProps { + startIcon?: IconName; + endIcon?: IconName; + tooltip?: string; +} -function Badge({ className, variant, ...props }: BadgeProps) { +function Badge({ + className, + variant, + size, + startIcon, + endIcon, + tooltip, + children, + ...props +}: BadgeProps) { return (
+ > + {startIcon && } + {children} + {endIcon && } +
); } From d9a34f439825bd57f0fdd40f0c42d615ddfaef79 Mon Sep 17 00:00:00 2001 From: SANCHARI SINGH <123357539+Sancharisingh@users.noreply.github.com> Date: Fri, 20 Dec 2024 00:13:13 +0530 Subject: [PATCH 8/8] remove import chip --- src/components/Patient/ManagePatients.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/Patient/ManagePatients.tsx b/src/components/Patient/ManagePatients.tsx index 187660c84e9..c0dbfb23cec 100644 --- a/src/components/Patient/ManagePatients.tsx +++ b/src/components/Patient/ManagePatients.tsx @@ -31,7 +31,6 @@ import { parseOptionId } from "@/common/utils"; import routes from "@/Utils/request/api"; -// import Chip from "../../CAREUI/display/Chip"; import CountBlock from "../../CAREUI/display/Count"; import FilterBadge from "../../CAREUI/display/FilterBadge"; import RecordMeta from "../../CAREUI/display/RecordMeta";