From 078fb7841b7cadb1065097464b567659ac8d89be Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Wed, 15 May 2024 16:40:42 +0530 Subject: [PATCH 1/8] Switch to events tab as default --- .../Facility/ConsultationDetails/ConsultationUpdatesTab.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx b/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx index 0f7f4d9b14a..e9e658cee4f 100644 --- a/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx +++ b/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx @@ -37,7 +37,7 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => { const [ventilatorSocketUrl, setVentilatorSocketUrl] = useState(); const [monitorBedData, setMonitorBedData] = useState(); const [ventilatorBedData, setVentilatorBedData] = useState(); - const [showEvents, setShowEvents] = useState(false); + const [showEvents, setShowEvents] = useState(true); const vitals = useVitalsAspectRatioConfig({ default: undefined, From fc1c043d3290edba5aaadf26ff58bd66738e214c Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Wed, 15 May 2024 22:16:11 +0530 Subject: [PATCH 2/8] fix cypress --- cypress/e2e/patient_spec/patient_logupdate.cy.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/cypress/e2e/patient_spec/patient_logupdate.cy.ts b/cypress/e2e/patient_spec/patient_logupdate.cy.ts index 46ef0b41379..00ba0a90af2 100644 --- a/cypress/e2e/patient_spec/patient_logupdate.cy.ts +++ b/cypress/e2e/patient_spec/patient_logupdate.cy.ts @@ -89,6 +89,7 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => { cy.verifyNotification("Normal Log Updates details created successfully"); cy.closeNotification(); // edit the card and verify the data. + cy.contains("Daily Rounds").click(); patientLogupdate.clickLogupdateCard("#dailyround-entry", patientCategory); cy.verifyContentPresence("#consultation-preview", [ patientCategory, From 51d4e44ecffb2fa7d597c6fc06f70baa5d0921b5 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Thu, 16 May 2024 12:10:33 +0530 Subject: [PATCH 3/8] fix cypress --- cypress/e2e/patient_spec/patient_logupdate.cy.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/cypress/e2e/patient_spec/patient_logupdate.cy.ts b/cypress/e2e/patient_spec/patient_logupdate.cy.ts index 00ba0a90af2..8cf83b1c5a8 100644 --- a/cypress/e2e/patient_spec/patient_logupdate.cy.ts +++ b/cypress/e2e/patient_spec/patient_logupdate.cy.ts @@ -110,6 +110,7 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => { patientLogupdate.typeDiastolic(patientModifiedDiastolic); cy.submitButton("Continue"); cy.verifyNotification("Normal Log Updates details updated successfully"); + cy.contains("Daily Rounds").click(); patientLogupdate.clickLogupdateCard("#dailyround-entry", patientCategory); cy.verifyContentPresence("#consultation-preview", [ patientModifiedDiastolic, From b17053ca3e1f119e7480190252957c8791484c3d Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Thu, 16 May 2024 16:09:03 +0530 Subject: [PATCH 4/8] fix precision for numeric values --- .../Facility/ConsultationDetails/Events/GenericEvent.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx b/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx index c454136c592..799ffb1f44c 100644 --- a/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx +++ b/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx @@ -17,7 +17,7 @@ const formatValue = (value: unknown, key?: string): ReactNode => { } if (typeof value === "number") { - return value; + return value % 1 ? value.toFixed(2) : value; } if (typeof value === "string") { From ae9e832c374c14022daa755add824db148da9784 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Thu, 16 May 2024 16:25:23 +0530 Subject: [PATCH 5/8] fix nested objects not rendered issue --- .../ConsultationDetails/Events/EventsList.tsx | 8 ++++--- .../Events/GenericEvent.tsx | 21 +++++++++---------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/Components/Facility/ConsultationDetails/Events/EventsList.tsx b/src/Components/Facility/ConsultationDetails/Events/EventsList.tsx index 560bfd02f33..fd45e3695d0 100644 --- a/src/Components/Facility/ConsultationDetails/Events/EventsList.tsx +++ b/src/Components/Facility/ConsultationDetails/Events/EventsList.tsx @@ -47,11 +47,11 @@ export default function EventsList() { isLast={items.indexOf(item) == items.length - 1} > {(() => { - const values = Object.entries(item.value).filter( - ([_, value]) => value !== null && value !== undefined, + const entries = Object.entries(item.value).filter( + ([_, value]) => value != null && value !== "", ); - if (values.length === 0) { + if (entries.length === 0) { return (
@@ -61,6 +61,8 @@ export default function EventsList() { ); } + const values = Object.fromEntries(entries); + switch (item.event_type.name) { case "INTERNAL_TRANSFER": case "CLINICAL": diff --git a/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx b/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx index 799ffb1f44c..5e74192a1d1 100644 --- a/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx +++ b/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx @@ -1,14 +1,13 @@ import type { ReactNode } from "react"; interface IProps { - values: Record; + values: Record; } /** * object - array, date */ - const formatValue = (value: unknown, key?: string): ReactNode => { - if (value === undefined || value === null) { + if (value == null) { return "N/A"; } @@ -21,7 +20,7 @@ const formatValue = (value: unknown, key?: string): ReactNode => { } if (typeof value === "string") { - const trimmed = value.trim(); + const trimmed = value.trim().replaceAll(/_/g, " "); if (trimmed === "") { return "Empty"; @@ -41,7 +40,7 @@ const formatValue = (value: unknown, key?: string): ReactNode => { if (typeof value === "object") { if (Array.isArray(value)) { if (value.length === 0) { - return `No ${key?.replace(/_/g, " ")}`; + return `No ${key?.replaceAll(/_/g, " ")}`; } return value.map((v) => formatValue(v, key)).join(", "); @@ -52,13 +51,13 @@ const formatValue = (value: unknown, key?: string): ReactNode => { } if (Object.entries(value).length === 0) { - return `No ${key?.replace(/_/g, " ")}`; + return `No ${key?.replaceAll(/_/g, " ")}`; } return Object.entries(value).map(([key, value]) => (
- {key.replace(/_/g, " ")} + {key.replaceAll(/_/g, " ")} {formatValue(value, key)} @@ -70,14 +69,14 @@ const formatValue = (value: unknown, key?: string): ReactNode => { return JSON.stringify(value); }; -export default function GenericEvent({ values }: IProps) { - console.log("value", values); +export default function GenericEvent(props: IProps) { + console.log({ values: props.values }); return (
- {values.map(([key, value]: [string, any]) => ( + {Object.entries(props.values).map(([key, value]) => (
- {key.replace(/_/g, " ")} + {key.replaceAll(/_/g, " ")} {formatValue(value, key)} From 3287a2dc1b40701930bb77f8522be5b4208bb852 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Thu, 16 May 2024 16:29:38 +0530 Subject: [PATCH 6/8] remove console log --- .../Facility/ConsultationDetails/Events/GenericEvent.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx b/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx index 5e74192a1d1..fb380efec5d 100644 --- a/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx +++ b/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx @@ -70,7 +70,6 @@ const formatValue = (value: unknown, key?: string): ReactNode => { }; export default function GenericEvent(props: IProps) { - console.log({ values: props.values }); return (
{Object.entries(props.values).map(([key, value]) => ( From 5d852cfe45259ff0e7dfd646a81f7c29ddd333ac Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Thu, 16 May 2024 16:46:07 +0530 Subject: [PATCH 7/8] fix nested objects not rendered --- .../Facility/ConsultationDetails/Events/GenericEvent.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx b/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx index fb380efec5d..ec7e844b56e 100644 --- a/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx +++ b/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx @@ -43,7 +43,7 @@ const formatValue = (value: unknown, key?: string): ReactNode => { return `No ${key?.replaceAll(/_/g, " ")}`; } - return value.map((v) => formatValue(v, key)).join(", "); + return value.map((v) => formatValue(v, key)); } if (value instanceof Date) { From 00a7aabb0bf7c4d62401f7db00caeff9c894c6d3 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Thu, 16 May 2024 16:59:29 +0530 Subject: [PATCH 8/8] remove empty attributes and captialize values --- .../ConsultationDetails/Events/GenericEvent.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx b/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx index ec7e844b56e..3176e18f2f3 100644 --- a/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx +++ b/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx @@ -50,16 +50,20 @@ const formatValue = (value: unknown, key?: string): ReactNode => { return value.toLocaleString(); } - if (Object.entries(value).length === 0) { + const entries = Object.entries(value).filter( + ([_, value]) => value != null && value !== "", + ); + + if (entries.length === 0) { return `No ${key?.replaceAll(/_/g, " ")}`; } - return Object.entries(value).map(([key, value]) => ( + return entries.map(([key, value]) => (
{key.replaceAll(/_/g, " ")} - + {formatValue(value, key)}