Revert "Changes for empi (as well as subscriptions and partitions)"
This commit is contained in:
@@ -158,10 +158,6 @@ The server may be configured with subscription support by enabling properties in
|
|||||||
|
|
||||||
- `subscription.websocket.enabled` - Enables websocket subscriptions. With this enabled, your server will accept incoming websocket connections on the following URL (this example uses the default context path and port, you may need to tweak depending on your deployment environment): [ws://localhost:8080/hapi-fhir-jpaserver/websocket](ws://localhost:8080/hapi-fhir-jpaserver/websocket)
|
- `subscription.websocket.enabled` - Enables websocket subscriptions. With this enabled, your server will accept incoming websocket connections on the following URL (this example uses the default context path and port, you may need to tweak depending on your deployment environment): [ws://localhost:8080/hapi-fhir-jpaserver/websocket](ws://localhost:8080/hapi-fhir-jpaserver/websocket)
|
||||||
|
|
||||||
## Enabling EMPI
|
|
||||||
|
|
||||||
Set `empi.enabled=true` in the [hapi.properties](https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/master/src/main/resources/hapi.properties) file to enable EMPI on this server. The EMPI matching rules are configured in [empi-rules.json](https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/master/src/main/resources/empi-rules.json). The rules in this example file should be replaced with actual matching rules appropriate to your data.
|
|
||||||
|
|
||||||
## Using Elasticsearch
|
## Using Elasticsearch
|
||||||
|
|
||||||
By default, the server will use embedded lucene indexes for terminology and fulltext indexing purposes. You can switch this to using lucene by editing the properties in [hapi.properties](https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/master/src/main/resources/hapi.properties)
|
By default, the server will use embedded lucene indexes for terminology and fulltext indexing purposes. You can switch this to using lucene by editing the properties in [hapi.properties](https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/master/src/main/resources/hapi.properties)
|
||||||
|
|||||||
18
pom.xml
18
pom.xml
@@ -11,7 +11,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>hapi-fhir</artifactId>
|
<artifactId>hapi-fhir</artifactId>
|
||||||
<version>5.1.0-SNAPSHOT</version>
|
<version>5.0.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>hapi-fhir-jpaserver-starter</artifactId>
|
<artifactId>hapi-fhir-jpaserver-starter</artifactId>
|
||||||
@@ -84,12 +84,7 @@
|
|||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- This dependency includes the JPA EMPI Server -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
|
||||||
<artifactId>hapi-fhir-jpaserver-empi</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- This dependency is used for the "FHIR Tester" web app overlay -->
|
<!-- This dependency is used for the "FHIR Tester" web app overlay -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
@@ -254,12 +249,7 @@
|
|||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.awaitility</groupId>
|
|
||||||
<artifactId>awaitility</artifactId>
|
|
||||||
<version>4.0.0-rc1</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
@@ -286,7 +276,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>jetty-maven-plugin</artifactId>
|
<artifactId>jetty-maven-plugin</artifactId>
|
||||||
<version>${jetty_version}</version>
|
<version>${jetty_version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<webApp>
|
<webApp>
|
||||||
<contextPath>/hapi-fhir-jpaserver</contextPath>
|
<contextPath>/hapi-fhir-jpaserver</contextPath>
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package ca.uhn.fhir.jpa.starter;
|
package ca.uhn.fhir.jpa.starter;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||||
import ca.uhn.fhir.jpa.empi.config.EmpiConsumerConfig;
|
|
||||||
import ca.uhn.fhir.jpa.empi.config.EmpiSubmitterConfig;
|
|
||||||
import ca.uhn.fhir.jpa.subscription.channel.config.SubscriptionChannelConfig;
|
import ca.uhn.fhir.jpa.subscription.channel.config.SubscriptionChannelConfig;
|
||||||
import ca.uhn.fhir.jpa.subscription.match.config.SubscriptionProcessorConfig;
|
import ca.uhn.fhir.jpa.subscription.match.config.SubscriptionProcessorConfig;
|
||||||
import ca.uhn.fhir.jpa.subscription.match.config.WebsocketDispatcherConfig;
|
import ca.uhn.fhir.jpa.subscription.match.config.WebsocketDispatcherConfig;
|
||||||
@@ -30,19 +28,13 @@ public class ApplicationContext extends AnnotationConfigWebApplicationContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (HapiProperties.getSubscriptionEmailEnabled()
|
if (HapiProperties.getSubscriptionEmailEnabled()
|
||||||
|| HapiProperties.getSubscriptionRestHookEnabled()
|
|| HapiProperties.getSubscriptionRestHookEnabled()
|
||||||
|| HapiProperties.getSubscriptionWebsocketEnabled()) {
|
|| HapiProperties.getSubscriptionWebsocketEnabled()) {
|
||||||
register(SubscriptionSubmitterConfig.class);
|
register(SubscriptionSubmitterConfig.class);
|
||||||
register(SubscriptionProcessorConfig.class);
|
register(SubscriptionProcessorConfig.class);
|
||||||
register(SubscriptionChannelConfig.class);
|
register(SubscriptionChannelConfig.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HapiProperties.getEmpiEnabled()) {
|
|
||||||
register(EmpiSubmitterConfig.class);
|
|
||||||
register(EmpiConsumerConfig.class);
|
|
||||||
register(EmpiConfig.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
package ca.uhn.fhir.jpa.starter;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.empi.api.IEmpiSettings;
|
|
||||||
import ca.uhn.fhir.empi.rules.config.EmpiSettings;
|
|
||||||
import com.google.common.base.Charsets;
|
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.core.io.DefaultResourceLoader;
|
|
||||||
import org.springframework.core.io.Resource;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
public class EmpiConfig {
|
|
||||||
@Bean
|
|
||||||
IEmpiSettings empiSettings() throws IOException {
|
|
||||||
DefaultResourceLoader resourceLoader = new DefaultResourceLoader();
|
|
||||||
Resource resource = resourceLoader.getResource("empi-rules.json");
|
|
||||||
String json = IOUtils.toString(resource.getInputStream(), Charsets.UTF_8);
|
|
||||||
return new EmpiSettings().setEnabled(HapiProperties.getEmpiEnabled()).setScriptText(json);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,6 +10,7 @@ import ca.uhn.fhir.jpa.subscription.match.deliver.email.IEmailSender;
|
|||||||
import ca.uhn.fhir.jpa.subscription.match.deliver.email.JavaMailEmailSender;
|
import ca.uhn.fhir.jpa.subscription.match.deliver.email.JavaMailEmailSender;
|
||||||
import org.apache.commons.dbcp2.BasicDataSource;
|
import org.apache.commons.dbcp2.BasicDataSource;
|
||||||
import org.hl7.fhir.dstu2.model.Subscription;
|
import org.hl7.fhir.dstu2.model.Subscription;
|
||||||
|
import org.springframework.beans.factory.BeanFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@@ -24,7 +25,7 @@ import java.sql.Driver;
|
|||||||
* This is the primary configuration file for the example server
|
* This is the primary configuration file for the example server
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableTransactionManagement
|
@EnableTransactionManagement()
|
||||||
public class FhirServerConfigCommon {
|
public class FhirServerConfigCommon {
|
||||||
|
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirServerConfigCommon.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirServerConfigCommon.class);
|
||||||
@@ -197,10 +198,11 @@ public class FhirServerConfigCommon {
|
|||||||
retVal.setSmtpServerPort(this.emailPort);
|
retVal.setSmtpServerPort(this.emailPort);
|
||||||
retVal.setSmtpServerUsername(this.emailUsername);
|
retVal.setSmtpServerUsername(this.emailUsername);
|
||||||
retVal.setSmtpServerPassword(this.emailPassword);
|
retVal.setSmtpServerPassword(this.emailPassword);
|
||||||
retVal.setAuth(this.emailAuth);
|
// TODO KHS add these when HAPI 4.2.0 is released
|
||||||
retVal.setStartTlsEnable(this.emailStartTlsEnable);
|
// retVal.setAuth(this.emailAuth);
|
||||||
retVal.setStartTlsRequired(this.emailStartTlsRequired);
|
// retVal.setStartTlsEnable(this.emailStartTlsEnable);
|
||||||
retVal.setQuitWait(this.emailQuitWait);
|
// retVal.setStartTlsRequired(this.emailStartTlsRequired);
|
||||||
|
// retVal.setQuitWait(this.emailQuitWait);
|
||||||
|
|
||||||
SubscriptionDeliveryHandlerFactory subscriptionDeliveryHandlerFactory = myAppCtx.getBean(SubscriptionDeliveryHandlerFactory.class);
|
SubscriptionDeliveryHandlerFactory subscriptionDeliveryHandlerFactory = myAppCtx.getBean(SubscriptionDeliveryHandlerFactory.class);
|
||||||
Validate.notNull(subscriptionDeliveryHandlerFactory, "No subscription delivery handler");
|
Validate.notNull(subscriptionDeliveryHandlerFactory, "No subscription delivery handler");
|
||||||
|
|||||||
@@ -57,11 +57,6 @@ public class HapiProperties {
|
|||||||
static final String SUBSCRIPTION_EMAIL_ENABLED = "subscription.email.enabled";
|
static final String SUBSCRIPTION_EMAIL_ENABLED = "subscription.email.enabled";
|
||||||
static final String SUBSCRIPTION_RESTHOOK_ENABLED = "subscription.resthook.enabled";
|
static final String SUBSCRIPTION_RESTHOOK_ENABLED = "subscription.resthook.enabled";
|
||||||
static final String SUBSCRIPTION_WEBSOCKET_ENABLED = "subscription.websocket.enabled";
|
static final String SUBSCRIPTION_WEBSOCKET_ENABLED = "subscription.websocket.enabled";
|
||||||
static final String EMPI_ENABLED = "empi.enabled";
|
|
||||||
static final String PARTITIONING_ENABLED = "partitioning.enabled";
|
|
||||||
static final String PARTITIONING_CROSS_PARTITION_REFERENCE_MODE = "partitioning.cross_partition_reference_mode";
|
|
||||||
private static final String PARTITIONING_INCLUDE_PARTITION_IN_SEARCH_HASHES = "partitioning.partitioning_include_in_search_hashes";
|
|
||||||
|
|
||||||
static final String ALLOWED_BUNDLE_TYPES = "allowed_bundle_types";
|
static final String ALLOWED_BUNDLE_TYPES = "allowed_bundle_types";
|
||||||
static final String TEST_PORT = "test.port";
|
static final String TEST_PORT = "test.port";
|
||||||
static final String TESTER_CONFIG_REFUSE_TO_FETCH_THIRD_PARTY_URLS = "tester.config.refuse_to_fetch_third_party_urls";
|
static final String TESTER_CONFIG_REFUSE_TO_FETCH_THIRD_PARTY_URLS = "tester.config.refuse_to_fetch_third_party_urls";
|
||||||
@@ -378,22 +373,6 @@ public class HapiProperties {
|
|||||||
return HapiProperties.getBooleanProperty(SUBSCRIPTION_WEBSOCKET_ENABLED, false);
|
return HapiProperties.getBooleanProperty(SUBSCRIPTION_WEBSOCKET_ENABLED, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Boolean getEmpiEnabled() {
|
|
||||||
return HapiProperties.getBooleanProperty(EMPI_ENABLED, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Boolean getPartitioningEnabled() {
|
|
||||||
return HapiProperties.getBooleanProperty(PARTITIONING_ENABLED, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getPartitioningCrossPartitionReferenceMode() {
|
|
||||||
return HapiProperties.getProperty(PARTITIONING_CROSS_PARTITION_REFERENCE_MODE, "NOT_ALLOWED");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Boolean getIncludePartitionInSearchHashes() {
|
|
||||||
return HapiProperties.getBooleanProperty(PARTITIONING_INCLUDE_PARTITION_IN_SEARCH_HASHES, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Boolean getAllowContainsSearches() {
|
public static Boolean getAllowContainsSearches() {
|
||||||
return HapiProperties.getBooleanProperty(ALLOW_CONTAINS_SEARCHES, true);
|
return HapiProperties.getBooleanProperty(ALLOW_CONTAINS_SEARCHES, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,11 +7,10 @@ import ca.uhn.fhir.interceptor.api.IInterceptorService;
|
|||||||
import ca.uhn.fhir.jpa.api.config.DaoConfig;
|
import ca.uhn.fhir.jpa.api.config.DaoConfig;
|
||||||
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
|
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
|
||||||
import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao;
|
import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao;
|
||||||
|
import ca.uhn.fhir.jpa.api.rp.ResourceProviderFactory;
|
||||||
import ca.uhn.fhir.jpa.binstore.BinaryStorageInterceptor;
|
import ca.uhn.fhir.jpa.binstore.BinaryStorageInterceptor;
|
||||||
import ca.uhn.fhir.jpa.bulk.BulkDataExportProvider;
|
import ca.uhn.fhir.jpa.bulk.BulkDataExportProvider;
|
||||||
import ca.uhn.fhir.jpa.interceptor.CascadingDeleteInterceptor;
|
import ca.uhn.fhir.jpa.interceptor.CascadingDeleteInterceptor;
|
||||||
import ca.uhn.fhir.jpa.model.config.PartitionSettings;
|
|
||||||
import ca.uhn.fhir.jpa.partition.PartitionManagementProvider;
|
|
||||||
import ca.uhn.fhir.jpa.provider.GraphQLProvider;
|
import ca.uhn.fhir.jpa.provider.GraphQLProvider;
|
||||||
import ca.uhn.fhir.jpa.provider.JpaConformanceProviderDstu2;
|
import ca.uhn.fhir.jpa.provider.JpaConformanceProviderDstu2;
|
||||||
import ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2;
|
import ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2;
|
||||||
@@ -36,7 +35,6 @@ import ca.uhn.fhir.rest.server.interceptor.LoggingInterceptor;
|
|||||||
import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor;
|
import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor;
|
||||||
import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor;
|
import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor;
|
||||||
import ca.uhn.fhir.rest.server.interceptor.ResponseValidatingInterceptor;
|
import ca.uhn.fhir.rest.server.interceptor.ResponseValidatingInterceptor;
|
||||||
import ca.uhn.fhir.rest.server.provider.ResourceProviderFactory;
|
|
||||||
import ca.uhn.fhir.validation.IValidatorModule;
|
import ca.uhn.fhir.validation.IValidatorModule;
|
||||||
import ca.uhn.fhir.validation.ResultSeverityEnum;
|
import ca.uhn.fhir.validation.ResultSeverityEnum;
|
||||||
import org.hl7.fhir.dstu3.model.Bundle;
|
import org.hl7.fhir.dstu3.model.Bundle;
|
||||||
@@ -320,13 +318,6 @@ public class JpaRestfulServer extends RestfulServer {
|
|||||||
registerProvider(appCtx.getBean(BulkDataExportProvider.class));
|
registerProvider(appCtx.getBean(BulkDataExportProvider.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HapiProperties.getPartitioningEnabled()) {
|
|
||||||
PartitionSettings partitionSettings = appCtx.getBean(PartitionSettings.class);
|
|
||||||
partitionSettings.setPartitioningEnabled(true);
|
|
||||||
PartitionSettings.CrossPartitionReferenceMode mode = PartitionSettings.CrossPartitionReferenceMode.valueOf(HapiProperties.getPartitioningCrossPartitionReferenceMode());
|
|
||||||
partitionSettings.setAllowReferencesAcrossPartitions(mode);
|
|
||||||
partitionSettings.setIncludePartitionInSearchHashes(HapiProperties.getIncludePartitionInSearchHashes());
|
|
||||||
registerProvider(appCtx.getBean(PartitionManagementProvider.class));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
{
|
|
||||||
"candidateSearchParams" : [ {
|
|
||||||
"resourceType" : "Patient",
|
|
||||||
"searchParam" : "birthdate"
|
|
||||||
}, {
|
|
||||||
"resourceType" : "*",
|
|
||||||
"searchParam" : "identifier"
|
|
||||||
},{
|
|
||||||
"resourceType" : "Patient",
|
|
||||||
"searchParam" : "general-practitioner"
|
|
||||||
} ],
|
|
||||||
"candidateFilterSearchParams" : [ {
|
|
||||||
"resourceType" : "*",
|
|
||||||
"searchParam" : "active",
|
|
||||||
"fixedValue" : "true"
|
|
||||||
} ],
|
|
||||||
"matchFields" : [ {
|
|
||||||
"name" : "given-name",
|
|
||||||
"resourceType" : "*",
|
|
||||||
"resourcePath" : "name.given",
|
|
||||||
"metric" : "COSINE",
|
|
||||||
"matchThreshold" : 0.8
|
|
||||||
}, {
|
|
||||||
"name" : "last-name",
|
|
||||||
"resourceType" : "*",
|
|
||||||
"resourcePath" : "name.family",
|
|
||||||
"metric" : "JARO_WINKLER",
|
|
||||||
"matchThreshold" : 0.8
|
|
||||||
}],
|
|
||||||
"matchResultMap" : {
|
|
||||||
"given-name" : "POSSIBLE_MATCH",
|
|
||||||
"given-name,last-name" : "MATCH"
|
|
||||||
},
|
|
||||||
"eidSystem": "http://company.io/fhir/NamingSystem/custom-eid-system"
|
|
||||||
}
|
|
||||||
@@ -149,11 +149,3 @@ email.password=
|
|||||||
|
|
||||||
# Enable Websocket Subscription Channel
|
# Enable Websocket Subscription Channel
|
||||||
subscription.websocket.enabled=false
|
subscription.websocket.enabled=false
|
||||||
|
|
||||||
# EMPI
|
|
||||||
empi.enabled=false
|
|
||||||
|
|
||||||
# Partitioning
|
|
||||||
partitioning.enabled=false
|
|
||||||
partitioning.cross_partition_reference_mode=NOT_ALLOWED
|
|
||||||
partitioning.partitioning_include_in_search_hashes=true
|
|
||||||
|
|||||||
@@ -9,25 +9,6 @@
|
|||||||
</encoder>
|
</encoder>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
<appender name="EMPI_TROUBLESHOOTING" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"><level>DEBUG</level></filter>
|
|
||||||
<file>${smile.basedir}/log/empi-troubleshooting.log</file>
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
|
|
||||||
<fileNamePattern>${smile.basedir}/log/empi-troubleshooting.log.%i.gz</fileNamePattern>
|
|
||||||
<minIndex>1</minIndex>
|
|
||||||
<maxIndex>9</maxIndex>
|
|
||||||
</rollingPolicy>
|
|
||||||
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
|
|
||||||
<maxFileSize>5MB</maxFileSize>
|
|
||||||
</triggeringPolicy>
|
|
||||||
<encoder>
|
|
||||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n${log.stackfilter.pattern}</pattern>
|
|
||||||
</encoder>
|
|
||||||
</appender>
|
|
||||||
<logger name="ca.uhn.fhir.log.empi_troubleshooting" level="TRACE">
|
|
||||||
<appender-ref ref="EMPI_TROUBLESHOOTING"/>
|
|
||||||
</logger>
|
|
||||||
|
|
||||||
<root level="INFO">
|
<root level="INFO">
|
||||||
<appender-ref ref="STDOUT" />
|
<appender-ref ref="STDOUT" />
|
||||||
</root>
|
</root>
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import ca.uhn.fhir.rest.client.api.IGenericClient;
|
|||||||
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
|
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
|
||||||
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
|
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
|
||||||
import ca.uhn.fhir.test.utilities.JettyUtil;
|
import ca.uhn.fhir.test.utilities.JettyUtil;
|
||||||
import ca.uhn.fhir.util.BundleUtil;
|
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
import org.eclipse.jetty.webapp.WebAppContext;
|
import org.eclipse.jetty.webapp.WebAppContext;
|
||||||
import org.eclipse.jetty.websocket.api.Session;
|
import org.eclipse.jetty.websocket.api.Session;
|
||||||
@@ -18,8 +17,6 @@ import org.hl7.fhir.instance.model.api.IIdType;
|
|||||||
import org.hl7.fhir.r4.model.Bundle;
|
import org.hl7.fhir.r4.model.Bundle;
|
||||||
import org.hl7.fhir.r4.model.Observation;
|
import org.hl7.fhir.r4.model.Observation;
|
||||||
import org.hl7.fhir.r4.model.Patient;
|
import org.hl7.fhir.r4.model.Patient;
|
||||||
import org.hl7.fhir.r4.model.Person;
|
|
||||||
import org.hl7.fhir.r4.model.Reference;
|
|
||||||
import org.hl7.fhir.r4.model.Subscription;
|
import org.hl7.fhir.r4.model.Subscription;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
@@ -27,16 +24,11 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import static ca.uhn.fhir.util.TestUtil.waitForSize;
|
import static ca.uhn.fhir.util.TestUtil.waitForSize;
|
||||||
import static org.awaitility.Awaitility.await;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
public class ExampleServerR4IT {
|
public class ExampleServerR4IT {
|
||||||
|
|
||||||
@@ -51,7 +43,6 @@ public class ExampleServerR4IT {
|
|||||||
HapiProperties.setProperty(HapiProperties.DATASOURCE_URL, "jdbc:h2:mem:dbr4");
|
HapiProperties.setProperty(HapiProperties.DATASOURCE_URL, "jdbc:h2:mem:dbr4");
|
||||||
HapiProperties.setProperty(HapiProperties.FHIR_VERSION, "R4");
|
HapiProperties.setProperty(HapiProperties.FHIR_VERSION, "R4");
|
||||||
HapiProperties.setProperty(HapiProperties.SUBSCRIPTION_WEBSOCKET_ENABLED, "true");
|
HapiProperties.setProperty(HapiProperties.SUBSCRIPTION_WEBSOCKET_ENABLED, "true");
|
||||||
HapiProperties.setProperty(HapiProperties.EMPI_ENABLED, "true");
|
|
||||||
ourCtx = FhirContext.forR4();
|
ourCtx = FhirContext.forR4();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,30 +57,9 @@ public class ExampleServerR4IT {
|
|||||||
|
|
||||||
Patient pt2 = ourClient.read().resource(Patient.class).withId(id).execute();
|
Patient pt2 = ourClient.read().resource(Patient.class).withId(id).execute();
|
||||||
assertEquals(methodName, pt2.getName().get(0).getFamily());
|
assertEquals(methodName, pt2.getName().get(0).getFamily());
|
||||||
|
|
||||||
// Test EMPI
|
|
||||||
|
|
||||||
// Wait until the EMPI message has been processed
|
|
||||||
await().until(() -> getPeople().size() > 0);
|
|
||||||
List<Person> persons = getPeople();
|
|
||||||
|
|
||||||
// Verify a Person was created that links to our Patient
|
|
||||||
Optional<String> personLinkToCreatedPatient = persons.stream()
|
|
||||||
.map(Person::getLink)
|
|
||||||
.flatMap(Collection::stream)
|
|
||||||
.map(Person.PersonLinkComponent::getTarget)
|
|
||||||
.map(Reference::getReference)
|
|
||||||
.filter(pid -> id.toUnqualifiedVersionless().getValue().equals(pid))
|
|
||||||
.findAny();
|
|
||||||
assertTrue(personLinkToCreatedPatient.isPresent());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Person> getPeople() {
|
@Test
|
||||||
Bundle bundle = ourClient.search().forResource(Person.class).cacheControl(new CacheControlDirective().setNoCache(true)).returnBundle(Bundle.class).execute();
|
|
||||||
return BundleUtil.toListOfResourcesOfType(ourCtx, bundle, Person.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testWebsocketSubscription() throws Exception {
|
public void testWebsocketSubscription() throws Exception {
|
||||||
/*
|
/*
|
||||||
* Create subscription
|
* Create subscription
|
||||||
@@ -108,7 +78,7 @@ public class ExampleServerR4IT {
|
|||||||
IIdType mySubscriptionId = methodOutcome.getId();
|
IIdType mySubscriptionId = methodOutcome.getId();
|
||||||
|
|
||||||
// Wait for the subscription to be activated
|
// Wait for the subscription to be activated
|
||||||
await().until(() -> activeSubscriptionCount() == 3);
|
waitForSize(1, () -> ourClient.search().forResource(Subscription.class).where(Subscription.STATUS.exactly().code("active")).cacheControl(new CacheControlDirective().setNoCache(true)).returnBundle(Bundle.class).execute().getEntry().size());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Attach websocket
|
* Attach websocket
|
||||||
@@ -147,11 +117,7 @@ public class ExampleServerR4IT {
|
|||||||
ourClient.delete().resourceById(mySubscriptionId).execute();
|
ourClient.delete().resourceById(mySubscriptionId).execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int activeSubscriptionCount() {
|
@AfterClass
|
||||||
return ourClient.search().forResource(Subscription.class).where(Subscription.STATUS.exactly().code("active")).cacheControl(new CacheControlDirective().setNoCache(true)).returnBundle(Bundle.class).execute().getEntry().size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterClass
|
|
||||||
public static void afterClass() throws Exception {
|
public static void afterClass() throws Exception {
|
||||||
ourServer.stop();
|
ourServer.stop();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,132 +34,132 @@ import static org.junit.Assert.assertEquals;
|
|||||||
|
|
||||||
public class ExampleServerR5IT {
|
public class ExampleServerR5IT {
|
||||||
|
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExampleServerR5IT.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExampleServerR5IT.class);
|
||||||
private static IGenericClient ourClient;
|
private static IGenericClient ourClient;
|
||||||
private static FhirContext ourCtx;
|
private static FhirContext ourCtx;
|
||||||
private static int ourPort;
|
private static int ourPort;
|
||||||
private static Server ourServer;
|
private static Server ourServer;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
HapiProperties.forceReload();
|
HapiProperties.forceReload();
|
||||||
HapiProperties.setProperty(HapiProperties.DATASOURCE_URL, "jdbc:h2:mem:dbr5");
|
HapiProperties.setProperty(HapiProperties.DATASOURCE_URL, "jdbc:h2:mem:dbr5");
|
||||||
HapiProperties.setProperty(HapiProperties.FHIR_VERSION, "R5");
|
HapiProperties.setProperty(HapiProperties.FHIR_VERSION, "R5");
|
||||||
HapiProperties.setProperty(HapiProperties.SUBSCRIPTION_WEBSOCKET_ENABLED, "true");
|
HapiProperties.setProperty(HapiProperties.SUBSCRIPTION_WEBSOCKET_ENABLED, "true");
|
||||||
ourCtx = FhirContext.forR5();
|
ourCtx = FhirContext.forR5();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateAndRead() {
|
public void testCreateAndRead() {
|
||||||
ourLog.info("Base URL is: " + HapiProperties.getServerAddress());
|
ourLog.info("Base URL is: " + HapiProperties.getServerAddress());
|
||||||
String methodName = "testCreateResourceConditional";
|
String methodName = "testCreateResourceConditional";
|
||||||
|
|
||||||
Patient pt = new Patient();
|
Patient pt = new Patient();
|
||||||
pt.addName().setFamily(methodName);
|
pt.addName().setFamily(methodName);
|
||||||
IIdType id = ourClient.create().resource(pt).execute().getId();
|
IIdType id = ourClient.create().resource(pt).execute().getId();
|
||||||
|
|
||||||
Patient pt2 = ourClient.read().resource(Patient.class).withId(id).execute();
|
Patient pt2 = ourClient.read().resource(Patient.class).withId(id).execute();
|
||||||
assertEquals(methodName, pt2.getName().get(0).getFamily());
|
assertEquals(methodName, pt2.getName().get(0).getFamily());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWebsocketSubscription() throws Exception {
|
public void testWebsocketSubscription() throws Exception {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create topic
|
* Create topic
|
||||||
*/
|
*/
|
||||||
SubscriptionTopic topic = new SubscriptionTopic();
|
SubscriptionTopic topic = new SubscriptionTopic();
|
||||||
topic.getResourceTrigger().getQueryCriteria().setCurrent("Observation?status=final");
|
topic.getResourceTrigger().getQueryCriteria().setCurrent("Observation?status=final");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create subscription
|
* Create subscription
|
||||||
*/
|
*/
|
||||||
Subscription subscription = new Subscription();
|
Subscription subscription = new Subscription();
|
||||||
subscription.getTopic().setResource(topic);
|
subscription.getTopic().setResource(topic);
|
||||||
subscription.setReason("Monitor new neonatal function (note, age will be determined by the monitor)");
|
subscription.setReason("Monitor new neonatal function (note, age will be determined by the monitor)");
|
||||||
subscription.setStatus(Enumerations.SubscriptionState.REQUESTED);
|
subscription.setStatus(Enumerations.SubscriptionState.REQUESTED);
|
||||||
subscription.getChannelType()
|
subscription.getChannelType()
|
||||||
.setSystem("http://terminology.hl7.org/CodeSystem/subscription-channel-type")
|
.setSystem("http://terminology.hl7.org/CodeSystem/subscription-channel-type")
|
||||||
.setCode("websocket");
|
.setCode("websocket");
|
||||||
subscription.setContentType("application/json");
|
subscription.setContentType("application/json");
|
||||||
|
|
||||||
MethodOutcome methodOutcome = ourClient.create().resource(subscription).execute();
|
MethodOutcome methodOutcome = ourClient.create().resource(subscription).execute();
|
||||||
IIdType mySubscriptionId = methodOutcome.getId();
|
IIdType mySubscriptionId = methodOutcome.getId();
|
||||||
|
|
||||||
// Wait for the subscription to be activated
|
// Wait for the subscription to be activated
|
||||||
waitForSize(1, () -> ourClient.search().forResource(Subscription.class).where(Subscription.STATUS.exactly().code("active")).cacheControl(new CacheControlDirective().setNoCache(true)).returnBundle(Bundle.class).execute().getEntry().size());
|
waitForSize(1, () -> ourClient.search().forResource(Subscription.class).where(Subscription.STATUS.exactly().code("active")).cacheControl(new CacheControlDirective().setNoCache(true)).returnBundle(Bundle.class).execute().getEntry().size());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Attach websocket
|
* Attach websocket
|
||||||
*/
|
*/
|
||||||
|
|
||||||
WebSocketClient myWebSocketClient = new WebSocketClient();
|
WebSocketClient myWebSocketClient = new WebSocketClient();
|
||||||
SocketImplementation mySocketImplementation = new SocketImplementation(mySubscriptionId.getIdPart(), EncodingEnum.JSON);
|
SocketImplementation mySocketImplementation = new SocketImplementation(mySubscriptionId.getIdPart(), EncodingEnum.JSON);
|
||||||
|
|
||||||
myWebSocketClient.start();
|
myWebSocketClient.start();
|
||||||
URI echoUri = new URI("ws://localhost:" + ourPort + "/hapi-fhir-jpaserver/websocket");
|
URI echoUri = new URI("ws://localhost:" + ourPort + "/hapi-fhir-jpaserver/websocket");
|
||||||
ClientUpgradeRequest request = new ClientUpgradeRequest();
|
ClientUpgradeRequest request = new ClientUpgradeRequest();
|
||||||
ourLog.info("Connecting to : {}", echoUri);
|
ourLog.info("Connecting to : {}", echoUri);
|
||||||
Future<Session> connection = myWebSocketClient.connect(mySocketImplementation, echoUri, request);
|
Future<Session> connection = myWebSocketClient.connect(mySocketImplementation, echoUri, request);
|
||||||
Session session = connection.get(2, TimeUnit.SECONDS);
|
Session session = connection.get(2, TimeUnit.SECONDS);
|
||||||
|
|
||||||
ourLog.info("Connected to WS: {}", session.isOpen());
|
ourLog.info("Connected to WS: {}", session.isOpen());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a matching resource
|
* Create a matching resource
|
||||||
*/
|
*/
|
||||||
Observation obs = new Observation();
|
Observation obs = new Observation();
|
||||||
obs.setStatus(Enumerations.ObservationStatus.FINAL);
|
obs.setStatus(Enumerations.ObservationStatus.FINAL);
|
||||||
ourClient.create().resource(obs).execute();
|
ourClient.create().resource(obs).execute();
|
||||||
|
|
||||||
// Give some time for the subscription to deliver
|
// Give some time for the subscription to deliver
|
||||||
Thread.sleep(2000);
|
Thread.sleep(2000);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ensure that we receive a ping on the websocket
|
* Ensure that we receive a ping on the websocket
|
||||||
*/
|
*/
|
||||||
waitForSize(1, () -> mySocketImplementation.myPingCount);
|
waitForSize(1, () -> mySocketImplementation.myPingCount);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Clean up
|
* Clean up
|
||||||
*/
|
*/
|
||||||
ourClient.delete().resourceById(mySubscriptionId).execute();
|
ourClient.delete().resourceById(mySubscriptionId).execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void afterClass() throws Exception {
|
public static void afterClass() throws Exception {
|
||||||
ourServer.stop();
|
ourServer.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void beforeClass() throws Exception {
|
public static void beforeClass() throws Exception {
|
||||||
String path = Paths.get("").toAbsolutePath().toString();
|
String path = Paths.get("").toAbsolutePath().toString();
|
||||||
|
|
||||||
ourLog.info("Project base path is: {}", path);
|
ourLog.info("Project base path is: {}", path);
|
||||||
|
|
||||||
ourServer = new Server(0);
|
ourServer = new Server(0);
|
||||||
|
|
||||||
WebAppContext webAppContext = new WebAppContext();
|
WebAppContext webAppContext = new WebAppContext();
|
||||||
webAppContext.setContextPath("/hapi-fhir-jpaserver");
|
webAppContext.setContextPath("/hapi-fhir-jpaserver");
|
||||||
webAppContext.setDisplayName("HAPI FHIR");
|
webAppContext.setDisplayName("HAPI FHIR");
|
||||||
webAppContext.setDescriptor(path + "/src/main/webapp/WEB-INF/web.xml");
|
webAppContext.setDescriptor(path + "/src/main/webapp/WEB-INF/web.xml");
|
||||||
webAppContext.setResourceBase(path + "/target/hapi-fhir-jpaserver-starter");
|
webAppContext.setResourceBase(path + "/target/hapi-fhir-jpaserver-starter");
|
||||||
webAppContext.setParentLoaderPriority(true);
|
webAppContext.setParentLoaderPriority(true);
|
||||||
|
|
||||||
ourServer.setHandler(webAppContext);
|
ourServer.setHandler(webAppContext);
|
||||||
ourServer.start();
|
ourServer.start();
|
||||||
|
|
||||||
ourPort = JettyUtil.getPortForStartedServer(ourServer);
|
ourPort = JettyUtil.getPortForStartedServer(ourServer);
|
||||||
|
|
||||||
ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
|
ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
|
||||||
ourCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000);
|
ourCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000);
|
||||||
String ourServerBase = "http://localhost:" + ourPort + "/hapi-fhir-jpaserver/fhir/";
|
String ourServerBase = "http://localhost:" + ourPort + "/hapi-fhir-jpaserver/fhir/";
|
||||||
|
|
||||||
ourClient = ourCtx.newRestfulGenericClient(ourServerBase);
|
ourClient = ourCtx.newRestfulGenericClient(ourServerBase);
|
||||||
ourClient.registerInterceptor(new LoggingInterceptor(true));
|
ourClient.registerInterceptor(new LoggingInterceptor(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] theArgs) throws Exception {
|
public static void main(String[] theArgs) throws Exception {
|
||||||
ourPort = 8080;
|
ourPort = 8080;
|
||||||
beforeClass();
|
beforeClass();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user