Add: No toast notification system or success feedback + No corrections/supersession UI

This commit is contained in:
voltsrage
2026-06-27 16:36:35 +08:00
parent efd3974d1f
commit 2d36d1a5dd
15 changed files with 598 additions and 29 deletions
@@ -232,6 +232,7 @@
<script setup lang="ts">
import { ref, reactive, computed, watch } from 'vue'
import { useBatchStore } from '../stores/batches'
import { useToast } from '../composables/useToast'
import ObservationRow from '../components/ObservationRow.vue'
import type { BatchDetailResponse, DraftObservation } from '../types'
@@ -241,6 +242,7 @@ const props = defineProps<{
}>()
const batchStore = useBatchStore()
const toast = useToast()
const submitting = ref(false)
const errorMessage = ref('')
@@ -363,8 +365,11 @@ async function saveAllergies() {
...patient,
allergiesJson: JSON.stringify(allergies.value.filter(a => a.trim())),
})
toast.success('Allergies saved')
} catch (e: unknown) {
errorMessage.value = e instanceof Error ? e.message : 'Failed to save allergies'
const msg = e instanceof Error ? e.message : 'Failed to save allergies'
errorMessage.value = msg
toast.error(msg)
}
}
@@ -390,8 +395,11 @@ async function saveMedications() {
...patient,
medicationsJson: JSON.stringify(medications.value.filter(m => m.trim())),
})
toast.success('Medications saved')
} catch (e: unknown) {
errorMessage.value = e instanceof Error ? e.message : 'Failed to save medications'
const msg = e instanceof Error ? e.message : 'Failed to save medications'
errorMessage.value = msg
toast.error(msg)
}
}
@@ -409,16 +417,22 @@ async function savePatient() {
allergiesJson: patient.noKnownAllergies ? null : JSON.stringify(allergies.value.filter(a => a.trim())),
medicationsJson: patient.noActiveMedications ? null : JSON.stringify(medications.value.filter(m => m.trim())),
})
toast.success('Patient demographics saved')
} catch (e: unknown) {
errorMessage.value = e instanceof Error ? e.message : 'Failed to save patient'
const msg = e instanceof Error ? e.message : 'Failed to save patient'
errorMessage.value = msg
toast.error(msg)
}
}
async function saveEncounter() {
try {
await batchStore.saveDraftEncounter(props.batchId, encounter)
toast.success('Encounter context saved')
} catch (e: unknown) {
errorMessage.value = e instanceof Error ? e.message : 'Failed to save encounter'
const msg = e instanceof Error ? e.message : 'Failed to save encounter'
errorMessage.value = msg
toast.error(msg)
}
}
@@ -450,8 +464,11 @@ async function submitForVerification() {
errorMessage.value = ''
try {
await batchStore.submitForVerification(props.batchId)
toast.success('Batch submitted for verification')
} catch (e: unknown) {
errorMessage.value = e instanceof Error ? e.message : 'Submit failed'
const msg = e instanceof Error ? e.message : 'Submit failed'
errorMessage.value = msg
toast.error(msg)
} finally {
submitting.value = false
}