Clinical Use

Measure Builder

Configuration guidance for governed HMIS, surveillance, operational, and clinical aggregate metrics.

Purpose

Measure Builder defines which aggregate clinical and operational values AMCDR exposes for HMIS dashboards, surveillance monitoring, service KPIs, and Grafana clinical metric panels. It is configured under Analytics → HMIS → Measure Builder.

Create programme indicators such as births, death notifications, reportable laboratory results, and referral counts as AQL or saved-query definitions. Administrators can then update national, regional, facility, and programme reporting rules without changing platform code.

When an indicator depends on operational state created from a clinical template, configure the template workflow projection first. See Workflow Foundation Bindings for the openEHR-to-foundation targets used by birth, NICU, admission, transfer, discharge, emergency, and death workflows. If the indicator depends on derived facts or rule outcomes, configure the rule process under Clinical Fact and Guideline Guardrail Workflows.

Definition governance

Each metric has a stable key, display name, source type, refresh interval, unit, status, labels, sensitivity policy, and sample history.

Fast monitoring path

Prometheus scrapes stored aggregate samples. It does not execute AQL and does not receive patient-level rows.

Safe clinical labels

Labels are bounded administrative dimensions such as domain, indicator set, or facility group. Patient identifiers and composition identifiers must not be labels.

Measure Builder UI

Measure Builder supports search, status/source filtering, create/edit, manual refresh, due processing, sample review, privacy suppression, and source review.

Registry Workflow

  1. Open Analytics → HMIS → Measure Builder.
  2. Review existing definitions and built-in collectors.
  3. Create a measure from a built-in collector, openEHR AQL aggregate, saved AQL aggregate, or governed operational workflow calculation.
  4. Add bounded static labels such as domain=laboratory, indicator_set=hmis, or programme=maternal_child_health.
  5. Set sensitivity and minimum group size where small counts risk exposing sensitive information.
  6. Save as draft, refresh manually, review samples, then activate when validated.
  7. Use Process due to run due metrics immediately, or allow the scheduler to collect samples on interval.
  8. Confirm values appear in the AMCDR Clinical Metrics Grafana folder through amcdr_clinical_metric_value, amcdr_clinical_metric_status, and amcdr_clinical_metric_updated_age_seconds.

Definition Types

Source kindUse whenConfiguration
builtinThe value is a stable platform-wide aggregate such as EHR records, active patients, active visits, open encounters, active alerts, or open critical lab alerts.Select a built-in source. Add labels, unit, refresh interval, and status.
aqlThe metric depends on openEHR composition content, templates, archetypes, or clinical facts.Write an aggregate AQL query that returns one numeric value as the first result. Add parameters for template IDs or date windows.
saved_queryThe metric reuses a governed saved query that is already reviewed and versioned.Enter the saved query key. The saved query must return one numeric aggregate value.
operationalThe measure uses governed visit/encounter workflow times or a distinct-patient coded cohort.Select admission stay, outpatient facility time, encounter cycle time, or coded patient count; set aggregation and named period/facility/code parameters.

Label Policy

Metric labels determine how Grafana groups values. They must be stable, low-cardinality, and non-identifying. AMCDR always includes the metric key and unit. Administrators add static labels that describe the metric domain or reporting set.

Allowed label patternExamples
Clinical or operational domaindomain=laboratory, domain=encounter, domain=vital_events
Indicator setindicator_set=hmis, indicator_set=civil_registration
Programme or reporting familyprogramme=maternal_child_health, programme=surveillance

Do not use patient names, MRNs, EHR IDs, encounter IDs, accession numbers, composition UIDs, raw query text, or clinical result values as labels. High-cardinality or identifying labels make monitoring unsafe and slow.

Sensitivity and Suppression

Some clinical aggregate counts are sensitive even when no patient identifiers are exposed. Use Sensitive metric and Minimum group size for domains such as HIV, mental health, genetics, safeguarding, pregnancy, rare disease, violence, and small-population surveillance. When a non-zero value is below the configured minimum group size, AMCDR suppresses the sample instead of exporting a misleading or privacy-risking value.

Sample AQL Definitions

The repository includes sample definition data in examples/clinical_metrics/clinical_metric_definitions.json for implementers who import seed definitions. In the application UI, administrators configure the same information through standard fields and name/value rows.

FieldExample value
Metric keybirth_records
NameBirth records
StatusDraft until validated, then Active
Source kindAQL
AQL aggregate querySELECT COUNT(c/uid/value) AS value FROM EHR e CONTAINS COMPOSITION c WHERE c/archetype_details/template_id/value = $birth_template_id
Query parameterbirth_template_id = neonatal_birth_record.v1
Metric labelsdomain=vital_events; indicator_set=civil_registration
Unit and refreshcount; refresh every 300 seconds

Operational States

StatusMeaning
draftThe definition is being prepared or validated. It must not be treated as production evidence.
activeThe scheduler processes the definition and Prometheus exports the latest sample.
pausedThe definition is retained but not processed automatically.
retiredThe definition is no longer operational. Keep it for audit/history when needed.

API Surface

Clinical metric management is an administrator function. The standard dashboard scrape remains GET /metrics.

RoutePurpose
GET /clinical-metrics/builtinList built-in aggregate collectors.
GET /clinical-metrics/definitionsList configured definitions and latest sample summaries.
POST /clinical-metrics/definitionsCreate a governed definition.
PATCH /clinical-metrics/definitions/{metric_key}Update a definition’s source, labels, status, interval, sensitivity, or metadata.
DELETE /clinical-metrics/definitions/{metric_key}Retire a definition.
POST /clinical-metrics/definitions/{metric_key}/refreshRun one metric immediately and store a sample.
GET /clinical-metrics/definitions/{metric_key}/samplesReview recent samples and failures.
POST /clinical-metrics/process-dueProcess due active definitions.
GET /clinical-metrics/prometheus-previewPreview registry metric lines included in /metrics.

Production Guidance