feature: Shared UX Primitives
This commit is contained in:
@@ -1,12 +1,26 @@
|
||||
<template>
|
||||
<div class="overflow-x-auto">
|
||||
<div v-if="loading" class="text-gray-500 text-center py-4">Loading...</div>
|
||||
<div v-else-if="batches.length === 0" class="text-gray-500 text-center py-4">
|
||||
No batches found.
|
||||
</div>
|
||||
<InlineError
|
||||
v-if="error"
|
||||
title="Could not load batches"
|
||||
:message="error"
|
||||
preserved="Your filters and previous selections were preserved."
|
||||
retry-label="Retry"
|
||||
@retry="$emit('retry')"
|
||||
/>
|
||||
<SkeletonBlock v-else-if="loading" variant="table" :rows="5" />
|
||||
<EmptyState
|
||||
v-else-if="batches.length === 0"
|
||||
:title="emptyTitle"
|
||||
:description="emptyDescription"
|
||||
>
|
||||
<template v-if="$slots.emptyAction" #action>
|
||||
<slot name="emptyAction" />
|
||||
</template>
|
||||
</EmptyState>
|
||||
<table v-else class="w-full min-w-[640px] text-sm">
|
||||
<thead>
|
||||
<tr class="border-b text-left text-gray-600">
|
||||
<tr class="border-b text-left text-ink-secondary">
|
||||
<th class="py-2 px-4">ID</th>
|
||||
<th class="py-2 px-4">Type</th>
|
||||
<th class="py-2 px-4">Track</th>
|
||||
@@ -19,7 +33,7 @@
|
||||
<tr
|
||||
v-for="batch in batches"
|
||||
:key="batch.id"
|
||||
class="border-b hover:bg-gray-50 cursor-pointer"
|
||||
class="border-b hover:bg-primary-50 cursor-pointer"
|
||||
@click="$emit('select', batch.id)"
|
||||
>
|
||||
<td class="py-2 px-4 font-mono text-xs">{{ batch.id.substring(0, 8) }}...</td>
|
||||
@@ -27,27 +41,23 @@
|
||||
<td class="py-2 px-4">
|
||||
<span
|
||||
:class="batch.track === 'BACKFILL'
|
||||
? 'bg-blue-100 text-blue-800'
|
||||
: 'bg-green-100 text-green-800'"
|
||||
? 'bg-primary-50 text-primary-800 border border-primary-100'
|
||||
: 'bg-clinical-safe-bg text-clinical-safe border border-[#ABEFC6]'"
|
||||
class="status-badge"
|
||||
>
|
||||
{{ batch.track === 'BACKFILL' ? 'Backfill' : 'Live' }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="py-2 px-4">
|
||||
<span
|
||||
:class="statusColor(batch.status)"
|
||||
class="status-badge"
|
||||
>
|
||||
{{ formatStatus(batch.status) }}
|
||||
</span>
|
||||
<StatusBadge :status="batch.status" />
|
||||
</td>
|
||||
<td class="py-2 px-4 text-gray-500">
|
||||
<td class="py-2 px-4 text-ink-secondary">
|
||||
{{ new Date(batch.createdAt).toLocaleString() }}
|
||||
</td>
|
||||
<td v-if="showAssign" class="py-2 px-4">
|
||||
<button
|
||||
v-if="batch.status === 'UPLOADED'"
|
||||
type="button"
|
||||
@click.stop="$emit('assign', batch.id)"
|
||||
class="text-primary-600 hover:text-primary-800 text-xs font-medium"
|
||||
>
|
||||
@@ -62,37 +72,33 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { BatchDetailResponse } from '../types'
|
||||
import StatusBadge from './StatusBadge.vue'
|
||||
import EmptyState from './EmptyState.vue'
|
||||
import SkeletonBlock from './SkeletonBlock.vue'
|
||||
import InlineError from './InlineError.vue'
|
||||
|
||||
defineProps<{
|
||||
batches: BatchDetailResponse[]
|
||||
loading: boolean
|
||||
showAssign?: boolean
|
||||
}>()
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
batches: BatchDetailResponse[]
|
||||
loading: boolean
|
||||
showAssign?: boolean
|
||||
error?: string | null
|
||||
emptyTitle?: string
|
||||
emptyDescription?: string
|
||||
}>(),
|
||||
{
|
||||
emptyTitle: 'No batches found.',
|
||||
emptyDescription: undefined,
|
||||
}
|
||||
)
|
||||
|
||||
defineEmits<{
|
||||
(e: 'select', batchId: string): void
|
||||
(e: 'assign', batchId: string): void
|
||||
(e: 'retry'): void
|
||||
}>()
|
||||
|
||||
function formatBatchType(type: string): string {
|
||||
return type.replace(/_/g, ' ').replace(/\b\w/g, c => c.toUpperCase())
|
||||
}
|
||||
|
||||
function formatStatus(status: string): string {
|
||||
return status.replace(/_/g, ' ').replace(/\b\w/g, c => c.toUpperCase())
|
||||
}
|
||||
|
||||
function statusColor(status: string): string {
|
||||
const colors: Record<string, string> = {
|
||||
UPLOADED: 'bg-gray-100 text-gray-800',
|
||||
IN_ENTRY: 'bg-yellow-100 text-yellow-800',
|
||||
PENDING_VERIFICATION: 'bg-orange-100 text-orange-800',
|
||||
REJECTED: 'bg-red-100 text-red-800',
|
||||
VERIFIED: 'bg-blue-100 text-blue-800',
|
||||
AWAITING_CLINICAL_APPROVAL: 'bg-purple-100 text-purple-800',
|
||||
APPROVED: 'bg-green-100 text-green-800',
|
||||
PROMOTED: 'bg-emerald-100 text-emerald-800',
|
||||
}
|
||||
return colors[status] ?? 'bg-gray-100 text-gray-800'
|
||||
return type.replace(/_/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase())
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<div
|
||||
v-if="open"
|
||||
class="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
:aria-labelledby="titleId"
|
||||
data-testid="confirm-dialog"
|
||||
@keydown.esc.prevent="$emit('cancel')"
|
||||
>
|
||||
<div
|
||||
class="w-full max-w-md rounded-card border border-line bg-surface p-6 shadow-dialog"
|
||||
@click.stop
|
||||
>
|
||||
<h3 :id="titleId" class="text-lg font-semibold text-ink-strong">
|
||||
{{ title }}
|
||||
</h3>
|
||||
<p v-if="body" class="mt-2 text-sm text-ink">{{ body }}</p>
|
||||
<div v-if="$slots.default" class="mt-4">
|
||||
<slot />
|
||||
</div>
|
||||
<div class="mt-6 flex flex-col-reverse gap-3 sm:flex-row sm:justify-end">
|
||||
<button
|
||||
type="button"
|
||||
class="px-4 py-2 text-sm text-ink-secondary hover:text-ink-strong"
|
||||
@click="$emit('cancel')"
|
||||
>
|
||||
{{ cancelLabel }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="variant === 'danger' ? 'btn-danger' : 'btn-primary'"
|
||||
:disabled="confirmDisabled"
|
||||
@click="$emit('confirm')"
|
||||
>
|
||||
{{ confirmLabel }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useId } from 'vue'
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
open: boolean
|
||||
title: string
|
||||
body?: string
|
||||
confirmLabel?: string
|
||||
cancelLabel?: string
|
||||
variant?: 'primary' | 'danger'
|
||||
confirmDisabled?: boolean
|
||||
}>(),
|
||||
{
|
||||
confirmLabel: 'Confirm',
|
||||
cancelLabel: 'Cancel',
|
||||
variant: 'primary',
|
||||
confirmDisabled: false,
|
||||
}
|
||||
)
|
||||
|
||||
defineEmits<{
|
||||
(e: 'confirm'): void
|
||||
(e: 'cancel'): void
|
||||
}>()
|
||||
|
||||
const titleId = useId()
|
||||
</script>
|
||||
@@ -0,0 +1,18 @@
|
||||
<template>
|
||||
<div class="flex flex-col items-center justify-center text-center py-10 px-4">
|
||||
<h3 class="text-base font-semibold text-ink-strong">{{ title }}</h3>
|
||||
<p v-if="description" class="mt-2 text-sm text-ink-secondary max-w-md">
|
||||
{{ description }}
|
||||
</p>
|
||||
<div v-if="$slots.action" class="mt-4">
|
||||
<slot name="action" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
defineProps<{
|
||||
title: string
|
||||
description?: string
|
||||
}>()
|
||||
</script>
|
||||
@@ -2,17 +2,12 @@
|
||||
<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>
|
||||
<span
|
||||
:class="statusColor"
|
||||
class="status-badge"
|
||||
>
|
||||
{{ batch?.status?.replace(/_/g, ' ') }}
|
||||
</span>
|
||||
<StatusBadge :status="batch?.status" />
|
||||
</div>
|
||||
|
||||
<div v-if="ocrConfidence" class="ocr-banner">
|
||||
Pre-filled by OCR ({{ ocrConfidence.provider }}).
|
||||
Review all values against the scan before submitting.
|
||||
Pre-filled by OCR ({{ ocrConfidence.provider }}) — review against the scan.
|
||||
OCR is assistive, not authoritative.
|
||||
</div>
|
||||
|
||||
<!-- Patient section -->
|
||||
@@ -20,7 +15,10 @@
|
||||
<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>
|
||||
<label class="block text-xs text-gray-500">Full Name</label>
|
||||
<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"
|
||||
@@ -29,7 +27,10 @@
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs text-gray-500">Date of Birth</label>
|
||||
<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"
|
||||
@@ -38,7 +39,10 @@
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs text-gray-500">Sex</label>
|
||||
<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"
|
||||
@@ -150,7 +154,10 @@
|
||||
<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="block text-xs text-gray-500">Admission Date</label>
|
||||
<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"
|
||||
@@ -159,7 +166,10 @@
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs text-gray-500">Department</label>
|
||||
<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"
|
||||
@@ -170,7 +180,10 @@
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs text-gray-500">Room / Bed</label>
|
||||
<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"
|
||||
@@ -179,7 +192,10 @@
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs text-gray-500">Admission Reason</label>
|
||||
<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"
|
||||
@@ -217,6 +233,8 @@
|
||||
: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"
|
||||
/>
|
||||
@@ -249,6 +267,8 @@ import { useBatchStore } from '../stores/batches'
|
||||
import { useToast } from '../composables/useToast'
|
||||
import { useOcrFieldConfidence } from '../composables/useOcrFieldConfidence'
|
||||
import ObservationRow from '../components/ObservationRow.vue'
|
||||
import StatusBadge from '../components/StatusBadge.vue'
|
||||
import OcrConfidenceBadge from '../components/OcrConfidenceBadge.vue'
|
||||
import type { BatchDetailResponse, DraftObservation } from '../types'
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -287,7 +307,11 @@ const departments = [
|
||||
|
||||
const fieldReqs = computed(() => batchStore.currentDraft?.fieldRequirements)
|
||||
const ocrConfidence = computed(() => batchStore.currentDraft?.ocrConfidence ?? null)
|
||||
const { fieldConfidenceClass } = useOcrFieldConfidence(ocrConfidence)
|
||||
const {
|
||||
fieldConfidenceClass,
|
||||
fieldConfidenceLabel,
|
||||
fieldConfidenceLevel,
|
||||
} = useOcrFieldConfidence(ocrConfidence)
|
||||
|
||||
function observationValueConfidenceClass(observationCode: string): string {
|
||||
if (!observationCode) return ''
|
||||
@@ -322,8 +346,6 @@ const encounter = reactive({
|
||||
|
||||
const observations = ref<DraftObservation[]>([])
|
||||
|
||||
const statusColor = ref('bg-gray-100 text-gray-800')
|
||||
|
||||
// Load draft data when batch changes
|
||||
watch(
|
||||
() => batchStore.currentDraft,
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<template>
|
||||
<div
|
||||
class="rounded-input border border-[#FECDCA] bg-clinical-danger-bg p-4"
|
||||
role="alert"
|
||||
>
|
||||
<p class="text-sm font-semibold text-clinical-danger">{{ title }}</p>
|
||||
<p v-if="message" class="mt-1 text-sm text-ink">{{ message }}</p>
|
||||
<p v-if="preserved" class="mt-2 text-sm text-ink-secondary">{{ preserved }}</p>
|
||||
<div class="mt-3 flex flex-wrap items-center gap-3">
|
||||
<button
|
||||
v-if="retryLabel"
|
||||
type="button"
|
||||
class="btn-secondary text-sm py-1.5"
|
||||
@click="$emit('retry')"
|
||||
>
|
||||
{{ retryLabel }}
|
||||
</button>
|
||||
<slot name="actions" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
title: string
|
||||
message?: string
|
||||
/** What was preserved / not lost */
|
||||
preserved?: string
|
||||
retryLabel?: string
|
||||
}>(),
|
||||
{
|
||||
retryLabel: 'Retry',
|
||||
}
|
||||
)
|
||||
|
||||
defineEmits<{
|
||||
(e: 'retry'): void
|
||||
}>()
|
||||
</script>
|
||||
@@ -23,7 +23,10 @@
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs text-gray-500">Value</label>
|
||||
<label class="flex items-center gap-2 text-xs text-gray-500">
|
||||
Value
|
||||
<OcrConfidenceBadge :label="ocrLabel" :level="ocrLevel" />
|
||||
</label>
|
||||
<input
|
||||
:value="observation.value"
|
||||
@change="update('value', parseFloat(($event.target as HTMLInputElement).value))"
|
||||
@@ -90,13 +93,17 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { DraftObservation } from '../types'
|
||||
import type { OcrConfidenceLevel } from '../composables/useOcrFieldConfidence'
|
||||
import OcrConfidenceBadge from './OcrConfidenceBadge.vue'
|
||||
|
||||
const props = defineProps<{
|
||||
defineProps<{
|
||||
observation: DraftObservation
|
||||
readonly?: boolean
|
||||
showVerified?: boolean
|
||||
verified?: boolean
|
||||
valueInputClass?: string
|
||||
ocrLabel?: string | null
|
||||
ocrLevel?: OcrConfidenceLevel | null
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
<template>
|
||||
<span
|
||||
v-if="label"
|
||||
class="ocr-confidence-badge"
|
||||
:class="badgeClass"
|
||||
:title="title"
|
||||
>
|
||||
{{ label }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import {
|
||||
confidenceToLevel,
|
||||
formatOcrBadgeLabel,
|
||||
type OcrConfidenceLevel,
|
||||
} from '../composables/useOcrFieldConfidence'
|
||||
|
||||
const props = defineProps<{
|
||||
/** 0–1 confidence; omit or undefined hides the badge */
|
||||
confidence?: number | null
|
||||
label?: string | null
|
||||
level?: OcrConfidenceLevel | null
|
||||
}>()
|
||||
|
||||
const resolvedLevel = computed<OcrConfidenceLevel | null>(() => {
|
||||
if (props.level) return props.level
|
||||
if (props.confidence === undefined || props.confidence === null) return null
|
||||
return confidenceToLevel(props.confidence)
|
||||
})
|
||||
|
||||
const label = computed(() => {
|
||||
if (props.label) return props.label
|
||||
if (props.confidence === undefined || props.confidence === null) return null
|
||||
return formatOcrBadgeLabel(props.confidence)
|
||||
})
|
||||
|
||||
const badgeClass = computed(() => {
|
||||
const level = resolvedLevel.value
|
||||
if (!level) return ''
|
||||
return `ocr-badge-${level}`
|
||||
})
|
||||
|
||||
const title = computed(() => {
|
||||
if (!label.value) return undefined
|
||||
return 'OCR extraction confidence — assistive only; verify against the scan'
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,77 @@
|
||||
<template>
|
||||
<div
|
||||
v-if="show"
|
||||
class="rounded-input border p-4 text-sm"
|
||||
:class="blocked
|
||||
? 'border-[#FECDCA] bg-clinical-danger-bg'
|
||||
: 'border-primary-100 bg-primary-50'"
|
||||
role="status"
|
||||
data-testid="sod-banner"
|
||||
>
|
||||
<template v-if="blocked">
|
||||
<p class="font-semibold text-clinical-danger">
|
||||
You cannot verify a batch you entered.
|
||||
</p>
|
||||
<p class="mt-1 text-ink-secondary">
|
||||
Separation of Duties requires a different verifier. Select another batch or ask a colleague to continue.
|
||||
</p>
|
||||
</template>
|
||||
<template v-else>
|
||||
<p class="font-semibold text-primary-800">Separation of Duties Enforced</p>
|
||||
<dl class="mt-2 grid gap-1 text-ink sm:grid-cols-2">
|
||||
<div>
|
||||
<dt class="text-xs text-ink-secondary">Entered by</dt>
|
||||
<dd class="font-medium">{{ enteredDisplay }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-xs text-ink-secondary">Current verifier</dt>
|
||||
<dd class="font-medium">{{ currentDisplay }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, watch } from 'vue'
|
||||
|
||||
const props = defineProps<{
|
||||
enteredByUserId?: string | null
|
||||
enteredByUserName?: string | null
|
||||
currentUserId?: string | null
|
||||
currentUserName?: string | null
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:blocked', value: boolean): void
|
||||
}>()
|
||||
|
||||
const show = computed(
|
||||
() => !!(props.enteredByUserId && props.currentUserId)
|
||||
)
|
||||
|
||||
const blocked = computed(
|
||||
() =>
|
||||
show.value &&
|
||||
props.enteredByUserId === props.currentUserId
|
||||
)
|
||||
|
||||
watch(
|
||||
blocked,
|
||||
(value) => emit('update:blocked', value),
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
function displayUser(id: string | null | undefined, name?: string | null): string {
|
||||
if (name?.trim()) return name.trim()
|
||||
if (!id) return 'Unknown'
|
||||
return id.length > 8 ? `${id.substring(0, 8)}…` : id
|
||||
}
|
||||
|
||||
const enteredDisplay = computed(() =>
|
||||
displayUser(props.enteredByUserId, props.enteredByUserName)
|
||||
)
|
||||
const currentDisplay = computed(() =>
|
||||
displayUser(props.currentUserId, props.currentUserName)
|
||||
)
|
||||
</script>
|
||||
@@ -0,0 +1,61 @@
|
||||
<template>
|
||||
<div
|
||||
class="animate-pulse"
|
||||
:class="variant === 'inline' ? 'inline-block' : 'w-full'"
|
||||
role="status"
|
||||
aria-busy="true"
|
||||
aria-label="Loading"
|
||||
>
|
||||
<template v-if="variant === 'table'">
|
||||
<div class="space-y-3 py-2">
|
||||
<div
|
||||
v-for="i in rows"
|
||||
:key="i"
|
||||
class="grid grid-cols-5 gap-3 items-center"
|
||||
>
|
||||
<div class="h-3 rounded bg-line" />
|
||||
<div class="h-3 rounded bg-line" />
|
||||
<div class="h-3 rounded bg-line w-3/4" />
|
||||
<div class="h-5 rounded-control bg-line w-24" />
|
||||
<div class="h-3 rounded bg-line w-2/3" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="variant === 'row'">
|
||||
<div class="space-y-2">
|
||||
<div
|
||||
v-for="i in rows"
|
||||
:key="i"
|
||||
class="h-4 rounded bg-line"
|
||||
:style="{ width: rowWidth(i) }"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<div
|
||||
v-else
|
||||
class="rounded bg-line"
|
||||
:style="{ height: height ?? '1rem', width: width ?? '100%' }"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
/** `block` = single rectangle; `row` = stacked lines; `table` = list-row placeholders */
|
||||
variant?: 'block' | 'row' | 'table' | 'inline'
|
||||
rows?: number
|
||||
height?: string
|
||||
width?: string
|
||||
}>(),
|
||||
{
|
||||
variant: 'block',
|
||||
rows: 5,
|
||||
}
|
||||
)
|
||||
|
||||
function rowWidth(index: number): string {
|
||||
const widths = ['100%', '92%', '85%', '96%', '78%']
|
||||
return widths[(index - 1) % widths.length]
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,66 @@
|
||||
<template>
|
||||
<span
|
||||
class="status-badge inline-flex items-center gap-1.5 border"
|
||||
:class="toneClass"
|
||||
:title="meta.label"
|
||||
>
|
||||
<span class="inline-flex shrink-0" aria-hidden="true">
|
||||
<!-- upload -->
|
||||
<svg v-if="meta.icon === 'upload'" class="w-3 h-3" viewBox="0 0 16 16" fill="none">
|
||||
<path d="M8 11V3M8 3L5 6M8 3l3 3M3 13h10" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" />
|
||||
</svg>
|
||||
<!-- edit -->
|
||||
<svg v-else-if="meta.icon === 'edit'" class="w-3 h-3" viewBox="0 0 16 16" fill="none">
|
||||
<path d="M11.5 2.5l2 2L5 13H3v-2L11.5 2.5z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round" />
|
||||
</svg>
|
||||
<!-- clock -->
|
||||
<svg v-else-if="meta.icon === 'clock'" class="w-3 h-3" viewBox="0 0 16 16" fill="none">
|
||||
<circle cx="8" cy="8" r="5.5" stroke="currentColor" stroke-width="1.5" />
|
||||
<path d="M8 5v3.5l2 1.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" />
|
||||
</svg>
|
||||
<!-- reject -->
|
||||
<svg v-else-if="meta.icon === 'reject'" class="w-3 h-3" viewBox="0 0 16 16" fill="none">
|
||||
<circle cx="8" cy="8" r="5.5" stroke="currentColor" stroke-width="1.5" />
|
||||
<path d="M5.5 5.5l5 5M10.5 5.5l-5 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" />
|
||||
</svg>
|
||||
<!-- check -->
|
||||
<svg v-else-if="meta.icon === 'check'" class="w-3 h-3" viewBox="0 0 16 16" fill="none">
|
||||
<path d="M3.5 8.5l3 3 6-7" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" />
|
||||
</svg>
|
||||
<!-- shield -->
|
||||
<svg v-else-if="meta.icon === 'shield'" class="w-3 h-3" viewBox="0 0 16 16" fill="none">
|
||||
<path d="M8 2.5l5 2v3.5c0 3-2.2 5.2-5 6-2.8-.8-5-3-5-6V4.5l5-2z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round" />
|
||||
</svg>
|
||||
<!-- approve -->
|
||||
<svg v-else-if="meta.icon === 'approve'" class="w-3 h-3" viewBox="0 0 16 16" fill="none">
|
||||
<circle cx="8" cy="8" r="5.5" stroke="currentColor" stroke-width="1.5" />
|
||||
<path d="M5.5 8l2 2 3.5-3.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" />
|
||||
</svg>
|
||||
<!-- done -->
|
||||
<svg v-else-if="meta.icon === 'done'" class="w-3 h-3" viewBox="0 0 16 16" fill="none">
|
||||
<path d="M2.5 8.5l2 2M6 9l3.5-4M9.5 8.5l2 2 3-3.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" />
|
||||
</svg>
|
||||
<!-- cancel / unknown -->
|
||||
<svg v-else class="w-3 h-3" viewBox="0 0 16 16" fill="none">
|
||||
<circle cx="8" cy="8" r="5.5" stroke="currentColor" stroke-width="1.5" />
|
||||
<path d="M5.5 8h5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" />
|
||||
</svg>
|
||||
</span>
|
||||
<span>{{ meta.label }}</span>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import {
|
||||
BATCH_STATUS_TONE_CLASSES,
|
||||
getBatchStatusMeta,
|
||||
} from '../utils/batchStatus'
|
||||
|
||||
const props = defineProps<{
|
||||
status: string | null | undefined
|
||||
}>()
|
||||
|
||||
const meta = computed(() => getBatchStatusMeta(props.status))
|
||||
const toneClass = computed(() => BATCH_STATUS_TONE_CLASSES[meta.value.tone])
|
||||
</script>
|
||||
@@ -2,9 +2,7 @@
|
||||
<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>
|
||||
<span class="bg-orange-100 text-orange-800 status-badge">
|
||||
Pending Verification
|
||||
</span>
|
||||
<StatusBadge :status="batch?.status ?? 'PENDING_VERIFICATION'" />
|
||||
</div>
|
||||
|
||||
<div v-if="batch?.rejectionReason" class="bg-red-50 border border-red-200 rounded-md p-4">
|
||||
@@ -13,10 +11,17 @@
|
||||
</div>
|
||||
|
||||
<div v-if="ocrConfidence" class="ocr-banner">
|
||||
Values pre-filled by OCR ({{ ocrConfidence.provider }}).
|
||||
Colored borders indicate extraction confidence — verify each value against the scan.
|
||||
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>
|
||||
@@ -30,6 +35,10 @@
|
||||
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"
|
||||
@@ -54,6 +63,10 @@
|
||||
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"
|
||||
@@ -78,6 +91,10 @@
|
||||
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"
|
||||
@@ -102,6 +119,10 @@
|
||||
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"
|
||||
@@ -127,6 +148,8 @@
|
||||
: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>
|
||||
@@ -153,49 +176,36 @@
|
||||
<button
|
||||
@click="approveVerification"
|
||||
class="btn-primary"
|
||||
:disabled="!allChecked || processing"
|
||||
:disabled="!allChecked || processing || sodBlocked"
|
||||
>
|
||||
{{ processing ? 'Processing...' : 'Approve - Verified' }}
|
||||
</button>
|
||||
<button
|
||||
@click="showRejectDialog = true"
|
||||
class="btn-danger"
|
||||
:disabled="processing"
|
||||
:disabled="processing || sodBlocked"
|
||||
>
|
||||
Reject
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Reject dialog -->
|
||||
<div
|
||||
v-if="showRejectDialog"
|
||||
class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"
|
||||
<ConfirmDialog
|
||||
:open="showRejectDialog"
|
||||
title="Reject Batch"
|
||||
body="This returns the batch for rework. A reason is required."
|
||||
confirm-label="Confirm Rejection"
|
||||
variant="danger"
|
||||
:confirm-disabled="!rejectionReason.trim() || processing"
|
||||
@confirm="rejectVerification"
|
||||
@cancel="showRejectDialog = false"
|
||||
>
|
||||
<div class="bg-white rounded-lg p-6 max-w-md w-full mx-4">
|
||||
<h3 class="text-lg font-semibold mb-4">Reject Batch</h3>
|
||||
<textarea
|
||||
v-model="rejectionReason"
|
||||
class="form-input"
|
||||
rows="4"
|
||||
placeholder="Reason for rejection (required)..."
|
||||
/>
|
||||
<div class="flex flex-col-reverse sm:flex-row sm:justify-end gap-4 mt-4">
|
||||
<button
|
||||
@click="showRejectDialog = false"
|
||||
class="px-4 py-2 text-gray-600 hover:text-gray-800"
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
<button
|
||||
@click="rejectVerification"
|
||||
class="btn-danger"
|
||||
:disabled="!rejectionReason.trim()"
|
||||
>
|
||||
Confirm Rejection
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<textarea
|
||||
v-model="rejectionReason"
|
||||
class="form-input"
|
||||
rows="4"
|
||||
placeholder="Reason for rejection (required)..."
|
||||
/>
|
||||
</ConfirmDialog>
|
||||
|
||||
<div v-if="errorMessage" class="text-clinical-danger text-sm">
|
||||
{{ errorMessage }}
|
||||
@@ -206,10 +216,15 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useAuthStore } from '../stores/auth'
|
||||
import { useBatchStore } from '../stores/batches'
|
||||
import { useToast } from '../composables/useToast'
|
||||
import { useOcrFieldConfidence } from '../composables/useOcrFieldConfidence'
|
||||
import ObservationRow from '../components/ObservationRow.vue'
|
||||
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 type { BatchDetailResponse, DraftObservation } from '../types'
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -217,6 +232,7 @@ const props = defineProps<{
|
||||
batchId: string
|
||||
}>()
|
||||
|
||||
const auth = useAuthStore()
|
||||
const batchStore = useBatchStore()
|
||||
const router = useRouter()
|
||||
const toast = useToast()
|
||||
@@ -224,6 +240,7 @@ const processing = ref(false)
|
||||
const errorMessage = ref('')
|
||||
const showRejectDialog = ref(false)
|
||||
const rejectionReason = ref('')
|
||||
const sodBlocked = ref(false)
|
||||
|
||||
const fieldChecks = ref<Record<string, boolean>>({})
|
||||
const observations = ref<DraftObservation[]>([])
|
||||
@@ -241,7 +258,11 @@ const encounterFields = ref<FieldInfo[]>([])
|
||||
|
||||
const fieldReqs = computed(() => batchStore.currentDraft?.fieldRequirements)
|
||||
const ocrConfidence = computed(() => batchStore.currentDraft?.ocrConfidence ?? null)
|
||||
const { fieldConfidenceClass } = useOcrFieldConfidence(ocrConfidence)
|
||||
const {
|
||||
fieldConfidenceClass,
|
||||
fieldConfidenceLabel,
|
||||
fieldConfidenceLevel,
|
||||
} = useOcrFieldConfidence(ocrConfidence)
|
||||
|
||||
function observationValueConfidenceClass(observationCode: string): string {
|
||||
if (!observationCode) return ''
|
||||
@@ -355,6 +376,7 @@ function toggleCheck(path: string, value?: boolean) {
|
||||
}
|
||||
|
||||
async function approveVerification() {
|
||||
if (sodBlocked.value) return
|
||||
processing.value = true
|
||||
errorMessage.value = ''
|
||||
try {
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<template>
|
||||
<div
|
||||
class="sticky bottom-0 z-10 -mx-4 mt-auto border-t border-line bg-surface/95 px-4 py-3 backdrop-blur-sm sm:-mx-0 sm:rounded-b-card"
|
||||
data-testid="workstation-action-bar"
|
||||
>
|
||||
<div
|
||||
class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between"
|
||||
>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<slot name="left" />
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center justify-center gap-2">
|
||||
<slot name="center" />
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center justify-end gap-2">
|
||||
<slot name="primary" />
|
||||
<slot name="right" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* Sticky bottom action bar for Entry / Verification / Approval workstations.
|
||||
* Wire into forms in Phase 16. Slots: left (Reject), center (Save Draft),
|
||||
* primary (Submit…), right (Next). Prefer btn-primary / btn-danger / btn-secondary.
|
||||
*/
|
||||
</script>
|
||||
Reference in New Issue
Block a user