Skip to content

Commit

Permalink
add daily round fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
AshrafMd-1 committed Nov 30, 2023
1 parent 2ba0143 commit 011d9f1
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 30 deletions.
74 changes: 45 additions & 29 deletions src/Components/Facility/Consultations/Mews.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import { ConsultationModel } from "../models";
import useQuery from "../../../Utils/request/useQuery";
import routes from "../../../Redux/api";

export const Mews = (props: { consultationId: string }) => {
const { data: dailyRoundsData } = useQuery(routes.getDailyReports, {
pathParams: {
consultationId: props.consultationId,
},
query: {
rounds_type: "NORMAL,VENTILATOR,ICU",
limit: 1,
},
});

export const Mews = (props: {
rounds: ConsultationModel["last_daily_round"] | undefined;
}) => {
const respRange = [
[-Infinity, 7, 2],
[8, 8, 1],
Expand Down Expand Up @@ -39,13 +48,15 @@ export const Mews = (props: {
[101.4, Infinity, 2],
];

const consciousnessCalculator = (value: string) => {
const consciousnessCalculator = (value: string | undefined) => {
switch (value) {
case "Alert":
return 0;
case "RESPONDS_TO_VOICE" || "AGITATED_OR_CONFUSED":
case "RESPONDS_TO_VOICE":
case "AGITATED_OR_CONFUSED":
return 1;
case "RESPONDS_TO_PAIN" || "ONSET_OF_AGITATION_AND_CONFUSION":
case "RESPONDS_TO_PAIN":
case "ONSET_OF_AGITATION_AND_CONFUSION":
return 2;
case "UNRESPONSIVE":
return 3;
Expand Down Expand Up @@ -94,11 +105,14 @@ export const Mews = (props: {
<div className="tooltip mt-2">
<p className="my-auto text-center text-2xl font-bold">{data} </p>
<div className="tooltip-text tooltip-left text-sm font-medium lg:-translate-y-1/2">
<p>Respiratory rate : {props.rounds?.resp}</p>
<p>Heart rate : {props.rounds?.pulse}</p>
<p>Systolic BP : {props.rounds?.bp.systolic}</p>
<p>Temperature : {props.rounds?.temperature}</p>
<p>Consciousness Level : {props.rounds?.consciousness_level}</p>
<p>Respiratory rate : {dailyRoundsData?.results[0].resp}</p>
<p>Heart rate : {dailyRoundsData?.results[0].pulse}</p>
<p>Systolic BP : {dailyRoundsData?.results[0].bp?.systolic}</p>
<p>Temperature : {dailyRoundsData?.results[0].temperature}</p>
<p>
Consciousness Level :{" "}
{dailyRoundsData?.results[0].consciousness_level}
</p>
</div>
<div
className={`mt-2 flex h-4 w-full flex-col items-center justify-center rounded-b-lg ${getIndividualScore(
Expand All @@ -112,26 +126,24 @@ export const Mews = (props: {
};

const mewsScore = () => {
const lastDailyRound = props.rounds || {};
const lastDailyRound = dailyRoundsData?.results[0];

const score = {
resp: getIndividualScore(lastDailyRound.resp, respRange),
heartRate: getIndividualScore(lastDailyRound.pulse, heartRateRange),
resp: getIndividualScore(lastDailyRound?.resp, respRange),
heartRate: getIndividualScore(lastDailyRound?.pulse, heartRateRange),
systolicBloodPressure: getIndividualScore(
lastDailyRound.bp.systolic,
lastDailyRound?.bp?.systolic,
systolicBloodPressureRange
),
temperature: getIndividualScore(
lastDailyRound.temperature,
Number(lastDailyRound?.temperature),
temperatureRange
),
consciousnessLevel: consciousnessCalculator(
lastDailyRound.consciousness_level
lastDailyRound?.consciousness_level
),
};

console.log(score);

if (
score.resp === undefined ||
score.heartRate === undefined ||
Expand Down Expand Up @@ -162,14 +174,18 @@ export const Mews = (props: {
};

return (
<div
className="flex flex-col justify-start rounded-lg border border-black"
style={{
height: "fit-content",
}}
>
<p className="px-2 pt-2 text-center">Mews Score</p>
{mewsScore()}
</div>
<>
{dailyRoundsData?.results[0].rounds_type === "VENTILATOR" && (
<div
className="flex flex-col justify-start rounded-lg border border-black"
style={{
height: "fit-content",
}}
>
<p className="px-2 pt-2 text-center">Mews Score</p>
{mewsScore()}
</div>
)}
</>
);
};
2 changes: 1 addition & 1 deletion src/Components/Patient/PatientInfoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ export default function PatientInfoCard(props: {
</div>
{consultation?.last_daily_round && (
<div className="flex w-full justify-center bg-white px-4 py-2 lg:w-5/12 lg:flex-row lg:justify-end lg:p-6">
<Mews rounds={consultation?.last_daily_round} />
<Mews consultationId={props.consultationId} />
</div>
)}

Expand Down
1 change: 1 addition & 0 deletions src/Components/Patient/models.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ export interface DailyRoundsModel {
created_date?: string;
modified_date?: string;
taken_at?: string;
consciousness_level?: string;
rounds_type?: "NORMAL" | "VENTILATOR" | "ICU" | "AUTOMATED";
last_updated_by_telemedicine?: boolean;
created_by_telemedicine?: boolean;
Expand Down

0 comments on commit 011d9f1

Please sign in to comment.