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
@@ -105,7 +105,7 @@
</div>
</section>
<!-- 3. Observations (dense table) -->
<!-- 3. Observations -->
<section class="card space-y-4">
<header class="flex flex-wrap items-end justify-between gap-3">
<div>
@@ -113,12 +113,12 @@
{{ mode === 'new' ? '3' : '2' }} · Observations
</p>
<h2 class="text-base font-semibold text-ink-strong mt-1">
Vitals ({{ observations.length }})
Vitals ({{ observations.length }}/10)
</h2>
</div>
<button
type="button"
class="text-sm font-semibold text-primary-700 hover:text-primary-800"
class="text-sm font-semibold text-primary-700 hover:text-primary-800 disabled:opacity-50"
:disabled="observations.length >= 10"
@click="addObservation"
>
@@ -126,84 +126,15 @@
</button>
</header>
<div class="overflow-x-auto -mx-1">
<table class="w-full min-w-[720px] text-sm">
<thead>
<tr class="border-b border-line text-left text-ink-secondary">
<th class="py-2 px-2 font-medium w-[18%]">Time</th>
<th class="py-2 px-2 font-medium w-[20%]">Type</th>
<th class="py-2 px-2 font-medium w-[12%]">Value</th>
<th class="py-2 px-2 font-medium w-[12%]">Unit</th>
<th class="py-2 px-2 font-medium">Notes</th>
<th class="py-2 px-2 font-medium w-[5rem]"></th>
</tr>
</thead>
<tbody>
<tr
v-for="(obs, idx) in observations"
:key="idx"
class="border-b border-line align-top"
>
<td class="py-2 px-2">
<input
v-model="obs.recordedAt"
type="datetime-local"
class="form-input text-sm py-1.5"
/>
</td>
<td class="py-2 px-2">
<select
v-model="obs.observationCode"
class="form-input text-sm py-1.5"
@change="autoFillUnit(obs)"
>
<option value="">Select...</option>
<option
v-for="code in vitalCodes"
:key="code.value"
:value="code.value"
>
{{ code.label }}
</option>
</select>
</td>
<td class="py-2 px-2">
<input
v-model.number="obs.value"
type="number"
step="0.01"
class="form-input text-sm py-1.5"
inputmode="decimal"
/>
</td>
<td class="py-2 px-2">
<input
v-model="obs.unit"
type="text"
class="form-input text-sm py-1.5"
/>
</td>
<td class="py-2 px-2">
<input
v-model="obs.note"
type="text"
class="form-input text-sm py-1.5"
placeholder="Optional"
/>
</td>
<td class="py-2 px-2 text-right">
<button
type="button"
class="text-xs font-medium text-clinical-danger hover:underline py-1.5"
:disabled="observations.length <= 1"
@click="removeObservation(idx)"
>
Remove
</button>
</td>
</tr>
</tbody>
</table>
<div class="space-y-3">
<ObservationRow
v-for="obs in observations"
:key="obs.id"
:observation="obs"
:can-delete="observations.length > 1"
@update="(field, value) => handleObsUpdate(obs.id, field, value)"
@delete="removeObservationById"
/>
</div>
<p v-if="observations.length >= 10" class="text-xs text-ink-disabled">
Maximum 10 observations per submission.
@@ -345,6 +276,8 @@ import { useToast } from '../composables/useToast'
import AppHeader from '../components/AppHeader.vue'
import PatientSearch from '../components/PatientSearch.vue'
import InlineError from '../components/InlineError.vue'
import ObservationRow from '../components/ObservationRow.vue'
import type { ObservationRowModel } from '../components/ObservationRow.vue'
import type { LiveCaptureObservationInput } from '../types'
const store = useLiveCaptureStore()
@@ -385,30 +318,24 @@ const departments = [
{ value: 'Anesthesiology', label: 'Anesthesiology' },
]
const vitalCodes = [
{ value: 'HEART_RATE', label: 'Heart Rate', unit: 'bpm' },
{ value: 'TEMP_C', label: 'Temperature', 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' },
]
function nowLocal(): string {
const d = new Date()
d.setMinutes(d.getMinutes() - d.getTimezoneOffset())
return d.toISOString().slice(0, 16)
}
function makeObservation(): LiveCaptureObservationInput {
return { observationCode: '', value: null, unit: '', recordedAt: nowLocal(), note: '' }
function makeObservation(): ObservationRowModel {
return {
id: crypto.randomUUID(),
observationCode: '',
value: null,
unit: '',
recordedAt: nowLocal(),
note: '',
}
}
const observations = ref<LiveCaptureObservationInput[]>([makeObservation()])
const observations = ref<ObservationRowModel[]>([makeObservation()])
function addObservation() {
if (observations.value.length < 10) {
@@ -416,20 +343,29 @@ function addObservation() {
}
}
function removeObservation(idx: number) {
if (observations.value.length > 1) {
observations.value.splice(idx, 1)
}
function removeObservationById(id: string) {
if (observations.value.length <= 1) return
observations.value = observations.value.filter((o) => o.id !== id)
}
function autoFillUnit(obs: LiveCaptureObservationInput) {
const match = vitalCodes.find(c => c.value === obs.observationCode)
if (match) obs.unit = match.unit
function handleObsUpdate(id: string, field: string, value: unknown) {
const obs = observations.value.find((o) => o.id === id)
if (!obs) return
;(obs as Record<string, unknown>)[field] = value
}
function toSubmitPayload(): LiveCaptureObservationInput[] {
return observations.value.map(({ observationCode, value, unit, recordedAt, note }) => ({
observationCode,
value,
unit: unit ?? '',
recordedAt: new Date(recordedAt ?? nowLocal()).toISOString(),
note: note ?? '',
}))
}
function formatCode(code: string): string {
const match = vitalCodes.find(c => c.value === code)
return match?.label ?? code
return code.replace(/_/g, ' ')
}
const canSubmit = computed(() => {
@@ -448,10 +384,7 @@ async function submit() {
errorMessage.value = ''
store.reset()
const obs = observations.value.map(o => ({
...o,
recordedAt: new Date(o.recordedAt).toISOString(),
}))
const obs = toSubmitPayload()
try {
if (mode.value === 'new') {