Skip to content

Commit

Permalink
Fixed null issue in review_interval in DailyRounds (#3815)
Browse files Browse the repository at this point in the history
  • Loading branch information
khavinshankar authored Oct 25, 2022
1 parent 9872c75 commit 14b24c2
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 57 deletions.
7 changes: 4 additions & 3 deletions src/Components/Facility/ConsultationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ const initForm: FormDetails = {
assigned_to: "",
assigned_to_object: null,
special_instruction: "",
review_interval: 0,
review_interval: -1,
weight: "",
height: "",
bed: null,
Expand Down Expand Up @@ -265,7 +265,8 @@ export const ConsultationForm = (props: any) => {
admitted: res.data.admitted ? String(res.data.admitted) : "false",
admitted_to: res.data.admitted_to ? res.data.admitted_to : "",
category: res.data.category
? PATIENT_CATEGORIES.find((i) => i.text === res.data.category)?.id || "Comfort"
? PATIENT_CATEGORIES.find((i) => i.text === res.data.category)
?.id || "Comfort"
: "Comfort",
ip_no: res.data.ip_no ? res.data.ip_no : "",
verified_by: res.data.verified_by ? res.data.verified_by : "",
Expand Down Expand Up @@ -1050,7 +1051,7 @@ export const ConsultationForm = (props: any) => {
variant="standard"
value={state.form.review_interval}
options={[
{ id: "", text: "select" },
{ id: -1, text: "select" },
...REVIEW_AT_CHOICES,
]}
onChange={handleChange}
Expand Down
1 change: 1 addition & 0 deletions src/Components/Facility/models.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export interface ConsultationModel {
lines?: any;
last_daily_round?: any;
current_bed?: CurrentBed;
review_interval?: number;
}
export interface PatientStatsModel {
id?: number;
Expand Down
22 changes: 15 additions & 7 deletions src/Components/Patient/DailyRounds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const initForm: any = {
current_health: 0,
recommend_discharge: false,
actions: null,
review_interval: null,
review_interval: 0,
admitted_to: "",
taken_at: null,
rounds_type: "NORMAL",
Expand Down Expand Up @@ -107,7 +107,7 @@ export const DailyRounds = (props: any) => {
const [isLoading, setIsLoading] = useState(false);
const [facilityName, setFacilityName] = useState("");
const [patientName, setPatientName] = useState("");
const [prevReviewInterval, setPreviousReviewInterval] = useState("");
const [prevReviewInterval, setPreviousReviewInterval] = useState(-1);
const [hasPreviousLog, setHasPreviousLog] = useState(false);
const headerText = !id ? "Add Consultation Update" : "Info";
const buttonText = !id ? "Save" : "Continue";
Expand Down Expand Up @@ -156,7 +156,9 @@ export const DailyRounds = (props: any) => {
if (res.data) {
setPatientName(res.data.name);
setFacilityName(res.data.facility_object.name);
setPreviousReviewInterval(res.data.last_consultation.review_interval);
setPreviousReviewInterval(
Number(res.data.last_consultation.review_interval)
);
}
} else {
setPatientName("");
Expand Down Expand Up @@ -243,6 +245,8 @@ export const DailyRounds = (props: any) => {
return map.toFixed(2);
};

console.log(state.form.review_interval);

const handleSubmit = async (e: any) => {
e.preventDefault();
const validForm = validateForm();
Expand Down Expand Up @@ -275,7 +279,9 @@ export const DailyRounds = (props: any) => {
consultation: consultationId,
recommend_discharge: JSON.parse(state.form.recommend_discharge),
action: state.form.action,
review_interval: state.form.review_interval,
review_interval: Number(
state.form.review_interval || prevReviewInterval
),
// bed: isTeleicu === "true" ? state.form.bed : undefined,
};
if (state.form.rounds_type === "NORMAL") {
Expand Down Expand Up @@ -460,8 +466,10 @@ export const DailyRounds = (props: any) => {
};

const getExpectedReviewTime = () => {
const nextReviewTime = state.form.review_interval || prevReviewInterval;
if (Number(nextReviewTime))
const nextReviewTime = Number(
state.form.review_interval || prevReviewInterval
);
if (nextReviewTime > 0)
return `Review before ${formatDate(
moment().add(nextReviewTime, "minutes").toDate()
)}`;
Expand Down Expand Up @@ -674,7 +682,7 @@ export const DailyRounds = (props: any) => {
variant="standard"
value={state.form.review_interval || prevReviewInterval}
options={[
{ id: 0, text: "select" },
{ id: -1, text: "select" },
...REVIEW_AT_CHOICES,
]}
onChange={handleChange}
Expand Down
17 changes: 10 additions & 7 deletions src/Components/Patient/ManagePatients.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -566,13 +566,16 @@ export const PatientManager = (props: any) => {
)}
<div className="flex w-full">
<div className="flex flex-wrap gap-2 flex-row justify-start">
{moment().isAfter(patient.review_time) && (
<Badge
color="red"
startIcon="clock"
text="Review Missed"
/>
)}
{patient.review_time &&
!patient.last_consultation?.discharge_date &&
Number(patient.last_consultation?.review_interval) > 0 &&
moment().isAfter(patient.review_time) && (
<Badge
color="red"
startIcon="clock"
text="Review Missed"
/>
)}
{patient.allow_transfer ? (
<Badge
color="yellow"
Expand Down
35 changes: 19 additions & 16 deletions src/Components/Patient/PatientHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -670,22 +670,25 @@ export const PatientHome = (props: any) => {
className="space-y-2 flex-col justify-between flex h-full"
>
<div>
{patientData.review_time && (
<div
className={
"mb-2 inline-flex items-center px-3 py-1 rounded-lg text-xs leading-4 font-semibold p-1 w-full justify-center border-gray-500 border " +
(moment().isBefore(patientData.review_time)
? " bg-gray-100"
: " p-1 bg-red-400 text-white")
}
>
<i className="mr-2 text-md fas fa-clock"></i>
{(moment().isBefore(patientData.review_time)
? "Review before: "
: "Review Missed: ") +
formatDate(patientData.review_time)}
</div>
)}
{patientData.review_time &&
!patientData.last_consultation?.discharge_date &&
Number(patientData.last_consultation?.review_interval) >
0 && (
<div
className={
"mb-2 inline-flex items-center px-3 py-1 rounded-lg text-xs leading-4 font-semibold p-1 w-full justify-center border-gray-500 border " +
(moment().isBefore(patientData.review_time)
? " bg-gray-100"
: " p-1 bg-red-400 text-white")
}
>
<i className="mr-2 text-md fas fa-clock"></i>
{(moment().isBefore(patientData.review_time)
? "Review before: "
: "Review Missed: ") +
formatDate(patientData.review_time)}
</div>
)}
<div className="p-2 bg-white rounded-lg shadow text-center">
<div className="flex justify-between">
<div className="w-1/2 border-r-2 truncate">
Expand Down
42 changes: 18 additions & 24 deletions src/Components/TeleIcu/Patient/InfoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ const PatientCategoryDisplayText: Record<PatientCategory, string> = {
unknown: "UNKNOWN",
};

const PatientCategoryClasses: Record<PatientCategory, string> = {
"Comfort Care": "h-10",
Stable: "h-6",
"Slightly Abnormal": "h-10",
Critical: "h-6",
unknown: "h-6",
};

export default function TeleICUPatientInfoCard(props: {
patient: PatientModel;
ip_no?: string | undefined;
Expand Down Expand Up @@ -116,22 +108,24 @@ export default function TeleICUPatientInfoCard(props: {
{patient.name}
</div>
<div>
{patient.review_time && (
<div
className={
"mb-2 inline-flex items-center px-3 py-1 rounded-lg text-xs leading-4 font-semibold p-1 w-full justify-center border-gray-500 border " +
(moment().isBefore(patient.review_time)
? " bg-gray-100"
: " p-1 bg-red-400 text-white")
}
>
<i className="mr-2 text-md fas fa-clock"></i>
{(moment().isBefore(patient.review_time)
? "Review before: "
: "Review Missed: ") +
moment(patient.review_time).format("lll")}
</div>
)}
{patient.review_time &&
!patient.last_consultation?.discharge_date &&
Number(patient.last_consultation?.review_interval) > 0 && (
<div
className={
"mb-2 inline-flex items-center px-3 py-1 rounded-lg text-xs leading-4 font-semibold p-1 w-full justify-center border-gray-500 border " +
(moment().isBefore(patient.review_time)
? " bg-gray-100"
: " p-1 bg-red-400 text-white")
}
>
<i className="mr-2 text-md fas fa-clock"></i>
{(moment().isBefore(patient.review_time)
? "Review before: "
: "Review Missed: ") +
moment(patient.review_time).format("lll")}
</div>
)}
</div>
<div className="flex flex-col sm:flex-row items-center gap-1 lg:mb-2">
<Link
Expand Down

0 comments on commit 14b24c2

Please sign in to comment.