diff --git a/src/components/Facility/ConsultationDetails/ConsultationNursingTab.tsx b/src/components/Facility/ConsultationDetails/ConsultationNursingTab.tsx index 02604566869..fbc53eac691 100644 --- a/src/components/Facility/ConsultationDetails/ConsultationNursingTab.tsx +++ b/src/components/Facility/ConsultationDetails/ConsultationNursingTab.tsx @@ -134,9 +134,8 @@ const NursingPlot = ({ consultationId }: ConsultationTabProps) => { const dataToDisplay = data .map((x) => x.nursing - ? x.nursing.map((f: any) => { - f["date"] = x.date; - return f; + ? x.nursing.map((f) => { + return { ...f, date: x.date }; }) : [], ) @@ -165,7 +164,7 @@ const NursingPlot = ({ consultationId }: ConsultationTabProps) => { ); const mappedData = dataToDisplay.reduce( - (acc: Record, item: any) => { + (acc: Record>, item) => { if (!acc[item.date]) acc[item.date] = {}; acc[item.date][item.procedure] = item.description; return acc; diff --git a/src/components/Facility/Consultations/LogUpdateAnalayseTable.tsx b/src/components/Facility/Consultations/LogUpdateAnalayseTable.tsx index cd8f0a32ed8..a9192b1c593 100644 --- a/src/components/Facility/Consultations/LogUpdateAnalayseTable.tsx +++ b/src/components/Facility/Consultations/LogUpdateAnalayseTable.tsx @@ -4,9 +4,9 @@ import { useTranslation } from "react-i18next"; import { classNames, formatDate, formatTime } from "@/Utils/utils"; interface SharedSectionTableProps { - data: Record; + data: Record>; rows: Array<{ title?: string; field?: string; subField?: boolean }>; - choices?: Record>; + choices?: Record>; } const LogUpdateAnalayseTable: React.FC = ({ @@ -16,26 +16,26 @@ const LogUpdateAnalayseTable: React.FC = ({ }) => { const { t } = useTranslation(); - // Helper function to get the display value + const dataValues = React.useMemo(() => Object.values(data), [data]); + const getDisplayValue = ( value: string | boolean | null | undefined, field?: string, ): string => { - if (value == null) { - return " "; - } - if (typeof value === "boolean") { return t(value ? "yes" : "no"); } + if (field && choices[field]) { + const choiceMap = choices[field]; const choice = - choices[field][value as keyof (typeof choices)[typeof field]]; + typeof value === "string" || typeof value === "number" + ? choiceMap[value] + : undefined; return choice ? t(`${field.toUpperCase()}__${choice}`) : "-"; } - if (value && typeof value == "string") return value; - return "-"; + return typeof value === "string" ? value : "-"; }; return ( @@ -45,15 +45,13 @@ const LogUpdateAnalayseTable: React.FC = ({ {Object.keys(data).map((date) => ( - <> - -

{formatDate(date)}

-

{formatTime(date)}

- - + +

{formatDate(date)}

+

{formatTime(date)}

+ ))} @@ -73,14 +71,14 @@ const LogUpdateAnalayseTable: React.FC = ({ > {row.title ?? t(`LOG_UPDATE_FIELD_LABEL__${row.field!}`)} - {Object.values(data).map((obj, idx) => { - const value = obj[row.field!]; + {dataValues.map((obj, idx) => { + const value = row.field ? obj[row.field] : undefined; return ( - {getDisplayValue(value, row.field)} + {row.field ? getDisplayValue(value, row.field) : "-"} ); })} diff --git a/src/components/Facility/models.tsx b/src/components/Facility/models.tsx index 79272ac3de7..a984efe6283 100644 --- a/src/components/Facility/models.tsx +++ b/src/components/Facility/models.tsx @@ -391,7 +391,10 @@ export const NursingPlotFields = [ ] as const satisfies (keyof DailyRoundsModel)[]; export type NursingPlotRes = { - nursing: any[]; + nursing: Array<{ + procedure: string; + description: string; + }>; }; export const RoutineFields = [