This commit is contained in:
James 2017-03-16 21:57:55 -04:00
parent 8a32e4bae5
commit fc7ac7ab00
5 changed files with 49 additions and 8 deletions

View File

@ -1,5 +1,8 @@
package example;
import org.hl7.fhir.dstu3.model.Bundle;
import org.hl7.fhir.instance.model.api.IBaseBundle;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.okhttp.client.OkHttpRestfulClientFactory;
import ca.uhn.fhir.rest.client.IGenericClient;
@ -35,6 +38,26 @@ public class ClientExamples {
// END SNIPPET: proxy
}
@SuppressWarnings("unused")
public void processMessage() {
// START SNIPPET: processMessage
FhirContext ctx = FhirContext.forDstu3();
// Create the client
IGenericClient client = ctx.newRestfulGenericClient("http://localhost:9999/fhir");
Bundle bundle = new Bundle();
// ..populate the bundle..
Bundle response = client
.operation()
.processMessage() // New operation for sending messages
.setMessageBundle(bundle)
.asynchronous(Bundle.class)
.execute();
// END SNIPPET: processMessage
}
@SuppressWarnings("unused")
public void createOkHttp() {
// START SNIPPET: okhttp

View File

@ -1,7 +1,5 @@
package ca.uhn.fhir.rest.gclient;
import org.hl7.fhir.instance.model.api.IBaseResource;
/*
* #%L
* HAPI FHIR - Core Library
@ -24,29 +22,27 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
public interface IOperation extends IBaseOn<IOperationUnnamed> {
/**
* This operation is called <b><a href="https://www.hl7.org/fhir/messaging.html">$process-message</a></b> as defined by FHIR
* DSTU2.<br><br>
* This operation is called <b><a href="https://www.hl7.org/fhir/messaging.html">$process-message</a></b> as defined by the FHIR
* specification.<br><br>
* Usage :<br>
* <code>
* <pre>
* Bundle response = client
* .operation()
* .onServer()
* .processMessage()
* .synchronous(Bundle.class)
* .setResponseUrlParam("http://myserver/fhir")
* .setMessageBundle(msgBundle)
* .synchronous(Bundle.class)
* .execute();
*
* //if you want to send an async message
*
* OperationOutcome response = client
* .operation()
* .onServer()
* .processMessage()
* .asynchronous(OperationOutcome.class)
* .setResponseUrlParam("http://myserver/fhir")
* .setMessageBundle(msgBundle)
* .asynchronous(OperationOutcome.class)
* .execute();
*
* </pre>

View File

@ -306,6 +306,10 @@
<id>sekaijin</id>
<name>sekaijin</name>
</developer>
<developer>
<id>hugosoares</id>
<name>Hugo Soares</name>
</developer>
</developers>
<licenses>

View File

@ -178,6 +178,10 @@
are now populated into the OperationOutcome produced by
create and update operations
</action>
<action type="add">
Add support for the $process-message operation to fluent client.
Thanks to Hugo Soares for the pull request!
</action>
</release>
<release version="2.2" date="2016-12-20">
<action type="add">

View File

@ -518,6 +518,20 @@
</subsection>
<subsection name="Built-In Operations - Process-Message">
<p>
The <code>$process-message</code> operation asks the server to accept a fhir
message bundle for processing.
</p>
<macro name="snippet">
<param name="id" value="processMessage" />
<param name="file" value="examples/src/main/java/example/ClientExamples.java" />
</macro>
</subsection>
</section>
</body>