Skip to content
openEHR Go SDK

openEHR Go SDK

Go packages for openEHR:
typed compositions, checkable templates,
and an AQL builder and validator.

Decoding, validation and the AQL tools run offline. Only the REST clients need a CDR.

openEHR and this SDK

What openEHR is

openEHR is an open specification for an electronic health record. Clinical content is modelled on two levels: a stable Reference Model that every record shares, and archetypes that constrain it for one purpose. Platform operations like creating an EHR, uploading a template, and running a query come from the Service Model. This SDK is a Go client for that platform's REST binding, ITS-REST. Its typed clients are written against the Release-1.1.0 OpenAPI files vendored in the repository, so it can talk to any clinical data repository (CDR) that implements them.

Which CDR →

Who it is for

Go developers new to openEHR, and openEHR developers new to Go. It was written with a few kinds of consumer in mind: benchmark and load tools running high-concurrency CRUD, synthetic data seeders that drive bulk Compositions from a template, MCP servers that forward the caller's token, federative clients that fan out over several CDRs, and SMART-on-openEHR apps with a Go backend.

You do not have to adopt the whole module. If the job only needs one building-block package, import that one.

What you import

Import only what you use

Reference Model types, codecs, validation, templates, and AQL are ordinary Go packages, and none of them reaches for transport/ or auth/. A CI job that validates a Composition takes no network dependency.

Idiomatic Go

The public surface reads like any other Go module: short package names, constructors that return errors, and plain types you pass around. There is no framework to adopt first.

Typed Reference Model

Compositions and data values are generated Go structs, not maps of strings. After a decode you read c.Name and len(c.Content), and the compiler catches a misspelt field.

Templates you can check

Parse an ADL 1.4 operational template (OPT), compile it, and validate a Composition against it before anything reaches a CDR.

AQL as data

Archetype Query Language (AQL) queries are ordinary values here. Build one from structs or parse one from text, then lint it against a compiled template before you send it.

One TokenSource

SMART-on-openEHR, client credentials, JWT bearer, and HTTP Basic all implement auth.TokenSource. Attach one to the client, or override it for a single request.

Two integration paths

Building blocks

Decode canonical JSON, parse an OPT, validate a Composition, and build or lint AQL, all without going near the network.

See the packages

REST client

The REST client packages cover EHR, composition, query, and definition. Point them at the in-process mock the examples use, or at a live openEHR REST deployment.

Run an example

Quick start

go get github.com/cadasto/openehr-sdk-go@v0.38.0
var c rm.Composition
if err := canjson.Unmarshal(body, &c); err != nil {
    log.Fatal(err)
}
fmt.Println(c.ArchetypeNodeID, c.Category.Value, len(c.Content))

Requires Go 1.27 or newer. The SDK is pre-1.0, so pin an exact tag: a minor release can change the public API.

Install → · Examples → · Go reference →