From 9d68af8c12aaca9f39150d5b8632b9d237ca6eb5 Mon Sep 17 00:00:00 2001 From: Nithin Date: Wed, 21 Aug 2024 06:34:20 +0530 Subject: [PATCH 1/5] Hide N/A and null values in event log #8376 --- .../Consultations/NeurologicalTables.tsx | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/Components/Facility/Consultations/NeurologicalTables.tsx b/src/Components/Facility/Consultations/NeurologicalTables.tsx index 24654f85e7f..6f083a4da29 100644 --- a/src/Components/Facility/Consultations/NeurologicalTables.tsx +++ b/src/Components/Facility/Consultations/NeurologicalTables.tsx @@ -35,22 +35,30 @@ const DataTable = (props: any) => {
{data.map((x: any, i: any) => { - return ( -
-
- {x.date} -
-
- {x.left} -
-
- {x.right} + if ( + x.left !== "N/A" && + x.left !== null && + x.right !== "N/A" && + x.right !== null + ) { + return ( +
+
+ {x.date} +
+
+ {x.left} +
+
+ {x.right} +
-
- ); + ); + } + return null; })}
From e6480d37309b5291450501479fe6844712ed3af8 Mon Sep 17 00:00:00 2001 From: Nithin Date: Wed, 21 Aug 2024 06:55:18 +0530 Subject: [PATCH 2/5] Hide N/A and null values in GenericEvent component --- .../Events/GenericEvent.tsx | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx b/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx index 04ab5657149..391cab2bfc9 100644 --- a/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx +++ b/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx @@ -9,8 +9,8 @@ interface IProps { * object - array, date */ const formatValue = (value: unknown, key?: string): ReactNode => { - if (value == null) { - return "N/A"; + if (value == null || value == "N/A") { + return null; } if (typeof value === "boolean") { @@ -25,7 +25,7 @@ const formatValue = (value: unknown, key?: string): ReactNode => { const trimmed = value.trim().replaceAll(/_/g, " "); if (trimmed === "") { - return "Empty"; + return null; } if (!isNaN(Number(trimmed))) { @@ -88,16 +88,18 @@ export default function GenericEvent(props: IProps) { const { t } = useTranslation(); return (
- {Object.entries(props.values).map(([key, value]) => ( -
- - {t(key).replaceAll(/_/g, " ")} - - - {formatValue(value, key)} - -
- ))} + {Object.entries(props.values) + .filter(([_, value]) => formatValue(value) !== null) + .map(([key, value]) => ( +
+ + {t(key).replaceAll(/_/g, " ")} + + + {formatValue(value, key)} + +
+ ))}
); } From 73acc8e6ce9b19459a3b686d537520988919f713 Mon Sep 17 00:00:00 2001 From: Nithin Date: Wed, 21 Aug 2024 07:13:38 +0530 Subject: [PATCH 3/5] Refactor GenericEvent component to improve readability and efficiency --- .../Facility/ConsultationDetails/Events/GenericEvent.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx b/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx index 391cab2bfc9..80aa0f86ef7 100644 --- a/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx +++ b/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx @@ -89,14 +89,15 @@ export default function GenericEvent(props: IProps) { return (
{Object.entries(props.values) - .filter(([_, value]) => formatValue(value) !== null) - .map(([key, value]) => ( + .map(([key, value]) => ({ key, value: formatValue(value, key) })) + .filter(({ value }) => value != null) + .map(({ key, value }) => (
{t(key).replaceAll(/_/g, " ")} - {formatValue(value, key)} + {value}
))} From 2556b393102ae7a4da3681d80df89836fd125f96 Mon Sep 17 00:00:00 2001 From: Nithin Date: Wed, 21 Aug 2024 07:36:23 +0530 Subject: [PATCH 4/5] Revert NeurologicalTables.tsx to previous state --- .../Consultations/NeurologicalTables.tsx | 38 ++++++++----------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/src/Components/Facility/Consultations/NeurologicalTables.tsx b/src/Components/Facility/Consultations/NeurologicalTables.tsx index 6f083a4da29..24654f85e7f 100644 --- a/src/Components/Facility/Consultations/NeurologicalTables.tsx +++ b/src/Components/Facility/Consultations/NeurologicalTables.tsx @@ -35,30 +35,22 @@ const DataTable = (props: any) => {
{data.map((x: any, i: any) => { - if ( - x.left !== "N/A" && - x.left !== null && - x.right !== "N/A" && - x.right !== null - ) { - return ( -
-
- {x.date} -
-
- {x.left} -
-
- {x.right} -
+ return ( +
+
+ {x.date} +
+
+ {x.left}
- ); - } - return null; +
+ {x.right} +
+
+ ); })}
From d7999b00a695e02fed6ecb6da320a256e3de9379 Mon Sep 17 00:00:00 2001 From: Nithin Date: Thu, 22 Aug 2024 10:46:10 +0530 Subject: [PATCH 5/5] Resolved conflict in GenericEvent component --- .../ConsultationDetails/Events/GenericEvent.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx b/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx index 80aa0f86ef7..1fd0724ed8c 100644 --- a/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx +++ b/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx @@ -9,7 +9,7 @@ interface IProps { * object - array, date */ const formatValue = (value: unknown, key?: string): ReactNode => { - if (value == null || value == "N/A") { + if (value == null || value === "N/A") { return null; } @@ -50,8 +50,8 @@ const formatValue = (value: unknown, key?: string): ReactNode => { return (
    - {value.map((v) => ( -
  • {formatValue(v, key)}
  • + {value.map((v, idx) => ( +
  • {formatValue(v, key)}
  • ))}
); @@ -69,8 +69,8 @@ const formatValue = (value: unknown, key?: string): ReactNode => { return `No ${key?.replaceAll(/_/g, " ")}`; } - return entries.map(([key, value]) => ( -
+ return entries.map(([key, value], idx) => ( +
{key.replaceAll(/_/g, " ")} @@ -96,7 +96,7 @@ export default function GenericEvent(props: IProps) { {t(key).replaceAll(/_/g, " ")} - + {value}