โ
UI โ gi-webpackages/anesthesia ยท procedures-panel
Fills the peripheral_block SynForm โ laterality=Left, block=popliteal, ultrasound โ โ and clicks Save. Descriptors are a hardcoded TS mirror; the values become a ProcedureRecord (layoutKey + formData{โฆ}).
โผ
โก
HTTP โ EdgeAFD โ SWA gi-web
AnesthesiaService.saveProcedure() โ PUT /api/anesthesia/cases/{id}/procedures. Same-origin through Azure Front Door; bearer token attached.
โผ
โข
clinical-apiAnesthesiaProxyController
Just forwards to aims-api (AimsApi:BaseUrl) โ no anesthesia logic here. Re-injects the identity (Authorization, or X-Dev-ApiKey+X-User-Id) so the RLS org survives the hop.
โผ
โฃ
aims-api โ controllerAnesthesiaCaseController
SaveProcedure โ GetOrCreateByCaseIdAsync(caseId) resolves the spine row (anesthesia_cases) โ creating it on first touch (1:1 with cases).
โผ
โค
aims-api โ repo (Dapper)AnesthesiaCaseRepository
Opens NpgsqlConnection โ SET app.organization_id (RLS) โ upserts anesthesia_procedures: form_data JSONB (SNAPSHOT) + promoted laterality / block_name / ultrasound_guided (PROJECTION, via SynFormValueMapper) so billing never parses JSON.
โผ
โฅ
the bridgeAnesthesiaProcedureBillingBridge
OnProcedureSavedAsync โ deterministic, no LLM. popliteal = named-nerve โ CPT 64445 (mod -59). ultrasound โ โ adds a 76942 found-money flag. UpsertBlockBySourceProcedureAsync โ anesthesia_regional_blocks (idempotent). try/catch โ best-effort.
โผ
โฆ
PostgreSQLRLS by organization_id
Rows committed inside the org session context. 200 OK returns to the UI โ even if โฅ threw (a billing hiccup never blocks the clinical save).
๐ฆ What's in the DB now (3 rows, 1 save)
anesthesia_procedures id=42, anesthesia_case_id=7, procedure_type=peripheral_block,
laterality=Left, block_name=popliteal, ultrasound_guided=true, form_data={โฆ}
anesthesia_regional_blocks source_procedure_id=42, cpt_code=64445,
modifier=-59, laterality=Left โ the billable line
anesthesia_field_avoidance_flags type=us_guided_block,
notes="us_block:42" โ drives 76942 imaging on the charge ticket
๐ Read ยท idempotency ยท live data
Read path = same hops in reverse. GET โฆ/procedures โ proxy โ aims-api โ repo โ JSON back. Nothing PHI is cached client-side.
Idempotent + reversible. Re-Save updates the same block (partial-unique on source_procedure_id). Delete the procedure โ block cascades away (ON DELETE CASCADE) and the 76942 flag is removed.
โ ๏ธ Live vitals are NOT this path. They stream over SignalR /hubs/intraop (aims-api), a separate channel from REST.
Source: AnesthesiaService (packages/anesthesia), AnesthesiaProxyController (clinical-api), AnesthesiaCaseController + AnesthesiaCaseRepository + AnesthesiaProcedureBillingBridge + SynFormValueMapper (aims-api). Verified against source 2026-06-30.