feature: Degraded Operations Visibility
This commit is contained in:
@@ -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()
|
||||
}
|
||||
Reference in New Issue
Block a user