openEHR Go SDK
翻譯準備中
取自儲存庫 README
正在載入完整 README。 以下為已儲存的摘錄。
A first-party Go SDK for openEHR. It covers the openEHR REST API, the Reference Model as typed Go structs, building and validating Compositions from operational templates, AQL, and SMART-on-openEHR authentication.
You don't have to take all of it. The building blocks (RM types, serialization, validation, AQL, template parsing) are plain packages with no dependency on the HTTP client or on auth. If all you need is to validate a Composition in a CI job, you import that one package and nothing else.檢視完整 README ↗A first-party Go SDK for openEHR. It covers the openEHR REST API, the Reference Model as typed Go structs, building and validating Compositions from operational templates, AQL, and SMART-on-openEHR authentication.
You don't have to take all of it. The building blocks (RM types, serialization, validation, AQL, template parsing) are plain packages with no dependency on the HTTP client or on auth. If all you need is to validate a Composition in a CI job, you import that one package and nothing else.
Everything the SDK does traces back to a specification that lives in this repository. When the code and a spec disagree, the spec wins.
It's written the way Go code usually is: every I/O call takes a context.Context, you pass in your own *http.Client, configuration is done with functional options, and RM polymorphism goes through generics and a type registry rather than reflection.
A COMPOSITION is the openEHR clinical document, and canonical JSON is how the REST API carries it. This decodes one into a typed struct and reads a few fields, with no network and no CDR involved:
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))
The runnable version, cmd/examples/canonical_json, does the same against a fixture bundled with the repo, so it works straight from a clone:
$ go run ./cmd/examples/canonical_json
composition: archetype_node_id=openEHR-EHR-COMPOSITION.encounter.v1
name="body_weight"
language=nl (terminology=ISO_639-1)
territory=NL
category=event
content items=1
OK: canonical-JSON Composition decoded from body_weight.json
archetype_node_id names the archetype the document is built on, language and territory are codes with the terminology they come from, category is the composition category, and content items counts the entries the document carries. The examples catalogue has a program of this size for each SDK surface (validate a composition against a template, build and lint AQL, create an EHR through the REST client, run a SMART launch), each with a note on what to copy into your own application.
To use it in your own project, pin an exact tag. The SDK is pre-1.0, so a minor release can change the public API:
go get github.com/cadasto/[email protected]
The version policy is in releases.md, and the roadmap says what has actually landed.
It was built with these kinds of consumer in mind:
If you only need one piece (RM modeling, a codec, validation, AQL string construction, OPT parsing), you can import that package on its own.
The roadmap and the REQ registry hold the authoritative landed-vs-planned status, with REQ and PROBE identifiers.
TokenSource. authStart with quick-start.md, then the runnable catalog in examples.md. quick-start covers toolchain setup, whether you have host Go or use the Docker fallback.
If you're working on the SDK itself, make help lists the grouped targets and ci.md explains the PR gate.
Much of this codebase and its documentation was written with AI coding assistants such as Claude Code and Cursor. The written specification keeps that work honest. Every change is measured against the specs in this repository and has to pass the make ci gate. Each change is also reviewed before a maintainer merges it. ai-workflow.md explains how the assistants are set up and what they must look up rather than guess. The rules for contributing with AI help, including the Assisted-by: commit trailer, are in CONTRIBUTING.md.
The normative source of truth and the design that realises it. When code and specs disagree, the specs win.
| Doc | Scope |
|---|---|
| docs/specifications/ | Normative specs: REQ / PROBE / STRAND topic specs |
| docs/specifications/REQ.md | Requirement registry (index → canonical topic spec) |
| docs/specifications/traceability.yaml | Machine-readable REQ → package / probe / test map |
| docs/architecture.md | Design narrative + dependency mermaid |
| docs/adr/ | Closed architectural decisions |
| docs/roadmap.md | Delivery stages and the work not yet finished |
Open research strands live in research-strands.md until promoted ADRs land in docs/adr/.
| Doc | Scope |
|---|---|
| docs/quick-start.md · docs/examples.md | Developer onboarding + runnable catalog |
| docs/development-process.md | How work flows: the SDD ladder and its gates |
| CONTRIBUTING.md | How to contribute |
| docs/ci.md | CI and contributor checks |
| docs/releases.md | Release process + version policy |
| CHANGELOG.md | Release log |
| AGENTS.md | Entry point for coding agents |
| docs/ai-workflow.md | AI agent conventions, MCP skills, example-doc upkeep |
| SECURITY.md | Vulnerability reporting |
The SDK is released under the MIT licence. See LICENSE.
Vendored third-party artefacts (test fixtures, openEHR specification pins, the AQL grammar) keep their upstream licences. The inventory is LICENSING.md.
cadasto/ cut line, so they can later move out as a subtree instead of being rewritten. module-layout