@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 }
/** * 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> * @param respondToUri An optional query parameter indicating that responses from the receiving server should be sent to this URI, may be NULL * @param msgBundle Set the Message Bundle to POST to the messaging server * @param asynchronous Whether to process the message asynchronously or synchronously, defaults to synchronous. * @param responseClass the response class * @param extraParameters see {@link ExtraParameters} for a full list of parameters that can be passed, may be NULL * @param <T> extends {@link IBaseBundle} * @return the {@link IBaseBundle} */ public <T extends IBaseBundle> T processMessage(String respondToUri, IBaseBundle msgBundle, boolean asynchronous, Class<T> responseClass, Map<ExtraParameters, Object> extraParameters) { IOperationProcessMsg operationProcessMsg = client.operation().processMessage(); if (ObjectHelper.isNotEmpty(respondToUri)) { operationProcessMsg.setResponseUrlParam(respondToUri); } IOperationProcessMsgMode<T> operationProcessMsgMode = operationProcessMsg.setMessageBundle(msgBundle); if (asynchronous) { operationProcessMsgMode.asynchronous(responseClass); } else { operationProcessMsgMode.synchronous(responseClass); } ExtraParameters.process(extraParameters, operationProcessMsgMode); return operationProcessMsgMode.execute(); }