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

change the NIBP display from last 30 mins to current bed assignment date #6479

Merged
merged 19 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import Chip from "../../../CAREUI/display/Chip";
import { formatAge, formatDate, formatDateTime } from "../../../Utils/utils";
import ReadMore from "../../Common/components/Readmore";
import { DailyRoundsList } from "../Consultations/DailyRoundsList";
import useQuery from "../../../Utils/request/useQuery";
import routes from "../../../Redux/api";
import * as Notification from "../../../Utils/Notifications.js";

const PageTitle = lazy(() => import("../../Common/PageTitle"));

Expand All @@ -23,6 +26,7 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => {
const [ventilatorSocketUrl, setVentilatorSocketUrl] = useState<string>();
const [monitorBedData, setMonitorBedData] = useState<AssetBedModel>();
const [ventilatorBedData, setVentilatorBedData] = useState<AssetBedModel>();
const [bedAssignmentStartDate, setBedAssignmentStartDate] = useState("");
rithviknishad marked this conversation as resolved.
Show resolved Hide resolved

const vitals = useVitalsAspectRatioConfig({
default: undefined,
Expand Down Expand Up @@ -104,6 +108,21 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => {
fetchData();
}, [props.consultationData]);

useQuery(routes.listConsultationBeds, {
query: {
consultation: props.consultationId,
},
onResponse: ({ res, data }) => {
if (res?.ok && data) {
setBedAssignmentStartDate(data.results[0].created_date);
} else {
Notification.Error({
msg: "Something went wrong: ",
});
}
},
});
rithviknishad marked this conversation as resolved.
Show resolved Hide resolved

return (
<div className="flex flex-col gap-2">
{!props.consultationData.discharge_date &&
Expand All @@ -113,6 +132,7 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => {
<div className="mx-auto flex w-full flex-col justify-between gap-1 rounded bg-[#020617] lg:w-auto lg:min-w-[1280px] lg:flex-row">
<div className="min-h-[400px] flex-1">
<HL7PatientVitalsMonitor
patientCurrentBedAssignmentDate={bedAssignmentStartDate}
patientAssetBed={{
asset: monitorBedData?.asset_object as AssetData,
bed: monitorBedData?.bed_object as BedModel,
Expand Down
10 changes: 10 additions & 0 deletions src/Components/Facility/models.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ProcedureType } from "../Common/prescription-builder/ProcedureBuilder";
import { NormalPrescription, PRNPrescription } from "../Medicine/models";
import { AssetData } from "../Assets/AssetTypes";
import { UserBareMinimum } from "../Users/models";
import { PaginatedResponse } from "../../Utils/request/types";

export interface LocalBodyModel {
name: string;
Expand Down Expand Up @@ -222,6 +223,15 @@ export interface CurrentBed {
meta: Record<string, any>;
}

export interface ConsultationBedRequest {
bed?: string;
consultation: string;
limit?: number;
offset?: number;
}
rithviknishad marked this conversation as resolved.
Show resolved Hide resolved

export type ConsultationBedResponse = PaginatedResponse<CurrentBed>;
rithviknishad marked this conversation as resolved.
Show resolved Hide resolved

// Voluntarily made as `type` for it to achieve type-safety when used with
// `useAsyncOptions<ICD11DiagnosisModel>`
export type ICD11DiagnosisModel = {
Expand Down
17 changes: 16 additions & 1 deletion src/Components/VitalsMonitor/HL7PatientVitalsMonitor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,23 @@ export default function HL7PatientVitalsMonitor(props: IVitalsComponentProps) {
connect(props.socketUrl);
}, [props.socketUrl]);

// Check if the time difference is within the specified maximum persistence time
const currentDate = new Date();
const bedAssignmentStartDate = props.patientCurrentBedAssignmentDate
? new Date(props.patientCurrentBedAssignmentDate)
: undefined;

const minutesSinceCurrentBedAssignment =
bedAssignmentStartDate &&
(currentDate.getTime() - bedAssignmentStartDate.getTime()) / (1000 * 60);
console.log(
"minutesSinceCurrentBedAssignment",
minutesSinceCurrentBedAssignment
);
rithviknishad marked this conversation as resolved.
Show resolved Hide resolved
const bpWithinMaxPersistence = !!(
(data.bp?.["date-time"] && isWithinMinutes(data.bp?.["date-time"], 30)) // Max blood pressure persistence is 30 minutes
data.bp?.["date-time"] &&
minutesSinceCurrentBedAssignment !== undefined && // Check if minutesSinceCurrentBedAssignment is defined
isWithinMinutes(data.bp?.["date-time"], minutesSinceCurrentBedAssignment)
);

return (
Expand Down
1 change: 1 addition & 0 deletions src/Components/VitalsMonitor/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export interface ChannelOptions {
}

export interface IVitalsComponentProps {
patientCurrentBedAssignmentDate?: string;
patientAssetBed?: PatientAssetBed;
socketUrl: string;
config?: ReturnType<typeof getVitalsCanvasSizeAndDuration>;
Expand Down
5 changes: 5 additions & 0 deletions src/Redux/api.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { IConfig } from "../Common/hooks/useConfig";

import {
IAadhaarOtp,
IAadhaarOtpTBody,
Expand Down Expand Up @@ -28,6 +29,8 @@ import {
AssetUpdate,
} from "../Components/Assets/AssetTypes";
import {
ConsultationBedRequest,
ConsultationBedResponse,
FacilityModel,
LocationModel,
WardModel,
Expand Down Expand Up @@ -350,6 +353,8 @@ const routes = {
listConsultationBeds: {
path: "/api/v1/consultationbed/",
method: "GET",
TRes: Type<ConsultationBedResponse>(),
TBody: Type<ConsultationBedRequest>(),
rithviknishad marked this conversation as resolved.
Show resolved Hide resolved
},
createConsultationBed: {
path: "/api/v1/consultationbed/",
Expand Down
Loading