From 84f366ee91dc03d40669e55584804b0071ee4ec3 Mon Sep 17 00:00:00 2001 From: Shivank Kacker Date: Fri, 20 Sep 2024 13:44:43 +0530 Subject: [PATCH] merge fix --- src/Components/Patient/DailyRounds.tsx | 311 ++++++++++++++++++------- 1 file changed, 232 insertions(+), 79 deletions(-) diff --git a/src/Components/Patient/DailyRounds.tsx b/src/Components/Patient/DailyRounds.tsx index acfe6871e3a..0c6e01be6f2 100644 --- a/src/Components/Patient/DailyRounds.tsx +++ b/src/Components/Patient/DailyRounds.tsx @@ -3,11 +3,19 @@ import { navigate } from "raviger"; import dayjs from "dayjs"; import { lazy, useCallback, useEffect, useState } from "react"; import { + APPETITE_CHOICES, + BLADDER_DRAINAGE_CHOICES, + BLADDER_ISSUE_CHOICES, + BOWEL_ISSUE_CHOICES, CONSCIOUSNESS_LEVEL, + NUTRITION_ROUTE_CHOICES, + ORAL_ISSUE_CHOICES, PATIENT_CATEGORIES, REVIEW_AT_CHOICES, RHYTHM_CHOICES, + SLEEP_CHOICES, TELEMEDICINE_ACTIONS, + URINATION_FREQUENCY_CHOICES, } from "../../Common/constants"; import useAppHistory from "../../Common/hooks/useAppHistory"; import { DraftSection, useAutoSaveReducer } from "../../Utils/AutoSave"; @@ -30,7 +38,7 @@ import request from "../../Utils/request/request"; import routes from "../../Redux/api"; import { Scribe } from "../Scribe/Scribe"; import { SCRIBE_FORMS } from "../Scribe/formDetails"; -import { DailyRoundsModel } from "./models"; +import { DailyRoundsModel, DailyRoundTypes } from "./models"; import InvestigationBuilder from "../Common/prescription-builder/InvestigationBuilder"; import { FieldErrorText } from "../Form/FormFields/FormField"; import { error } from "@pnotify/core"; @@ -48,6 +56,7 @@ import CheckBoxFormField from "../Form/FormFields/CheckBoxFormField"; import SymptomsApi from "../Symptoms/api"; import { scrollTo } from "../../Utils/utils"; import { ICD11DiagnosisModel } from "../Facility/models"; +import NursingCare from "../LogUpdate/Sections/NursingCare"; const Loading = lazy(() => import("../Common/Loading")); @@ -281,6 +290,16 @@ export const DailyRounds = (props: any) => { } return; } + + case "oral_issue": { + if (state.form.nutrition_route !== "ORAL" && state.form[field]) { + errors[field] = t("oral_issue_for_non_oral_nutrition_route_error"); + invalidForm = true; + break; + } + return; + } + default: return; } @@ -329,7 +348,7 @@ export const DailyRounds = (props: any) => { review_interval: Number(prevReviewInterval), }; - if (!["VENTILATOR"].includes(state.form.rounds_type)) { + if (state.form.rounds_type !== "VENTILATOR") { data = { ...data, bp: state.form.bp ?? {}, @@ -340,6 +359,17 @@ export const DailyRounds = (props: any) => { rhythm_detail: state.form.rhythm_detail, ventilator_spo2: state.form.ventilator_spo2 ?? null, consciousness_level: state.form.consciousness_level || undefined, + bowel_issue: state.form.bowel_issue ?? undefined, + bladder_drainage: state.form.bladder_drainage ?? undefined, + bladder_issue: state.form.bladder_issue ?? undefined, + is_experiencing_dysuria: state.form.is_experiencing_dysuria, + urination_frequency: state.form.urination_frequency ?? undefined, + sleep: state.form.sleep ?? undefined, + nutrition_route: state.form.nutrition_route ?? undefined, + oral_issue: state.form.oral_issue ?? undefined, + appetite: state.form.appetite ?? undefined, + blood_sugar_level: state.form.blood_sugar_level, + nursing: state.form.nursing, }; } @@ -354,9 +384,15 @@ export const DailyRounds = (props: any) => { if (obj) { dispatch({ type: "set_form", form: initForm }); Notification.Success({ - msg: `${t(obj.rounds_type as string)} log updated successfully`, + msg: t("LOG_UPDATE_UPDATED_NOTIFICATION", { + roundType: t(`ROUNDS_TYPE__${state.form.rounds_type}`), + }), }); - if (["NORMAL", "TELEMEDICINE"].includes(state.form.rounds_type)) { + if ( + ["NORMAL", "TELEMEDICINE", "COMMUNITY_NURSES_LOG"].includes( + state.form.rounds_type, + ) + ) { navigate( `/facility/${facilityId}/patient/${patientId}/consultation/${consultationId}`, ); @@ -375,10 +411,16 @@ export const DailyRounds = (props: any) => { if (obj) { dispatch({ type: "set_form", form: initForm }); Notification.Success({ - msg: `${t(state.form.rounds_type)} log created successfully`, + msg: t("LOG_UPDATE_CREATED_NOTIFICATION", { + roundType: t(`ROUNDS_TYPE__${state.form.rounds_type}`), + }), }); - if (["NORMAL", "TELEMEDICINE"].includes(state.form.rounds_type)) { + if ( + ["NORMAL", "TELEMEDICINE", "COMMUNITY_NURSES_LOG"].includes( + state.form.rounds_type, + ) + ) { navigate( `/facility/${facilityId}/patient/${patientId}/consultation/${consultationId}`, ); @@ -408,6 +450,7 @@ export const DailyRounds = (props: any) => { const field = (name: string) => { return { id: name, + label: t(`LOG_UPDATE_FIELD_LABEL__${name}`), name, value: state.form[name], error: state.errors[name], @@ -415,6 +458,18 @@ export const DailyRounds = (props: any) => { }; }; + const selectField = ( + name: keyof DailyRoundsModel, + options: readonly T[], + ) => { + return { + ...field(name), + options, + optionLabel: (option: T) => t(`${name.toUpperCase()}__${option}`), + optionValue: (option: T) => option, + }; + }; + const getExpectedReviewTime = () => { const nextReviewTime = Number( state.form.review_interval || prevReviewInterval, @@ -428,30 +483,30 @@ export const DailyRounds = (props: any) => { return ; } - const roundTypes: { id: string; text: string }[] = []; + const roundTypes: (typeof DailyRoundTypes)[number][] = []; if ( ["Doctor", "Staff", "DistrictAdmin", "StateAdmin"].includes( authUser.user_type, ) ) { - roundTypes.push({ id: "DOCTORS_LOG", text: t("DOCTORS_LOG") }); + roundTypes.push("DOCTORS_LOG"); } - - roundTypes.push( - { id: "NORMAL", text: t("NORMAL") }, - { id: "VENTILATOR", text: t("VENTILATOR") }, - ); - + roundTypes.push("NORMAL", "COMMUNITY_NURSES_LOG", "VENTILATOR"); if (consultationSuggestion === "DC") { - roundTypes.push({ id: "TELEMEDICINE", text: t("TELEMEDICINE") }); + roundTypes.push("TELEMEDICINE"); } + const submitButtonDisabled = (() => { if (buttonText !== "Save") { return false; } - if (["VENTILATOR", "DOCTORS_LOG"].includes(state.form.rounds_type)) { + if ( + ["VENTILATOR", "DOCTORS_LOG", "COMMUNITY_NURSES_LOG"].includes( + state.form.rounds_type, + ) + ) { return false; } @@ -540,7 +595,7 @@ export const DailyRounds = (props: any) => { "additional_symptoms", ].includes(f), ) && - roundTypes.some((t) => t.id === "DOCTORS_LOG") + roundTypes.some((t) => t === "DOCTORS_LOG") ) { rounds_type = "DOCTORS_LOG"; } @@ -578,20 +633,15 @@ export const DailyRounds = (props: any) => {
option.text} - optionValue={(option) => option.id} />
@@ -611,63 +661,67 @@ export const DailyRounds = (props: any) => { /> - - + + - {state.form.rounds_type !== "DOCTORS_LOG" && ( + {state.form.rounds_type === "COMMUNITY_NURSES_LOG" && ( <> +
+

{t("routine")}

+ option.desc} - optionValue={(option) => option.text} - value={prevAction} - onChange={(event) => { - handleFormFieldChange(event); - setPreviousAction(event.value); - }} - /> - - option.text} - optionValue={(option) => option.id} - value={prevReviewInterval} - onChange={(event) => { - handleFormFieldChange(event); - setPreviousReviewInterval(Number(event.value)); - }} + {...selectField("bowel_issue", BOWEL_ISSUE_CHOICES)} /> +
+
{t("bladder")}
+ + + t(c ? "yes" : "no")} + /> + +
+
+
{t("nutrition")}
+ + + +
)} - {["NORMAL", "TELEMEDICINE", "DOCTORS_LOG"].includes( - state.form.rounds_type, - ) && ( + {[ + "NORMAL", + "TELEMEDICINE", + "DOCTORS_LOG", + "COMMUNITY_NURSES_LOG", + ].includes(state.form.rounds_type) && ( <> -

Vitals

+
+

{t("vitals")}

- + { }, ]} /> + + )} - + + + )} + + {["NORMAL", "TELEMEDICINE", "DOCTORS_LOG"].includes( + state.form.rounds_type, + ) && ( + <> + { { option.desc} optionValue={(option) => option.id} @@ -760,18 +843,19 @@ export const DailyRounds = (props: any) => { a.value), + )} options={CONSCIOUSNESS_LEVEL.map((level) => ({ label: t(`CONSCIOUSNESS_LEVEL__${level.value}`), value: level.value, }))} - optionDisplay={(option) => option.label} + optionLabel={(option) => option.label} optionValue={(option) => option.value} unselectLabel="Unknown" layout="vertical" @@ -779,6 +863,45 @@ export const DailyRounds = (props: any) => { )} + {state.form.rounds_type === "COMMUNITY_NURSES_LOG" && ( +
+
+
+

+ {t("prescription_medications")} +

+ + setShowDiscontinuedPrescriptions(value) + } + errorClassName="hidden" + /> +
+ +
+ )} + + {state.form.rounds_type === "COMMUNITY_NURSES_LOG" && ( +
+
+
+

{t("nursing_care")}

+
+ + handleFormFieldChange({ name: "nursing", value: log.nursing }) + } + /> +
+ )} + {state.form.rounds_type === "DOCTORS_LOG" && ( <>
@@ -861,6 +984,36 @@ export const DailyRounds = (props: any) => {
)} + + {state.form.rounds_type !== "DOCTORS_LOG" && ( + <> +
+ option.desc} + optionValue={(option) => option.text} + value={prevAction} + onChange={(event) => { + handleFormFieldChange(event); + setPreviousAction(event.value); + }} + /> + + option.text} + optionValue={(option) => option.id} + value={prevReviewInterval} + onChange={(event) => { + handleFormFieldChange(event); + setPreviousReviewInterval(Number(event.value)); + }} + /> + + )}