https://github.com/ppazos/openehr-rest-client
openEHR Reference REST API Client in Groovy (runs in the JVM)
https://github.com/ppazos/openehr-rest-client
groovy-language openehr rest-api
Last synced: 5 months ago
JSON representation
openEHR Reference REST API Client in Groovy (runs in the JVM)
- Host: GitHub
- URL: https://github.com/ppazos/openehr-rest-client
- Owner: ppazos
- Created: 2021-12-12T16:03:13.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2026-01-11T20:35:52.000Z (6 months ago)
- Last Synced: 2026-01-12T00:07:39.561Z (6 months ago)
- Topics: groovy-language, openehr, rest-api
- Language: Groovy
- Homepage: https://cabolabs.com/our_software
- Size: 495 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# openEHR REST Client

This is the Groovy reference implementation of the [openEHR](https://www.openehr.org/) REST Client for connecting to openEHR REST API implementations.
It compiles to Java bytecode so it can be used as any Java library with any language that compiles to the JVM.
## Compile
`$ gradle build`
It generates a JAR file in the `build/libs` folder.
## Run tests
### run just one test
`$ gradle test --tests "OpenEhrRestClientTest.create demographic family trees"`
### run tests with dots in the names (using wild cards)
`$ gradle test --tests "OpenEhrRestClientTest.B*4*a* get composition at version"`
### run all tests inside a category
`$ gradle test --tests "OpenEhrRestClientTest.B*4*"`
## Use it
```groovy
// Setup authentication using a token
def token = "abc...."
def auth = new TokenAuth(token)
// Build the client
def client = new OpenEhrRestClient(
"http://localhost:8090/openehr/v1",
auth,
ContentTypeEnum.JSON
)
// Set committer metadata headers
client.setCommitterHeader('name="John Doe", external_ref.id="BC8132EA-8F4A-11E7-BB31-BE2E44B06B34", external_ref.namespace="demographic", external_ref.type="PERSON"')
// Upload EHR_STATUS template
String opt = this.getClass().getResource('/ehr_status_any_en_v1.opt').text
client.uploadTemplate(opt)
// Create EHR
client.createEhr()
// Commit a clinical document
// - Upload template for clinical document
// - Get sample document, parse it into a COMPOSITION, commit the COMPOSITION
String opt1 = this.getClass().getResource('/minimal_evaluation.opt').text
client.uploadTemplate(opt1)
String json_doc = this.getClass().getResource('/minimal_evaluation.en.v1_20230205.json').text
def parser = new OpenEhrJsonParserQuick()
def doc = parser.parseJson(json_doc)
client.createComposition(ehr.ehr_id.value, doc)
```