diff --git a/src/Components/Facility/Consultations/LiveFeed.tsx b/src/Components/Facility/Consultations/LiveFeed.tsx
index cd3f055921e..4f6c3391c43 100644
--- a/src/Components/Facility/Consultations/LiveFeed.tsx
+++ b/src/Components/Facility/Consultations/LiveFeed.tsx
@@ -1,11 +1,8 @@
-import { useEffect, useState, useRef } from "react";
+import { useEffect, useRef, useState } from "react";
import { useDispatch } from "react-redux";
+import routes from "../../../Redux/api";
+import request from "../../../Utils/request/request";
import useKeyboardShortcut from "use-keyboard-shortcut";
-import {
- listAssetBeds,
- partialUpdateAssetBed,
- deleteAssetBed,
-} from "../../../Redux/actions";
import { getCameraPTZ } from "../../../Common/constants";
import {
StreamStatus,
@@ -112,28 +109,30 @@ const LiveFeed = (props: any) => {
};
const getBedPresets = async (id: any) => {
- const bedAssets = await dispatch(
- listAssetBeds({
- asset: id,
+ const { data } = await request(routes.listAssetBeds, {
+ pathParams: { asset: id },
+ body: {
limit: page.limit,
offset: page.offset,
- })
- );
- setBedPresets(bedAssets?.data?.results);
+ },
+ });
+ setBedPresets(data?.results);
setPage({
...page,
- count: bedAssets?.data?.count,
+ count: data?.count || 0,
});
};
const deletePreset = async (id: any) => {
- const res = await dispatch(deleteAssetBed(id));
+ const { res, data } = await request(routes.deleteAssetBed, {
+ pathParams: { id },
+ });
if (res?.status === 204) {
Notification.Success({ msg: "Preset deleted successfully" });
getBedPresets(cameraAsset.id);
} else {
Notification.Error({
- msg: "Error while deleting Preset: " + (res?.data?.detail || ""),
+ msg: "Error while deleting Preset: " + (data?.detail || ""),
});
}
setToDelete(null);
@@ -144,20 +143,18 @@ const LiveFeed = (props: any) => {
bed_id: bed.id,
preset_name: preset,
};
- const response = await dispatch(
- partialUpdateAssetBed(
- {
- asset: currentPreset.asset_object.id,
- bed: bed.id,
- meta: {
- ...currentPreset.meta,
- ...data,
- },
+ const { res } = await request(routes.partialUpdateAssetBed, {
+ pathParams: { id: currentPreset.id },
+ body: {
+ asset: currentPreset.asset_object.id,
+ bed: bed.id,
+ meta: {
+ ...currentPreset.meta,
+ ...data,
},
- currentPreset?.id
- )
- );
- if (response && response.status === 200) {
+ },
+ });
+ if (res && res.status === 200) {
Notification.Success({ msg: "Preset Updated" });
} else {
Notification.Error({ msg: "Something Went Wrong" });
@@ -258,20 +255,19 @@ const LiveFeed = (props: any) => {
if (currentPreset?.asset_object?.id && data?.position) {
setLoading(option.loadingLabel);
console.log("Updating Preset");
- const response = await dispatch(
- partialUpdateAssetBed(
- {
- asset: currentPreset.asset_object.id,
- bed: currentPreset.bed_object.id,
- meta: {
- ...currentPreset.meta,
- position: data?.position,
- },
+ const { res } = await request(routes.partialUpdateAssetBed, {
+ pathParams: { id: currentPreset.id },
+ body: {
+ asset: currentPreset.asset_object.id,
+ bed: currentPreset.bed_object.id,
+ meta: {
+ ...currentPreset.meta,
+ position: data?.position,
},
- currentPreset?.id
- )
- );
- if (response && response.status === 200) {
+ },
+ });
+
+ if (res && res.status === 200) {
Notification.Success({ msg: "Preset Updated" });
getBedPresets(cameraAsset?.id);
fetchCameraPresets();
@@ -628,5 +624,4 @@ const LiveFeed = (props: any) => {
);
};
-
export default LiveFeed;
diff --git a/src/Components/Facility/Consultations/NeurologicalTables.tsx b/src/Components/Facility/Consultations/NeurologicalTables.tsx
index 36fae175480..cb3eed92144 100644
--- a/src/Components/Facility/Consultations/NeurologicalTables.tsx
+++ b/src/Components/Facility/Consultations/NeurologicalTables.tsx
@@ -1,13 +1,14 @@
-import { useCallback, useState } from "react";
-import { useDispatch } from "react-redux";
-import { statusType, useAbortableEffect } from "../../../Common/utils";
-import { dailyRoundsAnalyse } from "../../../Redux/actions";
+import { useEffect, useState } from "react";
+
+import routes from "../../../Redux/api";
+import request from "../../../Utils/request/request";
+
import Pagination from "../../Common/Pagination";
import {
- PAGINATION_LIMIT,
EYE_OPEN_SCALE,
- VERBAL_RESPONSE_SCALE,
MOTOR_RESPONSE_SCALE,
+ PAGINATION_LIMIT,
+ VERBAL_RESPONSE_SCALE,
} from "../../../Common/constants";
import { formatDateTime } from "../../../Utils/utils";
@@ -87,7 +88,7 @@ const DataDescription = (props: any) => {
export const NeurologicalTable = (props: any) => {
const { consultationId } = props;
- const dispatch: any = useDispatch();
+ // const dispatch: any = useDispatch();
const [results, setResults] = useState({});
const [currentPage, setCurrentPage] = useState(1);
const [totalCount, setTotalCount] = useState(0);
@@ -95,11 +96,10 @@ export const NeurologicalTable = (props: any) => {
const LOC_OPTIONS = [
{ id: 0, value: "Unknown" },
{ id: 5, value: "Alert" },
- { 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" },
+ { id: 10, value: "Drowsy" },
+ { id: 15, value: "Stuporous" },
+ { id: 20, value: "Comatose" },
+ { id: 25, value: "Cannot Be Assessed" },
];
const REACTION_OPTIONS = [
@@ -120,52 +120,47 @@ export const NeurologicalTable = (props: any) => {
{ id: 30, value: "None" },
];
- const fetchDailyRounds = useCallback(
- async (status: statusType) => {
- const res = await dispatch(
- dailyRoundsAnalyse(
- {
- page: currentPage,
- fields: [
- "consciousness_level",
- "consciousness_level_detail",
- "left_pupil_size",
- "left_pupil_size_detail",
- "right_pupil_size",
- "right_pupil_size_detail",
- "left_pupil_light_reaction",
- "left_pupil_light_reaction_detail",
- "right_pupil_light_reaction",
- "right_pupil_light_reaction_detail",
- "limb_response_upper_extremity_right",
- "limb_response_upper_extremity_left",
- "limb_response_lower_extremity_left",
- "limb_response_lower_extremity_right",
- "glasgow_eye_open",
- "glasgow_verbal_response",
- "glasgow_motor_response",
- "glasgow_total_calculated",
- ],
- },
- { consultationId }
- )
- );
- if (!status.aborted) {
- if (res && res.data && res.data.results) {
- setResults(res.data.results);
- setTotalCount(res.data.count);
- }
- }
- },
- [consultationId, dispatch, currentPage]
- );
+ useEffect(() => {
+ const fetchDailyRounds = async (
+ currentPage: number,
+ consultationId: string
+ ) => {
+ const { res, data } = await request(routes.dailyRoundsAnalyse, {
+ body: {
+ page: currentPage,
+ fields: [
+ "consciousness_level",
+ "consciousness_level_detail",
+ "left_pupil_size",
+ "left_pupil_size_detail",
+ "right_pupil_size",
+ "right_pupil_size_detail",
+ "left_pupil_light_reaction",
+ "left_pupil_light_reaction_detail",
+ "right_pupil_light_reaction",
+ "right_pupil_light_reaction_detail",
+ "limb_response_upper_extremity_right",
+ "limb_response_upper_extremity_left",
+ "limb_response_lower_extremity_left",
+ "limb_response_lower_extremity_right",
+ "glasgow_eye_open",
+ "glasgow_verbal_response",
+ "glasgow_motor_response",
+ "glasgow_total_calculated",
+ ],
+ },
+ pathParams: {
+ consultationId,
+ },
+ });
- useAbortableEffect(
- (status: statusType) => {
- fetchDailyRounds(status);
- },
- [currentPage]
- );
+ if (res && res.ok && data?.results) {
+ setResults(data.results);
+ setTotalCount(data.count);
+ }
+ };
+ fetchDailyRounds(currentPage, consultationId);
+ }, [currentPage, consultationId]);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const handlePagination = (page: number, limit: number) => {
@@ -299,9 +294,9 @@ export const NeurologicalTable = (props: any) => {
{locData.map((x: any, i: any) => (
-
+
{x.date}
diff --git a/src/Components/Facility/Consultations/NursingPlot.tsx b/src/Components/Facility/Consultations/NursingPlot.tsx
index a5d129f68e3..83444b6c50f 100644
--- a/src/Components/Facility/Consultations/NursingPlot.tsx
+++ b/src/Components/Facility/Consultations/NursingPlot.tsx
@@ -1,48 +1,42 @@
-import { useCallback, useState } from "react";
-import { useDispatch } from "react-redux";
+import { useEffect, useState } from "react";
+import routes from "../../../Redux/api";
+import request from "../../../Utils/request/request";
import {
NURSING_CARE_FIELDS,
PAGINATION_LIMIT,
} from "../../../Common/constants";
-import { statusType, useAbortableEffect } from "../../../Common/utils";
-import { dailyRoundsAnalyse } from "../../../Redux/actions";
+
import Pagination from "../../Common/Pagination";
import { formatDateTime } from "../../../Utils/utils";
export const NursingPlot = (props: any) => {
const { consultationId } = props;
- const dispatch: any = useDispatch();
const [results, setResults] = useState
({});
const [currentPage, setCurrentPage] = useState(1);
const [totalCount, setTotalCount] = useState(0);
- const fetchDailyRounds = useCallback(
- async (status: statusType) => {
- const res = await dispatch(
- dailyRoundsAnalyse(
- {
- page: currentPage,
- fields: ["nursing"],
- },
- { consultationId }
- )
- );
- if (!status.aborted) {
- if (res?.data) {
- setResults(res.data.results);
- setTotalCount(res.data.count);
- }
+ useEffect(() => {
+ const fetchDailyRounds = async (
+ currentPage: number,
+ consultationId: string
+ ) => {
+ const { res, data } = await request(routes.dailyRoundsAnalyse, {
+ body: {
+ page: currentPage,
+ fields: ["nursing"],
+ },
+ pathParams: {
+ consultationId,
+ },
+ });
+ if (res && res.ok && data) {
+ setResults(data.results);
+ setTotalCount(data.count);
}
- },
- [consultationId, dispatch, currentPage]
- );
+ };
- useAbortableEffect(
- (status: statusType) => {
- fetchDailyRounds(status);
- },
- [currentPage]
- );
+ fetchDailyRounds(currentPage, consultationId);
+ }, [consultationId, currentPage]);
const handlePagination = (page: number) => {
setCurrentPage(page);
diff --git a/src/Components/Facility/Consultations/NutritionPlots.tsx b/src/Components/Facility/Consultations/NutritionPlots.tsx
index 07dd6422555..93d7ba09010 100644
--- a/src/Components/Facility/Consultations/NutritionPlots.tsx
+++ b/src/Components/Facility/Consultations/NutritionPlots.tsx
@@ -1,7 +1,7 @@
-import { useCallback, useState } from "react";
-import { useDispatch } from "react-redux";
-import { statusType, useAbortableEffect } from "../../../Common/utils";
-import { dailyRoundsAnalyse } from "../../../Redux/actions";
+import { useEffect, useState } from "react";
+import routes from "../../../Redux/api";
+import request from "../../../Utils/request/request";
+
import { LinePlot } from "./components/LinePlot";
import { StackedLinePlot } from "./components/StackedLinePlot";
import Pagination from "../../Common/Pagination";
@@ -11,7 +11,6 @@ import CareIcon from "../../../CAREUI/icons/CareIcon";
export const NutritionPlots = (props: any) => {
const { consultationId } = props;
- const dispatch: any = useDispatch();
const [results, setResults] = useState({});
const [showIO, setShowIO] = useState(true);
const [showIntake, setShowIntake] = useState(false);
@@ -19,40 +18,35 @@ export const NutritionPlots = (props: any) => {
const [currentPage, setCurrentPage] = useState(1);
const [totalCount, setTotalCount] = useState(0);
- const fetchDailyRounds = useCallback(
- async (status: statusType) => {
- const res = await dispatch(
- dailyRoundsAnalyse(
- {
- page: currentPage,
- fields: [
- "infusions",
- "iv_fluids",
- "feeds",
- "total_intake_calculated",
- "total_output_calculated",
- "output",
- ],
- },
- { consultationId }
- )
- );
- if (!status.aborted) {
- if (res && res.data) {
- setResults(res.data.results);
- setTotalCount(res.data.count);
- }
+ useEffect(() => {
+ const fetchDailyRounds = async (
+ currentPage: number,
+ consultationId: string
+ ) => {
+ const { res, data } = await request(routes.dailyRoundsAnalyse, {
+ body: {
+ page: currentPage,
+ fields: [
+ "infusions",
+ "iv_fluids",
+ "feeds",
+ "total_intake_calculated",
+ "total_output_calculated",
+ "output",
+ ],
+ },
+ pathParams: {
+ consultationId,
+ },
+ });
+ if (res && res.ok && data) {
+ setResults(data.results);
+ setTotalCount(data.count);
}
- },
- [consultationId, dispatch, currentPage]
- );
+ };
- useAbortableEffect(
- (status: statusType) => {
- fetchDailyRounds(status);
- },
- [currentPage]
- );
+ fetchDailyRounds(currentPage, consultationId);
+ }, [consultationId, currentPage]);
const handlePagination = (page: number) => {
setCurrentPage(page);
diff --git a/src/Components/Facility/Consultations/PainDiagrams.tsx b/src/Components/Facility/Consultations/PainDiagrams.tsx
index afb070ba14a..183fd6066b3 100644
--- a/src/Components/Facility/Consultations/PainDiagrams.tsx
+++ b/src/Components/Facility/Consultations/PainDiagrams.tsx
@@ -1,13 +1,13 @@
-import { useCallback, useState, useEffect } from "react";
-import { useDispatch } from "react-redux";
-import { statusType, useAbortableEffect } from "../../../Common/utils";
-import { dailyRoundsAnalyse } from "../../../Redux/actions";
+import { useEffect, useState } from "react";
+import routes from "../../../Redux/api";
+import request from "../../../Utils/request/request";
+// eslint-disable-next-line @typescript-eslint/ban-ts-comment
+// @ts-ignore
import { make as CriticalCare__PainViewer } from "../../CriticalCareRecording/Pain/CriticalCare__PainViewer.bs";
import { formatDateTime } from "../../../Utils/utils";
export const PainDiagrams = (props: any) => {
const { consultationId } = props;
- const dispatch: any = useDispatch();
const [isLoading, setIsLoading] = useState(false);
const [results, setResults] = useState({});
const [selectedData, setData] = useState({
@@ -15,48 +15,47 @@ export const PainDiagrams = (props: any) => {
id: "",
});
- const fetchDailyRounds = useCallback(
- async (status: statusType) => {
+ useEffect(() => {
+ const fetchDailyRounds = async (consultationId: string) => {
setIsLoading(true);
- const res = await dispatch(
- dailyRoundsAnalyse(
- {
+ const { res, data: dailyRound } = await request(
+ routes.dailyRoundsAnalyse,
+ {
+ body: {
fields: ["pain_scale_enhanced"],
},
- { consultationId }
- )
+ pathParams: {
+ consultationId,
+ },
+ }
);
- if (!status.aborted) {
- if (res && res.data) {
- const keys = Object.keys(res.data.results || {}).filter(
- (key) => res.data.results[key].pain_scale_enhanced.length
- );
- const data: any = {};
- keys.forEach((key) => (data[key] = res.data.results[key]));
+ if (res && res.ok && dailyRound?.results) {
+ const keys = Object.keys(dailyRound.results || {}).filter(
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
+ // @ts-ignore
+ (key) => dailyRound.results[key].pain_scale_enhanced.length
+ );
+ const data: any = {};
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
+ // @ts-ignore
+ keys.forEach((key) => (data[key] = dailyRound.results[key]));
- setResults(data);
- if (keys.length > 0) {
- setSelectedDateData(data, keys[0]);
- }
+ setResults(data);
+ if (keys.length > 0) {
+ setSelectedDateData(data, keys[0]);
}
- setIsLoading(false);
}
- },
- [consultationId, dispatch]
- );
+ setIsLoading(false);
+ };
+
+ fetchDailyRounds(consultationId);
+ }, [consultationId]);
useEffect(() => {
if (Object.keys(results).length > 0)
setSelectedDateData(results, Object.keys(results)[0]);
}, [results]);
- useAbortableEffect(
- (status: statusType) => {
- fetchDailyRounds(status);
- },
- [consultationId]
- );
-
useEffect(() => {
if (Object.keys(results).length > 0)
setSelectedDateData(results, Object.keys(results)[0]);
diff --git a/src/Components/Facility/Consultations/PressureSoreDiagrams.tsx b/src/Components/Facility/Consultations/PressureSoreDiagrams.tsx
index 84be0fc827a..bf3f4704114 100644
--- a/src/Components/Facility/Consultations/PressureSoreDiagrams.tsx
+++ b/src/Components/Facility/Consultations/PressureSoreDiagrams.tsx
@@ -1,15 +1,15 @@
-import { useCallback, useState, useEffect } from "react";
-import { useDispatch } from "react-redux";
-import { statusType, useAbortableEffect } from "../../../Common/utils";
-import { dailyRoundsAnalyse } from "../../../Redux/actions";
+import { useEffect, useState } from "react";
+import routes from "../../../Redux/api";
+import request from "../../../Utils/request/request";
import { make as CriticalCare__PressureScoreViewer } from "../../CriticalCareRecording/PressureSore/CriticalCare__PressureSoreViewer.bs";
import Pagination from "../../Common/Pagination";
import { PAGINATION_LIMIT } from "../../../Common/constants";
+
import { formatDateTime } from "../../../Utils/utils";
+import { PressureSoreDiagramsRes } from "../models";
export const PressureSoreDiagrams = (props: any) => {
const { consultationId } = props;
- const dispatch: any = useDispatch();
const [isLoading, setIsLoading] = useState(false);
const [results, setResults] = useState({});
const [selectedData, setData] = useState({
@@ -19,49 +19,49 @@ export const PressureSoreDiagrams = (props: any) => {
const [currentPage, setCurrentPage] = useState(1);
const [totalCount, _setTotalCount] = useState(0);
- const fetchDailyRounds = useCallback(
- async (status: statusType) => {
+ useEffect(() => {
+ const fetchDailyRounds = async (
+ currentPage: number,
+ consultationId: string
+ ) => {
setIsLoading(true);
- const res = await dispatch(
- dailyRoundsAnalyse(
- {
+ const { res, data: dailyRounds } = await request(
+ routes.dailyRoundsAnalyse,
+ {
+ body: {
page: currentPage,
fields: ["pressure_sore"],
},
- { consultationId }
- )
+ pathParams: {
+ consultationId,
+ },
+ }
);
- if (!status.aborted) {
- if (res && res.data) {
- const keys = Object.keys(res.data.results || {}).filter(
- (key) => res.data.results[key].pressure_sore.length
- );
- const data: any = {};
- keys.forEach((key) => (data[key] = res.data.results[key]));
+ if (res && res.ok && dailyRounds) {
+ const keys = Object.keys(dailyRounds.results || {}).filter(
+ (key) =>
+ (dailyRounds.results[key] as PressureSoreDiagramsRes).pressure_sore
+ .length
+ );
+ const data: any = {};
+ keys.forEach((key) => (data[key] = dailyRounds.results[key]));
- setResults(data);
- if (keys.length > 0) {
- setSelectedDateData(data, keys[0]);
- }
+ setResults(data);
+ if (keys.length > 0) {
+ setSelectedDateData(data, keys[0]);
}
- setIsLoading(false);
}
- },
- [consultationId, dispatch, currentPage]
- );
+ setIsLoading(false);
+ };
+
+ fetchDailyRounds(currentPage, consultationId);
+ }, [consultationId, currentPage]);
useEffect(() => {
if (Object.keys(results).length > 0)
setSelectedDateData(results, Object.keys(results)[0]);
}, [results]);
- useAbortableEffect(
- (status: statusType) => {
- fetchDailyRounds(status);
- },
- [consultationId, currentPage]
- );
-
const handlePagination = (page: number, _limit: number) => {
setCurrentPage(page);
};
diff --git a/src/Components/Facility/Consultations/PrimaryParametersPlot.tsx b/src/Components/Facility/Consultations/PrimaryParametersPlot.tsx
index f7d74a024a1..4ff81acf868 100644
--- a/src/Components/Facility/Consultations/PrimaryParametersPlot.tsx
+++ b/src/Components/Facility/Consultations/PrimaryParametersPlot.tsx
@@ -1,7 +1,6 @@
-import { useCallback, useState } from "react";
-import { useDispatch } from "react-redux";
-import { statusType, useAbortableEffect } from "../../../Common/utils";
-import { dailyRoundsAnalyse } from "../../../Redux/actions";
+import { useEffect, useState } from "react";
+import routes from "../../../Redux/api";
+import request from "../../../Utils/request/request";
import { LinePlot } from "./components/LinePlot";
import { StackedLinePlot } from "./components/StackedLinePlot";
import Pagination from "../../Common/Pagination";
@@ -21,50 +20,44 @@ interface PrimaryParametersPlotProps {
export const PrimaryParametersPlot = ({
consultationId,
}: PrimaryParametersPlotProps) => {
- const dispatch: any = useDispatch();
const [results, setResults] = useState({});
const [currentPage, setCurrentPage] = useState(1);
const [totalCount, setTotalCount] = useState(0);
- const fetchDailyRounds = useCallback(
- async (status: statusType) => {
- const res = await dispatch(
- dailyRoundsAnalyse(
- {
- page: currentPage,
- fields: [
- "bp",
- "pulse",
- "temperature",
- "resp",
- "blood_sugar_level",
- "insulin_intake_frequency",
- "insulin_intake_dose",
- "ventilator_spo2",
- "ventilator_fi02",
- "rhythm",
- "rhythm_detail",
- ],
- },
- { consultationId }
- )
- );
- if (!status.aborted) {
- if (res && res.data) {
- setResults(res.data.results);
- setTotalCount(res.data.count);
- }
+ useEffect(() => {
+ const fetchDailyRounds = async (
+ currentPage: number,
+ consultationId: string
+ ) => {
+ const { res, data } = await request(routes.dailyRoundsAnalyse, {
+ body: {
+ page: currentPage,
+ fields: [
+ "bp",
+ "pulse",
+ "temperature",
+ "resp",
+ "blood_sugar_level",
+ "insulin_intake_frequency",
+ "insulin_intake_dose",
+ "ventilator_spo2",
+ "ventilator_fi02",
+ "rhythm",
+ "rhythm_detail",
+ ],
+ },
+ pathParams: {
+ consultationId,
+ },
+ });
+ if (res && res.ok && data) {
+ setResults(data.results);
+ setTotalCount(data.count);
}
- },
- [consultationId, dispatch, currentPage]
- );
+ };
- useAbortableEffect(
- (status: statusType) => {
- fetchDailyRounds(status);
- },
- [consultationId, currentPage]
- );
+ fetchDailyRounds(currentPage, consultationId);
+ }, [consultationId, currentPage]);
const handlePagination = (page: number) => {
setCurrentPage(page);
diff --git a/src/Components/Facility/Consultations/VentilatorPlot.tsx b/src/Components/Facility/Consultations/VentilatorPlot.tsx
index c1800823b66..9dfe0ce8a1e 100644
--- a/src/Components/Facility/Consultations/VentilatorPlot.tsx
+++ b/src/Components/Facility/Consultations/VentilatorPlot.tsx
@@ -1,7 +1,6 @@
-import { useCallback, useEffect, useState } from "react";
-import { useDispatch } from "react-redux";
-import { statusType, useAbortableEffect } from "../../../Common/utils";
-import { dailyRoundsAnalyse } from "../../../Redux/actions";
+import { useEffect, useState } from "react";
+import routes from "../../../Redux/api";
+import request from "../../../Utils/request/request";
import { LinePlot } from "./components/LinePlot";
import Pagination from "../../Common/Pagination";
import { PAGINATION_LIMIT } from "../../../Common/constants";
@@ -30,52 +29,45 @@ const modality: Array = [
export const VentilatorPlot = (props: any) => {
const { consultationId } = props;
- const dispatch: any = useDispatch();
const [results, setResults] = useState({});
const [currentPage, setCurrentPage] = useState(1);
const [totalCount, setTotalCount] = useState(0);
- const fetchDailyRounds = useCallback(
- async (status: statusType) => {
- const res = await dispatch(
- dailyRoundsAnalyse(
- {
- page: currentPage,
- fields: [
- "ventilator_pip",
- "ventilator_mean_airway_pressure",
- "ventilator_resp_rate",
- "ventilator_pressure_support",
- "ventilator_tidal_volume",
- "ventilator_peep",
- "ventilator_fi02",
- "ventilator_spo2",
- "etco2",
- "bilateral_air_entry",
- "ventilator_oxygen_modality_oxygen_rate",
- "ventilator_oxygen_modality_flow_rate",
- ],
- },
- { consultationId }
- )
- );
- if (!status.aborted) {
- if (res && res.data) {
- console.log(res);
- setResults(res.data.results);
- setTotalCount(res.data.count);
- }
+ useEffect(() => {
+ const fetchDailyRounds = async (
+ currentPage: number,
+ consultationId: string
+ ) => {
+ const { res, data } = await request(routes.dailyRoundsAnalyse, {
+ body: {
+ page: currentPage,
+ fields: [
+ "ventilator_pip",
+ "ventilator_mean_airway_pressure",
+ "ventilator_resp_rate",
+ "ventilator_pressure_support",
+ "ventilator_tidal_volume",
+ "ventilator_peep",
+ "ventilator_fi02",
+ "ventilator_spo2",
+ "etco2",
+ "bilateral_air_entry",
+ "ventilator_oxygen_modality_oxygen_rate",
+ "ventilator_oxygen_modality_flow_rate",
+ ],
+ },
+ pathParams: {
+ consultationId,
+ },
+ });
+ if (res && res.ok && data) {
+ setResults(data.results);
+ setTotalCount(data.count);
}
- },
- [consultationId, dispatch, currentPage]
- );
+ };
- useAbortableEffect(
- (status: statusType) => {
- fetchDailyRounds(status);
- },
- [currentPage]
- );
+ fetchDailyRounds(currentPage, consultationId);
+ }, [consultationId, currentPage]);
const handlePagination = (page: number) => {
setCurrentPage(page);
diff --git a/src/Components/Facility/models.tsx b/src/Components/Facility/models.tsx
index bd0f4eafeda..fe6c8e3b0d4 100644
--- a/src/Components/Facility/models.tsx
+++ b/src/Components/Facility/models.tsx
@@ -11,21 +11,25 @@ export interface LocalBodyModel {
localbody_code: string;
district: number;
}
+
export interface DistrictModel {
id: number;
name: string;
state: number;
}
+
export interface StateModel {
id: number;
name: string;
}
+
export interface WardModel {
id: number;
name: string;
number: number;
local_body: number;
}
+
export interface FacilityModel {
id?: number;
name?: string;
@@ -147,6 +151,7 @@ export interface ConsultationModel {
is_readmission?: boolean;
medico_legal_case?: boolean;
}
+
export interface PatientStatsModel {
id?: number;
entryDate?: string;
@@ -221,3 +226,216 @@ export interface CurrentBed {
end_date: string;
meta: Record;
}
+
+export type ABGPlotsFields =
+ | "ph"
+ | "pco2"
+ | "po2"
+ | "hco3"
+ | "base_excess"
+ | "lactate"
+ | "sodium"
+ | "potassium"
+ | "ventilator_fi02";
+
+export type ABGPlotsRes = {
+ ph: string;
+ pco2: number;
+ po2: number;
+ hco3: string;
+ base_excess: number;
+ lactate: string;
+ sodium: string;
+ potassium: string;
+ ventilator_fi02: number;
+};
+
+export type DialysisPlotsFields =
+ | "dialysis_fluid_balance"
+ | "dialysis_net_balance";
+
+export type DialysisPlotsRes = {
+ dialysis_fluid_balance: number;
+ dialysis_net_balance: number;
+};
+
+export type NeurologicalTablesFields =
+ | "consciousness_level"
+ | "consciousness_level_detail"
+ | "left_pupil_size"
+ | "left_pupil_size_detail"
+ | "right_pupil_size"
+ | "right_pupil_size_detail"
+ | "left_pupil_light_reaction"
+ | "left_pupil_light_reaction_detail"
+ | "right_pupil_light_reaction"
+ | "right_pupil_light_reaction_detail"
+ | "limb_response_upper_extremity_right"
+ | "limb_response_upper_extremity_left"
+ | "limb_response_lower_extremity_left"
+ | "limb_response_lower_extremity_right"
+ | "glasgow_eye_open"
+ | "glasgow_verbal_response"
+ | "glasgow_motor_response"
+ | "glasgow_total_calculated";
+
+export type NeurologicalTablesRes = {
+ consciousness_level: number;
+ consciousness_level_detail: string;
+ left_pupil_size: number;
+ left_pupil_size_detail: string;
+ right_pupil_size: number;
+ right_pupil_size_detail: string;
+ left_pupil_light_reaction: number;
+ left_pupil_light_reaction_detail: string;
+ right_pupil_light_reaction: number;
+ right_pupil_light_reaction_detail: string;
+ limb_response_upper_extremity_right: number;
+ limb_response_upper_extremity_left: number;
+ limb_response_lower_extremity_left: number;
+ limb_response_lower_extremity_right: number;
+ glasgow_eye_open: number;
+ glasgow_verbal_response: number;
+ glasgow_motor_response: number;
+ glasgow_total_calculated: number;
+};
+
+export type NursingPlotFields = "nursing";
+
+export type NursingPlotRes = {
+ nursing: any[];
+};
+
+export type NutritionPlotsFields =
+ | "infusions"
+ | "iv_fluids"
+ | "feeds"
+ | "total_intake_calculated"
+ | "total_output_calculated"
+ | "output";
+
+export type NutritionPlotsRes = {
+ infusions: any[];
+ iv_fluids: any[];
+ feeds: any[];
+ total_intake_calculated: string;
+ total_output_calculated: string;
+ output: any[];
+};
+
+export type PainDiagramsFields = "pain_scale_enhanced";
+
+export type PainDiagramsRes = {
+ pain_scale_enhanced: any[];
+};
+
+export type PressureSoreDiagramsFields = "pressure_sore";
+
+export type PressureSoreDiagramsRes = {
+ pressure_sore: any[];
+};
+
+export type PrimaryParametersPlotFields =
+ | "bp"
+ | "pulse"
+ | "temperature"
+ | "resp"
+ | "blood_sugar_level"
+ | "insulin_intake_frequency"
+ | "insulin_intake_dose"
+ | "ventilator_spo2"
+ | "ventilator_fi02"
+ | "rhythm"
+ | "rhythm_detail";
+
+export type PrimaryParametersPlotRes = {
+ bp: {
+ mean?: number;
+ systolic?: number;
+ diastolic?: number;
+ };
+ pulse: number;
+ temperature: string;
+ resp: number;
+ blood_sugar_level: number;
+ insulin_intake_frequency: number;
+ insulin_intake_dose: string;
+ ventilator_spo2: number;
+ ventilator_fi02: number;
+ rhythm: number;
+ rhythm_detail: string;
+};
+
+export type VentilatorPlotFields =
+ | "ventilator_pip"
+ | "ventilator_mean_airway_pressure"
+ | "ventilator_resp_rate"
+ | "ventilator_pressure_support"
+ | "ventilator_tidal_volume"
+ | "ventilator_peep"
+ | "ventilator_fi02"
+ | "ventilator_spo2"
+ | "etco2"
+ | "bilateral_air_entry"
+ | "ventilator_oxygen_modality_oxygen_rate"
+ | "ventilator_oxygen_modality_flow_rate";
+
+export type VentilatorPlotRes = {
+ ventilator_pip: number;
+ ventilator_mean_airway_pressure: number;
+ ventilator_resp_rate: number;
+ ventilator_pressure_support: number;
+ ventilator_tidal_volume: number;
+ ventilator_peep: string;
+ ventilator_fi02: number;
+ ventilator_spo2: number;
+ etco2: number;
+ bilateral_air_entry: boolean;
+ ventilator_oxygen_modality_oxygen_rate: number;
+ ventilator_oxygen_modality_flow_rate: number;
+};
+
+export interface DailyRoundsBody {
+ page?: number;
+ fields:
+ | ABGPlotsFields[]
+ | DialysisPlotsFields[]
+ | NeurologicalTablesFields[]
+ | NursingPlotFields[]
+ | NutritionPlotsFields[]
+ | PainDiagramsFields[]
+ | PressureSoreDiagramsFields[]
+ | PrimaryParametersPlotFields[]
+ | VentilatorPlotFields[];
+}
+
+export interface DailyRoundsRes {
+ count: number;
+ page_size: number;
+ results: {
+ [date: string]:
+ | PressureSoreDiagramsRes
+ | ABGPlotsRes
+ | DialysisPlotsRes
+ | NeurologicalTablesRes
+ | NursingPlotRes
+ | NutritionPlotsRes
+ | PainDiagramsRes
+ | PrimaryParametersPlotRes
+ | VentilatorPlotRes;
+ };
+}
+
+export interface CreateBedBody {
+ start_date: string;
+ assets: string[];
+ consultation: string;
+ bed: string;
+}
+
+// Voluntarily made as `type` for it to achieve type-safety when used with
+// `useAsyncOptions`
+export type ICD11DiagnosisModel = {
+ id: string;
+ label: string;
+};
diff --git a/src/Redux/api.tsx b/src/Redux/api.tsx
index 1ff80b55304..8217c3ab14c 100644
--- a/src/Redux/api.tsx
+++ b/src/Redux/api.tsx
@@ -5,18 +5,18 @@ import {
IAadhaarOtpTBody,
ICheckAndGenerateMobileOtp,
IConfirmMobileOtp,
+ IcreateHealthFacilityTBody,
ICreateHealthIdRequest,
ICreateHealthIdResponse,
IGenerateMobileOtpTBody,
+ IgetAbhaCardTBody,
IHealthFacility,
IHealthId,
+ IinitiateAbdmAuthenticationTBody,
ILinkABHANumber,
+ IpartialUpdateHealthFacilityTBody,
ISearchByHealthIdTBody,
IVerifyAadhaarOtpTBody,
- IcreateHealthFacilityTBody,
- IgetAbhaCardTBody,
- IinitiateAbdmAuthenticationTBody,
- IpartialUpdateHealthFacilityTBody,
} from "../Components/ABDM/models";
import {
AssetBedBody,
@@ -30,7 +30,10 @@ import {
} from "../Components/Assets/AssetTypes";
import {
ConsultationModel,
+ CreateBedBody,
CurrentBed,
+ DailyRoundsBody,
+ DailyRoundsRes,
FacilityModel,
LocationModel,
WardModel,
@@ -43,13 +46,16 @@ import {
ILocalBodyByDistrict,
IPartialUpdateExternalResult,
} from "../Components/ExternalResult/models";
+
+import { Prescription } from "../Components/Medicine/models";
import { UserModel } from "../Components/Users/models";
+import { DailyRoundsModel, PatientModel } from "../Components/Patient/models";
import { PaginatedResponse } from "../Utils/request/types";
import {
NotificationData,
PNconfigData,
} from "../Components/Notifications/models";
-import { PatientModel } from "../Components/Patient/models";
+
import { IComment, IResource } from "../Components/Resource/models";
import { IShift } from "../Components/Shifting/models";
@@ -92,7 +98,9 @@ const routes = {
path: "/api/v1/auth/token/refresh/",
method: "POST",
TRes: Type(),
- TBody: Type<{ refresh: string }>(),
+ TBody: Type<{
+ refresh: string;
+ }>(),
},
token_verify: {
@@ -105,7 +113,9 @@ const routes = {
method: "POST",
noAuth: true,
TRes: Type>(),
- TBody: Type<{ token: string }>(),
+ TBody: Type<{
+ token: string;
+ }>(),
},
resetPassword: {
@@ -113,7 +123,10 @@ const routes = {
method: "POST",
noAuth: true,
TRes: Type>(),
- TBody: Type<{ password: string; confirm: string }>(),
+ TBody: Type<{
+ password: string;
+ confirm: string;
+ }>(),
},
forgotPassword: {
@@ -121,7 +134,9 @@ const routes = {
method: "POST",
noAuth: true,
TRes: Type>(),
- TBody: Type<{ username: string }>(),
+ TBody: Type<{
+ username: string;
+ }>(),
},
updatePassword: {
@@ -326,6 +341,9 @@ const routes = {
deleteAssetBed: {
path: "/api/v1/assetbed/{external_id}/",
method: "DELETE",
+ TRes: Type(),
},
operateAsset: {
path: "/api/v1/asset/{external_id}/operate_assets/",
@@ -370,6 +388,8 @@ const routes = {
createConsultationBed: {
path: "/api/v1/consultationbed/",
method: "POST",
+ TBody: Type(),
+ TRes: Type>(),
},
getConsultationBed: {
path: "/api/v1/consultationbed/{external_id}/",
@@ -417,6 +437,8 @@ const routes = {
},
getConsultation: {
path: "/api/v1/consultation/{id}/",
+ method: "GET",
+ TRes: Type(),
},
updateConsultation: {
path: "/api/v1/consultation/{id}/",
@@ -446,6 +468,8 @@ const routes = {
},
getDailyReports: {
path: "/api/v1/consultation/{consultationId}/daily_rounds/",
+ method: "GET",
+ TRes: Type>(),
},
getDailyReport: {
@@ -454,6 +478,8 @@ const routes = {
dailyRoundsAnalyse: {
path: "/api/v1/consultation/{consultationId}/daily_rounds/analyse/",
method: "POST",
+ TBody: Type(),
+ TRes: Type(),
},
// Hospital Beds
@@ -1143,6 +1169,49 @@ const routes = {
method: "GET",
},
+ // Prescription endpoints
+
+ listPrescriptions: {
+ path: "/api/v1/consultation/{consultation_external_id}/prescriptions/",
+ method: "GET",
+ },
+
+ createPrescription: {
+ path: "/api/v1/consultation/{consultation_external_id}/prescriptions/",
+ method: "POST",
+ TBody: Type(),
+ TRes: Type(),
+ },
+
+ listAdministrations: {
+ path: "/api/v1/consultation/{consultation_external_id}/prescription_administration/",
+ method: "GET",
+ },
+
+ getAdministration: {
+ path: "/api/v1/consultation/{consultation_external_id}/prescription_administration/{external_id}/",
+ method: "GET",
+ },
+
+ getPrescription: {
+ path: "/api/v1/consultation/{consultation_external_id}/prescriptions/{external_id}/",
+ method: "GET",
+ },
+
+ administerPrescription: {
+ path: "/api/v1/consultation/{consultation_external_id}/prescriptions/{external_id}/administer/",
+ method: "POST",
+ },
+
+ discontinuePrescription: {
+ path: "/api/v1/consultation/{consultation_external_id}/prescriptions/{external_id}/discontinue/",
+ method: "POST",
+ TBody: Type<{
+ discontinued_reason: string;
+ }>(),
+ TRes: Type>(),
+ },
+
// HCX Endpoints
listPMJYPackages: {
From db03a610a9e3c7f027c8f6553aec7d2c52e443b6 Mon Sep 17 00:00:00 2001
From: konavivekramakrishna
<101407963+konavivekramakrishna@users.noreply.github.com>
Date: Wed, 22 Nov 2023 09:11:51 +0530
Subject: [PATCH 18/31] Implemented Insurance Details Page (#6595)
* Implemented Insurance Details Page
* implemented insurace details card
---
src/Components/HCX/models.ts | 4 +-
src/Components/Patient/InsuranceDetails.tsx | 62 +++++++++++++++
.../Patient/InsuranceDetailsCard.tsx | 78 +++++++++++++++++++
src/Components/Patient/PatientHome.tsx | 20 ++++-
src/Redux/api.tsx | 2 +
src/Routers/routes/PatientRoutes.tsx | 4 +
6 files changed, 167 insertions(+), 3 deletions(-)
create mode 100644 src/Components/Patient/InsuranceDetails.tsx
create mode 100644 src/Components/Patient/InsuranceDetailsCard.tsx
diff --git a/src/Components/HCX/models.ts b/src/Components/HCX/models.ts
index 7e624c474d7..a8a9812d31d 100644
--- a/src/Components/HCX/models.ts
+++ b/src/Components/HCX/models.ts
@@ -26,8 +26,8 @@ export interface HCXPolicyModel {
patient_object?: PatientModel;
subscriber_id: string;
policy_id: string;
- insurer_id: string;
- insurer_name: string;
+ insurer_id?: string;
+ insurer_name?: string;
status?: HCXPolicyStatus;
priority?: "Immediate" | "Normal" | "Deferred";
purpose?: "Auth Requirements" | "Benefits" | "Discovery" | "Validation";
diff --git a/src/Components/Patient/InsuranceDetails.tsx b/src/Components/Patient/InsuranceDetails.tsx
new file mode 100644
index 00000000000..dc8df8ff8a9
--- /dev/null
+++ b/src/Components/Patient/InsuranceDetails.tsx
@@ -0,0 +1,62 @@
+import { lazy } from "react";
+
+import Page from "../Common/components/Page";
+
+import useQuery from "../../Utils/request/useQuery";
+import routes from "../../Redux/api";
+import { HCXPolicyModel } from "../HCX/models";
+import { InsuranceDetialsCard } from "./InsuranceDetailsCard";
+
+const Loading = lazy(() => import("../Common/Loading"));
+
+interface IProps {
+ facilityId: string;
+ id: string;
+}
+
+export const InsuranceDetails = (props: IProps) => {
+ const { facilityId, id } = props;
+
+ const { data: insuranceDetials, loading } = useQuery(routes.listHCXPolicies, {
+ query: {
+ patient: id,
+ },
+ });
+
+ if (loading) {
+ return ;
+ }
+
+ return (
+
+ {loading ? (
+
+ ) : insuranceDetials?.count === 0 ? (
+
+ No Insurance Details Available
+
+ ) : (
+
+ {insuranceDetials?.results.map((data: HCXPolicyModel) => (
+
+ ))}
+
+ )}
+
+ );
+};
diff --git a/src/Components/Patient/InsuranceDetailsCard.tsx b/src/Components/Patient/InsuranceDetailsCard.tsx
new file mode 100644
index 00000000000..b928ce7bffd
--- /dev/null
+++ b/src/Components/Patient/InsuranceDetailsCard.tsx
@@ -0,0 +1,78 @@
+import ButtonV2 from "../Common/components/ButtonV2";
+import { HCXPolicyModel } from "../HCX/models";
+import { navigate } from "raviger";
+
+interface InsuranceDetails {
+ data?: HCXPolicyModel;
+ showViewAllDetails?: boolean;
+}
+
+export const InsuranceDetialsCard = (props: InsuranceDetails) => {
+ const { data, showViewAllDetails } = props;
+
+ return (
+
+
+
+ Policy Details
+
+ {data ? (
+
+
+
+ Member ID
+
+
+ {data.subscriber_id || ""}
+
+
+
+
+ Policy ID / Policy Name
+
+
+ {data.policy_id || ""}
+
+
+
+
+ Insurer ID
+
+
+ {data.insurer_id || ""}
+
+
+
+
+ Insurer Name
+
+
+ {data.insurer_name || ""}
+
+
+ {showViewAllDetails && (
+
+
+ {
+ navigate(
+ `/facility/${data.patient_object?.facility_object?.id}/patient/${data.patient_object?.id}/insurance`
+ );
+ }}
+ className="h-auto whitespace-pre-wrap border border-gray-500 bg-white text-black hover:bg-gray-300"
+ >
+ View All Details
+
+
+
+ )}
+
+ ) : (
+
+ No Insurance Details Available
+
+ )}
+
+
+ );
+};
diff --git a/src/Components/Patient/PatientHome.tsx b/src/Components/Patient/PatientHome.tsx
index a8f2335d484..fad482934ac 100644
--- a/src/Components/Patient/PatientHome.tsx
+++ b/src/Components/Patient/PatientHome.tsx
@@ -32,6 +32,9 @@ import UserAutocompleteFormField from "../Common/UserAutocompleteFormField";
import dayjs from "../../Utils/dayjs";
import { triggerGoal } from "../../Integrations/Plausible";
import useAuthUser from "../../Common/hooks/useAuthUser";
+import useQuery from "../../Utils/request/useQuery";
+import routes from "../../Redux/api";
+import { InsuranceDetialsCard } from "./InsuranceDetailsCard";
const Loading = lazy(() => import("../Common/Loading"));
@@ -91,6 +94,13 @@ export const PatientHome = (props: any) => {
});
};
+ const { data: insuranceDetials } = useQuery(routes.listHCXPolicies, {
+ query: {
+ patient: id,
+ limit: 1,
+ },
+ });
+
const handleAssignedVolunteer = () => {
dispatch(
patchPatient(
@@ -975,7 +985,7 @@ export const PatientHome = (props: any) => {
@@ -1110,6 +1120,14 @@ export const PatientHome = (props: any) => {
+
+
1
+ }
+ />
diff --git a/src/Redux/api.tsx b/src/Redux/api.tsx
index 8217c3ab14c..a69914bddb7 100644
--- a/src/Redux/api.tsx
+++ b/src/Redux/api.tsx
@@ -58,6 +58,7 @@ import {
import { IComment, IResource } from "../Components/Resource/models";
import { IShift } from "../Components/Shifting/models";
+import { HCXPolicyModel } from "../Components/HCX/models";
/**
* A fake function that returns an empty object casted to type T
@@ -1232,6 +1233,7 @@ const routes = {
listHCXPolicies: {
path: "/api/v1/hcx/policy/",
method: "GET",
+ TRes: Type
>(),
},
createHCXPolicy: {
diff --git a/src/Routers/routes/PatientRoutes.tsx b/src/Routers/routes/PatientRoutes.tsx
index ae594d767ec..ce2798c4492 100644
--- a/src/Routers/routes/PatientRoutes.tsx
+++ b/src/Routers/routes/PatientRoutes.tsx
@@ -6,6 +6,7 @@ import PatientNotes from "../../Components/Patient/PatientNotes";
import { PatientRegister } from "../../Components/Patient/PatientRegister";
import { DetailRoute } from "../types";
import DeathReport from "../../Components/DeathReport/DeathReport";
+import { InsuranceDetails } from "../../Components/Patient/InsuranceDetails";
export default {
"/patients": () => ,
@@ -21,6 +22,9 @@ export default {
"/facility/:facilityId/patient/:id": ({ facilityId, id }: any) => (
),
+ "/facility/:facilityId/patient/:id/insurance": ({ facilityId, id }: any) => (
+
+ ),
"/facility/:facilityId/patient/:id/update": ({ facilityId, id }: any) => (
),
From b8d8070638d6168f39eba9f5d6f8e0e89dbfcd0c Mon Sep 17 00:00:00 2001
From: Kshitij Todkar <120639775+KshitijTodkar48@users.noreply.github.com>
Date: Wed, 22 Nov 2023 09:12:22 +0530
Subject: [PATCH 19/31] Removed unnecessary multiple cancel buttons and added a
Back button. (#6579)
* Removed unnecessary cancel buttons and added a back button
* made the requested changes
---
src/Components/ABDM/ConfigureHealthFacility.tsx | 3 +--
src/Components/Facility/FacilityConfigure.tsx | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/Components/ABDM/ConfigureHealthFacility.tsx b/src/Components/ABDM/ConfigureHealthFacility.tsx
index 16e6bf90ea4..a84e4b6d4b9 100644
--- a/src/Components/ABDM/ConfigureHealthFacility.tsx
+++ b/src/Components/ABDM/ConfigureHealthFacility.tsx
@@ -1,7 +1,7 @@
import { lazy, useReducer, useState } from "react";
import * as Notification from "../../Utils/Notifications.js";
import { navigate } from "raviger";
-import { Cancel, Submit } from "../Common/components/ButtonV2";
+import { Submit } from "../Common/components/ButtonV2";
import TextFormField from "../Form/FormFields/TextFormField";
import { classNames } from "../../Utils/utils";
import useQuery from "../../Utils/request/useQuery";
@@ -218,7 +218,6 @@ export const ConfigureHealthFacility = (props: any) => {
- navigate(`/facility/${facilityId}`)} />
{