Clinical Use

Clinical Fact and Guideline Guardrail Workflows

How AMCDR turns openEHR template fields into derived clinical facts, configurable CDS decisions, alerts, worklist tasks, lifecycle events, and monitoring inputs.

Purpose

Clinical fact and guideline guardrail workflows extract values from openEHR records, calculate derived values, evaluate configured rules, and create follow-up work. They connect templates, CQL, the Clinical Safety Sidecar, and the workflow engine.

Use this pattern for medication review, laboratory follow-up, falls risk, discharge, chronic disease monitoring, public-health triggers, or neonatal care.

Runtime Pattern

  1. A clinician captures data through a published form bound to an openEHR template.
  2. Semantic Studio maps template paths to named clinical facts such as birth_weight_kg, current_weight_kg, potassium_mmol_l, or follow_up_required.
  3. The CDS fact workflow derives additional facts using safe structured operations such as percentage loss, percentage change, BMI, ratio, addition, or subtraction.
  4. Rules evaluate structured conditions such as greater-than, less-than, equality, case-insensitive equality, exists, missing, all, and any.
  5. Matched rules recommend actions such as creating a task, raising a clinical alert, recording a lifecycle event, requesting notification, or marking review required.
  6. If action application is explicitly enabled and the required patient or workflow context exists, AMCDR creates the operational records and writes audit evidence.
  7. Aggregate outcomes are monitored through the Clinical Metrics Registry and Prometheus without exposing patient-level values as labels.

AI, Guideline Guardrails, and Safety Decisions

The production CDS operating model is deliberately local, governed, and auditable. Patient data must not be sent to unmanaged public model endpoints. If an LLM is used, it should run in an approved self-hosted or controlled private environment and must remain an assistive clinical reasoning and drafting service, not the final authority for safety decisions.

Clinical safety decision chain
Clinical factsopenEHR compositions, encounters, orders, observations, allergies, medications, labs
→
LLM reasoningDraft support, explanation, summarisation, candidate recommendations
→
CQL guardrailsGuideline, eligibility, contraindication, escalation, and policy logic
→
Safety sidecarSpecialized medication and safety checks where configured
→
Decision and auditAllow, warn, block, override required, audit trail

CQL guardrails supervise guideline-leaning decisions before and after AI drafting. The Clinical Safety Sidecar performs specialized deterministic checks where needed, especially medication safety, allergies, interactions, dose range, pregnancy, renal risk, and override policy. AMCDR records the final decision and audit evidence so every warning, block, override, and accepted recommendation remains traceable.

LayerResponsibilityProduction rule
Clinical factsBuild governed context from template-backed records and operational workflow state.Use approved clinical records and configured fact bindings only.
LLM reasoningGenerate drafts, summaries, explanations, and candidate recommendations.Run only in approved local or private environments; do not send patient data to unmanaged online models.
CQL guardrailsEvaluate guideline, policy, eligibility, escalation, and contraindication logic.Use as the deterministic supervisor for guideline-leaning decisions.
Clinical Safety SidecarEvaluate specialized medication and safety rules where configured.Return structured allow, warn, block, or override-required decisions.
Audit trailPersist decision evidence, source context, rule versions, user action, and override state.No clinical safety decision is complete until it is auditable.

Configuration Surface

SurfacePurpose
Semantic Studio -> Bindings -> Foundation projectionsBinds openEHR template paths to encounter, movement, relationship, visibility, reporting, safety, and monitoring foundation targets.
CDS + AI -> CQL guardrails -> Fact workflowsShows starter blueprints, previews sample facts, saves configured fact workflows as CDS rule bindings, and tests derived decisions.
WorklistsReceives created tasks when the action has a queue and workflow instance context.
Clinical alertsReceives active alert records when a rule action creates an alert for a patient.
Lifecycle eventsStores decision, notification, review-required, and action evidence for audit and subscriptions.
Analytics -> HMIS -> DefinitionsDefines aggregate KPIs from AQL, saved queries, or built-in collectors for monitoring and dashboards.

Neonatal Example

A newborn has a birth weight of 2.1 kg and a current weight of 1.85 kg. The fact workflow calculates weight loss as 11.9%. Because the value is above 10%, the rule recommends a feeding assessment task, raises a neonatal weight-loss alert, records a review-required event, and requests notification for neonatal roles.

Input factValue
birth_weight_kg2.1
current_weight_kg1.85
weight_loss_percentDerived: 11.9
Ruleweight_loss_percent > 10
ActionsCreate feeding assessment task, create alert, notify neonatal nurse or paediatrician, mark review required.

Example CQL Guardrail

The same neonatal threshold can be represented as a deterministic CQL guardrail. In production, AMCDR binds the CQL parameters from approved clinical facts extracted from openEHR compositions, workflow context, or validated operational records.

library NeonatalWeightLossGuardrail version '1.0.0'

