feature: Core Digitization Workstation (Entry, Verification, Approval)
This commit is contained in:
@@ -0,0 +1,481 @@
|
||||
<template>
|
||||
<div
|
||||
class="h-full min-h-0 flex flex-col approval-frame"
|
||||
data-testid="approval-form"
|
||||
>
|
||||
<div class="flex-1 min-h-0 overflow-y-auto p-4 space-y-4">
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div>
|
||||
<p class="evidence-level evidence-level--2 mb-1">
|
||||
<span class="evidence-level-mark" aria-hidden="true">2</span>
|
||||
Verified draft
|
||||
</p>
|
||||
<h2 class="text-base font-semibold text-ink-strong">Clinical Approval</h2>
|
||||
<p class="mt-1 text-xs text-ink-secondary max-w-md">
|
||||
Clinical sign-off before promotion to live clinical tables. Review the source scan and verified draft.
|
||||
</p>
|
||||
</div>
|
||||
<StatusBadge :status="batch?.status ?? 'AWAITING_CLINICAL_APPROVAL'" />
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="batch?.supersedesBatchId"
|
||||
class="rounded-input border border-primary-100 bg-primary-50 p-3 text-sm"
|
||||
>
|
||||
<p class="font-medium text-primary-800">Correction Batch</p>
|
||||
<p class="text-primary-700 mt-1">
|
||||
This batch corrects and will supersede batch
|
||||
<span class="font-mono">{{ batch.supersedesBatchId.substring(0, 8) }}...</span>
|
||||
</p>
|
||||
<button
|
||||
v-if="batch.patientId"
|
||||
type="button"
|
||||
class="text-xs text-primary-600 hover:text-primary-800 mt-2"
|
||||
@click="$emit('view-history', batch.patientId)"
|
||||
>
|
||||
View patient history
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- High-stakes clinical signals (design-doc §16) -->
|
||||
<section
|
||||
v-if="highStakeItems.length > 0"
|
||||
class="rounded-input border border-[#FEDF89] bg-clinical-warning-bg/60 p-3"
|
||||
data-testid="high-stakes-summary"
|
||||
>
|
||||
<p class="evidence-level evidence-level--4 mb-2 !text-clinical-warning">
|
||||
<span class="evidence-level-mark" aria-hidden="true">!</span>
|
||||
High-stakes clinical signals
|
||||
</p>
|
||||
<ul class="space-y-2">
|
||||
<li
|
||||
v-for="item in highStakeItems"
|
||||
:key="item.key"
|
||||
class="clinical-signal"
|
||||
:class="{ 'clinical-signal--critical': item.critical }"
|
||||
>
|
||||
<span class="text-xs font-semibold uppercase tracking-wide text-ink-secondary">
|
||||
{{ item.label }}
|
||||
</span>
|
||||
<p class="font-medium text-ink-strong mt-0.5">{{ item.value }}</p>
|
||||
<p v-if="item.reason" class="text-xs text-ink-secondary mt-0.5">{{ item.reason }}</p>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<fieldset v-if="draft?.patient" class="workstation-form-section">
|
||||
<legend class="workstation-form-legend">Patient</legend>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-3 text-sm">
|
||||
<div>
|
||||
<span class="text-ink-secondary">Full Name</span>
|
||||
<p class="font-medium text-ink-strong">{{ draft.patient.fullName || '—' }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<span class="text-ink-secondary">DOB</span>
|
||||
<p class="font-medium text-ink-strong">{{ draft.patient.dateOfBirth ?? 'N/A' }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<span class="text-ink-secondary">Sex</span>
|
||||
<p class="font-medium text-ink-strong">{{ draft.patient.sex ?? 'N/A' }}</p>
|
||||
</div>
|
||||
<div :class="draft.patient.bloodType ? 'rounded-input bg-clinical-warning-bg/50 px-2 py-1 -mx-2' : ''">
|
||||
<span class="text-ink-secondary">Blood Type</span>
|
||||
<p class="font-medium text-ink-strong">{{ draft.patient.bloodType ?? 'N/A' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset v-if="draft?.encounter" class="workstation-form-section">
|
||||
<legend class="workstation-form-legend">Encounter</legend>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-3 text-sm">
|
||||
<div>
|
||||
<span class="text-ink-secondary">Admission</span>
|
||||
<p class="font-medium text-ink-strong">{{ draft.encounter.admissionDate ?? 'N/A' }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<span class="text-ink-secondary">Department</span>
|
||||
<p class="font-medium text-ink-strong">{{ draft.encounter.department ?? 'N/A' }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<span class="text-ink-secondary">Room / Bed</span>
|
||||
<p class="font-medium text-ink-strong">{{ draft.encounter.roomBed ?? 'N/A' }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<span class="text-ink-secondary">Reason</span>
|
||||
<p class="font-medium text-ink-strong">{{ draft.encounter.admissionReason ?? 'N/A' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="workstation-form-section">
|
||||
<legend class="workstation-form-legend">
|
||||
Observations ({{ draft?.observations?.length ?? 0 }})
|
||||
</legend>
|
||||
<div class="space-y-2">
|
||||
<ObservationRow
|
||||
v-for="obs in (draft?.observations ?? [])"
|
||||
:key="obs.id"
|
||||
:observation="obs"
|
||||
:readonly="true"
|
||||
/>
|
||||
<p v-if="!draft?.observations?.length" class="text-sm text-ink-secondary">
|
||||
No observations recorded.
|
||||
</p>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<div
|
||||
v-if="batch?.verifiedByUserId"
|
||||
class="rounded-input border border-line bg-canvas px-3 py-2 text-sm text-ink-secondary"
|
||||
>
|
||||
<span class="text-xs uppercase tracking-wide font-semibold">Verified by</span>
|
||||
<p class="font-mono text-ink mt-0.5">{{ batch.verifiedByUserId.substring(0, 8) }}…</p>
|
||||
</div>
|
||||
|
||||
<!-- Level 4 decision controls (copy weight below draft) -->
|
||||
<section
|
||||
class="rounded-input border border-line bg-canvas p-3 space-y-3"
|
||||
data-testid="approval-decision"
|
||||
>
|
||||
<p class="evidence-level evidence-level--4 mb-0">
|
||||
<span class="evidence-level-mark" aria-hidden="true">4</span>
|
||||
Clinical decision
|
||||
</p>
|
||||
<label class="flex items-start gap-3 cursor-pointer">
|
||||
<input
|
||||
v-model="enableRetroactiveAlerts"
|
||||
type="checkbox"
|
||||
class="mt-1 w-4 h-4 text-clinical-safe rounded"
|
||||
data-testid="retroactive-alerts"
|
||||
/>
|
||||
<div>
|
||||
<span class="text-sm font-medium text-ink-strong">
|
||||
Run alert evaluation after promotion
|
||||
</span>
|
||||
<p class="text-xs text-ink-secondary mt-0.5">
|
||||
May generate alerts for clinical criteria represented in historical records.
|
||||
It should not sound like alerts occurred contemporaneously.
|
||||
</p>
|
||||
</div>
|
||||
</label>
|
||||
</section>
|
||||
|
||||
<!-- Level 5 promotion outcome -->
|
||||
<section
|
||||
v-if="promotionResult"
|
||||
class="promotion-outcome"
|
||||
data-testid="promotion-result"
|
||||
>
|
||||
<p class="evidence-level evidence-level--5 mb-2">
|
||||
<span class="evidence-level-mark" aria-hidden="true">5</span>
|
||||
Promotion outcome
|
||||
</p>
|
||||
<p class="font-semibold text-clinical-safe">Promoted to live clinical tables</p>
|
||||
<dl class="mt-3 grid gap-2 sm:grid-cols-3 text-sm">
|
||||
<div>
|
||||
<dt class="text-xs text-ink-secondary uppercase tracking-wide">Patient MRN</dt>
|
||||
<dd class="font-mono font-medium text-ink-strong mt-0.5">{{ promotionResult.mrn }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-xs text-ink-secondary uppercase tracking-wide">Encounter</dt>
|
||||
<dd class="font-mono font-medium text-ink-strong mt-0.5">
|
||||
{{ promotionResult.encounterId?.substring(0, 8) }}…
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-xs text-ink-secondary uppercase tracking-wide">Observations</dt>
|
||||
<dd class="font-medium text-ink-strong mt-0.5">
|
||||
{{ promotionResult.observationIds?.length ?? 0 }} promoted
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<div class="flex flex-wrap gap-4 mt-3 pt-3 border-t border-[#ABEFC6]">
|
||||
<button
|
||||
type="button"
|
||||
class="text-sm text-primary-600 hover:text-primary-800 font-medium"
|
||||
@click="$emit('create-correction')"
|
||||
>
|
||||
Create Correction
|
||||
</button>
|
||||
<button
|
||||
v-if="batch?.patientId"
|
||||
type="button"
|
||||
class="text-sm text-ink-secondary hover:text-ink-strong"
|
||||
@click="$emit('view-history', batch.patientId)"
|
||||
>
|
||||
View Patient History
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div
|
||||
v-if="deferred"
|
||||
class="rounded-input border border-[#FEDF89] bg-clinical-warning-bg p-4 text-sm"
|
||||
data-testid="promotion-deferred"
|
||||
>
|
||||
<p class="font-medium text-clinical-warning">Approved — Promotion Deferred</p>
|
||||
<p class="text-ink mt-1">
|
||||
Promotion will be retried automatically due to a temporary infrastructure issue.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div v-if="errorMessage" class="text-clinical-danger text-sm" role="alert">
|
||||
{{ errorMessage }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<WorkstationActionBar>
|
||||
<template #left>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-danger"
|
||||
:disabled="processing || !!promotionResult"
|
||||
data-testid="reject-batch"
|
||||
@click="showRejectDialog = true"
|
||||
>
|
||||
Reject Batch
|
||||
</button>
|
||||
</template>
|
||||
<template #primary>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-primary"
|
||||
:disabled="processing || !!promotionResult"
|
||||
data-testid="approve-promote"
|
||||
@click="showApproveConfirm = true"
|
||||
>
|
||||
{{ processing ? 'Promoting...' : 'Approve & Promote' }}
|
||||
</button>
|
||||
</template>
|
||||
<template #right>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-secondary"
|
||||
:disabled="processing"
|
||||
@click="$emit('back')"
|
||||
>
|
||||
Back to Queue
|
||||
</button>
|
||||
</template>
|
||||
</WorkstationActionBar>
|
||||
|
||||
<ConfirmDialog
|
||||
:open="showApproveConfirm"
|
||||
title="Approve & Promote"
|
||||
body="Approval will promote the verified records into live clinical tables."
|
||||
confirm-label="Approve & Promote"
|
||||
variant="primary"
|
||||
:confirm-disabled="processing"
|
||||
@confirm="confirmApprove"
|
||||
@cancel="showApproveConfirm = false"
|
||||
/>
|
||||
|
||||
<ConfirmDialog
|
||||
:open="showRejectDialog"
|
||||
title="Reject Batch"
|
||||
body="This returns the batch for rework. A reason is required."
|
||||
confirm-label="Reject Batch"
|
||||
variant="danger"
|
||||
:confirm-disabled="!rejectionReason.trim() || processing"
|
||||
@confirm="reject"
|
||||
@cancel="closeRejectDialog"
|
||||
>
|
||||
<textarea
|
||||
v-model="rejectionReason"
|
||||
class="form-input"
|
||||
rows="4"
|
||||
placeholder="Reason for rejection (required)..."
|
||||
/>
|
||||
</ConfirmDialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch } from 'vue'
|
||||
import { useBatchStore } from '../stores/batches'
|
||||
import { useToast } from '../composables/useToast'
|
||||
import ObservationRow from './ObservationRow.vue'
|
||||
import StatusBadge from './StatusBadge.vue'
|
||||
import ConfirmDialog from './ConfirmDialog.vue'
|
||||
import WorkstationActionBar from './WorkstationActionBar.vue'
|
||||
import type { BatchDetailResponse, BatchDraft, DraftObservation } from '../types'
|
||||
|
||||
const props = defineProps<{
|
||||
batch: BatchDetailResponse | null
|
||||
batchId: string
|
||||
draft: BatchDraft | null
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'back'): void
|
||||
(e: 'view-history', patientId: string): void
|
||||
(e: 'create-correction'): void
|
||||
(e: 'approved'): void
|
||||
(e: 'rejected'): void
|
||||
}>()
|
||||
|
||||
const batchStore = useBatchStore()
|
||||
const toast = useToast()
|
||||
|
||||
const processing = ref(false)
|
||||
const errorMessage = ref('')
|
||||
const enableRetroactiveAlerts = ref(false)
|
||||
const showApproveConfirm = ref(false)
|
||||
const showRejectDialog = ref(false)
|
||||
const rejectionReason = ref('')
|
||||
const promotionResult = ref<{ mrn: string; encounterId: string; observationIds: string[] } | null>(null)
|
||||
const deferred = ref(false)
|
||||
|
||||
watch(
|
||||
() => props.batchId,
|
||||
() => {
|
||||
promotionResult.value = null
|
||||
deferred.value = false
|
||||
errorMessage.value = ''
|
||||
enableRetroactiveAlerts.value = false
|
||||
rejectionReason.value = ''
|
||||
}
|
||||
)
|
||||
|
||||
interface HighStakeItem {
|
||||
key: string
|
||||
label: string
|
||||
value: string
|
||||
reason?: string
|
||||
critical?: boolean
|
||||
}
|
||||
|
||||
function isCriticalObservation(obs: DraftObservation): boolean {
|
||||
const code = (obs.observationCode ?? '').toUpperCase()
|
||||
const value = Number(obs.value)
|
||||
if (Number.isNaN(value)) return false
|
||||
if (code.includes('TEMP') && value >= 38) return true
|
||||
if (code.includes('SPO2') && value < 92) return true
|
||||
if ((code.includes('HEART') || code === 'HR') && (value > 120 || value < 40)) return true
|
||||
if (code.includes('BP_SYSTOLIC') && (value >= 180 || value < 90)) return true
|
||||
if (code.includes('LACTATE') && value >= 2) return true
|
||||
if (code.includes('POTASSIUM') && (value < 3 || value > 5.5)) return true
|
||||
return false
|
||||
}
|
||||
|
||||
function formatObsLabel(code: string): string {
|
||||
return code.replace(/_/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase())
|
||||
}
|
||||
|
||||
const highStakeItems = computed((): HighStakeItem[] => {
|
||||
const draft = props.draft
|
||||
if (!draft) return []
|
||||
const items: HighStakeItem[] = []
|
||||
const patient = draft.patient
|
||||
|
||||
if (patient?.bloodType) {
|
||||
items.push({
|
||||
key: 'bloodType',
|
||||
label: 'Blood type',
|
||||
value: patient.bloodType,
|
||||
reason: 'High-stakes demographic for transfusion safety',
|
||||
})
|
||||
}
|
||||
|
||||
if (patient?.noKnownAllergies) {
|
||||
items.push({
|
||||
key: 'nka',
|
||||
label: 'Allergies',
|
||||
value: 'No known allergies (NKA)',
|
||||
})
|
||||
} else if (patient?.allergies?.length) {
|
||||
items.push({
|
||||
key: 'allergies',
|
||||
label: 'Allergies',
|
||||
value: patient.allergies.join(', '),
|
||||
reason: 'Allergy documentation requires clinical oversight',
|
||||
critical: true,
|
||||
})
|
||||
}
|
||||
|
||||
if (patient?.noActiveMedications) {
|
||||
items.push({
|
||||
key: 'nam',
|
||||
label: 'Medications',
|
||||
value: 'No active medications',
|
||||
})
|
||||
} else if (patient?.medications?.length) {
|
||||
items.push({
|
||||
key: 'medications',
|
||||
label: 'Medications',
|
||||
value: patient.medications.join(', '),
|
||||
reason: 'Medication list requires clinical oversight',
|
||||
critical: true,
|
||||
})
|
||||
}
|
||||
|
||||
for (const obs of draft.observations ?? []) {
|
||||
if (!isCriticalObservation(obs)) continue
|
||||
items.push({
|
||||
key: `obs-${obs.id}`,
|
||||
label: formatObsLabel(obs.observationCode),
|
||||
value: `${obs.value}${obs.unit ? ` ${obs.unit}` : ''}`,
|
||||
reason: 'Out-of-range clinical signal',
|
||||
critical: true,
|
||||
})
|
||||
}
|
||||
|
||||
return items
|
||||
})
|
||||
|
||||
function closeRejectDialog() {
|
||||
showRejectDialog.value = false
|
||||
}
|
||||
|
||||
async function confirmApprove() {
|
||||
showApproveConfirm.value = false
|
||||
await approve()
|
||||
}
|
||||
|
||||
async function approve() {
|
||||
processing.value = true
|
||||
errorMessage.value = ''
|
||||
promotionResult.value = null
|
||||
deferred.value = false
|
||||
|
||||
try {
|
||||
const response = await batchStore.approveBatch(props.batchId, enableRetroactiveAlerts.value)
|
||||
if (response?.status === 202) {
|
||||
deferred.value = true
|
||||
toast.info('Approved. Promotion will be retried automatically.')
|
||||
} else if (response?.data) {
|
||||
promotionResult.value = response.data
|
||||
toast.success('Batch approved and promoted successfully')
|
||||
emit('approved')
|
||||
}
|
||||
} catch (e: unknown) {
|
||||
const msg = e instanceof Error ? e.message : 'Approval failed'
|
||||
if (msg.includes('PROMOTION_DEFERRED')) {
|
||||
deferred.value = true
|
||||
toast.info('Approved. Promotion will be retried automatically.')
|
||||
} else {
|
||||
errorMessage.value = msg
|
||||
toast.error(msg)
|
||||
}
|
||||
} finally {
|
||||
processing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function reject() {
|
||||
processing.value = true
|
||||
errorMessage.value = ''
|
||||
try {
|
||||
await batchStore.rejectBatch(props.batchId, rejectionReason.value)
|
||||
showRejectDialog.value = false
|
||||
toast.warning('Batch rejected')
|
||||
emit('rejected')
|
||||
} catch (e: unknown) {
|
||||
const msg = e instanceof Error ? e.message : 'Rejection failed'
|
||||
errorMessage.value = msg
|
||||
toast.error(msg)
|
||||
} finally {
|
||||
processing.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -1,263 +1,313 @@
|
||||
<template>
|
||||
<div class="h-full overflow-y-auto p-4 space-y-6">
|
||||
<div class="flex items-center justify-between">
|
||||
<h2 class="text-lg font-semibold">Data Entry</h2>
|
||||
<StatusBadge :status="batch?.status" />
|
||||
</div>
|
||||
|
||||
<div v-if="ocrConfidence" class="ocr-banner">
|
||||
Pre-filled by OCR ({{ ocrConfidence.provider }}) — review against the scan.
|
||||
OCR is assistive, not authoritative.
|
||||
</div>
|
||||
|
||||
<!-- Patient section -->
|
||||
<fieldset class="border border-gray-200 rounded-md p-4">
|
||||
<legend class="text-sm font-medium text-gray-700 px-2">Patient Demographics</legend>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div class="h-full min-h-0 flex flex-col" data-testid="entry-form">
|
||||
<div class="flex-1 min-h-0 overflow-y-auto p-4 space-y-4">
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div>
|
||||
<label class="flex items-center gap-2 text-xs text-gray-500">
|
||||
Full Name
|
||||
<OcrConfidenceBadge :label="fieldConfidenceLabel('patient.fullName')" :level="fieldConfidenceLevel('patient.fullName')" />
|
||||
</label>
|
||||
<input
|
||||
v-model="patient.fullName"
|
||||
@blur="savePatient"
|
||||
type="text"
|
||||
:class="['form-input', 'text-sm', fieldConfidenceClass('patient.fullName')]"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="flex items-center gap-2 text-xs text-gray-500">
|
||||
Date of Birth
|
||||
<OcrConfidenceBadge :label="fieldConfidenceLabel('patient.dateOfBirth')" :level="fieldConfidenceLevel('patient.dateOfBirth')" />
|
||||
</label>
|
||||
<input
|
||||
v-model="patient.dateOfBirth"
|
||||
@blur="savePatient"
|
||||
type="date"
|
||||
:class="['form-input', 'text-sm', fieldConfidenceClass('patient.dateOfBirth')]"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="flex items-center gap-2 text-xs text-gray-500">
|
||||
Sex
|
||||
<OcrConfidenceBadge :label="fieldConfidenceLabel('patient.sex')" :level="fieldConfidenceLevel('patient.sex')" />
|
||||
</label>
|
||||
<select
|
||||
v-model="patient.sex"
|
||||
@change="savePatient"
|
||||
:class="['form-input', 'text-sm', fieldConfidenceClass('patient.sex')]"
|
||||
<p class="evidence-level evidence-level--2 mb-1">
|
||||
<span class="evidence-level-mark" aria-hidden="true">2</span>
|
||||
Structured draft
|
||||
</p>
|
||||
<h2 class="text-base font-semibold text-ink-strong">Data Entry</h2>
|
||||
<p
|
||||
class="mt-1 text-xs tabular-nums"
|
||||
:class="{
|
||||
'text-ink-secondary': saveState === 'saved' || saveState === 'idle',
|
||||
'text-ink-secondary animate-pulse': saveState === 'saving',
|
||||
'text-clinical-danger font-medium': saveState === 'failed',
|
||||
}"
|
||||
data-testid="entry-save-status"
|
||||
>
|
||||
<option value="">Select...</option>
|
||||
<option value="male">Male</option>
|
||||
<option value="female">Female</option>
|
||||
<option value="other">Other</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs text-gray-500">Blood Type</label>
|
||||
<select v-model="patient.bloodType" @change="savePatient" class="form-input text-sm">
|
||||
<option value="">Unknown</option>
|
||||
<option v-for="bt in bloodTypes" :key="bt" :value="bt">{{ bt }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-span-2">
|
||||
<label class="block text-xs text-gray-500">Emergency Contact</label>
|
||||
<input
|
||||
v-model="patient.emergencyContact"
|
||||
@blur="savePatient"
|
||||
type="text"
|
||||
class="form-input text-sm"
|
||||
/>
|
||||
{{ saveStatusLabel }}
|
||||
</p>
|
||||
</div>
|
||||
<StatusBadge :status="batch?.status" />
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<!-- Allergies section (ALLERGY_UPDATE or MIXED) -->
|
||||
<fieldset v-if="showAllergies" class="border border-gray-200 rounded-md p-4">
|
||||
<legend class="text-sm font-medium text-gray-700 px-2">Allergies</legend>
|
||||
<label class="flex items-center gap-2 mb-3 cursor-pointer">
|
||||
<input
|
||||
v-model="patient.noKnownAllergies"
|
||||
@change="onNoKnownAllergiesChange"
|
||||
type="checkbox"
|
||||
class="w-4 h-4 text-clinical-safe rounded"
|
||||
/>
|
||||
<span class="text-sm">No known allergies (NKA)</span>
|
||||
</label>
|
||||
<div v-if="!patient.noKnownAllergies" class="space-y-2">
|
||||
<div
|
||||
v-for="(_allergy, idx) in allergies"
|
||||
:key="idx"
|
||||
class="flex items-center gap-2"
|
||||
>
|
||||
<div v-if="ocrConfidence" class="ocr-banner">
|
||||
Pre-filled by OCR ({{ ocrConfidence.provider }}) — review against the scan.
|
||||
OCR is assistive, not authoritative.
|
||||
</div>
|
||||
|
||||
<!-- Patient section -->
|
||||
<fieldset class="workstation-form-section">
|
||||
<legend class="workstation-form-legend">Patient Demographics</legend>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-3">
|
||||
<div>
|
||||
<label class="workstation-field-label">
|
||||
Full Name
|
||||
<OcrConfidenceBadge :label="fieldConfidenceLabel('patient.fullName')" :level="fieldConfidenceLevel('patient.fullName')" />
|
||||
</label>
|
||||
<input
|
||||
v-model="patient.fullName"
|
||||
type="text"
|
||||
:class="['form-input', 'text-sm', 'py-1.5', fieldConfidenceClass('patient.fullName')]"
|
||||
@blur="savePatient"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="workstation-field-label">
|
||||
Date of Birth
|
||||
<OcrConfidenceBadge :label="fieldConfidenceLabel('patient.dateOfBirth')" :level="fieldConfidenceLevel('patient.dateOfBirth')" />
|
||||
</label>
|
||||
<input
|
||||
v-model="patient.dateOfBirth"
|
||||
type="date"
|
||||
:class="['form-input', 'text-sm', 'py-1.5', fieldConfidenceClass('patient.dateOfBirth')]"
|
||||
@blur="savePatient"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="workstation-field-label">
|
||||
Sex
|
||||
<OcrConfidenceBadge :label="fieldConfidenceLabel('patient.sex')" :level="fieldConfidenceLevel('patient.sex')" />
|
||||
</label>
|
||||
<select
|
||||
v-model="patient.sex"
|
||||
:class="['form-input', 'text-sm', 'py-1.5', fieldConfidenceClass('patient.sex')]"
|
||||
@change="savePatient"
|
||||
>
|
||||
<option value="">Select...</option>
|
||||
<option value="male">Male</option>
|
||||
<option value="female">Female</option>
|
||||
<option value="other">Other</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="workstation-field-label">Blood Type</label>
|
||||
<select v-model="patient.bloodType" class="form-input text-sm py-1.5" @change="savePatient">
|
||||
<option value="">Unknown</option>
|
||||
<option v-for="bt in bloodTypes" :key="bt" :value="bt">{{ bt }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="md:col-span-2">
|
||||
<label class="workstation-field-label">Emergency Contact</label>
|
||||
<input
|
||||
v-model="patient.emergencyContact"
|
||||
type="text"
|
||||
class="form-input text-sm py-1.5"
|
||||
@blur="savePatient"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<!-- Allergies section (ALLERGY_UPDATE or MIXED) -->
|
||||
<fieldset v-if="showAllergies" class="workstation-form-section">
|
||||
<legend class="workstation-form-legend">Allergies</legend>
|
||||
<label class="flex items-center gap-2 mb-2 cursor-pointer">
|
||||
<input
|
||||
v-model="allergies[idx]"
|
||||
@blur="saveAllergies"
|
||||
type="text"
|
||||
class="form-input text-sm flex-1"
|
||||
placeholder="Allergy (e.g. Penicillin)"
|
||||
v-model="patient.noKnownAllergies"
|
||||
type="checkbox"
|
||||
class="w-4 h-4 text-clinical-safe rounded"
|
||||
@change="onNoKnownAllergiesChange"
|
||||
/>
|
||||
<button
|
||||
@click="removeAllergy(idx)"
|
||||
class="text-clinical-danger hover:text-red-800 text-sm"
|
||||
<span class="text-sm">No known allergies (NKA)</span>
|
||||
</label>
|
||||
<div v-if="!patient.noKnownAllergies" class="space-y-2">
|
||||
<div
|
||||
v-for="(_allergy, idx) in allergies"
|
||||
:key="idx"
|
||||
class="flex items-center gap-2"
|
||||
>
|
||||
Remove
|
||||
<input
|
||||
v-model="allergies[idx]"
|
||||
type="text"
|
||||
class="form-input text-sm py-1.5 flex-1"
|
||||
placeholder="Allergy (e.g. Penicillin)"
|
||||
@blur="saveAllergies"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="text-clinical-danger hover:text-clinical-critical text-sm"
|
||||
@click="removeAllergy(idx)"
|
||||
>
|
||||
Remove
|
||||
</button>
|
||||
</div>
|
||||
<button type="button" class="text-sm text-primary-600 hover:text-primary-800" @click="addAllergy">
|
||||
+ Add Allergy
|
||||
</button>
|
||||
</div>
|
||||
<button @click="addAllergy" class="text-sm text-primary-600 hover:text-primary-800">
|
||||
+ Add Allergy
|
||||
</button>
|
||||
</div>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
|
||||
<!-- Medications section (MEDICATION_LIST or MIXED) -->
|
||||
<fieldset v-if="showMedications" class="border border-gray-200 rounded-md p-4">
|
||||
<legend class="text-sm font-medium text-gray-700 px-2">Medications</legend>
|
||||
<label class="flex items-center gap-2 mb-3 cursor-pointer">
|
||||
<input
|
||||
v-model="patient.noActiveMedications"
|
||||
@change="onNoActiveMedicationsChange"
|
||||
type="checkbox"
|
||||
class="w-4 h-4 text-clinical-safe rounded"
|
||||
/>
|
||||
<span class="text-sm">No active medications</span>
|
||||
</label>
|
||||
<div v-if="!patient.noActiveMedications" class="space-y-2">
|
||||
<div
|
||||
v-for="(_med, idx) in medications"
|
||||
:key="idx"
|
||||
class="flex items-center gap-2"
|
||||
>
|
||||
<!-- Medications section (MEDICATION_LIST or MIXED) -->
|
||||
<fieldset v-if="showMedications" class="workstation-form-section">
|
||||
<legend class="workstation-form-legend">Medications</legend>
|
||||
<label class="flex items-center gap-2 mb-2 cursor-pointer">
|
||||
<input
|
||||
v-model="medications[idx]"
|
||||
@blur="saveMedications"
|
||||
type="text"
|
||||
class="form-input text-sm flex-1"
|
||||
placeholder="Medication (e.g. Metoprolol 50mg BID)"
|
||||
v-model="patient.noActiveMedications"
|
||||
type="checkbox"
|
||||
class="w-4 h-4 text-clinical-safe rounded"
|
||||
@change="onNoActiveMedicationsChange"
|
||||
/>
|
||||
<button
|
||||
@click="removeMedication(idx)"
|
||||
class="text-clinical-danger hover:text-red-800 text-sm"
|
||||
<span class="text-sm">No active medications</span>
|
||||
</label>
|
||||
<div v-if="!patient.noActiveMedications" class="space-y-2">
|
||||
<div
|
||||
v-for="(_med, idx) in medications"
|
||||
:key="idx"
|
||||
class="flex items-center gap-2"
|
||||
>
|
||||
Remove
|
||||
<input
|
||||
v-model="medications[idx]"
|
||||
type="text"
|
||||
class="form-input text-sm py-1.5 flex-1"
|
||||
placeholder="Medication (e.g. Metoprolol 50mg BID)"
|
||||
@blur="saveMedications"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="text-clinical-danger hover:text-clinical-critical text-sm"
|
||||
@click="removeMedication(idx)"
|
||||
>
|
||||
Remove
|
||||
</button>
|
||||
</div>
|
||||
<button type="button" class="text-sm text-primary-600 hover:text-primary-800" @click="addMedication">
|
||||
+ Add Medication
|
||||
</button>
|
||||
</div>
|
||||
<button @click="addMedication" class="text-sm text-primary-600 hover:text-primary-800">
|
||||
+ Add Medication
|
||||
</button>
|
||||
</div>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
|
||||
<!-- Encounter section -->
|
||||
<fieldset class="border border-gray-200 rounded-md p-4">
|
||||
<legend class="text-sm font-medium text-gray-700 px-2">Encounter Context</legend>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="flex items-center gap-2 text-xs text-gray-500">
|
||||
Admission Date
|
||||
<OcrConfidenceBadge :label="fieldConfidenceLabel('encounter.admissionDate')" :level="fieldConfidenceLevel('encounter.admissionDate')" />
|
||||
</label>
|
||||
<input
|
||||
v-model="encounter.admissionDate"
|
||||
@blur="saveEncounter"
|
||||
type="datetime-local"
|
||||
:class="['form-input', 'text-sm', fieldConfidenceClass('encounter.admissionDate')]"
|
||||
/>
|
||||
<!-- Encounter section -->
|
||||
<fieldset class="workstation-form-section">
|
||||
<legend class="workstation-form-legend">Encounter Context</legend>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-3">
|
||||
<div>
|
||||
<label class="workstation-field-label">
|
||||
Admission Date
|
||||
<OcrConfidenceBadge :label="fieldConfidenceLabel('encounter.admissionDate')" :level="fieldConfidenceLevel('encounter.admissionDate')" />
|
||||
</label>
|
||||
<input
|
||||
v-model="encounter.admissionDate"
|
||||
type="datetime-local"
|
||||
:class="['form-input', 'text-sm', 'py-1.5', fieldConfidenceClass('encounter.admissionDate')]"
|
||||
@blur="saveEncounter"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="workstation-field-label">
|
||||
Department
|
||||
<OcrConfidenceBadge :label="fieldConfidenceLabel('encounter.department')" :level="fieldConfidenceLevel('encounter.department')" />
|
||||
</label>
|
||||
<select
|
||||
v-model="encounter.department"
|
||||
:class="['form-input', 'text-sm', 'py-1.5', fieldConfidenceClass('encounter.department')]"
|
||||
@change="saveEncounter"
|
||||
>
|
||||
<option value="">—</option>
|
||||
<option v-for="dept in departments" :key="dept" :value="dept">{{ dept }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="workstation-field-label">
|
||||
Room / Bed
|
||||
<OcrConfidenceBadge :label="fieldConfidenceLabel('encounter.roomBed')" :level="fieldConfidenceLevel('encounter.roomBed')" />
|
||||
</label>
|
||||
<input
|
||||
v-model="encounter.roomBed"
|
||||
type="text"
|
||||
:class="['form-input', 'text-sm', 'py-1.5', fieldConfidenceClass('encounter.roomBed')]"
|
||||
@blur="saveEncounter"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="workstation-field-label">
|
||||
Admission Reason
|
||||
<OcrConfidenceBadge :label="fieldConfidenceLabel('encounter.admissionReason')" :level="fieldConfidenceLevel('encounter.admissionReason')" />
|
||||
</label>
|
||||
<input
|
||||
v-model="encounter.admissionReason"
|
||||
type="text"
|
||||
:class="['form-input', 'text-sm', 'py-1.5', fieldConfidenceClass('encounter.admissionReason')]"
|
||||
@blur="saveEncounter"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="showEncounterSummary">
|
||||
<label class="workstation-field-label">Encounter Status</label>
|
||||
<select v-model="encounter.status" class="form-input text-sm py-1.5" @change="saveEncounter">
|
||||
<option value="">—</option>
|
||||
<option value="active">Active</option>
|
||||
<option value="discharged">Discharged</option>
|
||||
</select>
|
||||
</div>
|
||||
<div v-if="showEncounterSummary" class="md:col-span-2">
|
||||
<label class="workstation-field-label">Discharge Diagnosis</label>
|
||||
<textarea
|
||||
v-model="encounter.dischargeDiagnosis"
|
||||
class="form-input text-sm py-1.5"
|
||||
rows="2"
|
||||
placeholder="Discharge diagnosis..."
|
||||
@blur="saveEncounter"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="flex items-center gap-2 text-xs text-gray-500">
|
||||
Department
|
||||
<OcrConfidenceBadge :label="fieldConfidenceLabel('encounter.department')" :level="fieldConfidenceLevel('encounter.department')" />
|
||||
</label>
|
||||
<select
|
||||
v-model="encounter.department"
|
||||
@change="saveEncounter"
|
||||
:class="['form-input', 'text-sm', fieldConfidenceClass('encounter.department')]"
|
||||
</fieldset>
|
||||
|
||||
<!-- Observations section -->
|
||||
<fieldset class="workstation-form-section">
|
||||
<legend class="workstation-form-legend">Observations</legend>
|
||||
<div class="space-y-2">
|
||||
<ObservationRow
|
||||
v-for="obs in observations"
|
||||
:key="obs.id"
|
||||
:observation="obs"
|
||||
:value-input-class="observationValueConfidenceClass(obs.observationCode)"
|
||||
:ocr-label="fieldConfidenceLabel(`observation.${obs.observationCode}.value`)"
|
||||
:ocr-level="fieldConfidenceLevel(`observation.${obs.observationCode}.value`)"
|
||||
@update="(field, value) => handleObsUpdate(obs.id, field, value)"
|
||||
@delete="handleObsDelete"
|
||||
/>
|
||||
<button type="button" class="btn-secondary text-sm py-1.5" @click="addObservation">
|
||||
+ Add Observation
|
||||
</button>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<div v-if="errorMessage" class="text-clinical-danger text-sm" role="alert">
|
||||
{{ errorMessage }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<WorkstationActionBar>
|
||||
<template #center>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-secondary"
|
||||
:disabled="saveState === 'saving' || submitting"
|
||||
@click="saveDraft"
|
||||
>
|
||||
Save Draft
|
||||
</button>
|
||||
</template>
|
||||
<template #primary>
|
||||
<div class="flex flex-col items-end gap-1">
|
||||
<p class="evidence-level evidence-level--3 mb-0 hidden sm:flex">
|
||||
<span class="evidence-level-mark" aria-hidden="true">3</span>
|
||||
Submit decision
|
||||
</p>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-primary"
|
||||
:disabled="submitting || saveState === 'saving'"
|
||||
@click="submitForVerification"
|
||||
>
|
||||
<option value="">—</option>
|
||||
<option v-for="dept in departments" :key="dept" :value="dept">{{ dept }}</option>
|
||||
</select>
|
||||
{{ submitting ? 'Submitting...' : 'Submit for Verification' }}
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<label class="flex items-center gap-2 text-xs text-gray-500">
|
||||
Room / Bed
|
||||
<OcrConfidenceBadge :label="fieldConfidenceLabel('encounter.roomBed')" :level="fieldConfidenceLevel('encounter.roomBed')" />
|
||||
</label>
|
||||
<input
|
||||
v-model="encounter.roomBed"
|
||||
@blur="saveEncounter"
|
||||
type="text"
|
||||
:class="['form-input', 'text-sm', fieldConfidenceClass('encounter.roomBed')]"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="flex items-center gap-2 text-xs text-gray-500">
|
||||
Admission Reason
|
||||
<OcrConfidenceBadge :label="fieldConfidenceLabel('encounter.admissionReason')" :level="fieldConfidenceLevel('encounter.admissionReason')" />
|
||||
</label>
|
||||
<input
|
||||
v-model="encounter.admissionReason"
|
||||
@blur="saveEncounter"
|
||||
type="text"
|
||||
:class="['form-input', 'text-sm', fieldConfidenceClass('encounter.admissionReason')]"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="showEncounterSummary">
|
||||
<label class="block text-xs text-gray-500">Encounter Status</label>
|
||||
<select v-model="encounter.status" @change="saveEncounter" class="form-input text-sm">
|
||||
<option value="">—</option>
|
||||
<option value="active">Active</option>
|
||||
<option value="discharged">Discharged</option>
|
||||
</select>
|
||||
</div>
|
||||
<div v-if="showEncounterSummary" class="col-span-2">
|
||||
<label class="block text-xs text-gray-500">Discharge Diagnosis</label>
|
||||
<textarea
|
||||
v-model="encounter.dischargeDiagnosis"
|
||||
@blur="saveEncounter"
|
||||
class="form-input text-sm"
|
||||
rows="2"
|
||||
placeholder="Discharge diagnosis..."
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<!-- Observations section -->
|
||||
<fieldset class="border border-gray-200 rounded-md p-4">
|
||||
<legend class="text-sm font-medium text-gray-700 px-2">Observations</legend>
|
||||
<div class="space-y-2">
|
||||
<ObservationRow
|
||||
v-for="obs in observations"
|
||||
:key="obs.id"
|
||||
:observation="obs"
|
||||
:value-input-class="observationValueConfidenceClass(obs.observationCode)"
|
||||
:ocr-label="fieldConfidenceLabel(`observation.${obs.observationCode}.value`)"
|
||||
:ocr-level="fieldConfidenceLevel(`observation.${obs.observationCode}.value`)"
|
||||
@update="(field, value) => handleObsUpdate(obs.id, field, value)"
|
||||
@delete="handleObsDelete"
|
||||
/>
|
||||
<button @click="addObservation" class="btn-primary text-sm">
|
||||
+ Add Observation
|
||||
</template>
|
||||
<template v-if="nextBatchId" #right>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-secondary"
|
||||
:disabled="submitting"
|
||||
data-testid="entry-next-batch"
|
||||
@click="emit('open-next', nextBatchId)"
|
||||
>
|
||||
Next
|
||||
</button>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<!-- Submit -->
|
||||
<div class="flex flex-col sm:flex-row gap-4 pt-4 border-t">
|
||||
<button
|
||||
@click="submitForVerification"
|
||||
class="btn-primary"
|
||||
:disabled="submitting"
|
||||
>
|
||||
{{ submitting ? 'Submitting...' : 'Submit for Verification' }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="errorMessage" class="text-clinical-danger text-sm">
|
||||
{{ errorMessage }}
|
||||
</div>
|
||||
</template>
|
||||
</WorkstationActionBar>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -269,17 +319,35 @@ import { useOcrFieldConfidence } from '../composables/useOcrFieldConfidence'
|
||||
import ObservationRow from '../components/ObservationRow.vue'
|
||||
import StatusBadge from '../components/StatusBadge.vue'
|
||||
import OcrConfidenceBadge from '../components/OcrConfidenceBadge.vue'
|
||||
import WorkstationActionBar from '../components/WorkstationActionBar.vue'
|
||||
import type { BatchDetailResponse, DraftObservation } from '../types'
|
||||
|
||||
const props = defineProps<{
|
||||
batch: BatchDetailResponse | null
|
||||
batchId: string
|
||||
/** Next batch in the current queue list, if any */
|
||||
nextBatchId?: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'open-next', id: string): void
|
||||
}>()
|
||||
|
||||
const batchStore = useBatchStore()
|
||||
const toast = useToast()
|
||||
const submitting = ref(false)
|
||||
const errorMessage = ref('')
|
||||
const saveState = ref<'idle' | 'saving' | 'saved' | 'failed'>('idle')
|
||||
const lastSavedAt = ref<Date | null>(null)
|
||||
|
||||
const saveStatusLabel = computed(() => {
|
||||
if (saveState.value === 'saving') return 'Saving…'
|
||||
if (saveState.value === 'failed') return 'Save failed'
|
||||
if (saveState.value === 'saved' && lastSavedAt.value) {
|
||||
return `Saved ${lastSavedAt.value.toLocaleTimeString()}`
|
||||
}
|
||||
return ''
|
||||
})
|
||||
|
||||
const bloodTypes = ['A+', 'A-', 'B+', 'B-', 'AB+', 'AB-', 'O+', 'O-']
|
||||
const departments = [
|
||||
@@ -346,7 +414,6 @@ const encounter = reactive({
|
||||
|
||||
const observations = ref<DraftObservation[]>([])
|
||||
|
||||
// Load draft data when batch changes
|
||||
watch(
|
||||
() => batchStore.currentDraft,
|
||||
(draft) => {
|
||||
@@ -388,18 +455,29 @@ function removeAllergy(idx: number) {
|
||||
saveAllergies()
|
||||
}
|
||||
|
||||
async function saveAllergies() {
|
||||
async function withSaveFeedback(fn: () => Promise<void>) {
|
||||
saveState.value = 'saving'
|
||||
errorMessage.value = ''
|
||||
try {
|
||||
await fn()
|
||||
lastSavedAt.value = new Date()
|
||||
saveState.value = 'saved'
|
||||
} catch (e: unknown) {
|
||||
saveState.value = 'failed'
|
||||
const msg = e instanceof Error ? e.message : 'Failed to save'
|
||||
errorMessage.value = msg
|
||||
toast.error(msg)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
async function saveAllergies() {
|
||||
await withSaveFeedback(async () => {
|
||||
await batchStore.saveDraftPatient(props.batchId, {
|
||||
...patient,
|
||||
allergies: allergies.value.filter(a => a.trim()),
|
||||
})
|
||||
toast.success('Allergies saved')
|
||||
} catch (e: unknown) {
|
||||
const msg = e instanceof Error ? e.message : 'Failed to save allergies'
|
||||
errorMessage.value = msg
|
||||
toast.error(msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function onNoKnownAllergiesChange() {
|
||||
@@ -419,17 +497,12 @@ function removeMedication(idx: number) {
|
||||
}
|
||||
|
||||
async function saveMedications() {
|
||||
try {
|
||||
await withSaveFeedback(async () => {
|
||||
await batchStore.saveDraftPatient(props.batchId, {
|
||||
...patient,
|
||||
medications: medications.value.filter(m => m.trim()),
|
||||
})
|
||||
toast.success('Medications saved')
|
||||
} catch (e: unknown) {
|
||||
const msg = e instanceof Error ? e.message : 'Failed to save medications'
|
||||
errorMessage.value = msg
|
||||
toast.error(msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function onNoActiveMedicationsChange() {
|
||||
@@ -440,28 +513,33 @@ function onNoActiveMedicationsChange() {
|
||||
}
|
||||
|
||||
async function savePatient() {
|
||||
try {
|
||||
await withSaveFeedback(async () => {
|
||||
await batchStore.saveDraftPatient(props.batchId, {
|
||||
...patient,
|
||||
allergies: patient.noKnownAllergies ? null : allergies.value.filter(a => a.trim()),
|
||||
medications: patient.noActiveMedications ? null : medications.value.filter(m => m.trim()),
|
||||
})
|
||||
toast.success('Patient demographics saved')
|
||||
} catch (e: unknown) {
|
||||
const msg = e instanceof Error ? e.message : 'Failed to save patient'
|
||||
errorMessage.value = msg
|
||||
toast.error(msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function saveEncounter() {
|
||||
try {
|
||||
await withSaveFeedback(async () => {
|
||||
await batchStore.saveDraftEncounter(props.batchId, encounter)
|
||||
toast.success('Encounter context saved')
|
||||
} catch (e: unknown) {
|
||||
const msg = e instanceof Error ? e.message : 'Failed to save encounter'
|
||||
errorMessage.value = msg
|
||||
toast.error(msg)
|
||||
})
|
||||
}
|
||||
|
||||
async function saveDraft() {
|
||||
try {
|
||||
await withSaveFeedback(async () => {
|
||||
await batchStore.saveDraftPatient(props.batchId, {
|
||||
...patient,
|
||||
allergies: patient.noKnownAllergies ? null : allergies.value.filter(a => a.trim()),
|
||||
medications: patient.noActiveMedications ? null : medications.value.filter(m => m.trim()),
|
||||
})
|
||||
await batchStore.saveDraftEncounter(props.batchId, encounter)
|
||||
})
|
||||
} catch {
|
||||
// Feedback already set
|
||||
}
|
||||
}
|
||||
|
||||
@@ -502,4 +580,4 @@ async function submitForVerification() {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -1,67 +1,160 @@
|
||||
<template>
|
||||
<div class="h-full flex flex-col bg-gray-900 rounded-lg overflow-hidden">
|
||||
<!-- Toolbar -->
|
||||
<div class="flex flex-wrap items-center gap-2 p-4 bg-gray-800 text-white text-sm">
|
||||
<button @click="zoomIn" class="px-2 py-1 hover:bg-gray-700 rounded" title="Zoom in">
|
||||
<div
|
||||
class="h-full flex flex-col bg-canvas rounded-card border border-line overflow-hidden"
|
||||
data-testid="scan-viewer"
|
||||
>
|
||||
<!-- Toolbar — light chrome, no decorative overlays on the page -->
|
||||
<div
|
||||
class="flex flex-wrap items-center gap-1 px-3 py-2 bg-surface border-b border-line text-sm text-ink shrink-0"
|
||||
data-testid="scan-viewer-toolbar"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="scan-toolbar-btn"
|
||||
title="Zoom out"
|
||||
:disabled="!url"
|
||||
@click="zoomOut"
|
||||
>
|
||||
−
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="scan-toolbar-btn"
|
||||
title="Zoom in"
|
||||
:disabled="!url"
|
||||
@click="zoomIn"
|
||||
>
|
||||
+
|
||||
</button>
|
||||
<button @click="zoomOut" class="px-2 py-1 hover:bg-gray-700 rounded" title="Zoom out">
|
||||
-
|
||||
<button
|
||||
type="button"
|
||||
class="scan-toolbar-btn"
|
||||
title="Fit width"
|
||||
:disabled="!url"
|
||||
data-testid="scan-fit-width"
|
||||
@click="fitWidth"
|
||||
>
|
||||
Fit width
|
||||
</button>
|
||||
<button @click="resetZoom" class="px-2 py-1 hover:bg-gray-700 rounded" title="Reset">
|
||||
<button
|
||||
type="button"
|
||||
class="scan-toolbar-btn"
|
||||
title="Reset zoom"
|
||||
:disabled="!url"
|
||||
@click="resetZoom"
|
||||
>
|
||||
1:1
|
||||
</button>
|
||||
<button @click="rotateCw" class="px-2 py-1 hover:bg-gray-700 rounded" title="Rotate 90">
|
||||
<button
|
||||
type="button"
|
||||
class="scan-toolbar-btn"
|
||||
title="Rotate 90°"
|
||||
:disabled="!url"
|
||||
@click="rotateCw"
|
||||
>
|
||||
Rotate
|
||||
</button>
|
||||
<span class="ml-auto text-gray-400 text-xs">{{ Math.round(scale * 100) }}%</span>
|
||||
<span class="ml-auto text-ink-secondary text-xs tabular-nums">
|
||||
{{ url ? `${Math.round(scale * 100)}%` : '' }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- Document area -->
|
||||
<!-- Document surface -->
|
||||
<div
|
||||
ref="viewerContainer"
|
||||
class="flex-1 overflow-auto cursor-grab active:cursor-grabbing"
|
||||
class="flex-1 min-h-0 overflow-auto bg-[#E8ECF1]"
|
||||
:class="url && !loading && !error ? 'cursor-grab active:cursor-grabbing' : ''"
|
||||
@mousedown="startPan"
|
||||
@mousemove="pan"
|
||||
@mouseup="stopPan"
|
||||
@mouseleave="stopPan"
|
||||
@wheel.prevent="onWheel"
|
||||
>
|
||||
<div
|
||||
:style="{
|
||||
transform: `translate(${panX}px, ${panY}px) scale(${scale}) rotate(${rotation}deg)`,
|
||||
transformOrigin: 'top left',
|
||||
transition: isPanning ? 'none' : 'transform 0.2s',
|
||||
}"
|
||||
>
|
||||
<!-- PDF/image rendered from same-origin blob URL (avoids cross-origin MinIO iframe issues) -->
|
||||
<iframe
|
||||
v-if="isPdf"
|
||||
:src="url"
|
||||
class="w-[800px] h-[1100px] bg-white"
|
||||
frameborder="0"
|
||||
title="Scanned document"
|
||||
/>
|
||||
<img
|
||||
v-else
|
||||
:src="url"
|
||||
class="max-w-none"
|
||||
draggable="false"
|
||||
@load="onImageLoad"
|
||||
<div v-if="loading" class="flex h-full items-center justify-center p-8">
|
||||
<SkeletonBlock
|
||||
variant="block"
|
||||
height="min(70vh, 640px)"
|
||||
width="min(100%, 480px)"
|
||||
class="max-w-full shadow-page bg-surface"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div v-else-if="error" class="flex h-full items-center justify-center p-6">
|
||||
<InlineError
|
||||
class="max-w-md w-full"
|
||||
title="Could not load document"
|
||||
:message="error"
|
||||
preserved="Your form draft was not affected."
|
||||
retry-label="Retry"
|
||||
@retry="$emit('retry')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-else-if="url"
|
||||
class="p-6 inline-block min-w-full"
|
||||
>
|
||||
<div
|
||||
:style="{
|
||||
transform: `translate(${panX}px, ${panY}px) scale(${scale}) rotate(${rotation}deg)`,
|
||||
transformOrigin: 'top left',
|
||||
transition: isPanning ? 'none' : 'transform 0.15s ease-out',
|
||||
}"
|
||||
>
|
||||
<!-- PDF/image from same-origin blob URL (avoids cross-origin MinIO iframe issues) -->
|
||||
<iframe
|
||||
v-if="isPdf"
|
||||
:src="url"
|
||||
class="scan-page w-[800px] h-[1100px] bg-white"
|
||||
frameborder="0"
|
||||
title="Scanned document"
|
||||
/>
|
||||
<img
|
||||
v-else
|
||||
:src="url"
|
||||
class="scan-page max-w-none bg-white"
|
||||
draggable="false"
|
||||
alt="Scanned document"
|
||||
@load="onImageLoad"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<EmptyState
|
||||
v-else
|
||||
title="No document available"
|
||||
description="The source scan will appear here when the batch document loads."
|
||||
class="h-full"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue'
|
||||
import { ref, computed, watch, nextTick } from 'vue'
|
||||
import SkeletonBlock from './SkeletonBlock.vue'
|
||||
import InlineError from './InlineError.vue'
|
||||
import EmptyState from './EmptyState.vue'
|
||||
|
||||
const props = defineProps<{
|
||||
url: string
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
url?: string | null
|
||||
loading?: boolean
|
||||
error?: string | null
|
||||
}>(),
|
||||
{
|
||||
url: null,
|
||||
loading: false,
|
||||
error: null,
|
||||
}
|
||||
)
|
||||
|
||||
defineEmits<{
|
||||
(e: 'retry'): void
|
||||
}>()
|
||||
|
||||
const isPdf = computed(() => {
|
||||
if (!props.url) return false
|
||||
const lower = props.url.toLowerCase()
|
||||
return lower.includes('.pdf') || lower.includes('application/pdf')
|
||||
})
|
||||
@@ -73,23 +166,44 @@ const panY = ref(0)
|
||||
const isPanning = ref(false)
|
||||
const lastX = ref(0)
|
||||
const lastY = ref(0)
|
||||
const viewerContainer = ref<HTMLElement | null>(null)
|
||||
const naturalPageWidth = ref(800)
|
||||
|
||||
function zoomIn() { scale.value = Math.min(scale.value + 0.25, 5) }
|
||||
function zoomOut() { scale.value = Math.max(scale.value - 0.25, 0.25) }
|
||||
function zoomIn() {
|
||||
scale.value = Math.min(scale.value + 0.25, 5)
|
||||
}
|
||||
function zoomOut() {
|
||||
scale.value = Math.max(scale.value - 0.25, 0.25)
|
||||
}
|
||||
function resetZoom() {
|
||||
scale.value = 1
|
||||
panX.value = 0
|
||||
panY.value = 0
|
||||
rotation.value = 0
|
||||
}
|
||||
function rotateCw() { rotation.value = (rotation.value + 90) % 360 }
|
||||
function rotateCw() {
|
||||
rotation.value = (rotation.value + 90) % 360
|
||||
}
|
||||
|
||||
function fitWidth() {
|
||||
const container = viewerContainer.value
|
||||
if (!container) return
|
||||
const padding = 48 // matches p-6
|
||||
const available = Math.max(container.clientWidth - padding, 120)
|
||||
scale.value = Math.min(Math.max(available / naturalPageWidth.value, 0.25), 5)
|
||||
panX.value = 0
|
||||
panY.value = 0
|
||||
}
|
||||
|
||||
function onWheel(e: WheelEvent) {
|
||||
if (!props.url || props.loading || props.error) return
|
||||
if (e.deltaY < 0) zoomIn()
|
||||
else zoomOut()
|
||||
}
|
||||
|
||||
function startPan(e: MouseEvent) {
|
||||
if (!props.url || props.loading || props.error) return
|
||||
if ((e.target as HTMLElement)?.closest('button')) return
|
||||
isPanning.value = true
|
||||
lastX.value = e.clientX
|
||||
lastY.value = e.clientY
|
||||
@@ -103,12 +217,40 @@ function pan(e: MouseEvent) {
|
||||
lastY.value = e.clientY
|
||||
}
|
||||
|
||||
function stopPan() { isPanning.value = false }
|
||||
function stopPan() {
|
||||
isPanning.value = false
|
||||
}
|
||||
|
||||
function onImageLoad() {
|
||||
// Reset view when a new image loads
|
||||
function onImageLoad(e: Event) {
|
||||
const img = e.target as HTMLImageElement
|
||||
if (img.naturalWidth > 0) {
|
||||
naturalPageWidth.value = img.naturalWidth
|
||||
}
|
||||
scale.value = 1
|
||||
panX.value = 0
|
||||
panY.value = 0
|
||||
nextTick(() => fitWidth())
|
||||
}
|
||||
</script>
|
||||
|
||||
watch(
|
||||
() => props.url,
|
||||
(url) => {
|
||||
if (!url) return
|
||||
if (isPdf.value) {
|
||||
naturalPageWidth.value = 800
|
||||
nextTick(() => fitWidth())
|
||||
}
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.scan-toolbar-btn {
|
||||
@apply px-2 py-1 rounded-control text-ink hover:bg-canvas
|
||||
disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent
|
||||
transition-colors;
|
||||
}
|
||||
.scan-page {
|
||||
box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 16px rgba(16, 24, 40, 0.08);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,199 +1,251 @@
|
||||
<template>
|
||||
<div class="h-full overflow-y-auto p-4 space-y-6">
|
||||
<div class="flex items-center justify-between">
|
||||
<h2 class="text-lg font-semibold">Verification Review</h2>
|
||||
<StatusBadge :status="batch?.status ?? 'PENDING_VERIFICATION'" />
|
||||
</div>
|
||||
|
||||
<div v-if="batch?.rejectionReason" class="bg-red-50 border border-red-200 rounded-md p-4">
|
||||
<p class="text-sm font-medium text-red-800">Previous Rejection Reason:</p>
|
||||
<p class="text-sm text-red-700">{{ batch.rejectionReason }}</p>
|
||||
</div>
|
||||
|
||||
<div v-if="ocrConfidence" class="ocr-banner">
|
||||
Pre-filled by OCR ({{ ocrConfidence.provider }}) — review against the scan.
|
||||
OCR is assistive, not authoritative. Colored borders and badges indicate extraction confidence only.
|
||||
</div>
|
||||
|
||||
<SeparationOfDutiesBanner
|
||||
v-model:blocked="sodBlocked"
|
||||
:entered-by-user-id="batch?.enteredByUserId"
|
||||
:current-user-id="auth.userId"
|
||||
:current-user-name="auth.userFullName"
|
||||
/>
|
||||
|
||||
<!-- Patient review -->
|
||||
<fieldset class="border border-gray-200 rounded-md p-4">
|
||||
<legend class="text-sm font-medium text-gray-700 px-2">Patient Demographics</legend>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div v-for="field in patientFields" :key="field.path">
|
||||
<div class="flex items-center gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="fieldChecks[field.path]"
|
||||
@change="toggleCheck(field.path)"
|
||||
class="w-4 h-4 text-clinical-safe rounded"
|
||||
/>
|
||||
<label class="text-xs text-gray-500">{{ field.label }}</label>
|
||||
<OcrConfidenceBadge
|
||||
:label="fieldConfidenceLabel(field.path)"
|
||||
:level="fieldConfidenceLevel(field.path)"
|
||||
/>
|
||||
</div>
|
||||
<p
|
||||
class="text-sm mt-2 pl-8 font-medium"
|
||||
:class="fieldConfidenceClass(field.path)"
|
||||
>
|
||||
{{ field.value || '(empty)' }}
|
||||
<div class="h-full min-h-0 flex flex-col" data-testid="verification-form">
|
||||
<div class="flex-1 min-h-0 overflow-y-auto p-4 space-y-4">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<div>
|
||||
<p class="evidence-level evidence-level--2 mb-1">
|
||||
<span class="evidence-level-mark" aria-hidden="true">2</span>
|
||||
Verified draft
|
||||
</p>
|
||||
<h2 class="text-base font-semibold text-ink-strong">Verification Review</h2>
|
||||
</div>
|
||||
<StatusBadge :status="batch?.status ?? 'PENDING_VERIFICATION'" />
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<!-- Allergies review (ALLERGY_UPDATE or MIXED) -->
|
||||
<fieldset v-if="allergyFields.length > 0" class="border border-gray-200 rounded-md p-4">
|
||||
<legend class="text-sm font-medium text-gray-700 px-2">Allergies</legend>
|
||||
<div class="space-y-3">
|
||||
<div v-for="field in allergyFields" :key="field.path">
|
||||
<div class="flex items-center gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="fieldChecks[field.path]"
|
||||
@change="toggleCheck(field.path)"
|
||||
class="w-4 h-4 text-clinical-safe rounded"
|
||||
/>
|
||||
<label class="text-xs text-gray-500">{{ field.label }}</label>
|
||||
<OcrConfidenceBadge
|
||||
:label="fieldConfidenceLabel(field.path)"
|
||||
:level="fieldConfidenceLevel(field.path)"
|
||||
/>
|
||||
</div>
|
||||
<p
|
||||
class="text-sm mt-2 pl-8 font-medium"
|
||||
:class="fieldConfidenceClass(field.path)"
|
||||
>
|
||||
{{ field.value || '(empty)' }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<!-- Medications review (MEDICATION_LIST or MIXED) -->
|
||||
<fieldset v-if="medicationFields.length > 0" class="border border-gray-200 rounded-md p-4">
|
||||
<legend class="text-sm font-medium text-gray-700 px-2">Medications</legend>
|
||||
<div class="space-y-3">
|
||||
<div v-for="field in medicationFields" :key="field.path">
|
||||
<div class="flex items-center gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="fieldChecks[field.path]"
|
||||
@change="toggleCheck(field.path)"
|
||||
class="w-4 h-4 text-clinical-safe rounded"
|
||||
/>
|
||||
<label class="text-xs text-gray-500">{{ field.label }}</label>
|
||||
<OcrConfidenceBadge
|
||||
:label="fieldConfidenceLabel(field.path)"
|
||||
:level="fieldConfidenceLevel(field.path)"
|
||||
/>
|
||||
</div>
|
||||
<p
|
||||
class="text-sm mt-2 pl-8 font-medium"
|
||||
:class="fieldConfidenceClass(field.path)"
|
||||
>
|
||||
{{ field.value || '(empty)' }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<!-- Encounter review -->
|
||||
<fieldset class="border border-gray-200 rounded-md p-4">
|
||||
<legend class="text-sm font-medium text-gray-700 px-2">Encounter Context</legend>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div v-for="field in encounterFields" :key="field.path">
|
||||
<div class="flex items-center gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="fieldChecks[field.path]"
|
||||
@change="toggleCheck(field.path)"
|
||||
class="w-4 h-4 text-clinical-safe rounded"
|
||||
/>
|
||||
<label class="text-xs text-gray-500">{{ field.label }}</label>
|
||||
<OcrConfidenceBadge
|
||||
:label="fieldConfidenceLabel(field.path)"
|
||||
:level="fieldConfidenceLevel(field.path)"
|
||||
/>
|
||||
</div>
|
||||
<p
|
||||
class="text-sm mt-2 pl-8 font-medium"
|
||||
:class="fieldConfidenceClass(field.path)"
|
||||
>
|
||||
{{ field.value || '(empty)' }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<!-- Observations review -->
|
||||
<fieldset class="border border-gray-200 rounded-md p-4">
|
||||
<legend class="text-sm font-medium text-gray-700 px-2">
|
||||
Observations ({{ observations.length }})
|
||||
</legend>
|
||||
<div class="space-y-2">
|
||||
<ObservationRow
|
||||
v-for="(obs, index) in observations"
|
||||
:key="obs.id"
|
||||
:observation="obs"
|
||||
:readonly="true"
|
||||
:show-verified="true"
|
||||
:verified="fieldChecks[`observations[${index}].value`] ?? false"
|
||||
:value-input-class="observationValueConfidenceClass(obs.observationCode)"
|
||||
:ocr-label="fieldConfidenceLabel(`observation.${obs.observationCode}.value`)"
|
||||
:ocr-level="fieldConfidenceLevel(`observation.${obs.observationCode}.value`)"
|
||||
@verify="(_obsId, passed) => toggleCheck(`observations[${index}].value`, passed)"
|
||||
/>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<!-- Verification progress -->
|
||||
<div class="bg-gray-50 rounded-md p-4">
|
||||
<div class="flex items-center justify-between text-sm">
|
||||
<span>Fields verified:</span>
|
||||
<span :class="allChecked ? 'text-clinical-safe font-bold' : 'text-gray-600'">
|
||||
{{ checkedCount }} / {{ totalFields }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="w-full bg-gray-200 rounded-full h-2 mt-2">
|
||||
<div
|
||||
class="bg-clinical-safe h-2 rounded-full transition-all"
|
||||
:style="{ width: `${(checkedCount / Math.max(totalFields, 1)) * 100}%` }"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Actions -->
|
||||
<div class="flex flex-col sm:flex-row gap-4 pt-4 border-t">
|
||||
<button
|
||||
@click="approveVerification"
|
||||
class="btn-primary"
|
||||
:disabled="!allChecked || processing || sodBlocked"
|
||||
<div
|
||||
v-if="batch?.rejectionReason"
|
||||
class="rounded-input border border-[#FECDCA] bg-clinical-danger-bg p-3"
|
||||
>
|
||||
{{ processing ? 'Processing...' : 'Approve - Verified' }}
|
||||
</button>
|
||||
<button
|
||||
@click="showRejectDialog = true"
|
||||
class="btn-danger"
|
||||
:disabled="processing || sodBlocked"
|
||||
>
|
||||
Reject
|
||||
</button>
|
||||
<p class="text-sm font-medium text-clinical-danger">Previous Rejection Reason:</p>
|
||||
<p class="text-sm text-ink mt-1">{{ batch.rejectionReason }}</p>
|
||||
</div>
|
||||
|
||||
<div v-if="ocrConfidence" class="ocr-banner">
|
||||
Pre-filled by OCR ({{ ocrConfidence.provider }}) — review against the scan.
|
||||
OCR is assistive, not authoritative. Colored borders and badges indicate extraction confidence only.
|
||||
</div>
|
||||
|
||||
<SeparationOfDutiesBanner
|
||||
v-model:blocked="sodBlocked"
|
||||
:entered-by-user-id="batch?.enteredByUserId"
|
||||
:current-user-id="auth.userId"
|
||||
:current-user-name="auth.userFullName"
|
||||
/>
|
||||
|
||||
<!-- Patient review -->
|
||||
<fieldset class="workstation-form-section">
|
||||
<legend class="workstation-form-legend">Patient Demographics</legend>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-3">
|
||||
<div v-for="field in patientFields" :key="field.path">
|
||||
<div class="flex items-center gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="fieldChecks[field.path]"
|
||||
class="w-4 h-4 text-clinical-safe rounded"
|
||||
@change="toggleCheck(field.path)"
|
||||
/>
|
||||
<label class="text-xs text-ink-secondary">{{ field.label }}</label>
|
||||
<OcrConfidenceBadge
|
||||
:label="fieldConfidenceLabel(field.path)"
|
||||
:level="fieldConfidenceLevel(field.path)"
|
||||
/>
|
||||
</div>
|
||||
<p
|
||||
class="text-sm mt-1.5 pl-6 font-medium"
|
||||
:class="fieldConfidenceClass(field.path)"
|
||||
>
|
||||
{{ field.value || '(empty)' }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<!-- Allergies review -->
|
||||
<fieldset v-if="allergyFields.length > 0" class="workstation-form-section">
|
||||
<legend class="workstation-form-legend">Allergies</legend>
|
||||
<div class="space-y-2.5">
|
||||
<div v-for="field in allergyFields" :key="field.path">
|
||||
<div class="flex items-center gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="fieldChecks[field.path]"
|
||||
class="w-4 h-4 text-clinical-safe rounded"
|
||||
@change="toggleCheck(field.path)"
|
||||
/>
|
||||
<label class="text-xs text-ink-secondary">{{ field.label }}</label>
|
||||
<OcrConfidenceBadge
|
||||
:label="fieldConfidenceLabel(field.path)"
|
||||
:level="fieldConfidenceLevel(field.path)"
|
||||
/>
|
||||
</div>
|
||||
<p
|
||||
class="text-sm mt-1.5 pl-6 font-medium"
|
||||
:class="fieldConfidenceClass(field.path)"
|
||||
>
|
||||
{{ field.value || '(empty)' }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<!-- Medications review -->
|
||||
<fieldset v-if="medicationFields.length > 0" class="workstation-form-section">
|
||||
<legend class="workstation-form-legend">Medications</legend>
|
||||
<div class="space-y-2.5">
|
||||
<div v-for="field in medicationFields" :key="field.path">
|
||||
<div class="flex items-center gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="fieldChecks[field.path]"
|
||||
class="w-4 h-4 text-clinical-safe rounded"
|
||||
@change="toggleCheck(field.path)"
|
||||
/>
|
||||
<label class="text-xs text-ink-secondary">{{ field.label }}</label>
|
||||
<OcrConfidenceBadge
|
||||
:label="fieldConfidenceLabel(field.path)"
|
||||
:level="fieldConfidenceLevel(field.path)"
|
||||
/>
|
||||
</div>
|
||||
<p
|
||||
class="text-sm mt-1.5 pl-6 font-medium"
|
||||
:class="fieldConfidenceClass(field.path)"
|
||||
>
|
||||
{{ field.value || '(empty)' }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<!-- Encounter review -->
|
||||
<fieldset class="workstation-form-section">
|
||||
<legend class="workstation-form-legend">Encounter Context</legend>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-3">
|
||||
<div v-for="field in encounterFields" :key="field.path">
|
||||
<div class="flex items-center gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="fieldChecks[field.path]"
|
||||
class="w-4 h-4 text-clinical-safe rounded"
|
||||
@change="toggleCheck(field.path)"
|
||||
/>
|
||||
<label class="text-xs text-ink-secondary">{{ field.label }}</label>
|
||||
<OcrConfidenceBadge
|
||||
:label="fieldConfidenceLabel(field.path)"
|
||||
:level="fieldConfidenceLevel(field.path)"
|
||||
/>
|
||||
</div>
|
||||
<p
|
||||
class="text-sm mt-1.5 pl-6 font-medium"
|
||||
:class="fieldConfidenceClass(field.path)"
|
||||
>
|
||||
{{ field.value || '(empty)' }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<!-- Observations review -->
|
||||
<fieldset class="workstation-form-section">
|
||||
<legend class="workstation-form-legend">
|
||||
Observations ({{ observations.length }})
|
||||
</legend>
|
||||
<div class="space-y-2">
|
||||
<ObservationRow
|
||||
v-for="(obs, index) in observations"
|
||||
:key="obs.id"
|
||||
:observation="obs"
|
||||
:readonly="true"
|
||||
:show-verified="true"
|
||||
:verified="fieldChecks[`observations[${index}].value`] ?? false"
|
||||
:value-input-class="observationValueConfidenceClass(obs.observationCode)"
|
||||
:ocr-label="fieldConfidenceLabel(`observation.${obs.observationCode}.value`)"
|
||||
:ocr-level="fieldConfidenceLevel(`observation.${obs.observationCode}.value`)"
|
||||
@verify="(_obsId, passed) => toggleCheck(`observations[${index}].value`, passed)"
|
||||
/>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<!-- Verification progress (field checks only — not analytics chrome) -->
|
||||
<div class="rounded-input border border-line bg-canvas p-3">
|
||||
<div class="flex items-center justify-between text-sm">
|
||||
<span class="text-ink-secondary">Fields verified:</span>
|
||||
<span :class="allChecked ? 'text-clinical-safe font-semibold' : 'text-ink'">
|
||||
{{ checkedCount }} / {{ totalFields }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="w-full bg-line rounded-full h-1.5 mt-2">
|
||||
<div
|
||||
class="bg-clinical-safe h-1.5 rounded-full transition-all"
|
||||
:style="{ width: `${(checkedCount / Math.max(totalFields, 1)) * 100}%` }"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="errorMessage" class="text-clinical-danger text-sm" role="alert">
|
||||
{{ errorMessage }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<WorkstationActionBar>
|
||||
<template #center>
|
||||
<div class="flex flex-col gap-2">
|
||||
<p class="evidence-level evidence-level--3 mb-0">
|
||||
<span class="evidence-level-mark" aria-hidden="true">3</span>
|
||||
Verification decision
|
||||
</p>
|
||||
<div class="flex flex-wrap items-center gap-4 text-sm" role="radiogroup" aria-label="Verification decision">
|
||||
<label class="inline-flex items-center gap-2 cursor-pointer">
|
||||
<input
|
||||
v-model="decision"
|
||||
type="radio"
|
||||
value="pass"
|
||||
class="text-clinical-safe"
|
||||
:disabled="sodBlocked || processing"
|
||||
/>
|
||||
<span :class="sodBlocked ? 'text-ink-disabled' : 'text-ink'">Pass</span>
|
||||
</label>
|
||||
<label class="inline-flex items-center gap-2 cursor-pointer">
|
||||
<input
|
||||
v-model="decision"
|
||||
type="radio"
|
||||
value="reject"
|
||||
class="text-clinical-danger"
|
||||
:disabled="sodBlocked || processing"
|
||||
/>
|
||||
<span :class="sodBlocked ? 'text-ink-disabled' : 'text-ink'">Reject</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #primary>
|
||||
<button
|
||||
v-if="decision === 'pass'"
|
||||
type="button"
|
||||
class="btn-primary"
|
||||
:disabled="!allChecked || processing || sodBlocked"
|
||||
data-testid="verify-pass"
|
||||
@click="approveVerification"
|
||||
>
|
||||
{{ processing ? 'Processing...' : 'Pass Verification' }}
|
||||
</button>
|
||||
<button
|
||||
v-else-if="decision === 'reject'"
|
||||
type="button"
|
||||
class="btn-danger"
|
||||
:disabled="processing || sodBlocked"
|
||||
data-testid="verify-return"
|
||||
@click="showRejectDialog = true"
|
||||
>
|
||||
Return for Rework
|
||||
</button>
|
||||
</template>
|
||||
</WorkstationActionBar>
|
||||
|
||||
<ConfirmDialog
|
||||
:open="showRejectDialog"
|
||||
title="Reject Batch"
|
||||
title="Return for Rework"
|
||||
body="This returns the batch for rework. A reason is required."
|
||||
confirm-label="Confirm Rejection"
|
||||
confirm-label="Return for Rework"
|
||||
variant="danger"
|
||||
:confirm-disabled="!rejectionReason.trim() || processing"
|
||||
@confirm="rejectVerification"
|
||||
@@ -206,10 +258,6 @@
|
||||
placeholder="Reason for rejection (required)..."
|
||||
/>
|
||||
</ConfirmDialog>
|
||||
|
||||
<div v-if="errorMessage" class="text-clinical-danger text-sm">
|
||||
{{ errorMessage }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -225,6 +273,7 @@ import StatusBadge from '../components/StatusBadge.vue'
|
||||
import OcrConfidenceBadge from '../components/OcrConfidenceBadge.vue'
|
||||
import SeparationOfDutiesBanner from '../components/SeparationOfDutiesBanner.vue'
|
||||
import ConfirmDialog from '../components/ConfirmDialog.vue'
|
||||
import WorkstationActionBar from '../components/WorkstationActionBar.vue'
|
||||
import type { BatchDetailResponse, DraftObservation } from '../types'
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -241,6 +290,7 @@ const errorMessage = ref('')
|
||||
const showRejectDialog = ref(false)
|
||||
const rejectionReason = ref('')
|
||||
const sodBlocked = ref(false)
|
||||
const decision = ref<'pass' | 'reject' | null>(null)
|
||||
|
||||
const fieldChecks = ref<Record<string, boolean>>({})
|
||||
const observations = ref<DraftObservation[]>([])
|
||||
@@ -280,7 +330,6 @@ watch(
|
||||
|
||||
observations.value = draft.observations ?? []
|
||||
|
||||
// Build patient field list
|
||||
if (draft.patient) {
|
||||
patientFields.value = [
|
||||
{ path: 'patient.fullName', label: 'Full Name', value: draft.patient.fullName ?? '' },
|
||||
@@ -290,7 +339,6 @@ watch(
|
||||
{ path: 'patient.emergencyContact', label: 'Emergency Contact', value: draft.patient.emergencyContact ?? '' },
|
||||
]
|
||||
|
||||
// Build allergy fields
|
||||
allergyFields.value = []
|
||||
if (showAllergies.value) {
|
||||
if (draft.patient.noKnownAllergies) {
|
||||
@@ -312,7 +360,6 @@ watch(
|
||||
}
|
||||
}
|
||||
|
||||
// Build medication fields
|
||||
medicationFields.value = []
|
||||
if (showMedications.value) {
|
||||
if (draft.patient.noActiveMedications) {
|
||||
@@ -335,7 +382,6 @@ watch(
|
||||
}
|
||||
}
|
||||
|
||||
// Build encounter field list
|
||||
if (draft.encounter) {
|
||||
encounterFields.value = [
|
||||
{ path: 'encounter.admissionDate', label: 'Admission Date', value: draft.encounter.admissionDate ?? '' },
|
||||
@@ -351,7 +397,6 @@ watch(
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize all checks to false
|
||||
fieldChecks.value = {}
|
||||
patientFields.value.forEach((f) => { fieldChecks.value[f.path] = false })
|
||||
allergyFields.value.forEach((f) => { fieldChecks.value[f.path] = false })
|
||||
@@ -362,6 +407,10 @@ watch(
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
watch(sodBlocked, (blocked) => {
|
||||
if (blocked) decision.value = null
|
||||
})
|
||||
|
||||
const totalFields = computed(
|
||||
() => patientFields.value.length + allergyFields.value.length + medicationFields.value.length
|
||||
+ encounterFields.value.length + observations.value.length
|
||||
@@ -376,7 +425,7 @@ function toggleCheck(path: string, value?: boolean) {
|
||||
}
|
||||
|
||||
async function approveVerification() {
|
||||
if (sodBlocked.value) return
|
||||
if (sodBlocked.value || decision.value !== 'pass') return
|
||||
processing.value = true
|
||||
errorMessage.value = ''
|
||||
try {
|
||||
@@ -397,12 +446,13 @@ async function approveVerification() {
|
||||
}
|
||||
|
||||
async function rejectVerification() {
|
||||
if (sodBlocked.value) return
|
||||
processing.value = true
|
||||
errorMessage.value = ''
|
||||
try {
|
||||
await batchStore.rejectBatch(props.batchId, rejectionReason.value)
|
||||
showRejectDialog.value = false
|
||||
toast.warning('Batch rejected')
|
||||
toast.warning('Batch returned for rework')
|
||||
router.push('/verification')
|
||||
} catch (e: unknown) {
|
||||
const msg = e instanceof Error ? e.message : 'Rejection failed'
|
||||
@@ -412,4 +462,4 @@ async function rejectVerification() {
|
||||
processing.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<template>
|
||||
<!-- Queue-only: full-width list with empty/skeleton patterns from the list slot -->
|
||||
<div
|
||||
v-if="!hasBatch"
|
||||
class="flex-1 min-h-0 overflow-auto p-4 sm:p-6"
|
||||
data-testid="workstation-queue"
|
||||
>
|
||||
<slot name="queue" />
|
||||
</div>
|
||||
|
||||
<!-- Work mode: optional left rail + dominant scan + form (desktop ≥1280px) -->
|
||||
<div
|
||||
v-else
|
||||
class="workstation-split flex-1 min-h-0"
|
||||
:class="{ 'workstation-split--no-rail': !showRail }"
|
||||
data-testid="workstation-split"
|
||||
>
|
||||
<aside
|
||||
v-if="showRail"
|
||||
class="workstation-rail hidden xl:flex min-h-0"
|
||||
data-testid="workstation-rail"
|
||||
>
|
||||
<slot name="rail" />
|
||||
</aside>
|
||||
<section class="workstation-scan min-h-0 min-w-0" data-testid="workstation-scan">
|
||||
<p class="evidence-level evidence-level--1" data-testid="evidence-level-1">
|
||||
<span class="evidence-level-mark" aria-hidden="true">1</span>
|
||||
Source scan
|
||||
</p>
|
||||
<div class="min-h-0 flex-1 flex flex-col">
|
||||
<slot name="scan" />
|
||||
</div>
|
||||
</section>
|
||||
<section class="workstation-form min-h-0 min-w-0" data-testid="workstation-form">
|
||||
<slot name="form" />
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, useSlots } from 'vue'
|
||||
|
||||
const props = defineProps<{
|
||||
/** When false, render full-width queue slot only */
|
||||
hasBatch: boolean
|
||||
}>()
|
||||
|
||||
const slots = useSlots()
|
||||
const showRail = computed(() => props.hasBatch && !!slots.rail)
|
||||
</script>
|
||||
@@ -0,0 +1,89 @@
|
||||
<template>
|
||||
<div
|
||||
class="flex h-full w-full min-h-0 flex-col bg-surface border-r border-line"
|
||||
data-testid="workstation-queue-rail"
|
||||
>
|
||||
<div class="shrink-0 border-b border-line px-3 py-2.5">
|
||||
<h3 class="text-xs font-semibold uppercase tracking-wide text-ink-secondary">
|
||||
{{ title }}
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div class="min-h-0 flex-1 overflow-y-auto">
|
||||
<SkeletonBlock
|
||||
v-if="loading && batches.length === 0"
|
||||
variant="row"
|
||||
:rows="5"
|
||||
class="p-3"
|
||||
/>
|
||||
<EmptyState
|
||||
v-else-if="batches.length === 0"
|
||||
title="No batches in queue"
|
||||
description="Assigned or pending items appear here."
|
||||
class="!py-6"
|
||||
/>
|
||||
<button
|
||||
v-for="batch in batches"
|
||||
:key="batch.id"
|
||||
type="button"
|
||||
class="w-full border-b border-line border-l-2 px-3 py-2.5 text-left transition-colors hover:bg-primary-50"
|
||||
:class="
|
||||
batch.id === selectedId
|
||||
? 'border-l-primary-600 bg-primary-50'
|
||||
: 'border-l-transparent'
|
||||
"
|
||||
:aria-current="batch.id === selectedId ? 'true' : undefined"
|
||||
@click="$emit('select', batch.id)"
|
||||
>
|
||||
<div class="font-mono text-xs font-medium text-ink-strong">
|
||||
{{ batch.id.substring(0, 8) }}…
|
||||
</div>
|
||||
<div class="mt-0.5 text-xs text-ink-secondary truncate">
|
||||
{{ formatBatchType(batch.batchType) }}
|
||||
</div>
|
||||
<div class="mt-1.5">
|
||||
<StatusBadge :status="batch.status" />
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="shrink-0 border-t border-line p-2">
|
||||
<button
|
||||
type="button"
|
||||
class="w-full rounded-input px-2 py-1.5 text-xs font-medium text-primary-600 hover:bg-primary-50"
|
||||
@click="$emit('back')"
|
||||
>
|
||||
Full queue
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { BatchDetailResponse } from '../types'
|
||||
import StatusBadge from './StatusBadge.vue'
|
||||
import EmptyState from './EmptyState.vue'
|
||||
import SkeletonBlock from './SkeletonBlock.vue'
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
title?: string
|
||||
batches: BatchDetailResponse[]
|
||||
selectedId?: string
|
||||
loading?: boolean
|
||||
}>(),
|
||||
{
|
||||
title: 'Queue',
|
||||
loading: false,
|
||||
}
|
||||
)
|
||||
|
||||
defineEmits<{
|
||||
(e: 'select', id: string): void
|
||||
(e: 'back'): void
|
||||
}>()
|
||||
|
||||
function formatBatchType(type: string): string {
|
||||
return type.replace(/_/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase())
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user