Skip to content

Commit

Permalink
fix NIBP visibility bug in Vitals Monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
sriharsh05 committed Nov 1, 2023
1 parent d2daf7a commit 365bf7a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => {
<div className="min-h-[400px] flex-1">
<HL7PatientVitalsMonitor
key={`hl7-${hl7SocketUrl}-${vitals.hash}`}
patientCurrentBedAssignmentDate={
props.patientData?.last_consultation?.current_bed
?.start_date
}
patientAssetBed={{
asset: monitorBedData?.asset_object as AssetData,
bed: monitorBedData?.bed_object as BedModel,
Expand Down
23 changes: 10 additions & 13 deletions src/Components/VitalsMonitor/HL7PatientVitalsMonitor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ const minutesAgo = (timestamp: string) => {
return `${dayjs().diff(dayjs(timestamp), "minute")}m ago`;
};

const isWithinMinutes = (timestamp: string, minutes: number) => {
return dayjs().diff(dayjs(timestamp), "minute") < minutes;
const isWithinMinutes = (timestamp: string, bedAssignmentStartDate: string) => {
return (
dayjs().diff(dayjs(timestamp), "minute") <
dayjs().diff(dayjs(bedAssignmentStartDate), "minute")
);
};

export default function HL7PatientVitalsMonitor(props: IVitalsComponentProps) {
Expand All @@ -39,19 +42,13 @@ 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);
const bpWithinMaxPersistence = !!(
data.bp?.["date-time"] &&
minutesSinceCurrentBedAssignment !== undefined && // Check if minutesSinceCurrentBedAssignment is defined
isWithinMinutes(data.bp?.["date-time"], minutesSinceCurrentBedAssignment)
props.patientCurrentBedAssignmentDate &&
isWithinMinutes(
data.bp?.["date-time"],
props.patientCurrentBedAssignmentDate
)
);

return (
Expand Down

0 comments on commit 365bf7a

Please sign in to comment.