Cannot upload OPT template using EHRBase Java SDK v1.19.0

Hi, I’m new to OpenEHR & EHRBase. I have studied the OpenEHR specification. I found that many concepts are interesting. I want to make a proof of concept to use Spring Boot with EHRBase as a backend with some business logic.

I have already tried angular-SDK-example. I now want to start my own API development using Java, following the example but with different package versions. (I’m not Java Developer. I usually use Typescript.). Here is my stack

  • Java 11
  • Spring Boot v2.7.1
  • EHRBase SDK Client v1.19.0

After running a repo, I found that the service cannot upload new OPT with following error,

Caused by: org.ehrbase.client.exception.WrongStatusCodeException: Wrong Status code. Expected: [200, 201, 204]. Got: 404. Error message: <!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 404 – Not Found</h1></body></html>
	at org.ehrbase.client.openehrclient.defaultrestclient.DefaultRestClient.checkStatus(DefaultRestClient.java:283) ~[client-1.18.0.jar:na]
	at org.ehrbase.client.openehrclient.defaultrestclient.DefaultRestClient.internalPost(DefaultRestClient.java:167) ~[client-1.18.0.jar:na]
	at org.ehrbase.client.openehrclient.defaultrestclient.DefaultRestTemplateEndpoint.upload(DefaultRestTemplateEndpoint.java:132) ~[client-1.18.0.jar:na]
	at org.ehrbase.client.openehrclient.defaultrestclient.DefaultRestTemplateEndpoint.ensureExistence(DefaultRestTemplateEndpoint.java:113) ~[client-1.18.0.jar:na]
	at com.example.democpoe.config.ClientConfig.lambda$afterPropertiesSet$0(ClientConfig.java:63) ~[classes/:na]
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) ~[na:na]
	at com.example.democpoe.config.ClientConfig.afterPropertiesSet(ClientConfig.java:60) ~[classes/:na]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.21.jar:5.3.21]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.21.jar:5.3.21]
	... 21 common frames omitted

Here is my POC repo GitHub POC Repo.

Can anyone suggest what should I do next?

Best regards
Pawat

Hi @pawat,

welcome to the forum and great that you are evaluating EHRbase and the SDK! If you can post the template, I would like to try uploading it directly using the REST API. For me it is a bit hard to tell, but the error message might be a hint that the SDK does not call the right endpoints URL for the template upload.

Cheers,

Birger

Hi @birger.haarbrandt ,

The template is in this folder demo-cpoe-openehr/src/main/resources/opt at main · cortexcloud/demo-cpoe-openehr · GitHub.
First, I used the template that I built by myself. It was not working, so I used the template from angular-sdk-example and it was also not working. Furthermore, I tried to upload directly to EHRBase API using this path and there was no problem to insert directly.

curl --request POST \
  --url http://localhost:8080/ehrbase/rest/openehr/v1/definition/template/adl1.4/ \
  --header 'Content-Type: application/xml' \
  --header 'Prefer: return=minimal' \
  --data '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <template xmlns="http://schemas.openehr.org/v1">
    ....
     <template_id>
		<value>General Evaluation</value>
	</template_id>
    ....
	</template>
'

Thank you for your help.
Pawat