// Do not edit directly!
// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
[id="extensions-fhir"]
= FHIR
:page-aliases: extensions/fhir.adoc
:linkattrs:
:cq-artifact-id: camel-quarkus-fhir
:cq-native-supported: true
:cq-status: Stable
:cq-status-deprecation: Stable
:cq-description: Exchange information in the healthcare domain using the FHIR (Fast Healthcare Interoperability Resources) standard. Marshall and unmarshall FHIR objects to/from JSON. Marshall and unmarshall FHIR objects to/from XML.
:cq-deprecated: false
:cq-jvm-since: 0.3.0
:cq-native-since: 0.3.0

ifeval::[{doc-show-badges} == true]
[.badges]
[.badge-key]##JVM since##[.badge-supported]##0.3.0## [.badge-key]##Native since##[.badge-supported]##0.3.0##
endif::[]

Exchange information in the healthcare domain using the FHIR (Fast Healthcare Interoperability Resources) standard. Marshall and unmarshall FHIR objects to/from JSON. Marshall and unmarshall FHIR objects to/from XML.

[id="extensions-fhir-whats-inside"]
== What's inside

* xref:{cq-camel-components}::fhir-component.adoc[FHIR component], URI syntax: `fhir:apiName/methodName`
* xref:{cq-camel-components}:dataformats:fhirJson-dataformat.adoc[FHIR JSon data format]
* xref:{cq-camel-components}:dataformats:fhirXml-dataformat.adoc[FHIR XML data format]

Please refer to the above links for usage and configuration details.

[id="extensions-fhir-maven-coordinates"]
== Maven coordinates

https://{link-quarkus-code-generator}/?extension-search=camel-quarkus-fhir[Create a new project with this extension on {link-quarkus-code-generator}, window="_blank"]

Or add the coordinates to your existing project:

[source,xml]
----
<dependency>
    <groupId>org.apache.camel.quarkus</groupId>
    <artifactId>camel-quarkus-fhir</artifactId>
</dependency>
----
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

This extension auto-enables SSL support in native mode. Hence you do not need to add
`quarkus.ssl.native=true` to your `application.properties` yourself. See also
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 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"]
|===
| Configuration property | Type | Default


a|icon:lock[title=Fixed at build time] [[quarkus-camel-fhir-enable-dstu2]]`link:#quarkus-camel-fhir-enable-dstu2[quarkus.camel.fhir.enable-dstu2]`

Enable FHIR DSTU2 Specs in native mode.
| `boolean`
| `false`

a|icon:lock[title=Fixed at build time] [[quarkus-camel-fhir-enable-dstu2_hl7org]]`link:#quarkus-camel-fhir-enable-dstu2_hl7org[quarkus.camel.fhir.enable-dstu2_hl7org]`

Enable FHIR DSTU2_HL7ORG Specs in native mode.
| `boolean`
| `false`

a|icon:lock[title=Fixed at build time] [[quarkus-camel-fhir-enable-dstu2_1]]`link:#quarkus-camel-fhir-enable-dstu2_1[quarkus.camel.fhir.enable-dstu2_1]`

Enable FHIR DSTU2_1 Specs in native mode.
| `boolean`
| `false`

a|icon:lock[title=Fixed at build time] [[quarkus-camel-fhir-enable-dstu3]]`link:#quarkus-camel-fhir-enable-dstu3[quarkus.camel.fhir.enable-dstu3]`

Enable FHIR DSTU3 Specs in native mode.
| `boolean`
| `false`

a|icon:lock[title=Fixed at build time] [[quarkus-camel-fhir-enable-r4]]`link:#quarkus-camel-fhir-enable-r4[quarkus.camel.fhir.enable-r4]`

Enable FHIR R4 Specs in native mode.
| `boolean`
| `true`

a|icon:lock[title=Fixed at build time] [[quarkus-camel-fhir-enable-r5]]`link:#quarkus-camel-fhir-enable-r5[quarkus.camel.fhir.enable-r5]`

Enable FHIR R5 Specs in native mode.
| `boolean`
| `false`
|===

[.configuration-legend]
{doc-link-icon-lock}[title=Fixed at build time] Configuration property fixed at build time. All other configuration properties are overridable at runtime.

