Skip to content

Commit

Permalink
handled volunter tab, Rename Sample Test to Service Request, page spe…
Browse files Browse the repository at this point in the history
…cfic actions
  • Loading branch information
Mahendar0701 committed Nov 25, 2024
1 parent 7575e3f commit 0c18c32
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 93 deletions.
1 change: 1 addition & 0 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1244,6 +1244,7 @@
"send_sample_to_collection_centre_description": "Are you sure you want to send the sample to Collection Centre?",
"send_sample_to_collection_centre_title": "Send sample to collection centre",
"serial_number": "Serial Number",
"service-request": "Service Request",
"serviced_on": "Serviced on",
"session_expired": "Session Expired",
"session_expired_msg": "It appears that your session has expired. This could be due to inactivity. Please login again to continue.",
Expand Down
31 changes: 17 additions & 14 deletions src/components/Patient/PatientDetailsTab/Demography.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,20 +278,23 @@ export const Demography = (props: PatientProps) => {
},
],
},
{
id: "volunteer-contact",
hidden: !patientData.assigned_to_object,
details: [
<EmergencyContact
number={patientData.assigned_to_object?.alt_phone_number}
name={
patientData.assigned_to_object
? formatName(patientData.assigned_to_object)
: undefined
}
/>,
],
},
...(patientData.assigned_to_object
? [
{
id: "volunteer-contact",
details: [
<EmergencyContact
number={patientData.assigned_to_object?.alt_phone_number}
name={
patientData.assigned_to_object
? formatName(patientData.assigned_to_object)
: undefined
}
/>,
],
},
]
: []),
{
id: "insurance-details",
details: [
Expand Down
35 changes: 2 additions & 33 deletions src/components/Patient/PatientDetailsTab/SampleTestHistory.tsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,24 @@
import { navigate } from "raviger";
import React, { useState } from "react";
import { useTranslation } from "react-i18next";

import CareIcon from "@/CAREUI/icons/CareIcon";
import PaginatedList from "@/CAREUI/misc/PaginatedList";

import ButtonV2 from "@/components/Common/ButtonV2";
import CircularProgress from "@/components/Common/CircularProgress";

import { NonReadOnlyUsers } from "@/Utils/AuthorizeFor";
import routes from "@/Utils/request/api";

import { PatientProps } from ".";
import { SampleTestCard } from "../SampleTestCard";
import { PatientModel, SampleTestModel } from "../models";
import { SampleTestModel } from "../models";

export const SampleTestHistory = (props: PatientProps) => {
const { patientData, facilityId, id } = props;
const { facilityId, id } = props;
const [_selectedStatus, setSelectedStatus] = useState<{
status: number;
sample: SampleTestModel | null;
}>({ status: 0, sample: null });
const [_showAlertMessage, setShowAlertMessage] = useState(false);

const isPatientInactive = (patientData: PatientModel, facilityId: string) => {
return (
!patientData.is_active ||
!(
patientData?.last_consultation &&
patientData.last_consultation.facility === facilityId
)
);
};

const confirmApproval = (status: number, sample: SampleTestModel) => {
setSelectedStatus({ status, sample });
setShowAlertMessage(true);
Expand All @@ -47,23 +33,6 @@ export const SampleTestHistory = (props: PatientProps) => {
<h2 className="my-4 ml-0 text-2xl font-semibold leading-tight">
{t("sample_test_history")}
</h2>
<ButtonV2
className="bg-green-600 px-3 py-2 font-semibold text-white hover:bg-green-500"
disabled={isPatientInactive(patientData, facilityId)}
size="default"
onClick={() =>
navigate(
`/facility/${patientData?.facility}/patient/${id}/sample-test`,
)
}
authorizeFor={NonReadOnlyUsers}
id="sample-request-btn"
>
<span className="flex w-full items-center justify-start gap-2">
<CareIcon icon="l-medkit" className="text-xl" />
{t("request_sample_test")}
</span>
</ButtonV2>
</div>
</div>

Expand Down
28 changes: 1 addition & 27 deletions src/components/Patient/PatientDetailsTab/ShiftingHistory.tsx
Original file line number Diff line number Diff line change
@@ -1,51 +1,25 @@
import { navigate } from "raviger";
import { useTranslation } from "react-i18next";

import CareIcon from "@/CAREUI/icons/CareIcon";
import PaginatedList from "@/CAREUI/misc/PaginatedList";

import ButtonV2 from "@/components/Common/ButtonV2";
import CircularProgress from "@/components/Common/CircularProgress";
import { ShiftingModel } from "@/components/Facility/models";
import ShiftingBlock from "@/components/Shifting/ShiftingBlock";

import { NonReadOnlyUsers } from "@/Utils/AuthorizeFor";
import routes from "@/Utils/request/api";

import { PatientProps } from ".";
import { PatientModel } from "../models";

const ShiftingHistory = (props: PatientProps) => {
const { patientData, facilityId, id } = props;
const { id } = props;
const { t } = useTranslation();

const isPatientInactive = (patientData: PatientModel, facilityId: string) => {
return (
!patientData.is_active ||
!(patientData?.last_consultation?.facility === facilityId)
);
};

return (
<section className="mt-4">
<div className="flex justify-between items-center">
<h2 className="my-4 ml-0 text-2xl font-semibold leading-tight">
{t("shifting_history")}
</h2>
<ButtonV2
className=""
disabled={isPatientInactive(patientData, facilityId)}
size="default"
onClick={() =>
navigate(`/facility/${facilityId}/patient/${id}/shift/new`)
}
authorizeFor={NonReadOnlyUsers}
>
<span className="flex w-full items-center justify-start gap-2">
<CareIcon icon="l-ambulance" className="text-xl" />
{t("shift")}
</span>
</ButtonV2>
</div>
<PaginatedList
route={routes.listShiftRequests}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Patient/PatientDetailsTab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const patientTabs = [
component: ShiftingHistory,
},
{
route: "request-sample-test",
route: "service-request",
component: SampleTestHistory,
},
{
Expand Down
94 changes: 76 additions & 18 deletions src/components/Patient/PatientHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,16 @@ export const PatientHome = (props: {
});
};

const isPatientInactive = (patientData: PatientModel, facilityId: string) => {
return (
!patientData.is_active ||
!(
patientData?.last_consultation &&
patientData.last_consultation.facility === facilityId
)
);
};

const Tab = patientTabs.find((t) => t.route === page)?.component;

return (
Expand Down Expand Up @@ -467,6 +477,72 @@ export const PatientHome = (props: {
</div>
<div className="mt-2 h-full space-y-2">
<div className="space-y-3 border-b border-dashed text-left text-lg font-semibold text-secondary-900">
{page == "service-request" && NonReadOnlyUsers && (
<div>
<ButtonV2
className="w-full bg-white font-semibold text-green-800 hover:bg-secondary-200"
disabled={isPatientInactive(
patientData,
facilityId || "",
)}
size="large"
onClick={() =>
navigate(
`/facility/${patientData?.facility}/patient/${id}/sample-test`,
)
}
authorizeFor={NonReadOnlyUsers}
id="sample-request-btn"
>
<span className="flex w-full items-center justify-start gap-2">
<CareIcon icon="l-medkit" className="text-xl" />
{t("request_sample_test")}
</span>
</ButtonV2>
</div>
)}
{page == "shift" && NonReadOnlyUsers && (
<div>
<ButtonV2
className="w-full bg-white font-semibold text-green-800 hover:bg-secondary-200"
disabled={isPatientInactive(
patientData,
facilityId || "",
)}
size="large"
onClick={() =>
navigate(
`/facility/${facilityId}/patient/${id}/shift/new`,
)
}
authorizeFor={NonReadOnlyUsers}
>
<span className="flex w-full items-center justify-start gap-2">
<CareIcon icon="l-ambulance" className="text-xl" />
{t("shift")}
</span>
</ButtonV2>
</div>
)}

{page == "demography" && NonReadOnlyUsers && (
<div>
<ButtonV2
id="assign-volunteer"
onClick={() => setOpenAssignVolunteerDialog(true)}
disabled={false}
authorizeFor={NonReadOnlyUsers}
className="w-full bg-white font-semibold text-green-800 hover:bg-secondary-200"
size="large"
>
<span className="flex w-full items-center justify-start gap-2">
<CareIcon icon="l-users-alt" className="text-lg" />{" "}
{t("assign_to_volunteer")}
</span>
</ButtonV2>
</div>
)}

<div>
<ButtonV2
className="w-full bg-white font-semibold text-green-800 hover:bg-secondary-200"
Expand Down Expand Up @@ -502,24 +578,6 @@ export const PatientHome = (props: {
</ButtonV2>
</div>

{NonReadOnlyUsers && (
<div>
<ButtonV2
id="assign-volunteer"
onClick={() => setOpenAssignVolunteerDialog(true)}
disabled={false}
authorizeFor={NonReadOnlyUsers}
className="w-full bg-white font-semibold text-green-800 hover:bg-secondary-200"
size="large"
>
<span className="flex w-full items-center justify-start gap-2">
<CareIcon icon="l-users-alt" className="text-lg" />{" "}
{t("assign_to_volunteer")}
</span>
</ButtonV2>
</div>
)}

<div>
<ButtonV2
id="patient-allow-transfer"
Expand Down

0 comments on commit 0c18c32

Please sign in to comment.