Coder Social home page Coder Social logo

openehr-rest-client's Introduction

openEHR REST Client

This is the Groovy reference implementation of the openEHR 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

// 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)

openehr-rest-client's People

Contributors

ppazos avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

openehr-rest-client's Issues

Update groovy dependencies

Project is using old groovy dependencies (2020) and there are some problems using the latest JDK. I'd suggest we move to groovy-all:3.0.17 and spock-core:2.3-groovy-3.0. Gradle could also be updated to 7.6

Verify error codes instead of messages

Since error messages are not part of the specs and will vary quite a lot between implementations, I would suggest we check HTTP status codes instead. Those are included in the specs and should be implementation agnostic.

Default representation details negotiation

The conformance is currently running with a hardcoded HTTP header for representation details (Prefer: return=representation) and it is expecting resolved references in the creation of EHRs (EhrDto). We can support both behaviours by allowing defining these headers, returning EhrDto when configured to resolve references (i.e. Prefer: return=representation, resolve_refs) and Ehr if not (i.e. Prefer: return=representation).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.