)}
diff --git a/src/Components/Facility/PatientConsultationNotesList.tsx b/src/Components/Facility/PatientConsultationNotesList.tsx
index 35822508d4b..e7e0bb25504 100644
--- a/src/Components/Facility/PatientConsultationNotesList.tsx
+++ b/src/Components/Facility/PatientConsultationNotesList.tsx
@@ -2,7 +2,7 @@ import { Dispatch, SetStateAction, useEffect, useState } from "react";
import { RESULTS_PER_PAGE_LIMIT } from "../../Common/constants";
import CircularProgress from "../Common/components/CircularProgress";
import routes from "../../Redux/api";
-import { PatientNoteStateType } from "./models";
+import { PatientNoteStateType, PatientNotesModel } from "./models";
import useSlug from "../../Common/hooks/useSlug";
import DoctorNote from "./DoctorNote";
import request from "../../Utils/request/request";
@@ -13,12 +13,13 @@ interface PatientNotesProps {
reload?: boolean;
setReload?: (value: boolean) => void;
disableEdit?: boolean;
+ thread: PatientNotesModel["thread"];
}
const pageSize = RESULTS_PER_PAGE_LIMIT;
const PatientConsultationNotesList = (props: PatientNotesProps) => {
- const { state, setState, reload, setReload, disableEdit } = props;
+ const { state, setState, reload, setReload, disableEdit, thread } = props;
const consultationId = useSlug("consultation") ?? "";
const [isLoading, setIsLoading] = useState(true);
@@ -31,6 +32,7 @@ const PatientConsultationNotesList = (props: PatientNotesProps) => {
},
query: {
consultation: consultationId,
+ thread,
offset: (state.cPage - 1) * RESULTS_PER_PAGE_LIMIT,
},
});
@@ -60,6 +62,10 @@ const PatientConsultationNotesList = (props: PatientNotesProps) => {
}
}, [reload]);
+ useEffect(() => {
+ fetchNotes();
+ }, [thread]);
+
useEffect(() => {
setReload?.(true);
}, []);
@@ -76,7 +82,7 @@ const PatientConsultationNotesList = (props: PatientNotesProps) => {
if (isLoading && !state.notes.length) {
return (
-
+
);
diff --git a/src/Components/Facility/PatientNotesList.tsx b/src/Components/Facility/PatientNotesList.tsx
index a36762072b9..9585ace5db7 100644
--- a/src/Components/Facility/PatientNotesList.tsx
+++ b/src/Components/Facility/PatientNotesList.tsx
@@ -2,7 +2,7 @@ import { useState, useEffect } from "react";
import { RESULTS_PER_PAGE_LIMIT } from "../../Common/constants";
import CircularProgress from "../Common/components/CircularProgress";
import DoctorNote from "./DoctorNote";
-import { PatientNoteStateType } from "./models";
+import { PatientNoteStateType, PatientNotesModel } from "./models";
import routes from "../../Redux/api";
import request from "../../Utils/request/request";
@@ -13,12 +13,13 @@ interface PatientNotesProps {
facilityId: string;
reload?: boolean;
setReload?: any;
+ thread: PatientNotesModel["thread"];
}
const pageSize = RESULTS_PER_PAGE_LIMIT;
const PatientNotesList = (props: PatientNotesProps) => {
- const { state, setState, reload, setReload } = props;
+ const { state, setState, reload, setReload, thread } = props;
const [isLoading, setIsLoading] = useState(true);
@@ -26,7 +27,10 @@ const PatientNotesList = (props: PatientNotesProps) => {
setIsLoading(true);
const { data }: any = await request(routes.getPatientNotes, {
pathParams: { patientId: props.patientId },
- query: { offset: (state.cPage - 1) * RESULTS_PER_PAGE_LIMIT },
+ query: {
+ offset: (state.cPage - 1) * RESULTS_PER_PAGE_LIMIT,
+ thread,
+ },
});
if (state.cPage === 1) {
@@ -52,6 +56,10 @@ const PatientNotesList = (props: PatientNotesProps) => {
}
}, [reload]);
+ useEffect(() => {
+ fetchNotes();
+ }, [thread]);
+
useEffect(() => {
setReload(true);
}, []);
@@ -68,7 +76,7 @@ const PatientNotesList = (props: PatientNotesProps) => {
if (isLoading && !state.notes.length) {
return (
-
+
);
diff --git a/src/Components/Facility/PatientNotesSlideover.tsx b/src/Components/Facility/PatientNotesSlideover.tsx
index 038b980d24b..3fd46f92f57 100644
--- a/src/Components/Facility/PatientNotesSlideover.tsx
+++ b/src/Components/Facility/PatientNotesSlideover.tsx
@@ -14,6 +14,7 @@ import useKeyboardShortcut from "use-keyboard-shortcut";
import AutoExpandingTextInputFormField from "../Form/FormFields/AutoExpandingTextInputFormField.js";
import * as Sentry from "@sentry/browser";
import useAuthUser from "../../Common/hooks/useAuthUser";
+import { PATIENT_NOTES_THREADS } from "../../Common/constants.js";
interface PatientNotesProps {
patientId: string;
@@ -23,6 +24,12 @@ interface PatientNotesProps {
}
export default function PatientNotesSlideover(props: PatientNotesProps) {
+ const authUser = useAuthUser();
+ const [thread, setThread] = useState(
+ authUser.user_type === "Nurse"
+ ? PATIENT_NOTES_THREADS.Nurses
+ : PATIENT_NOTES_THREADS.Doctors,
+ );
const [show, setShow] = useState(true);
const [patientActive, setPatientActive] = useState(true);
const [reload, setReload] = useState(false);
@@ -39,11 +46,11 @@ export default function PatientNotesSlideover(props: PatientNotesProps) {
const subscription = await reg.pushManager.getSubscription();
if (!subscription && !res.data?.pf_endpoint) {
Notification.Warn({
- msg: "Please subscribe to notifications to get live updates on doctor notes.",
+ msg: "Please subscribe to notifications to get live updates on discussion notes.",
});
} else if (subscription?.endpoint !== res.data?.pf_endpoint) {
Notification.Warn({
- msg: "Please subscribe to notifications on this device to get live updates on doctor notes.",
+ msg: "Please subscribe to notifications on this device to get live updates on discussion notes.",
});
}
} catch (error) {
@@ -73,10 +80,6 @@ export default function PatientNotesSlideover(props: PatientNotesProps) {
);
const onAddNote = async () => {
- const payload = {
- note: noteField,
- consultation: consultationId,
- };
if (!/\S+/.test(noteField)) {
Notification.Error({
msg: "Note Should Contain At Least 1 Character",
@@ -85,7 +88,11 @@ export default function PatientNotesSlideover(props: PatientNotesProps) {
}
const { res } = await request(routes.addPatientNote, {
pathParams: { patientId: patientId },
- body: payload,
+ body: {
+ note: noteField,
+ consultation: consultationId,
+ thread,
+ },
});
if (res?.status === 201) {
Notification.Success({ msg: "Note added successfully" });
@@ -189,23 +196,43 @@ export default function PatientNotesSlideover(props: PatientNotesProps) {
className="flex w-full cursor-pointer items-center justify-around rounded-t-md bg-primary-800 p-2 text-white"
onClick={() => setShow(!show)}
>
-
{"Doctor's Notes"}
+
Discussion Notes
{notesActionIcons}
) : (
- {/* Doctor Notes Header */}
- {"Doctor's Notes"}
+ Discussion Notes
{notesActionIcons}
- {/* Doctor Notes Body */}
+
+ {Object.values(PATIENT_NOTES_THREADS).map((current) => (
+
+ ))}
+
{
const { patientId, facilityId } = props;
+ const authUser = useAuthUser();
+ const [thread, setThread] = useState(
+ authUser.user_type === "Nurse"
+ ? PATIENT_NOTES_THREADS.Nurses
+ : PATIENT_NOTES_THREADS.Doctors,
+ );
+
const [patientActive, setPatientActive] = useState(true);
const [noteField, setNoteField] = useState("");
const [reload, setReload] = useState(false);
@@ -33,9 +43,6 @@ const PatientNotes = (props: PatientNotesProps) => {
const [state, setState] = useState(initialData);
const onAddNote = async () => {
- const payload = {
- note: noteField,
- };
if (!/\S+/.test(noteField)) {
Notification.Error({
msg: "Note Should Contain At Least 1 Character",
@@ -45,7 +52,10 @@ const PatientNotes = (props: PatientNotesProps) => {
const { res } = await request(routes.addPatientNote, {
pathParams: { patientId: patientId },
- body: payload,
+ body: {
+ note: noteField,
+ thread,
+ },
});
if (res?.status === 201) {
Notification.Success({ msg: "Note added successfully" });
@@ -93,7 +103,28 @@ const PatientNotes = (props: PatientNotesProps) => {
}}
backUrl={`/facility/${facilityId}/patient/${patientId}`}
>
-
+
+
+ {Object.values(PATIENT_NOTES_THREADS).map((current) => (
+
+ ))}
+
{
facilityId={facilityId}
reload={reload}
setReload={setReload}
+ thread={thread}
/>
diff --git a/src/Redux/api.tsx b/src/Redux/api.tsx
index eb924f03c51..82ae52f26a4 100644
--- a/src/Redux/api.tsx
+++ b/src/Redux/api.tsx
@@ -753,6 +753,9 @@ const routes = {
path: "/api/v1/patient/{patientId}/notes/",
method: "POST",
TRes: Type
(),
+ TBody: Type<
+ Pick & { consultation?: string }
+ >(),
},
updatePatientNote: {
path: "/api/v1/patient/{patientId}/notes/{noteId}/",