Skip to main content

AI Gateway Service — AI Integration

Status: populated Owner: TBD Last updated: 2026-04-17 Companion: Service Template · 03 platform-services · 14 compliance-security-extended

This service is the AI integration plane. All AI calls for every other service flow through it. There are no AI calls made from this service that bypass its own pipeline.

1. Registered AI features (v1)

Feature keyCaller servicePurposePrompt templateModerationHITL
patient_chart.note_summarypatient-chart-serviceSummarise a set of clinical noteschart.note.summarypre+postrequired_for_phi
patient_chart.differential_dxpatient-chart-serviceSuggest differential diagnoses from S/O/Achart.ddxpre+postrequired
medication.interaction_narrativemedication-serviceExplain detected drug-drug interactionsmed.interactionpre+postrequired_for_phi
medication.reconciliation_assistmedication-servicePropose reconciliation across sourcesmed.reconcilepre+postrequired
radiology.preread_chest_xrayradiology-servicePre-read narrative (non-diagnostic)rad.preread.chest_xraypre+postrequired
laboratory.result_narrativelaboratory-servicePlain-language result explanationlab.narrativepre+postrequired_for_phi
portal.triagepatient-portal-servicePatient-facing symptom triageportal.triagepre+post strictrequired
vcare.soap_scaffoldvirtual-care-serviceGenerate SOAP scaffold from transcriptvcare.soappre+postrequired
interop.document_classificationinterop-serviceClassify inbound documentsinterop.doc_classpost onlysampled
comms.message_draftcommunication-serviceDraft clinician-to-patient messagecomms.message_draftpre+postrequired
pophealth.cohort_explanationpopulation-health-serviceHuman-readable cohort logic explanationpop.cohort_explainpost onlynone (de-identified)

2. Prompt template contract

FieldDetail
StorageSecure registry (outside primary DB); template_hash in prompt_template table
SemverMajor bumps require re-approval; minor for wording, patch for whitespace
GuardrailsSystem-message portion; references policy language and safety stance
InputsJinja2-style placeholders; validated against feature schema
Localisationps-AF, fa-AF, en, ar-AE, ur — separate versions

3. Moderation

StageClassifier(s)Purpose
InputLocal fastText PHI sniffer + prompt-injection detector + provider-side moderation (when available)Refuse prompts that leak beyond feature scope or attempt jailbreak
OutputProvider moderation (Anthropic/OpenAI) + local self-harm / medical-safety classifierCatch harmful output before returning

Thresholds configurable per feature in config-service. Block verdict returns 422 / sets draftText=null.

4. HITL orchestration

PolicyBehaviour
noneDraft returned directly; caller may auto-accept
requiredDraft state under_review; reviewer queue; cannot be auto-accepted
required_for_phiAs required when resource touches PHI, else none
sampled% configured; pulled decisions go to review queue

Reviewer assignment policy: by facility + feature; escalation path configured in config-service.

5. AIProvenance — every clinical AI artifact

Every accepted draft's provenance record is referenced by the owning clinical service when creating the final FHIR resource. The Provenance resource (FHIR) links:

  • target → clinical resource (DocumentReference, Observation, MedicationRequest)
  • agent.who.referenceDevice/ai-gateway-service
  • entity.what.reference → Provenance record in this service (via identifier.value = prv_...)
  • reason.text → featureKey

6. Provider matrix (default)

FeaturePrimaryFallbackResidency constraints
patient_chart.*Anthropic Claude Sonnet 4Azure OpenAI GPT-4oTenant KMS region
medication.*Anthropic Claude Sonnet 4On-prem vLLM Llama-3.1-70BAF residency uses on-prem
radiology.preread_*On-prem medical model (vLLM)None (fail closed)Always on-prem
portal.triageAzure OpenAI GPT-4o (content-filtered)Anthropic Claude Sonnet 4Region = tenant residency
interop.document_classificationSmall OSS classifier (Ollama)OpenAIN/A
pophealth.*Azure OpenAI GPT-4oAnthropicDe-identified only

7. Explicit non-goals

  • No autonomous clinical decision making — every clinical-impact feature has HITL or post-moderation block.
  • No training/fine-tuning.
  • No persistent chat state — each assist is a stateless request.