using FHIR version '4.0.1'

context Patient

parameter BirthWeightKg Decimal
parameter CurrentWeightKg Decimal

define "Has Weight Data":
  BirthWeightKg is not null
    and CurrentWeightKg is not null
    and BirthWeightKg > 0

define "Weight Loss Percent":
  if "Has Weight Data"
    then ((BirthWeightKg - CurrentWeightKg) / BirthWeightKg) * 100
    else null

define "Excessive Neonatal Weight Loss":
  "Weight Loss Percent" is not null
    and "Weight Loss Percent" > 10

define "Recommended Decision":
  if "Excessive Neonatal Weight Loss"
    then 'warn'
    else 'allow'

define "Recommended Actions":
  if "Excessive Neonatal Weight Loss"
    then {
      'create_feeding_assessment_task',
      'create_neonatal_weight_loss_alert',
      'notify_neonatal_clinician',
      'mark_review_required'
    }
    else {}

The CQL result does not create records by itself. AMCDR converts the guardrail output into governed workflow actions only when the caller has valid patient, encounter, workflow, role, and audit context.

Medication Safety and Sidecar Use

Fact workflows prepare the clinical context required by the Clinical Safety Sidecar. For neonatal gentamicin review, the platform provides medication requested, latest weight, gestational age, and renal-function availability. If renal function is missing, the fact workflow creates a pharmacy review task and an alert. The sidecar then performs dosing, interaction, and contraindication checks using the same governed facts.

This keeps responsibilities clear: openEHR templates store the clinical facts, fact workflows decide operational follow-up, and the sidecar performs specialized medication-safety logic.

Non-Neonatal Examples

WorkflowFactsDecisionActions
Critical potassium follow-uppotassium_mmol_lCritical low or high result.Create clinical follow-up task, create critical lab alert, record audit event.
Adult fall-risk reviewfall_risk_score, recent_fall_countRisk score exceeds policy threshold or recent fall exists.Create care-planning task.
Discharge follow-upfollow_up_required, follow_up_daysFollow-up required is true.Create scheduling task and continuity-of-care event.
Renal dosing reviewMedication, latest weight, eGFR or creatinine, age, pregnancy status.Medication requires dosing review or renal function is unavailable.Create pharmacy review task and medication safety alert.
Sepsis screeningTemperature, heart rate, respiratory rate, blood pressure, lactate, mental status.Configured score or threshold is met.Create urgent clinical review task and lifecycle event.

Action Requirements

Clinical alerts require patient context. Worklist tasks require a workflow instance because tasks are part of AMCDR workflow history. If a fact workflow is evaluated without the required context, the API returns a skipped action with a clear reason instead of silently creating incomplete operational data.

ActionRequired contextResult
create_alertpatient_idCreates active clinical alert.
create_taskworkflow_instance_id; optional queue.Creates workflow task. If configured, the queue is auto-created.
notifyRole or destination metadata.Records notification-request lifecycle event for delivery/subscription layers.
mark_review_requiredPatient context where available.Records review-required lifecycle event.
audit_eventNone beyond authenticated request context.Records lifecycle evidence.

API Surface

RoutePurpose
GET /cds/fact-workflows/blueprintsList starter blueprint definitions.
GET /cds/fact-workflows/blueprints/{key}Fetch one starter blueprint.
POST /cds/fact-workflows/evaluateEvaluate a posted definition, saved CDS binding, or blueprint rule key.
GET /enterprise/cds-rule-bindingsList persisted CDS rule bindings, including fact workflow bindings.
POST /enterprise/cds-rule-bindingsSave a configured fact workflow as a CDS rule binding.

Evaluation Example

POST /cds/fact-workflows/evaluate
{
  "rule_key": "neonatal_weight_loss_feeding_review",
  "facts": {
    "birth_weight_kg": 2.1,
    "current_weight_kg": 1.85
  },
  "subject": {
    "patient_id": "newborn-patient-id",
    "workflow_instance_id": "workflow-instance-id"
  },
  "apply_actions": false
}

Use apply_actions=false for preview and validation. Use apply_actions=true only when the caller has the correct patient, encounter, and workflow context and is allowed to create operational follow-up records.

Production Rules

Relationship to Other AMCDR Capabilities

CapabilityRelationship
openEHR templatesAuthoritative clinical data contract and persistence layer.
Semantic Studio foundation projectionsMaps template paths to facts and operational foundations.
Clinical fact workflowsEvaluates derived facts and creates operational follow-up decisions.
CQL guardrailsRuns authored guideline logic where CQL is the appropriate standard representation.
Clinical Safety SidecarPerforms specialized medication and safety checks using governed clinical facts.
Workflow engineOwns tasks, queues, stages, and workflow history.
Clinical Metrics RegistryExposes aggregate KPIs and rule outcome metrics safely to monitoring and dashboards.