Skip to content

Commit

Permalink
Add medico-legal case toggle and filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashesh3 committed Oct 11, 2023
1 parent 31b530a commit 38c0d4d
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 18 deletions.
16 changes: 8 additions & 8 deletions src/Components/Common/components/SwitchTabs.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
export default function SwitchTabs(props: {
activeTab: boolean;
isTab2Active: boolean;
onClickTab1: () => void;
onClickTab2: () => void;
Tab1: string;
Tab2: string;
tab1: string;
tab2: string;
}) {
return (
<div className="relative grid w-full grid-cols-2 items-center gap-4 rounded-md bg-primary-500/10 px-4 py-3 lg:w-52">
<div
className={`absolute z-0 w-[50%] origin-left rounded bg-primary-500 py-4 transition-all duration-200 ease-out lg:left-1.5 ${
props.activeTab ? "right-1.5 lg:translate-x-[89%]" : "left-1.5"
props.isTab2Active ? "right-1.5 lg:translate-x-[89%]" : "left-1.5"
}`}
></div>
<div
className={`z-10 flex cursor-pointer items-center justify-center text-sm transition-all duration-200 ease-out ${
props.activeTab
props.isTab2Active
? "text-primary-500 hover:font-medium hover:text-green-600"
: "text-white"
} `}
onClick={props.onClickTab1}
>
{props.Tab1}
{props.tab1}
</div>
<div
className={`z-10 flex cursor-pointer items-center justify-center text-sm transition-all duration-200 ease-out ${
!props.activeTab
!props.isTab2Active
? "ml-2 text-primary-500 hover:font-medium hover:text-green-600"
: "text-white"
}`}
onClick={props.onClickTab2}
>
{props.Tab2}
{props.tab2}
</div>
</div>
);
Expand Down
1 change: 1 addition & 0 deletions src/Components/Facility/models.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export interface ConsultationModel {
death_datetime?: string;
death_confirmed_doctor?: string;
is_readmission?: boolean;
medico_legal_case?: boolean;
}
export interface PatientStatsModel {
id?: number;
Expand Down
13 changes: 10 additions & 3 deletions src/Components/Patient/ManagePatients.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ export const PatientManager = () => {
qParams.date_declared_positive_after || undefined,
date_of_result_before: qParams.date_of_result_before || undefined,
date_of_result_after: qParams.date_of_result_after || undefined,
last_consultation_medico_legal_case:
qParams.last_consultation_medico_legal_case || undefined,
last_consultation_admission_date_before:
qParams.last_consultation_admission_date_before || undefined,
last_consultation_admission_date_after:
Expand Down Expand Up @@ -333,6 +335,7 @@ export const PatientManager = () => {
});
}, [
dispatch,
qParams.last_consultation_medico_legal_case,
qParams.last_consultation_admission_date_before,
qParams.last_consultation_admission_date_after,
qParams.last_consultation_discharge_date_before,
Expand Down Expand Up @@ -768,11 +771,11 @@ export const PatientManager = () => {
</div>
<div className="flex w-full flex-col justify-end gap-2 lg:w-fit lg:flex-row lg:gap-3">
<SwitchTabs
Tab1="Live"
Tab2="Discharged"
tab1="Live"
tab2="Discharged"
onClickTab1={() => updateQuery({ is_active: "True" })}
onClickTab2={() => updateQuery({ is_active: "False" })}
activeTab={tabValue ? true : false}
isTab2Active={tabValue ? true : false}
/>
{showDoctorConnect && (
<ButtonV2
Expand Down Expand Up @@ -932,6 +935,10 @@ export const PatientManager = () => {
kasp(),
badge("COWIN ID", "covin_id"),
badge("Is Antenatal", "is_antenatal"),
badge(
"Is Medico-Legal Case",
"last_consultation_medico_legal_case"
),
value("Facility", "facility", facilityBadgeName),
badge("Facility Type", "facility_type"),
value("District", "district", districtName),
Expand Down
23 changes: 23 additions & 0 deletions src/Components/Patient/PatientFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export default function PatientFilter(props: any) {
age_max: filter.age_max || null,
date_of_result: filter.date_of_result || null,
date_declared_positive: filter.date_declared_positive || null,
last_consultation_medico_legal_case:
filter.last_consultation_medico_legal_case || null,
last_consultation_admission_date_before:
filter.last_consultation_admission_date_before || null,
last_consultation_admission_date_after:
Expand Down Expand Up @@ -120,6 +122,7 @@ export default function PatientFilter(props: any) {
age_max: "",
date_of_result: null,
date_declared_positive: null,
last_consultation_medico_legal_case: null,
last_consultation_admission_date_before: "",
last_consultation_admission_date_after: "",
last_consultation_discharge_date_before: "",
Expand Down Expand Up @@ -229,6 +232,7 @@ export default function PatientFilter(props: any) {
age_min,
age_max,
date_of_result,
last_consultation_medico_legal_case,
last_consultation_admission_date_before,
last_consultation_admission_date_after,
last_consultation_discharge_date_before,
Expand Down Expand Up @@ -266,6 +270,8 @@ export default function PatientFilter(props: any) {
modified_date_before: dateQueryString(modified_date_before),
modified_date_after: dateQueryString(modified_date_after),
date_of_result: dateQueryString(date_of_result),
last_consultation_medico_legal_case:
last_consultation_medico_legal_case || "",
last_consultation_admission_date_before: dateQueryString(
last_consultation_admission_date_before
),
Expand Down Expand Up @@ -473,6 +479,23 @@ export default function PatientFilter(props: any) {
}
/>
</div>
<div className="w-full flex-none">
<FieldLabel className="text-sm">Is Medico-Legal Case</FieldLabel>
<SelectMenuV2
placeholder="Show all"
options={["true", "false"]}
optionLabel={(o) =>
o === "true" ? "Medico-Legal" : "Non-Medico-Legal"
}
value={filterState.last_consultation_medico_legal_case}
onChange={(v) =>
setFilterState({
...filterState,
last_consultation_medico_legal_case: v,
})
}
/>
</div>
</div>
</AccordionV2>
<AccordionV2
Expand Down
40 changes: 40 additions & 0 deletions src/Components/Patient/PatientInfoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import useConfig from "../../Common/hooks/useConfig";
import { useState } from "react";
import { formatAge, formatDate, formatDateTime } from "../../Utils/utils.js";
import dayjs from "../../Utils/dayjs";
import SwitchTabs from "../Common/components/SwitchTabs.js";
import request from "../../Utils/request/request.js";
import routes from "../../Redux/api.js";

export default function PatientInfoCard(props: {
patient: PatientModel;
Expand All @@ -42,6 +45,10 @@ export default function PatientInfoCard(props: {
const patient = props.patient;
const consultation = props.consultation;

const [medicoLegalCase, setMedicoLegalCase] = useState(
consultation?.medico_legal_case ?? false
);

const category: PatientCategory | undefined =
consultation?.last_daily_round?.patient_category ?? consultation?.category;
const categoryClass = category
Expand All @@ -54,6 +61,25 @@ export default function PatientInfoCard(props: {
? "Assign Bed"
: "Switch Bed";

const switchMedicoLegalCase = async (value: boolean) => {
if (!consultation?.id || value === medicoLegalCase) return;
const { res, data } = await request(routes.partialUpdateConsultation, {
pathParams: { id: consultation?.id },
body: { medico_legal_case: value },
});

if (res?.status !== 200 || !data) {
Notification.Error({
msg: "Failed to update Medico Legal Case",
});
setMedicoLegalCase(!value);
} else {
Notification.Success({
msg: "Medico Legal Case updated successfully",
});
}
};

return (
<>
<DialogModal
Expand Down Expand Up @@ -433,6 +459,20 @@ export default function PatientInfoCard(props: {
/>
</>
))}
Is this a medico-legal case?
<SwitchTabs
tab1="Yes"
tab2="No"
isTab2Active={!medicoLegalCase}
onClickTab1={() => {
setMedicoLegalCase(true);
switchMedicoLegalCase(true);
}}
onClickTab2={() => {
setMedicoLegalCase(false);
switchMedicoLegalCase(false);
}}
/>
</div>
</section>
</>
Expand Down
6 changes: 3 additions & 3 deletions src/Components/Resource/ResourceBoardView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ export default function BoardView() {
<div className="flex w-full flex-col items-center justify-between gap-2 pt-2 lg:flex-row lg:gap-4">
<div></div>
<SwitchTabs
Tab1="Active"
Tab2="Completed"
tab1="Active"
tab2="Completed"
onClickTab1={() => setBoardFilter(ACTIVE)}
onClickTab2={() => setBoardFilter(COMPLETED)}
activeTab={boardFilter !== ACTIVE}
isTab2Active={boardFilter !== ACTIVE}
/>
<div className="flex w-full flex-col gap-2 lg:mr-4 lg:w-fit lg:flex-row lg:gap-4">
<ButtonV2 className="py-[11px]" onClick={onListViewBtnClick}>
Expand Down
6 changes: 3 additions & 3 deletions src/Components/Shifting/BoardView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ export default function BoardView() {
/>

<SwitchTabs
Tab1={t("active")}
Tab2={t("completed")}
tab1={t("active")}
tab2={t("completed")}
onClickTab1={() => setBoardFilter(activeBoards)}
onClickTab2={() => setBoardFilter(completedBoards)}
activeTab={boardFilter[0].text !== activeBoards[0].text}
isTab2Active={boardFilter[0].text !== activeBoards[0].text}
/>

<div className="flex w-full flex-col gap-2 lg:mr-4 lg:w-fit lg:flex-row lg:gap-4">
Expand Down
7 changes: 6 additions & 1 deletion src/Redux/api.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { IConfig } from "../Common/hooks/useConfig";
import { AssetData } from "../Components/Assets/AssetTypes";
import { LocationModel } from "../Components/Facility/models";
import {
ConsultationModel,
LocationModel,
} from "../Components/Facility/models";
import { Prescription } from "../Components/Medicine/models";
import { UserModel } from "../Components/Users/models";
import { PaginatedResponse } from "../Utils/request/types";
Expand Down Expand Up @@ -358,6 +361,8 @@ const routes = {
partialUpdateConsultation: {
path: "/api/v1/consultation/{id}/",
method: "PATCH",
TRes: Type<Partial<ConsultationModel>>(),
TBody: Type<ConsultationModel>(),
},
deleteConsultation: {
path: "/api/v1/consultation/{id}/",
Expand Down

0 comments on commit 38c0d4d

Please sign in to comment.