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

Adds support for review missed logic #8607 #9486

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
290 changes: 152 additions & 138 deletions src/components/Patient/ManagePatients.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
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";
Expand All @@ -29,7 +31,6 @@

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";
Expand Down Expand Up @@ -108,7 +109,7 @@

const tabValue =
qParams.last_consultation__new_discharge_reason ||
qParams.is_active === "False"
qParams.is_active === "False"

Check failure on line 112 in src/components/Patient/ManagePatients.tsx

View workflow job for this annotation

GitHub Actions / lint

Delete `··`
? 1
: 0;

Expand Down Expand Up @@ -458,7 +459,7 @@
<div className="flex flex-col items-start gap-4 md:flex-row">
<div className="w-full min-w-20 rounded-lg border border-secondary-300 bg-secondary-50 md:h-20 md:w-20">
{patient?.last_consultation?.current_bed &&
patient?.last_consultation?.discharge_date === null ? (
patient?.last_consultation?.discharge_date === null ? (

Check failure on line 462 in src/components/Patient/ManagePatients.tsx

View workflow job for this annotation

GitHub Actions / lint

Delete `··`
<div className="tooltip flex h-full flex-col items-center justify-center">
<span className="w-full truncate px-1 text-center text-sm text-secondary-900">
{
Expand Down Expand Up @@ -544,12 +545,14 @@
<div className="flex flex-row flex-wrap justify-start gap-2">
{!isPatientMandatoryDataFilled(patient) && (
<span className="relative inline-flex">
<Chip
<Badge
size="small"
variant="danger"
variant="destructive"
startIcon="l-notes"
text={t("patient_details_incomplete")}
/>
>
{t("patient_details_incomplete")}
</Badge>

<span className="absolute -right-1 -top-1 flex h-3 w-3 items-center justify-center">
<span className="center absolute inline-flex h-4 w-4 animate-ping rounded-full bg-red-400"></span>
<span className="relative inline-flex h-3 w-3 rounded-full bg-red-600"></span>
Expand All @@ -558,17 +561,19 @@
)}

{isPatientMandatoryDataFilled(patient) &&
(!patient.last_consultation ||
patient.last_consultation?.facility !== patient.facility ||
(patient.last_consultation?.discharge_date &&
patient.is_active)) ? (
(!patient.last_consultation ||

Check failure on line 564 in src/components/Patient/ManagePatients.tsx

View workflow job for this annotation

GitHub Actions / lint

Delete `··`
patient.last_consultation?.facility !== patient.facility ||

Check failure on line 565 in src/components/Patient/ManagePatients.tsx

View workflow job for this annotation

GitHub Actions / lint

Delete `··`
(patient.last_consultation?.discharge_date &&

Check failure on line 566 in src/components/Patient/ManagePatients.tsx

View workflow job for this annotation

GitHub Actions / lint

Delete `··`
patient.is_active)) ? (

Check failure on line 567 in src/components/Patient/ManagePatients.tsx

View workflow job for this annotation

GitHub Actions / lint

Delete `··`
<span className="relative inline-flex">
<Chip
<Badge
size="small"
variant="danger"
variant="destructive"
startIcon="l-notes"
text="No Consultation Filed"
/>
>
No Consultation Filed
</Badge>

<span className="absolute -right-1 -top-1 flex h-3 w-3 items-center justify-center">
<span className="center absolute inline-flex h-4 w-4 animate-ping rounded-full bg-red-400"></span>
<span className="relative inline-flex h-3 w-3 rounded-full bg-red-600"></span>
Expand All @@ -577,66 +582,73 @@
) : (
<>
{patient.last_consultation?.patient_no && (
<Chip
<Badge

Check failure on line 585 in src/components/Patient/ManagePatients.tsx

View workflow job for this annotation

GitHub Actions / lint

Replace `⏎··························size="small"⏎··························variant="primary"⏎························` with `·size="small"·variant="primary"`
size="small"
variant="primary"
text={`${patient.last_consultation?.suggestion === "A" ? "IP No:" : "OP No:"} ${
patient.last_consultation?.patient_no
}`}
/>
>
{`${patient.last_consultation?.suggestion === "A" ? "IP No:" : "OP No:"} ${patient.last_consultation?.patient_no

Check failure on line 589 in src/components/Patient/ManagePatients.tsx

View workflow job for this annotation

GitHub Actions / lint

Insert `⏎····························`
}`}

Check failure on line 590 in src/components/Patient/ManagePatients.tsx

View workflow job for this annotation

GitHub Actions / lint

Delete `··`
</Badge>

Check failure on line 591 in src/components/Patient/ManagePatients.tsx

View workflow job for this annotation

GitHub Actions / lint

Delete `⏎`

)}
</>
)}
{patient.review_time &&
!patient.last_consultation?.discharge_date &&
Number(patient.last_consultation?.review_interval) > 0 &&
dayjs().isAfter(patient.review_time) && (
<Chip
size="small"
variant="danger"
startIcon="l-clock"
text="Review Missed"
/>
Number(patient.last_consultation?.review_interval) > 0 && (
<Badge
variant={
dayjs().isAfter(patient.review_time)
? "destructive"
: "primary"
}
className="flex items-center gap-1"
>
<i className="icon-class l-clock"></i>
{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`}
</Badge>
)}
{patient.last_consultation?.is_readmission && (
<Chip
size="small"
variant="custom"
className="border-blue-600 bg-blue-100 text-blue-600"
startIcon="l-repeat"
text="Readmission"
/>
)}

{patient.last_consultation?.suggestion === "A" &&
patient.last_consultation.facility === patient.facility &&
!patient.last_consultation.discharge_date && (
<Chip
<Badge
size="small"
variant="primary"
startIcon="l-clock-three"
text={`IP Day No: ${dayjs().diff(patient.last_consultation.encounter_date, "day") + 1}`}
/>
>
{`IP Day No: ${dayjs().diff(patient.last_consultation.encounter_date, "day") + 1}`}
</Badge>

)}
{patient.gender === 2 &&
patient.is_antenatal &&
isAntenatal(patient.last_menstruation_start_date) &&
patient.is_active && (
<Chip
<Badge
size="small"
variant="custom"
className="bg-pink-100 text-pink-600"
startIcon="l-baby-carriage"
text="Antenatal"
/>
>
Antenatal
</Badge>
)}
{patient.is_medical_worker && patient.is_active && (
<Chip
<Badge
size="small"
variant="custom"
className="bg-blue-100 text-blue-600"
startIcon="l-user-md"
text="Medical Worker"
/>
>
Medical Worker
</Badge>
)}
{!(
patient.last_consultation?.facility !== patient.facility
Expand All @@ -649,12 +661,14 @@
new Date().getTime() - 24 * 60 * 60 * 1000,
) && (
<span className="relative inline-flex">
<Chip
<Badge
size="small"
variant="danger"
variant="destructive"
startIcon="l-exclamation-circle"
text="No update in 24 hours"
/>
>
No update in 24 hours
</Badge>

<span className="absolute -right-1 -top-1 flex h-3 w-3 items-center justify-center">
<span className="center absolute inline-flex h-4 w-4 animate-ping rounded-full bg-red-400"></span>
<span className="relative inline-flex h-3 w-3 rounded-full bg-red-600"></span>
Expand Down Expand Up @@ -1017,97 +1031,97 @@
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) && (
Expand Down
Loading
Loading