fix: Optional OCR-Assisted Draft Pre-Fill

This commit is contained in:
voltsrage
2026-06-28 01:48:15 +08:00
parent c160c5f912
commit c26ef22670
16 changed files with 186 additions and 69 deletions
@@ -349,8 +349,8 @@ watch(
noKnownAllergies: draft.patient.noKnownAllergies ?? false,
noActiveMedications: draft.patient.noActiveMedications ?? false,
})
allergies.value = parseJsonList(draft.patient.allergiesJson)
medications.value = parseJsonList(draft.patient.medicationsJson)
allergies.value = draft.patient.allergies ?? []
medications.value = draft.patient.medications ?? []
}
if (draft.encounter) {
Object.assign(encounter, {
@@ -380,7 +380,7 @@ async function saveAllergies() {
try {
await batchStore.saveDraftPatient(props.batchId, {
...patient,
allergiesJson: JSON.stringify(allergies.value.filter(a => a.trim())),
allergies: allergies.value.filter(a => a.trim()),
})
toast.success('Allergies saved')
} catch (e: unknown) {
@@ -410,7 +410,7 @@ async function saveMedications() {
try {
await batchStore.saveDraftPatient(props.batchId, {
...patient,
medicationsJson: JSON.stringify(medications.value.filter(m => m.trim())),
medications: medications.value.filter(m => m.trim()),
})
toast.success('Medications saved')
} catch (e: unknown) {
@@ -431,8 +431,8 @@ async function savePatient() {
try {
await batchStore.saveDraftPatient(props.batchId, {
...patient,
allergiesJson: patient.noKnownAllergies ? null : JSON.stringify(allergies.value.filter(a => a.trim())),
medicationsJson: patient.noActiveMedications ? null : JSON.stringify(medications.value.filter(m => m.trim())),
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) {
@@ -34,12 +34,13 @@
transition: isPanning ? 'none' : 'transform 0.2s',
}"
>
<!-- PDF rendering via iframe for simplicity; production would use pdf.js -->
<!-- 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
@@ -287,7 +287,7 @@ watch(
{ path: 'patient.noKnownAllergies', label: 'No Known Allergies', value: 'Yes (NKA)' },
]
} else {
const items = parseJsonList(draft.patient.allergiesJson)
const items = draft.patient.allergies ?? []
allergyFields.value = items.map((item, i) => ({
path: `patient.allergies[${i}]`,
label: `Allergy ${i + 1}`,
@@ -295,7 +295,7 @@ watch(
}))
if (items.length === 0) {
allergyFields.value = [
{ path: 'patient.allergiesJson', label: 'Allergies', value: '(none entered)' },
{ path: 'patient.allergies', label: 'Allergies', value: '(none entered)' },
]
}
}
@@ -309,7 +309,7 @@ watch(
{ path: 'patient.noActiveMedications', label: 'No Active Medications', value: 'Yes' },
]
} else {
const items = parseJsonList(draft.patient.medicationsJson)
const items = draft.patient.medications ?? []
medicationFields.value = items.map((item, i) => ({
path: `patient.medications[${i}]`,
label: `Medication ${i + 1}`,
@@ -317,7 +317,7 @@ watch(
}))
if (items.length === 0) {
medicationFields.value = [
{ path: 'patient.medicationsJson', label: 'Medications', value: '(none entered)' },
{ path: 'patient.medications', label: 'Medications', value: '(none entered)' },
]
}
}