Skip to content

Commit

Permalink
Merge branch 'develop' into localstorage
Browse files Browse the repository at this point in the history
  • Loading branch information
shramanpaul authored Dec 30, 2023
2 parents 4177a3f + 8aea0cc commit 15f80d7
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 92 deletions.
8 changes: 5 additions & 3 deletions src/CAREUI/display/RecordMeta.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import CareIcon from "../icons/CareIcon";
import {
formatDateTime,
formatDate,
formatName,
formatTime,
isUserOnline,
relativeTime,
} from "../../Utils/utils";
Expand Down Expand Up @@ -37,8 +38,9 @@ const RecordMeta = ({
let child = (
<div className="tooltip">
<span className="underline">{relativeTime(time)}</span>
<span className="tooltip-text tooltip-left flex gap-1 text-xs font-medium tracking-wider">
{formatDateTime(time)}
<span className="tooltip-text tooltip-bottom flex -translate-x-1/2 gap-1 text-xs font-medium tracking-wider">
{formatTime(time)} <br />
{formatDate(time)}
{user && !inlineUser && (
<span className="flex items-center gap-1">
by
Expand Down
2 changes: 1 addition & 1 deletion src/CAREUI/misc/PaginatedList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ interface ItemsProps<TItem> {
const Items = <TItem extends object>(props: ItemsProps<TItem>) => {
const { loading, items } = useContextualized<TItem>();

if (loading) {
if (loading || items.length === 0) {
return null;
}

Expand Down
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
24 changes: 11 additions & 13 deletions src/Components/Facility/BedManagement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,24 +182,22 @@ export const BedManagement = (props: BedManagementProps) => {
));
} else if (data?.results.length === 0) {
BedList = (
<p className="flex w-full justify-center border-b border-gray-200 bg-white p-5 text-center text-2xl font-bold text-gray-500">
<p className="flex w-full justify-center bg-white p-5 text-center text-2xl font-bold text-gray-500">
No beds available in this location
</p>
);
}

if (data?.results.length) {
bed = (
<>
<div className="mt-5 flex grow flex-wrap bg-white p-4">{BedList}</div>
{data.count && (
<div className="mt-4 flex w-full justify-center">
<Pagination totalCount={data.count} />
</div>
)}
</>
);
}
bed = (
<>
<div className="mt-5 flex grow flex-wrap bg-white p-4">{BedList}</div>
{Boolean(data?.count && data.count > 0) && (
<div className="mt-4 flex w-full justify-center">
<Pagination totalCount={data?.count ?? 0} />
</div>
)}
</>
);

if (loading) {
return <Loading />;
Expand Down
4 changes: 4 additions & 0 deletions src/Components/Facility/ConsultationDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ const symptomChoices = [...SYMPTOM_CHOICES];

export interface ConsultationTabProps {
consultationId: string;
facilityId: string;
patientId: string;
consultationData: ConsultationModel;
patientData: PatientModel;
}
Expand Down Expand Up @@ -189,6 +191,8 @@ export const ConsultationDetails = (props: any) => {
const consultationTabProps: ConsultationTabProps = {
consultationId,
consultationData,
patientId: consultationData.patient,
facilityId: consultationData.facility,
patientData,
};

Expand Down
14 changes: 7 additions & 7 deletions src/Components/Facility/LocationManagement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ export default function LocationManagement({ facilityId }: Props) {
Add New Location
</ButtonV2>
</div>
<PaginatedList.WhenEmpty className="flex w-full justify-center border-b border-gray-200 bg-white p-5 text-center text-2xl font-bold text-gray-500">
<span>No locations available</span>
</PaginatedList.WhenEmpty>

<PaginatedList.WhenLoading>
<Loading />
</PaginatedList.WhenLoading>
<div className="w-full @container">
<PaginatedList.WhenEmpty className="flex w-full justify-center border-b border-gray-200 bg-white p-5 text-center text-2xl font-bold text-gray-500">
<span>No locations available</span>
</PaginatedList.WhenEmpty>

<PaginatedList.WhenLoading>
<Loading />
</PaginatedList.WhenLoading>
<PaginatedList.Items<LocationModel> className="my-8 grid gap-3 @4xl:grid-cols-2 @6xl:grid-cols-3 @[100rem]:grid-cols-4 lg:mx-8">
{(item) => <Location {...item} />}
</PaginatedList.Items>
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Facility/models.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ export interface ConsultationModel {
discharge_notes?: string;
examination_details?: string;
history_of_present_illness?: string;
facility?: number;
facility: string;
facility_name?: string;
id: string;
modified_date?: string;
other_symptoms?: string;
patient?: string;
patient: string;
treatment_plan?: string;
referred_to?: FacilityModel["id"];
referred_to_object?: FacilityModel;
Expand Down
116 changes: 51 additions & 65 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,8 +135,37 @@ export const DailyRounds = (props: any) => {
"consciousness_level",
];

useEffect(() => {
(async () => {
const fetchRoundDetails = useCallback(
async (status: statusType) => {
setIsLoading(true);
let formData: any = initialData;
if (id) {
const res = await dispatchAction(
getConsultationDailyRoundsDetails({ consultationId, id })
);

if (!status.aborted) {
if (res?.data) {
const data = {
...res.data,
patient_category: res.data.patient_category
? PATIENT_CATEGORIES.find(
(i) => i.text === res.data.patient_category
)?.id ?? ""
: "",
rhythm:
(res.data.rhythm &&
RHYTHM_CHOICES.find((i) => i.text === res.data.rhythm)?.id) ||
"0",
admitted_to: res.data.admitted_to
? res.data.admitted_to
: "Select",
};
formData = { ...formData, ...data };
}
}
}
setIsLoading(false);
if (patientId) {
const res = await dispatchAction(getPatient({ id: patientId }));
if (res.data) {
Expand All @@ -154,71 +183,20 @@ export const DailyRounds = (props: any) => {
...initialData,
action: getAction,
});
dispatch({
type: "set_form",
form: {
...state.form,
action: getAction,
},
});
formData = { ...formData, ...{ action: getAction } };
}
} else {
setPatientName("");
setFacilityName("");
}
})();
}, [dispatchAction, patientId]);

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

if (!status.aborted) {
if (res?.data) {
const data = {
...res.data,
patient_category: res.data.patient_category
? PATIENT_CATEGORIES.find(
(i) => i.text === res.data.patient_category
)?.id ?? ""
: "",
rhythm:
(res.data.rhythm &&
RHYTHM_CHOICES.find((i) => i.text === res.data.rhythm)?.id) ||
"0",
admitted_to: res.data.admitted_to ? res.data.admitted_to : "Select",
};
dispatch({ type: "set_form", form: data });
setInitialData(data);
}
setIsLoading(false);
}
},
[consultationId, id, dispatchAction]
);
useAbortableEffect(
(status: statusType) => {
if (id) {
fetchRoundDetails(status);
}
},
[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 +207,20 @@ 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,
},
});
};
}
})();
}, [dispatchAction, consultationId, id]);
dispatch({ type: "set_form", form: formData });
setInitialData(formData);
},
[consultationId, id, dispatchAction, patientId]
);
useAbortableEffect(
(status: statusType) => {
fetchRoundDetails(status);
},
[dispatchAction, fetchRoundDetails]
);

const validateForm = () => {
const errors = { ...initError };
Expand Down Expand Up @@ -311,9 +297,9 @@ export const DailyRounds = (props: any) => {
}
: undefined,
pulse: state.form.pulse,
resp: Number(state.form.resp),
resp: state.form.resp,
temperature: state.form.temperature,
rhythm: Number(state.form.rhythm) || 0,
rhythm: state.form.rhythm || 0,
rhythm_detail: state.form.rhythm_detail,
ventilator_spo2: state.form.ventilator_spo2,
consciousness_level: state.form.consciousness_level,
Expand Down

0 comments on commit 15f80d7

Please sign in to comment.