diff --git a/vigilcare-dashboard/src/views/PatientDetail.vue b/vigilcare-dashboard/src/views/PatientDetail.vue index a2d43cf..80ba51d 100644 --- a/vigilcare-dashboard/src/views/PatientDetail.vue +++ b/vigilcare-dashboard/src/views/PatientDetail.vue @@ -21,7 +21,23 @@ import Skeleton from '@/components/ui/Skeleton.vue' const route = useRoute() const alertStore = useAlertStore() const { alerts } = storeToRefs(alertStore) -const replay = useReplayControls() +const { + isPaused, + speed, + progress, + formattedTime, + currentMs, + scenarioEndMs, + scenarioStartMs, + pause, + resume, + setSpeed, + jumpToTimestamp, + isAtOrBefore, + setScenarioBounds, + syncToEnd, + stopPlayback, +} = useReplayControls() const encounter = ref(null) const loading = ref(true) @@ -39,11 +55,11 @@ const openAlerts = computed(() => ) const replayObservations = computed(() => - observations.value.filter(o => replay.isAtOrBefore(o.recordedAt)), + observations.value.filter(o => isAtOrBefore(o.recordedAt)), ) const replayNews2History = computed(() => - news2History.value.filter(h => replay.isAtOrBefore(h.calculatedAt)), + news2History.value.filter(h => isAtOrBefore(h.calculatedAt)), ) function collectScenarioTimes() { @@ -58,10 +74,10 @@ function syncReplayBounds() { const times = collectScenarioTimes() if (!times.length) return - const atEnd = replay.currentMs.value >= replay.scenarioEndMs.value - 1_000 - replay.setScenarioBounds(Math.min(...times), Math.max(...times)) - if (atEnd || replay.scenarioEndMs.value === replay.scenarioStartMs.value) { - replay.syncToEnd() + const atEnd = currentMs.value >= scenarioEndMs.value - 1_000 + setScenarioBounds(Math.min(...times), Math.max(...times)) + if (atEnd || scenarioEndMs.value === scenarioStartMs.value) { + syncToEnd() } } @@ -94,7 +110,7 @@ async function loadAll() { function onSelectAlert(alert) { selectedAlert.value = alert - replay.jumpToTimestamp(alert.triggeredAt) + jumpToTimestamp(alert.triggeredAt) } function jumpToNextAlert() { @@ -106,7 +122,7 @@ function jumpToNextAlert() { const alert = sorted[nextAlertIndex % sorted.length] selectedAlert.value = alert nextAlertIndex++ - replay.jumpToTimestamp(alert.triggeredAt) + jumpToTimestamp(alert.triggeredAt) document.getElementById(`alert-row-${alert.id}`)?.scrollIntoView({ behavior: 'smooth', block: 'nearest' }) document.getElementById('clinical-review')?.scrollIntoView({ behavior: 'smooth', block: 'start' }) @@ -117,7 +133,7 @@ usePolling(loadAll, 5_000) watch(() => route.params.encounterId, () => { selectedAlert.value = null nextAlertIndex = 0 - replay.pause() + pause() loadAll() }) @@ -130,7 +146,7 @@ watch(openAlerts, (list) => { watch([observations, news2History, alerts], syncReplayBounds, { deep: true }) -onBeforeUnmount(() => replay.stopPlayback()) +onBeforeUnmount(() => stopPlayback())