Skip to content

Commit

Permalink
Showing 7 changed files with 29 additions and 31 deletions.
5 changes: 3 additions & 2 deletions src/Components/ExternalResult/ExternalResultUpload.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<div key={error[0][0]}>
{error[0][0].toLowerCase()} -{" "}
{error[0][1].toLowerCase()}
{_.startCase(_.camelCase(error[0][0]))} -{" "}
{error[0][1]}
</div>
);
})
5 changes: 2 additions & 3 deletions src/Components/Facility/Investigations/Reports/index.tsx
Original file line number Diff line number Diff line change
@@ -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) => ({
12 changes: 6 additions & 6 deletions src/Components/Facility/Investigations/Reports/utils.tsx
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions src/Components/Facility/Investigations/ShowInvestigation.tsx
Original file line number Diff line number Diff line change
@@ -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,
19 changes: 8 additions & 11 deletions src/Components/Patient/SampleDetails.tsx
Original file line number Diff line number Diff line change
@@ -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) => {
) : (
<div>
<span className="font-semibold leading-relaxed">Age: </span>
{formatAge(patientData.age, patientData.date_of_birth)}
{formatAge(patientData?.age, patientData?.date_of_birth)}
</div>
)}
<div>
@@ -257,16 +258,12 @@ export const SampleDetails = ({ id }: DetailRoute) => {
<Card key={flow.id}>
<div className="grid grid-cols-1 gap-4 md:grid-cols-2">
<div>
<span className="font-semibold capitalize leading-relaxed">
Status:{" "}
</span>{" "}
{flow.status}
<span className="font-semibold leading-relaxed">Status: </span>{" "}
{_.startCase(_.camelCase(flow.status))}
</div>
<div>
<span className="font-semibold capitalize leading-relaxed">
Label:
</span>{" "}
{flow.notes?.toLowerCase()}
<span className="font-semibold leading-relaxed">Label:</span>{" "}
{_.capitalize(flow.notes)}
</div>
<div>
<span className="font-semibold leading-relaxed">Created On :</span>{" "}
@@ -350,7 +347,7 @@ export const SampleDetails = ({ id }: DetailRoute) => {
<span className="font-semibold leading-relaxed">
Doctor&apos;s Name:{" "}
</span>
{sampleDetails.doctor_name}
{_.startCase(_.camelCase(sampleDetails.doctor_name))}
</div>
)}
{sampleDetails.diagnosis && (
@@ -433,7 +430,7 @@ export const SampleDetails = ({ id }: DetailRoute) => {
<span className="font-semibold capitalize leading-relaxed">
Sample Type:{" "}
</span>
{sampleDetails.sample_type}
{_.startCase(_.camelCase(sampleDetails.sample_type))}
</div>
)}
</div>
9 changes: 5 additions & 4 deletions src/Components/Patient/SampleTestCard.tsx
Original file line number Diff line number Diff line change
@@ -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) => {
<div className="text-sm font-semibold leading-5 text-zinc-400">
Status{" "}
</div>
<div className="mt-1 overflow-x-scroll whitespace-normal break-words text-sm font-medium capitalize leading-5">
{itemData.status?.toLowerCase()}
<div className="mt-1 overflow-x-scroll whitespace-normal break-words text-sm font-medium leading-5">
{_.startCase(_.camelCase(itemData.status))}
</div>
</div>
</div>
@@ -125,8 +126,8 @@ export const SampleTestCard = (props: SampleDetailsProps) => {
<div className="text-sm font-semibold leading-5 text-zinc-400">
Result{" "}
</div>
<div className="mt-1 overflow-x-scroll whitespace-normal break-words text-sm font-medium capitalize leading-5">
{itemData.result?.toLowerCase()}
<div className="mt-1 overflow-x-scroll whitespace-normal break-words text-sm font-medium leading-5">
{_.startCase(_.camelCase(itemData.result))}
</div>
</div>
</div>
4 changes: 2 additions & 2 deletions src/Utils/Notifications.js
Original file line number Diff line number Diff line change
@@ -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(", ")}`;

0 comments on commit 08193ba

Please sign in to comment.