This is an automated email from the ASF dual-hosted git repository. lburgazzoli pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/master by this push: new aec0003 Add FHIR extension aec0003 is described below commit aec00039908d167bc48359afa1398baf4c50b436 Author: John Poth <poth.j...@gmail.com> AuthorDate: Tue Oct 15 12:56:01 2019 +0200 Add FHIR extension --- docs/modules/ROOT/pages/extensions/fhir.adoc | 34 +++++ .../pages/list-of-camel-quarkus-extensions.adoc | 11 +- extensions/fhir/deployment/pom.xml | 61 ++++++++ .../component/fhir/deployment/FhirProcessor.java | 165 +++++++++++++++++++++ extensions/fhir/pom.xml | 21 +++ extensions/fhir/runtime/pom.xml | 72 +++++++++ .../camel/quarkus/component/fhir/FhirFlags.java | 46 ++++++ .../main/resources/META-INF/quarkus-extension.json | 10 ++ extensions/pom.xml | 1 + extensions/readme.adoc | 11 +- integration-tests/fhir/pom.xml | 146 ++++++++++++++++++ .../component/fhir/it/FhirDstu2Resource.java | 74 +++++++++ .../component/fhir/it/FhirDstu2RouteBuilder.java | 49 ++++++ .../component/fhir/it/FhirDstu3Resource.java | 74 +++++++++ .../component/fhir/it/FhirDstu3RouteBuilder.java | 49 ++++++ .../quarkus/component/fhir/it/FhirR4Resource.java | 74 +++++++++ .../component/fhir/it/FhirR4RouteBuilder.java | 50 +++++++ .../fhir/src/main/resources/application.properties | 40 +++++ .../camel/quarkus/component/fhir/it/FhirIT.java | 24 +++ .../camel/quarkus/component/fhir/it/FhirTest.java | 165 +++++++++++++++++++++ integration-tests/pom.xml | 1 + pom.xml | 1 + poms/bom-deployment/pom.xml | 5 + poms/bom/pom.xml | 21 +++ 24 files changed, 1201 insertions(+), 4 deletions(-) diff --git a/docs/modules/ROOT/pages/extensions/fhir.adoc b/docs/modules/ROOT/pages/extensions/fhir.adoc new file mode 100644 index 0000000..871f3b7 --- /dev/null +++ b/docs/modules/ROOT/pages/extensions/fhir.adoc @@ -0,0 +1,34 @@ +[[fhir]] += FHIR Extension + +*Available as of Camel Quarkus version 0.21* + +The FHIR extension integrates with the +http://hapifhir.io/[HAPI-FHIR] library which is an open-source implementation of the +http://hl7.org/implement/standards/fhir/[FHIR] (Fast Healthcare Interoperability Resources) specification in Java. + +Maven users will need to add the following dependency to their `pom.xml` for this extension. + +[source,xml] +------------------------------------------------------------ +<dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-fhir</artifactId> +</dependency> +------------------------------------------------------------ + +== Usage + +The extension supports the Camel https://camel.apache.org/components/latest/fhirJson-dataformat.html[FHIR Json Dataformat], https://camel.apache.org/components/latest/fhirXml-dataformat.html[FHIR XML Dataformat] and https://camel.apache.org/components/latest/fhir-component.html[FHIR Component]. DSTU2, DSTU3 and R4 are supported. + +=== Configuration + +The https://hapifhir.io/download.html[hapi-fhir] library, on which camel-fhir depends on, heavily uses reflection which affects performance in Quarkus (memory footprint, build time, CPU resources etc...). The following options are provided to improve on this: + +* `camel.fhir.enable-dstu2`: enables dstu2 resources, default `true` +* `camel.fhir.enable-dstu3`: enables dstu3 resources, default `true` +* `camel.fhir.enable-r4`: : enables r4 resources, default `true` + +which can be configured within the `application.properties` configuration file. + +Enjoy ! \ No newline at end of file diff --git a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc index 444584e..d82a469 100644 --- a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc +++ b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc @@ -6,7 +6,7 @@ As of Camel Quarkus {camel-quarkus-last-release} the following Camel artifacts a == Camel Components // components: START -Number of Camel components: 22 in 18 JAR artifacts (0 deprecated) +Number of Camel components: 23 in 19 JAR artifacts (0 deprecated) [width="100%",cols="4,1,5",options="header"] |=== @@ -33,6 +33,9 @@ Number of Camel components: 22 in 18 JAR artifacts (0 deprecated) | link:https://camel.apache.org/components/latest/direct-component.html[Direct] (camel-quarkus-direct) + `direct:name` | 0.2 | The direct component provides direct, synchronous call to another endpoint from the same CamelContext. +| link:https://camel.apache.org/components/latest/fhir-component.html[FHIR] (camel-quarkus-fhir) + +`fhir:apiName/methodName` | 0.2 | The fhir component is used for working with the FHIR protocol (health care). + | link:https://camel.apache.org/components/latest/infinispan-component.html[Infinispan] (camel-quarkus-infinispan) + `infinispan:cacheName` | 0.2 | For reading/writing from/to Infinispan distributed key/value store and data grid. @@ -84,7 +87,7 @@ Number of Camel components: 22 in 18 JAR artifacts (0 deprecated) == Camel Data Formats // dataformats: START -Number of Camel data formats: 4 in 4 JAR artifacts (0 deprecated) +Number of Camel data formats: 6 in 5 JAR artifacts (0 deprecated) [width="100%",cols="4,1,5",options="header"] |=== @@ -92,6 +95,10 @@ Number of Camel data formats: 4 in 4 JAR artifacts (0 deprecated) | link:https://camel.apache.org/components/latest/csv-dataformat.html[CSV] (camel-quarkus-csv) | 0.2 | The CSV data format is used for handling CSV payloads. +| link:https://camel.apache.org/components/latest/fhirJson-dataformat.html[FHIR JSon] (camel-quarkus-fhir) | 0.2 | The FHIR JSon data format is used to marshall/unmarshall to/from FHIR objects to/from JSON. + +| link:https://camel.apache.org/components/latest/fhirXml-dataformat.html[FHIR XML] (camel-quarkus-fhir) | 0.2 | The FHIR XML data format is used to marshall/unmarshall from/to FHIR objects to/from XML. + | link:https://camel.apache.org/components/latest/mime-multipart-dataformat.html[MIME Multipart] (camel-quarkus-mail) | 0.2 | The MIME Multipart data format is used for marshalling Camel messages with attachments into MIME-Multipart message, and vise-versa. | link:https://camel.apache.org/components/latest/tarfile-dataformat.html[Tar File] (camel-quarkus-tarfile) | 0.3 | The Tar File data format is a message compression and de-compression format of tar files. diff --git a/extensions/fhir/deployment/pom.xml b/extensions/fhir/deployment/pom.xml new file mode 100644 index 0000000..b4505ba --- /dev/null +++ b/extensions/fhir/deployment/pom.xml @@ -0,0 +1,61 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-fhir-parent</artifactId> + <version>0.2.1-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-fhir-deployment</artifactId> + <name>Camel Quarkus :: FHIR :: Deployment</name> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-bom-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-core-deployment</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-core-xml-deployment</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-fhir</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <annotationProcessorPaths> + <path> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-extension-processor</artifactId> + <version>${quarkus.version}</version> + </path> + </annotationProcessorPaths> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/extensions/fhir/deployment/src/main/java/org/apache/camel/quarkus/component/fhir/deployment/FhirProcessor.java b/extensions/fhir/deployment/src/main/java/org/apache/camel/quarkus/component/fhir/deployment/FhirProcessor.java new file mode 100644 index 0000000..b2c52bf --- /dev/null +++ b/extensions/fhir/deployment/src/main/java/org/apache/camel/quarkus/component/fhir/deployment/FhirProcessor.java @@ -0,0 +1,165 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.fhir.deployment; + +import java.io.InputStream; +import java.util.Collection; +import java.util.HashSet; +import java.util.Properties; +import java.util.Set; +import ca.uhn.fhir.model.dstu2.FhirDstu2; +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; +import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.quarkus.deployment.builditem.substrate.ReflectiveClassBuildItem; +import io.quarkus.deployment.builditem.substrate.SubstrateResourceBuildItem; +import io.quarkus.deployment.builditem.substrate.SubstrateResourceBundleBuildItem; +import org.apache.camel.component.fhir.FhirCapabilitiesEndpointConfiguration; +import org.apache.camel.component.fhir.FhirConfiguration; +import org.apache.camel.component.fhir.FhirCreateEndpointConfiguration; +import org.apache.camel.component.fhir.FhirDeleteEndpointConfiguration; +import org.apache.camel.component.fhir.FhirHistoryEndpointConfiguration; +import org.apache.camel.component.fhir.FhirLoadPageEndpointConfiguration; +import org.apache.camel.component.fhir.FhirMetaEndpointConfiguration; +import org.apache.camel.component.fhir.FhirOperationEndpointConfiguration; +import org.apache.camel.component.fhir.FhirPatchEndpointConfiguration; +import org.apache.camel.component.fhir.FhirReadEndpointConfiguration; +import org.apache.camel.component.fhir.FhirSearchEndpointConfiguration; +import org.apache.camel.component.fhir.FhirTransactionEndpointConfiguration; +import org.apache.camel.component.fhir.FhirUpdateEndpointConfiguration; +import org.apache.camel.component.fhir.FhirValidateEndpointConfiguration; +import org.apache.camel.quarkus.component.fhir.FhirFlags; +import org.hl7.fhir.dstu3.hapi.ctx.FhirDstu3; +import org.hl7.fhir.dstu3.model.Enumerations; + +class FhirProcessor { + + private static final String FEATURE = "camel-fhir"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } + + @BuildStep + ExtensionSslNativeSupportBuildItem activateSslNativeSupport() { + return new ExtensionSslNativeSupportBuildItem(FEATURE); + } + + + @BuildStep() + ReflectiveClassBuildItem fhirEndpointConfiguration() { + return new ReflectiveClassBuildItem(true, true, + FhirCreateEndpointConfiguration.class.getCanonicalName(), + FhirCapabilitiesEndpointConfiguration.class.getCanonicalName(), + FhirDeleteEndpointConfiguration.class.getCanonicalName(), + FhirHistoryEndpointConfiguration.class.getCanonicalName(), + FhirLoadPageEndpointConfiguration.class.getCanonicalName(), + FhirMetaEndpointConfiguration.class.getCanonicalName(), + FhirOperationEndpointConfiguration.class.getCanonicalName(), + FhirPatchEndpointConfiguration.class.getCanonicalName(), + FhirReadEndpointConfiguration.class.getCanonicalName(), + FhirSearchEndpointConfiguration.class.getCanonicalName(), + FhirTransactionEndpointConfiguration.class.getCanonicalName(), + FhirUpdateEndpointConfiguration.class.getCanonicalName(), + FhirValidateEndpointConfiguration.class.getCanonicalName(), + FhirConfiguration.class.getCanonicalName()); + } + + @BuildStep() + SubstrateResourceBundleBuildItem hapiMessages() { + return new SubstrateResourceBundleBuildItem("ca.uhn.fhir.i18n.hapi-messages"); + } + + @BuildStep + ReflectiveClassBuildItem xmlOutputFactory() { + return new ReflectiveClassBuildItem(false, false, + "com.sun.xml.internal.stream.XMLOutputFactoryImpl"); + } + + @BuildStep(applicationArchiveMarkers = {"org/hl7/fhir", "ca/uhn/fhir"}) + void processFhir(BuildProducer<ReflectiveClassBuildItem> reflectiveClass, BuildProducer<SubstrateResourceBuildItem> resource) { + Set<String> classes = new HashSet<>(); + classes.add("ca.uhn.fhir.rest.client.apache.ApacheRestfulClientFactory"); + classes.add("ca.uhn.fhir.validation.schematron.SchematronBaseValidator"); + classes.add("org.apache.commons.logging.impl.LogFactoryImpl"); + classes.add("org.apache.commons.logging.LogFactory"); + classes.add("org.apache.commons.logging.impl.Jdk14Logger"); + reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, true, classes.toArray(new String[0]))); + } + + @BuildStep(onlyIf = FhirFlags.Dstu2Enabled.class, applicationArchiveMarkers = {"org/hl7/fhir", "ca/uhn/fhir"}) + void processDstu2(BuildProducer<ReflectiveClassBuildItem> reflectiveClass, BuildProducer<SubstrateResourceBuildItem> resource) { + Set<String> classes = new HashSet<>(); + classes.add(FhirDstu2.class.getCanonicalName()); + classes.addAll(getModelClasses("/ca/uhn/fhir/model/dstu2/fhirversion.properties")); + + reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, true, classes.toArray(new String[0]))); + resource.produce(new SubstrateResourceBuildItem("ca/uhn/fhir/model/dstu2/fhirversion.properties")); + } + + @BuildStep(onlyIf = FhirFlags.Dstu3Enabled.class, applicationArchiveMarkers = {"org/hl7/fhir", "ca/uhn/fhir"}) + void processDstu3(BuildProducer<ReflectiveClassBuildItem> reflectiveClass, BuildProducer<SubstrateResourceBuildItem> resource) { + Set<String> classes = new HashSet<>(); + classes.add(FhirDstu3.class.getCanonicalName()); + classes.addAll(getModelClasses("/org/hl7/fhir/dstu3/model/fhirversion.properties")); + classes.addAll(getInnerClasses(Enumerations.class.getCanonicalName())); + + reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, true, classes.toArray(new String[0]))); + resource.produce(new SubstrateResourceBuildItem("org/hl7/fhir/dstu3/model/fhirversion.properties")); + } + + @BuildStep(onlyIf = FhirFlags.R4Enabled.class, applicationArchiveMarkers = {"org/hl7/fhir", "ca/uhn/fhir"}) + void processR4(BuildProducer<ReflectiveClassBuildItem> reflectiveClass, BuildProducer<SubstrateResourceBuildItem> resource) { + Set<String> classes = new HashSet<>(); + classes.add("org.hl7.fhir.r4.hapi.ctx.FhirR4"); + classes.addAll(getModelClasses("/org/hl7/fhir/r4/model/fhirversion.properties")); + classes.addAll(getInnerClasses(org.hl7.fhir.r4.model.Enumerations.class.getCanonicalName())); + + reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, true, classes.toArray(new String[0]))); + resource.produce(new SubstrateResourceBuildItem("org/hl7/fhir/r4/model/fhirversion.properties")); + } + + private Collection<String> getModelClasses(String model) { + try (InputStream str = FhirDstu3.class.getResourceAsStream(model)) { + Properties prop = new Properties(); + prop.load(str); + return getInnerClasses(prop.values().toArray(new String[0])); + } catch (Exception e) { + throw new RuntimeException("Please ensure FHIR is on the classpath", e); + } + } + + private Collection<String> getInnerClasses(String... classList) { + try { + Set<String> classes = new HashSet<>(); + for (Object value : classList) { + String clazz = (String) value; + final Class[] parent = Class.forName(clazz).getClasses(); + for (Class aClass : parent) { + String name = aClass.getName(); + classes.add(name); + } + classes.add(clazz); + } + return classes; + } catch (ClassNotFoundException e) { + throw new RuntimeException("Please ensure FHIR is on the classpath", e); + } + } +} diff --git a/extensions/fhir/pom.xml b/extensions/fhir/pom.xml new file mode 100644 index 0000000..0110618 --- /dev/null +++ b/extensions/fhir/pom.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-build-parent</artifactId> + <version>0.2.1-SNAPSHOT</version> + <relativePath>../../poms/build-parent/pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-fhir-parent</artifactId> + <name>Camel Quarkus :: FHIR</name> + <packaging>pom</packaging> + + <modules> + <module>deployment</module> + <module>runtime</module> + </modules> +</project> diff --git a/extensions/fhir/runtime/pom.xml b/extensions/fhir/runtime/pom.xml new file mode 100644 index 0000000..7971bb8 --- /dev/null +++ b/extensions/fhir/runtime/pom.xml @@ -0,0 +1,72 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-fhir-parent</artifactId> + <version>0.2.1-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-fhir</artifactId> + <name>Camel Quarkus :: FHIR :: Runtime</name> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-bom</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-core-xml</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-fhir</artifactId> + </dependency> + <dependency> + <groupId>ca.uhn.hapi.fhir</groupId> + <artifactId>hapi-fhir-structures-r4</artifactId> + </dependency> + <dependency> + <groupId>org.jboss.logging</groupId> + <artifactId>commons-logging-jboss-logging</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-bootstrap-maven-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <annotationProcessorPaths> + <path> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-extension-processor</artifactId> + <version>${quarkus.version}</version> + </path> + </annotationProcessorPaths> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/extensions/fhir/runtime/src/main/java/org/apache/camel/quarkus/component/fhir/FhirFlags.java b/extensions/fhir/runtime/src/main/java/org/apache/camel/quarkus/component/fhir/FhirFlags.java new file mode 100644 index 0000000..0a3af8e --- /dev/null +++ b/extensions/fhir/runtime/src/main/java/org/apache/camel/quarkus/component/fhir/FhirFlags.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.fhir; + +import java.util.function.BooleanSupplier; +import org.eclipse.microprofile.config.ConfigProvider; + +public final class FhirFlags { + private FhirFlags() { + } + + public static final class Dstu2Enabled implements BooleanSupplier { + @Override + public boolean getAsBoolean() { + return ConfigProvider.getConfig().getOptionalValue("camel.fhir.enable-dstu2", Boolean.class).orElse(Boolean.TRUE); + } + } + + public static final class Dstu3Enabled implements BooleanSupplier { + @Override + public boolean getAsBoolean() { + return ConfigProvider.getConfig().getOptionalValue("camel.fhir.enable-dstu3", Boolean.class).orElse(Boolean.TRUE); + } + } + + public static final class R4Enabled implements BooleanSupplier { + @Override + public boolean getAsBoolean() { + return ConfigProvider.getConfig().getOptionalValue("camel.fhir.enable-r4", Boolean.class).orElse(Boolean.TRUE); + } + } +} \ No newline at end of file diff --git a/extensions/fhir/runtime/src/main/resources/META-INF/quarkus-extension.json b/extensions/fhir/runtime/src/main/resources/META-INF/quarkus-extension.json new file mode 100644 index 0000000..8c3daaf --- /dev/null +++ b/extensions/fhir/runtime/src/main/resources/META-INF/quarkus-extension.json @@ -0,0 +1,10 @@ +{ + "name": "Camel Quarkus FHIR", + "labels": [ + "integration", + "camel", + "healthcare" + ], + "guide": "https://quarkus.io/guides/camel" +} + diff --git a/extensions/pom.xml b/extensions/pom.xml index 4da29c1..2833d8e 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -50,6 +50,7 @@ <module>bean</module> <module>csv</module> <module>direct</module> + <module>fhir</module> <module>infinispan</module> <module>jdbc</module> <module>log</module> diff --git a/extensions/readme.adoc b/extensions/readme.adoc index 92bce7a..d9d4749 100644 --- a/extensions/readme.adoc +++ b/extensions/readme.adoc @@ -5,7 +5,7 @@ Apache Camel Quarkus supports the following Camel artifacts as Quarkus Extension == Camel Components // components: START -Number of Camel components: 22 in 18 JAR artifacts (0 deprecated) +Number of Camel components: 23 in 19 JAR artifacts (0 deprecated) [width="100%",cols="4,1,5",options="header"] |=== @@ -32,6 +32,9 @@ Number of Camel components: 22 in 18 JAR artifacts (0 deprecated) | link:https://camel.apache.org/components/latest/direct-component.html[Direct] (camel-quarkus-direct) + `direct:name` | 0.2 | The direct component provides direct, synchronous call to another endpoint from the same CamelContext. +| link:https://camel.apache.org/components/latest/fhir-component.html[FHIR] (camel-quarkus-fhir) + +`fhir:apiName/methodName` | 0.2 | The fhir component is used for working with the FHIR protocol (health care). + | link:https://camel.apache.org/components/latest/infinispan-component.html[Infinispan] (camel-quarkus-infinispan) + `infinispan:cacheName` | 0.2 | For reading/writing from/to Infinispan distributed key/value store and data grid. @@ -84,7 +87,7 @@ Number of Camel components: 22 in 18 JAR artifacts (0 deprecated) == Camel Data Formats // dataformats: START -Number of Camel data formats: 4 in 4 JAR artifacts (0 deprecated) +Number of Camel data formats: 6 in 5 JAR artifacts (0 deprecated) [width="100%",cols="4,1,5",options="header"] |=== @@ -92,6 +95,10 @@ Number of Camel data formats: 4 in 4 JAR artifacts (0 deprecated) | link:https://camel.apache.org/components/latest/csv-dataformat.html[CSV] (camel-quarkus-csv) | 0.2 | The CSV data format is used for handling CSV payloads. +| link:https://camel.apache.org/components/latest/fhirJson-dataformat.html[FHIR JSon] (camel-quarkus-fhir) | 0.2 | The FHIR JSon data format is used to marshall/unmarshall to/from FHIR objects to/from JSON. + +| link:https://camel.apache.org/components/latest/fhirXml-dataformat.html[FHIR XML] (camel-quarkus-fhir) | 0.2 | The FHIR XML data format is used to marshall/unmarshall from/to FHIR objects to/from XML. + | link:https://camel.apache.org/components/latest/mime-multipart-dataformat.html[MIME Multipart] (camel-quarkus-mail) | 0.2 | The MIME Multipart data format is used for marshalling Camel messages with attachments into MIME-Multipart message, and vise-versa. | link:https://camel.apache.org/components/latest/tarfile-dataformat.html[Tar File] (camel-quarkus-tarfile) | 0.3 | The Tar File data format is a message compression and de-compression format of tar files. diff --git a/integration-tests/fhir/pom.xml b/integration-tests/fhir/pom.xml new file mode 100644 index 0000000..51ee3d8 --- /dev/null +++ b/integration-tests/fhir/pom.xml @@ -0,0 +1,146 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-integration-tests</artifactId> + <version>0.2.1-SNAPSHOT</version> + </parent> + + <artifactId>camel-quarkus-integration-test-fhir</artifactId> + <name>Camel Quarkus :: Integration Tests :: fhir</name> + <description>Integration tests for Camel Quarkus fhir extension</description> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-bom-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-fhir</artifactId> + <exclusions> + <exclusion> + <!-- Pulled in from junit5 --> + <groupId>org.slf4j</groupId> + <artifactId>jcl-over-slf4j</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-log</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-direct</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-junit5</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>io.rest-assured</groupId> + <artifactId>rest-assured</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-maven-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>build</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <systemProperties combine.children="append"> + <camel.fhir.enable-dstu2>true</camel.fhir.enable-dstu2> + <camel.fhir.enable-r4>true</camel.fhir.enable-r4> + </systemProperties> + </configuration> + </plugin> + </plugins> + </build> + + <profiles> + <profile> + <id>native-image</id> + <activation> + <property> + <name>native</name> + </property> + </activation> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-failsafe-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + <configuration> + <systemProperties> + <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path> + </systemProperties> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-maven-plugin</artifactId> + <executions> + <execution> + <id>native-image</id> + <goals> + <goal>native-image</goal> + </goals> + <configuration> + <reportErrorsAtRuntime>false</reportErrorsAtRuntime> + <cleanupServer>true</cleanupServer> + <enableHttpsUrlHandler>true</enableHttpsUrlHandler> + <enableHttpUrlHandler>true</enableHttpUrlHandler> + <enableServer>false</enableServer> + <dumpProxies>false</dumpProxies> + <graalvmHome>${graalvmHome}</graalvmHome> + <enableJni>true</enableJni> + <enableAllSecurityServices>true</enableAllSecurityServices> + <disableReports>true</disableReports> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> + +</project> \ No newline at end of file diff --git a/integration-tests/fhir/src/main/java/org/apache/camel/quarkus/component/fhir/it/FhirDstu2Resource.java b/integration-tests/fhir/src/main/java/org/apache/camel/quarkus/component/fhir/it/FhirDstu2Resource.java new file mode 100644 index 0000000..fcc22ec --- /dev/null +++ b/integration-tests/fhir/src/main/java/org/apache/camel/quarkus/component/fhir/it/FhirDstu2Resource.java @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.fhir.it; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.io.InputStream; +import java.net.URI; +import ca.uhn.fhir.rest.api.MethodOutcome; +import org.apache.camel.ProducerTemplate; + +@Path("/dstu2") +@ApplicationScoped +public class FhirDstu2Resource { + + @Inject + ProducerTemplate producerTemplate; + + @Path("/fhir2json") + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response fhir2json(String patient) throws Exception { + InputStream response = producerTemplate.requestBody("direct:json-to-dstu2", patient, InputStream.class); + return Response + .created(new URI("https://camel.apache.org/")) + .entity(response) + .build(); + } + + @Path("/fhir2xml") + @POST + @Consumes(MediaType.APPLICATION_XML) + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response fhir2xml(String patient) throws Exception { + InputStream response = producerTemplate.requestBody("direct:xml-to-dstu2", patient, InputStream.class); + return Response + .created(new URI("https://camel.apache.org/")) + .entity(response) + .build(); + } + + @Path("/createPatient") + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.TEXT_PLAIN) + public Response createPatient(String patient) throws Exception { + MethodOutcome result = producerTemplate.requestBody("direct:create-dstu2", patient, MethodOutcome.class); + return Response + .created(new URI("https://camel.apache.org/")) + .entity(result.getId().getIdPart()) + .build(); + } +} diff --git a/integration-tests/fhir/src/main/java/org/apache/camel/quarkus/component/fhir/it/FhirDstu2RouteBuilder.java b/integration-tests/fhir/src/main/java/org/apache/camel/quarkus/component/fhir/it/FhirDstu2RouteBuilder.java new file mode 100644 index 0000000..06107eb --- /dev/null +++ b/integration-tests/fhir/src/main/java/org/apache/camel/quarkus/component/fhir/it/FhirDstu2RouteBuilder.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.fhir.it; + +import ca.uhn.fhir.context.FhirVersionEnum; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.fhir.FhirJsonDataFormat; +import org.apache.camel.component.fhir.FhirXmlDataFormat; +import org.apache.camel.quarkus.component.fhir.FhirFlags; + +public class FhirDstu2RouteBuilder extends RouteBuilder { + + @Override + public void configure() { + Boolean dstu2 = new FhirFlags.Dstu2Enabled().getAsBoolean();; + if (dstu2) { + FhirJsonDataFormat fhirJsonDataFormat = new FhirJsonDataFormat(); + fhirJsonDataFormat.setFhirVersion(FhirVersionEnum.DSTU2.name()); + + FhirXmlDataFormat fhirXmlDataFormat = new FhirXmlDataFormat(); + fhirXmlDataFormat.setFhirVersion(FhirVersionEnum.DSTU2.name()); + + from("direct:json-to-dstu2") + .unmarshal(fhirJsonDataFormat) + .marshal(fhirJsonDataFormat); + + from("direct:xml-to-dstu2") + .unmarshal(fhirXmlDataFormat) + .marshal(fhirXmlDataFormat); + + from("direct:create-dstu2") + .to("fhir://create/resource?inBody=resourceAsString&log={{fhir.verbose}}&serverUrl={{fhir.dstu2.url}}&fhirVersion=DSTU2"); + } + } +} diff --git a/integration-tests/fhir/src/main/java/org/apache/camel/quarkus/component/fhir/it/FhirDstu3Resource.java b/integration-tests/fhir/src/main/java/org/apache/camel/quarkus/component/fhir/it/FhirDstu3Resource.java new file mode 100644 index 0000000..a7a9614 --- /dev/null +++ b/integration-tests/fhir/src/main/java/org/apache/camel/quarkus/component/fhir/it/FhirDstu3Resource.java @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.fhir.it; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.io.InputStream; +import java.net.URI; +import ca.uhn.fhir.rest.api.MethodOutcome; +import org.apache.camel.ProducerTemplate; + +@Path("/dstu3") +@ApplicationScoped +public class FhirDstu3Resource { + + @Inject + ProducerTemplate producerTemplate; + + @Path("/fhir2json") + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response fhir2json(String patient) throws Exception { + InputStream response = producerTemplate.requestBody("direct:json-to-dstu3", patient, InputStream.class); + return Response + .created(new URI("https://camel.apache.org/")) + .entity(response) + .build(); + } + + @Path("/fhir2xml") + @POST + @Consumes(MediaType.APPLICATION_XML) + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response fhir2xml(String patient) throws Exception { + InputStream response = producerTemplate.requestBody("direct:xml-to-dstu3", patient, InputStream.class); + return Response + .created(new URI("https://camel.apache.org/")) + .entity(response) + .build(); + } + + @Path("/createPatient") + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.TEXT_PLAIN) + public Response createPatient(String patient) throws Exception { + MethodOutcome result = producerTemplate.requestBody("direct:create-dstu3", patient, MethodOutcome.class); + return Response + .created(new URI("https://camel.apache.org/")) + .entity(result.getId().getIdPart()) + .build(); + } +} diff --git a/integration-tests/fhir/src/main/java/org/apache/camel/quarkus/component/fhir/it/FhirDstu3RouteBuilder.java b/integration-tests/fhir/src/main/java/org/apache/camel/quarkus/component/fhir/it/FhirDstu3RouteBuilder.java new file mode 100644 index 0000000..f93b2d2 --- /dev/null +++ b/integration-tests/fhir/src/main/java/org/apache/camel/quarkus/component/fhir/it/FhirDstu3RouteBuilder.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.fhir.it; + +import ca.uhn.fhir.context.FhirVersionEnum; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.fhir.FhirJsonDataFormat; +import org.apache.camel.component.fhir.FhirXmlDataFormat; +import org.apache.camel.quarkus.component.fhir.FhirFlags; + +public class FhirDstu3RouteBuilder extends RouteBuilder { + + @Override + public void configure() { + Boolean dstu3 = new FhirFlags.Dstu3Enabled().getAsBoolean(); + if (dstu3) { + FhirJsonDataFormat fhirJsonDataFormat = new FhirJsonDataFormat(); + fhirJsonDataFormat.setFhirVersion(FhirVersionEnum.DSTU3.name()); + + FhirXmlDataFormat fhirXmlDataFormat = new FhirXmlDataFormat(); + fhirXmlDataFormat.setFhirVersion(FhirVersionEnum.DSTU3.name()); + + from("direct:json-to-dstu3") + .unmarshal(fhirJsonDataFormat) + .marshal(fhirJsonDataFormat); + + from("direct:xml-to-dstu3") + .unmarshal(fhirXmlDataFormat) + .marshal(fhirXmlDataFormat); + + from("direct:create-dstu3") + .to("fhir://create/resource?inBody=resourceAsString&log={{fhir.verbose}}&serverUrl={{fhir.dstu3.url}}&fhirVersion=DSTU3"); + } + } +} diff --git a/integration-tests/fhir/src/main/java/org/apache/camel/quarkus/component/fhir/it/FhirR4Resource.java b/integration-tests/fhir/src/main/java/org/apache/camel/quarkus/component/fhir/it/FhirR4Resource.java new file mode 100644 index 0000000..3e914ed --- /dev/null +++ b/integration-tests/fhir/src/main/java/org/apache/camel/quarkus/component/fhir/it/FhirR4Resource.java @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.fhir.it; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.io.InputStream; +import java.net.URI; +import ca.uhn.fhir.rest.api.MethodOutcome; +import org.apache.camel.ProducerTemplate; + +@Path("/r4") +@ApplicationScoped +public class FhirR4Resource { + + @Inject + ProducerTemplate producerTemplate; + + @Path("/fhir2json") + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response fhir2json(String patient) throws Exception { + InputStream response = producerTemplate.requestBody("direct:json-to-r4", patient, InputStream.class); + return Response + .created(new URI("https://camel.apache.org/")) + .entity(response) + .build(); + } + + @Path("/fhir2xml") + @POST + @Consumes(MediaType.APPLICATION_XML) + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response fhir2xml(String patient) throws Exception { + InputStream response = producerTemplate.requestBody("direct:xml-to-r4", patient, InputStream.class); + return Response + .created(new URI("https://camel.apache.org/")) + .entity(response) + .build(); + } + + @Path("/createPatient") + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.TEXT_PLAIN) + public Response createPatient(String patient) throws Exception { + MethodOutcome result = producerTemplate.requestBody("direct:create-r4", patient, MethodOutcome.class); + return Response + .created(new URI("https://camel.apache.org/")) + .entity(result.getId().getIdPart()) + .build(); + } +} diff --git a/integration-tests/fhir/src/main/java/org/apache/camel/quarkus/component/fhir/it/FhirR4RouteBuilder.java b/integration-tests/fhir/src/main/java/org/apache/camel/quarkus/component/fhir/it/FhirR4RouteBuilder.java new file mode 100644 index 0000000..03641a6 --- /dev/null +++ b/integration-tests/fhir/src/main/java/org/apache/camel/quarkus/component/fhir/it/FhirR4RouteBuilder.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.fhir.it; + +import ca.uhn.fhir.context.FhirVersionEnum; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.fhir.FhirJsonDataFormat; +import org.apache.camel.component.fhir.FhirXmlDataFormat; +import org.apache.camel.quarkus.component.fhir.FhirFlags; + +public class FhirR4RouteBuilder extends RouteBuilder { + + @Override + public void configure() { + Boolean r4 = new FhirFlags.R4Enabled().getAsBoolean(); + + if (r4) { + FhirJsonDataFormat fhirJsonDataFormat = new FhirJsonDataFormat(); + fhirJsonDataFormat.setFhirVersion(FhirVersionEnum.R4.name()); + + FhirXmlDataFormat fhirXmlDataFormat = new FhirXmlDataFormat(); + fhirXmlDataFormat.setFhirVersion(FhirVersionEnum.R4.name()); + + from("direct:json-to-r4") + .unmarshal(fhirJsonDataFormat) + .marshal(fhirJsonDataFormat); + + from("direct:xml-to-r4") + .unmarshal(fhirXmlDataFormat) + .marshal(fhirXmlDataFormat); + + from("direct:create-r4") + .to("fhir://create/resource?inBody=resourceAsString&log={{fhir.verbose}}&serverUrl={{fhir.r4.url}}&fhirVersion=R4"); + } + } +} diff --git a/integration-tests/fhir/src/main/resources/application.properties b/integration-tests/fhir/src/main/resources/application.properties new file mode 100644 index 0000000..06640a2 --- /dev/null +++ b/integration-tests/fhir/src/main/resources/application.properties @@ -0,0 +1,40 @@ +## --------------------------------------------------------------------------- +## Licensed to the Apache Software Foundation (ASF) under one or more +## contributor license agreements. See the NOTICE file distributed with +## this work for additional information regarding copyright ownership. +## The ASF licenses this file to You under the Apache License, Version 2.0 +## (the "License"); you may not use this file except in compliance with +## the License. You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## --------------------------------------------------------------------------- +# +# Quarkus +# +quarkus.ssl.native=true +# +# Quarkus :: Camel +# +quarkus.camel.disable-jaxb=false +# +# Quarkus :: Camel :: FHIR +# +# The HAPI-FHIR library, on which camel-fhir depends on, heavily uses reflection which affects performance in Quarkus +# (memory footprint, build time, CPU resources etc...). For the sake of time, only DSTU3 (which is the default FHIR version) +# tests are enabled for DSTU3 only by default. +camel.fhir.enable-dstu2=false +camel.fhir.enable-dstu3=true +camel.fhir.enable-r4=false +# +# Camel +# +fhir.dstu2.url=http://Fhirtest.uhn.ca/baseDstu2 +fhir.dstu3.url=http://Fhirtest.uhn.ca/baseDstu3 +fhir.r4.url=http://Fhirtest.uhn.ca/baseR4 +fhir.verbose=false \ No newline at end of file diff --git a/integration-tests/fhir/src/test/java/org/apache/camel/quarkus/component/fhir/it/FhirIT.java b/integration-tests/fhir/src/test/java/org/apache/camel/quarkus/component/fhir/it/FhirIT.java new file mode 100644 index 0000000..102e635 --- /dev/null +++ b/integration-tests/fhir/src/test/java/org/apache/camel/quarkus/component/fhir/it/FhirIT.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.fhir.it; + +import io.quarkus.test.junit.SubstrateTest; + +@SubstrateTest +class FhirIT extends FhirTest { + +} diff --git a/integration-tests/fhir/src/test/java/org/apache/camel/quarkus/component/fhir/it/FhirTest.java b/integration-tests/fhir/src/test/java/org/apache/camel/quarkus/component/fhir/it/FhirTest.java new file mode 100644 index 0000000..84b0aa8 --- /dev/null +++ b/integration-tests/fhir/src/test/java/org/apache/camel/quarkus/component/fhir/it/FhirTest.java @@ -0,0 +1,165 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.fhir.it; + +import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.model.dstu2.composite.AddressDt; +import ca.uhn.fhir.model.dstu2.composite.HumanNameDt; +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; +import org.apache.camel.quarkus.component.fhir.FhirFlags; +import org.hl7.fhir.dstu3.model.Address; +import org.hl7.fhir.dstu3.model.HumanName; +import org.hl7.fhir.dstu3.model.Patient; +import org.junit.jupiter.api.Test; + +@QuarkusTest +class FhirTest { + + Boolean dstu2 = new FhirFlags.Dstu2Enabled().getAsBoolean(); + Boolean dstu3 = new FhirFlags.Dstu3Enabled().getAsBoolean(); + Boolean r4 = new FhirFlags.R4Enabled().getAsBoolean(); + + @Test + public void jsonDstu2() { + if(!dstu2) + return; + final ca.uhn.fhir.model.dstu2.resource.Patient patient = getDstu2Patient(); + String patientString = FhirContext.forDstu2().newJsonParser().encodeResourceToString(patient); + RestAssured.given() // + .contentType(ContentType.JSON).body(patientString).post("/dstu2/fhir2json") + .then().statusCode(201); + } + + @Test + public void xmlDstu2() { + if(!dstu2) + return; + + final ca.uhn.fhir.model.dstu2.resource.Patient patient = getDstu2Patient(); + String patientString = FhirContext.forDstu2().newXmlParser().encodeResourceToString(patient); + RestAssured.given() // + .contentType(ContentType.XML).body(patientString).post("/dstu2/fhir2xml") + .then().statusCode(201); + } + + @Test + public void fhirClientDstu2() { + if(!dstu2) + return; + + final ca.uhn.fhir.model.dstu2.resource.Patient patient = getDstu2Patient(); + String patientString = FhirContext.forDstu2().newJsonParser().encodeResourceToString(patient); + RestAssured.given() // + .contentType(ContentType.JSON).body(patientString).post("/dstu2/createPatient") // + .then().statusCode(201); + } + + @Test + public void jsonDstu3() { + if(!dstu3) + return; + + final Patient patient = getDstu3Patient(); + String patientString = FhirContext.forDstu3().newJsonParser().encodeResourceToString(patient); + RestAssured.given() // + .contentType(ContentType.JSON).body(patientString).post("/dstu3/fhir2json") + .then().statusCode(201); + } + + @Test + public void xmlDstu3() { + if(!dstu3) + return; + + final Patient patient = getDstu3Patient(); + String patientString = FhirContext.forDstu3().newXmlParser().encodeResourceToString(patient); + RestAssured.given() // + .contentType(ContentType.XML).body(patientString).post("/dstu3/fhir2xml") + .then().statusCode(201); + } + + @Test + public void fhirClientDstu3() { + if(!dstu3) + return; + + final Patient patient = getDstu3Patient(); + String patientString = FhirContext.forDstu3().newJsonParser().encodeResourceToString(patient); + RestAssured.given() // + .contentType(ContentType.JSON).body(patientString).post("/dstu3/createPatient") // + .then().statusCode(201); + } + + @Test + public void jsonR4() { + if(!r4) + return; + + final org.hl7.fhir.r4.model.Patient patient = getR4Patient(); + String patientString = FhirContext.forR4().newJsonParser().encodeResourceToString(patient); + RestAssured.given() // + .contentType(ContentType.JSON).body(patientString).post("/r4/fhir2json") + .then().statusCode(201); + } + + @Test + public void xmlR4() { + if(!r4) + return; + + final org.hl7.fhir.r4.model.Patient patient = getR4Patient(); + String patientString = FhirContext.forR4().newXmlParser().encodeResourceToString(patient); + RestAssured.given() // + .contentType(ContentType.XML).body(patientString).post("/r4/fhir2xml") + .then().statusCode(201); + } + + @Test + public void fhirClientR4() { + if(!r4) + return; + + final org.hl7.fhir.r4.model.Patient patient = getR4Patient(); + String patientString = FhirContext.forR4().newJsonParser().encodeResourceToString(patient); + RestAssured.given() // + .contentType(ContentType.JSON).body(patientString.getBytes()).post("/r4/createPatient") // + .then().statusCode(201); + } + + private ca.uhn.fhir.model.dstu2.resource.Patient getDstu2Patient() { + return new ca.uhn.fhir.model.dstu2.resource.Patient().addName(new HumanNameDt().addGiven("Sherlock") + .addFamily("Holmes")) + .addAddress(new AddressDt().addLine("221b Baker St, Marylebone, London NW1 6XE, UK")); + } + + private Patient getDstu3Patient() { + return new Patient().addName(new HumanName().addGiven("Sherlock") + .setFamily("Holmes")) + .addAddress(new Address().addLine("221b Baker St, Marylebone, London NW1 6XE, UK")); + } + + private org.hl7.fhir.r4.model.Patient getR4Patient() { + org.hl7.fhir.r4.model.Patient patient = new org.hl7.fhir.r4.model.Patient(); + patient.addAddress().addLine("221b Baker St, Marylebone, London NW1 6XE, UK"); + patient.addName().addGiven("Sherlock").setFamily("Holmes"); + return patient; + } + + +} diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 7cd2cb7..d75164b 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -91,6 +91,7 @@ <module>aws</module> <module>bean</module> <module>csv</module> + <module>fhir</module> <module>infinispan</module> <module>jdbc</module> <module>mail</module> diff --git a/pom.xml b/pom.xml index 0a76965..3cefd31 100644 --- a/pom.xml +++ b/pom.xml @@ -41,6 +41,7 @@ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <camel.version>3.0.0-RC3</camel.version> + <hapi.version>3.7.0</hapi.version> <quarkus.version>0.26.1</quarkus.version> <jetty.version>9.4.18.v20190429</jetty.version> <xstream.version>1.4.11</xstream.version> diff --git a/poms/bom-deployment/pom.xml b/poms/bom-deployment/pom.xml index cb50acf..396b8d8 100644 --- a/poms/bom-deployment/pom.xml +++ b/poms/bom-deployment/pom.xml @@ -240,6 +240,11 @@ <artifactId>camel-quarkus-attachments-deployment</artifactId> <version>${camel-quarkus.version}</version> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-fhir-deployment</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> </dependencies> </dependencyManagement> diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index 8ccb641..d83878a 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -121,6 +121,11 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> + <artifactId>camel-fhir</artifactId> + <version>${camel.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> <artifactId>camel-headersmap</artifactId> <version>${camel.version}</version> </dependency> @@ -339,6 +344,11 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-fhir</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-infinispan</artifactId> <version>${camel-quarkus.version}</version> </dependency> @@ -435,6 +445,17 @@ <!-- Other third party dependencies (in alphabetical order by groupId:artifactId) --> <dependency> + <groupId>ca.uhn.hapi.fhir</groupId> + <artifactId>hapi-fhir-structures-r4</artifactId> + <version>${hapi.version}</version> + <exclusions> + <exclusion> + <groupId>org.slf4j</groupId> + <artifactId>jcl-over-slf4j</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-client</artifactId> <version>${jetty.version}</version>