Core Rule
Templates define the clinical content of portable forms. The form builder controls layout, labels, widgets, visibility, and other interface behaviour. Map each field to a path in the selected template.
Deployment Modes
| Mode | Purpose |
|---|---|
FULL | Force-full platform mode. Enables the real module surface and keeps mock CDR off. |
full_amcdr | Full platform with templates, forms, patient workspace, composition storage, AQL, admin, and external CDR connectors. |
form_builder_only | Design, preview, validate, import, and export openEHR-anchored form packages. No patient workflow or real composition persistence. |
form_runtime | Render published forms and submit template-compliant compositions. Form editing and AQL workbench are disabled. |
demo_training | Training mode with mock CDR behavior and no real composition storage. |
Module Behavior
| Module | Full / Full AMCDR | Form Builder Only | Form Runtime | Demo / Training |
|---|---|---|---|---|
| Template registry | Yes | Yes | Yes | Yes |
| Form builder | Yes | Yes | No | Yes |
| Form runtime | Yes | No | Yes | Yes |
| Patient workspace | Yes | No | Yes | Yes |
| Composition storage | Yes | No | Yes | No |
| AQL workbench | Yes | No | No | Yes |
| External CDR connectors | Yes | Yes | Yes | No |
| Semantic Studio | Yes | Yes | No | Yes |
| Workflow, medication, analytics | Yes | No | No | Configurable training surface |
| Mock CDR | No | Yes | No | Yes |
Inspect the active profile with GET /platform/modules. The response shows deployment_mode, deployment_mode_source, and per-module flags. FULL is strict and ignores stored module toggles; full_amcdr is full-featured but still configurable by super admins.
Live switching
Switching from Full AMCDR to Form Builder Only, Form Runtime, or Demo / Training through Platform configuration -> Platform Modules is live. It stores the preset in platform_module_settings, and backend route guards read the effective module configuration per request. No container restart is needed for UI or admin API preset changes.
Restart the backend only when changing environment variables such as AMCDR_DEPLOYMENT_MODE in .env, Docker Compose, Kubernetes, or systemd. Use full_amcdr for a switchable full deployment. Use uppercase FULL for locked full mode, where stored presets cannot disable the real CDR module surface.
Form Builder Only Configuration
AMCDR_DEPLOYMENT_MODE=form_builder_only
AMCDR_MODULE_TEMPLATE_REGISTRY_ENABLED=true
AMCDR_MODULE_FORM_BUILDER_ENABLED=true
AMCDR_MODULE_FORM_RUNTIME_ENABLED=false
AMCDR_MODULE_PATIENT_WORKSPACE_ENABLED=false
AMCDR_MODULE_COMPOSITION_STORAGE_ENABLED=false
AMCDR_MODULE_AQL_WORKBENCH_ENABLED=false
AMCDR_MODULE_EXTERNAL_CDR_CONNECTORS_ENABLED=true
AMCDR_MODULE_SEMANTIC_STUDIO_ENABLED=true
AMCDR_MODULE_WORKFLOW_ENGINE_ENABLED=false
AMCDR_MODULE_MEDICATION_OPERATIONS_ENABLED=false
AMCDR_MODULE_MEDISERVE_INTEGRATION_ENABLED=false
AMCDR_MODULE_MOCK_CDR_ENABLED=true
Use the same AMCDR image and change the deployment mode. This keeps the artifact reproducible while backend guards and frontend navigation disable patient and composition workflows.
Form Runtime Configuration
AMCDR_DEPLOYMENT_MODE=form_runtime
AMCDR_MODULE_TEMPLATE_REGISTRY_ENABLED=true
AMCDR_MODULE_FORM_BUILDER_ENABLED=false
AMCDR_MODULE_FORM_RUNTIME_ENABLED=true
AMCDR_MODULE_PATIENT_WORKSPACE_ENABLED=true
AMCDR_MODULE_COMPOSITION_STORAGE_ENABLED=true
AMCDR_MODULE_EXTERNAL_CDR_CONNECTORS_ENABLED=true
AMCDR_MODULE_SEMANTIC_STUDIO_ENABLED=false
AMCDR_MODULE_WORKFLOW_ENGINE_ENABLED=false
AMCDR_MODULE_MEDICATION_OPERATIONS_ENABLED=false
AMCDR_MODULE_MEDISERVE_INTEGRATION_ENABLED=false
AMCDR_MODULE_MOCK_CDR_ENABLED=false
Runtime Verification
curl -s http://127.0.0.1:8009/platform/modules | jq .
curl -i http://127.0.0.1:8009/patients
curl -i http://127.0.0.1:8009/template-sources
curl -i http://127.0.0.1:8009/workbench/queries
In form_builder_only, patient and composition endpoints return 403. In form_runtime, form draft/edit endpoints return 403 while published runtime form endpoints remain available. In demo_training, mock CDR is enabled and external CDR template sources are hidden.
Module Config Defaults
form_builder:
require_template_anchor: true
allow_local_opt_upload: true
allow_cdr_template_selection: true
allow_form_package_import: true
allow_form_package_export: true
allow_unanchored_forms: false
form_runtime:
allowed_composition_formats:
- FLAT
- STRUCTURED
default_composition_format: FLAT
external_cdr:
allow_direct_frontend_connection: false
connection_timeout_seconds: 20
supported_adapters:
- AMCDR
- EHRBASE
- HIP_CDR
- BETTER_CDR
Template Sources
The frontend asks AMCDR for template sources. It does not call external CDRs directly.
- Local AMCDR template registry.
- Local OPT/OPT2 upload when allowed.
- Connected external openEHR CDRs through backend adapters.
- Portable form package import after the referenced template exists.
GET /template-sources
GET /template-sources/{source_id}/templates
GET /template-sources/{source_id}/templates/{template_id}/web-template
Package Contents
| Item | Purpose |
|---|---|
manifest.json | Package identity, form ID, template ID, version, and runtime requirements. |
template.opt or template.opt2 | Source template where available. |
web-template.json | Normalized template field metadata. |
form-definition.json | Form fields and openEHR path bindings. |
ui-layout.json | Layout, grouping, widgets, display behavior. |
value-set-bindings.json | Terminology and coded-field bindings. |
terminology-snapshot.json | Referenced value-set bindings inherited from AMCDR for portable dropdowns. |
runtime-settings.json | Runtime composition, context, and terminology endpoint settings inherited from AMCDR without secrets. |
validation-rules.json | Form-layer validation rules. |
runtime-manifest.json | Connected, offline edge, kiosk, and demo runtime profile metadata. |
submission-mapping.json | Adapter contract for AMCDR, external openEHR, FHIR adapter, or custom targets. |
package-signature.json | Package hash and HMAC signature used to detect tampering. |
example-flat-composition.json | Example runtime payload for FLAT composition. |
example-structured-composition.json | Example runtime payload for structured composition. |
Package APIs
POST /forms/{form_key}/export-package
POST /forms/import-package
POST /forms/runtime/verify-package
GET /forms/runtime/status
POST /forms/runtime/devices
POST /forms/runtime/sync
Import requires the referenced template_id to exist in the target AMCDR template registry. This prevents a UI package from silently introducing a clinical model the target system has not accepted.
Browser/PWA Runtime
Export a signed form package from Semantic Studio for use in a browser or PWA. The runtime submits through an adapter or sync API to AMCDR or a configured external backend, while AMCDR manages the templates and package configuration.
Production capture is never anonymous. Connected PWA mode uses the current AMCDR session or token and submits immediately. Offline PWA/edge mode requires prior online login, an active registered device, a backend-issued device grant, encrypted IndexedDB queue storage, and backend revalidation during sync. Kiosk/shared-device mode uses short sessions and minimal local cache. Demo/training mode must stay isolated from production clinical data.
Terminology-bound dropdowns inherit the saved AMCDR form configuration. The runtime first uses terminology-snapshot.json, value-set-bindings.json, and static value-set options embedded in ui-layout.json. If a field has only a value-set reference, the connected runtime uses inherited runtime-settings.json terminology endpoints, such as /terminology/expand, to load choices from the target AMCDR after authentication. The clinical view shows labels and dropdowns only; openEHR paths, RM types, package JSON, and flat payload JSON stay in Advanced.
The exported browser runtime includes a Test connection action in Runtime settings. For local AMCDR, use the backend API URL http://127.0.0.1:8009, not the frontend dev server at http://127.0.0.1:5173. Local development allows file:// exports through the null CORS origin; production runtimes must be served from a trusted HTTPS origin and must not include null in CORS origins.
The production frontend registers a conservative service worker. It caches only runtime shell assets and does not intercept /api or authentication traffic. Offline clinical data belongs in the encrypted local queue, not the HTTP cache.
Set AMCDR_PORTABLE_FORM_SIGNING_SECRET to a long independent secret in production. Deployments that verify each other's packages must share or rotate this package-signing trust deliberately.
Runtime Sync Contract
Patient and subject context
Portable runtimes must not maintain a parallel demographic registry. Subject search uses GET /forms/runtime/context/subjects. New subjects use POST /forms/runtime/context/subjects, and updates use PUT /forms/runtime/context/subjects/{patient_id}. Both write operations resolve/upsert the internal MPI identity and generate a new openEHR PartyVersion before patient/EHR context is returned.
The same duplicate and merge safeguards apply as in client registration, FHIR Patient and openEHR PERSON: exact identifiers follow the surviving MPI record, ambiguous evidence returns 409 Conflict, and omission of an identifier does not erase identity history.
POST /forms/runtime/devices registers or refreshes a portable runtime device and returns a device grant for offline/kiosk sync. Store that grant in the runtime's secure local state and use it as the encryption material for the local queue.
POST /forms/runtime/sync accepts queued runtime items with runtime_profile, optional device_identifier, device_grant_id for offline/kiosk modes, and captured form payloads. Each item carries local_id, template_key, composition_format, patient or EHR context, payload, and optional package hash. For target=amcdr, AMCDR submits through the existing template-formatted composition pipeline.
Offline and kiosk sync require an active registered device. Revoked, suspended, expired, or unknown devices are rejected before any clinical write. Sync start, accepted item, rejected item, and completion events are recorded as lifecycle events.
How Forms Create Compositions In Other CDRs
The browser never builds external CDR URLs and never stores external CDR credentials. The backend chooses the configured adapter and posts FLAT or STRUCTURED composition JSON to the target CDR.
External integrations workspace routing
When a form is routed to External integrations in the Form Designer runtime workspace list, the published form is eligible for external openEHR CDR connector workflows. AMCDR renders the form and submits or exports the resulting template-compliant composition to a configured target such as EHRbase, Better CDR, another AMCDR deployment, or an integration gateway.
Before using the form with another CDR, configure its endpoint, authentication, patient/EHR context, and submission rules. The target must accept the same template_id and version requirements, composition format, and terminology bindings.