feature: Degraded Operations Visibility

This commit is contained in:
voltsrage
2026-06-23 23:18:31 +08:00
parent 940e27c0ac
commit 4399996448
81 changed files with 3949 additions and 323 deletions
+26 -1
View File
@@ -1,4 +1,4 @@
import { api } from './client'
import { api, BASE_URL, authHeaders } from './client'
export function fetchActiveEncounters(department, { page = 1, pageSize = 20 } = {}) {
const params = new URLSearchParams({
@@ -50,4 +50,29 @@ export function submitVitalsObservations(encounterId, observations) {
return api.post(`/api/v1/encounters/${encounterId}/observations`, {
observations,
})
}
export function fetchDischargeSummaryStatus(encounterId) {
return api.get(`/api/v1/encounters/${encounterId}/discharge-summary`)
}
export async function fetchDischargeSummaryContent(encounterId) {
const res = await fetch(
`${BASE_URL}/api/v1/encounters/${encounterId}/discharge-summary/content`,
{ headers: authHeaders() },
)
if (res.status === 404) {
const envelope = await res.json().catch(() => null)
const code = envelope?.error?.code
if (code === 'DISCHARGE_SUMMARY_PENDING') return null
throw new Error(envelope?.error?.message ?? 'Discharge summary not found.')
}
if (res.status === 401) {
throw new Error('Session expired — please log in again.')
}
if (!res.ok) {
const envelope = await res.json().catch(() => null)
throw new Error(envelope?.error?.message ?? `Failed to download discharge summary (${res.status})`)
}
return res.text()
}