Skip to content

Commit

Permalink
Merge branch 'develop' into issues/7767/DiscontinuedPrescriptionColla…
Browse files Browse the repository at this point in the history
…psed
  • Loading branch information
rithviknishad authored May 17, 2024
2 parents feba2f5 + 86103da commit c38bec1
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 20 deletions.
2 changes: 2 additions & 0 deletions cypress/e2e/patient_spec/patient_logupdate.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => {
const [ventilatorSocketUrl, setVentilatorSocketUrl] = useState<string>();
const [monitorBedData, setMonitorBedData] = useState<AssetBedModel>();
const [ventilatorBedData, setVentilatorBedData] = useState<AssetBedModel>();
const [showEvents, setShowEvents] = useState(false);
const [showEvents, setShowEvents] = useState(true);

const vitals = useVitalsAspectRatioConfig({
default: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div className="flex w-full flex-col items-center gap-2 md:flex-row">
<span className="text-xs uppercase text-gray-700">
Expand All @@ -61,6 +61,8 @@ export default function EventsList() {
);
}

const values = Object.fromEntries(entries);

switch (item.event_type.name) {
case "INTERNAL_TRANSFER":
case "CLINICAL":
Expand Down
34 changes: 18 additions & 16 deletions src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import type { ReactNode } from "react";
interface IProps {
values: Record<string, any>;
values: Record<string, unknown>;
}

/**
* object - array, date
*/

const formatValue = (value: unknown, key?: string): ReactNode => {
if (value === undefined || value === null) {
if (value == null) {
return "N/A";
}

Expand All @@ -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";
Expand All @@ -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]) => (
<div className="flex flex-col items-center gap-2 md:flex-row">
<span className="text-xs uppercase text-gray-700">
{key.replace(/_/g, " ")}
{key.replaceAll(/_/g, " ")}
</span>
<span className="text-sm font-semibold text-gray-700">
<span className="text-sm font-semibold capitalize text-gray-700">
{formatValue(value, key)}
</span>
</div>
Expand All @@ -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 (
<div className="flex w-full flex-col gap-4 rounded-lg border border-gray-400 p-4 @container">
{values.map(([key, value]: [string, any]) => (
{Object.entries(props.values).map(([key, value]) => (
<div className="flex w-full flex-col items-center gap-2 md:flex-row">
<span className="text-xs uppercase text-gray-700">
{key.replace(/_/g, " ")}
{key.replaceAll(/_/g, " ")}
</span>
<span className="break-all text-sm font-semibold text-gray-700">
{formatValue(value, key)}
Expand Down

0 comments on commit c38bec1

Please sign in to comment.