From 56e0afab267a02a42edac0042a46e8b3afb6cb79 Mon Sep 17 00:00:00 2001 From: SilverD3 Date: Wed, 30 Oct 2024 18:19:55 +0100 Subject: [PATCH 1/4] fix:OH2-386 | Laboratory - edit page: fix "results" select --- .../laboratory/examForm/ExamForm.tsx | 17 ++++++++--------- .../patientExams/examRowTable/ExamRowTable.tsx | 8 ++++---- .../patientExams/examRowTable/types.ts | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/components/accessories/laboratory/examForm/ExamForm.tsx b/src/components/accessories/laboratory/examForm/ExamForm.tsx index d00570ba2..95d4f7ba6 100644 --- a/src/components/accessories/laboratory/examForm/ExamForm.tsx +++ b/src/components/accessories/laboratory/examForm/ExamForm.tsx @@ -288,15 +288,14 @@ const ExamForm: FC = ({ ); const onBlurCallbackForTableRow = useCallback( - () => (value: string) => { - setRowsData((rowObjs: string[]) => { - if (!rowObjs.includes(value)) { - rowObjs.push(value); - } else rowObjs = rowObjs.filter((e) => e !== value); - return rowObjs; - }); + (value: string, checked: boolean) => { + if (checked && !rowsData.includes(value)) { + setRowsData((prevState) => [...prevState, value]); + } else { + setRowsData((prevState) => prevState.filter((row) => row !== value)); + } }, - [] + [rowsData] ); const [openResetConfirmation, setOpenResetConfirmation] = useState(false); @@ -416,7 +415,7 @@ const ExamForm: FC = ({ diff --git a/src/components/accessories/patientExams/examRowTable/ExamRowTable.tsx b/src/components/accessories/patientExams/examRowTable/ExamRowTable.tsx index ada2220e2..44f36e8b2 100644 --- a/src/components/accessories/patientExams/examRowTable/ExamRowTable.tsx +++ b/src/components/accessories/patientExams/examRowTable/ExamRowTable.tsx @@ -29,13 +29,13 @@ const ExamRowTable: FC = ({ state.laboratories.getLabWithRowsByCode.data?.laboratoryRowList ); - const handleOnBlur = (value: string) => { - debounceUpdate(value); + const handleOnBlur = (value: string, checked: boolean) => { + debounceUpdate(value, checked); }; // eslint-disable-next-line react-hooks/exhaustive-deps const debounceUpdate = useCallback( - debounce((value: string) => onBlur(value), 100), + debounce((value: string, checked: boolean) => onBlur(value, checked), 100), [] ); @@ -76,7 +76,7 @@ const ExamRowTable: FC = ({ { - handleOnBlur(row.label); + handleOnBlur(row.label, value); }} defaultChecked={ !isEmpty( diff --git a/src/components/accessories/patientExams/examRowTable/types.ts b/src/components/accessories/patientExams/examRowTable/types.ts index c86d85f1e..20ee00c83 100644 --- a/src/components/accessories/patientExams/examRowTable/types.ts +++ b/src/components/accessories/patientExams/examRowTable/types.ts @@ -1,6 +1,6 @@ export interface IEditableTableProps { rows: Array<{ label: string; value: string }>; - onBlur: (value: string) => void; + onBlur: (value: string, checked: boolean) => void; fieldValues?: string[]; headerData: Array<{ label: string; From 1eb095d4006d97963069f30ad28171b553fd3b6b Mon Sep 17 00:00:00 2001 From: SilverD3 Date: Mon, 4 Nov 2024 15:55:41 +0100 Subject: [PATCH 2/4] chore:code improvement --- .../laboratory/examForm/ExamForm.tsx | 2 +- .../patientExams/ExamForm/ExamForm.tsx | 2 +- .../examRowTable/ExamRowTable.tsx | 24 +++++++++++-------- .../patientExams/examRowTable/types.ts | 2 +- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/components/accessories/laboratory/examForm/ExamForm.tsx b/src/components/accessories/laboratory/examForm/ExamForm.tsx index 95d4f7ba6..c8520c4dc 100644 --- a/src/components/accessories/laboratory/examForm/ExamForm.tsx +++ b/src/components/accessories/laboratory/examForm/ExamForm.tsx @@ -415,7 +415,7 @@ const ExamForm: FC = ({ diff --git a/src/components/accessories/patientExams/ExamForm/ExamForm.tsx b/src/components/accessories/patientExams/ExamForm/ExamForm.tsx index ae93c8991..e2dc0836a 100644 --- a/src/components/accessories/patientExams/ExamForm/ExamForm.tsx +++ b/src/components/accessories/patientExams/ExamForm/ExamForm.tsx @@ -288,7 +288,7 @@ const ExamForm: FC = ({ diff --git a/src/components/accessories/patientExams/examRowTable/ExamRowTable.tsx b/src/components/accessories/patientExams/examRowTable/ExamRowTable.tsx index 44f36e8b2..29c639204 100644 --- a/src/components/accessories/patientExams/examRowTable/ExamRowTable.tsx +++ b/src/components/accessories/patientExams/examRowTable/ExamRowTable.tsx @@ -12,14 +12,14 @@ import TableHead from "@mui/material/TableHead"; import TableRow from "@mui/material/TableRow"; import { useAppSelector } from "libraries/hooks/redux"; import { debounce, isEmpty } from "lodash"; -import React, { FC, useCallback } from "react"; +import React, { ChangeEvent, FC, useCallback } from "react"; import { IState } from "../../../../types"; import "./styles.scss"; import { IEditableTableProps } from "./types"; const ExamRowTable: FC = ({ rows, - onBlur, + onChange, headerData, title, disabled = false, @@ -29,16 +29,22 @@ const ExamRowTable: FC = ({ state.laboratories.getLabWithRowsByCode.data?.laboratoryRowList ); - const handleOnBlur = (value: string, checked: boolean) => { - debounceUpdate(value, checked); - }; - // eslint-disable-next-line react-hooks/exhaustive-deps const debounceUpdate = useCallback( - debounce((value: string, checked: boolean) => onBlur(value, checked), 100), + debounce( + (value: string, checked: boolean) => onChange(value, checked), + 100 + ), [] ); + const handleChange = useCallback( + (value: string) => (_: ChangeEvent, checked: boolean) => { + debounceUpdate(value, checked); + }, + [debounceUpdate] + ); + return ( = ({ { - handleOnBlur(row.label, value); - }} + onChange={handleChange(row.label)} defaultChecked={ !isEmpty( labToEditRows?.filter((e) => e === row.label) ?? [] diff --git a/src/components/accessories/patientExams/examRowTable/types.ts b/src/components/accessories/patientExams/examRowTable/types.ts index 20ee00c83..b89cd2f5c 100644 --- a/src/components/accessories/patientExams/examRowTable/types.ts +++ b/src/components/accessories/patientExams/examRowTable/types.ts @@ -1,6 +1,6 @@ export interface IEditableTableProps { rows: Array<{ label: string; value: string }>; - onBlur: (value: string, checked: boolean) => void; + onChange: (value: string, checked: boolean) => void; fieldValues?: string[]; headerData: Array<{ label: string; From b407ae797ab749b6fbf533ca4dc23c12af55e7be Mon Sep 17 00:00:00 2001 From: SilverD3 Date: Tue, 12 Nov 2024 16:52:46 +0100 Subject: [PATCH 3/4] chore: remove exam results table header --- .../accessories/patientExams/examRowTable/ExamRowTable.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/accessories/patientExams/examRowTable/ExamRowTable.tsx b/src/components/accessories/patientExams/examRowTable/ExamRowTable.tsx index 29c639204..056976620 100644 --- a/src/components/accessories/patientExams/examRowTable/ExamRowTable.tsx +++ b/src/components/accessories/patientExams/examRowTable/ExamRowTable.tsx @@ -8,7 +8,6 @@ import Table from "@mui/material/Table"; import TableBody from "@mui/material/TableBody"; import TableCell from "@mui/material/TableCell"; import TableContainer from "@mui/material/TableContainer"; -import TableHead from "@mui/material/TableHead"; import TableRow from "@mui/material/TableRow"; import { useAppSelector } from "libraries/hooks/redux"; import { debounce, isEmpty } from "lodash"; @@ -62,7 +61,7 @@ const ExamRowTable: FC = ({ size="small" aria-label="results table" > - + {/* {headerData.map((row, index) => { return ( @@ -72,7 +71,7 @@ const ExamRowTable: FC = ({ ); })} - + */} {rows?.map((row, index) => ( From 3c965525237b82edadd5def1e1ef1862ec4149a9 Mon Sep 17 00:00:00 2001 From: SilverD3 Date: Wed, 13 Nov 2024 09:14:17 +0100 Subject: [PATCH 4/4] chore:remove exam result header --- .../accessories/laboratory/examForm/ExamForm.tsx | 9 --------- .../accessories/patientExams/ExamForm/ExamForm.tsx | 9 --------- .../patientExams/examRowTable/ExamRowTable.tsx | 12 ------------ .../accessories/patientExams/examRowTable/types.ts | 4 ---- 4 files changed, 34 deletions(-) diff --git a/src/components/accessories/laboratory/examForm/ExamForm.tsx b/src/components/accessories/laboratory/examForm/ExamForm.tsx index 46861e109..8a62db45d 100644 --- a/src/components/accessories/laboratory/examForm/ExamForm.tsx +++ b/src/components/accessories/laboratory/examForm/ExamForm.tsx @@ -141,14 +141,6 @@ const ExamForm: FC = ({ setActivityTransitionState("IDLE"); }, [dispatch]); - const rowTableHeaders: Array<{ - label: string; - align: "left" | "right" | "center" | "justify"; - }> = [ - { label: t("lab.resultrow"), align: "left" }, - { label: t("lab.value"), align: "right" }, - ]; - const validationSchema = object({ labDate: string() .required(t("common.required")) @@ -410,7 +402,6 @@ const ExamForm: FC = ({ {currentExamProcedure === "2" && ( = ({ const [currentExamProcedure, setCurrentExamProcedure] = useState(""); const labToEditRows = labWithRowsToEdit.laboratoryRowList ?? []; - const rowTableHeaders: Array<{ - label: string; - align: "left" | "right" | "center" | "justify"; - }> = [ - { label: t("lab.resultrow"), align: "left" }, - { label: t("lab.value"), align: "right" }, - ]; - const validationSchema = object({ labDate: string() .required(t("common.required")) @@ -287,7 +279,6 @@ const ExamForm: FC = ({ {currentExamProcedure === "2" && ( = ({ rows, onChange, - headerData, title, disabled = false, }) => { @@ -61,17 +60,6 @@ const ExamRowTable: FC = ({ size="small" aria-label="results table" > - {/* - - {headerData.map((row, index) => { - return ( - - {row.label} - - ); - })} - - */} {rows?.map((row, index) => ( diff --git a/src/components/accessories/patientExams/examRowTable/types.ts b/src/components/accessories/patientExams/examRowTable/types.ts index b89cd2f5c..a69d48903 100644 --- a/src/components/accessories/patientExams/examRowTable/types.ts +++ b/src/components/accessories/patientExams/examRowTable/types.ts @@ -2,10 +2,6 @@ export interface IEditableTableProps { rows: Array<{ label: string; value: string }>; onChange: (value: string, checked: boolean) => void; fieldValues?: string[]; - headerData: Array<{ - label: string; - align: "left" | "right" | "center" | "justify"; - }>; title: string; disabled?: boolean; }