From b7331977ad8a9f638b2d3998c121dfd4c15ee022 Mon Sep 17 00:00:00 2001 From: Niels Wolters Date: Wed, 14 Feb 2024 12:02:45 +0100 Subject: [PATCH 1/5] Updated config to allow ips generation --- pom.xml | 4 ++-- .../uhn/fhir/jpa/starter/AppProperties.java | 2 +- .../jpa/starter/ips/IpsConfigCondition.java | 12 ++++++++++- src/main/resources/application.yaml | 20 +++++++++---------- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index 1b8fee45e..b8dab28c4 100644 --- a/pom.xml +++ b/pom.xml @@ -176,10 +176,10 @@ - + diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java b/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java index 451c19dbb..5385f8bd4 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java @@ -24,7 +24,7 @@ public class AppProperties { private Boolean cr_enabled = false; - private Boolean ips_enabled = false; + private Boolean ips_enabled = true; private Boolean openapi_enabled = false; private Boolean mdm_enabled = false; private String mdm_rules_json_location = "mdm-rules.json"; diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/ips/IpsConfigCondition.java b/src/main/java/ca/uhn/fhir/jpa/starter/ips/IpsConfigCondition.java index ca26e48ff..c587be10f 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/ips/IpsConfigCondition.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/ips/IpsConfigCondition.java @@ -8,7 +8,17 @@ public class IpsConfigCondition implements Condition { @Override public boolean matches(ConditionContext theConditionContext, AnnotatedTypeMetadata theAnnotatedTypeMetadata) { + System.out.println("\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"); String property = theConditionContext.getEnvironment().getProperty("hapi.fhir.ips_enabled"); - return Boolean.parseBoolean(property); + Boolean result = Boolean.parseBoolean(property); + + if(result) { + System.out.println("IpsConfigCondition.matches: true"); + } else { + System.out.println("IpsConfigCondition.matches: false"); + } + + System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n"); + return result; } } diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 95ebfeca2..7ec717f65 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -86,16 +86,16 @@ hapi: # install_transitive_ig_dependencies: true #implementationguides: ### example from registry (packages.fhir.org) - # swiss: - # name: swiss.mednet.fhir - # version: 0.8.0 - # reloadExisting: false - # installMode: STORE_AND_INSTALL + # swiss: + # name: swiss.mednet.fhir + # version: 0.8.0 + # reloadExisting: false + # installMode: STORE_AND_INSTALL # example not from registry - # ips_1_0_0: - # packageUrl: https://build.fhir.org/ig/HL7/fhir-ips/package.tgz - # name: hl7.fhir.uv.ips - # version: 1.0.0 + # ips_1_0_0: + # packageUrl: https://build.fhir.org/ig/HL7/fhir-ips/package.tgz + # name: hl7.fhir.uv.ips + # version: 1.0.0 # supported_resource_types: # - Patient # - Observation @@ -111,7 +111,7 @@ hapi: # auto_create_placeholder_reference_targets: false ### tells the server to automatically append the current version of the target resource to references at these paths # auto_version_reference_at_paths: Device.patient, Device.location, Device.parent, DeviceMetric.parent, DeviceMetric.source, Observation.device, Observation.subject - # ips_enabled: false + ips_enabled: true # default_encoding: JSON # default_pretty_print: true # default_page_size: 20 From 6673b57d2cc9624cca0e1c4d7bd2e4f32f40720a Mon Sep 17 00:00:00 2001 From: Niels Wolters Date: Thu, 15 Feb 2024 14:52:51 +0100 Subject: [PATCH 2/5] Changed default deployment port for Spring Boot build to 8888 --- .vscode/settings.json | 3 ++- README.md | 26 ++++++++++++++++++- .../uhn/fhir/jpa/starter/AppProperties.java | 2 +- .../ips/ZorgRotondeIpsGenerationStrategy.java | 20 ++++++++++++++ src/main/resources/application.yaml | 4 ++- 5 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 src/main/java/ca/uhn/fhir/jpa/starter/ips/ZorgRotondeIpsGenerationStrategy.java diff --git a/.vscode/settings.json b/.vscode/settings.json index 5b1ccac99..f93b47c56 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,5 +5,6 @@ "**/.settings": true, "**/.factorypath": true }, - "java.compile.nullAnalysis.mode": "disabled" + "java.compile.nullAnalysis.mode": "disabled", + "java.configuration.updateBuildConfiguration": "automatic" } \ No newline at end of file diff --git a/README.md b/README.md index 94fee8382..80361d393 100644 --- a/README.md +++ b/README.md @@ -191,12 +191,16 @@ public class YourInterceptor The easiest way to run this server entirely depends on your environment requirements. At least, the following 4 ways are supported: -### Using jetty +### Using jetty (only default port 8080 possible) +[15-02-2024] We only managed to run the server through the Jetty servlet on the default port [localhost:8080](http://localhost:8080/): + ```bash mvn -Pjetty jetty:run ``` +Go to section 'Using Spring Boot' to run on a different port. + If you need to run this server on a different port (using Maven), you can change the port in the run command as follows: ```bash @@ -214,6 +218,7 @@ Server will then be accessible at http://localhost:8888/ and eg. http://localhos refuse_to_fetch_third_party_urls: false fhir_version: R4 ``` + ### Using Spring Boot with :run ```bash @@ -246,6 +251,25 @@ Server will then be accessible at http://localhost:8080/ and eg. http://localhos refuse_to_fetch_third_party_urls: false fhir_version: R4 ``` + +If you want to run on a different port, for example 8888, add the following lines to your application.yaml file: + +```yaml +server: + port: 8888 +``` +And adjust the overlay configuration in the same file: + +```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 and Google distroless ```bash mvn clean package com.google.cloud.tools:jib-maven-plugin:dockerBuild -Dimage=distroless-hapi && docker run -p 8080:8080 distroless-hapi diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java b/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java index 5385f8bd4..451c19dbb 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java @@ -24,7 +24,7 @@ public class AppProperties { private Boolean cr_enabled = false; - private Boolean ips_enabled = true; + private Boolean ips_enabled = false; private Boolean openapi_enabled = false; private Boolean mdm_enabled = false; private String mdm_rules_json_location = "mdm-rules.json"; diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/ips/ZorgRotondeIpsGenerationStrategy.java b/src/main/java/ca/uhn/fhir/jpa/starter/ips/ZorgRotondeIpsGenerationStrategy.java new file mode 100644 index 000000000..e5a26a107 --- /dev/null +++ b/src/main/java/ca/uhn/fhir/jpa/starter/ips/ZorgRotondeIpsGenerationStrategy.java @@ -0,0 +1,20 @@ +package ca.uhn.fhir.jpa.starter.ips; + +import ca.uhn.fhir.jpa.ips.strategy.DefaultIpsGenerationStrategy; + +import org.hl7.fhir.instance.model.api.IBaseResource; + +// TODO: Implement the ZorgRotondeIpsGenerationStrategy class +// public class ZorgRotondeIpsGenerationStrategy extends DefaultIpsGenerationStrategy { + +// @Override +// public IBaseResource createAuthor(){ +// return new IBaseResource() { + +// }; +// } + + +// } + + diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 7ec717f65..8068bf82f 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -5,6 +5,8 @@ management: web: exposure: include: "health,prometheus" +server: + port: 8888 spring: main: allow-circular-references: true @@ -191,7 +193,7 @@ hapi: tester: home: name: Local Tester - server_address: 'http://localhost:8080/fhir' + server_address: 'http://localhost:8888/fhir' refuse_to_fetch_third_party_urls: false fhir_version: R4 global: From 39924101a96e8b60ca419b8730769d2d84ba6ce0 Mon Sep 17 00:00:00 2001 From: Niels Wolters Date: Thu, 15 Feb 2024 15:00:40 +0100 Subject: [PATCH 3/5] clarified README instructions for running with Spring Boot --- README.md | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 80361d393..eda66d7bf 100644 --- a/README.md +++ b/README.md @@ -191,7 +191,7 @@ public class YourInterceptor The easiest way to run this server entirely depends on your environment requirements. At least, the following 4 ways are supported: -### Using jetty (only default port 8080 possible) +### Using jetty (localhost:8080) [15-02-2024] We only managed to run the server through the Jetty servlet on the default port [localhost:8080](http://localhost:8080/): ```bash @@ -236,21 +236,11 @@ Server will then be accessible at http://localhost:8080/ and eg. http://localhos fhir_version: R4 ``` -### Using Spring Boot +### Using Spring Boot (localhost:8888) ```bash 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 your 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 -``` +Server will then be accessible at http://localhost:8888/ and eg. http://localhost:8888/fhir/metadata. If you want to run on a different port, for example 8888, add the following lines to your application.yaml file: From 2feb2f9fc4d6eb0f4de8d9cf5fe95edbab57fc6d Mon Sep 17 00:00:00 2001 From: Niels Wolters Date: Thu, 15 Feb 2024 15:05:04 +0100 Subject: [PATCH 4/5] further clarification --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index eda66d7bf..1cada8707 100644 --- a/README.md +++ b/README.md @@ -242,11 +242,11 @@ mvn clean package spring-boot:repackage -Pboot && java -jar target/ROOT.war ``` Server will then be accessible at http://localhost:8888/ and eg. http://localhost:8888/fhir/metadata. -If you want to run on a different port, for example 8888, add the following lines to your application.yaml file: +If you want to run on a different port, for example 8089, change the following lines to your application.yaml file: ```yaml server: - port: 8888 + port: 8089 ``` And adjust the overlay configuration in the same file: @@ -255,7 +255,7 @@ And adjust the overlay configuration in the same file: - id: home name: Local Tester - server_address: 'http://localhost:8888/fhir' + server_address: 'http://localhost:8089/fhir' refuse_to_fetch_third_party_urls: false fhir_version: R4 ``` From 88ec918f2cace7ce6a69de3eb595c6b9d847cfff Mon Sep 17 00:00:00 2001 From: Niels Wolters Date: Thu, 15 Feb 2024 15:32:28 +0100 Subject: [PATCH 5/5] Created subclass for ZorgRotonde IPS Generation Strategy from DefaultIpsGenerationStrategy. --- .../jpa/starter/ips/IpsConfigCondition.java | 4 +-- .../jpa/starter/ips/StarterIpsConfig.java | 4 +-- .../ips/ZorgRotondeIpsGenerationStrategy.java | 32 ++++++++++++------- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/ips/IpsConfigCondition.java b/src/main/java/ca/uhn/fhir/jpa/starter/ips/IpsConfigCondition.java index c587be10f..2b3141bea 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/ips/IpsConfigCondition.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/ips/IpsConfigCondition.java @@ -8,7 +8,7 @@ public class IpsConfigCondition implements Condition { @Override public boolean matches(ConditionContext theConditionContext, AnnotatedTypeMetadata theAnnotatedTypeMetadata) { - System.out.println("\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"); + System.out.println("\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"); String property = theConditionContext.getEnvironment().getProperty("hapi.fhir.ips_enabled"); Boolean result = Boolean.parseBoolean(property); @@ -18,7 +18,7 @@ public boolean matches(ConditionContext theConditionContext, AnnotatedTypeMetada System.out.println("IpsConfigCondition.matches: false"); } - System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n"); + System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n"); return result; } } diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/ips/StarterIpsConfig.java b/src/main/java/ca/uhn/fhir/jpa/starter/ips/StarterIpsConfig.java index 0b1db60e6..09a7cce15 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/ips/StarterIpsConfig.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/ips/StarterIpsConfig.java @@ -6,7 +6,7 @@ import ca.uhn.fhir.jpa.ips.generator.IIpsGeneratorSvc; import ca.uhn.fhir.jpa.ips.generator.IpsGeneratorSvcImpl; import ca.uhn.fhir.jpa.ips.provider.IpsOperationProvider; -import ca.uhn.fhir.jpa.ips.strategy.DefaultIpsGenerationStrategy; + import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Conditional; @@ -14,7 +14,7 @@ public class StarterIpsConfig { @Bean IIpsGenerationStrategy ipsGenerationStrategy() { - return new DefaultIpsGenerationStrategy(); + return new ZorgRotondeIpsGenerationStrategy(); } @Bean diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/ips/ZorgRotondeIpsGenerationStrategy.java b/src/main/java/ca/uhn/fhir/jpa/starter/ips/ZorgRotondeIpsGenerationStrategy.java index e5a26a107..709d2d95d 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/ips/ZorgRotondeIpsGenerationStrategy.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/ips/ZorgRotondeIpsGenerationStrategy.java @@ -1,20 +1,30 @@ +/* + * Custom implementation of the default International Patient Summary (IPS) + * generation strategy defined by HAPI FHIR. + */ + package ca.uhn.fhir.jpa.starter.ips; import ca.uhn.fhir.jpa.ips.strategy.DefaultIpsGenerationStrategy; - import org.hl7.fhir.instance.model.api.IBaseResource; +import org.hl7.fhir.r4.model.*; -// TODO: Implement the ZorgRotondeIpsGenerationStrategy class -// public class ZorgRotondeIpsGenerationStrategy extends DefaultIpsGenerationStrategy { - -// @Override -// public IBaseResource createAuthor(){ -// return new IBaseResource() { - -// }; -// } +public class ZorgRotondeIpsGenerationStrategy extends DefaultIpsGenerationStrategy { + @Override + public IBaseResource createAuthor(){ + Organization organization = new Organization(); + organization + .setName("ZorgRotonde - Info Support") + .addAddress(new Address() + .addLine("Kruisboog 42") + .setCity("Veenendaal") + .setPostalCode("3905 TG") + .setCountry("NL")) + .setId(IdType.newRandomUuid()); + return organization; + } -// } +}