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

Issue: 7132 - Disallow Add Consultation updates for active consultations without bed assigned #7303

Merged
merged 4 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
271 changes: 155 additions & 116 deletions src/Components/Facility/ConsultationCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,172 +6,211 @@ import { NonReadOnlyUsers } from "../../Utils/AuthorizeFor";
import RelativeDateUserMention from "../Common/RelativeDateUserMention";
import useConfig from "../../Common/hooks/useConfig";
import Chip from "../../CAREUI/display/Chip";
import * as Notification from "../../Utils/Notifications.js";
import { useState } from "react";
import DialogModal from "../Common/Dialog.js";
import Beds from "./Consultations/Beds";

interface ConsultationProps {
itemData: ConsultationModel;
isLastConsultation?: boolean;
refetch: () => void;
}

export const ConsultationCard = (props: ConsultationProps) => {
const { itemData, isLastConsultation } = props;
const { itemData, isLastConsultation, refetch } = props;
const { kasp_string } = useConfig();
const [open, setOpen] = useState(false);
const bedDialogTitle = itemData.discharge_date
? "Bed History"
: !itemData.current_bed
? "Assign Bed"
: "Switch Bed";
return (
<div className="mt-4 block cursor-pointer rounded-lg border bg-white p-4 text-black shadow hover:border-primary-500">
{itemData.is_kasp && (
<div className="ml-3 mt-2 inline-flex items-center rounded-md bg-yellow-100 px-2.5 py-0.5 text-sm font-medium leading-5 text-yellow-800">
{kasp_string}
</div>
)}
<>
<DialogModal
title={bedDialogTitle}
show={open}
onClose={() => setOpen(false)}
className="md:max-w-3xl"
>
{itemData.facility && itemData.patient && itemData.id ? (
<Beds
facilityId={itemData.facility}
patientId={itemData.patient}
discharged={!!itemData.discharge_date}
consultationId={itemData.id ?? ""}
setState={setOpen}
fetchPatientData={refetch}
smallLoader
hideTitle
/>
) : (
<div>Invalid Patient Data</div>
)}
</DialogModal>
<div className="mt-4 block cursor-pointer rounded-lg border bg-white p-4 text-black shadow hover:border-primary-500">
{itemData.is_kasp && (
<div className="ml-3 mt-2 inline-flex items-center rounded-md bg-yellow-100 px-2.5 py-0.5 text-sm font-medium leading-5 text-yellow-800">
{kasp_string}
</div>
)}

<div className="ml-2 mt-2 grid grid-cols-1 gap-4 md:grid-cols-4">
<div className="sm:col-span-1">
<div className="ml-2 mt-2 grid grid-cols-1 gap-4 md:grid-cols-4">
<div className="sm:col-span-1">
<div className="text-sm font-semibold leading-5 text-zinc-400">
Facility
</div>
<div className="mt-1 overflow-x-scroll whitespace-normal break-words text-sm font-medium leading-5">
{itemData.facility_name}{" "}
{itemData.is_telemedicine && (
<span className="ml-2">(Telemedicine)</span>
)}
</div>
</div>
</div>
<div className="sm:col-span-1">
<div className="capitalize">
<div className="sm:col-span-1">
<div className="text-sm font-semibold leading-5 text-zinc-400">
Suggestion{" "}
Facility
</div>
<div className="mt-1 overflow-x-scroll whitespace-normal break-words text-sm font-medium leading-5">
{itemData.suggestion_text?.toLocaleLowerCase()}
{itemData.facility_name}{" "}
{itemData.is_telemedicine && (
<span className="ml-2">(Telemedicine)</span>
)}
</div>
</div>
</div>
</div>
{itemData.kasp_enabled_date && (
<div className="sm:col-span-1">
<div className="sm:col-span-1">
<div className="text-sm font-semibold leading-5 text-zinc-400">
{kasp_string} Enabled date{" "}
</div>
<div className="mt-1 overflow-x-scroll whitespace-normal break-words text-sm font-medium leading-5">
{itemData.kasp_enabled_date
? formatDateTime(itemData.kasp_enabled_date)
: "-"}
<div className="capitalize">
<div className="sm:col-span-1">
<div className="text-sm font-semibold leading-5 text-zinc-400">
Suggestion{" "}
</div>
<div className="mt-1 overflow-x-scroll whitespace-normal break-words text-sm font-medium leading-5">
{itemData.suggestion_text?.toLocaleLowerCase()}
</div>
</div>
</div>
</div>
)}
{itemData.admitted && itemData.encounter_date && (
<div className="sm:col-span-1">
{itemData.kasp_enabled_date && (
<div className="sm:col-span-1">
<div className="text-sm font-semibold leading-5 text-zinc-400">
Admitted on
</div>
<div className="mt-1 overflow-x-scroll whitespace-normal break-words text-sm font-medium leading-5">
{formatDateTime(itemData.encounter_date)}
{itemData.is_readmission && (
<Chip
size="small"
variant="custom"
className="ml-4 border-blue-600 bg-blue-100 text-blue-600"
startIcon="l-repeat"
text="Readmission"
/>
)}
<div className="sm:col-span-1">
<div className="text-sm font-semibold leading-5 text-zinc-400">
{kasp_string} Enabled date{" "}
</div>
<div className="mt-1 overflow-x-scroll whitespace-normal break-words text-sm font-medium leading-5">
{itemData.kasp_enabled_date
? formatDateTime(itemData.kasp_enabled_date)
: "-"}
</div>
</div>
</div>
</div>
)}
{!itemData.admitted && (
<div className="sm:col-span-1">
)}
{itemData.admitted && itemData.encounter_date && (
<div className="sm:col-span-1">
<div className="text-sm font-semibold leading-5 text-zinc-400">
Admitted{" "}
<div className="sm:col-span-1">
<div className="text-sm font-semibold leading-5 text-zinc-400">
Admitted on
</div>
<div className="mt-1 overflow-x-scroll whitespace-normal break-words text-sm font-medium leading-5">
{formatDateTime(itemData.encounter_date)}
{itemData.is_readmission && (
<Chip
size="small"
variant="custom"
className="ml-4 border-blue-600 bg-blue-100 text-blue-600"
startIcon="l-repeat"
text="Readmission"
/>
)}
</div>
</div>
<div className="mt-1 overflow-x-scroll whitespace-normal break-words text-sm font-medium leading-5">
No
</div>
)}
{!itemData.admitted && (
<div className="sm:col-span-1">
<div className="sm:col-span-1">
<div className="text-sm font-semibold leading-5 text-zinc-400">
Admitted{" "}
</div>
<div className="mt-1 overflow-x-scroll whitespace-normal break-words text-sm font-medium leading-5">
No
</div>
</div>
</div>
</div>
)}
{itemData.discharge_date && (
<div className="sm:col-span-1">
)}
{itemData.discharge_date && (
<div className="sm:col-span-1">
<div className="text-sm font-semibold leading-5 text-zinc-400">
Discharged on{" "}
<div className="sm:col-span-1">
<div className="text-sm font-semibold leading-5 text-zinc-400">
Discharged on{" "}
</div>
<div className="mt-1 overflow-x-scroll whitespace-normal break-words text-sm font-medium leading-5">
{formatDateTime(itemData.discharge_date)}
</div>
</div>
<div className="mt-1 overflow-x-scroll whitespace-normal break-words text-sm font-medium leading-5">
{formatDateTime(itemData.discharge_date)}
</div>
)}
</div>
<div className="mt-8 flex flex-col">
{
<div className="flex flex-col items-center text-sm text-gray-700 md:flex-row">
<div className=" font-medium text-black">Created : </div>
<div className=" ml-1 text-black">
<RelativeDateUserMention
tooltipPosition="right"
actionDate={itemData.created_date}
user={itemData.created_by}
/>
</div>
</div>
</div>
)}
</div>
<div className="mt-8 flex flex-col">
{
}
<div className="flex flex-col items-center text-sm text-gray-700 md:flex-row">
<div className=" font-medium text-black">Created : </div>
<div className=" font-medium text-black">Last Modified : </div>
<div className=" ml-1 text-gray-700">
<RelativeDateUserMention
tooltipPosition="right"
actionDate={itemData.created_date}
user={itemData.created_by}
actionDate={itemData.modified_date}
user={itemData.last_edited_by}
/>
</div>
</div>
}
<div className="flex flex-col items-center text-sm text-gray-700 md:flex-row">
<div className=" font-medium text-black">Last Modified : </div>
<div className=" ml-1 text-gray-700">
<RelativeDateUserMention
tooltipPosition="right"
actionDate={itemData.modified_date}
user={itemData.last_edited_by}
/>
</div>
</div>
</div>
<div className="mt-4 flex w-full flex-col justify-between gap-1 md:flex-row">
<ButtonV2
id="view_consulation_updates"
className="h-auto whitespace-pre-wrap border border-gray-500 bg-white text-black hover:bg-gray-300"
onClick={() =>
navigate(
`/facility/${itemData.facility}/patient/${itemData.patient}/consultation/${itemData.id}`
)
}
>
View Consultation / Consultation Updates
</ButtonV2>
<ButtonV2
className="h-auto whitespace-pre-wrap border border-gray-500 bg-white text-black hover:bg-gray-300"
onClick={() =>
navigate(
`/facility/${itemData.facility}/patient/${itemData.patient}/consultation/${itemData.id}/files/`
)
}
>
View / Upload Consultation Files
</ButtonV2>
{isLastConsultation && (
<div className="mt-4 flex w-full flex-col justify-between gap-1 md:flex-row">
<ButtonV2
id="view_consulation_updates"
className="h-auto whitespace-pre-wrap border border-gray-500 bg-white text-black hover:bg-gray-300"
onClick={() =>
navigate(
`/facility/${itemData.facility}/patient/${itemData.patient}/consultation/${itemData.id}/daily-rounds`
`/facility/${itemData.facility}/patient/${itemData.patient}/consultation/${itemData.id}`
)
}
disabled={
(itemData.discharge_date as string | undefined) != undefined
>
View Consultation / Consultation Updates
</ButtonV2>
<ButtonV2
className="h-auto whitespace-pre-wrap border border-gray-500 bg-white text-black hover:bg-gray-300"
onClick={() =>
navigate(
`/facility/${itemData.facility}/patient/${itemData.patient}/consultation/${itemData.id}/files/`
)
}
authorizeFor={NonReadOnlyUsers}
>
Add Consultation Updates
View / Upload Consultation Files
</ButtonV2>
)}
{isLastConsultation && (
<ButtonV2
className="h-auto whitespace-pre-wrap border border-gray-500 bg-white text-black hover:bg-gray-300"
onClick={() => {
if (itemData.admitted && !itemData.current_bed) {
Notification.Error({
msg: "Please assign a bed to the patient",
});
setOpen(true);
} else {
navigate(
`/facility/${itemData.facility}/patient/${itemData.patient}/consultation/${itemData.id}/daily-rounds`
);
}
}}
disabled={itemData.discharge_date}
authorizeFor={NonReadOnlyUsers}
>
Add Consultation Updates
</ButtonV2>
)}
</div>
</div>
</div>
</>
);
};
1 change: 1 addition & 0 deletions src/Components/Patient/PatientHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1375,6 +1375,7 @@ export const PatientHome = (props: any) => {
isLastConsultation={
item.id == patientData.last_consultation?.id
}
refetch={refetch}
/>
)}
</PaginatedList.Items>
Expand Down
Loading