From 9de4f1b248b5f4f25f6fa07c10b83505bdf5bedc Mon Sep 17 00:00:00 2001 From: James Agnew Date: Mon, 14 Sep 2020 05:43:38 -0400 Subject: [PATCH 01/21] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 25464fd..838bef0 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ This project is a complete starter project you can use to deploy a FHIR server u Note that this project is specifically intended for end users of the HAPI FHIR JPA server module (in other words, it helps you implement HAPI FHIR, it is not the source of the library itself). If you are looking for the main HAPI FHIR project, see here: https://github.com/jamesagnew/hapi-fhir +Need Help? Please see: https://github.com/jamesagnew/hapi-fhir/wiki/Getting-Help + ## Prerequisites In order to use this sample, you should have: From 2979aca07d7a786b8f902d42fc4763720d38288c Mon Sep 17 00:00:00 2001 From: jamesagnew Date: Thu, 17 Sep 2020 05:46:42 -0400 Subject: [PATCH 02/21] Enable terminology uploader by default --- .../fhir/jpa/starter/BaseJpaRestfulServer.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/BaseJpaRestfulServer.java b/src/main/java/ca/uhn/fhir/jpa/starter/BaseJpaRestfulServer.java index 814395f..2f7c044 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/BaseJpaRestfulServer.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/BaseJpaRestfulServer.java @@ -16,6 +16,8 @@ import ca.uhn.fhir.jpa.partition.PartitionManagementProvider; import ca.uhn.fhir.jpa.provider.GraphQLProvider; import ca.uhn.fhir.jpa.provider.IJpaSystemProvider; import ca.uhn.fhir.jpa.provider.JpaConformanceProviderDstu2; +import ca.uhn.fhir.jpa.provider.SubscriptionTriggeringProvider; +import ca.uhn.fhir.jpa.provider.TerminologyUploaderProvider; import ca.uhn.fhir.jpa.provider.dstu3.JpaConformanceProviderDstu3; import ca.uhn.fhir.jpa.provider.r4.JpaConformanceProviderR4; import ca.uhn.fhir.jpa.provider.r5.JpaConformanceProviderR5; @@ -35,6 +37,7 @@ import ca.uhn.fhir.validation.ResultSeverityEnum; import com.google.common.base.Strings; import org.hl7.fhir.r4.model.Bundle.BundleType; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; import org.springframework.http.HttpHeaders; import org.springframework.web.cors.CorsConfiguration; @@ -95,6 +98,9 @@ public class BaseJpaRestfulServer extends RestfulServer { @Autowired AppProperties appProperties; + @Autowired + ApplicationContext myApplicationContext; + public BaseJpaRestfulServer() { } @@ -236,16 +242,14 @@ public class BaseJpaRestfulServer extends RestfulServer { * so it is a potential security vulnerability. Consider using an AuthorizationInterceptor * with this feature. */ - if (false) { // <-- DISABLED RIGHT NOW - //registerProvider(appCtx.getBean(TerminologyUploaderProvider.class)); + if (ctx.getVersion().getVersion().isEqualOrNewerThan(FhirVersionEnum.DSTU3)) { // <-- ENABLED RIGHT NOW + registerProvider(myApplicationContext.getBean(TerminologyUploaderProvider.class)); } // If you want to enable the $trigger-subscription operation to allow // manual triggering of a subscription delivery, enable this provider - if (false) { // <-- DISABLED RIGHT NOW - /* SubscriptionTriggeringProvider retriggeringProvider = appCtx - .getBean(SubscriptionTriggeringProvider.class); - registerProvider(retriggeringProvider);*/ + if (true) { // <-- ENABLED RIGHT NOW + registerProvider(myApplicationContext.getBean(SubscriptionTriggeringProvider.class)); } // Define your CORS configuration. This is an example From c7d5716ffbf3d6d41fca28c11b641a22c8e015cd Mon Sep 17 00:00:00 2001 From: jvi Date: Fri, 18 Sep 2020 18:29:12 +0200 Subject: [PATCH 03/21] Removing dialect as it is calculated by hibernate --- src/main/java/ca/uhn/fhir/jpa/starter/EnvironmentHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/EnvironmentHelper.java b/src/main/java/ca/uhn/fhir/jpa/starter/EnvironmentHelper.java index 036f2be..4dbc122 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/EnvironmentHelper.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/EnvironmentHelper.java @@ -14,8 +14,8 @@ public class EnvironmentHelper { public static Properties getHibernateProperties(ConfigurableEnvironment environment) { Properties properties = new Properties(); + if (environment.getProperty("spring.jpa.properties", String.class) == null) { - properties.put("hibernate.dialect", "org.hibernate.dialect.H2Dialect"); properties.put("hibernate.search.model_mapping", "ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory"); properties.put("hibernate.format_sql", "false"); properties.put("hibernate.show_sql", "false"); From 58efcffd8140ee30b05e4d27a7cf5ceab0c69d75 Mon Sep 17 00:00:00 2001 From: jvi Date: Fri, 18 Sep 2020 22:56:48 +0200 Subject: [PATCH 04/21] Updated documentation Removed unnecessary scanning Corrected context paths --- README.md | 178 ++++++++++++------ .../ca/uhn/fhir/jpa/starter/Application.java | 8 +- .../jpa/starter/ExampleServerDstu2IT.java | 2 +- .../jpa/starter/ExampleServerDstu3IT.java | 4 +- .../fhir/jpa/starter/ExampleServerR4IT.java | 4 +- .../fhir/jpa/starter/ExampleServerR5IT.java | 4 +- .../jpa/starter/MultitenantServerR4IT.java | 2 +- 7 files changed, 134 insertions(+), 68 deletions(-) diff --git a/README.md b/README.md index 838bef0..ffe6612 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,13 @@ Need Help? Please see: https://github.com/jamesagnew/hapi-fhir/wiki/Getting-Help In order to use this sample, you should have: - [This project](https://github.com/hapifhir/hapi-fhir-jpaserver-starter) checked out. You may wish to create a GitHub Fork of the project and check that out instead so that you can customize the project and save the results to GitHub. -- Oracle Java (JDK) installed: Minimum JDK8 or newer. -- Apache Maven build tool (newest version) + +### and either + - Oracle Java (JDK) installed: Minimum JDK8 or newer. + - Apache Maven build tool (newest version) + +### or + - Docker, as the entire project can be built using multistage docker (with both JDK and maven wrapped in docker) orr used directly from [Docker Hub](https://hub.docker.com/repository/docker/hapiproject/hapi) ## Running via [Docker Hub](https://hub.docker.com/repository/docker/hapiproject/hapi) @@ -20,26 +25,26 @@ Each tagged/released version of `hapi-fhir-jpaserver` is built as a Docker image ``` docker pull hapiproject/hapi:latest -docker run -p 8080:8080 hapiproject/hapi:tagname +docker run -p 8080:8080 -e "spring.batch.job.enabled=false" hapiproject/hapi:tagname ``` -This will run the docker image with the default configuration, mapping port 8080 from the container to port 8080 in the host. Once running, you can access `http://localhost:8080/hapi-fhir-jpaserver/fhir` in the browser to access the HAPI FHIR server's UI. +This will run the docker image with the default configuration, mapping port 8080 from the container to port 8080 in the host. Once running, you can access `http://localhost:8080/hapi-fhir-jpaserver/` in the browser to access the HAPI FHIR server's UI. -If you change the mapped port, you need to change the configuration used by HAPI to have the correct `server_address` property/value. +If you change the mapped port, you need to change the configuration used by HAPI to have the correct `hapi.fhir.tester` property/value. ### Configuration via environment variables You can customize HAPI directly from the `run` command using environment variables. For example: -`docker run -p 8090:8080 -e server_address=http://localhost:8090/hapi-fhir-jpaserver/fhir hapiproject/hapi:tagname` +`docker run -p 8080:8080 -e hapi.fhir.default_encoding=xml hapiproject/hapi:tagname` -HAPI looks in the environment variables for properties in the [hapi.properties](https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/master/src/main/resources/hapi.properties) file. +HAPI looks in the environment variables for properties in the [application.yaml](https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/master/src/main/resources/application.yaml) file for defaults. -### Configuration via overridden hapi.properties file +### Configuration via overridden application.yaml file -You can customize HAPI by telling HAPI to look for the `hapi.properties` file in a different location: +You can customize HAPI by telling HAPI to look for the configuration file in a different location, eg.: -`docker run -p 8090:8080 -e hapi.properties=/some/directory/with/hapi.properties hapiproject/hapi:tagname` +`docker run -p 8090:8080 -e "--spring.config.location=classpath:/another.application.yaml" hapiproject/hapi:tagname` ### Example docker-compose.yml @@ -52,11 +57,11 @@ services: - "8090:8080" configs: - source: hapi - target: /data/hapi/hapi.properties + target: /data/hapi/application.yaml volumes: - hapi-data:/data/hapi environment: - JAVA_OPTS: '-Dhapi.properties=/data/hapi/hapi.properties' + JAVA_OPTS: '-Dhapi.properties=/data/hapi/application.yaml' configs: hapi: external: true @@ -67,15 +72,13 @@ volumes: ## Running locally -The easiest way to run this server is to run it directly in Maven using a built-in Jetty server. To do this, change `src/main/resources/hapi.properties` `server_address` and `server.base` with the values commented out as _For Jetty, use this_ and then execute the following command: +The easiest way to run this server entirely depends on your environment requirements. At least, the following 4 ways are supported: +### Using jetty ```bash -mvn jetty:run +mvn jetty:run -Dspring.batch.job.enabled=false ``` -Then, browse to the following link to use the server: - -[http://localhost:8080/hapi-fhir-jpaserver/](http://localhost:8080/hapi-fhir-jpaserver/) If you need to run this server on a different port (using Maven), you can change the port in the run command as follows: @@ -83,43 +86,98 @@ If you need to run this server on a different port (using Maven), you can change mvn -Djetty.port=8888 jetty:run ``` -And replacing 8888 with the port of your choice. +Server will then be accessible at http://localhost:8888/ and eg. http://localhost:8888/fhir/metadata. Remember to adjust you overlay configuration in the application.yaml to eg. + +```yaml + tester: + - + id: home + name: Local Tester + server_address: 'http://localhost:8888/fhir' + refuse_to_fetch_third_party_urls: false + fhir_version: R4 +``` + + + +### Using Spring Boot +```bash +mvn clean package spring-boot:repackage -Pboot && java -jar target/hapi-fhir-jpaserver.war +``` +Server will then be accessible at http://localhost:8080/ and eg. http://localhost:8080/fhir/metadata. Remember to adjust you overlay configuration in the application.yaml to eg. + +```yaml + tester: + - + id: home + name: Local Tester + server_address: 'http://localhost:8080/fhir' + refuse_to_fetch_third_party_urls: false + fhir_version: R4 +``` +### Using Spring Boot and Google distroless +```bash +mvn clean package com.google.cloud.tools:jib-maven-plugin:dockerBuild -Dimage=distroless-hapi && docker run -p 8080:8080 -e spring.batch.job.enabled=false distroless-hapi +``` +Server will then be accessible at http://localhost:8080/ and eg. http://localhost:8080/fhir/metadata. Remember to adjust you overlay configuration in the application.yaml to eg. + +```yaml + tester: + - + id: home + name: Local Tester + server_address: 'http://localhost:8080/fhir' + refuse_to_fetch_third_party_urls: false + fhir_version: R4 +``` + +### Using the Dockerfile and multistage build +```bash +./build-docker-image.sh && docker run -p 8080:8080 -e "spring.batch.job.enabled=false" hapi-fhir/hapi-fhir-jpaserver-starter:latest +``` +Server will then be accessible at http://localhost:8080/hapi-fhir-jpaserver and eg. http://localhost:8080/hapi-fhir-jpaserver/fhir/metadata. Remember to adjust you overlay configuration in the application.yaml to eg. + +```yaml + tester: + - + id: home + name: Local Tester + server_address: 'http://localhost:8080/hapi-fhir-jpaserver/fhir' + refuse_to_fetch_third_party_urls: false + fhir_version: R4 +``` ## Configurations -Much of this HAPI starter project can be configured using the properties file in _src/main/resources/hapi.properties_. By default, this starter project is configured to use Derby as the database. +Much of this HAPI starter project can be configured using the yaml file in _src/main/resources/application.yaml_. By default, this starter project is configured to use H2 as the database. ### MySql configuration -To configure the starter app to use MySQL, instead of the default Derby, update the hapi.properties file to have the following: +To configure the starter app to use MySQL, instead of the default H2, update the application.yaml file to have the following: -- datasource.driver=com.mysql.jdbc.Driver -- datasource.url=jdbc:mysql://localhost:3306/hapi_dstu3 -- hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect -- datasource.username=admin -- datasource.password=admin +```yaml +spring: + datasource: + url: 'jdbc:mysql://localhost:3306/hapi_dstu3' + username: admin + password: admin + driverClassName: com.mysql.jdbc.Driver +``` ### PostgreSQL configuration -To configure the starter app to use PostgreSQL, instead of the default Derby, update the hapi.properties file to have the following: +To configure the starter app to use PostgreSQL, instead of the default H2, update the application.yaml file to have the following: -- datasource.driver=org.postgresql.Driver -- datasource.url=jdbc:postgresql://localhost:5432/hapi_dstu3 -- hibernate.dialect=org.hibernate.dialect.PostgreSQL95Dialect -- datasource.username=admin -- datasource.password=admin +```yaml +spring: + datasource: + url: 'jdbc:postgresql://localhost:5432/hapi_dstu3' + username: admin + password: admin + driverClassName: org.postgresql.Driver +``` -Because the integration tests within the project rely on the default Derby database configuration, it is important to either explicity skip the integration tests during the build process, i.e., `mvn install -DskipTests`, or delete the tests altogether. Failure to skip or delete the tests once you've configured PostgreSQL for the datasource.driver, datasource.url, and hibernate.dialect as outlined above will result in build errors and compilation failure. - -It is important to use PostgreSQL95Dialect when using PostgreSQL version 10+. - -## Overriding application properties - -You can override the properties that are loaded into the compiled web app (.war file) making a copy of the hapi.properties file on the file system, making changes to it, and then setting the JAVA_OPTS environment variable on the tomcat server to tell hapi-jpaserver-starter where the overriding properties file is. For example: - -`-Dhapi.properties=/some/custom/directory/hapi.properties` - -Note: This property name and the path is case-sensitive. "-DHAPI.PROPERTIES=XXX" will not work. +Because the integration tests within the project rely on the default H2 database configuration, it is important to either explicity skip the integration tests during the build process, i.e., `mvn install -DskipTests`, or delete the tests altogether. Failure to skip or delete the tests once you've configured PostgreSQL for the datasource.driver, datasource.url, and hibernate.dialect as outlined above will result in build errors and compilation failure. ## Customizing The Web Testpage UI @@ -129,7 +187,7 @@ The UI is customized using [Thymeleaf](https://www.thymeleaf.org/) template file Several template files that can be customized are found in the following directory: [https://github.com/hapifhir/hapi-fhir-jpaserver-starter/tree/master/src/main/webapp/WEB-INF/templates](https://github.com/hapifhir/hapi-fhir-jpaserver-starter/tree/master/src/main/webapp/WEB-INF/templates) -## Deploying to a Container +## Deploying to an Application Server Using the Maven-Embedded Jetty method above is convenient, but it is not a good solution if you want to leave the server running in the background. @@ -149,6 +207,8 @@ Again, browse to the following link to use the server (note that the port 8080 m [http://localhost:8080/hapi-fhir-jpaserver/](http://localhost:8080/hapi-fhir-jpaserver/) +If you would like it to be hosted at the root, eg. http://localhost:8080/ - then rename the WAR file to ```ROOT.war```. + ## Deploy with docker compose Docker compose is a simple option to build and deploy container. To deploy with docker compose, you should build the project @@ -158,14 +218,20 @@ reached at http://localhost:8080/hapi-fhir-jpaserver/. In order to use another port, change the `ports` parameter inside `docker-compose.yml` to `8888:8080`, where 8888 is a port of your choice. -The docker compose set also includes my MySQL database, if you choose to use MySQL instead of derby, change the following -properties in hapi.properties: +The docker compose set also includes my MySQL database, if you choose to use MySQL instead of H2, change the following +properties in application.yaml: -- datasource.driver=com.mysql.jdbc.Driver -- datasource.url=jdbc:mysql://hapi-fhir-mysql:3306/hapi -- hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect -- datasource.username=admin -- datasource.password=admin +```yaml +spring: + datasource: + url: 'jdbc:mysql://hapi-fhir-mysql:3306/hapi' + username: admin + password: admin + driverClassName: com.mysql.jdbc.Driver +``` + +## Running hapi-fhir-jpaserver direclty from IntelliJ as Spring Boot +Make sure you run with the maven profile called ```boot``` and NOT also ```jetty```. Then you are ready to press debug the project directly without any extra Application Servers. ## Running hapi-fhir-jpaserver-example in Tomcat from IntelliJ @@ -203,21 +269,21 @@ It is important to use MySQL5Dialect when using MySQL version 5+. ## Enabling Subscriptions -The server may be configured with subscription support by enabling properties in the [hapi.properties](https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/master/src/main/resources/hapi.properties) file: +The server may be configured with subscription support by enabling properties in the [application.yaml](https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/master/src/main/resources/application.yaml) file: -- `subscription.resthook.enabled` - Enables REST Hook subscriptions, where the server will make an outgoing connection to a remote REST server +- `hapi.fhir.subscription.resthook.enabled` - Enables REST Hook subscriptions, where the server will make an outgoing connection to a remote REST server -- `subscription.email.enabled` - Enables email subscriptions. Note that you must also provide the connection details for a usable SMTP server. +- `hapi.fhir.subscription.email.*` - Enables email subscriptions. Note that you must also provide the connection details for a usable SMTP server. -- `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) +- `hapi.fhir.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. Note that EMPI relies on subscriptions, so for EMPI to work, subscriptions must be enabled. +Set `hapi.fhir.empi_enabled=true` in the [application.yaml](https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/master/src/main/resources/application.yaml) 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. Note that EMPI relies on subscriptions, so for EMPI to work, subscriptions must be enabled. ## 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 [application.yaml](https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/master/src/main/resources/application.yaml) For example: diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/Application.java b/src/main/java/ca/uhn/fhir/jpa/starter/Application.java index b0aa670..fab5481 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/Application.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/Application.java @@ -20,8 +20,8 @@ import org.springframework.web.context.support.AnnotationConfigWebApplicationCon import org.springframework.web.servlet.DispatcherServlet; @ServletComponentScan(basePackageClasses = { - JpaRestfulServer.class}, basePackages = "ca.uhn.fhir.jpa.starter") -@SpringBootApplication(exclude = {ElasticsearchRestClientAutoConfiguration.class}, scanBasePackages = {"ca.uhn.fhir.jpa.starter"}) + JpaRestfulServer.class}) +@SpringBootApplication(exclude = {ElasticsearchRestClientAutoConfiguration.class}) @Import({SubscriptionSubmitterConfig.class, SubscriptionProcessorConfig.class, SubscriptionChannelConfig.class, WebsocketDispatcherConfig.class, EmpiConfig.class}) public class Application extends SpringBootServletInitializer { @@ -49,7 +49,7 @@ public class Application extends SpringBootServletInitializer { JpaRestfulServer jpaRestfulServer = new JpaRestfulServer(); beanFactory.autowireBean(jpaRestfulServer); servletRegistrationBean.setServlet(jpaRestfulServer); - servletRegistrationBean.addUrlMappings("/hapi-fhir-jpaserver/fhir/*"); + servletRegistrationBean.addUrlMappings("/fhir/*"); servletRegistrationBean.setLoadOnStartup(1); return servletRegistrationBean; @@ -68,7 +68,7 @@ public class Application extends SpringBootServletInitializer { ServletRegistrationBean registrationBean = new ServletRegistrationBean(); registrationBean.setServlet(dispatcherServlet); - registrationBean.addUrlMappings("/hapi-fhir-jpaserver/*", "/*"); + registrationBean.addUrlMappings("/*"); registrationBean.setLoadOnStartup(1); return registrationBean; diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu2IT.java b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu2IT.java index aeab8d7..b99ea65 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu2IT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu2IT.java @@ -50,7 +50,7 @@ public class ExampleServerDstu2IT { ourCtx = FhirContext.forDstu2(); ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER); ourCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000); - String ourServerBase = "http://localhost:" + port + "/hapi-fhir-jpaserver/fhir/"; + String ourServerBase = "http://localhost:" + port + "/fhir/"; ourClient = ourCtx.newRestfulGenericClient(ourServerBase); ourClient.registerInterceptor(new LoggingInterceptor(true)); } diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu3IT.java b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu3IT.java index 208ca01..ca1cbf1 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu3IT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu3IT.java @@ -92,7 +92,7 @@ public class ExampleServerDstu3IT { SocketImplementation mySocketImplementation = new SocketImplementation(mySubscriptionId.getIdPart(), EncodingEnum.JSON); myWebSocketClient.start(); - URI echoUri = new URI("ws://localhost:" + port + "/hapi-fhir-jpaserver/websocket"); + URI echoUri = new URI("ws://localhost:" + port + "/websocket"); ClientUpgradeRequest request = new ClientUpgradeRequest(); ourLog.info("Connecting to : {}", echoUri); Future connection = myWebSocketClient.connect(mySocketImplementation, echoUri, request); @@ -127,7 +127,7 @@ public class ExampleServerDstu3IT { ourCtx = FhirContext.forDstu3(); ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER); ourCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000); - String ourServerBase = "http://localhost:" + port + "/hapi-fhir-jpaserver/fhir/"; + String ourServerBase = "http://localhost:" + port + "/fhir/"; ourClient = ourCtx.newRestfulGenericClient(ourServerBase); ourClient.registerInterceptor(new LoggingInterceptor(true)); } diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java index dbcfff4..6fc36b3 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java @@ -119,7 +119,7 @@ public class ExampleServerR4IT { SocketImplementation mySocketImplementation = new SocketImplementation(mySubscriptionId.getIdPart(), EncodingEnum.JSON); myWebSocketClient.start(); - URI echoUri = new URI("ws://localhost:" + port + "/hapi-fhir-jpaserver/websocket"); + URI echoUri = new URI("ws://localhost:" + port + "/websocket"); ClientUpgradeRequest request = new ClientUpgradeRequest(); ourLog.info("Connecting to : {}", echoUri); Future connection = myWebSocketClient.connect(mySocketImplementation, echoUri, request); @@ -159,7 +159,7 @@ public class ExampleServerR4IT { ourCtx = FhirContext.forR4(); ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER); ourCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000); - String ourServerBase = "http://localhost:" + port + "/hapi-fhir-jpaserver/fhir/"; + String ourServerBase = "http://localhost:" + port + "/fhir/"; ourClient = ourCtx.newRestfulGenericClient(ourServerBase); ourClient.registerInterceptor(new LoggingInterceptor(true)); } diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR5IT.java b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR5IT.java index 9eea4d6..3a52ec7 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR5IT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR5IT.java @@ -97,7 +97,7 @@ public class ExampleServerR5IT { SocketImplementation mySocketImplementation = new SocketImplementation(mySubscriptionId.getIdPart(), EncodingEnum.JSON); myWebSocketClient.start(); - URI echoUri = new URI("ws://localhost:" + port + "/hapi-fhir-jpaserver/websocket"); + URI echoUri = new URI("ws://localhost:" + port + "/websocket"); ClientUpgradeRequest request = new ClientUpgradeRequest(); ourLog.info("Connecting to : {}", echoUri); Future connection = myWebSocketClient.connect(mySocketImplementation, echoUri, request); @@ -129,7 +129,7 @@ public class ExampleServerR5IT { ourCtx = FhirContext.forR5(); ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER); ourCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000); - String ourServerBase = "http://localhost:" + port + "/hapi-fhir-jpaserver/fhir/"; + String ourServerBase = "http://localhost:" + port + "/fhir/"; ourClient = ourCtx.newRestfulGenericClient(ourServerBase); ourClient.registerInterceptor(new LoggingInterceptor(true)); } diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/MultitenantServerR4IT.java b/src/test/java/ca/uhn/fhir/jpa/starter/MultitenantServerR4IT.java index 856ad70..66fb4df 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/MultitenantServerR4IT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/MultitenantServerR4IT.java @@ -99,7 +99,7 @@ public class MultitenantServerR4IT { ourCtx = FhirContext.forR4(); ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER); ourCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000); - String ourServerBase = "http://localhost:" + port + "/hapi-fhir-jpaserver/fhir/"; + String ourServerBase = "http://localhost:" + port + "/fhir/"; ourClient = ourCtx.newRestfulGenericClient(ourServerBase); ourClient.registerInterceptor(new LoggingInterceptor(true)); ourClient.registerInterceptor(ourClientTenantInterceptor); From e24af07f0988f843d496215c0232f368938cf564 Mon Sep 17 00:00:00 2001 From: jvi Date: Fri, 18 Sep 2020 23:00:04 +0200 Subject: [PATCH 05/21] spelling --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ffe6612..8a39fba 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ In order to use this sample, you should have: - Apache Maven build tool (newest version) ### or - - Docker, as the entire project can be built using multistage docker (with both JDK and maven wrapped in docker) orr used directly from [Docker Hub](https://hub.docker.com/repository/docker/hapiproject/hapi) + - Docker, as the entire project can be built using multistage docker (with both JDK and maven wrapped in docker) or used directly from [Docker Hub](https://hub.docker.com/repository/docker/hapiproject/hapi) ## Running via [Docker Hub](https://hub.docker.com/repository/docker/hapiproject/hapi) From ee337296eeb1adbe4faf21e295d55757767009bf Mon Sep 17 00:00:00 2001 From: Jens Kristian Villadsen <46567685+jvitrifork@users.noreply.github.com> Date: Mon, 21 Sep 2020 19:19:10 +0200 Subject: [PATCH 06/21] =?UTF-8?q?Renamed=20deployable=20war=20to=20ROOT=20?= =?UTF-8?q?in=20order=20to=20homogenize=20urls=20regardless=E2=80=A6=20(#1?= =?UTF-8?q?41)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Renamed deployable war to ROOT in order to homogenize urls regardless of deployment method * Made Maven quite when doing downloading dependencies --- Dockerfile | 4 ++-- README.md | 4 ++-- pom.xml | 16 ++++++++-------- src/main/resources/application.yaml | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6ae7213..a6699d5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,12 +2,12 @@ FROM maven:3.6.3-jdk-11-slim as build-hapi WORKDIR /tmp/hapi-fhir-jpaserver-starter COPY pom.xml . -RUN mvn dependency:go-offline +RUN mvn -ntp dependency:go-offline COPY src/ /tmp/hapi-fhir-jpaserver-starter/src/ RUN mvn clean install -DskipTests -FROM tomcat:9.0.37-jdk11-openjdk-slim-buster +FROM tomcat:9.0.38-jdk11-openjdk-slim-buster RUN mkdir -p /data/hapi/lucenefiles && chmod 775 /data/hapi/lucenefiles COPY --from=build-hapi /tmp/hapi-fhir-jpaserver-starter/target/*.war /usr/local/tomcat/webapps/ diff --git a/README.md b/README.md index 8a39fba..b9b2aca 100644 --- a/README.md +++ b/README.md @@ -135,14 +135,14 @@ Server will then be accessible at http://localhost:8080/ and eg. http://localhos ```bash ./build-docker-image.sh && docker run -p 8080:8080 -e "spring.batch.job.enabled=false" hapi-fhir/hapi-fhir-jpaserver-starter:latest ``` -Server will then be accessible at http://localhost:8080/hapi-fhir-jpaserver and eg. http://localhost:8080/hapi-fhir-jpaserver/fhir/metadata. Remember to adjust you overlay configuration in the application.yaml to eg. +Server will then be accessible at http://localhost:8080/ and eg. http://localhost:8080/fhir/metadata. Remember to adjust you overlay configuration in the application.yaml to eg. ```yaml tester: - id: home name: Local Tester - server_address: 'http://localhost:8080/hapi-fhir-jpaserver/fhir' + server_address: 'http://localhost:8080/fhir' refuse_to_fetch_third_party_urls: false fhir_version: R4 ``` diff --git a/pom.xml b/pom.xml index 0e66d1c..e17c0cc 100644 --- a/pom.xml +++ b/pom.xml @@ -21,11 +21,11 @@ 8 - 2.3.3.RELEASE + 2.3.4.RELEASE - 3.6.0 + 3.6.3 war @@ -269,7 +269,7 @@ org.springframework.boot spring-boot-autoconfigure - ${spring.boot} + ${spring_boot_version} @@ -289,7 +289,7 @@ org.springframework.boot spring-boot-starter-test - ${spring.boot} + ${spring_boot_version} test @@ -298,8 +298,8 @@ - - hapi-fhir-jpaserver + + ROOT @@ -495,7 +495,7 @@ org.springframework.boot spring-boot-starter-web - 2.3.3.RELEASE + ${spring_boot_version} @@ -508,7 +508,7 @@ org.springframework.boot spring-boot-starter-web - 2.3.3.RELEASE + ${spring_boot_version} org.springframework.boot diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 7a91683..96bb062 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -86,7 +86,7 @@ hapi: - id: home name: Local Tester - server_address: 'http://localhost:8080/hapi-fhir-jpaserver/fhir' + server_address: 'http://localhost:8080/fhir' refuse_to_fetch_third_party_urls: false fhir_version: R4 - From 85e9fc725ad18ba1c0dd10330e4d6e3b255d7541 Mon Sep 17 00:00:00 2001 From: Panayiotis Savva Date: Tue, 22 Sep 2020 19:39:28 +0300 Subject: [PATCH 07/21] Update README.md (#143) The rename from hapi-fhir-jpaserver to ROOT as per ee337296eeb1adbe4faf21e295d55757767009bf requires that the new war file is specified which is now ROOT.war --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b9b2aca..d028bd7 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ Server will then be accessible at http://localhost:8888/ and eg. http://localhos ### Using Spring Boot ```bash -mvn clean package spring-boot:repackage -Pboot && java -jar target/hapi-fhir-jpaserver.war +mvn clean package spring-boot:repackage -Pboot && java -jar target/ROOT.war ``` Server will then be accessible at http://localhost:8080/ and eg. http://localhost:8080/fhir/metadata. Remember to adjust you overlay configuration in the application.yaml to eg. From a62de8249507b710ac93a4289ae1068ea4f4e476 Mon Sep 17 00:00:00 2001 From: Sean McIlvenna Date: Tue, 22 Sep 2020 16:05:23 -0700 Subject: [PATCH 08/21] Setting `batch.job.enabled` to `false` by default, since HAPI won't launch on its own without it. Updating the README.md to have the correct example externalized configs in a docker-compose file --- README.md | 2 +- src/main/resources/application.yaml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d028bd7..774af56 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ services: volumes: - hapi-data:/data/hapi environment: - JAVA_OPTS: '-Dhapi.properties=/data/hapi/application.yaml' + SPRING_CONFIG_LOCATION: 'file:///data/hapi/application.yaml' configs: hapi: external: true diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 96bb062..b7ec776 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -24,6 +24,10 @@ spring: hibernate.search.default.indexBase: target/lucenefiles hibernate.search.lucene_version: LUCENE_CURRENT + batch: + job: + enabled: false + hapi: fhir: defer_indexing_for_codesystems_of_size: 101 From 90de1746e81cac5c28f7c709f003d240e932ace4 Mon Sep 17 00:00:00 2001 From: "Gerlach, Winfried" Date: Tue, 1 Sep 2020 17:00:49 +0200 Subject: [PATCH 09/21] README.md: consistently use Docker tagname "latest"; Docker newbies will be confused if it is "latest" in one place and "tagname" in another; Docker pros know that they can choose a different tag name anyway --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 774af56..b2c2e27 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Each tagged/released version of `hapi-fhir-jpaserver` is built as a Docker image ``` docker pull hapiproject/hapi:latest -docker run -p 8080:8080 -e "spring.batch.job.enabled=false" hapiproject/hapi:tagname +docker run -p 8080:8080 -e "spring.batch.job.enabled=false" hapiproject/hapi:latest ``` This will run the docker image with the default configuration, mapping port 8080 from the container to port 8080 in the host. Once running, you can access `http://localhost:8080/hapi-fhir-jpaserver/` in the browser to access the HAPI FHIR server's UI. @@ -36,7 +36,9 @@ If you change the mapped port, you need to change the configuration used by HAPI You can customize HAPI directly from the `run` command using environment variables. For example: -`docker run -p 8080:8080 -e hapi.fhir.default_encoding=xml hapiproject/hapi:tagname` +``` +docker run -p 8080:8080 -e hapi.fhir.default_encoding=xml hapiproject/hapi:latest +``` HAPI looks in the environment variables for properties in the [application.yaml](https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/master/src/main/resources/application.yaml) file for defaults. @@ -44,7 +46,9 @@ HAPI looks in the environment variables for properties in the [application.yaml] You can customize HAPI by telling HAPI to look for the configuration file in a different location, eg.: -`docker run -p 8090:8080 -e "--spring.config.location=classpath:/another.application.yaml" hapiproject/hapi:tagname` +``` +docker run -p 8090:8080 -e "--spring.config.location=classpath:/another.application.yaml" hapiproject/hapi:latest +``` ### Example docker-compose.yml @@ -52,7 +56,7 @@ You can customize HAPI by telling HAPI to look for the configuration file in a d version: '3.7' services: web: - image: "hapiproject/hapi:tagname" + image: "hapiproject/hapi:latest" ports: - "8090:8080" configs: From 7dc7b847d9ce04ee461ecb4dada555a62a0c4c7c Mon Sep 17 00:00:00 2001 From: "Gerlach, Winfried" Date: Tue, 1 Sep 2020 17:02:12 +0200 Subject: [PATCH 10/21] README.md: also mention REST endpoint, not only UI URL --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b2c2e27..049e72e 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ docker pull hapiproject/hapi:latest docker run -p 8080:8080 -e "spring.batch.job.enabled=false" hapiproject/hapi:latest ``` -This will run the docker image with the default configuration, mapping port 8080 from the container to port 8080 in the host. Once running, you can access `http://localhost:8080/hapi-fhir-jpaserver/` in the browser to access the HAPI FHIR server's UI. +This will run the docker image with the default configuration, mapping port 8080 from the container to port 8080 in the host. Once running, you can access `http://localhost:8080/hapi-fhir-jpaserver/` in the browser to access the HAPI FHIR server's UI or use `http://localhost:8080/hapi-fhir-jpaserver/fhir/` as the base URL for your REST requests. If you change the mapped port, you need to change the configuration used by HAPI to have the correct `hapi.fhir.tester` property/value. From 75503466cdd8628e0d084b21349bd07b831e2e1d Mon Sep 17 00:00:00 2001 From: Panayiotis Savva Date: Wed, 23 Sep 2020 20:13:22 +0300 Subject: [PATCH 11/21] Spring batch job enabled (#144) * Remove Batch job enabled=false * Batch job Enabled default to False --- README.md | 8 ++++---- src/main/resources/application.yaml | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 774af56..3f390be 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Each tagged/released version of `hapi-fhir-jpaserver` is built as a Docker image ``` docker pull hapiproject/hapi:latest -docker run -p 8080:8080 -e "spring.batch.job.enabled=false" hapiproject/hapi:tagname +docker run -p 8080:8080 hapiproject/hapi:tagname ``` This will run the docker image with the default configuration, mapping port 8080 from the container to port 8080 in the host. Once running, you can access `http://localhost:8080/hapi-fhir-jpaserver/` in the browser to access the HAPI FHIR server's UI. @@ -76,7 +76,7 @@ The easiest way to run this server entirely depends on your environment requirem ### Using jetty ```bash -mvn jetty:run -Dspring.batch.job.enabled=false +mvn jetty:run ``` @@ -117,7 +117,7 @@ Server will then be accessible at http://localhost:8080/ and eg. http://localhos ``` ### Using Spring Boot and Google distroless ```bash -mvn clean package com.google.cloud.tools:jib-maven-plugin:dockerBuild -Dimage=distroless-hapi && docker run -p 8080:8080 -e spring.batch.job.enabled=false distroless-hapi +mvn clean package com.google.cloud.tools:jib-maven-plugin:dockerBuild -Dimage=distroless-hapi && docker run -p 8080:8080 distroless-hapi ``` Server will then be accessible at http://localhost:8080/ and eg. http://localhost:8080/fhir/metadata. Remember to adjust you overlay configuration in the application.yaml to eg. @@ -133,7 +133,7 @@ Server will then be accessible at http://localhost:8080/ and eg. http://localhos ### Using the Dockerfile and multistage build ```bash -./build-docker-image.sh && docker run -p 8080:8080 -e "spring.batch.job.enabled=false" hapi-fhir/hapi-fhir-jpaserver-starter:latest +./build-docker-image.sh && docker run -p 8080:8080 hapi-fhir/hapi-fhir-jpaserver-starter:latest ``` Server will then be accessible at http://localhost:8080/ and eg. http://localhost:8080/fhir/metadata. Remember to adjust you overlay configuration in the application.yaml to eg. diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index b7ec776..96a4040 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -1,4 +1,6 @@ spring: + batch: + job.enabled: false datasource: url: 'jdbc:h2:file:./target/database/h2' username: sa From 8699965569c203e071a6c47a06cbd7c0b1f3ea19 Mon Sep 17 00:00:00 2001 From: Panayiotis Savva Date: Fri, 25 Sep 2020 09:02:28 +0300 Subject: [PATCH 12/21] Remove Duplicate batch job enabled It seems via the adding and removing of the previous PR landed up having 2x the tags for Batch job enabled. Once on line 2, Once on Line 29 --- src/main/resources/application.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 96a4040..b7ec776 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -1,6 +1,4 @@ spring: - batch: - job.enabled: false datasource: url: 'jdbc:h2:file:./target/database/h2' username: sa From 8906366cb26ffcde9afcd945d220ecb7728d95ea Mon Sep 17 00:00:00 2001 From: "Gerlach, Winfried" Date: Fri, 25 Sep 2020 09:44:54 +0200 Subject: [PATCH 13/21] README.md: adapt to renaming deployable war to ROOT.war --- README.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 049e72e..8c45e45 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ docker pull hapiproject/hapi:latest docker run -p 8080:8080 -e "spring.batch.job.enabled=false" hapiproject/hapi:latest ``` -This will run the docker image with the default configuration, mapping port 8080 from the container to port 8080 in the host. Once running, you can access `http://localhost:8080/hapi-fhir-jpaserver/` in the browser to access the HAPI FHIR server's UI or use `http://localhost:8080/hapi-fhir-jpaserver/fhir/` as the base URL for your REST requests. +This will run the docker image with the default configuration, mapping port 8080 from the container to port 8080 in the host. Once running, you can access `http://localhost:8080/` in the browser to access the HAPI FHIR server's UI or use `http://localhost:8080/fhir/` as the base URL for your REST requests. If you change the mapped port, you need to change the configuration used by HAPI to have the correct `hapi.fhir.tester` property/value. @@ -205,19 +205,17 @@ To deploy to a container, you should first build the project: mvn clean install ``` -This will create a file called `hapi-fhir-jpaserver.war` in your `target` directory. This should be installed in your Web Container according to the instructions for your particular container. For example, if you are using Tomcat, you will want to copy this file to the `webapps/` directory. +This will create a file called `ROOT.war` in your `target` directory. This should be installed in your Web Container according to the instructions for your particular container. For example, if you are using Tomcat, you will want to copy this file to the `webapps/` directory. Again, browse to the following link to use the server (note that the port 8080 may not be correct depending on how your server is configured). -[http://localhost:8080/hapi-fhir-jpaserver/](http://localhost:8080/hapi-fhir-jpaserver/) - -If you would like it to be hosted at the root, eg. http://localhost:8080/ - then rename the WAR file to ```ROOT.war```. +[http://localhost:8080/](http://localhost:8080/) ## Deploy with docker compose Docker compose is a simple option to build and deploy container. To deploy with docker compose, you should build the project with `mvn clean install` and then bring up the containers with `docker-compose up -d --build`. The server can be -reached at http://localhost:8080/hapi-fhir-jpaserver/. +reached at http://localhost:8080/. In order to use another port, change the `ports` parameter inside `docker-compose.yml` to `8888:8080`, where 8888 is a port of your choice. @@ -234,7 +232,7 @@ spring: driverClassName: com.mysql.jdbc.Driver ``` -## Running hapi-fhir-jpaserver direclty from IntelliJ as Spring Boot +## Running hapi-fhir-jpaserver directly from IntelliJ as Spring Boot Make sure you run with the maven profile called ```boot``` and NOT also ```jetty```. Then you are ready to press debug the project directly without any extra Application Servers. ## Running hapi-fhir-jpaserver-example in Tomcat from IntelliJ @@ -279,7 +277,7 @@ The server may be configured with subscription support by enabling properties in - `hapi.fhir.subscription.email.*` - Enables email subscriptions. Note that you must also provide the connection details for a usable SMTP server. -- `hapi.fhir.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) +- `hapi.fhir.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/websocket](ws://localhost:8080/websocket) ## Enabling EMPI From 5c4a51601f1d113247cb39b918bead878603fd0f Mon Sep 17 00:00:00 2001 From: Jens Kristian Villadsen <46567685+jvitrifork@users.noreply.github.com> Date: Tue, 29 Sep 2020 17:56:02 +0200 Subject: [PATCH 14/21] Update README.md (#149) Adjusted according to current defaults --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3f390be..43ab456 100644 --- a/README.md +++ b/README.md @@ -201,19 +201,19 @@ To deploy to a container, you should first build the project: mvn clean install ``` -This will create a file called `hapi-fhir-jpaserver.war` in your `target` directory. This should be installed in your Web Container according to the instructions for your particular container. For example, if you are using Tomcat, you will want to copy this file to the `webapps/` directory. +This will create a file called `ROOT.war` in your `target` directory. This should be installed in your Web Container according to the instructions for your particular container. For example, if you are using Tomcat, you will want to copy this file to the `webapps/` directory. Again, browse to the following link to use the server (note that the port 8080 may not be correct depending on how your server is configured). -[http://localhost:8080/hapi-fhir-jpaserver/](http://localhost:8080/hapi-fhir-jpaserver/) +[http://localhost:8080/](http://localhost:8080/hapi-fhir-jpaserver/) -If you would like it to be hosted at the root, eg. http://localhost:8080/ - then rename the WAR file to ```ROOT.war```. +If you would like it to be hosted at eg. hapi-fhir-jpaserver, eg. http://localhost:8080/hapi-fhir-jpaserver/ - then rename the WAR file to ```hapi-fhir-jpaserver.war```. ## Deploy with docker compose Docker compose is a simple option to build and deploy container. To deploy with docker compose, you should build the project with `mvn clean install` and then bring up the containers with `docker-compose up -d --build`. The server can be -reached at http://localhost:8080/hapi-fhir-jpaserver/. +reached at http://localhost:8080/. In order to use another port, change the `ports` parameter inside `docker-compose.yml` to `8888:8080`, where 8888 is a port of your choice. From cb9769f0c3d4224dd0e92cc0ae91af56ae95784a Mon Sep 17 00:00:00 2001 From: Panayiotis Savva Date: Wed, 21 Oct 2020 18:38:58 +0300 Subject: [PATCH 15/21] Docker buid - heap memory error (#155) When building in Docker, we sometimes face a heap memory running out when compiling the WAR file. Setting the MAVEN_OPTS="-Xmx1024m" resolves this --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index a6699d5..16ce405 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,7 @@ COPY pom.xml . RUN mvn -ntp dependency:go-offline COPY src/ /tmp/hapi-fhir-jpaserver-starter/src/ +RUN set MAVEN_OPTS="-Xmx1024m" RUN mvn clean install -DskipTests FROM tomcat:9.0.38-jdk11-openjdk-slim-buster From 8f06e457df04fa2358c801138751e11917064559 Mon Sep 17 00:00:00 2001 From: Sean McIlvenna Date: Wed, 21 Oct 2020 13:06:31 -0400 Subject: [PATCH 16/21] Revert "Docker buid - heap memory error (#155)" (#156) This reverts commit cb9769f0c3d4224dd0e92cc0ae91af56ae95784a. --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 16ce405..a6699d5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,6 @@ COPY pom.xml . RUN mvn -ntp dependency:go-offline COPY src/ /tmp/hapi-fhir-jpaserver-starter/src/ -RUN set MAVEN_OPTS="-Xmx1024m" RUN mvn clean install -DskipTests FROM tomcat:9.0.38-jdk11-openjdk-slim-buster From 313e6b3e2c4a1de842621ef4d1523c5816ecd74d Mon Sep 17 00:00:00 2001 From: Jens Kristian Villadsen <46567685+jvitrifork@users.noreply.github.com> Date: Sun, 25 Oct 2020 20:28:55 +0100 Subject: [PATCH 17/21] Update README.md Added spring-boot:run optionality --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 0c7b32b..c5be768 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,21 @@ Server will then be accessible at http://localhost:8888/ and eg. http://localhos fhir_version: R4 ``` +### Using Spring Boot with :run +```bash +mvn clean spring-boot:run -Pboot +``` +Server will then be accessible at http://localhost:8080/ and eg. http://localhost:8080/fhir/metadata. Remember to adjust you overlay configuration in the application.yaml to eg. +```yaml + tester: + - + id: home + name: Local Tester + server_address: 'http://localhost:8080/fhir' + refuse_to_fetch_third_party_urls: false + fhir_version: R4 +``` ### Using Spring Boot ```bash From 7479b5fa28c5175100ffe4a8fa56615866c87f57 Mon Sep 17 00:00:00 2001 From: Jens Kristian Villadsen <46567685+jvitrifork@users.noreply.github.com> Date: Thu, 12 Nov 2020 10:31:24 +0100 Subject: [PATCH 18/21] Update README.md Added example for mounting configuration in a one-line style --- README.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c5be768..13d8fe4 100644 --- a/README.md +++ b/README.md @@ -42,15 +42,23 @@ docker run -p 8080:8080 -e hapi.fhir.default_encoding=xml hapiproject/hapi:lates HAPI looks in the environment variables for properties in the [application.yaml](https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/master/src/main/resources/application.yaml) file for defaults. -### Configuration via overridden application.yaml file +### Configuration via overridden application.yaml file and using Docker You can customize HAPI by telling HAPI to look for the configuration file in a different location, eg.: +``` +docker run -p 8090:8080 -v $(pwd)/yourLocalFolder:/configs -e "--spring.config.location=file:///configs/another.application.yaml" hapiproject/hapi:latest +``` +Here, the configuration file (*another.application.yaml*) is placed locally in the folder *yourLocalFolder*. + + + ``` docker run -p 8090:8080 -e "--spring.config.location=classpath:/another.application.yaml" hapiproject/hapi:latest ``` +Here, the configuration file (*another.application.yaml*) is part of the compiled set of resources. -### Example docker-compose.yml +### Example using docker-compose.yml for docker-compose ``` version: '3.7' From cfd180e3f314ca16069d06ef6dc60831fa968c01 Mon Sep 17 00:00:00 2001 From: jamesagnew Date: Wed, 18 Nov 2020 06:45:31 -0500 Subject: [PATCH 19/21] Version bump to 5.2.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e17c0cc..8c2b2bc 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ ca.uhn.hapi.fhir hapi-fhir - 5.1.0 + 5.2.0 hapi-fhir-jpaserver-starter From 8850e645cec454d1bfbe5cf05f88c9d3fd131b25 Mon Sep 17 00:00:00 2001 From: jamesagnew Date: Wed, 18 Nov 2020 07:20:51 -0500 Subject: [PATCH 20/21] Fix issue in 5.2.0 bump --- .../jpa/starter/FhirServerConfigCommon.java | 14 ++++++++++++ .../starter/JpaHibernateDialectProvider.java | 22 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/main/java/ca/uhn/fhir/jpa/starter/JpaHibernateDialectProvider.java diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/FhirServerConfigCommon.java b/src/main/java/ca/uhn/fhir/jpa/starter/FhirServerConfigCommon.java index cfe9bde..091f37a 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/FhirServerConfigCommon.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/FhirServerConfigCommon.java @@ -3,6 +3,7 @@ package ca.uhn.fhir.jpa.starter; import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.binstore.DatabaseBlobBinaryStorageSvcImpl; import ca.uhn.fhir.jpa.binstore.IBinaryStorageSvc; +import ca.uhn.fhir.jpa.config.HibernateDialectProvider; import ca.uhn.fhir.jpa.model.config.PartitionSettings; import ca.uhn.fhir.jpa.model.entity.ModelConfig; import ca.uhn.fhir.jpa.subscription.channel.subscription.SubscriptionDeliveryHandlerFactory; @@ -10,9 +11,11 @@ import ca.uhn.fhir.jpa.subscription.match.deliver.email.IEmailSender; import ca.uhn.fhir.jpa.subscription.match.deliver.email.JavaMailEmailSender; import com.google.common.base.Strings; import org.hl7.fhir.dstu2.model.Subscription; +import org.springframework.boot.env.YamlPropertySourceLoader; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Lazy; +import org.springframework.context.annotation.Primary; import org.springframework.transaction.annotation.EnableTransactionManagement; import java.util.Optional; @@ -110,6 +113,11 @@ public class FhirServerConfigCommon { return retVal; } + @Bean + public YamlPropertySourceLoader yamlPropertySourceLoader() { + return new YamlPropertySourceLoader(); + } + @Bean public PartitionSettings partitionSettings(AppProperties appProperties) { PartitionSettings retVal = new PartitionSettings(); @@ -123,6 +131,12 @@ public class FhirServerConfigCommon { } + @Primary + @Bean + public HibernateDialectProvider jpaStarterDialectProvider() { + return new JpaHibernateDialectProvider(); + } + @Bean public ModelConfig modelConfig(AppProperties appProperties) { ModelConfig modelConfig = new ModelConfig(); diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/JpaHibernateDialectProvider.java b/src/main/java/ca/uhn/fhir/jpa/starter/JpaHibernateDialectProvider.java new file mode 100644 index 0000000..61395a1 --- /dev/null +++ b/src/main/java/ca/uhn/fhir/jpa/starter/JpaHibernateDialectProvider.java @@ -0,0 +1,22 @@ +package ca.uhn.fhir.jpa.starter; + +import ca.uhn.fhir.context.ConfigurationException; +import ca.uhn.fhir.jpa.config.HibernateDialectProvider; +import org.hibernate.dialect.Dialect; +import org.springframework.beans.factory.annotation.Value; + +public class JpaHibernateDialectProvider extends HibernateDialectProvider { + + @Value("${spring.jpa.properties.hibernate.dialect}") + public String myDialectClass; + + + @Override + public Dialect getDialect() { + try { + return (Dialect) Class.forName(myDialectClass).newInstance(); + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { + throw new ConfigurationException("Can not load dialect: " + myDialectClass); + } + } +} From 2181238ebae954dae779073a739002c1187c49f6 Mon Sep 17 00:00:00 2001 From: jamesagnew Date: Wed, 18 Nov 2020 07:38:22 -0500 Subject: [PATCH 21/21] One more test fix --- src/main/resources/empi-rules.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/resources/empi-rules.json b/src/main/resources/empi-rules.json index 9f2706a..cb1d710 100644 --- a/src/main/resources/empi-rules.json +++ b/src/main/resources/empi-rules.json @@ -26,17 +26,17 @@ "name": "cosine-given-name", "resourceType": "*", "resourcePath": "name.given", - "metric": "COSINE", - "matchThreshold": 0.8, - "exact": true + "matcher": { + "algorithm": "COLOGNE" + } }, { "name": "jaro-last-name", "resourceType": "*", "resourcePath": "name.family", - "metric": "JARO_WINKLER", - "matchThreshold": 0.8, - "exact": true + "matcher": { + "algorithm": "SOUNDEX" + } } ], "matchResultMap": {