make addition ui fixes for cramped features
CI / backend (push) Successful in 6m6s
CI / frontend (push) Failing after 1m8s

This commit is contained in:
2026-08-12 06:11:30 +08:00
parent 4c5aafe591
commit 53338906aa
18 changed files with 668 additions and 317 deletions
@@ -111,7 +111,7 @@
<legend class="workstation-form-legend">
Observations ({{ draft?.observations?.length ?? 0 }})
</legend>
<div class="space-y-2">
<div class="space-y-3">
<ObservationRow
v-for="obs in (draft?.observations ?? [])"
:key="obs.id"
@@ -30,45 +30,47 @@
<p v-else-if="!loading && events.length === 0" class="text-sm text-ink-secondary">
No audit events for this batch yet.
</p>
<div v-else class="overflow-x-auto">
<table class="w-full min-w-[520px] text-sm">
<thead>
<tr class="border-b border-line text-left text-ink-secondary">
<th class="py-2 px-2 font-medium w-[28%]">Timestamp</th>
<th class="py-2 px-2 font-medium">Event</th>
<th class="py-2 px-2 font-medium w-[22%]">Actor</th>
<th class="py-2 px-2 font-medium w-[22%]">Details</th>
</tr>
</thead>
<tbody>
<tr
v-for="event in events"
:key="event.id"
class="border-b border-line last:border-0 align-top"
<ol v-else class="space-y-0" data-testid="audit-trail-timeline">
<li
v-for="event in events"
:key="event.id"
class="flex gap-3"
>
<div class="w-[5.5rem] shrink-0 pt-0.5 text-right">
<time
class="block text-[11px] leading-snug text-ink-secondary tabular-nums"
:datetime="event.occurredAt"
>
<td class="py-2 px-2 text-ink-secondary whitespace-nowrap">
{{ formatDateTime(event.occurredAt) }}
</td>
<td class="py-2 px-2">
<span class="font-medium text-ink-strong">
{{ formatEventType(event.eventType) }}
</span>
</td>
<td class="py-2 px-2 text-ink">
{{ event.actorFullName || event.actorUsername || '—' }}
</td>
<td class="py-2 px-2 text-ink-secondary text-xs">
{{ summarizePayload(event.metadataJson) }}
</td>
</tr>
</tbody>
</table>
</div>
{{ formatDateTime(event.occurredAt) }}
</time>
</div>
<div class="observation-card__rail self-stretch" aria-hidden="true">
<span class="observation-card__dot" />
<span class="mt-1 w-px flex-1 bg-line" />
</div>
<div class="min-w-0 flex-1 pb-4">
<p class="text-sm font-bold leading-snug text-ink-strong">
{{ formatEventType(event.eventType) }}
</p>
<p class="mt-0.5 text-xs text-ink">
{{ event.actorFullName || event.actorUsername || '—' }}
</p>
<p
v-if="summarizePayload(event.metadataJson) !== '—'"
class="mt-1 text-xs text-ink-secondary"
>
{{ summarizePayload(event.metadataJson) }}
</p>
</div>
</li>
</ol>
<button
v-if="hasMore"
type="button"
class="mt-3 text-sm font-medium text-primary-700 hover:text-primary-800 disabled:opacity-50"
class="mt-1 text-sm font-medium text-primary-700 hover:text-primary-800 disabled:opacity-50"
:disabled="loading"
data-testid="audit-trail-load-more"
@click="loadMore"
@@ -121,13 +123,17 @@ async function loadMore() {
function formatEventType(type: string): string {
return type
.toLowerCase()
.replace(/_/g, ' ')
.replace(/\b\w/g, (c) => c.toUpperCase())
}
function formatDateTime(iso: string): string {
try {
return new Date(iso).toLocaleString()
return new Date(iso).toLocaleString(undefined, {
dateStyle: 'short',
timeStyle: 'short',
})
} catch {
return iso
}
@@ -247,7 +247,7 @@
<!-- Observations section -->
<fieldset class="workstation-form-section">
<legend class="workstation-form-legend">Observations</legend>
<div class="space-y-2">
<div class="space-y-3">
<ObservationRow
v-for="obs in observations"
:key="obs.id"
@@ -258,7 +258,7 @@
@update="(field, value) => handleObsUpdate(obs.id, field, value)"
@delete="handleObsDelete"
/>
<button type="button" class="btn-secondary text-sm py-1.5" @click="addObservation">
<button type="button" class="btn-secondary text-sm py-1.5 w-full sm:w-auto" @click="addObservation">
+ Add Observation
</button>
</div>
@@ -1,117 +1,204 @@
<template>
<!-- Read-only: activity-list row — bold value, timestamp meta, optional OK -->
<div
class="flex flex-col xl:flex-row xl:items-start gap-3 p-3 rounded-input border border-line bg-canvas"
v-if="readonly"
class="observation-card observation-card--readonly"
:class="{ 'observation-card--verified': showVerified && verified }"
data-testid="observation-row"
>
<div class="flex-1 grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-5 gap-3 min-w-0">
<div>
<label class="workstation-field-label">Code</label>
<div class="observation-card__rail" aria-hidden="true">
<span class="observation-card__dot" />
</div>
<div class="min-w-0 flex-1">
<div class="flex items-start justify-between gap-2">
<div class="min-w-0">
<p class="text-xs font-semibold uppercase tracking-wide text-ink-secondary">
{{ codeLabel }}
</p>
<p
class="mt-0.5 flex flex-wrap items-baseline gap-x-1.5 gap-y-0.5 tabular-nums"
:class="valueInputClass || 'text-ink-strong'"
>
<span class="text-xl font-bold leading-tight tracking-tight">
{{ displayValue }}
</span>
<span
v-if="observation.unit"
class="text-sm font-medium text-ink-secondary"
>
{{ observation.unit }}
</span>
</p>
<p
v-if="recordedAtLabel"
class="mt-1 text-[11px] leading-snug text-ink-secondary"
>
{{ recordedAtLabel }}
</p>
<p
v-if="observation.note"
class="mt-1 text-xs text-ink"
>
<span class="text-ink-secondary">Note:</span>
{{ observation.note }}
</p>
<OcrConfidenceBadge
v-if="ocrLabel"
class="mt-1"
:label="ocrLabel"
:level="ocrLevel"
/>
</div>
<label
v-if="showVerified"
class="inline-flex shrink-0 items-center gap-1.5 rounded-input border px-2 py-1 text-xs font-semibold cursor-pointer transition-colors"
:class="verified
? 'border-clinical-safe bg-clinical-safe-bg text-clinical-safe'
: 'border-line bg-surface text-ink-secondary hover:border-primary-300'"
>
<input
type="checkbox"
class="w-3.5 h-3.5 text-clinical-safe rounded"
:checked="verified"
@change="$emit('verify', observation.id, ($event.target as HTMLInputElement).checked)"
/>
OK
</label>
</div>
</div>
</div>
<!-- Editable: card with hero value, then secondary fields (not a 5-col crunch) -->
<div
v-else
class="observation-card"
data-testid="observation-row"
>
<div class="flex items-start justify-between gap-2 mb-2.5">
<div class="min-w-0 flex-1">
<label class="workstation-field-label">Observation</label>
<select
:value="observation.observationCode"
@change="update('observationCode', ($event.target as HTMLSelectElement).value)"
class="form-input text-sm py-1.5"
:disabled="readonly"
class="form-input text-sm font-semibold py-1.5"
@change="onCodeChange(($event.target as HTMLSelectElement).value)"
>
<option value="">Select...</option>
<option value="HEART_RATE">Heart Rate</option>
<option value="TEMP_C">Temperature (C)</option>
<option value="BP_SYSTOLIC">BP Systolic</option>
<option value="BP_DIASTOLIC">BP Diastolic</option>
<option value="RESP_RATE">Respiratory Rate</option>
<option value="SPO2">SpO2</option>
<option value="POTASSIUM_MEQ_L">Potassium</option>
<option value="GLUCOSE_MG_DL">Glucose</option>
<option value="WBC_K_UL">WBC</option>
<option value="LACTATE_MMOL_L">Lactate</option>
<option value="">Select code…</option>
<option
v-for="opt in CODE_OPTIONS"
:key="opt.value"
:value="opt.value"
>
{{ opt.label }}
</option>
</select>
</div>
<div>
<button
v-if="canDelete"
type="button"
class="shrink-0 mt-5 text-sm font-medium text-clinical-danger hover:text-clinical-critical"
@click="$emit('delete', observation.id)"
>
Remove
</button>
</div>
<div class="flex items-end gap-2 mb-2.5">
<div class="min-w-0 flex-[1.4]">
<label class="workstation-field-label">
Value
<OcrConfidenceBadge :label="ocrLabel" :level="ocrLevel" />
</label>
<input
:value="observation.value"
@change="update('value', parseFloat(($event.target as HTMLInputElement).value))"
type="number"
step="0.01"
:class="['form-input', 'text-sm', 'py-1.5', valueInputClass]"
:disabled="readonly"
:class="[
'form-input text-xl font-bold tabular-nums py-1.5 leading-none',
valueInputClass,
]"
@change="update('value', parseFloat(($event.target as HTMLInputElement).value))"
/>
</div>
<div>
<div class="w-[4.75rem] shrink-0">
<label class="workstation-field-label">Unit</label>
<input
:value="observation.unit"
@change="update('unit', ($event.target as HTMLInputElement).value)"
type="text"
class="form-input text-sm py-1.5"
:disabled="readonly"
@change="update('unit', ($event.target as HTMLInputElement).value)"
/>
</div>
</div>
<div class="grid grid-cols-1 gap-2">
<div>
<label class="workstation-field-label">Recorded At</label>
<label class="workstation-field-label">Recorded at</label>
<input
:value="observation.recordedAt?.substring(0, 16)"
@change="update('recordedAt', ($event.target as HTMLInputElement).value)"
type="datetime-local"
class="form-input text-sm py-1.5"
:disabled="readonly"
@change="update('recordedAt', ($event.target as HTMLInputElement).value)"
/>
</div>
<div>
<label class="workstation-field-label">Note</label>
<input
:value="observation.note"
@change="update('note', ($event.target as HTMLInputElement).value)"
type="text"
class="form-input text-sm py-1.5"
placeholder="Optional"
:disabled="readonly"
@change="update('note', ($event.target as HTMLInputElement).value)"
/>
</div>
</div>
<div
v-if="showVerified"
class="flex items-center shrink-0 xl:mt-7"
>
<label class="inline-flex items-center gap-2 cursor-pointer">
<input
type="checkbox"
:checked="verified"
@change="$emit('verify', observation.id, ($event.target as HTMLInputElement).checked)"
class="w-4 h-4 text-clinical-safe rounded"
/>
<span class="text-xs text-ink-secondary">OK</span>
</label>
</div>
<button
v-if="!readonly && !showVerified"
type="button"
@click="$emit('delete', observation.id)"
class="self-start xl:mt-7 text-clinical-danger hover:text-clinical-critical text-sm font-medium"
>
Remove
</button>
</div>
</template>
<script setup lang="ts">
import type { DraftObservation } from '../types'
import { computed } from 'vue'
import type { OcrConfidenceLevel } from '../composables/useOcrFieldConfidence'
import OcrConfidenceBadge from './OcrConfidenceBadge.vue'
defineProps<{
observation: DraftObservation
readonly?: boolean
showVerified?: boolean
verified?: boolean
valueInputClass?: string
ocrLabel?: string | null
ocrLevel?: OcrConfidenceLevel | null
}>()
/** Minimal observation shape for editable/readonly cards (DraftObservation satisfies this). */
export interface ObservationRowModel {
id: string
observationCode: string
value: number | null
unit: string | null
recordedAt: string | null
note: string | null
}
const CODE_OPTIONS = [
{ value: 'HEART_RATE', label: 'Heart Rate', unit: 'bpm' },
{ value: 'TEMP_C', label: 'Temperature (C)', unit: '°C' },
{ value: 'BP_SYSTOLIC', label: 'BP Systolic', unit: 'mmHg' },
{ value: 'BP_DIASTOLIC', label: 'BP Diastolic', unit: 'mmHg' },
{ value: 'RESP_RATE', label: 'Respiratory Rate', unit: 'breaths/min' },
{ value: 'SPO2', label: 'SpO2', unit: '%' },
{ value: 'POTASSIUM_MEQ_L', label: 'Potassium', unit: 'mEq/L' },
{ value: 'GLUCOSE_MG_DL', label: 'Glucose', unit: 'mg/dL' },
{ value: 'WBC_K_UL', label: 'WBC', unit: '×10³/µL' },
{ value: 'LACTATE_MMOL_L', label: 'Lactate', unit: 'mmol/L' },
] as const
const props = withDefaults(
defineProps<{
observation: ObservationRowModel
readonly?: boolean
showVerified?: boolean
verified?: boolean
canDelete?: boolean
valueInputClass?: string
ocrLabel?: string | null
ocrLevel?: OcrConfidenceLevel | null
}>(),
{
canDelete: true,
},
)
const emit = defineEmits<{
(e: 'update', field: string, value: unknown): void
@@ -119,7 +206,38 @@ const emit = defineEmits<{
(e: 'verify', obsId: string, passed: boolean): void
}>()
const codeLabel = computed(() => {
const code = props.observation.observationCode
if (!code) return 'Unspecified observation'
return CODE_OPTIONS.find((o) => o.value === code)?.label ?? code.replace(/_/g, ' ')
})
const displayValue = computed(() => {
const value = props.observation.value
if (value == null || Number.isNaN(Number(value))) return '—'
return String(value)
})
const recordedAtLabel = computed(() => {
const raw = props.observation.recordedAt
if (!raw) return null
const date = new Date(raw)
if (Number.isNaN(date.getTime())) return raw
return date.toLocaleString(undefined, {
dateStyle: 'medium',
timeStyle: 'short',
})
})
function update(field: string, value: unknown) {
emit('update', field, value)
}
function onCodeChange(code: string) {
emit('update', 'observationCode', code)
const match = CODE_OPTIONS.find((o) => o.value === code)
if (match?.unit) {
emit('update', 'unit', match.unit)
}
}
</script>
@@ -0,0 +1,74 @@
<template>
<div
class="observation-card observation-card--readonly"
:class="{ 'observation-card--verified': checked }"
data-testid="verification-field-card"
>
<div class="observation-card__rail" aria-hidden="true">
<span class="observation-card__dot" />
</div>
<div class="min-w-0 flex-1">
<div class="flex items-start justify-between gap-2">
<div class="min-w-0">
<div class="flex flex-wrap items-center gap-1.5">
<p class="text-xs font-semibold uppercase tracking-wide text-ink-secondary">
{{ label }}
</p>
<OcrConfidenceBadge
v-if="ocrLabel"
:label="ocrLabel"
:level="ocrLevel"
/>
</div>
<p
class="mt-0.5 text-base font-bold leading-snug text-ink-strong break-words"
:class="valueClass"
>
{{ displayValue }}
</p>
</div>
<label
class="inline-flex shrink-0 items-center gap-1.5 rounded-input border px-2 py-1 text-xs font-semibold cursor-pointer transition-colors"
:class="checked
? 'border-clinical-safe bg-clinical-safe-bg text-clinical-safe'
: 'border-line bg-surface text-ink-secondary hover:border-primary-300'"
>
<input
type="checkbox"
class="w-3.5 h-3.5 text-clinical-safe rounded"
:checked="checked"
@change="$emit('toggle', ($event.target as HTMLInputElement).checked)"
/>
OK
</label>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { computed } from 'vue'
import type { OcrConfidenceLevel } from '../composables/useOcrFieldConfidence'
import OcrConfidenceBadge from './OcrConfidenceBadge.vue'
const props = defineProps<{
label: string
value: string | null | undefined
checked: boolean
valueClass?: string
ocrLabel?: string | null
ocrLevel?: OcrConfidenceLevel | null
}>()
defineEmits<{
(e: 'toggle', checked: boolean): void
}>()
const displayValue = computed(() => {
const raw = props.value
if (raw == null || String(raw).trim() === '') return '(empty)'
return String(raw)
})
</script>
@@ -34,30 +34,20 @@
/>
<!-- Patient review -->
<fieldset class="workstation-form-section">
<fieldset v-if="patientFields.length > 0" 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 class="space-y-2.5">
<VerificationFieldCard
v-for="field in patientFields"
:key="field.path"
:label="field.label"
:value="field.value"
:checked="fieldChecks[field.path] ?? false"
:value-class="fieldConfidenceClass(field.path)"
:ocr-label="fieldConfidenceLabel(field.path)"
:ocr-level="fieldConfidenceLevel(field.path)"
@toggle="(passed) => toggleCheck(field.path, passed)"
/>
</div>
</fieldset>
@@ -65,27 +55,17 @@
<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>
<VerificationFieldCard
v-for="field in allergyFields"
:key="field.path"
:label="field.label"
:value="field.value"
:checked="fieldChecks[field.path] ?? false"
:value-class="fieldConfidenceClass(field.path)"
:ocr-label="fieldConfidenceLabel(field.path)"
:ocr-level="fieldConfidenceLevel(field.path)"
@toggle="(passed) => toggleCheck(field.path, passed)"
/>
</div>
</fieldset>
@@ -93,27 +73,17 @@
<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>
<VerificationFieldCard
v-for="field in medicationFields"
:key="field.path"
:label="field.label"
:value="field.value"
:checked="fieldChecks[field.path] ?? false"
:value-class="fieldConfidenceClass(field.path)"
:ocr-label="fieldConfidenceLabel(field.path)"
:ocr-level="fieldConfidenceLevel(field.path)"
@toggle="(passed) => toggleCheck(field.path, passed)"
/>
</div>
</fieldset>
@@ -123,28 +93,18 @@
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 class="space-y-2.5">
<VerificationFieldCard
v-for="field in encounterFields"
:key="field.path"
:label="field.label"
:value="field.value"
:checked="fieldChecks[field.path] ?? false"
:value-class="fieldConfidenceClass(field.path)"
:ocr-label="fieldConfidenceLabel(field.path)"
:ocr-level="fieldConfidenceLevel(field.path)"
@toggle="(passed) => toggleCheck(field.path, passed)"
/>
</div>
</fieldset>
@@ -162,7 +122,7 @@
>
No observations recorded.
</p>
<div v-else class="space-y-2">
<div v-else class="space-y-3">
<ObservationRow
v-for="(obs, index) in observations"
:key="obs.id"
@@ -284,8 +244,8 @@ import { useBatchStore } from '../stores/batches'
import { useToast } from '../composables/useToast'
import { useOcrFieldConfidence } from '../composables/useOcrFieldConfidence'
import ObservationRow from '../components/ObservationRow.vue'
import VerificationFieldCard from '../components/VerificationFieldCard.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 WorkstationActionBar from '../components/WorkstationActionBar.vue'
@@ -405,6 +365,10 @@ watch(
}
}
}
} else {
patientFields.value = []
allergyFields.value = []
medicationFields.value = []
}
if (draft.encounter && showEncounterContext.value) {
@@ -35,15 +35,15 @@
: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">
<div class="text-sm font-semibold text-ink-strong truncate">
{{ formatBatchType(batch.batchType) }}
</div>
<div class="mt-1.5">
<StatusBadge :status="batch.status" />
</div>
<div class="mt-1 font-mono text-[11px] text-ink-secondary truncate">
{{ batch.id.substring(0, 8) }}…
</div>
</button>
</div>
@@ -84,6 +84,9 @@ defineEmits<{
}>()
function formatBatchType(type: string): string {
return type.replace(/_/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase())
return type
.toLowerCase()
.replace(/_/g, ' ')
.replace(/\b\w/g, (c) => c.toUpperCase())
}
</script>