From c690b754ad2ccb774d22c04220e3bad47d0861ef Mon Sep 17 00:00:00 2001
From: Ashesh <3626859+Ashesh3@users.noreply.github.com>
Date: Fri, 20 Oct 2023 06:34:29 +0530
Subject: [PATCH] Fix loadash-es import (#6477)
---
.../ExternalResult/ExternalResultUpload.tsx | 5 +++--
.../Facility/Investigations/Reports/index.tsx | 5 ++---
.../Facility/Investigations/Reports/utils.tsx | 12 ++++++------
.../Investigations/ShowInvestigation.tsx | 6 +++---
src/Components/Patient/SampleDetails.tsx | 19 ++++++++-----------
src/Components/Patient/SampleTestCard.tsx | 9 +++++----
src/Utils/Notifications.js | 4 ++--
7 files changed, 29 insertions(+), 31 deletions(-)
diff --git a/src/Components/ExternalResult/ExternalResultUpload.tsx b/src/Components/ExternalResult/ExternalResultUpload.tsx
index a3b6dd2fbf9..20a2cec3341 100644
--- a/src/Components/ExternalResult/ExternalResultUpload.tsx
+++ b/src/Components/ExternalResult/ExternalResultUpload.tsx
@@ -1,3 +1,4 @@
+import _ from "lodash-es";
import { navigate } from "raviger";
import { lazy, useState } from "react";
import CSVReader from "react-csv-reader";
@@ -130,8 +131,8 @@ export default function ExternalResultUpload() {
? errors.map((error: any) => {
return (
- {error[0][0].toLowerCase()} -{" "}
- {error[0][1].toLowerCase()}
+ {_.startCase(_.camelCase(error[0][0]))} -{" "}
+ {error[0][1]}
);
})
diff --git a/src/Components/Facility/Investigations/Reports/index.tsx b/src/Components/Facility/Investigations/Reports/index.tsx
index 2db928386f1..9b3c29d40f8 100644
--- a/src/Components/Facility/Investigations/Reports/index.tsx
+++ b/src/Components/Facility/Investigations/Reports/index.tsx
@@ -1,5 +1,5 @@
import * as Notification from "../../../../Utils/Notifications";
-
+import _ from "lodash-es";
import { Group, InvestigationType } from "..";
import {
getPatient,
@@ -17,7 +17,6 @@ import { InvestigationResponse } from "./types";
import Loading from "../../../Common/Loading";
import Page from "../../../Common/components/Page";
import ReportTable from "./ReportTable";
-import { chain } from "lodash-es";
import { useDispatch } from "react-redux";
import { useRef } from "react";
@@ -175,7 +174,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 46b95800339..e57f3c42c53 100644
--- a/src/Components/Facility/Investigations/Reports/utils.tsx
+++ b/src/Components/Facility/Investigations/Reports/utils.tsx
@@ -1,20 +1,20 @@
-import { memoize, chain, findIndex } from "lodash-es";
+import _ 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 4b8d1d065a7..00196bb6678 100644
--- a/src/Components/Facility/Investigations/ShowInvestigation.tsx
+++ b/src/Components/Facility/Investigations/ShowInvestigation.tsx
@@ -8,8 +8,8 @@ import {
} from "../../../Redux/actions";
import PageTitle from "../../Common/PageTitle";
import InvestigationTable from "./InvestigationTable";
-
-import { set, chain } from "lodash-es";
+import _ from "lodash-es";
+import { set } from "lodash-es";
import { navigate } from "raviger";
import * as Notification from "../../../Utils/Notifications.js";
@@ -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/Patient/SampleDetails.tsx b/src/Components/Patient/SampleDetails.tsx
index 672f3905792..9b08395a233 100644
--- a/src/Components/Patient/SampleDetails.tsx
+++ b/src/Components/Patient/SampleDetails.tsx
@@ -7,6 +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-es";
import { formatAge, formatDateTime } from "../../Utils/utils";
import { getTestSample } from "../../Redux/actions";
@@ -114,7 +115,7 @@ export const SampleDetails = ({ id }: DetailRoute) => {
) : (
Age:
- {formatAge(patientData.age, patientData.date_of_birth)}
+ {formatAge(patientData?.age, patientData?.date_of_birth)}
)}
@@ -257,16 +258,12 @@ export const SampleDetails = ({ id }: DetailRoute) => {
-
- Status:{" "}
- {" "}
- {flow.status}
+ Status: {" "}
+ {_.startCase(_.camelCase(flow.status))}
-
- Label:
- {" "}
- {flow.notes?.toLowerCase()}
+ Label:{" "}
+ {_.capitalize(flow.notes)}
Created On :{" "}
@@ -350,7 +347,7 @@ export const SampleDetails = ({ id }: DetailRoute) => {
Doctor's Name:{" "}
- {sampleDetails.doctor_name}
+ {_.startCase(_.camelCase(sampleDetails.doctor_name))}
)}
{sampleDetails.diagnosis && (
@@ -433,7 +430,7 @@ export const SampleDetails = ({ id }: DetailRoute) => {
Sample Type:{" "}
- {sampleDetails.sample_type}
+ {_.startCase(_.camelCase(sampleDetails.sample_type))}
)}
diff --git a/src/Components/Patient/SampleTestCard.tsx b/src/Components/Patient/SampleTestCard.tsx
index 0c299f0a1b5..1ae1ff8671b 100644
--- a/src/Components/Patient/SampleTestCard.tsx
+++ b/src/Components/Patient/SampleTestCard.tsx
@@ -6,6 +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-es";
import { formatDateTime } from "../../Utils/utils";
import ButtonV2 from "../Common/components/ButtonV2";
import { NonReadOnlyUsers } from "../../Utils/AuthorizeFor";
@@ -90,8 +91,8 @@ export const SampleTestCard = (props: SampleDetailsProps) => {
Status{" "}
-
- {itemData.status?.toLowerCase()}
+
+ {_.startCase(_.camelCase(itemData.status))}
@@ -125,8 +126,8 @@ export const SampleTestCard = (props: SampleDetailsProps) => {
Result{" "}
-
- {itemData.result?.toLowerCase()}
+
+ {_.startCase(_.camelCase(itemData.result))}
diff --git a/src/Utils/Notifications.js b/src/Utils/Notifications.js
index 298622c35ca..188a2f7a61b 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 { startCase, camelCase } from "lodash-es";
+import _ 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(", ")}`;