diff --git a/package-lock.json b/package-lock.json
index 6697b3e7021..a2f8d202145 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -32,7 +32,7 @@
"events": "^3.3.0",
"i18next": "^23.2.7",
"i18next-browser-languagedetector": "^7.1.0",
- "lodash": "^4.17.21",
+ "lodash-es": "^4.17.21",
"postcss-loader": "^7.3.3",
"qrcode.react": "^3.1.0",
"raviger": "^4.1.2",
@@ -73,7 +73,7 @@
"@types/cypress": "^1.1.3",
"@types/echarts": "^4.9.18",
"@types/google.maps": "^3.53.4",
- "@types/lodash": "^4.14.195",
+ "@types/lodash-es": "^4.17.9",
"@types/lodash.get": "^4.4.7",
"@types/node": "^20.4.0",
"@types/prop-types": "*",
@@ -5483,6 +5483,15 @@
"integrity": "sha512-22y3o88f4a94mKljsZcanlNWPzO0uBsBdzLAngf2tp533LzZcQzb6+eZPJ+vCTt+bqF2XnvT9gejTLsAcJAJyQ==",
"dev": true
},
+ "node_modules/@types/lodash-es": {
+ "version": "4.17.9",
+ "resolved": "https://registry.npmjs.org/@types/lodash-es/-/lodash-es-4.17.9.tgz",
+ "integrity": "sha512-ZTcmhiI3NNU7dEvWLZJkzG6ao49zOIjEgIE0RgV7wbPxU0f2xT3VSAHw2gmst8swH6V0YkLRGp4qPlX/6I90MQ==",
+ "dev": true,
+ "dependencies": {
+ "@types/lodash": "*"
+ }
+ },
"node_modules/@types/lodash.get": {
"version": "4.4.7",
"resolved": "https://registry.npmjs.org/@types/lodash.get/-/lodash.get-4.4.7.tgz",
@@ -12454,6 +12463,11 @@
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
},
+ "node_modules/lodash-es": {
+ "version": "4.17.21",
+ "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz",
+ "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw=="
+ },
"node_modules/lodash.castarray": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/lodash.castarray/-/lodash.castarray-4.4.0.tgz",
diff --git a/package.json b/package.json
index 6114fdf7496..ed884f49881 100644
--- a/package.json
+++ b/package.json
@@ -72,7 +72,7 @@
"events": "^3.3.0",
"i18next": "^23.2.7",
"i18next-browser-languagedetector": "^7.1.0",
- "lodash": "^4.17.21",
+ "lodash-es": "^4.17.21",
"postcss-loader": "^7.3.3",
"qrcode.react": "^3.1.0",
"raviger": "^4.1.2",
@@ -113,7 +113,7 @@
"@types/cypress": "^1.1.3",
"@types/echarts": "^4.9.18",
"@types/google.maps": "^3.53.4",
- "@types/lodash": "^4.14.195",
+ "@types/lodash-es": "^4.17.9",
"@types/lodash.get": "^4.4.7",
"@types/node": "^20.4.0",
"@types/prop-types": "*",
diff --git a/src/Common/hooks/useAsyncOptions.ts b/src/Common/hooks/useAsyncOptions.ts
index f0a1c895430..2f3f68d5c3a 100644
--- a/src/Common/hooks/useAsyncOptions.ts
+++ b/src/Common/hooks/useAsyncOptions.ts
@@ -1,4 +1,4 @@
-import { debounce } from "lodash";
+import { debounce } from "lodash-es";
import { useMemo, useState } from "react";
import { useDispatch } from "react-redux";
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/ExternalResult/ExternalResultUpload.tsx b/src/Components/ExternalResult/ExternalResultUpload.tsx
index a9d5c29bfe8..14cc2ede03c 100644
--- a/src/Components/ExternalResult/ExternalResultUpload.tsx
+++ b/src/Components/ExternalResult/ExternalResultUpload.tsx
@@ -1,4 +1,4 @@
-import _ from "lodash";
+import { startCase, camelCase } from "lodash-es";
import { navigate } from "raviger";
import { lazy, useState } from "react";
import CSVReader from "react-csv-reader";
@@ -131,7 +131,7 @@ export default function ExternalResultUpload() {
? errors.map((error: any) => {
return (
- {_.startCase(_.camelCase(error[0][0]))} -{" "}
+ {startCase(camelCase(error[0][0]))} -{" "}
{error[0][1]}
);
diff --git a/src/Components/Facility/Investigations/InvestigationTable.tsx b/src/Components/Facility/Investigations/InvestigationTable.tsx
index 8149e18496b..54e7e50bdc7 100644
--- a/src/Components/Facility/Investigations/InvestigationTable.tsx
+++ b/src/Components/Facility/Investigations/InvestigationTable.tsx
@@ -2,7 +2,6 @@ import ButtonV2 from "../../Common/components/ButtonV2";
import CareIcon from "../../../CAREUI/icons/CareIcon";
import { SelectFormField } from "../../Form/FormFields/SelectFormField";
import TextFormField from "../../Form/FormFields/TextFormField";
-import _ from "lodash";
import { classNames } from "../../../Utils/utils";
import { useState } from "react";
diff --git a/src/Components/Facility/Investigations/Reports/index.tsx b/src/Components/Facility/Investigations/Reports/index.tsx
index ab5380c62ca..2db928386f1 100644
--- a/src/Components/Facility/Investigations/Reports/index.tsx
+++ b/src/Components/Facility/Investigations/Reports/index.tsx
@@ -17,7 +17,7 @@ import { InvestigationResponse } from "./types";
import Loading from "../../../Common/Loading";
import Page from "../../../Common/components/Page";
import ReportTable from "./ReportTable";
-import _ from "lodash";
+import { chain } from "lodash-es";
import { useDispatch } from "react-redux";
import { useRef } from "react";
@@ -175,7 +175,7 @@ const InvestigationReports = ({ id }: any) => {
})
);
- const investigationList = _.chain(data)
+ const investigationList = chain(data)
.compact()
.flatten()
.map((i) => ({
diff --git a/src/Components/Facility/Investigations/Reports/utils.tsx b/src/Components/Facility/Investigations/Reports/utils.tsx
index 485a3e1d5f4..46b95800339 100644
--- a/src/Components/Facility/Investigations/Reports/utils.tsx
+++ b/src/Components/Facility/Investigations/Reports/utils.tsx
@@ -1,20 +1,20 @@
-import _ from "lodash";
+import { memoize, chain, findIndex } from "lodash-es";
import { InvestigationResponse } from "./types";
-export const transformData = _.memoize((data: InvestigationResponse) => {
- const sessions = _.chain(data)
+export const transformData = memoize((data: InvestigationResponse) => {
+ const sessions = chain(data)
.map((value) => value.session_object)
.uniqBy("session_external_id")
.orderBy("session_created_date", "desc")
.value();
- const groupByInvestigation = _.chain(data)
+ const groupByInvestigation = chain(data)
.groupBy("investigation_object.external_id")
.values()
.value();
const reqData = groupByInvestigation.map((value) => {
const sessionValues = Array.from({ length: sessions.length });
value.forEach((val) => {
- const sessionIndex = _.findIndex(sessions, [
+ const sessionIndex = findIndex(sessions, [
"session_external_id",
val.session_object.session_external_id,
]);
@@ -55,7 +55,7 @@ export const transformData = _.memoize((data: InvestigationResponse) => {
return { sessions, data: reqData };
});
-export const getColorIndex = _.memoize(
+export const getColorIndex = memoize(
({ max, min, value }: { min?: number; max?: number; value?: number }) => {
if (!max && min && value) {
// 1 => yellow color
diff --git a/src/Components/Facility/Investigations/ShowInvestigation.tsx b/src/Components/Facility/Investigations/ShowInvestigation.tsx
index 4c2826f6eea..4b8d1d065a7 100644
--- a/src/Components/Facility/Investigations/ShowInvestigation.tsx
+++ b/src/Components/Facility/Investigations/ShowInvestigation.tsx
@@ -9,7 +9,7 @@ import {
import PageTitle from "../../Common/PageTitle";
import InvestigationTable from "./InvestigationTable";
-import _ from "lodash";
+import { set, chain } from "lodash-es";
import { navigate } from "raviger";
import * as Notification from "../../../Utils/Notifications.js";
@@ -110,7 +110,7 @@ export default function ShowInvestigation(props: any) {
const handleValueChange = (value: any, name: string) => {
const changedFields = { ...state.changedFields };
- _.set(changedFields, name, value);
+ set(changedFields, name, value);
dispatch({ type: "set_changed_fields", changedFields });
};
@@ -147,7 +147,7 @@ export default function ShowInvestigation(props: any) {
};
const handleUpdateCancel = useCallback(() => {
- const changedValues = _.chain(state.initialValues)
+ const changedValues = chain(state.initialValues)
.map((val: any, _key: string) => ({
id: val?.id,
initialValue: val?.notes || val?.value || null,
diff --git a/src/Components/Facility/Investigations/Table.tsx b/src/Components/Facility/Investigations/Table.tsx
index 4d6ce4c2340..4bd7e841543 100644
--- a/src/Components/Facility/Investigations/Table.tsx
+++ b/src/Components/Facility/Investigations/Table.tsx
@@ -1,7 +1,7 @@
import { FieldChangeEvent } from "../../Form/FormFields/Utils";
import { SelectFormField } from "../../Form/FormFields/SelectFormField";
import TextFormField from "../../Form/FormFields/TextFormField";
-import _ from "lodash";
+import { set } from "lodash-es";
import { useState } from "react";
const TestRow = ({ data, value, onChange, i }: any) => {
@@ -59,7 +59,7 @@ export const TestTable = ({ title, data, state, dispatch }: any) => {
const handleValueChange = (value: any, name: string) => {
const form = { ...state };
- _.set(form, name, value);
+ set(form, name, value);
dispatch({ type: "set_form", form });
};
diff --git a/src/Components/Facility/LegacyFacilityCNS.tsx b/src/Components/Facility/LegacyFacilityCNS.tsx
index b3a933b9a9f..5b0005c9daf 100644
--- a/src/Components/Facility/LegacyFacilityCNS.tsx
+++ b/src/Components/Facility/LegacyFacilityCNS.tsx
@@ -16,7 +16,7 @@ import Pagination from "../Common/Pagination";
import { PatientModel } from "../Patient/models";
import { FacilityModel } from "./models";
import AutocompleteFormField from "../Form/FormFields/Autocomplete";
-import { uniqBy } from "lodash";
+import { uniqBy } from "lodash-es";
import DialogModal from "../Common/Dialog";
import { LegacyMonitorCard } from "./LegacyMonitorCard";
diff --git a/src/Components/Form/AutoCompleteAsync.tsx b/src/Components/Form/AutoCompleteAsync.tsx
index 0d860b178ce..340b7ac6b8b 100644
--- a/src/Components/Form/AutoCompleteAsync.tsx
+++ b/src/Components/Form/AutoCompleteAsync.tsx
@@ -1,6 +1,6 @@
import { useEffect, useState, useMemo } from "react";
import { Combobox } from "@headlessui/react";
-import { debounce } from "lodash";
+import { debounce } from "lodash-es";
import { DropdownTransition } from "../Common/components/HelperComponents";
import CareIcon from "../../CAREUI/icons/CareIcon";
import {
diff --git a/src/Components/Form/Form.tsx b/src/Components/Form/Form.tsx
index e934c4ffe0e..66383616034 100644
--- a/src/Components/Form/Form.tsx
+++ b/src/Components/Form/Form.tsx
@@ -1,4 +1,4 @@
-import { isEmpty, omitBy } from "lodash";
+import { isEmpty, omitBy } from "lodash-es";
import { useEffect, useMemo, useState } from "react";
import { classNames } from "../../Utils/utils";
import { Cancel, Submit } from "../Common/components/ButtonV2";
diff --git a/src/Components/Patient/PatientRegister.tsx b/src/Components/Patient/PatientRegister.tsx
index c515e7584c1..4fc6fef7fbe 100644
--- a/src/Components/Patient/PatientRegister.tsx
+++ b/src/Components/Patient/PatientRegister.tsx
@@ -61,7 +61,7 @@ import TextAreaFormField from "../Form/FormFields/TextAreaFormField";
import TextFormField from "../Form/FormFields/TextFormField";
import TransferPatientDialog from "../Facility/TransferPatientDialog";
import countryList from "../../Common/static/countries.json";
-import { debounce } from "lodash";
+import { debounce } from "lodash-es";
import useAppHistory from "../../Common/hooks/useAppHistory";
import useConfig from "../../Common/hooks/useConfig";
diff --git a/src/Components/Patient/SampleDetails.tsx b/src/Components/Patient/SampleDetails.tsx
index e29df92f47f..518fae2e728 100644
--- a/src/Components/Patient/SampleDetails.tsx
+++ b/src/Components/Patient/SampleDetails.tsx
@@ -7,7 +7,7 @@ import ButtonV2 from "../Common/components/ButtonV2";
import Card from "../../CAREUI/display/Card";
import { FileUpload } from "./FileUpload";
import Page from "../Common/components/Page";
-import _ from "lodash";
+import { startCase, camelCase } from "lodash-es";
import { formatAge, formatDateTime } from "../../Utils/utils";
import { getTestSample } from "../../Redux/actions";
@@ -259,11 +259,11 @@ export const SampleDetails = ({ id }: DetailRoute) => {
Status: {" "}
- {_.startCase(_.camelCase(flow.status))}
+ {startCase(camelCase(flow.status))}
Label:{" "}
- {_.capitalize(flow.notes)}
+ {capitalize(flow.notes)}
Created On :{" "}
@@ -343,7 +343,7 @@ export const SampleDetails = ({ id }: DetailRoute) => {
Doctor's Name:{" "}
- {_.startCase(_.camelCase(sampleDetails.doctor_name))}
+ {startCase(camelCase(sampleDetails.doctor_name))}
)}
{sampleDetails.diagnosis && (
@@ -426,7 +426,7 @@ export const SampleDetails = ({ id }: DetailRoute) => {
Sample Type:{" "}
- {_.startCase(_.camelCase(sampleDetails.sample_type))}
+ {startCase(camelCase(sampleDetails.sample_type))}
)}
diff --git a/src/Components/Patient/SampleTestCard.tsx b/src/Components/Patient/SampleTestCard.tsx
index 847be365181..5387154dd35 100644
--- a/src/Components/Patient/SampleTestCard.tsx
+++ b/src/Components/Patient/SampleTestCard.tsx
@@ -6,7 +6,7 @@ import { SAMPLE_TEST_STATUS } from "../../Common/constants";
import { patchSample } from "../../Redux/actions";
import * as Notification from "../../Utils/Notifications";
import UpdateStatusDialog from "./UpdateStatusDialog";
-import _ from "lodash";
+import { startCase, camelCase } from "lodash-es";
import { formatDateTime } from "../../Utils/utils";
import ButtonV2 from "../Common/components/ButtonV2";
import { NonReadOnlyUsers } from "../../Utils/AuthorizeFor";
@@ -92,7 +92,7 @@ export const SampleTestCard = (props: SampleDetailsProps) => {
Status{" "}
- {_.startCase(_.camelCase(itemData.status))}
+ {startCase(camelCase(itemData.status))}
@@ -126,7 +126,7 @@ export const SampleTestCard = (props: SampleDetailsProps) => {
Result{" "}
- {_.startCase(_.camelCase(itemData.result))}
+ {startCase(camelCase(itemData.result))}
diff --git a/src/Redux/fireRequest.tsx b/src/Redux/fireRequest.tsx
index 9859ea540b6..bf083e23a92 100644
--- a/src/Redux/fireRequest.tsx
+++ b/src/Redux/fireRequest.tsx
@@ -1,6 +1,6 @@
import * as Notification from "../Utils/Notifications.js";
-import { isEmpty, omitBy } from "lodash";
+import { isEmpty, omitBy } from "lodash-es";
import { LocalStorageKeys } from "../Common/constants";
import api from "./api";
diff --git a/src/Utils/Notifications.js b/src/Utils/Notifications.js
index b4393049531..298622c35ca 100644
--- a/src/Utils/Notifications.js
+++ b/src/Utils/Notifications.js
@@ -1,6 +1,6 @@
import { alert, Stack, defaultModules } from "@pnotify/core";
import * as PNotifyMobile from "@pnotify/mobile";
-import _ from "lodash";
+import { startCase, camelCase } from "lodash-es";
defaultModules.set(PNotifyMobile, {});
@@ -43,7 +43,7 @@ const notifyError = (error) => {
errorMsg = error.detail;
} else {
for (let [key, value] of Object.entries(error)) {
- let keyName = _.startCase(_.camelCase(key));
+ let keyName = startCase(camelCase(key));
if (Array.isArray(value)) {
const uniques = [...new Set(value)];
errorMsg += `${keyName} - ${uniques.splice(0, 5).join(", ")}`;