Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update consciousness level constants #6947

Merged
merged 1 commit into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Common/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ export const CONSCIOUSNESS_LEVEL = [
{ id: "ALERT", text: "Alert" },
{ id: "AGITATED_OR_CONFUSED", text: "Agitated or Confused" },
{
id: "Onset of Agitation and Confusion",
id: "ONSET_OF_AGITATION_AND_CONFUSION",
text: "Onset of Agitation and Confusion",
},
{ id: "UNKNOWN", text: "Unknown" },
Expand Down
103 changes: 44 additions & 59 deletions src/Components/Patient/DailyRounds.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { navigate } from "raviger";

import dayjs from "dayjs";
import { lazy, useCallback, useEffect, useState } from "react";
import { lazy, useCallback, useState } from "react";
import { useDispatch } from "react-redux";
import {
CONSCIOUSNESS_LEVEL,
Expand Down Expand Up @@ -61,7 +61,7 @@ const initForm: any = {
rhythm: "0",
rhythm_detail: "",
ventilator_spo2: null,
consciousness_level: "Unknown",
consciousness_level: "UNKNOWN",
// bed: null,
};

Expand Down Expand Up @@ -135,47 +135,15 @@ export const DailyRounds = (props: any) => {
"consciousness_level",
];

useEffect(() => {
(async () => {
if (patientId) {
const res = await dispatchAction(getPatient({ id: patientId }));
if (res.data) {
setPatientName(res.data.name);
setFacilityName(res.data.facility_object.name);
setConsultationSuggestion(res.data.last_consultation?.suggestion);
setPreviousReviewInterval(
Number(res.data.last_consultation.review_interval)
);
const getAction =
TELEMEDICINE_ACTIONS.find((action) => action.id === res.data.action)
?.text || "NO_ACTION";
setPreviousAction(getAction);
setInitialData({
...initialData,
action: getAction,
});
dispatch({
type: "set_form",
form: {
...state.form,
action: getAction,
},
});
}
} else {
setPatientName("");
setFacilityName("");
}
})();
}, [dispatchAction, patientId]);

const fetchRoundDetails = useCallback(
async (status: statusType) => {
setIsLoading(true);
const res = await dispatchAction(
getConsultationDailyRoundsDetails({ consultationId, id })
);

let formData: any = {};

if (!status.aborted) {
if (res?.data) {
const data = {
Expand All @@ -191,34 +159,41 @@ export const DailyRounds = (props: any) => {
"0",
admitted_to: res.data.admitted_to ? res.data.admitted_to : "Select",
};
dispatch({ type: "set_form", form: data });
setInitialData(data);
formData = { ...formData, ...data };
}
setIsLoading(false);
}
},
[consultationId, id, dispatchAction]
);
useAbortableEffect(
(status: statusType) => {
if (id) {
fetchRoundDetails(status);
if (patientId) {
const res = await dispatchAction(getPatient({ id: patientId }));
if (res.data) {
setPatientName(res.data.name);
setFacilityName(res.data.facility_object.name);
setConsultationSuggestion(res.data.last_consultation?.suggestion);
setPreviousReviewInterval(
Number(res.data.last_consultation.review_interval)
);
const getAction =
TELEMEDICINE_ACTIONS.find((action) => action.id === res.data.action)
?.text || "NO_ACTION";
setPreviousAction(getAction);
setInitialData({
...initialData,
action: getAction,
});
formData = { ...formData, ...{ action: getAction } };
}
} else {
setPatientName("");
setFacilityName("");
}
},
[dispatchAction, fetchRoundDetails]
);

useEffect(() => {
(async () => {
if (consultationId && !id) {
const res = await dispatchAction(
getDailyReport({ limit: 1, offset: 0 }, { consultationId })
);
setHasPreviousLog(res.data.count > 0);
dispatch({
type: "set_form",
form: {
...state.form,
formData = {
...formData,
...{
patient_category: res.data.patient_category
? PATIENT_CATEGORIES.find(
(i) => i.text === res.data.patient_category
Expand All @@ -229,12 +204,22 @@ export const DailyRounds = (props: any) => {
RHYTHM_CHOICES.find((i) => i.text === res.data.rhythm)?.id) ||
"0",
temperature: parseFloat(res.data.temperature),
// clone_last: res.data.count > 0 ? true : false,
},
});
};
}
dispatch({ type: "set_form", form: formData });
setInitialData(formData);
},
[consultationId, id, dispatchAction, patientId]
);
useAbortableEffect(
(status: statusType) => {
if (id) {
fetchRoundDetails(status);
}
})();
}, [dispatchAction, consultationId, id]);
},
[dispatchAction, fetchRoundDetails]
);

const validateForm = () => {
const errors = { ...initError };
Expand Down
Loading