-
+ |
{dayjs(service.serviced_on).format("DD MMM YYYY")}
@@ -229,7 +205,7 @@ const AssetManage = (props: AssetManageProps) => {
)}
|
-
+ |
{
};
useEffect(() => {
- populateTableRows(transactions);
+ if (transactions) populateTableRows(transactions.results);
}, [transactions]);
useEffect(() => {
- populateServiceTableRows(services);
+ if (services) populateServiceTableRows(services?.results);
}, [services]);
- if (isLoading) return ;
+ if (loading) return ;
if (isPrintMode) return ;
const assetClassProp =
@@ -323,13 +299,17 @@ const AssetManage = (props: AssetManageProps) => {
const handleDelete = async () => {
if (asset) {
- const response = await dispatch(deleteAsset(asset.id));
- if (response && response.status === 204) {
- Notification.Success({
- msg: "Asset deleted successfully",
- });
- navigate("/assets");
- }
+ await request(routes.deleteAsset, {
+ pathParams: {
+ external_id: asset.id,
+ },
+ onResponse: () => {
+ Notification.Success({
+ msg: "Asset deleted successfully",
+ });
+ navigate("/assets");
+ },
+ });
}
};
@@ -408,6 +388,9 @@ const AssetManage = (props: AssetManageProps) => {
startIcon="l-times"
/>
)}
+ {warrantyAmcValidityChip(
+ asset?.warranty_amc_end_of_validity as string
+ )}
@@ -449,20 +432,24 @@ const AssetManage = (props: AssetManageProps) => {
{t("update")}
- {asset?.asset_class && (
-
- navigate(
- `/facility/${asset?.location_object.facility.id}/assets/${asset?.id}/configure`
- )
- }
- id="configure-asset"
- data-testid="asset-configure-button"
- >
-
- {t("configure")}
-
- )}
+ {asset?.asset_class &&
+ (asset?.asset_class !== "ONVIF" ||
+ ["DistrictAdmin", "StateAdmin", "Doctor"].includes(
+ authUser.user_type
+ )) && (
+
+ navigate(
+ `/facility/${asset?.location_object.facility.id}/assets/${asset?.id}/configure`
+ )
+ }
+ id="configure-asset"
+ data-testid="asset-configure-button"
+ >
+
+ {t("configure")}
+
+ )}
{checkAuthority(authUser.user_type, "DistrictAdmin") && (
{
-
+ |
Serviced on
|
@@ -537,7 +524,7 @@ const AssetManage = (props: AssetManageProps) => {
|
Last Updated
|
-
+ |
Edit
|
@@ -558,13 +545,13 @@ const AssetManage = (props: AssetManageProps) => {
Moved from
|
-
+ |
Moved to
|
-
+ |
Moved By
|
-
+ |
Moved On
|
@@ -591,7 +578,7 @@ const AssetManage = (props: AssetManageProps) => {
handleClose={() =>
setServiceEditData({ ...serviceEditData, open: false })
}
- handleUpdate={() => fetchData({ aborted: false })}
+ handleUpdate={() => serviceRefetch()}
show={serviceEditData.open}
viewOnly={serviceEditData.viewOnly}
/>
diff --git a/src/Components/Assets/AssetServiceEditModal.tsx b/src/Components/Assets/AssetServiceEditModal.tsx
index 66d44d11907..3964dfe0770 100644
--- a/src/Components/Assets/AssetServiceEditModal.tsx
+++ b/src/Components/Assets/AssetServiceEditModal.tsx
@@ -1,16 +1,16 @@
import { useEffect, useState } from "react";
-import { useDispatch } from "react-redux";
-import { updateAssetService } from "../../Redux/actions";
import * as Notification from "../../Utils/Notifications.js";
import ButtonV2, { Cancel, Submit } from "../Common/components/ButtonV2";
import DialogModal from "../Common/Dialog";
import { AssetData, AssetService, AssetServiceEdit } from "./AssetTypes";
import dayjs from "dayjs";
import TextAreaFormField from "../Form/FormFields/TextAreaFormField";
-import DateInputV2 from "../Common/DateInputV2";
-import { FieldLabel } from "../Form/FormFields/FormField";
import { formatDate, formatDateTime } from "../../Utils/utils";
import CareIcon from "../../CAREUI/icons/CareIcon";
+import request from "../../Utils/request/request";
+import routes from "../../Redux/api";
+import DateFormField from "../Form/FormFields/DateFormField";
+import { t } from "i18next";
export const AssetServiceEditModal = (props: {
asset?: AssetData;
@@ -24,23 +24,25 @@ export const AssetServiceEditModal = (props: {
serviced_on: props.service_record?.serviced_on,
note: props.service_record?.note,
});
- const dispatchAction: any = useDispatch();
const [isLoading, setIsLoading] = useState(false);
const [editRecord, setEditRecord] = useState();
const handleSubmit = async (e: any) => {
e.preventDefault();
setIsLoading(true);
- const data = {
+ const body = {
serviced_on: form.serviced_on,
note: form.note,
};
-
- const res = await dispatchAction(
- updateAssetService(props.asset?.id ?? "", props.service_record.id, data)
- );
+ const { data } = await request(routes.updateAssetService, {
+ pathParams: {
+ asset_external_id: props.asset?.id ?? "",
+ external_id: props.service_record.id,
+ },
+ body: body,
+ });
setIsLoading(false);
- if (res?.data) {
+ if (data) {
Notification.Success({
msg: "Asset service record updated successfully",
});
@@ -61,12 +63,12 @@ export const AssetServiceEditModal = (props: {
- Update record for asset
+ {t("update_record_for_asset")}
{props.asset?.name}
@@ -110,13 +112,17 @@ export const AssetServiceEditModal = (props: {
- Edited On
+
+ {t("edited_on")}
+
{formatDateTime(editRecord.edited_on)}
- Edited By
+
+ {t("edited_by")}
+
{editRecord.edited_by.username}
@@ -125,7 +131,7 @@ export const AssetServiceEditModal = (props: {
- Serviced On
+ {t("serviced_on")}
- Notes
+
+ {t("notes")}
+
{editRecord.note || "-"}
@@ -151,7 +159,7 @@ export const AssetServiceEditModal = (props: {
editRecord ? setEditRecord(undefined) : props.handleClose();
}}
>
- {editRecord ? "Back" : "Close"}
+ {editRecord ? t("back") : t("close")}
@@ -163,12 +171,12 @@ export const AssetServiceEditModal = (props: {
- Update record for asset
+ {t("update_record_for_asset")}
{props.asset?.name}
@@ -178,19 +186,31 @@ export const AssetServiceEditModal = (props: {
className="col-span-6 sm:col-span-3"
data-testid="asset-last-serviced-on-input"
>
- Serviced On
- {
- setForm({
- ...form,
- serviced_on: dayjs(date).format("YYYY-MM-DD"),
- });
+ if (
+ dayjs(date.value).format("YYYY-MM-DD") >
+ new Date(
+ props.service_record.created_date
+ ).toLocaleDateString("en-ca")
+ ) {
+ Notification.Error({
+ msg: `Service date can't be after ${formatDate(
+ props.service_record.created_date
+ )} (Creation date)`,
+ });
+ } else {
+ setForm({
+ ...form,
+ serviced_on: dayjs(date.value).format("YYYY-MM-DD"),
+ });
+ }
}}
- max={new Date(props.service_record.created_date)}
/>
@@ -198,8 +218,8 @@ export const AssetServiceEditModal = (props: {
{
setForm({ ...form, note: e.value });
@@ -210,7 +230,7 @@ export const AssetServiceEditModal = (props: {
diff --git a/src/Components/Assets/AssetType/HL7Monitor.tsx b/src/Components/Assets/AssetType/HL7Monitor.tsx
index 55f4d0c258e..b4fefbc90b2 100644
--- a/src/Components/Assets/AssetType/HL7Monitor.tsx
+++ b/src/Components/Assets/AssetType/HL7Monitor.tsx
@@ -1,10 +1,5 @@
import { SyntheticEvent, useEffect, useState } from "react";
import { AssetData } from "../AssetTypes";
-import { useDispatch } from "react-redux";
-import {
- partialUpdateAsset,
- getPermittedFacility,
-} from "../../../Redux/actions";
import * as Notification from "../../../Utils/Notifications.js";
import MonitorConfigure from "../configure/MonitorConfigure";
import Loading from "../../Common/Loading";
@@ -16,6 +11,9 @@ import TextFormField from "../../Form/FormFields/TextFormField";
import HL7PatientVitalsMonitor from "../../VitalsMonitor/HL7PatientVitalsMonitor";
import VentilatorPatientVitalsMonitor from "../../VitalsMonitor/VentilatorPatientVitalsMonitor";
import useAuthUser from "../../../Common/hooks/useAuthUser";
+import request from "../../../Utils/request/request";
+import routes from "../../../Redux/api";
+import useQuery from "../../../Utils/request/useQuery";
interface HL7MonitorProps {
assetId: string;
@@ -33,19 +31,14 @@ const HL7Monitor = (props: HL7MonitorProps) => {
const [localipAddress, setLocalIPAddress] = useState("");
const [ipadrdress_error, setIpAddress_error] = useState("");
const authUser = useAuthUser();
- const dispatch = useDispatch ();
-
- useEffect(() => {
- const fetchFacility = async () => {
- const res = await dispatch(getPermittedFacility(facilityId));
-
- if (res.status === 200 && res.data) {
- setFacilityMiddlewareHostname(res.data.middleware_address);
+ const { data: facility, loading } = useQuery(routes.getPermittedFacility, {
+ pathParams: { id: facilityId },
+ onResponse: ({ res, data }) => {
+ if (res?.status === 200 && data && data.middleware_address) {
+ setFacilityMiddlewareHostname(data.middleware_address);
}
- };
-
- if (facilityId) fetchFacility();
- }, [dispatch, facilityId]);
+ },
+ });
useEffect(() => {
setAssetType(asset?.asset_class);
@@ -65,26 +58,28 @@ const HL7Monitor = (props: HL7MonitorProps) => {
local_ip_address: localipAddress,
},
};
- const res: any = await Promise.resolve(
- dispatch(partialUpdateAsset(assetId, data))
- );
+ const { res } = await request(routes.partialUpdateAsset, {
+ pathParams: { external_id: assetId },
+ body: data,
+ });
if (res?.status === 200) {
Notification.Success({
msg: "Asset Configured Successfully",
});
} else {
Notification.Error({
- msg: "Something went wrong..!",
+ msg: "Something went wrong!",
});
}
} else {
- setIpAddress_error("Please Enter a Valid IP address !!");
+ setIpAddress_error("IP address is invalid");
}
};
- const middleware = middlewareHostname || facilityMiddlewareHostname;
+ const fallbackMiddleware =
+ asset?.location_object?.middleware_address || facilityMiddlewareHostname;
- if (isLoading) return ;
+ if (isLoading || loading || !facility) return ;
return (
@@ -93,11 +88,29 @@ const HL7Monitor = (props: HL7MonitorProps) => {
@@ -422,12 +363,30 @@ const AssetsList = () => {
<>
[
- value("Facility", "facility", facilityName ?? ""),
+ value(
+ "Facility",
+ "facility",
+ qParams.facility && facilityObject?.name
+ ),
badge("Name/Serial No./QR ID", "search"),
value("Asset Type", "asset_type", asset_type ?? ""),
value("Asset Class", "asset_class", asset_class ?? ""),
value("Status", "status", status?.replace(/_/g, " ") ?? ""),
- value("Location", "location", locationName ?? ""),
+ value(
+ "Location",
+ "location",
+ qParams.location && locationObject?.name
+ ),
+ value(
+ "Warranty AMC End Of Validity Before",
+ "warranty_amc_end_of_validity_before",
+ qParams.warranty_amc_end_of_validity_before ?? ""
+ ),
+ value(
+ "Warranty AMC End Of Validity After",
+ "warranty_amc_end_of_validity_after",
+ qParams.warranty_amc_end_of_validity_after ?? ""
+ ),
]}
/>
@@ -484,4 +443,47 @@ const AssetsList = () => {
);
};
+export const warrantyAmcValidityChip = (
+ warranty_amc_end_of_validity: string
+) => {
+ if (warranty_amc_end_of_validity === "" || !warranty_amc_end_of_validity)
+ return;
+ const today = new Date();
+ const warrantyAmcEndDate = new Date(warranty_amc_end_of_validity);
+
+ const days = Math.ceil(
+ Math.abs(Number(warrantyAmcEndDate) - Number(today)) / (1000 * 60 * 60 * 24)
+ );
+
+ if (warrantyAmcEndDate < today) {
+ return (
+
+ );
+ } else if (days <= 30) {
+ return (
+
+ );
+ } else if (days <= 90) {
+ return (
+
+ );
+ }
+};
+
export default AssetsList;
diff --git a/src/Components/Assets/configure/MonitorConfigure.tsx b/src/Components/Assets/configure/MonitorConfigure.tsx
index 1d469335ce2..d1b24b24959 100644
--- a/src/Components/Assets/configure/MonitorConfigure.tsx
+++ b/src/Components/Assets/configure/MonitorConfigure.tsx
@@ -1,62 +1,50 @@
-import { Dispatch, useEffect, useState } from "react";
+import { useState } from "react";
import { BedSelect } from "../../Common/BedSelect";
import { BedModel } from "../../Facility/models";
import { AssetData } from "../AssetTypes";
-import {
- createAssetBed,
- listAssetBeds,
- partialUpdateAssetBed,
-} from "../../../Redux/actions";
import * as Notification from "../../../Utils/Notifications.js";
-import { useDispatch } from "react-redux";
import { Submit } from "../../Common/components/ButtonV2";
import { FieldLabel } from "../../Form/FormFields/FormField";
+import request from "../../../Utils/request/request";
+import routes from "../../../Redux/api";
+import useQuery from "../../../Utils/request/useQuery";
-const saveLink = (assetId: string, bedId: string, dispatch: Dispatch ) => {
- dispatch(createAssetBed({}, assetId, bedId));
+const saveLink = async (assetId: string, bedId: string) => {
+ await request(routes.createAssetBed, {
+ body: {
+ asset: assetId,
+ bed: bedId,
+ },
+ });
Notification.Success({ msg: "AssetBed Link created successfully" });
};
-const update_Link = (
+const update_Link = async (
assetbedId: string,
assetId: string,
- bed: BedModel,
- assetBed: any,
- dispatch: Dispatch
+ bed: BedModel
) => {
- dispatch(
- partialUpdateAssetBed(
- {
- asset: assetId,
- bed: bed.id,
- },
- assetbedId
- )
- );
+ await request(routes.partialUpdateAssetBed, {
+ pathParams: { external_id: assetbedId },
+ body: {
+ asset: assetId,
+ bed: bed.id ?? "",
+ },
+ });
Notification.Success({ msg: "AssetBed Link updated successfully" });
};
export default function MonitorConfigure({ asset }: { asset: AssetData }) {
const [bed, setBed] = useState({});
const [updateLink, setUpdateLink] = useState(false);
- const [assetBed, setAssetBed] = useState();
- const dispatch: any = useDispatch();
-
- const getAssetBeds = async (id: string) => {
- const assetBeds = await dispatch(listAssetBeds({ asset: id }));
- if (assetBeds.data?.results?.length > 0) {
- setUpdateLink(true);
- setAssetBed(assetBeds.data.results[0]);
- setBed(assetBeds.data.results[0].bed_object);
- } else {
- setUpdateLink(false);
- }
- };
-
- useEffect(() => {
- if (asset.id) {
- getAssetBeds(asset.id);
- }
- }, [asset]);
+ const { data: assetBed } = useQuery(routes.listAssetBeds, {
+ query: { asset: asset.id },
+ onResponse: ({ res, data }) => {
+ if (res?.status === 200 && data && data.results.length > 0) {
+ setBed(data.results[0].bed_object);
+ setUpdateLink(true);
+ }
+ },
+ });
return (
@@ -385,14 +369,9 @@ const DateInputV2: React.FC = ({
)}
onClick={setMonthValue(i)}
>
- {format(
- new Date(
- datePickerHeaderDate.getFullYear(),
- i,
- 1
- ),
- "MMM"
- )}
+ {dayjs(
+ new Date(datePickerHeaderDate.getFullYear(), i, 1)
+ ).format("MMM")}
))}
diff --git a/src/Components/Common/Export.tsx b/src/Components/Common/Export.tsx
index 3595b3c84a0..f991c476aac 100644
--- a/src/Components/Common/Export.tsx
+++ b/src/Components/Common/Export.tsx
@@ -44,7 +44,7 @@ export const ExportMenu = ({
}
+ icon={ }
className="tooltip border-primary-500 bg-white text-primary-500 hover:bg-primary-100 enabled:border"
>
{exportItems.map((item) => (
diff --git a/src/Components/Common/GLocationPicker.tsx b/src/Components/Common/GLocationPicker.tsx
index 5356d28fa2a..fc121b8519f 100644
--- a/src/Components/Common/GLocationPicker.tsx
+++ b/src/Components/Common/GLocationPicker.tsx
@@ -7,14 +7,6 @@ import CareIcon from "../../CAREUI/icons/CareIcon";
import useConfig from "../../Common/hooks/useConfig";
import { Popover } from "@headlessui/react";
-const render = (status: Status) => {
- if (status === "LOADING") {
- return ;
- }
-
- return {status};
-};
-
interface GLocationPickerProps {
lat: number;
lng: number;
@@ -67,22 +59,37 @@ const GLocationPicker = ({
setCenter(m?.getCenter()?.toJSON());
};
+ const render = (status: Status) => {
+ switch (status) {
+ case Status.LOADING:
+ return ;
+ case Status.SUCCESS:
+ return (
+
+ );
+ default:
+ return {status};
+ }
+ };
+
return (
-
-
-
+
);
};
@@ -149,7 +156,9 @@ const Map: React.FC = ({
places.length > 0 &&
places[0].geometry?.location
) {
- handleOnChange(places[0].geometry.location);
+ const selectedLocation = places[0].geometry.location;
+ handleOnChange(selectedLocation);
+ map?.setCenter(selectedLocation);
}
});
}
diff --git a/src/Components/Common/Uptime.tsx b/src/Components/Common/Uptime.tsx
index ce60e7b7f7e..6f6966b9053 100644
--- a/src/Components/Common/Uptime.tsx
+++ b/src/Components/Common/Uptime.tsx
@@ -4,7 +4,7 @@ import { listAssetAvailability } from "../../Redux/actions";
import { useDispatch } from "react-redux";
import * as Notification from "../../Utils/Notifications.js";
import { AssetStatus, AssetUptimeRecord } from "../Assets/AssetTypes";
-import { reverse } from "lodash";
+import { reverse } from "lodash-es";
import { classNames } from "../../Utils/utils";
import dayjs from "../../Utils/dayjs";
diff --git a/src/Components/Common/components/Menu.tsx b/src/Components/Common/components/Menu.tsx
index 4b52a293f9e..49ee02b393e 100644
--- a/src/Components/Common/components/Menu.tsx
+++ b/src/Components/Common/components/Menu.tsx
@@ -16,6 +16,7 @@ interface DropdownMenuProps {
children: JSX.Element | JSX.Element[];
disabled?: boolean | undefined;
className?: string | undefined;
+ itemClassName?: string | undefined;
}
export default function DropdownMenu({
@@ -36,7 +37,9 @@ export default function DropdownMenu({
-
+
<>{props.children}>
diff --git a/src/Components/Common/components/SwitchTabs.tsx b/src/Components/Common/components/SwitchTabs.tsx
index 0592f0272dd..047dba53b4b 100644
--- a/src/Components/Common/components/SwitchTabs.tsx
+++ b/src/Components/Common/components/SwitchTabs.tsx
@@ -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 (
- {props.Tab1}
+ {props.tab1}
- {props.Tab2}
+ {props.tab2}
);
diff --git a/src/Components/CriticalCareRecording/NeurologicalMonitoring/CriticalCare__NeurologicalMonitoringEditor.res b/src/Components/CriticalCareRecording/NeurologicalMonitoring/CriticalCare__NeurologicalMonitoringEditor.res
index 35d137e0414..dfe0e5cc3dc 100644
--- a/src/Components/CriticalCareRecording/NeurologicalMonitoring/CriticalCare__NeurologicalMonitoringEditor.res
+++ b/src/Components/CriticalCareRecording/NeurologicalMonitoring/CriticalCare__NeurologicalMonitoringEditor.res
@@ -68,12 +68,12 @@ let reducer = (state, action) => {
| SetConsciousnessLevel(consciousnessLevel) => {
...state,
dirty: true,
- consciousnessLevel: consciousnessLevel,
+ consciousnessLevel,
}
| SetConsciousnessLevelDetails(consciousnessLevelDetails) => {
...state,
dirty: true,
- consciousnessLevelDetails: consciousnessLevelDetails,
+ consciousnessLevelDetails,
}
| SetLeftPupilSize(leftPupilSize) => {
...state,
@@ -83,17 +83,17 @@ let reducer = (state, action) => {
| SetLeftPupilSizeDetails(leftPupilSizeDetails) => {
...state,
dirty: true,
- leftPupilSizeDetails: leftPupilSizeDetails,
+ leftPupilSizeDetails,
}
| SetLeftPupilLightReaction(leftPupilLightReaction) => {
...state,
dirty: true,
- leftPupilLightReaction: leftPupilLightReaction,
+ leftPupilLightReaction,
}
| SetLeftPupilLightReactionDetails(leftPupilLightReactionDetails) => {
...state,
dirty: true,
- leftPupilLightReactionDetails: leftPupilLightReactionDetails,
+ leftPupilLightReactionDetails,
}
| SetRightPupilSize(rightPupilSize) => {
...state,
@@ -103,17 +103,17 @@ let reducer = (state, action) => {
| SetRightPupilSizeDetails(rightPupilSizeDetails) => {
...state,
dirty: true,
- rightPupilSizeDetails: rightPupilSizeDetails,
+ rightPupilSizeDetails,
}
| SetRightPupilLightReaction(rightPupilLightReaction) => {
...state,
dirty: true,
- rightPupilLightReaction: rightPupilLightReaction,
+ rightPupilLightReaction,
}
| SetRightPupilLightReactionDetails(rightPupilLightReactionDetails) => {
...state,
dirty: true,
- rightPupilLightReactionDetails: rightPupilLightReactionDetails,
+ rightPupilLightReactionDetails,
}
| SetGlasgowEyeOpen(glasgowEyeOpen) => {...state, glasgowEyeOpen: Some(glasgowEyeOpen)}
| SetGlasgowVerbalResponse(glasgowVerbalResponse) => {
@@ -129,22 +129,22 @@ let reducer = (state, action) => {
| SetLimbResponseUpperExtremityRight(limbResponseUpperExtremityRight) => {
...state,
dirty: true,
- limbResponseUpperExtremityRight: limbResponseUpperExtremityRight,
+ limbResponseUpperExtremityRight,
}
| SetLimbResponseUpperExtremityLeft(limbResponseUpperExtremityLeft) => {
...state,
dirty: true,
- limbResponseUpperExtremityLeft: limbResponseUpperExtremityLeft,
+ limbResponseUpperExtremityLeft,
}
| SetLimbResponseLowerExtremityRight(limbResponseLowerExtremityRight) => {
...state,
dirty: true,
- limbResponseLowerExtremityRight: limbResponseLowerExtremityRight,
+ limbResponseLowerExtremityRight,
}
| SetLimbResponseLowerExtremityLeft(limbResponseLowerExtremityLeft) => {
...state,
dirty: true,
- limbResponseLowerExtremityLeft: limbResponseLowerExtremityLeft,
+ limbResponseLowerExtremityLeft,
}
| SetSaving => {...state, saving: true}
@@ -265,7 +265,7 @@ let renderConsciousnessLevel = (
) => {
{str("Level Of Consciousness")}
-
+
{Js.Array.map(consciousnessLevel => {
onInputChange(consciousnessLevel)}
/>
- }, [Alert, Drowsy, Stuporous, Comatose, CannotBeAssessed])->React.array}
+ }, [
+ Unresponsive,
+ Alert,
+ RespondsToPain,
+ RespondsToVoice,
+ AgitatedOrConfused,
+ OnsetOfAgitationAndConfusion,
+ ])->React.array}
- {ReactUtils.nullUnless(
- onInputDetailsChange(event)}
- />,
- input === NeurologicalMonitoring.CannotBeAssessed,
- )}
}
diff --git a/src/Components/CriticalCareRecording/NeurologicalMonitoring/DailyRound__NeurologicalMonitoring.res b/src/Components/CriticalCareRecording/NeurologicalMonitoring/DailyRound__NeurologicalMonitoring.res
index f476fd36c46..7dd295ecb51 100644
--- a/src/Components/CriticalCareRecording/NeurologicalMonitoring/DailyRound__NeurologicalMonitoring.res
+++ b/src/Components/CriticalCareRecording/NeurologicalMonitoring/DailyRound__NeurologicalMonitoring.res
@@ -16,10 +16,6 @@ let make = (
NeurologicalMonitoring.consciousnessLevel(neurologicalMonitoring),
),
)}
- {renderOptionalDescription(
- "Consciousness Level Reaction Description",
- NeurologicalMonitoring.consciousnessLevelDetails(neurologicalMonitoring),
- )}
{title("Left Pupil")}
diff --git a/src/Components/CriticalCareRecording/Pain/CriticalCare__PainInputModal.res b/src/Components/CriticalCareRecording/Pain/CriticalCare__PainInputModal.res
index 63be6d2f3a4..eb4fd2b2376 100644
--- a/src/Components/CriticalCareRecording/Pain/CriticalCare__PainInputModal.res
+++ b/src/Components/CriticalCareRecording/Pain/CriticalCare__PainInputModal.res
@@ -31,7 +31,6 @@ let make = (
None
}, [state])
-
let handleClickOutside = %raw(`
function (event, ref, hideModal) {
if (ref.current && !ref.current.contains(event.target)) {
@@ -56,18 +55,18 @@ let make = (
}
})
-let getStatus = (min, minText, max, maxText, val) => {
- switch (val >= min, val <= max) {
- | (true, true) => ("Normal", "#059669")
- | (true, false) => (maxText, "#DC2626")
- | _ => (minText, "#DC2626")
+ let getStatus = (min, minText, max, maxText, val) => {
+ switch (val >= min, val <= max) {
+ | (true, true) => ("Normal", "#059669")
+ | (true, false) => (maxText, "#DC2626")
+ | _ => (minText, "#DC2626")
+ }
}
-}
handleClickOutside(e, modalRef, hideModal)}
- className={previewMode && innerWidth > 720 ? "" : "fixed w-full inset-0 z-40 overflow-y-auto"}>
+ className="absolute w-full inset-0 z-40 overflow-y-auto">
@@ -85,9 +84,7 @@ let getStatus = (min, minText, max, maxText, val) => {
{str("Region: ")}
-
- {str(Pain.regionToString(state.region))}
-
+ {str(Pain.regionToString(state.region))}
@@ -108,7 +105,11 @@ let getStatus = (min, minText, max, maxText, val) => {
}
}}
getLabel={getStatus(2.0, "Low", 4.0, "High")}
- hasError={ValidationUtils.isInputInRangeInt(0, 5, Belt.Float.toString(painScale)->Belt.Int.fromString)}
+ hasError={ValidationUtils.isInputInRangeInt(
+ 0,
+ 5,
+ Belt.Float.toString(painScale)->Belt.Int.fromString,
+ )}
/>
-}
\ No newline at end of file
+}
diff --git a/src/Components/CriticalCareRecording/types/CriticalCare__NeurologicalMonitoring.res b/src/Components/CriticalCareRecording/types/CriticalCare__NeurologicalMonitoring.res
index f42ca5c140d..0fae710ce36 100644
--- a/src/Components/CriticalCareRecording/types/CriticalCare__NeurologicalMonitoring.res
+++ b/src/Components/CriticalCareRecording/types/CriticalCare__NeurologicalMonitoring.res
@@ -1,4 +1,11 @@
-type consciousnessLevel = Alert | Drowsy | Stuporous | Comatose | CannotBeAssessed | Unknown
+type consciousnessLevel =
+ | Unresponsive
+ | RespondsToPain
+ | RespondsToVoice
+ | Alert
+ | AgitatedOrConfused
+ | OnsetOfAgitationAndConfusion
+ | Unknown
type lightReaction = Brisk | Sluggish | Fixed | CannotBeAssessed | Unknown
type limpResponse = Strong | Moderate | Weak | Flexion | Extension | NONE_ | Unknown
@@ -68,11 +75,12 @@ let make = (
let makeConsciousnessLevel = consciousnessLevel => {
switch consciousnessLevel {
+ | "UNRESPONSIVE" => Unresponsive
+ | "RESPONDS_TO_PAIN" => RespondsToPain
+ | "RESPONDS_TO_VOICE" => RespondsToVoice
| "ALERT" => Alert
- | "DROWSY" => Drowsy
- | "STUPOROUS" => Stuporous
- | "COMATOSE" => Comatose
- | "CANNOT_BE_ASSESSED" => CannotBeAssessed
+ | "AGITATED_OR_CONFUSED" => AgitatedOrConfused
+ | "ONSET_OF_AGITATION_AND_CONFUSION" => OnsetOfAgitationAndConfusion
| "UNKNOWN"
| _ =>
Unknown
@@ -81,11 +89,12 @@ let makeConsciousnessLevel = consciousnessLevel => {
let encodeConConsciousnessLevel = consciousnessLevel => {
switch consciousnessLevel {
+ | Unresponsive => "UNRESPONSIVE"
+ | RespondsToPain => "RESPONDS_TO_PAIN"
+ | RespondsToVoice => "RESPONDS_TO_VOICE"
| Alert => "ALERT"
- | Drowsy => "DROWSY"
- | Stuporous => "STUPOROUS"
- | Comatose => "COMATOSE"
- | CannotBeAssessed => "CANNOT_BE_ASSESSED"
+ | AgitatedOrConfused => "AGITATED_OR_CONFUSED"
+ | OnsetOfAgitationAndConfusion => "ONSET_OF_AGITATION_AND_CONFUSION"
| Unknown => "UNKNOWN"
}
}
@@ -150,11 +159,12 @@ let lightReactionToString = lightReaction => {
let consciousnessLevelToString = consciousnessLevel => {
switch consciousnessLevel {
+ | Unresponsive => "Unresponsive"
+ | RespondsToPain => "Responds to Pain"
+ | RespondsToVoice => "Responds to Voice"
| Alert => "Alert"
- | Drowsy => "Drowsy"
- | Stuporous => "Stuporous"
- | Comatose => "Comatose"
- | CannotBeAssessed => "Cannot be assessed"
+ | AgitatedOrConfused => "Agitated or Confused"
+ | OnsetOfAgitationAndConfusion => "Onset of Agitation and Confusion"
| Unknown => "Unknown"
}
}
diff --git a/src/Components/DeathReport/DeathReport.tsx b/src/Components/DeathReport/DeathReport.tsx
index be725eb3b6d..9908b4fa852 100644
--- a/src/Components/DeathReport/DeathReport.tsx
+++ b/src/Components/DeathReport/DeathReport.tsx
@@ -1,6 +1,5 @@
-import { useState, useCallback } from "react";
-import { useDispatch } from "react-redux";
-import { getPatient } from "../../Redux/actions";
+/* eslint-disable @typescript-eslint/no-unused-vars */
+import { useEffect, useState } from "react";
import { statusType, useAbortableEffect } from "../../Common/utils";
import { GENDER_TYPES } from "../../Common/constants";
import TextFormField from "../Form/FormFields/TextFormField";
@@ -13,32 +12,34 @@ import Form from "../Form/Form";
import { useTranslation } from "react-i18next";
import { navigate } from "raviger";
import dayjs from "dayjs";
+import useQuery from "../../Utils/request/useQuery";
+import routes from "../../Redux/api";
type DeathReport = {
- name: string;
- age: string;
- gender: string;
- address: string;
- phone_number: string;
- is_declared_positive: string;
- date_declared_positive: Date | "";
- test_type: string;
- date_of_test: Date | "";
- date_of_result: Date | "";
- srf_id: string;
- hospital_tested_in: string;
- hospital_died_in: string;
- date_of_admission: Date | "";
- date_of_death: Date | "";
- comorbidities: string;
- history_clinical_course: string;
- brought_dead: string;
- home_or_cfltc: string;
- is_vaccinated: string;
- kottayam_confirmation_sent: string;
- kottayam_sample_date: Date | "";
- cause_of_death: string;
- facility: string;
+ name?: string;
+ age?: string | number;
+ gender?: string;
+ address?: string;
+ phone_number?: string;
+ is_declared_positive?: string;
+ date_declared_positive: Date | string;
+ test_type?: string;
+ date_of_test?: Date | string;
+ date_of_result?: Date | string;
+ srf_id?: string;
+ hospital_tested_in?: string;
+ hospital_died_in?: string;
+ date_of_admission?: Date | string;
+ date_of_death?: Date | string;
+ comorbidities?: string;
+ history_clinical_course?: string;
+ brought_dead?: string;
+ home_or_cfltc?: string;
+ is_vaccinated?: string;
+ kottayam_confirmation_sent?: string;
+ kottayam_sample_date?: Date | string;
+ cause_of_death?: string;
+ facility?: string;
};
export default function PrintDeathReport(props: { id: string }) {
@@ -71,10 +72,8 @@ export default function PrintDeathReport(props: { id: string }) {
const [patientData, setPatientData] = useState (initialState);
const [patientName, setPatientName] = useState("");
- const [_isLoading, setIsLoading] = useState(true);
const [isPrintMode, setIsPrintMode] = useState(false);
const { id } = props;
- const dispatch: any = useDispatch();
const { t } = useTranslation();
const getPatientGender = (patientData: any) =>
@@ -96,58 +95,43 @@ export default function PrintDeathReport(props: { id: string }) {
}
};
- const fetchpatient = useCallback(
- async (status: statusType) => {
- setIsLoading(true);
- const patientRes = await dispatch(getPatient({ id }));
- if (!status.aborted) {
- if (patientRes && patientRes.data) {
- setPatientName(patientRes.data.name);
- const patientGender = getPatientGender(patientRes.data);
- const patientAddress = getPatientAddress(patientRes.data);
- const patientComorbidities = getPatientComorbidities(patientRes.data);
- const data = {
- ...patientRes.data,
- gender: patientGender,
- address: patientAddress,
- comorbidities: patientComorbidities,
- is_declared_positive: patientRes.data.is_declared_positive
- ? "Yes"
- : "No",
- is_vaccinated: patientData.is_vaccinated ? "Yes" : "No",
- cause_of_death:
- patientRes.data.last_consultation?.discharge_notes || "",
- hospital_died_in: patientRes.data.last_consultation.facility_name,
- date_declared_positive: patientRes.data.date_declared_positive
- ? dayjs(patientRes.data.date_declared_positive).toDate()
- : "",
- date_of_admission: patientRes.data.last_consultation.admission_date
- ? dayjs(patientRes.data.last_consultation.admission_date).toDate()
- : "",
- date_of_test: patientRes.data.date_of_test
- ? dayjs(patientRes.data.date_of_test).toDate()
- : "",
- date_of_result: patientRes.data.date_of_result
- ? dayjs(patientRes.data.date_of_result).toDate()
- : "",
- date_of_death: patientRes.data.last_consultation.death_datetime
- ? dayjs(patientRes.data.last_consultation.death_datetime).toDate()
- : "",
- };
- setPatientData(data);
- }
- setIsLoading(false);
+ const { loading: _isLoading } = useQuery(routes.getPatient, {
+ pathParams: { id },
+ onResponse(res) {
+ if (res.res?.ok && res) {
+ setPatientName(res.data?.name ?? "");
+ const patientGender = getPatientGender(res.data);
+ const patientAddress = getPatientAddress(res.data);
+ const patientComorbidities = getPatientComorbidities(res.data);
+ const data = {
+ ...res.data,
+ gender: patientGender,
+ address: patientAddress,
+ comorbidities: patientComorbidities,
+ is_declared_positive: res.data?.is_declared_positive ? "Yes" : "No",
+ is_vaccinated: res.data?.is_vaccinated ? "Yes" : "No",
+ cause_of_death: res.data?.last_consultation?.discharge_notes || "",
+ hospital_died_in: res.data?.last_consultation?.facility_name,
+ date_declared_positive: res.data?.date_declared_positive
+ ? dayjs(res.data?.date_declared_positive).toDate()
+ : "",
+ date_of_admission: res.data?.last_consultation?.admission_date
+ ? dayjs(res.data?.last_consultation?.admission_date).toDate()
+ : "",
+ date_of_test: res.data?.date_of_test
+ ? dayjs(res.data?.date_of_test).toDate()
+ : "",
+ date_of_result: res.data?.date_of_result
+ ? dayjs(res.data?.date_of_result).toDate()
+ : "",
+ date_of_death: res.data?.last_consultation?.death_datetime
+ ? dayjs(res.data?.last_consultation?.death_datetime).toDate()
+ : "",
+ };
+ setPatientData(data);
}
},
- [dispatch, id]
- );
-
- useAbortableEffect(
- (status: statusType) => {
- fetchpatient(status);
- },
- [dispatch, fetchpatient]
- );
+ });
const previewData = () => (
diff --git a/src/Components/ExternalResult/ExternalResultUpload.tsx b/src/Components/ExternalResult/ExternalResultUpload.tsx
index 5f39cb213a4..20a2cec3341 100644
--- a/src/Components/ExternalResult/ExternalResultUpload.tsx
+++ b/src/Components/ExternalResult/ExternalResultUpload.tsx
@@ -1,22 +1,22 @@
-import _ from "lodash";
+import _ from "lodash-es";
import { navigate } from "raviger";
import { lazy, useState } from "react";
import CSVReader from "react-csv-reader";
-import { useDispatch } from "react-redux";
import useConfig from "../../Common/hooks/useConfig";
-import { externalResultUploadCsv } from "../../Redux/actions";
import * as Notification from "../../Utils/Notifications.js";
const PageTitle = lazy(() => import("../Common/PageTitle"));
import { useTranslation } from "react-i18next";
import { Cancel, Submit } from "../Common/components/ButtonV2";
import useAppHistory from "../../Common/hooks/useAppHistory";
+import request from "../../Utils/request/request";
+import routes from "../../Redux/api";
+import { IExternalResult } from "./models";
export default function ExternalResultUpload() {
const { sample_format_external_result_import } = useConfig();
- const dispatch: any = useDispatch();
// for disabling save button once clicked
const [loading, setLoading] = useState(false);
- const [csvData, setCsvData] = useState(new Array ());
+ const [csvData, setCsvData] = useState(new Array());
const [errors, setErrors] = useState([]);
const handleForce = (data: any) => {
setCsvData(data);
@@ -32,26 +32,35 @@ export default function ExternalResultUpload() {
header.toLowerCase().replace(/\W/g, "_"),
};
- const handleSubmit = (e: any) => {
+ const handleSubmit = async (e: any) => {
e.preventDefault();
setLoading(true);
const valid = true;
- if (csvData.length !== 0) {
- const data = {
- sample_tests: csvData,
- };
+ if (csvData.length !== 0) {
if (valid) {
setErrors([]);
- dispatch(externalResultUploadCsv(data)).then((resp: any) => {
- if (resp && resp.status === 202) {
+
+ try {
+ const { res, data } = await request(routes.externalResultUploadCsv, {
+ body: {
+ sample_tests: csvData,
+ },
+ });
+
+ if (res && res.status === 202) {
setLoading(false);
navigate("/external_results");
} else {
- setErrors(resp.data.map((err: any) => Object.entries(err)));
+ if (data) {
+ setErrors(data.map((err: any) => Object.entries(err)));
+ }
setLoading(false);
}
- });
+ } catch (error) {
+ console.error("An error occurred:", error);
+ setLoading(false);
+ }
} else {
setLoading(false);
}
@@ -117,7 +126,7 @@ export default function ExternalResultUpload() {
{index + 1}
{data.name}
-
+
{errors && errors.length !== 0
? errors.map((error: any) => {
return (
diff --git a/src/Components/ExternalResult/ListFilter.tsx b/src/Components/ExternalResult/ListFilter.tsx
index 91b75e535d2..75358196ffd 100644
--- a/src/Components/ExternalResult/ListFilter.tsx
+++ b/src/Components/ExternalResult/ListFilter.tsx
@@ -1,6 +1,4 @@
-import { useEffect, useState } from "react";
-import { getAllLocalBodyByDistrict } from "../../Redux/actions";
-import { useDispatch } from "react-redux";
+import { useState } from "react";
import useMergeState from "../../Common/hooks/useMergeState";
import { navigate } from "raviger";
import { useTranslation } from "react-i18next";
@@ -11,6 +9,9 @@ import DateRangeFormField from "../Form/FormFields/DateRangeFormField";
import dayjs from "dayjs";
import { dateQueryString } from "../../Utils/utils";
import useAuthUser from "../../Common/hooks/useAuthUser";
+import useQuery from "../../Utils/request/useQuery";
+import routes from "../../Redux/api";
+import Loading from "../Common/Loading";
const clearFilterState = {
created_date_before: "",
@@ -29,10 +30,8 @@ export default function ListFilter(props: any) {
const { filter, onChange, closeFilter, dataList } = props;
const [wardList, setWardList] = useState ([]);
const [lsgList, setLsgList] = useState([]);
-
const [wards, setWards] = useState([]);
const [selectedLsgs, setSelectedLsgs] = useState([]);
- const dispatch: any = useDispatch();
const authUser = useAuthUser();
const [filterState, setFilterState] = useMergeState({
created_date_before: filter.created_date_before || null,
@@ -45,6 +44,57 @@ export default function ListFilter(props: any) {
});
const { t } = useTranslation();
+ const { loading } = useQuery(routes.getAllLocalBodyByDistrict, {
+ pathParams: { id: String(authUser.district) },
+ onResponse: ({ res, data }) => {
+ if (res && data) {
+ let allWards: any[] = [];
+ let allLsgs: any[] = [];
+ if (res && data) {
+ data.forEach((local: any) => {
+ allLsgs = [...allLsgs, { id: local.id, name: local.name }];
+ if (local.wards) {
+ local.wards.forEach((ward: any) => {
+ allWards = [
+ ...allWards,
+ {
+ id: ward.id,
+ name: ward.number + ": " + ward.name,
+ panchayath: local.name,
+ number: ward.number,
+ local_body_id: local.id,
+ },
+ ];
+ });
+ }
+ });
+ }
+
+ sortByName(allWards);
+ sortByName(allLsgs);
+ setWardList(allWards || []);
+ setLsgList(allLsgs || []);
+ const filteredWard = filter?.wards?.split(",").map(Number);
+ const selectedWards: any =
+ filteredWard && allWards
+ ? allWards.filter(({ id }: { id: number }) => {
+ return filteredWard.includes(id);
+ })
+ : [];
+ setWards(selectedWards);
+
+ const filteredLsgs = filter?.local_bodies?.split(",").map(Number);
+ const selectedLsgs: any =
+ filteredLsgs && allLsgs
+ ? allLsgs.filter(({ id }: { id: number }) => {
+ return filteredLsgs.includes(id);
+ })
+ : [];
+ setSelectedLsgs(selectedLsgs);
+ }
+ },
+ });
+
const handleDateRangeChange = (
startDateId: string,
endDateId: string,
@@ -118,59 +168,10 @@ export default function ListFilter(props: any) {
});
};
- useEffect(() => {
- async function getWardList() {
- const id = authUser.district;
- const res = await dispatch(getAllLocalBodyByDistrict({ id }));
- let allWards: any[] = [];
- let allLsgs: any[] = [];
- res?.data?.forEach((local: any) => {
- allLsgs = [...allLsgs, { id: local.id, name: local.name }];
- if (local.wards) {
- local.wards.forEach((ward: any) => {
- allWards = [
- ...allWards,
- {
- id: ward.id,
- name: ward.number + ": " + ward.name,
- panchayath: local.name,
- number: ward.number,
- local_body_id: local.id,
- },
- ];
- });
- }
- });
- sortByName(allWards);
- sortByName(allLsgs);
- setWardList(allWards || []);
- setLsgList(allLsgs || []);
- const filteredWard = filter?.wards?.split(",").map(Number);
- const selectedWards: any =
- filteredWard && allWards
- ? allWards.filter(({ id }: { id: number }) => {
- return filteredWard.includes(id);
- })
- : [];
- setWards(selectedWards);
-
- const filteredLsgs = filter?.local_bodies?.split(",").map(Number);
- const selectedLsgs: any =
- filteredLsgs && allLsgs
- ? allLsgs.filter(({ id }: { id: number }) => {
- return filteredLsgs.includes(id);
- })
- : [];
- setSelectedLsgs(selectedLsgs);
- }
- getWardList();
- }, []);
-
const filterWards = () => {
const selectedLsgIds: any = selectedLsgs.map((e) => {
return e.id;
});
-
const selectedwards: any =
selectedLsgIds.length === 0
? wardList
@@ -183,13 +184,15 @@ export default function ListFilter(props: any) {
const handleChange = (event: any) => {
const { name, value } = event.target;
-
const filterData: any = { ...filterState };
filterData[name] = value;
-
setFilterState(filterData);
};
+ if (loading) {
+ ;
+ }
+
return (
import("../Common/Loading"));
export default function ResultItem(props: any) {
- const dispatch: any = useDispatch();
- const initialData: any = {};
- const [data, setData] = useState(initialData);
- const [isLoading, setIsLoading] = useState(true);
const [showDeleteAlert, setShowDeleteAlert] = useState(false);
const { t } = useTranslation();
- const fetchData = useCallback(
- async (status: statusType) => {
- setIsLoading(true);
- const res = await dispatch(externalResult({ id: props.id }));
- if (!status.aborted) {
- if (res && res.data) {
- setData(res.data);
- }
- setIsLoading(false);
- }
- },
- [props.id, dispatch]
- );
+ const { data: resultItemData, loading } = useQuery(routes.externalResult, {
+ pathParams: { id: props.id },
+ });
const handleDelete = async () => {
- const res = await dispatch(deleteExternalResult(props.id));
- if (res?.status === 204) {
- Notification.Success({
- msg: t("record_has_been_deleted_successfully"),
+ if (showDeleteAlert) {
+ const { res, data } = await request(routes.deleteExternalResult, {
+ pathParams: { id: props.id },
});
- } else {
- Notification.Error({
- msg:
- t("error_while_deleting_record") + ": " + (res?.data?.detail || ""),
- });
- }
- setShowDeleteAlert(false);
- navigate("/external_results");
+ if (res?.status === 204) {
+ Notification.Success({
+ msg: t("record_has_been_deleted_successfully"),
+ });
+ } else {
+ Notification.Error({
+ msg: t("error_while_deleting_record") + ": " + (data?.detail || ""),
+ });
+ }
+ setShowDeleteAlert(false);
+ navigate("/external_results");
+ }
};
- useAbortableEffect(
- (status: statusType) => {
- fetchData(status);
- },
- [fetchData]
- );
-
- if (isLoading) {
+ if (loading || !resultItemData) {
return ;
}
@@ -69,14 +50,18 @@ export default function ResultItem(props: any) {
variant="danger"
action={t("delete")}
show={showDeleteAlert}
- onConfirm={() => handleDelete()}
+ onConfirm={() => {
+ handleDelete();
+ }}
onClose={() => setShowDeleteAlert(false)}
/>
diff --git a/src/Components/ExternalResult/ResultList.tsx b/src/Components/ExternalResult/ResultList.tsx
index 74fbf8430b0..d148b26e3f5 100644
--- a/src/Components/ExternalResult/ResultList.tsx
+++ b/src/Components/ExternalResult/ResultList.tsx
@@ -1,12 +1,10 @@
import ButtonV2 from "../Common/components/ButtonV2";
import { navigate } from "raviger";
-import { lazy, useEffect, useState } from "react";
-import { useDispatch } from "react-redux";
+import { lazy, useState } from "react";
import { externalResultList } from "../../Redux/actions";
import ListFilter from "./ListFilter";
import FacilitiesSelectDialogue from "./FacilitiesSelectDialogue";
import { FacilityModel } from "../Facility/models";
-import { parsePhoneNumber } from "../../Utils/utils";
import SearchInput from "../Form/SearchInput";
import useFilters from "../../Common/hooks/useFilters";
import CareIcon from "../../CAREUI/icons/CareIcon";
@@ -15,14 +13,12 @@ import PhoneNumberFormField from "../Form/FormFields/PhoneNumberFormField";
import CountBlock from "../../CAREUI/display/Count";
import { AdvancedFilterButton } from "../../CAREUI/interactive/FiltersSlideover";
import Page from "../Common/components/Page";
-
+import routes from "../../Redux/api";
+import useQuery from "../../Utils/request/useQuery";
+import { parsePhoneNumber } from "../../Utils/utils";
const Loading = lazy(() => import("../Common/Loading"));
export default function ResultList() {
- const dispatch: any = useDispatch();
- const [data, setData] = useState([]);
- const [isLoading, setIsLoading] = useState(false);
- const [totalCount, setTotalCount] = useState(0);
const {
qParams,
updateQuery,
@@ -57,61 +53,31 @@ export default function ResultList() {
setPhoneNumberError("Enter a valid number");
};
+ const params = {
+ page: qParams.page || 1,
+ name: qParams.name || "",
+ mobile_number: qParams.mobile_number
+ ? parsePhoneNumber(qParams.mobile_number) ?? ""
+ : "",
+ wards: qParams.wards || undefined,
+ local_bodies: qParams.local_bodies || undefined,
+ created_date_before: qParams.created_date_before || undefined,
+ created_date_after: qParams.created_date_after || undefined,
+ result_date_before: qParams.result_date_before || undefined,
+ result_date_after: qParams.result_date_after || undefined,
+ sample_collection_date_after:
+ qParams.sample_collection_date_after || undefined,
+ sample_collection_date_before:
+ qParams.sample_collection_date_before || undefined,
+ offset: (qParams.page ? qParams.page - 1 : 0) * resultsPerPage,
+ srf_id: qParams.srf_id || undefined,
+ };
- let manageResults: any = null;
- useEffect(() => {
- setIsLoading(true);
- const params = {
- page: qParams.page || 1,
- name: qParams.name || "",
- mobile_number: qParams.mobile_number
- ? parsePhoneNumber(qParams.mobile_number) ?? ""
- : "",
- wards: qParams.wards || undefined,
- local_bodies: qParams.local_bodies || undefined,
- created_date_before: qParams.created_date_before || undefined,
- created_date_after: qParams.created_date_after || undefined,
- result_date_before: qParams.result_date_before || undefined,
- result_date_after: qParams.result_date_after || undefined,
- sample_collection_date_after:
- qParams.sample_collection_date_after || undefined,
- sample_collection_date_before:
- qParams.sample_collection_date_before || undefined,
- offset: (qParams.page ? qParams.page - 1 : 0) * resultsPerPage,
- srf_id: qParams.srf_id || undefined,
- };
-
- dispatch(externalResultList(params, "externalResultList"))
- .then((res: any) => {
- if (res && res.data) {
- setData(res.data.results);
- setTotalCount(res.data.count);
- setIsLoading(false);
- }
- })
- .catch(() => {
- setIsLoading(false);
- });
+ const { data, loading } = useQuery(routes.externalResultList, {
+ query: params,
+ });
- if (!params.mobile_number) {
- setPhoneNum("+91");
- }
- }, [
- dispatch,
- qParams.name,
- qParams.page,
- qParams.mobile_number,
- qParams.wards,
- qParams.created_date_before,
- qParams.created_date_after,
- qParams.result_date_before,
- qParams.result_date_after,
- qParams.sample_collection_date_after,
- qParams.sample_collection_date_before,
- qParams.local_bodies,
- qParams.srf_id,
- dataList,
- ]);
+ let manageResults: any = null;
const removeLSGFilter = (paramKey: any, id: any) => {
const updatedLsgList = dataList.lsgList.filter((x: any) => x.id !== id);
@@ -158,8 +124,8 @@ export default function ResultList() {
};
let resultList: any[] = [];
- if (data && data.length) {
- resultList = data.map((result: any) => {
+ if (data?.results.length) {
+ resultList = data.results.map((result: any) => {
const resultUrl = `/external_results/${result.id}`;
return (
@@ -173,7 +139,7 @@ export default function ResultList() {
className="group inline-flex space-x-2 text-sm leading-5"
>
- {result.name} - {result.age} {result.age_in}
+ {`${result.name}`} - {result.age} {result.age_in}
@@ -214,7 +180,7 @@ export default function ResultList() {
});
}
- if (isLoading || !data) {
+ if (loading) {
manageResults = (
@@ -222,9 +188,9 @@ export default function ResultList() {
|
);
- } else if (data && data.length) {
+ } else if (data?.results.length) {
manageResults = <>{resultList}>;
- } else if (data && data.length === 0) {
+ } else if (data?.results.length === 0) {
manageResults = (
@@ -286,8 +252,8 @@ export default function ResultList() {
@@ -358,7 +324,7 @@ export default function ResultList() {
|
-
+
import("../Common/Loading"));
@@ -63,79 +57,76 @@ export default function UpdateResult(props: any) {
const { id } = props;
const { goBack } = useAppHistory();
- const dispatchAction: any = useDispatch();
const [state, dispatch] = useReducer(FormReducer, initialState);
- const [isLoading, setIsLoading] = useState(false);
+ const [isLoading, setIsLoading] = useState(true);
const [isLocalbodyLoading, setIsLocalbodyLoading] = useState(false);
const [isWardLoading, setIsWardLoading] = useState(false);
const [localBody, setLocalBody] = useState(initialLocalbodies);
const [ward, setWard] = useState(initialLocalbodies);
- const fetchData = useCallback(
- async (status: statusType) => {
- setIsLoading(true);
- const res = await dispatchAction(externalResult({ id: id }));
- if (!status.aborted) {
- if (res && res.data) {
- const form = { ...state.form };
- form["name"] = res.data.name;
- form["age"] = res.data.age;
- form["age_in"] = res.data.age_in;
- form["srf_id"] = res.data.srf_id;
- form["address"] = res.data.address;
- form["district"] = res.data.district_object.name;
- form["local_body"] = String(res.data.local_body);
- form["ward"] = String(res.data.ward);
- form["patient_created"] = String(res.data.patient_created);
+ const { loading } = useQuery(routes.externalResult, {
+ pathParams: { id },
+ onResponse: async ({ res, data }) => {
+ if (res && data) {
+ const form = { ...state.form };
+ form["name"] = data.name;
+ form["age"] = data.age;
+ form["age_in"] = data.age_in;
+ form["srf_id"] = data.srf_id;
+ form["address"] = data.address;
+ form["district"] = data.district_object.name;
+ form["local_body"] = String(data.local_body);
+ form["ward"] = String(data.ward);
+ form["patient_created"] = String(data.patient_created);
- dispatch({ type: "set_form", form });
+ dispatch({ type: "set_form", form });
- Promise.all([
- fetchLocalBody(res.data.district),
- fetchWards(res.data.local_body),
- ]);
- }
+ Promise.all([
+ fetchLocalBody(data.district),
+ fetchWards(data.local_body),
+ ]);
setIsLoading(false);
}
},
- [props.id, dispatchAction]
- );
+ });
- const fetchLocalBody = useCallback(
- async (id: string) => {
- if (Number(id) > 0) {
- setIsLocalbodyLoading(true);
- const localBodyList = await dispatchAction(
- getLocalbodyByDistrict({ id })
- );
+ const fetchLocalBody = async (id: number) => {
+ if (Number(id) > 0) {
+ setIsLocalbodyLoading(true);
+ const { res, data } = await request(routes.getLocalbodyByDistrict, {
+ pathParams: { id: String(id) },
+ });
+ if (res && data) {
setIsLocalbodyLoading(false);
- setLocalBody([...initialLocalbodies, ...localBodyList.data]);
- } else {
- setLocalBody(initialLocalbodies);
+ const transformedData = {
+ id: data.id,
+ name: data.name,
+ number: data.state,
+ };
+ initialLocalbodies.push(transformedData);
+ setLocalBody([...initialLocalbodies]);
}
- },
- [dispatchAction]
- );
+ } else {
+ setLocalBody(initialLocalbodies);
+ }
+ };
const fetchWards = useCallback(
- async (id: string) => {
+ async (id: number) => {
if (Number(id) > 0) {
setIsWardLoading(true);
- const wardList = await dispatchAction(getWardByLocalBody({ id }));
+ const { res, data } = await request(routes.getWardByLocalBody, {
+ pathParams: { id: String(id) },
+ });
+ if (res && data) {
+ setWard([...initialWard, ...data.results]);
+ }
setIsWardLoading(false);
- setWard([...initialWard, ...wardList.data.results]);
} else {
setWard(initialLocalbodies);
}
},
- [dispatchAction]
- );
-
- useAbortableEffect(
- (status: statusType) => {
- fetchData(status);
- },
- [fetchData]
+ [props.id]
);
const validateForm = () => {
@@ -195,15 +186,20 @@ export default function UpdateResult(props: any) {
const validForm = validateForm();
if (validForm) {
setIsLoading(true);
- const data = {
+ const rdata = {
address: state.form.address ? state.form.address : undefined,
local_body: state.form.local_body ? state.form.local_body : undefined,
ward: state.form.ward,
patient_created: state.form.patient_created === "true",
};
- const res = await dispatchAction(partialUpdateExternalResult(id, data));
+
+ const { res, data } = await request(routes.partialUpdateExternalResult, {
+ pathParams: { id },
+ body: rdata,
+ });
+
setIsLoading(false);
- if (res && res.data) {
+ if (res && data) {
dispatch({ type: "set_form", form: initForm });
Notification.Success({
msg: "External Result updated successfully",
@@ -213,7 +209,7 @@ export default function UpdateResult(props: any) {
}
};
- if (isLoading) {
+ if (isLoading || loading) {
return ;
}
@@ -262,10 +258,7 @@ export default function UpdateResult(props: any) {
options={localBody}
optionLabel={(localBody) => localBody.name}
optionValue={(localBody) => localBody.id}
- onChange={(e) => [
- handleChange(e),
- fetchWards(String(e.value)),
- ]}
+ onChange={(e) => [handleChange(e), fetchWards(e.value)]}
error={state.errors.local_body}
/>
)}
diff --git a/src/Components/ExternalResult/models.ts b/src/Components/ExternalResult/models.ts
new file mode 100644
index 00000000000..8ccaba04d05
--- /dev/null
+++ b/src/Components/ExternalResult/models.ts
@@ -0,0 +1,72 @@
+export interface IExternalResultUploadCsv {
+ sample_tests: any[];
+}
+
+export interface IExternalResult {
+ id: number;
+ name: string;
+ age: number;
+ age_in: string;
+ test_type: string;
+ result: string;
+ result_date: string;
+ patient_created: boolean;
+ gender: string;
+ source: string;
+ is_repeat: boolean;
+ mobile_number: string;
+ patient_status: string;
+ sample_type: string;
+ sample_collection_date: string;
+ patient_category: string;
+ srf_id: string;
+ district_object: {
+ id: number;
+ name: string;
+ state: number;
+ };
+ district: number;
+ ward: number;
+ local_body: number;
+ address: string;
+ ward_object: {
+ id: number;
+ number: number;
+ name: string;
+ };
+ local_body_object: {
+ id: number;
+ name: string;
+ };
+}
+
+export interface ILocalBodies {
+ id: number;
+ name: string;
+ state: number;
+ number: number;
+ body_type: number;
+ localbody_code: string;
+ district: number;
+}
+
+export interface IDeleteExternalResult {
+ detail: string;
+}
+
+export interface IPartialUpdateExternalResult {
+ address: string;
+ ward: number;
+ local_body: number;
+ patient_created: boolean;
+}
+
+export interface ILocalBodyByDistrict {
+ id: number;
+ name: string;
+ state: number;
+}
+
+export interface IExternalResultCsv {
+ sample_tests: Partial[];
+}
diff --git a/src/Components/Facility/AddLocationForm.tsx b/src/Components/Facility/AddLocationForm.tsx
index f0dd7893aca..e71b68cc95c 100644
--- a/src/Components/Facility/AddLocationForm.tsx
+++ b/src/Components/Facility/AddLocationForm.tsx
@@ -25,12 +25,14 @@ export const AddLocationForm = (props: LocationFormProps) => {
const dispatchAction: any = useDispatch();
const [isLoading, setIsLoading] = useState(false);
const [name, setName] = useState("");
+ const [middlewareAddress, setMiddlewareAddress] = useState("");
const [description, setDescription] = useState("");
const [facilityName, setFacilityName] = useState("");
const [locationName, setLocationName] = useState("");
const [errors, setErrors] = useState({
name: "",
description: "",
+ middlewareAddress: "",
});
const headerText = !locationId ? "Add Location" : "Update Location";
const buttonText = !locationId ? "Add Location" : "Update Location";
@@ -51,6 +53,7 @@ export const AddLocationForm = (props: LocationFormProps) => {
setName(res?.data?.name || "");
setLocationName(res?.data?.name || "");
setDescription(res?.data?.description || "");
+ setMiddlewareAddress(res?.data?.middleware_address || "");
}
setIsLoading(false);
}
@@ -62,6 +65,7 @@ export const AddLocationForm = (props: LocationFormProps) => {
const error = {
name: "",
description: "",
+ middlewareAddress: "",
};
if (name.trim().length === 0) {
@@ -69,6 +73,16 @@ export const AddLocationForm = (props: LocationFormProps) => {
formValid = false;
}
+ if (
+ middlewareAddress &&
+ middlewareAddress.match(
+ /^(?!https?:\/\/)[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)*\.[a-zA-Z]{2,}$/
+ ) === null
+ ) {
+ error.middlewareAddress = "Invalid Middleware Address";
+ formValid = false;
+ }
+
setErrors(error);
return formValid;
};
@@ -83,6 +97,7 @@ export const AddLocationForm = (props: LocationFormProps) => {
const data = {
name,
description,
+ middleware_address: middlewareAddress,
};
const res = await dispatchAction(
@@ -157,8 +172,18 @@ export const AddLocationForm = (props: LocationFormProps) => {
error={errors.description}
/>
+
+ setMiddlewareAddress(e.value)}
+ error={errors.middlewareAddress}
+ />
+
-
+
navigate(`/facility/${facilityId}/location`, {
diff --git a/src/Components/Facility/AssetCreate.tsx b/src/Components/Facility/AssetCreate.tsx
index 156d738857a..84fc09188d0 100644
--- a/src/Components/Facility/AssetCreate.tsx
+++ b/src/Components/Facility/AssetCreate.tsx
@@ -37,7 +37,8 @@ import useVisibility from "../../Utils/useVisibility";
import { validateEmailAddress } from "../../Common/validation";
import { dateQueryString, parsePhoneNumber } from "../../Utils/utils.js";
import dayjs from "../../Utils/dayjs";
-import DateInputV2 from "../Common/DateInputV2.js";
+import DateFormField from "../Form/FormFields/DateFormField.js";
+import { t } from "i18next";
const Loading = lazy(() => import("../Common/Loading"));
@@ -305,7 +306,7 @@ const AssetCreate = (props: AssetProps) => {
setLocation("");
setAssetType(assetTypeInitial);
setAssetClass(assetClassInitial);
- setIsWorking("");
+ setIsWorking(undefined);
setNotWorkingReason("");
setSerialNumber("");
setVendorName("");
@@ -404,7 +405,7 @@ const AssetCreate = (props: AssetProps) => {
if (locations.length === 0) {
return (
{
- You need at least a location to create an assest.
+ {t("you_need_at_least_a_location_to_create_an_assest")}
@@ -440,7 +441,8 @@ const AssetCreate = (props: AssetProps) => {
onClick={() => setIsScannerActive(false)}
className="btn btn-default mb-2"
>
- Close Scanner
+
+ {t("close_scanner")}
{
}
style={{ width: "100%" }}
/>
- Scan Asset QR!
+
+ {t("scan_asset_qr")}
+
);
@@ -479,7 +483,7 @@ const AssetCreate = (props: AssetProps) => {
return (
{
>
setName(value)}
@@ -544,7 +548,7 @@ const AssetCreate = (props: AssetProps) => {
{/* Location */}
- Asset Location
+ {t("asset_location")}
{
data-testid="asset-type-input"
>
{
{
>
setDescription(value)}
error={state.errors.description}
@@ -664,7 +668,7 @@ const AssetCreate = (props: AssetProps) => {
className="col-span-6"
required
name="is_working"
- label="Working Status"
+ label={t("working_status")}
options={["true", "false"]}
optionLabel={(option) => {
return (
@@ -692,8 +696,8 @@ const AssetCreate = (props: AssetProps) => {
>
setNotWorkingReason(e.value)}
error={state.errors.not_working_reason}
@@ -717,7 +721,7 @@ const AssetCreate = (props: AssetProps) => {
id="qr_code_id"
name="qr_code_id"
placeholder=""
- label="Asset QR ID"
+ label={t("asset_qr_id")}
value={qrCodeId}
onChange={(e) => setQrCodeId(e.value)}
error={state.errors.qr_code_id}
@@ -743,9 +747,9 @@ const AssetCreate = (props: AssetProps) => {
setManufacturer(e.value)}
error={state.errors.manufacturer}
/>
@@ -760,7 +764,7 @@ const AssetCreate = (props: AssetProps) => {
{
const value = dayjs(event.value);
@@ -788,8 +792,8 @@ const AssetCreate = (props: AssetProps) => {
setSupportName(e.value)}
error={state.errors.support_name}
@@ -804,7 +808,7 @@ const AssetCreate = (props: AssetProps) => {
>
setSupportPhone(e.value)}
@@ -822,8 +826,8 @@ const AssetCreate = (props: AssetProps) => {
setSupportEmail(e.value)}
error={state.errors.support_email}
@@ -841,9 +845,9 @@ const AssetCreate = (props: AssetProps) => {
setVendorName(e.value)}
error={state.errors.vendor_name}
/>
@@ -858,7 +862,7 @@ const AssetCreate = (props: AssetProps) => {
setSerialNumber(e.value)}
error={state.errors.serial_number}
@@ -874,25 +878,26 @@ const AssetCreate = (props: AssetProps) => {
ref={fieldRef["last_serviced_on"]}
data-testid="asset-last-serviced-on-input"
>
- Last Serviced On
- {
if (
- dayjs(date).format("YYYY-MM-DD") >
+ dayjs(date.value).format("YYYY-MM-DD") >
new Date().toLocaleDateString("en-ca")
) {
Notification.Error({
msg: "Last Serviced date can't be in future",
});
} else {
- setLastServicedOn(dayjs(date).format("YYYY-MM-DD"));
+ setLastServicedOn(
+ dayjs(date.value).format("YYYY-MM-DD")
+ );
}
}}
- max={new Date()}
/>
{
>
setNotes(e.value)}
error={state.errors.notes}
@@ -928,13 +935,13 @@ const AssetCreate = (props: AssetProps) => {
/>
handleSubmit(e, false)}
- label={assetId ? "Update" : "Create Asset"}
+ label={assetId ? t("update") : t("create_asset")}
/>
{!assetId && (
handleSubmit(e, true)}
- label="Create & Add More"
+ label={t("create_add_more")}
/>
)}
diff --git a/src/Components/Facility/ConsultationCard.tsx b/src/Components/Facility/ConsultationCard.tsx
index f6b4484b477..4859b981e8f 100644
--- a/src/Components/Facility/ConsultationCard.tsx
+++ b/src/Components/Facility/ConsultationCard.tsx
@@ -131,6 +131,7 @@ export const ConsultationCard = (props: ConsultationProps) => {
navigate(
diff --git a/src/Components/Facility/ConsultationDetails/ConsultationMedicinesTab.tsx b/src/Components/Facility/ConsultationDetails/ConsultationMedicinesTab.tsx
index 19810102833..0643765339f 100644
--- a/src/Components/Facility/ConsultationDetails/ConsultationMedicinesTab.tsx
+++ b/src/Components/Facility/ConsultationDetails/ConsultationMedicinesTab.tsx
@@ -1,9 +1,12 @@
import { ConsultationTabProps } from "./index";
import PrescriptionAdministrationsTable from "../../Medicine/PrescriptionAdministrationsTable";
+import PageTitle from "../../Common/PageHeadTitle";
export const ConsultationMedicinesTab = (props: ConsultationTabProps) => {
return (
+ {/* eslint-disable-next-line i18next/no-literal-string */}
+
import("../../Common/PageTitle"));
-export const ConsultationNeutritionTab = (props: ConsultationTabProps) => {
+export const ConsultationNutritionTab = (props: ConsultationTabProps) => {
return (
diff --git a/src/Components/Facility/ConsultationDetails/index.tsx b/src/Components/Facility/ConsultationDetails/index.tsx
index 403f1752704..cedb1a843d3 100644
--- a/src/Components/Facility/ConsultationDetails/index.tsx
+++ b/src/Components/Facility/ConsultationDetails/index.tsx
@@ -41,6 +41,7 @@ import { ConsultationVentilatorTab } from "./ConsultationVentilatorTab";
import { ConsultationPressureSoreTab } from "./ConsultationPressureSoreTab";
import { ConsultationDialysisTab } from "./ConsultationDialysisTab";
import { ConsultationNeurologicalMonitoringTab } from "./ConsultationNeurologicalMonitoringTab";
+import { ConsultationNutritionTab } from "./ConsultationNutritionTab";
const Loading = lazy(() => import("../../Common/Loading"));
const PageTitle = lazy(() => import("../../Common/PageTitle"));
@@ -65,7 +66,7 @@ const TABS = {
NURSING: ConsultationNursingTab,
NEUROLOGICAL_MONITORING: ConsultationNeurologicalMonitoringTab,
VENTILATOR: ConsultationVentilatorTab,
- NUTRITION: ConsultationNursingTab,
+ NUTRITION: ConsultationNutritionTab,
PRESSURE_SORE: ConsultationPressureSoreTab,
DIALYSIS: ConsultationDialysisTab,
};
@@ -308,6 +309,7 @@ export const ConsultationDetails = (props: any) => {
) : (
navigate(
`/facility/${patientData.facility}/patient/${patientData.id}/shift/new`
@@ -351,6 +353,7 @@ export const ConsultationDetails = (props: any) => {
Patient Details
@@ -449,6 +452,7 @@ export const ConsultationDetails = (props: any) => {
setOpenDischargeDialog(true)}
disabled={!!consultationData.discharge_date}
>
@@ -495,14 +499,20 @@ export const ConsultationDetails = (props: any) => {
-
)}
diff --git a/src/Components/Facility/Consultations/LiveFeed.tsx b/src/Components/Facility/Consultations/LiveFeed.tsx
index c6ba749b471..aba473e958d 100644
--- a/src/Components/Facility/Consultations/LiveFeed.tsx
+++ b/src/Components/Facility/Consultations/LiveFeed.tsx
@@ -36,6 +36,7 @@ const LiveFeed = (props: any) => {
const [streamStatus, setStreamStatus] = useState (
StreamStatus.Offline
);
+ const [videoStartTime, setVideoStartTime] = useState(null);
const [bed, setBed] = useState({});
const [preset, setNewPreset] = useState("");
const [loading, setLoading] = useState();
@@ -100,6 +101,16 @@ const LiveFeed = (props: any) => {
},
});
+ const calculateVideoLiveDelay = () => {
+ const video = liveFeedPlayerRef.current as HTMLVideoElement;
+ if (!video || !videoStartTime) return 0;
+
+ const timeDifference =
+ (new Date().getTime() - videoStartTime.getTime()) / 1000;
+
+ return timeDifference - video.currentTime;
+ };
+
const getBedPresets = async (id: any) => {
const bedAssets = await dispatch(
listAssetBeds({
@@ -223,6 +234,7 @@ const LiveFeed = (props: any) => {
},
reset: () => {
setStreamStatus(StreamStatus.Loading);
+ setVideoStartTime(null);
startStream({
onSuccess: () => setStreamStatus(StreamStatus.Playing),
onError: () => setStreamStatus(StreamStatus.Offline),
@@ -344,8 +356,25 @@ const LiveFeed = (props: any) => {
playsInline
className="z-10 h-full w-full"
ref={liveFeedPlayerRef}
+ onPlay={() => {
+ setVideoStartTime(() => new Date());
+ }}
+ onWaiting={() => {
+ const delay = calculateVideoLiveDelay();
+ if (delay > 5) {
+ setStreamStatus(StreamStatus.Loading);
+ }
+ }}
>
+ {streamStatus === StreamStatus.Playing &&
+ calculateVideoLiveDelay() > 3 && (
+
+
+ Slow Network Detected
+
+ )}
+
{loading && (
diff --git a/src/Components/Facility/Consultations/NeurologicalTables.tsx b/src/Components/Facility/Consultations/NeurologicalTables.tsx
index 89e9d598604..36fae175480 100644
--- a/src/Components/Facility/Consultations/NeurologicalTables.tsx
+++ b/src/Components/Facility/Consultations/NeurologicalTables.tsx
@@ -28,10 +28,7 @@ const DataTable = (props: any) => {
Right
-
+
{data.map((x: any, i: any) => {
return (
{
const LOC_OPTIONS = [
{ id: 0, value: "Unknown" },
{ id: 5, value: "Alert" },
- { id: 10, value: "Drowsy" },
- { id: 15, value: "Stuporous" },
- { id: 20, value: "Comatose" },
- { id: 25, value: "Cannot Be Assessed" },
+ { id: 10, value: "Responds to Voice" },
+ { id: 15, value: "Responds to Pain" },
+ { id: 20, value: "Unresponsive" },
+ { id: 25, value: "Agitated or Confused" },
+ { id: 30, value: "Onset of Agitation and Confusion" },
];
const REACTION_OPTIONS = [
@@ -297,16 +295,13 @@ export const NeurologicalTable = (props: any) => {
Level Of Consciousness
-
+
{locData.map((x: any, i: any) => (
-
+
{x.date}
@@ -376,10 +371,7 @@ export const NeurologicalTable = (props: any) => {
Total
-
+
{glasgowData.map((x: any, i: any) => {
return (
{
const {
@@ -197,7 +225,8 @@ export const LinePlot = (props: any) => {
}
return (
- {
@@ -81,5 +108,5 @@ export const StackedLinePlot = (props: any) => {
},
series: series,
};
- return ;
+ return ;
};
diff --git a/src/Components/Facility/FacilityCard.tsx b/src/Components/Facility/FacilityCard.tsx
index 9fc80f7d211..2689193b4c2 100644
--- a/src/Components/Facility/FacilityCard.tsx
+++ b/src/Components/Facility/FacilityCard.tsx
@@ -47,11 +47,11 @@ export const FacilityCard = (props: { facility: any; userType: any }) => {
return (
-
+
{(facility.read_cover_image_url && (
{
{(facility.read_cover_image_url && (
{
)}
-
+
{facility.kasp_empanelled && (
@@ -87,7 +87,7 @@ export const FacilityCard = (props: { facility: any; userType: any }) => {
{kasp_string}
)}
-
-
+
-
+
0.85
@@ -219,7 +219,7 @@ export const FacilityCard = (props: { facility: any; userType: any }) => {
-
+
{userType !== "Staff" ? (
import("../Common/Loading"));
const initForm = {
@@ -18,6 +19,7 @@ const initForm = {
ward: 0,
middleware_address: "",
};
+
const initialState = {
form: { ...initForm },
errors: {},
@@ -42,42 +44,33 @@ const FormReducer = (state = initialState, action: any) => {
}
};
-export const UpdateFacilityMiddleware = (props: any) => {
+interface IProps {
+ facilityId: string;
+}
+
+export const FacilityConfigure = (props: IProps) => {
const [state, dispatch] = useReducer(FormReducer, initialState);
const { facilityId } = props;
const [isLoading, setIsLoading] = useState(false);
- const { res, data, refetch } = useQuery(routes.getPermittedFacility, {
- pathParams: {
- id: facilityId,
- },
- });
-
- useEffect(() => {
- if (facilityId) {
- setIsLoading(true);
- if (data) {
+ const { loading } = useQuery(routes.getPermittedFacility, {
+ pathParams: { id: facilityId },
+ onResponse: (res) => {
+ if (res.data) {
const formData = {
- name: data.name,
- state: data.state,
- district: data.district,
- local_body: data.local_body,
- ward: data.ward,
- middleware_address: data.middleware_address,
+ name: res.data.name,
+ state: res.data.state,
+ district: res.data.district,
+ local_body: res.data.local_body,
+ ward: res.data.ward,
+ middleware_address: res.data.middleware_address,
};
dispatch({ type: "set_form", form: formData });
- } else {
- navigate(`/facility/${facilityId}`);
}
- setIsLoading(false);
- }
- }, [facilityId, res, data]);
-
- useEffect(() => {
- refetch();
- }, [dispatch, refetch]);
+ },
+ });
- const handleSubmit = async (e: any) => {
+ const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
setIsLoading(true);
if (!state.form.middleware_address) {
@@ -102,44 +95,39 @@ export const UpdateFacilityMiddleware = (props: any) => {
setIsLoading(false);
return;
}
- const data: any = {
+
+ const data = {
...state.form,
middleware_address: state.form.middleware_address,
};
- // data for request body is not same - keep any
- const { res, data: updateData } = await request(
- routes.partialUpdateFacility,
- {
- body: data,
- pathParams: {
- id: facilityId,
- },
- }
- );
+ const { res, error } = await request(routes.partialUpdateFacility, {
+ pathParams: { id: facilityId },
+ body: data,
+ });
+
setIsLoading(false);
- if (res && updateData) {
+ if (res?.ok) {
Notification.Success({
msg: "Facility updated successfully",
});
navigate(`/facility/${facilityId}`);
} else {
- if (updateData)
- Notification.Error({
- msg: "Something went wrong: ", // No detail property in response
- });
+ Notification.Error({
+ msg: error?.detail ?? "Something went wrong",
+ });
}
setIsLoading(false);
};
- const handleChange = (e: any) => {
+ const handleChange = (e: FieldChangeEvent) => {
dispatch({
type: "set_form",
form: { ...state.form, [e.name]: e.value },
});
};
- if (isLoading) {
+ if (isLoading || loading) {
return ;
}
@@ -149,22 +137,23 @@ export const UpdateFacilityMiddleware = (props: any) => {
crumbsReplacements={{
[facilityId]: { name: state.form.name },
}}
- className="mx-auto max-w-3xl"
+ className="w-full overflow-x-hidden"
>
|