You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2024/10/21 13:03:13 UTC
(camel-quarkus) 01/02: Document FHIR native mode requirements for FhirContext
This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 6cf7430d116d5a1be3e46acdfb0ab3949290521d
Author: James Netherton <ja...@gmail.com>
AuthorDate: Mon Oct 21 11:34:32 2024 +0100
Document FHIR native mode requirements for FhirContext
---
.../ROOT/pages/reference/extensions/fhir.adoc | 81 +++++++++++++++++++++-
.../fhir/runtime/src/main/doc/configuration.adoc | 3 +-
extensions/fhir/runtime/src/main/doc/usage.adoc | 73 +++++++++++++++++++
3 files changed, 153 insertions(+), 4 deletions(-)
diff --git a/docs/modules/ROOT/pages/reference/extensions/fhir.adoc b/docs/modules/ROOT/pages/reference/extensions/fhir.adoc
index 5103d43e8d..104fe8c4a0 100644
--- a/docs/modules/ROOT/pages/reference/extensions/fhir.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/fhir.adoc
@@ -47,6 +47,84 @@ ifeval::[{doc-show-user-guide-link} == true]
Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
endif::[]
+[id="extensions-fhir-usage"]
+== Usage
+[id="extensions-fhir-usage-configuring-the-fhircontext-in-native-mode"]
+=== Configuring the `FhirContext` in native mode
+
+To ensure `camel-quarkus-fhir` operates correctly in native mode, it is important that the FHIR component and data formats use a native mode optimized `FhirContext`.
+Examples of how to achieve this follow below.
+
+NOTE: To use a particular FHIR version in native mode, you must ensure that it is enabled via the configuration options mentioned below.
+
+Endpoint configuration when using the default `R4` FHIR version.
+
+[source,java]
+----
+public class FhirRoutes extends RouteBuilder {
+ @Override
+ public void configure() {
+ from("direct:start")
+ .to("fhir://create/resource?fhirContext=#R4&inBody=resourceAsString");
+ }
+}
+----
+
+Endpoint configuration when using a custom FHIR version (e.g `R5`).
+
+[source,java]
+----
+public class FhirRoutes extends RouteBuilder {
+ @Override
+ public void configure() {
+ from("direct:start")
+ .to("fhir://create/resource?fhirVersion=R5&fhirContext=#R5&inBody=resourceAsString");
+ }
+}
+----
+
+Instead of setting the `fhirContext` option on every endpoint URI, you can instead configure it directly on the FHIR component.
+
+[source,properties]
+----
+camel.component.fhir.fhir-context=#R4
+----
+
+FHIR data format configuration.
+
+[source,java]
+----
+public class FhirRoutes extends RouteBuilder {
+ // Each FHIR version has a corresponding injectable named bean
+ @Inject
+ @Named("R4")
+ FhirContext r4FhirContext;
+
+ @Inject
+ @Named("R5")
+ FhirContext r5FhirContext;
+
+ @Override
+ public void configure() {
+ // Configure FhirJsonDataFormat with the default R4 FhirContext
+ FhirJsonDataFormat fhirJsonDataFormat = new FhirJsonDataFormat();
+ fhirJsonDataFormat.setFhirContext(r4FhirContext);
+
+ // Configure FhirXmlDataFormat with a custom version and the corresponding FhirContext
+ FhirXmlDataFormat fhirXmlDataFormat = new FhirXmlDataFormat();
+ fhirXmlDataFormat.setVersion("R5");
+ fhirXmlDataFormat.setFhirContext(r5FhirContext);
+
+ from("direct:marshalFhirJson")
+ .marshal(fhirJsonDataFormat);
+
+ from("direct:marshalFhirXml")
+ .marshal(fhirXmlDataFormat);
+ }
+}
+----
+
+
[id="extensions-fhir-ssl-in-native-mode"]
== SSL in native mode
@@ -57,8 +135,7 @@ https://quarkus.io/guides/native-and-ssl[Quarkus SSL guide].
[id="extensions-fhir-additional-camel-quarkus-configuration"]
== Additional Camel Quarkus configuration
-
-By default, only FHIR versions `R4` & `DSTU3` are enabled in native mode, since they are the default values on the FHIR component and DataFormat.
+By default, only FHIR version `R4` is enabled in native mode, since that is also the default version configured on the FHIR component and data formats.
[width="100%",cols="80,5,15",options="header"]
diff --git a/extensions/fhir/runtime/src/main/doc/configuration.adoc b/extensions/fhir/runtime/src/main/doc/configuration.adoc
index 820a98a5aa..f98ecd15b7 100644
--- a/extensions/fhir/runtime/src/main/doc/configuration.adoc
+++ b/extensions/fhir/runtime/src/main/doc/configuration.adoc
@@ -1,2 +1 @@
-
-By default, only FHIR versions `R4` & `DSTU3` are enabled in native mode, since they are the default values on the FHIR component and DataFormat.
+By default, only FHIR version `R4` is enabled in native mode, since that is also the default version configured on the FHIR component and data formats.
diff --git a/extensions/fhir/runtime/src/main/doc/usage.adoc b/extensions/fhir/runtime/src/main/doc/usage.adoc
new file mode 100644
index 0000000000..d2dc499f3a
--- /dev/null
+++ b/extensions/fhir/runtime/src/main/doc/usage.adoc
@@ -0,0 +1,73 @@
+=== Configuring the `FhirContext` in native mode
+
+To ensure `camel-quarkus-fhir` operates correctly in native mode, it is important that the FHIR component and data formats use a native mode optimized `FhirContext`.
+Examples of how to achieve this follow below.
+
+NOTE: To use a particular FHIR version in native mode, you must ensure that it is enabled via the configuration options mentioned below.
+
+Endpoint configuration when using the default `R4` FHIR version.
+
+[source,java]
+----
+public class FhirRoutes extends RouteBuilder {
+ @Override
+ public void configure() {
+ from("direct:start")
+ .to("fhir://create/resource?fhirContext=#R4&inBody=resourceAsString");
+ }
+}
+----
+
+Endpoint configuration when using a custom FHIR version (e.g `R5`).
+
+[source,java]
+----
+public class FhirRoutes extends RouteBuilder {
+ @Override
+ public void configure() {
+ from("direct:start")
+ .to("fhir://create/resource?fhirVersion=R5&fhirContext=#R5&inBody=resourceAsString");
+ }
+}
+----
+
+Instead of setting the `fhirContext` option on every endpoint URI, you can instead configure it directly on the FHIR component.
+
+[source,properties]
+----
+camel.component.fhir.fhir-context=#R4
+----
+
+FHIR data format configuration.
+
+[source,java]
+----
+public class FhirRoutes extends RouteBuilder {
+ // Each FHIR version has a corresponding injectable named bean
+ @Inject
+ @Named("R4")
+ FhirContext r4FhirContext;
+
+ @Inject
+ @Named("R5")
+ FhirContext r5FhirContext;
+
+ @Override
+ public void configure() {
+ // Configure FhirJsonDataFormat with the default R4 FhirContext
+ FhirJsonDataFormat fhirJsonDataFormat = new FhirJsonDataFormat();
+ fhirJsonDataFormat.setFhirContext(r4FhirContext);
+
+ // Configure FhirXmlDataFormat with a custom version and the corresponding FhirContext
+ FhirXmlDataFormat fhirXmlDataFormat = new FhirXmlDataFormat();
+ fhirXmlDataFormat.setVersion("R5");
+ fhirXmlDataFormat.setFhirContext(r5FhirContext);
+
+ from("direct:marshalFhirJson")
+ .marshal(fhirJsonDataFormat);
+
+ from("direct:marshalFhirXml")
+ .marshal(fhirXmlDataFormat);
+ }
+}
+----