diff --git a/cypress/e2e/patient_spec/patient_logupdate.cy.ts b/cypress/e2e/patient_spec/patient_logupdate.cy.ts index 46ef0b41379..8cf83b1c5a8 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, @@ -109,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, 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, 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 c454136c592..3176e18f2f3 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"; } @@ -17,11 +16,11 @@ const formatValue = (value: unknown, key?: string): ReactNode => { } if (typeof value === "number") { - return value; + return value % 1 ? value.toFixed(2) : value; } if (typeof value === "string") { - const trimmed = value.trim(); + const trimmed = value.trim().replaceAll(/_/g, " "); if (trimmed === "") { return "Empty"; @@ -41,26 +40,30 @@ 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(", "); + return value.map((v) => formatValue(v, key)); } if (value instanceof Date) { return value.toLocaleString(); } - if (Object.entries(value).length === 0) { - return `No ${key?.replace(/_/g, " ")}`; + 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.replace(/_/g, " ")} + {key.replaceAll(/_/g, " ")} - + {formatValue(value, key)}
@@ -70,14 +73,13 @@ 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) { return (
- {values.map(([key, value]: [string, any]) => ( + {Object.entries(props.values).map(([key, value]) => (
- {key.replace(/_/g, " ")} + {key.replaceAll(/_/g, " ")} {formatValue(value, key)}