-
-
-
-
- |
- {Object.keys(results).map((date) => (
-
- {formatDate(date)}
- {formatTime(date)}
- |
- ))}
-
-
-
- {ROUTINE_ROWS.map((row) => (
-
-
- {row.title ?? t(`LOG_UPDATE_FIELD_LABEL__${row.field!}`)}
- |
- {row.field &&
- Object.values(results).map((obj, idx) => (
-
- {(() => {
- const value = obj[row.field];
- if (value == null) {
- return "-";
- }
- if (typeof value === "boolean") {
- return t(value ? "yes" : "no");
- }
- const choices = REVERSE_CHOICES[row.field];
- const choice = `${row.field.toUpperCase()}__${choices[value as keyof typeof choices]}`;
- return t(choice);
- })()}
- |
- ))}
-
- ))}
-
-
-
+
{totalCount != null && totalCount > PAGINATION_LIMIT && (
@@ -231,3 +239,24 @@ const RoutineSection = ({ consultationId }: ConsultationTabProps) => {
);
};
+
+export default function ConsultationNursingTab(props: ConsultationTabProps) {
+ const { t } = useTranslation();
+ return (
+
+
+
+
{t("routine")}
+
+
+
+
{t("nursing_care")}
+
+
+
+ );
+}
diff --git a/src/components/Facility/Consultations/LogUpdateAnalyseTable.tsx b/src/components/Facility/Consultations/LogUpdateAnalyseTable.tsx
new file mode 100644
index 00000000000..43e59bebe7d
--- /dev/null
+++ b/src/components/Facility/Consultations/LogUpdateAnalyseTable.tsx
@@ -0,0 +1,93 @@
+import React from "react";
+import { useTranslation } from "react-i18next";
+
+import { classNames, formatDate, formatTime } from "@/Utils/utils";
+
+interface SharedSectionTableProps {
+ data: Record
>;
+ rows: Array<{ title?: string; field?: string; subField?: boolean }>;
+ choices?: Record>;
+}
+
+const LogUpdateAnalyseTable: React.FC = ({
+ data,
+ rows,
+ choices = {},
+}) => {
+ const { t } = useTranslation();
+
+ const dataValues = React.useMemo(() => Object.values(data), [data]);
+
+ const getDisplayValue = (
+ value: string | boolean | null | undefined,
+ field?: string,
+ ): string => {
+ if (typeof value === "boolean") {
+ return t(value ? "yes" : "no");
+ }
+
+ if (field && choices[field]) {
+ const choiceMap = choices[field];
+ const choice =
+ typeof value === "string" || typeof value === "number"
+ ? choiceMap[value]
+ : undefined;
+ return choice ? t(`${field.toUpperCase()}__${choice}`) : "-";
+ }
+
+ return typeof value === "string" ? value : "-";
+ };
+
+ return (
+
+
+
+
+ |
+ {Object.keys(data).map((date) => (
+
+ {formatDate(date)}
+ {formatTime(date)}
+ |
+ ))}
+
+
+
+ {rows.map((row) => (
+
+
+ {row.title ?? t(`LOG_UPDATE_FIELD_LABEL__${row.field!}`)}
+ |
+ {dataValues.map((obj, idx) => {
+ const value = row.field ? obj[row.field] : undefined;
+ return (
+
+ {row.field ? getDisplayValue(value, row.field) : "-"}
+ |
+ );
+ })}
+
+ ))}
+
+
+
+ );
+};
+
+export default LogUpdateAnalyseTable;
diff --git a/src/components/Facility/Consultations/NursingPlot.tsx b/src/components/Facility/Consultations/NursingPlot.tsx
deleted file mode 100644
index 13f5bb64201..00000000000
--- a/src/components/Facility/Consultations/NursingPlot.tsx
+++ /dev/null
@@ -1,132 +0,0 @@
-import { useEffect, useState } from "react";
-import { useTranslation } from "react-i18next";
-
-import Pagination from "@/components/Common/Pagination";
-import { NursingPlotFields } from "@/components/Facility/models";
-
-import { NURSING_CARE_PROCEDURES, PAGINATION_LIMIT } from "@/common/constants";
-
-import routes from "@/Utils/request/api";
-import request from "@/Utils/request/request";
-import { formatDateTime } from "@/Utils/utils";
-
-export const NursingPlot = ({ consultationId }: any) => {
- const { t } = useTranslation();
- const [results, setResults] = useState({});
- const [currentPage, setCurrentPage] = useState(1);
- const [totalCount, setTotalCount] = useState(0);
-
- useEffect(() => {
- const fetchDailyRounds = async (
- currentPage: number,
- consultationId: string,
- ) => {
- const { res, data } = await request(routes.dailyRoundsAnalyse, {
- body: { page: currentPage, fields: NursingPlotFields },
- pathParams: {
- consultationId,
- },
- });
- if (res && res.ok && data) {
- setResults(data.results);
- setTotalCount(data.count);
- }
- };
-
- fetchDailyRounds(currentPage, consultationId);
- }, [consultationId, currentPage]);
-
- const handlePagination = (page: number) => {
- setCurrentPage(page);
- };
-
- const data = Object.entries(results).map((key: any) => {
- return {
- date: formatDateTime(key[0]),
- nursing: key[1]["nursing"],
- };
- });
-
- const dataToDisplay = data
- .map((x) =>
- x.nursing.map((f: any) => {
- f["date"] = x.date;
- return f;
- }),
- )
- .reduce((accumulator, value) => accumulator.concat(value), []);
-
- const filterEmpty = (field: (typeof NURSING_CARE_PROCEDURES)[number]) => {
- const filtered = dataToDisplay.filter((i: any) => i.procedure === field);
- return filtered.length > 0;
- };
-
- const areFieldsEmpty = () => {
- let emptyFieldCount = 0;
- for (const field of NURSING_CARE_PROCEDURES) {
- if (!filterEmpty(field)) emptyFieldCount++;
- }
- if (emptyFieldCount === NURSING_CARE_PROCEDURES.length) return true;
- else return false;
- };
-
- return (
-
-
-
-
- {areFieldsEmpty() && (
-
-
- {t("no_data_found")}
-
-
- )}
- {NURSING_CARE_PROCEDURES.map(
- (f) =>
- filterEmpty(f) && (
-
-
-
-
- {t(`NURSING_CARE_PROCEDURE__${f}`)}
-
-
-
-
- {dataToDisplay
- .filter((i: any) => i.procedure === f)
- .map((care: any, index: number) => (
-
-
- {care.date}
-
-
- {care.description}
-
-
- ))}
-
-
- ),
- )}
-
-
-
-
- {!areFieldsEmpty() && totalCount > PAGINATION_LIMIT && (
-
- )}
-
- );
-};
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 = [