= ({ config, defaultRoute }) => {
if (!mobile) {
return tabs.map((item, index) => {
const path = item.path!;
- return tabs.length == 1 ? (
+ return tabs.length === 1 ? (
<>>
) : (
{
if (item.checkPermissions) {
const checkPermissions = asArray(item.checkPermissions);
return checkPermissions.find((permission) =>
- permissions.includes(permission)
+ permissions.includes(permission as TPermission)
);
}
return true;
diff --git a/src/components/activities/editPatientActivity/EditPatientActivity.tsx b/src/components/activities/editPatientActivity/EditPatientActivity.tsx
index f73ae8524..d291558e1 100644
--- a/src/components/activities/editPatientActivity/EditPatientActivity.tsx
+++ b/src/components/activities/editPatientActivity/EditPatientActivity.tsx
@@ -50,7 +50,7 @@ const EditPatientActivity = () => {
if (isEmpty(patient.data) && patient.status === "IDLE" && id) {
dispatch(getPatient(id));
}
- }, [patient, id, getPatient]);
+ }, [patient, id, dispatch]);
const breadcrumbMap = {
[t("nav.patients")]: PATHS.patients,
@@ -81,10 +81,6 @@ const EditPatientActivity = () => {
},
})
);
- else
- console.error(
- 'The Patient: PatientDTO object must have a "code" property.'
- );
};
const [activityTransitionState, setActivityTransitionState] =
@@ -96,10 +92,9 @@ const EditPatientActivity = () => {
if (isEmpty(patient.data) && patient.status === "IDLE") {
getPatient(id!);
}
- }, [patient, id, getPatient]);
+ }, [patient, id]);
useEffect(() => {
- console.log(activityTransitionState);
if (activityTransitionState === "TO_PATIENT") {
getPatient(id!);
updatePatientReset();
@@ -108,7 +103,7 @@ const EditPatientActivity = () => {
setOpenConfirmationMessage(false);
setActivityTransitionState("IDLE");
}
- }, [activityTransitionState, updatePatientReset, getPatient, id]);
+ }, [activityTransitionState, id]);
useEffect(() => {
setOpenConfirmationMessage(hasSucceeded);
diff --git a/src/components/activities/laboratoryActivity/LaboratoryActivity.tsx b/src/components/activities/laboratoryActivity/LaboratoryActivity.tsx
index 9f5a69e92..a028f0d0d 100644
--- a/src/components/activities/laboratoryActivity/LaboratoryActivity.tsx
+++ b/src/components/activities/laboratoryActivity/LaboratoryActivity.tsx
@@ -27,7 +27,7 @@ const LaboratoryActivity: FC = () => {
return {
[t("nav.laboratory")]: PATHS.laboratory,
};
- }, [location]);
+ }, [location.pathname, t]);
const userCredentials = useAppSelector(
(state) => state.main.authentication.data
diff --git a/src/components/activities/newPatientActivity/NewPatientActivity.tsx b/src/components/activities/newPatientActivity/NewPatientActivity.tsx
index aa5e501c6..6542af7c5 100644
--- a/src/components/activities/newPatientActivity/NewPatientActivity.tsx
+++ b/src/components/activities/newPatientActivity/NewPatientActivity.tsx
@@ -60,7 +60,7 @@ const NewPatientActivity: FunctionComponent = ({
useEffect(() => {
dispatch(getPatientReset());
- }, []);
+ }, [dispatch]);
useEffect(() => {
if (
@@ -77,7 +77,7 @@ const NewPatientActivity: FunctionComponent = ({
});
}
}
- }, [activityTransitionState, createPatientReset]);
+ }, [activityTransitionState, dispatch, navigate, patient?.code]);
const infoBoxRef = useRef(null);
useEffect(() => {
diff --git a/src/components/activities/newPatientActivity/types.ts b/src/components/activities/newPatientActivity/types.ts
index c682e0979..3fa083d29 100644
--- a/src/components/activities/newPatientActivity/types.ts
+++ b/src/components/activities/newPatientActivity/types.ts
@@ -1,4 +1,3 @@
-import { PatientDTO } from "../../../generated";
import { TUserCredentials } from "../../../state/main/types";
export interface IOwnProps {
diff --git a/src/components/activities/patientDetailsActivity/InPatientDashboardMenu.tsx b/src/components/activities/patientDetailsActivity/InPatientDashboardMenu.tsx
index 3d121c567..1fbcd0042 100644
--- a/src/components/activities/patientDetailsActivity/InPatientDashboardMenu.tsx
+++ b/src/components/activities/patientDetailsActivity/InPatientDashboardMenu.tsx
@@ -10,7 +10,7 @@ import {
} from "@mui/icons-material";
import React, { FunctionComponent, useCallback } from "react";
import { useTranslation } from "react-i18next";
-import { useLocation, useNavigate } from "react-router";
+import { useNavigate } from "react-router";
import Arrow from "../../../assets/arrow-w.svg";
import { Permission } from "../../../libraries/permissionUtils/Permission";
import "./styles.scss";
@@ -27,7 +27,6 @@ const InPatientDashboardMenu: FunctionComponent = ({
}) => {
const { t } = useTranslation();
- const { pathname } = useLocation();
const navigate = useNavigate();
const isActive = (value: string) => {
diff --git a/src/components/activities/patientDetailsActivity/OutPatientDashboardMenu.tsx b/src/components/activities/patientDetailsActivity/OutPatientDashboardMenu.tsx
index bfa339129..3e4de4957 100644
--- a/src/components/activities/patientDetailsActivity/OutPatientDashboardMenu.tsx
+++ b/src/components/activities/patientDetailsActivity/OutPatientDashboardMenu.tsx
@@ -8,7 +8,7 @@ import {
} from "@mui/icons-material";
import React, { FunctionComponent, useCallback } from "react";
import { useTranslation } from "react-i18next";
-import { useLocation, useNavigate } from "react-router";
+import { useNavigate } from "react-router";
import Arrow from "../../../assets/arrow-w.svg";
import "./styles.scss";
import { IUserSection } from "./types";
@@ -28,7 +28,6 @@ const OutPatientDashboardMenu: FunctionComponent = ({
return value === userSection ? "active" : "default";
};
- const { pathname } = useLocation();
const navigate = useNavigate();
const changeUserSection = useCallback(
@@ -36,7 +35,7 @@ const OutPatientDashboardMenu: FunctionComponent = ({
setUserSection(section);
navigate(`${section}`, { replace: true });
},
- [navigate, pathname, setUserSection]
+ [navigate, setUserSection]
);
return (
diff --git a/src/components/activities/searchPatientActivity/PatientSearchItem.tsx b/src/components/activities/searchPatientActivity/PatientSearchItem.tsx
index 55379330c..cf3581e98 100644
--- a/src/components/activities/searchPatientActivity/PatientSearchItem.tsx
+++ b/src/components/activities/searchPatientActivity/PatientSearchItem.tsx
@@ -24,7 +24,7 @@ const PatientSearchItem: FunctionComponent = ({
navigate(`/patients/details/${patient.code}`);
}
}
- }, [activityTransitionState, getPatientSuccessCallback, patient]);
+ }, [activityTransitionState, getPatientSuccessCallback, navigate, patient]);
const patientDate = renderDate(patient.birthDate ?? "");
diff --git a/src/components/activities/searchPatientActivity/types.ts b/src/components/activities/searchPatientActivity/types.ts
index c35e85394..b695e9020 100644
--- a/src/components/activities/searchPatientActivity/types.ts
+++ b/src/components/activities/searchPatientActivity/types.ts
@@ -1,6 +1,6 @@
import { PatientDTO } from "../../../generated";
import { TUserCredentials } from "../../../state/main/types";
-import { IAction, TAPIResponseStatus } from "../../../state/types";
+import { TAPIResponseStatus } from "../../../state/types";
export interface IStateProps {
userCredentials: TUserCredentials;
diff --git a/src/libraries/authUtils/getAuthenticationFromSession.ts b/src/libraries/authUtils/getAuthenticationFromSession.ts
index 1b53e105f..460a33c49 100644
--- a/src/libraries/authUtils/getAuthenticationFromSession.ts
+++ b/src/libraries/authUtils/getAuthenticationFromSession.ts
@@ -3,7 +3,7 @@ import { IAuthentication } from "../../state/main/types";
import { SessionStorage } from "../storage/storage";
export const getAuthenticationFromSession = (): IAuthentication => {
- const { permissions, userName } = SessionStorage.read(PERMISSION_KEY);
+ const { permissions } = SessionStorage.read(PERMISSION_KEY);
const { username, token } = SessionStorage.read(AUTH_KEY);
if (!(token && username && permissions)) {
diff --git a/src/libraries/dashboardUtils/admissions/useAdmByAdmTypeData.ts b/src/libraries/dashboardUtils/admissions/useAdmByAdmTypeData.ts
index ef7098b56..8cfd178ec 100644
--- a/src/libraries/dashboardUtils/admissions/useAdmByAdmTypeData.ts
+++ b/src/libraries/dashboardUtils/admissions/useAdmByAdmTypeData.ts
@@ -21,10 +21,7 @@ export const useAdmByAdmTypeData = () => {
state.admissions.getAdmissions.status ?? ""
)
);
- const wardStatus = useAppSelector(
- (state) => state.wards.allWards.status ?? "IDLE"
- );
- const sexLabels = [t("common.male"), t("common.female")];
+
const labels = admissionTypes.map((e) => e.description ?? "");
const data = {
labels: labels,
diff --git a/src/libraries/dashboardUtils/admissions/useAdmByWardData.ts b/src/libraries/dashboardUtils/admissions/useAdmByWardData.ts
index 41a1c9a87..b7859bfc8 100644
--- a/src/libraries/dashboardUtils/admissions/useAdmByWardData.ts
+++ b/src/libraries/dashboardUtils/admissions/useAdmByWardData.ts
@@ -1,8 +1,5 @@
-import { useTranslation } from "react-i18next";
-import { AdmissionDTO, WardDTO } from "../../../generated";
-import { TAPIResponseStatus } from "../../../state/types";
-import { IState } from "../../../types";
import { useAppSelector } from "libraries/hooks/redux";
+import { useTranslation } from "react-i18next";
export const useAdmByAdmWardData = () => {
const { t } = useTranslation();
diff --git a/src/libraries/dashboardUtils/discharges/useDisByAgeTypeData.ts b/src/libraries/dashboardUtils/discharges/useDisByAgeTypeData.ts
index 6acf55b70..aeeac06d5 100644
--- a/src/libraries/dashboardUtils/discharges/useDisByAgeTypeData.ts
+++ b/src/libraries/dashboardUtils/discharges/useDisByAgeTypeData.ts
@@ -1,8 +1,5 @@
-import { useTranslation } from "react-i18next";
import { useAppSelector } from "libraries/hooks/redux";
-import { AdmissionDTO, AgeTypeDTO } from "../../../generated";
-import { TAPIResponseStatus } from "../../../state/types";
-import { IState } from "../../../types";
+import { useTranslation } from "react-i18next";
export const useDisByAgeTypeData = () => {
const { t } = useTranslation();
diff --git a/src/libraries/dashboardUtils/discharges/useDisByDisTypeData.ts b/src/libraries/dashboardUtils/discharges/useDisByDisTypeData.ts
index 4c7644da7..338411f8d 100644
--- a/src/libraries/dashboardUtils/discharges/useDisByDisTypeData.ts
+++ b/src/libraries/dashboardUtils/discharges/useDisByDisTypeData.ts
@@ -1,8 +1,5 @@
-import { useTranslation } from "react-i18next";
import { useAppSelector } from "libraries/hooks/redux";
-import { AdmissionDTO, AdmissionTypeDTO } from "../../../generated";
-import { TAPIResponseStatus } from "../../../state/types";
-import { IState } from "../../../types";
+import { useTranslation } from "react-i18next";
import { colorGen } from "../../uiUtils/colorGenerator";
export const useDisByDisTypeData = () => {
diff --git a/src/libraries/dashboardUtils/discharges/useDisBySexData.ts b/src/libraries/dashboardUtils/discharges/useDisBySexData.ts
index dc4708613..49f02c299 100644
--- a/src/libraries/dashboardUtils/discharges/useDisBySexData.ts
+++ b/src/libraries/dashboardUtils/discharges/useDisBySexData.ts
@@ -1,8 +1,5 @@
-import { useTranslation } from "react-i18next";
import { useAppSelector } from "libraries/hooks/redux";
-import { AdmissionDTO } from "../../../generated";
-import { TAPIResponseStatus } from "../../../state/types";
-import { IState } from "../../../types";
+import { useTranslation } from "react-i18next";
export const useDisBySexData = () => {
const { t } = useTranslation();
diff --git a/src/libraries/dashboardUtils/discharges/useDisByWardData.ts b/src/libraries/dashboardUtils/discharges/useDisByWardData.ts
index ffad9861d..8d3f5f746 100644
--- a/src/libraries/dashboardUtils/discharges/useDisByWardData.ts
+++ b/src/libraries/dashboardUtils/discharges/useDisByWardData.ts
@@ -1,8 +1,5 @@
-import { useTranslation } from "react-i18next";
import { useAppSelector } from "libraries/hooks/redux";
-import { AdmissionDTO, WardDTO } from "../../../generated";
-import { TAPIResponseStatus } from "../../../state/types";
-import { IState } from "../../../types";
+import { useTranslation } from "react-i18next";
export const useDisByWardData = () => {
const { t } = useTranslation();
diff --git a/src/libraries/formDataHandling/functions.ts b/src/libraries/formDataHandling/functions.ts
index 0a19d8bc9..2f501c91c 100644
--- a/src/libraries/formDataHandling/functions.ts
+++ b/src/libraries/formDataHandling/functions.ts
@@ -1,5 +1,10 @@
import { produce } from "immer";
+import { isEmpty } from "lodash";
import moment from "moment";
+import {
+ TAgeFieldName,
+ TAgeType,
+} from "../../components/accessories/patientDataForm/types";
import { IFormCustomizationProps } from "../../customization/formCustomization/type";
import {
AdmissionDTO,
@@ -17,11 +22,6 @@ import {
WardDTO,
} from "../../generated";
import { TFieldAddress, TFieldFormattedValue, TFields } from "./types";
-import {
- TAgeFieldName,
- TAgeType,
-} from "../../components/accessories/patientDataForm/types";
-import { isEmpty } from "lodash";
export const getFromFields = (
fields: TFields,
@@ -328,10 +328,10 @@ export const getBirthDateAndAge = (
switch (ageType) {
case "agetype":
let selectedAgeType = allAgeTypes?.find(
- (at, i) => at.code == values.agetype
+ (at, i) => at.code === values.agetype
);
- if (selectedAgeType != undefined) {
+ if (selectedAgeType !== undefined) {
let averageAge = Math.round(
selectedAgeType.from && selectedAgeType.to
? (selectedAgeType.from + selectedAgeType.to) / 2
diff --git a/src/libraries/hooks/api/useAdmissions.ts b/src/libraries/hooks/api/useAdmissions.ts
index d4817d86d..9c509c5f7 100644
--- a/src/libraries/hooks/api/useAdmissions.ts
+++ b/src/libraries/hooks/api/useAdmissions.ts
@@ -36,7 +36,7 @@ export const useAdmissions = () => {
useEffect(() => {
dispatch(getAdmissions({ admissionrange: range, page, size }));
- }, [page]);
+ }, [dispatch, page, range, size]);
return {
pageInfo,
diff --git a/src/libraries/hooks/api/useDischarges.ts b/src/libraries/hooks/api/useDischarges.ts
index 69113d756..9a6b70b62 100644
--- a/src/libraries/hooks/api/useDischarges.ts
+++ b/src/libraries/hooks/api/useDischarges.ts
@@ -36,7 +36,7 @@ export const useDisharges = () => {
useEffect(() => {
dispatch(getDischarges({ dischargerange: range, page, size }));
- }, [page]);
+ }, [dispatch, page, range, size]);
return {
pageInfo,
diff --git a/src/mockServer/fixtures/examRequestDTO.js b/src/mockServer/fixtures/examRequestDTO.js
new file mode 100644
index 000000000..a8c78939f
--- /dev/null
+++ b/src/mockServer/fixtures/examRequestDTO.js
@@ -0,0 +1,48 @@
+export const examRequestDTO = [
+ {
+ code: 344,
+ material: "Undefined",
+ exam: {
+ code: "01.04",
+ description: "1.4 Film Comment",
+ procedure: 1,
+ defaultResult: "0",
+ examtype: { code: "HB", description: "1.Haematology" },
+ lock: 1,
+ },
+ registrationDate: "2024-10-03T11:03:31",
+ labDate: "2024-10-03T00:03:30",
+ result: "",
+ lock: 0,
+ note: null,
+ patientCode: 85,
+ patName: "Threadgill Mack",
+ inOutPatient: "O",
+ age: 64,
+ sex: "F",
+ status: "draft",
+ },
+ {
+ code: 345,
+ material: "Undefined",
+ exam: {
+ code: "01.03",
+ description: "1.3 Differential ",
+ procedure: 1,
+ defaultResult: "",
+ examtype: { code: "HB", description: "1.Haematology" },
+ lock: 0,
+ },
+ registrationDate: "2024-10-03T11:05:02",
+ labDate: "2024-10-03T00:05:01",
+ result: "",
+ lock: 0,
+ note: null,
+ patientCode: 85,
+ patName: "Threadgill Mack",
+ inOutPatient: "O",
+ age: 64,
+ sex: "F",
+ status: "draft",
+ },
+];
diff --git a/src/mockServer/routes/labExamRequest.js b/src/mockServer/routes/labExamRequest.js
new file mode 100644
index 000000000..2136d32fc
--- /dev/null
+++ b/src/mockServer/routes/labExamRequest.js
@@ -0,0 +1,19 @@
+import { examRequestDTO } from "mockServer/fixtures/examRequestDTO";
+
+export const labExamRequestRoutes = (server) => {
+ server.namespace("/laboratories/examRequest", () => {
+ server.get("/patient/:id").intercept((req, res) => {
+ res.status(200).json(examRequestDTO);
+ });
+ server.post("/").intercept((req, res) => {
+ let body = req.jsonBody();
+ switch (body.code) {
+ case "FAIL":
+ res.status(400).json({ message: "Fail to create lab exam request" });
+ break;
+ default:
+ res.status(200).json(body);
+ }
+ });
+ });
+};
diff --git a/src/mockServer/server.js b/src/mockServer/server.js
index 417d51792..7e20c60e1 100644
--- a/src/mockServer/server.js
+++ b/src/mockServer/server.js
@@ -1,38 +1,39 @@
import XHRAdapter from "@pollyjs/adapter-xhr";
import { Polly } from "@pollyjs/core";
import { BASE_PATH } from "../generated/runtime";
-import { authRoutes } from "./routes/auth";
-import { examinationsRoutes } from "./routes/examinations";
-import { patientRoutes } from "./routes/patients";
-import { userRoutes } from "./routes/users";
-import { userGroupRoutes } from "./routes/userGroups";
-import { visitRoutes } from "./routes/visits";
-import { opdRoutes } from "./routes/opd";
-import { diseasesRoutes } from "./routes/diseases";
-import { diseaseTypeRoutes } from "./routes/diseaseTypes";
-import { ageTypeRoutes } from "./routes/ageTypes";
-import { therapyRoutes } from "./routes/therapies";
-import { medicalRoutes } from "./routes/medicals";
import { admissionRoutes } from "./routes/admissions";
import { admissionTypesRoutes } from "./routes/admissionTypes";
+import { ageTypeRoutes } from "./routes/ageTypes";
+import { authRoutes } from "./routes/auth";
+import { billRoutes } from "./routes/bill";
+import { deliveryResultTypeRoutes } from "./routes/deliveryResultType";
+import { deliveryTypesRoutes } from "./routes/deliveryTypes";
import { dischargeTypesRoutes } from "./routes/dischargeTypes";
-import { wardsRoutes } from "./routes/wards";
-import { labRoutes } from "./routes/lab";
+import { diseasesRoutes } from "./routes/diseases";
+import { diseaseTypeRoutes } from "./routes/diseaseTypes";
import { examRoutes } from "./routes/exam";
+import { examinationsRoutes } from "./routes/examinations";
import { examRowRoutes } from "./routes/examRow";
import { examTypesRoutes } from "./routes/examTypes";
-import { billRoutes } from "./routes/bill";
-import { pricesRoutes } from "./routes/prices";
-import { operationRoutes } from "./routes/operations";
import { hospitalRoutes } from "./routes/hospital";
+import { labRoutes } from "./routes/lab";
+import { labExamRequestRoutes } from "./routes/labExamRequest";
+import { medicalRoutes } from "./routes/medicals";
+import { medicalTypesRoutes } from "./routes/medicalTypes";
+import { opdRoutes } from "./routes/opd";
+import { operationRoutes } from "./routes/operations";
import { operationTypeRoutes } from "./routes/operationTypes";
+import { patientRoutes } from "./routes/patients";
+import { pregnantTreatmentTypeRoutes } from "./routes/pregnantTreatmentType";
+import { pricesRoutes } from "./routes/prices";
+import { suppliersRoutes } from "./routes/suppliers";
+import { therapyRoutes } from "./routes/therapies";
+import { userGroupRoutes } from "./routes/userGroups";
+import { userRoutes } from "./routes/users";
import { vaccineRoutes } from "./routes/vaccine";
import { vaccineTypesRoutes } from "./routes/vaccineTypes";
-import { deliveryTypesRoutes } from "./routes/deliveryTypes";
-import { suppliersRoutes } from "./routes/suppliers";
-import { medicalTypesRoutes } from "./routes/medicalTypes";
-import { pregnantTreatmentTypeRoutes } from "./routes/pregnantTreatmentType";
-import { deliveryResultTypeRoutes } from "./routes/deliveryResultType";
+import { visitRoutes } from "./routes/visits";
+import { wardsRoutes } from "./routes/wards";
export function makeServer() {
Polly.register(XHRAdapter);
@@ -76,6 +77,7 @@ export function makeServer() {
medicalTypesRoutes(server);
pregnantTreatmentTypeRoutes(server);
deliveryResultTypeRoutes(server);
+ labExamRequestRoutes(server);
});
return server;
}
diff --git a/src/routes/MainRouter.tsx b/src/routes/MainRouter.tsx
index 4b9759656..475b82bef 100644
--- a/src/routes/MainRouter.tsx
+++ b/src/routes/MainRouter.tsx
@@ -24,7 +24,7 @@ export const MainRouter: React.FC = () => {
if (status === "SUCCESS") {
dispatch(getUserSettings());
}
- }, [status]);
+ }, [dispatch, status]);
const RequiredAdminAccess = withPermission(
"admin.access",
diff --git a/src/styles/index.scss b/src/styles/index.scss
index e0d627f65..5d0229f6f 100644
--- a/src/styles/index.scss
+++ b/src/styles/index.scss
@@ -9,7 +9,7 @@
.App {
& > div {
- height: 100vh;
+ min-height: 100vh;
}
[class*="Form"],