diff --git a/README.md b/README.md index b5ab790b8e4a44d83bd19169e354e5e39a367a5b..c5859f81d8b91e7c01144e076a9d31fb65f8afe6 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,54 @@ + # Pixm Connector +--- +### Prerequisites +- Java 11 with maven. +- WildFly 18. +--- +### Build project locally + +After cloning this repository to your local installation launch + +```bash + > mvn clean install +``` + +from the project root directory. + + +The artifact pixm_fhir_server.war will be created in target/ directory. + + +--- +### Deploy on WildFly server + +After building the project through Maven, the artifact created just has to be added to your local WildFly installation in the folder +```bash + {$wildfly.home}/standalone/deployments +``` + +--- +### Request a Patient on a specific Target Identifier + +Once the project deployed on your WildFly, you can now call it to request a cross Referenced Patient in the Patient Registry. + +The URL to call is +```http + {wildfly18.address}/pixm_fhir_server/fhir_ihe/Patient/$ihe-pix +``` +Parameters allowed are : + +- The Patient Identifier and the Target System attributed to this identifier +- The Target System you want the cross reference from. + +For example : +Given the Patient with the ID 69420 in the Target System 1:2:3:4:5023:31520 +And you want the cross referenced patient in the target system 5:6:7:8:0587:79085 + +The corresponding url will be : + +```http + {wildfly18.address}/pixm_fhir_server/fhir_ihe/Patient/$ihe-pix?sourceIdentifier=urn:oid:1:2:3:4:5023:31520|69420&targetSystem=5:6:7:8:0587:79085 +``` + diff --git a/pom.xml b/pom.xml index 6590ea30adfcc25db7c8b9e437cefa73c4958431..8563125befa20636fd749f42c78a291d13614d2c 100644 --- a/pom.xml +++ b/pom.xml @@ -1,31 +1,32 @@ -<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/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>net.ihe.gazelle</groupId> - <artifactId>pixm-connector</artifactId> - <packaging>war</packaging> - <version>1.0.0-SNAPSHOT</version> - <name>Pixm Connector</name> +<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/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>net.ihe.gazelle</groupId> + <artifactId>pixm-connector</artifactId> + <packaging>war</packaging> + <version>1.0.0-SNAPSHOT</version> + <name>Pixm Connector</name> - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <dependency.check.version>5.2.4</dependency.check.version> - <dependency.check.skip>true</dependency.check.skip> - <cvss.score.level.tolerate>8</cvss.score.level.tolerate> - <nexus.url>https://gazelle.ihe.net/nexus</nexus.url> - <nexus.path>/content/groups/public/</nexus.path> - <java.version>11</java.version> - <maven-javadoc-plugin.version>3.1.1</maven-javadoc-plugin.version> - <git.user.name>gitlab-ci</git.user.name> - <git.user.token>changeit</git.user.token> - <git.project.url> - https://${git.user.name}:${git.user.token}@gitlab.inria.fr/gazelle/applications/test-execution/simulator/pixm-connector.git - </git.project.url> - <hapifhir_version>5.4.0</hapifhir_version> + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <dependency.check.version>5.2.4</dependency.check.version> + <dependency.check.skip>true</dependency.check.skip> + <cvss.score.level.tolerate>8</cvss.score.level.tolerate> + <nexus.url>https://gazelle.ihe.net/nexus</nexus.url> + <nexus.path>/content/groups/public/</nexus.path> + <java.version>11</java.version> + <maven-javadoc-plugin.version>3.1.1</maven-javadoc-plugin.version> + <git.user.name>gitlab-ci</git.user.name> + <git.user.token>changeit</git.user.token> + <git.project.url> + https://${git.user.name}:${git.user.token}@gitlab.inria.fr/gazelle/applications/test-execution/simulator/pixm-connector.git + </git.project.url> + <hapifhir_version>5.4.0</hapifhir_version> <maven.release.plugin.version>2.5.3</maven.release.plugin.version> <nexus.staging.maven.plugin.version>1.6.8</nexus.staging.maven.plugin.version> <sonar.maven.plugin>3.5.0.1254</sonar.maven.plugin> - </properties> + </properties> <scm> <connection>scm:git:${git.project.url}</connection> @@ -111,60 +112,56 @@ </profiles> <build> - <finalName>pixm_fhir_server</finalName> + <finalName>pixm_fhir_server</finalName> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-release-plugin</artifactId> - <version>${maven.release.plugin.version}</version> - <configuration> - <tagNameFormat>@{project.version}</tagNameFormat> - <autoVersionSubmodules>true</autoVersionSubmodules> - <releaseProfiles>release</releaseProfiles> - </configuration> - </plugin> - <!-- - Tell Maven which Java source version you want to use - --> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <version>3.3</version> - <configuration> - <source>${java.version}</source> - <target>${java.version}</target> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <version>2.22.2</version> - <dependencies> - <dependency> - <groupId>org.apache.maven.surefire</groupId> - <artifactId>surefire-testng</artifactId> - <version>2.22.1</version> - </dependency> - </dependencies> - </plugin> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-release-plugin</artifactId> + <version>${maven.release.plugin.version}</version> + <configuration> + <tagNameFormat>@{project.version}</tagNameFormat> + <autoVersionSubmodules>true</autoVersionSubmodules> + <releaseProfiles>release</releaseProfiles> + </configuration> + </plugin> + <!-- Tell Maven which Java source version you want to use --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.3</version> + <configuration> + <source>${java.version}</source> + <target>${java.version}</target> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.22.2</version> + <dependencies> + <dependency> + <groupId>org.apache.maven.surefire</groupId> + <artifactId>surefire-testng</artifactId> + <version>2.22.1</version> + </dependency> + </dependencies> + </plugin> - <!-- - The configuration here tells the WAR plugin to include the FHIR Tester - overlay. You can omit it if you are not using that feature. - --> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-war-plugin</artifactId> - <configuration> - <overlays> - <overlay> - <groupId>ca.uhn.hapi.fhir</groupId> - <artifactId>hapi-fhir-testpage-overlay</artifactId> - </overlay> - </overlays> - </configuration> - </plugin> + <!-- The configuration here tells the WAR plugin to include the FHIR Tester + overlay. You can omit it if you are not using that feature. --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-war-plugin</artifactId> + <configuration> + <overlays> + <overlay> + <groupId>ca.uhn.hapi.fhir</groupId> + <artifactId>hapi-fhir-testpage-overlay</artifactId> + </overlay> + </overlays> + </configuration> + </plugin> </plugins> @@ -172,9 +169,15 @@ <dependencies> <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.13.2</version> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.13.2</version> + </dependency> + + <dependency> + <groupId>net.ihe.gazelle</groupId> + <artifactId>framework.preferences-model-api</artifactId> + <version>1.0.0</version> </dependency> <!-- This dependency includes the core HAPI-FHIR classes --> @@ -183,21 +186,21 @@ <artifactId>hapi-fhir-base</artifactId> <version>${hapifhir_version}</version> </dependency> - + <dependency> - <groupId>ca.uhn.hapi.fhir</groupId> - <artifactId>hapi-fhir-server</artifactId> - <version>${hapifhir_version}</version> - </dependency> + <groupId>ca.uhn.hapi.fhir</groupId> + <artifactId>hapi-fhir-server</artifactId> + <version>${hapifhir_version}</version> + </dependency> - <!-- At least one "structures" JAR must also be included --> - <dependency> - <groupId>ca.uhn.hapi.fhir</groupId> - <artifactId>hapi-fhir-structures-r4</artifactId> - <version>${hapifhir_version}</version> - </dependency> - - <!-- Used for validation --> + <!-- At least one "structures" JAR must also be included --> + <dependency> + <groupId>ca.uhn.hapi.fhir</groupId> + <artifactId>hapi-fhir-structures-r4</artifactId> + <version>${hapifhir_version}</version> + </dependency> + + <!-- Used for validation --> <dependency> <groupId>ca.uhn.hapi.fhir</groupId> <artifactId>hapi-fhir-validation-resources-r4</artifactId> @@ -215,22 +218,20 @@ <artifactId>hapi-fhir-testpage-overlay</artifactId> <version>${hapifhir_version}</version> <type>war</type> - <scope>provided</scope> + <scope>provided</scope> </dependency> <dependency> <groupId>ca.uhn.hapi.fhir</groupId> <artifactId>hapi-fhir-testpage-overlay</artifactId> <version>${hapifhir_version}</version> <classifier>classes</classifier> - <scope>provided</scope> + <scope>provided</scope> </dependency> - <!-- - HAPI-FHIR uses Logback for logging support. The logback library is included - automatically by Maven as a part of the hapi-fhir-base dependency, but you - also need to include a logging library. Logback is used here, but log4j - would also be fine. - --> + <!-- HAPI-FHIR uses Logback for logging support. The logback library is + included automatically by Maven as a part of the hapi-fhir-base dependency, + but you also need to include a logging library. Logback is used here, but + log4j would also be fine. --> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> @@ -245,28 +246,26 @@ <scope>provided</scope> </dependency> - <!-- - If you are using HAPI narrative generation, you will need to include Thymeleaf - as well. Otherwise the following can be omitted. - --> + <!-- If you are using HAPI narrative generation, you will need to include + Thymeleaf as well. Otherwise the following can be omitted. --> <dependency> <groupId>org.thymeleaf</groupId> <artifactId>thymeleaf</artifactId> <version>3.0.2.RELEASE</version> </dependency> - + <dependency> <groupId>org.fhir</groupId> <artifactId>ucum</artifactId> <version>1.0.3</version> </dependency> - + <dependency> <groupId>com.github.ben-manes.caffeine</groupId> <artifactId>caffeine</artifactId> <version>3.0.2</version> </dependency> - + <dependency> <groupId>net.ihe.gazelle</groupId> <artifactId>app.patient-registry-xref-search-client</artifactId> @@ -285,7 +284,7 @@ </exclusion> </exclusions> </dependency> - + </dependencies> </project> diff --git a/src/main/java/net/ihe/gazelle/adapter/preferences/Namespaces.java b/src/main/java/net/ihe/gazelle/adapter/preferences/Namespaces.java new file mode 100644 index 0000000000000000000000000000000000000000..c36d95b26df562b108b06dd5e86602df50afce9b --- /dev/null +++ b/src/main/java/net/ihe/gazelle/adapter/preferences/Namespaces.java @@ -0,0 +1,31 @@ +package net.ihe.gazelle.adapter.preferences; + +public enum Namespaces { + DEPLOYMENT("java:/app/gazelle/pdqm-connector/operational-preferences"); + + private String value; + + /** + * Default constructor for the class. Defines the value of the value in the JNDI context. This aims to be used by the Preferences Module. + * @param value value of the value in the JNDI context. + */ + Namespaces(String value){ + this.value = value; + } + + /** + * Getter for the value property. + * @return the value of the value property. + */ + public String getValue() { + return value; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return value; + } +} diff --git a/src/main/java/net/ihe/gazelle/adapter/preferences/Preferences.java b/src/main/java/net/ihe/gazelle/adapter/preferences/Preferences.java new file mode 100644 index 0000000000000000000000000000000000000000..3a9eaf11a562e5ef1dd99d48ed80dc35c3177aff --- /dev/null +++ b/src/main/java/net/ihe/gazelle/adapter/preferences/Preferences.java @@ -0,0 +1,44 @@ +package net.ihe.gazelle.adapter.preferences; + +public enum Preferences { + PATIENT_REGISTRY_URL(Namespaces.DEPLOYMENT,"patientregistry.url"); + + private Namespaces namespace; + private String key; + + /** + * Default constructor for the class. Defines the value of the Preference's key. It can then be used throughout the application to retrieve the + * preference value. + * @param namespace value of the namespace where the Preference is defined. + * @param key value of the Preference's key. + */ + Preferences(Namespaces namespace, String key){ + this.namespace = namespace; + this.key = key; + } + + /** + * Getter for the namespace property. + * @return the value of the namespace property. + */ + public Namespaces getNamespace() { + return namespace; + } + + /** + * Getter for the key property. + * @return the value of the key property. + */ + public String getKey() { + return key; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return key; + } + +} diff --git a/src/main/java/net/ihe/gazelle/application/PatientRegistryXRefSearchClient.java b/src/main/java/net/ihe/gazelle/application/PatientRegistryXRefSearchClient.java index 2b24f41777d39cff853c68b99deb16e2c5fc41dc..7926614cd8024b7f4ffeb9c2acac40d422a5ba3b 100644 --- a/src/main/java/net/ihe/gazelle/application/PatientRegistryXRefSearchClient.java +++ b/src/main/java/net/ihe/gazelle/application/PatientRegistryXRefSearchClient.java @@ -1,4 +1,58 @@ package net.ihe.gazelle.application; +import java.net.MalformedURLException; +import java.net.URL; + +import javax.inject.Inject; +import javax.xml.ws.WebServiceException; + +import org.slf4j.LoggerFactory; + +import com.gitb.ps.ProcessingService; + +import net.ihe.gazelle.adapter.preferences.Preferences; +import net.ihe.gazelle.app.patientregistryxrefsearchclient.adapter.XRefSearchClient; +import net.ihe.gazelle.framework.preferencesmodelapi.application.NamespaceException; +import net.ihe.gazelle.framework.preferencesmodelapi.application.OperationalPreferencesService; +import net.ihe.gazelle.framework.preferencesmodelapi.application.PreferenceException; +import net.ihe.gazelle.lib.annotations.Package; +import net.ihe.gazelle.lib.searchmodelapi.business.exception.SearchException; + public class PatientRegistryXRefSearchClient { + + private static final Logger clientLogger = LoggerFactory.getLogger(PatientRegistryXRefSearchClient.class); + private OperationPreferencesService operationalPreferencesService; + private XRefSearchClient client; + + @Inject + public PatientRegistryXRefSearchClient(OperationalPreferencesService operationalPreferencesService) { + this.operationalPreferencesService = operationalPreferencesService; + } + + @Package + PatientRegistryXRefSearchClient(URL url) { + this.client = new XRefSearchClient(url); + } + + @Package + PatientRegistryXRefSearchClient(ProcessingService service) { + this.client = new XRefSearchClient(service); + } + + private void initializeSearchClient() { + String patientRegistryUrl = null; + try { + patientRegistryUrl = this.operationalPreferencesService.getStringValue( + Preferences.PATIENT_REGISTRY_URL.getNamespace().getValue(), Preferences.PATIENT_REGISTRY_URL.getKey()); + this.client = new PatientRegistryXRefSearchClient(new URL(patientRegistryUrl)); + } catch (NamespaceException | PreferenceException e) { + throw new SearchException(String.format("Unable to retrieve [%s] Preference !", Preferences.PATIENT_REGISTRY_URL.getKey())); + } catch (MalformedURLException e) { + throw new SearchException(String.format("Preference [%s] with value [%s] is not a valid URL !", Preferences.PATIENT_REGISTRY_URL.getKey(), + patientRegistryUrl)); + } catch (WebServiceException e) { + throw new SearchException("Can't connect to patient registry !"); + } + } + } diff --git a/src/main/java/net/ihe/gazelle/application/PatientXRefSupplier.java b/src/main/java/net/ihe/gazelle/application/PatientXRefSupplier.java new file mode 100644 index 0000000000000000000000000000000000000000..0efa59930156f35d3551730e65b805b3e812f2b5 --- /dev/null +++ b/src/main/java/net/ihe/gazelle/application/PatientXRefSupplier.java @@ -0,0 +1,17 @@ +package net.ihe.gazelle.application; + +import javax.inject.Inject; + +public class PatientXRefSupplier { + + private static final Logger = LoggerFactory.getLogger(PatientXRefSupplier.class); + private PatientRegistryXRefSearchClient client; + + @Inject + public PatientXRefSupplier(PatientRegistryXRefSearchClient patientRegistryXRefSearchClient) { + this.client = patientRegistryXRefSearchClient; + } + + + +}