Skip to content

Commit

Permalink
Merge branch 'develop' into issue#6530
Browse files Browse the repository at this point in the history
  • Loading branch information
thedevildude authored Nov 29, 2023
2 parents b739413 + bf4920c commit f792cfc
Show file tree
Hide file tree
Showing 21 changed files with 721 additions and 704 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/facility_spec/facility.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe("Facility Creation", () => {
facilityPage.fillPhoneNumber("9898469865");
facilityPage.submitForm();

facilityPage.selectBedType("Non-Covid Oxygen beds");
facilityPage.selectBedType("Oxygen beds");
facilityPage.fillTotalCapacity("10");
facilityPage.fillCurrentlyOccupied("5");
facilityPage.saveAndExitBedCapacityForm();
Expand Down
3 changes: 2 additions & 1 deletion cypress/pageobject/Patient/PatientConsultation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ export class PatientConsultationPage {
}

clickDischargePatient() {
cy.get("#discharge_patient_from_care").click();
cy.get("#show-more").click();
cy.contains("p", "Discharge from CARE").click();
}

selectDischargeReason(reason: string) {
Expand Down
8 changes: 4 additions & 4 deletions src/Common/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,10 @@ export const getBedTypes = ({
: [];

return [
{ id: 1, text: "Non-Covid Ordinary Beds" },
{ id: 150, text: "Non-Covid Oxygen beds" },
{ id: 10, text: "Non-Covid ICU (ICU without ventilator)" },
{ id: 20, text: "Non-Covid Ventilator (ICU with ventilator)" },
{ id: 1, text: "Ordinary Beds" },
{ id: 150, text: "Oxygen beds" },
{ id: 10, text: "ICU (ICU without ventilator)" },
{ id: 20, text: "Ventilator (ICU with ventilator)" },
{ id: 30, text: "Covid Ordinary Beds" },
{ id: 120, text: "Covid Oxygen beds" },
{ id: 110, text: "Covid ICU (ICU without ventilator)" },
Expand Down
10 changes: 0 additions & 10 deletions src/Common/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,6 @@ export const parseOptionId: (
return textArray.join(", ");
};

export const getDimensionOrDash = (
value: number | string | null | undefined,
unit: string
) => {
if (value === undefined || value === null || value === 0 || value === "0") {
return "-";
}
return value + unit;
};

export const deepEqual = (x: any, y: any): boolean => {
if (x === y) return true;

Expand Down
2 changes: 1 addition & 1 deletion src/Components/Common/LocationSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface LocationSelectProps {
name: string;
disabled?: boolean;
margin?: string;
errors: string;
errors?: string;
className?: string;
searchAll?: boolean;
multiple?: boolean;
Expand Down
86 changes: 8 additions & 78 deletions src/Components/Facility/ConsultationDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ import {
} from "../../../Redux/actions";
import { statusType, useAbortableEffect } from "../../../Common/utils";
import { lazy, useCallback, useState } from "react";
import ButtonV2 from "../../Common/components/ButtonV2";
import CareIcon from "../../../CAREUI/icons/CareIcon";
import DischargeModal from "../DischargeModal";
import DischargeSummaryModal from "../DischargeSummaryModal";
import DoctorVideoSlideover from "../DoctorVideoSlideover";
import { make as Link } from "../../Common/components/Link.bs";
import PatientInfoCard from "../../Patient/PatientInfoCard";
Expand All @@ -25,7 +21,6 @@ import { formatDateTime, relativeTime } from "../../../Utils/utils";

import { navigate, useQueryParams } from "raviger";
import { useDispatch } from "react-redux";
import { useTranslation } from "react-i18next";
import { triggerGoal } from "../../../Integrations/Plausible";
import useAuthUser from "../../../Common/hooks/useAuthUser";
import { ConsultationUpdatesTab } from "./ConsultationUpdatesTab";
Expand Down Expand Up @@ -73,7 +68,6 @@ const TABS = {
};

export const ConsultationDetails = (props: any) => {
const { t } = useTranslation();
const { facilityId, patientId, consultationId } = props;
const tab = props.tab.toUpperCase() as keyof typeof TABS;
const dispatch: any = useDispatch();
Expand All @@ -86,9 +80,6 @@ export const ConsultationDetails = (props: any) => {
);
const [patientData, setPatientData] = useState<PatientModel>({});
const [activeShiftingData, setActiveShiftingData] = useState<Array<any>>([]);
const [openDischargeSummaryDialog, setOpenDischargeSummaryDialog] =
useState(false);
const [openDischargeDialog, setOpenDischargeDialog] = useState(false);
const [isCameraAttached, setIsCameraAttached] = useState(false);

const getPatientGender = (patientData: any) =>
Expand Down Expand Up @@ -197,19 +188,6 @@ export const ConsultationDetails = (props: any) => {

const SelectedTab = TABS[tab];

const hasActiveShiftingRequest = () => {
if (activeShiftingData.length > 0) {
return [
"PENDING",
"APPROVED",
"DESTINATION APPROVED",
"PATIENT TO BE PICKED UP",
].includes(activeShiftingData[activeShiftingData.length - 1].status);
}

return false;
};

if (isLoading) {
return <Loading />;
}
Expand Down Expand Up @@ -272,18 +250,6 @@ export const ConsultationDetails = (props: any) => {

return (
<div>
<DischargeSummaryModal
consultation={consultationData}
show={openDischargeSummaryDialog}
onClose={() => setOpenDischargeSummaryDialog(false)}
/>

<DischargeModal
show={openDischargeDialog}
onClose={() => setOpenDischargeDialog(false)}
consultationData={consultationData}
/>

<div className="px-2 pb-2">
<nav className="relative flex flex-wrap items-start justify-between">
<PageTitle
Expand All @@ -307,34 +273,6 @@ export const ConsultationDetails = (props: any) => {
<div className="flex w-full flex-col min-[1150px]:w-min min-[1150px]:flex-row min-[1150px]:items-center">
{!consultationData.discharge_date && (
<>
{hasActiveShiftingRequest() ? (
<ButtonV2
onClick={() =>
navigate(
`/shifting/${
activeShiftingData[activeShiftingData.length - 1].id
}`
)
}
className="btn btn-primary mx-1 w-full p-1.5 px-4 hover:text-white"
>
<CareIcon className="care-l-ambulance h-5 w-5" />
Track Shifting
</ButtonV2>
) : (
<ButtonV2
id="create_shift_request"
onClick={() =>
navigate(
`/facility/${patientData.facility}/patient/${patientData.id}/shift/new`
)
}
className="btn btn-primary mx-1 w-full p-1.5 px-4 hover:text-white"
>
<CareIcon className="care-l-ambulance h-5 w-5" />
Shift Patient
</ButtonV2>
)}
<button
onClick={() => {
triggerGoal("Doctor Connect Clicked", {
Expand Down Expand Up @@ -371,7 +309,13 @@ export const ConsultationDetails = (props: any) => {
</Link>
<Link
id="patient_doctor_notes"
onClick={() => setShowPatientNotesPopup(true)}
onClick={() =>
showPatientNotesPopup
? navigate(
`/facility/${facilityId}/patient/${patientId}/notes`
)
: setShowPatientNotesPopup(true)
}
className="btn btn-primary m-1 w-full hover:text-white"
>
Doctor&apos;s Notes
Expand All @@ -385,6 +329,7 @@ export const ConsultationDetails = (props: any) => {
consultation={consultationData}
fetchPatientData={fetchData}
consultationId={consultationId}
activeShiftingData={activeShiftingData}
showAbhaProfile={qParams["show-abha-profile"] === "true"}
/>

Expand Down Expand Up @@ -448,21 +393,6 @@ export const ConsultationDetails = (props: any) => {
</div>
)}
</div>
<div className="flex h-full w-full flex-col justify-end gap-2 text-right lg:flex-row">
<ButtonV2 onClick={() => setOpenDischargeSummaryDialog(true)}>
<i className="fas fa-clipboard-list"></i>
<span>{t("discharge_summary")}</span>
</ButtonV2>

<ButtonV2
id="discharge_patient_from_care"
onClick={() => setOpenDischargeDialog(true)}
disabled={!!consultationData.discharge_date}
>
<i className="fas fa-hospital-user"></i>
<span>{t("discharge_from_care")}</span>
</ButtonV2>
</div>
</div>
<div className="flex flex-col justify-between gap-2 p-4 md:flex-row">
<div className="font-base flex flex-col text-xs leading-relaxed text-gray-700">
Expand Down
4 changes: 4 additions & 0 deletions src/Components/Facility/ConsultationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,10 @@ export const ConsultationForm = (props: any) => {
errors[field] = "Field is required";
invalidForm = true;
}
if (dayjs(state.form.admission_date).isBefore(dayjs("2000-01-01"))) {
errors[field] = "Admission date cannot be before 01/01/2000";
invalidForm = true;
}
return;
case "cause_of_death":
if (state.form.suggestion === "DD" && !state.form[field]) {
Expand Down
119 changes: 119 additions & 0 deletions src/Components/Facility/FacilityBedCapacity.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import { useState } from "react";
import { getBedTypes } from "../../Common/constants";
import routes from "../../Redux/api";
import { NonReadOnlyUsers } from "../../Utils/AuthorizeFor";
import useQuery from "../../Utils/request/useQuery";
import DialogModal from "../Common/Dialog";
import ButtonV2 from "../Common/components/ButtonV2";
import { BedCapacity } from "./BedCapacity";
import BedTypeCard from "./BedTypeCard";
import useConfig from "../../Common/hooks/useConfig";

export const FacilityBedCapacity = (props: any) => {
const [bedCapacityModalOpen, setBedCapacityModalOpen] = useState(false);
const config = useConfig();

const capacityQuery = useQuery(routes.getCapacity, {
pathParams: { facilityId: props.facilityId },
});

let capacityList: any = null;
if (!capacityQuery.data || !capacityQuery.data.results.length) {
capacityList = (
<h5 className="mt-4 flex w-full items-center justify-center rounded-lg bg-white p-4 text-xl font-bold text-gray-500 shadow">
No Bed Types Found
</h5>
);
} else {
const totalBedCount = capacityQuery.data.results.reduce(
(acc, x) => acc + (x.total_capacity ? x.total_capacity : 0),
0
);
const totalOccupiedBedCount = capacityQuery.data.results.reduce(
(acc, x) => acc + (x.current_capacity ? x.current_capacity : 0),
0
);

capacityList = (
<div className="mt-4 grid w-full gap-7 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4">
<BedTypeCard
label="Total Beds"
used={totalOccupiedBedCount}
total={totalBedCount}
handleUpdate={() => {
return;
}}
/>
{getBedTypes(config).map((x) => {
const res = capacityQuery.data?.results.find((data) => {
return data.room_type === x.id;
});
if (
res &&
res.current_capacity !== undefined &&
res.total_capacity !== undefined
) {
const removeCurrentBedType = (bedTypeId: number | undefined) => {
if (capacityQuery.data !== undefined) {
capacityQuery.data.results.filter((i) => i.id !== bedTypeId);
capacityQuery.refetch();
}
};
return (
<BedTypeCard
facilityId={props.facilityId}
bedCapacityId={res.id}
key={`bed_${res.id}`}
room_type={res.room_type}
label={x.text}
used={res.current_capacity}
total={res.total_capacity}
lastUpdated={res.modified_date}
removeBedType={removeCurrentBedType}
handleUpdate={() => {
capacityQuery.refetch();
}}
/>
);
}
})}
</div>
);
}

return (
<div>
<div className="mt-5 rounded bg-white p-3 shadow-sm md:p-6">
<div className="justify-between md:flex md:border-b md:pb-2">
<div className="mb-2 text-xl font-semibold">Bed Capacity</div>
<ButtonV2
className="w-full md:w-auto"
onClick={() => setBedCapacityModalOpen(true)}
authorizeFor={NonReadOnlyUsers}
>
<i className="fas fa-bed mr-2 text-white" />
Add More Bed Types
</ButtonV2>
</div>
<div>{capacityList}</div>
</div>

{bedCapacityModalOpen && (
<DialogModal
show={bedCapacityModalOpen}
onClose={() => setBedCapacityModalOpen(false)}
title="Add Bed Capacity"
className="max-w-md md:min-w-[600px]"
>
<BedCapacity
facilityId={props.facilityId}
handleClose={() => setBedCapacityModalOpen(false)}
handleUpdate={async () => {
capacityQuery.refetch();
}}
/>
</DialogModal>
)}
</div>
);
};
21 changes: 10 additions & 11 deletions src/Components/Facility/FacilityCard.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { useState } from "react";
import { useDispatch } from "react-redux";
import { Link } from "raviger";
import { useTranslation } from "react-i18next";

import { sendNotificationMessages } from "../../Redux/actions";
import { FACILITY_FEATURE_TYPES } from "../../Common/constants";
import ButtonV2, { Cancel, Submit } from "../Common/components/ButtonV2";
import * as Notification from "../../Utils/Notifications.js";
Expand All @@ -14,26 +11,28 @@ import DialogModal from "../Common/Dialog";
import TextAreaFormField from "../Form/FormFields/TextAreaFormField";
import useConfig from "../../Common/hooks/useConfig";
import { classNames } from "../../Utils/utils";
import request from "../../Utils/request/request";
import routes from "../../Redux/api";

export const FacilityCard = (props: { facility: any; userType: any }) => {
const { facility, userType } = props;
const { kasp_string } = useConfig();

const { t } = useTranslation();
const dispatchAction: any = useDispatch();
const [notifyModalFor, setNotifyModalFor] = useState(undefined);
const [notifyMessage, setNotifyMessage] = useState("");
const [notifyError, setNotifyError] = useState("");

const handleNotifySubmit = async (id: any) => {
const data = {
facility: id,
message: notifyMessage,
};
if (data.message.trim().length >= 1) {
if (notifyMessage.trim().length >= 1) {
setNotifyError("");
const res = await dispatchAction(sendNotificationMessages(data));
if (res && res.status == 204) {
const { res } = await request(routes.sendNotificationMessages, {
body: {
facility: id,
message: notifyMessage,
},
});
if (res?.ok) {
Notification.Success({
msg: "Facility Notified",
});
Expand Down
Loading

0 comments on commit f792cfc

Please sign in to comment.