diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml index 5fb8224..09ec9d1 100644 --- a/.github/workflows/maven-build.yml +++ b/.github/workflows/maven-build.yml @@ -11,11 +11,13 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set up JDK 17 - uses: actions/setup-java@v1 + - uses: actions/checkout@v5 + - name: Set up JDK 25 + uses: actions/setup-java@v5 with: - java-version: 17 + distribution: 'zulu' + java-version: 25 + cache: 'maven' - name: Build with Maven env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index 91d3940..5264c94 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -20,11 +20,13 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set up JDK 17 - uses: actions/setup-java@v1 + - uses: actions/checkout@v5 + - name: Set up JDK 25 + uses: actions/setup-java@v5 with: - java-version: 17 + distribution: 'zulu' + java-version: 25 + cache: 'maven' - name: Publish with Maven env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/LICENSE b/LICENSE index fccc574..e987cdd 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2023 Heilbronn University of Applied Sciences + Copyright 2018-2025 Heilbronn University of Applied Sciences Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pom.xml b/pom.xml index 8764246..ed716fa 100644 --- a/pom.xml +++ b/pom.xml @@ -5,21 +5,28 @@ dev.dsf dsf-process-hello-world - 1.5.0.0 + 2.0.0.0 jar + 2025-12-02T17:25:00Z UTF-8 - 17 - 17 + 25 + 25 + 25 - 1.5.0 + 2.0.1 ../dsf dsf-process-hello-world - Hello World DSF process + Hello World Process Plugin https://github.com/datasharingframework/dsf-process-hello-world + + + Heilbronn University of Applied Sciences + https://www.hs-heilbronn.de + scm:git:git://github.com/datasharingframework/dsf-process-hello-world.git @@ -38,7 +45,7 @@ dev.dsf - dsf-bpe-process-api-v1 + dsf-bpe-process-api-v2 ${dsf.version} provided @@ -46,24 +53,11 @@ org.slf4j slf4j-api - 2.0.12 + 2.0.17 provided - - dev.dsf - dsf-bpe-process-api-v1 - ${dsf.version} - test - test-jar - - - dev.dsf - dsf-fhir-validation - ${dsf.version} - test - junit junit @@ -73,31 +67,60 @@ org.apache.logging.log4j log4j-slf4j2-impl - 2.22.1 + 2.25.2 + test + + + + dev.dsf + dsf-fhir-validation + ${dsf.version} test + + + src/main/resources + false + + plugin.properties + + + + src/main/resources + true + + plugin.properties + + + + org.apache.maven.plugins maven-compiler-plugin - 3.11.0 + 3.14.1 + + + org.apache.maven.plugins + maven-resources-plugin + 3.4.0 - ${compileSource} - ${compileTarget} + UTF-8 org.apache.maven.plugins maven-surefire-plugin - 3.2.3 + 3.5.4 org.apache.maven.plugins maven-jar-plugin - 3.3.0 + + 3.4.2 @@ -111,25 +134,20 @@ - - org.apache.maven.plugins - maven-shade-plugin - 3.5.1 - org.apache.maven.plugins maven-dependency-plugin - 3.6.1 + 3.9.0 org.apache.maven.plugins maven-clean-plugin - 3.3.2 + 3.5.0 org.codehaus.mojo buildnumber-maven-plugin - 3.2.0 + 3.2.1 validate @@ -145,7 +163,7 @@ net.revelc.code.formatter formatter-maven-plugin - 2.23.0 + 2.29.0 eclipse-formatter-config.xml @@ -153,7 +171,7 @@ net.revelc.code impsort-maven-plugin - 1.9.0 + 1.12.0 17 java.,javax.,org.,com. @@ -162,22 +180,78 @@ dev.dsf - dsf-tools-documentation-generator + dsf-maven-plugin ${dsf.version} - generate + generate-config-doc - - dev.dsf.bpe - + + dev.dsf.bpe + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.6.2 + + + enforce-maven + + enforce + + + + + 3.6.3 + + + + commons-logging:commons-logging + + + + true + + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + dev.dsf + dsf-maven-plugin + ${dsf.version} + + generate-config-doc + + + + + + + + + + + + @@ -191,34 +265,6 @@ - - - github - GitHub DSF Apache Maven Packages - https://maven.pkg.github.com/datasharingframework/dsf - - false - - - true - - - - - - - github - GitHub DSF Apache Maven Packages - https://maven.pkg.github.com/datasharingframework/dsf - - false - - - true - - - - validate-and-check @@ -293,7 +339,7 @@ maven-dependency-plugin - copy-process-plugin-to-docker-test-setup + copy-process-plugin-to-docker-dev-setup package copy @@ -306,11 +352,11 @@ ${project.version} - ${dsf.location}/dsf-docker-test-setup/bpe/process + ${dsf.location}/dsf-docker-dev-setup/bpe/process - copy-process-plugin-to-docker-test-setup-3dic-ttp/dic1 + copy-process-plugin-to-docker-dev-setup-3dic-ttp/dic1 package copy @@ -323,7 +369,7 @@ ${project.version} - ${dsf.location}/dsf-docker-test-setup-3dic-ttp/dic1/bpe/process + ${dsf.location}/dsf-docker-dev-setup-3dic-ttp/dic1/bpe/process @@ -334,14 +380,14 @@ - ${dsf.location}/dsf-docker-test-setup/bpe/process + ${dsf.location}/dsf-docker-dev-setup/bpe/process ${project.artifactId}-${project.version}.jar false - ${dsf.location}/dsf-docker-test-setup-3dic-ttp/dic1/bpe/process + ${dsf.location}/dsf-docker-dev-setup-3dic-ttp/dic1/bpe/process ${project.artifactId}-${project.version}.jar diff --git a/src/main/java/dev/dsf/bpe/ConstantsHelloWorld.java b/src/main/java/dev/dsf/bpe/ConstantsHelloWorld.java deleted file mode 100644 index bc7cf35..0000000 --- a/src/main/java/dev/dsf/bpe/ConstantsHelloWorld.java +++ /dev/null @@ -1,20 +0,0 @@ -package dev.dsf.bpe; - -public interface ConstantsHelloWorld -{ - String PROCESS_NAME_HELLO_WORLD = "helloWorld"; - String PROCESS_NAME_FULL_HELLO_WORLD = "dsfdev_" + PROCESS_NAME_HELLO_WORLD; - - String PROCESS_NAME_HELLO_USER = "helloUser"; - String PROCESS_NAME_FULL_HELLO_USER = "dsfdev_" + PROCESS_NAME_HELLO_USER; - - String PROCESS_DSF_URI_BASE = "http://dsf.dev/bpe/Process/"; - - String PROFILE_DSF_TASK_TASK_HELLO_WORLD = "http://dsf.dev/fhir/StructureDefinition/task-hello-world"; - String PROFILE_DSF_TASK_HELLO_WORLD_PROCESS_URI = PROCESS_DSF_URI_BASE + PROCESS_NAME_HELLO_WORLD; - String PROFILE_DSF_TASK_HELLO_WORLD_MESSAGE_NAME = "helloWorld"; - - String PROFILE_DSF_TASK_TASK_HELLO_USER = "http://dsf.dev/fhir/StructureDefinition/task-hello-user"; - String PROFILE_DSF_TASK_HELLO_USER_PROCESS_URI = PROCESS_DSF_URI_BASE + PROCESS_NAME_HELLO_USER; - String PROFILE_DSF_TASK_HELLO_USER_MESSAGE_NAME = "helloUser"; -} diff --git a/src/main/java/dev/dsf/bpe/HelloWorldProcessPluginDefinition.java b/src/main/java/dev/dsf/bpe/HelloWorldProcessPluginDefinition.java index 25618c2..18a4099 100644 --- a/src/main/java/dev/dsf/bpe/HelloWorldProcessPluginDefinition.java +++ b/src/main/java/dev/dsf/bpe/HelloWorldProcessPluginDefinition.java @@ -1,36 +1,13 @@ package dev.dsf.bpe; -import java.time.LocalDate; -import java.util.Arrays; import java.util.List; import java.util.Map; import dev.dsf.bpe.spring.config.HelloWorldConfig; -import dev.dsf.bpe.v1.ProcessPluginDefinition; +import dev.dsf.bpe.v2.AbstractProcessPluginDefinition; -public class HelloWorldProcessPluginDefinition implements ProcessPluginDefinition +public class HelloWorldProcessPluginDefinition extends AbstractProcessPluginDefinition { - public static final String VERSION = "1.5.0.0"; - public static final LocalDate RELEASE_DATE = LocalDate.of(2024, 2, 21); - - @Override - public String getName() - { - return "dsf-process-hello-world"; - } - - @Override - public String getVersion() - { - return VERSION; - } - - @Override - public LocalDate getReleaseDate() - { - return RELEASE_DATE; - } - @Override public List getProcessModels() { @@ -61,9 +38,7 @@ public Map> getFhirResourcesByProcessId() var vHelloWorld = "fhir/ValueSet/dsf-hello-world.xml"; - return Map.of(ConstantsHelloWorld.PROCESS_NAME_FULL_HELLO_USER, - Arrays.asList(aHelloUser, qHelloWorld, sHelloUser, tHelloUser), - ConstantsHelloWorld.PROCESS_NAME_FULL_HELLO_WORLD, - Arrays.asList(aHelloWorld, cHelloWorld, sHelloWorld, tHelloWorld, vHelloWorld)); + return Map.of("dsfdev_helloUser", List.of(aHelloUser, qHelloWorld, sHelloUser, tHelloUser), "dsfdev_helloWorld", + List.of(aHelloWorld, cHelloWorld, sHelloWorld, tHelloWorld, vHelloWorld)); } } diff --git a/src/main/java/dev/dsf/bpe/listener/ProcessPluginDeploymentListenerImpl.java b/src/main/java/dev/dsf/bpe/listener/ProcessPluginDeploymentListenerImpl.java new file mode 100644 index 0000000..cdb4d7a --- /dev/null +++ b/src/main/java/dev/dsf/bpe/listener/ProcessPluginDeploymentListenerImpl.java @@ -0,0 +1,19 @@ +package dev.dsf.bpe.listener; + +import java.util.List; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import dev.dsf.bpe.v2.ProcessPluginDeploymentListener; + +public class ProcessPluginDeploymentListenerImpl implements ProcessPluginDeploymentListener +{ + private static final Logger logger = LoggerFactory.getLogger(ProcessPluginDeploymentListenerImpl.class); + + @Override + public void onProcessesDeployed(List processes) + { + logger.info("Deployed HelloWorld Processes: {}", processes); + } +} diff --git a/src/main/java/dev/dsf/bpe/service/HelloWorld.java b/src/main/java/dev/dsf/bpe/service/HelloWorld.java index 0c372bd..c85298e 100644 --- a/src/main/java/dev/dsf/bpe/service/HelloWorld.java +++ b/src/main/java/dev/dsf/bpe/service/HelloWorld.java @@ -1,25 +1,20 @@ package dev.dsf.bpe.service; -import org.camunda.bpm.engine.delegate.DelegateExecution; import org.hl7.fhir.r4.model.Task; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import dev.dsf.bpe.v1.ProcessPluginApi; -import dev.dsf.bpe.v1.activity.AbstractServiceDelegate; -import dev.dsf.bpe.v1.variables.Variables; +import dev.dsf.bpe.v2.ProcessPluginApi; +import dev.dsf.bpe.v2.activity.ServiceTask; +import dev.dsf.bpe.v2.error.ErrorBoundaryEvent; +import dev.dsf.bpe.v2.variables.Variables; -public class HelloWorld extends AbstractServiceDelegate +public class HelloWorld implements ServiceTask { private static final Logger logger = LoggerFactory.getLogger(HelloWorld.class); - public HelloWorld(ProcessPluginApi api) - { - super(api); - } - @Override - protected void doExecute(DelegateExecution execution, Variables variables) + public void execute(ProcessPluginApi api, Variables variables) throws ErrorBoundaryEvent, Exception { Task task = variables.getStartTask(); logger.info("Hello World from organization with identifier '{}'", diff --git a/src/main/java/dev/dsf/bpe/service/LogUserTaskResponse.java b/src/main/java/dev/dsf/bpe/service/LogUserTaskResponse.java index 2a7f365..259721e 100644 --- a/src/main/java/dev/dsf/bpe/service/LogUserTaskResponse.java +++ b/src/main/java/dev/dsf/bpe/service/LogUserTaskResponse.java @@ -1,43 +1,19 @@ package dev.dsf.bpe.service; -import java.util.Objects; - -import org.camunda.bpm.engine.delegate.DelegateExecution; import org.hl7.fhir.r4.model.QuestionnaireResponse; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import ca.uhn.fhir.context.FhirContext; -import dev.dsf.bpe.v1.ProcessPluginApi; -import dev.dsf.bpe.v1.activity.AbstractServiceDelegate; -import dev.dsf.bpe.v1.variables.Variables; +import dev.dsf.bpe.v2.ProcessPluginApi; +import dev.dsf.bpe.v2.activity.ServiceTask; +import dev.dsf.bpe.v2.error.ErrorBoundaryEvent; +import dev.dsf.bpe.v2.variables.Variables; -public class LogUserTaskResponse extends AbstractServiceDelegate implements InitializingBean +public class LogUserTaskResponse implements ServiceTask { - private static final Logger logger = LoggerFactory.getLogger(LogUserTaskResponse.class); - - private final FhirContext fhirContext; - - public LogUserTaskResponse(ProcessPluginApi api, FhirContext fhirContext) - { - super(api); - this.fhirContext = fhirContext; - } - - @Override - public void afterPropertiesSet() throws Exception - { - super.afterPropertiesSet(); - Objects.requireNonNull(fhirContext, "fhirContext"); - } - @Override - protected void doExecute(DelegateExecution execution, Variables variables) + public void execute(ProcessPluginApi api, Variables variables) throws ErrorBoundaryEvent, Exception { QuestionnaireResponse questionnaireResponse = variables.getLatestReceivedQuestionnaireResponse(); - logger.info("Completed QuestionnaireResponse: {}", - fhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(questionnaireResponse)); + api.getDataLogger().log("Completed QuestionnaireResponse", questionnaireResponse); } } diff --git a/src/main/java/dev/dsf/bpe/spring/config/HelloWorldConfig.java b/src/main/java/dev/dsf/bpe/spring/config/HelloWorldConfig.java index 723e049..257c2cf 100755 --- a/src/main/java/dev/dsf/bpe/spring/config/HelloWorldConfig.java +++ b/src/main/java/dev/dsf/bpe/spring/config/HelloWorldConfig.java @@ -1,36 +1,26 @@ package dev.dsf.bpe.spring.config; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Scope; -import ca.uhn.fhir.context.FhirContext; +import dev.dsf.bpe.listener.ProcessPluginDeploymentListenerImpl; import dev.dsf.bpe.service.HelloWorld; import dev.dsf.bpe.service.LogUserTaskResponse; -import dev.dsf.bpe.v1.ProcessPluginApi; +import dev.dsf.bpe.v2.ProcessPluginDeploymentListener; +import dev.dsf.bpe.v2.spring.ActivityPrototypeBeanCreator; @Configuration public class HelloWorldConfig { - @Autowired - private ProcessPluginApi api; - - @Autowired - private FhirContext fhirContext; - @Bean - @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public HelloWorld helloWorld() + public static ActivityPrototypeBeanCreator activityPrototypeBeanCreator() { - return new HelloWorld(api); + return new ActivityPrototypeBeanCreator(HelloWorld.class, LogUserTaskResponse.class); } @Bean - @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public LogUserTaskResponse logUserTaskResponse() + public ProcessPluginDeploymentListener deploymentListener() { - return new LogUserTaskResponse(api, fhirContext); + return new ProcessPluginDeploymentListenerImpl(); } } diff --git a/src/main/java/dev/dsf/bpe/variable/README.md b/src/main/java/dev/dsf/bpe/variable/README.md deleted file mode 100644 index ab241aa..0000000 --- a/src/main/java/dev/dsf/bpe/variable/README.md +++ /dev/null @@ -1 +0,0 @@ -`variable` package typically used for implementing custom BPMN variable serializers \ No newline at end of file diff --git a/src/main/resources/META-INF/services/dev.dsf.bpe.v1.ProcessPluginDefinition b/src/main/resources/META-INF/services/dev.dsf.bpe.v2.ProcessPluginDefinition similarity index 100% rename from src/main/resources/META-INF/services/dev.dsf.bpe.v1.ProcessPluginDefinition rename to src/main/resources/META-INF/services/dev.dsf.bpe.v2.ProcessPluginDefinition diff --git a/src/main/resources/bpe/hello-user.bpmn b/src/main/resources/bpe/hello-user.bpmn index f77e90c..1b7528d 100644 --- a/src/main/resources/bpe/hello-user.bpmn +++ b/src/main/resources/bpe/hello-user.bpmn @@ -1,5 +1,5 @@ - + @@ -11,6 +11,22 @@ + + + + DIC_USER + + + http://dsf.dev/fhir/CodeSystem/hello-world + + + questionnaire-response-reference + + + #{version} + + + SequenceFlow_0bbhq2r Flow_00nx7hv @@ -23,21 +39,12 @@ - - - - - - - - - - - - + + + @@ -46,9 +53,18 @@ - - - + + + + + + + + + + + + diff --git a/src/main/resources/fhir/ActivityDefinition/dsf-hello-user.xml b/src/main/resources/fhir/ActivityDefinition/dsf-hello-user.xml index 8aa641f..44b7162 100644 --- a/src/main/resources/fhir/ActivityDefinition/dsf-hello-user.xml +++ b/src/main/resources/fhir/ActivityDefinition/dsf-hello-user.xml @@ -1,5 +1,6 @@ + @@ -23,7 +24,7 @@ - + @@ -53,7 +54,7 @@ - + diff --git a/src/main/resources/fhir/ActivityDefinition/dsf-hello-world.xml b/src/main/resources/fhir/ActivityDefinition/dsf-hello-world.xml index ff7f1f1..3c6cfe7 100644 --- a/src/main/resources/fhir/ActivityDefinition/dsf-hello-world.xml +++ b/src/main/resources/fhir/ActivityDefinition/dsf-hello-world.xml @@ -1,5 +1,6 @@ + @@ -23,7 +24,7 @@ - + @@ -53,7 +54,7 @@ - + diff --git a/src/main/resources/fhir/CodeSystem/dsf-hello-world.xml b/src/main/resources/fhir/CodeSystem/dsf-hello-world.xml index 4b8a18a..c90bcba 100644 --- a/src/main/resources/fhir/CodeSystem/dsf-hello-world.xml +++ b/src/main/resources/fhir/CodeSystem/dsf-hello-world.xml @@ -1,5 +1,6 @@ + @@ -86,4 +87,14 @@ - \ No newline at end of file + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/fhir/Questionnaire/dsf-hello-user.xml b/src/main/resources/fhir/Questionnaire/dsf-hello-user.xml index f298789..87bdf6a 100644 --- a/src/main/resources/fhir/Questionnaire/dsf-hello-user.xml +++ b/src/main/resources/fhir/Questionnaire/dsf-hello-user.xml @@ -1,93 +1,106 @@ - + - - + + - + - + - + - + - - - - + + + + - - - - + + + + - - - + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/fhir/StructureDefinition/dsf-task-hello-user.xml b/src/main/resources/fhir/StructureDefinition/dsf-task-hello-user.xml index d961a05..9899327 100644 --- a/src/main/resources/fhir/StructureDefinition/dsf-task-hello-user.xml +++ b/src/main/resources/fhir/StructureDefinition/dsf-task-hello-user.xml @@ -1,55 +1,103 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/fhir/StructureDefinition/dsf-task-hello-world.xml b/src/main/resources/fhir/StructureDefinition/dsf-task-hello-world.xml index 40a6b57..beb3678 100644 --- a/src/main/resources/fhir/StructureDefinition/dsf-task-hello-world.xml +++ b/src/main/resources/fhir/StructureDefinition/dsf-task-hello-world.xml @@ -1,548 +1,654 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/fhir/Task/dsf-task-hello-user.xml b/src/main/resources/fhir/Task/dsf-task-hello-user.xml index a5818d8..2c8f384 100644 --- a/src/main/resources/fhir/Task/dsf-task-hello-user.xml +++ b/src/main/resources/fhir/Task/dsf-task-hello-user.xml @@ -1,38 +1,38 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/fhir/Task/dsf-task-hello-world.xml b/src/main/resources/fhir/Task/dsf-task-hello-world.xml index 1db9e48..2aa7205 100644 --- a/src/main/resources/fhir/Task/dsf-task-hello-world.xml +++ b/src/main/resources/fhir/Task/dsf-task-hello-world.xml @@ -1,169 +1,198 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/fhir/ValueSet/dsf-hello-world.xml b/src/main/resources/fhir/ValueSet/dsf-hello-world.xml index 4aba52b..e2edf98 100644 --- a/src/main/resources/fhir/ValueSet/dsf-hello-world.xml +++ b/src/main/resources/fhir/ValueSet/dsf-hello-world.xml @@ -1,5 +1,6 @@ + diff --git a/src/main/resources/plugin.properties b/src/main/resources/plugin.properties new file mode 100644 index 0000000..4d0ef3c --- /dev/null +++ b/src/main/resources/plugin.properties @@ -0,0 +1,6 @@ +release-date=${project.build.outputTimestamp} +version=${project.version} +name=${project.artifactId} +title=${project.description} +publisher=${project.organization.name} +publisher-email=dsf-gecko@hs-heilbronn.de \ No newline at end of file diff --git a/src/test/java/dev/dsf/bpe/HelloProcessPluginDefinitionTest.java b/src/test/java/dev/dsf/bpe/HelloProcessPluginDefinitionTest.java index d637a37..1a9f373 100644 --- a/src/test/java/dev/dsf/bpe/HelloProcessPluginDefinitionTest.java +++ b/src/test/java/dev/dsf/bpe/HelloProcessPluginDefinitionTest.java @@ -8,7 +8,7 @@ import org.junit.Test; -import dev.dsf.bpe.v1.ProcessPluginDefinition; +import dev.dsf.bpe.v2.ProcessPluginDefinition; public class HelloProcessPluginDefinitionTest { @@ -18,11 +18,11 @@ public void testResourceLoading() ProcessPluginDefinition definition = new HelloWorldProcessPluginDefinition(); Map> resourcesByProcessId = definition.getFhirResourcesByProcessId(); - var helloWorld = resourcesByProcessId.get(ConstantsHelloWorld.PROCESS_NAME_FULL_HELLO_WORLD); + var helloWorld = resourcesByProcessId.get("dsfdev_helloWorld"); assertNotNull(helloWorld); assertEquals(5, helloWorld.stream().filter(this::exists).count()); - var helloUser = resourcesByProcessId.get(ConstantsHelloWorld.PROCESS_NAME_FULL_HELLO_USER); + var helloUser = resourcesByProcessId.get("dsfdev_helloUser"); assertNotNull(helloUser); assertEquals(4, helloUser.stream().filter(this::exists).count()); } diff --git a/src/test/java/dev/dsf/bpe/start/HelloUserExampleStarter.java b/src/test/java/dev/dsf/bpe/start/HelloUserExampleStarter.java deleted file mode 100644 index 8087719..0000000 --- a/src/test/java/dev/dsf/bpe/start/HelloUserExampleStarter.java +++ /dev/null @@ -1,47 +0,0 @@ -package dev.dsf.bpe.start; - -import java.util.Date; - -import org.hl7.fhir.r4.model.ResourceType; -import org.hl7.fhir.r4.model.StringType; -import org.hl7.fhir.r4.model.Task; - -import dev.dsf.bpe.ConstantsHelloWorld; -import dev.dsf.bpe.HelloWorldProcessPluginDefinition; -import dev.dsf.bpe.v1.constants.CodeSystems; -import dev.dsf.bpe.v1.constants.NamingSystems; - -public class HelloUserExampleStarter -{ - // Environment variable "DSF_CLIENT_CERTIFICATE_PATH" or args[0]: the path to the client-certificate - // dsf/dsf-tools/dsf-tools-test-data-generator/cert/Webbrowser_Test_User/Webbrowser_Test_User_certificate.p12 - // Environment variable "DSF_CLIENT_CERTIFICATE_PASSWORD" or args[1]: the password of the client-certificate - // password - public static void main(String[] args) throws Exception - { - ExampleStarter.forServer(args, ConstantsExampleStarters.DIC_1_FHIR_BASE_URL).startWith(task()); - } - - private static Task task() - { - var def = new HelloWorldProcessPluginDefinition(); - - Task task = new Task(); - task.getMeta().addProfile(ConstantsHelloWorld.PROFILE_DSF_TASK_TASK_HELLO_USER); - task.setInstantiatesCanonical( - ConstantsHelloWorld.PROFILE_DSF_TASK_HELLO_USER_PROCESS_URI + "|" + def.getResourceVersion()); - task.setStatus(Task.TaskStatus.REQUESTED); - task.setIntent(Task.TaskIntent.ORDER); - task.setAuthoredOn(new Date()); - task.getRequester().setType(ResourceType.Organization.name()).setIdentifier(NamingSystems.OrganizationIdentifier - .withValue(ConstantsExampleStarters.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER_VALUE_DIC_1)); - task.getRestriction().addRecipient().setType(ResourceType.Organization.name()) - .setIdentifier(NamingSystems.OrganizationIdentifier - .withValue(ConstantsExampleStarters.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER_VALUE_DIC_1)); - - task.addInput().setValue(new StringType(ConstantsHelloWorld.PROFILE_DSF_TASK_HELLO_USER_MESSAGE_NAME)).getType() - .addCoding(CodeSystems.BpmnMessage.messageName()); - - return task; - } -} diff --git a/src/test/java/dev/dsf/bpe/start/HelloWorldExampleStarter.java b/src/test/java/dev/dsf/bpe/start/HelloWorldExampleStarter.java deleted file mode 100644 index 18bf380..0000000 --- a/src/test/java/dev/dsf/bpe/start/HelloWorldExampleStarter.java +++ /dev/null @@ -1,47 +0,0 @@ -package dev.dsf.bpe.start; - -import java.util.Date; - -import org.hl7.fhir.r4.model.ResourceType; -import org.hl7.fhir.r4.model.StringType; -import org.hl7.fhir.r4.model.Task; - -import dev.dsf.bpe.ConstantsHelloWorld; -import dev.dsf.bpe.HelloWorldProcessPluginDefinition; -import dev.dsf.bpe.v1.constants.CodeSystems; -import dev.dsf.bpe.v1.constants.NamingSystems; - -public class HelloWorldExampleStarter -{ - // Environment variable "DSF_CLIENT_CERTIFICATE_PATH" or args[0]: the path to the client-certificate - // dsf/dsf-tools/dsf-tools-test-data-generator/cert/Webbrowser_Test_User/Webbrowser_Test_User_certificate.p12 - // Environment variable "DSF_CLIENT_CERTIFICATE_PASSWORD" or args[1]: the password of the client-certificate - // password - public static void main(String[] args) throws Exception - { - ExampleStarter.forServer(args, ConstantsExampleStarters.DIC_1_FHIR_BASE_URL).startWith(task()); - } - - private static Task task() - { - var def = new HelloWorldProcessPluginDefinition(); - - Task task = new Task(); - task.getMeta().addProfile(ConstantsHelloWorld.PROFILE_DSF_TASK_TASK_HELLO_WORLD); - task.setInstantiatesCanonical( - ConstantsHelloWorld.PROFILE_DSF_TASK_HELLO_WORLD_PROCESS_URI + "|" + def.getResourceVersion()); - task.setStatus(Task.TaskStatus.REQUESTED); - task.setIntent(Task.TaskIntent.ORDER); - task.setAuthoredOn(new Date()); - task.getRequester().setType(ResourceType.Organization.name()).setIdentifier(NamingSystems.OrganizationIdentifier - .withValue(ConstantsExampleStarters.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER_VALUE_DIC_1)); - task.getRestriction().addRecipient().setType(ResourceType.Organization.name()) - .setIdentifier(NamingSystems.OrganizationIdentifier - .withValue(ConstantsExampleStarters.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER_VALUE_DIC_1)); - - task.addInput().setValue(new StringType(ConstantsHelloWorld.PROFILE_DSF_TASK_HELLO_WORLD_MESSAGE_NAME)) - .getType().addCoding(CodeSystems.BpmnMessage.messageName()); - - return task; - } -} diff --git a/src/test/java/dev/dsf/fhir/profile/ActivityDefinitionProfileTest.java b/src/test/java/dev/dsf/fhir/profile/ActivityDefinitionProfileTest.java index 9df9502..7191cb6 100644 --- a/src/test/java/dev/dsf/fhir/profile/ActivityDefinitionProfileTest.java +++ b/src/test/java/dev/dsf/fhir/profile/ActivityDefinitionProfileTest.java @@ -1,7 +1,6 @@ package dev.dsf.fhir.profile; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import java.nio.file.Paths; import java.util.Arrays; @@ -15,8 +14,6 @@ import ca.uhn.fhir.validation.ResultSeverityEnum; import ca.uhn.fhir.validation.ValidationResult; import dev.dsf.bpe.HelloWorldProcessPluginDefinition; -import dev.dsf.fhir.authorization.process.ProcessAuthorizationHelper; -import dev.dsf.fhir.authorization.process.ProcessAuthorizationHelperImpl; import dev.dsf.fhir.validation.ResourceValidator; import dev.dsf.fhir.validation.ResourceValidatorImpl; import dev.dsf.fhir.validation.ValidationSupportRule; @@ -25,34 +22,40 @@ public class ActivityDefinitionProfileTest { private static final Logger logger = LoggerFactory.getLogger(ActivityDefinitionProfileTest.class); + private static final HelloWorldProcessPluginDefinition pluginDefinition = new HelloWorldProcessPluginDefinition(); + @ClassRule - public static final ValidationSupportRule validationRule = new ValidationSupportRule( - HelloWorldProcessPluginDefinition.VERSION, HelloWorldProcessPluginDefinition.RELEASE_DATE, - Arrays.asList("dsf-activity-definition-1.0.0.xml", "dsf-extension-process-authorization-1.0.0.xml", - "dsf-extension-process-authorization-organization-1.0.0.xml", - "dsf-extension-process-authorization-organization-practitioner-1.0.0.xml", - "dsf-extension-process-authorization-parent-organization-role-1.0.0.xml", - "dsf-extension-process-authorization-parent-organization-role-practitioner-1.0.0.xml", - "dsf-extension-process-authorization-practitioner-1.0.0.xml", - "dsf-coding-process-authorization-local-all-1.0.0.xml", - "dsf-coding-process-authorization-local-all-practitioner-1.0.0.xml", - "dsf-coding-process-authorization-local-organization-1.0.0.xml", - "dsf-coding-process-authorization-local-organization-practitioner-1.0.0.xml", - "dsf-coding-process-authorization-local-parent-organization-role-1.0.0.xml", - "dsf-coding-process-authorization-local-parent-organization-role-practitioner-1.0.0.xml", - "dsf-coding-process-authorization-remote-all-1.0.0.xml", - "dsf-coding-process-authorization-remote-parent-organization-role-1.0.0.xml", - "dsf-coding-process-authorization-remote-organization-1.0.0.xml"), - Arrays.asList("dsf-organization-role-1.0.0.xml", "dsf-practitioner-role-1.0.0.xml", - "dsf-process-authorization-1.0.0.xml", "dsf-read-access-tag-1.0.0.xml", "dsf-hello-world.xml"), - Arrays.asList("dsf-organization-role-1.0.0.xml", "dsf-practitioner-role-1.0.0.xml", - "dsf-process-authorization-recipient-1.0.0.xml", "dsf-process-authorization-requester-1.0.0.xml", - "dsf-read-access-tag-1.0.0.xml", "dsf-hello-world.xml")); + public static final ValidationSupportRule validationRule = new ValidationSupportRule(pluginDefinition.getVersion(), + pluginDefinition.getReleaseDate(), + Arrays.asList("dsf-extension-read-access-organization-2.0.0.xml", + "dsf-extension-read-access-parent-organization-role-2.0.0.xml", "dsf-meta-2.0.0.xml", + "dsf-extension-process-authorization-2.0.0.xml", + "dsf-extension-process-authorization-practitioner-2.0.0.xml", + "dsf-extension-process-authorization-organization-2.0.0.xml", + "dsf-extension-process-authorization-organization-practitioner-2.0.0.xml", + "dsf-extension-process-authorization-parent-organization-role-2.0.0.xml", + "dsf-extension-process-authorization-parent-organization-role-practitioner-2.0.0.xml", + "dsf-coding-process-authorization-local-all-2.0.0.xml", + "dsf-coding-process-authorization-local-all-practitioner-2.0.0.xml", + "dsf-coding-process-authorization-local-organization-2.0.0.xml", + "dsf-coding-process-authorization-local-organization-practitioner-2.0.0.xml", + "dsf-coding-process-authorization-local-parent-organization-role-2.0.0.xml", + "dsf-coding-process-authorization-local-parent-organization-role-practitioner-2.0.0.xml", + "dsf-coding-process-authorization-remote-all-2.0.0.xml", + "dsf-coding-process-authorization-remote-organization-2.0.0.xml", + "dsf-coding-process-authorization-remote-parent-organization-role-2.0.0.xml", + "dsf-activity-definition-2.0.0.xml"), + Arrays.asList("dsf-organization-role-2.0.0.xml", "dsf-practitioner-role-2.0.0.xml", + "dsf-process-authorization-2.0.0.xml", "dsf-read-access-tag-2.0.0.xml", "dsf-hello-world.xml"), + Arrays.asList("dsf-organization-role-2.0.0.xml", "dsf-practitioner-role-2.0.0.xml", + "dsf-process-authorization-recipient-2.0.0.xml", "dsf-process-authorization-requester-2.0.0.xml", + "dsf-read-access-tag-2.0.0.xml", "dsf-hello-world.xml")); private final ResourceValidator resourceValidator = new ResourceValidatorImpl(validationRule.getFhirContext(), validationRule.getValidationSupport()); - private final ProcessAuthorizationHelper processAuthorizationHelper = new ProcessAuthorizationHelperImpl(); + // TODO + // private final ProcessAuthorizationHelper processAuthorizationHelper = new ProcessAuthorizationHelperImpl(); @Test public void testHelloWorldValid() throws Exception @@ -66,8 +69,9 @@ public void testHelloWorldValid() throws Exception assertEquals(0, result.getMessages().stream().filter(m -> ResultSeverityEnum.ERROR.equals(m.getSeverity()) || ResultSeverityEnum.FATAL.equals(m.getSeverity())).count()); - assertTrue(processAuthorizationHelper.isValid(ad, taskProfile -> true, practitionerRole -> true, - orgIdentifier -> true, organizationRole -> true)); + // TODO + // assertTrue(processAuthorizationHelper.isValid(ad, taskProfile -> true, practitionerRole -> true, + // orgIdentifier -> true, organizationRole -> true)); } @Test @@ -82,7 +86,8 @@ public void testHelloUserValid() throws Exception assertEquals(0, result.getMessages().stream().filter(m -> ResultSeverityEnum.ERROR.equals(m.getSeverity()) || ResultSeverityEnum.FATAL.equals(m.getSeverity())).count()); - assertTrue(processAuthorizationHelper.isValid(ad, taskProfile -> true, practitionerRole -> true, - orgIdentifier -> true, organizationRole -> true)); + // TODO + // assertTrue(processAuthorizationHelper.isValid(ad, taskProfile -> true, practitionerRole -> true, + // orgIdentifier -> true, organizationRole -> true)); } } diff --git a/src/test/java/dev/dsf/fhir/profile/TaskProfileTest.java b/src/test/java/dev/dsf/fhir/profile/TaskProfileTest.java index 200b798..72b4bfb 100644 --- a/src/test/java/dev/dsf/fhir/profile/TaskProfileTest.java +++ b/src/test/java/dev/dsf/fhir/profile/TaskProfileTest.java @@ -2,8 +2,10 @@ import static org.junit.Assert.assertEquals; +import java.nio.file.Paths; import java.util.Arrays; import java.util.Date; +import java.util.UUID; import org.hl7.fhir.r4.model.BooleanType; import org.hl7.fhir.r4.model.Coding; @@ -13,6 +15,7 @@ import org.hl7.fhir.r4.model.Identifier; import org.hl7.fhir.r4.model.InstantType; import org.hl7.fhir.r4.model.IntegerType; +import org.hl7.fhir.r4.model.Quantity; import org.hl7.fhir.r4.model.Reference; import org.hl7.fhir.r4.model.ResourceType; import org.hl7.fhir.r4.model.StringType; @@ -28,10 +31,9 @@ import ca.uhn.fhir.validation.ResultSeverityEnum; import ca.uhn.fhir.validation.ValidationResult; -import dev.dsf.bpe.ConstantsHelloWorld; import dev.dsf.bpe.HelloWorldProcessPluginDefinition; -import dev.dsf.bpe.v1.constants.CodeSystems; -import dev.dsf.bpe.v1.constants.NamingSystems; +import dev.dsf.bpe.v2.constants.CodeSystems; +import dev.dsf.bpe.v2.constants.NamingSystems; import dev.dsf.fhir.validation.ResourceValidator; import dev.dsf.fhir.validation.ResourceValidatorImpl; import dev.dsf.fhir.validation.ValidationSupportRule; @@ -45,9 +47,9 @@ public class TaskProfileTest @ClassRule public static final ValidationSupportRule validationRule = new ValidationSupportRule(def.getResourceVersion(), def.getReleaseDate(), - Arrays.asList("dsf-task-base-1.0.0.xml", "dsf-task-hello-world.xml", "dsf-task-hello-user.xml"), - Arrays.asList("dsf-read-access-tag-1.0.0.xml", "dsf-bpmn-message-1.0.0.xml", "dsf-hello-world.xml"), - Arrays.asList("dsf-read-access-tag-1.0.0.xml", "dsf-bpmn-message-1.0.0.xml", "dsf-hello-world.xml")); + Arrays.asList("dsf-task-2.0.0.xml", "dsf-task-hello-world.xml", "dsf-task-hello-user.xml"), + Arrays.asList("dsf-read-access-tag-2.0.0.xml", "dsf-bpmn-message-2.0.0.xml", "dsf-hello-world.xml"), + Arrays.asList("dsf-read-access-tag-2.0.0.xml", "dsf-bpmn-message-2.0.0.xml", "dsf-hello-world.xml")); private ResourceValidator resourceValidator = new ResourceValidatorImpl(validationRule.getFhirContext(), validationRule.getValidationSupport()); @@ -69,38 +71,51 @@ public void testMaximalTaskHelloWorldValid() { Task task = createValidTaskHelloWorld(); - task.addInput().setValue(new DecimalType(1.1)).getType().addCoding( - new Coding().setSystem("http://dsf.dev/fhir/CodeSystem/hello-world").setCode("decimal-example")); - task.addInput().setValue(new BooleanType(true)).getType().addCoding( - new Coding().setSystem("http://dsf.dev/fhir/CodeSystem/hello-world").setCode("boolean-example")); - task.addInput().setValue(new DateType(new Date())).getType().addCoding( - new Coding().setSystem("http://dsf.dev/fhir/CodeSystem/hello-world").setCode("date-example")); - task.addInput().setValue(new TimeType("10:00:00")).getType().addCoding( - new Coding().setSystem("http://dsf.dev/fhir/CodeSystem/hello-world").setCode("time-example")); - task.addInput().setValue(new DateTimeType(new Date())).getType().addCoding( - new Coding().setSystem("http://dsf.dev/fhir/CodeSystem/hello-world").setCode("date-time-example")); - task.addInput().setValue(new InstantType(new Date())).getType().addCoding( - new Coding().setSystem("http://dsf.dev/fhir/CodeSystem/hello-world").setCode("instant-example")); + task.addInput().setValue(new DecimalType(1.1)).getType() + .addCoding(new Coding().setSystem("http://dsf.dev/fhir/CodeSystem/hello-world") + .setCode("decimal-example").setVersion(def.getResourceVersion())); + task.addInput().setValue(new BooleanType(true)).getType() + .addCoding(new Coding().setSystem("http://dsf.dev/fhir/CodeSystem/hello-world") + .setCode("boolean-example").setVersion(def.getResourceVersion())); + task.addInput().setValue(new DateType(new Date())).getType() + .addCoding(new Coding().setSystem("http://dsf.dev/fhir/CodeSystem/hello-world").setCode("date-example") + .setVersion(def.getResourceVersion())); + task.addInput().setValue(new TimeType("10:00:00")).getType() + .addCoding(new Coding().setSystem("http://dsf.dev/fhir/CodeSystem/hello-world").setCode("time-example") + .setVersion(def.getResourceVersion())); + task.addInput().setValue(new DateTimeType(new Date())).getType() + .addCoding(new Coding().setSystem("http://dsf.dev/fhir/CodeSystem/hello-world") + .setCode("date-time-example").setVersion(def.getResourceVersion())); + task.addInput().setValue(new InstantType(new Date())).getType() + .addCoding(new Coding().setSystem("http://dsf.dev/fhir/CodeSystem/hello-world") + .setCode("instant-example").setVersion(def.getResourceVersion())); task.addInput().setValue(new UriType("http://dsf.dev/fhir/CodeSystem/hello-world")).getType() - .addCoding(new Coding().setSystem("http://dsf.dev/fhir/CodeSystem/hello-world").setCode("uri-example")); - task.addInput().setValue(new Reference("http://hl7.org/fhir/Patient/example-id")).getType().addCoding( - new Coding().setSystem("http://dsf.dev/fhir/CodeSystem/hello-world").setCode("reference-example")); + .addCoding(new Coding().setSystem("http://dsf.dev/fhir/CodeSystem/hello-world").setCode("uri-example") + .setVersion(def.getResourceVersion())); + task.addInput().setValue(new Reference("http://hl7.org/fhir/Patient/example-id")).getType() + .addCoding(new Coding().setSystem("http://dsf.dev/fhir/CodeSystem/hello-world") + .setCode("reference-example").setVersion(def.getResourceVersion())); task.addInput() .setValue(new Reference().setType("Patient") .setIdentifier(new Identifier().setSystem("http://dsf.dev/sid/hello-world-identifier") .setValue("identifier-value"))) .getType().addCoding(new Coding().setSystem("http://dsf.dev/fhir/CodeSystem/hello-world") - .setCode("reference-identifier-example")); + .setCode("reference-identifier-example").setVersion(def.getResourceVersion())); task.addInput() .setValue(new Identifier().setSystem("http://dsf.dev/sid/hello-world-identifier") .setValue("identifier-value")) .getType().addCoding(new Coding().setSystem("http://dsf.dev/fhir/CodeSystem/hello-world") - .setCode("identifier-example")); + .setCode("identifier-example").setVersion(def.getResourceVersion())); task.addInput() .setValue( new Coding().setSystem("http://dsf.dev/fhir/CodeSystem/hello-world").setCode("coding-example")) - .getType().addCoding( - new Coding().setSystem("http://dsf.dev/fhir/CodeSystem/hello-world").setCode("coding-example")); + .getType().addCoding(new Coding().setSystem("http://dsf.dev/fhir/CodeSystem/hello-world") + .setCode("coding-example").setVersion(def.getResourceVersion())); + task.addInput() + .setValue(new Quantity().setSystem("http://unitsofmeasure.org").setCode("m").setUnit("m").setValue(1) + .setComparator(Quantity.QuantityComparator.LESS_OR_EQUAL)) + .getType().addCoding(new Coding().setSystem("http://dsf.dev/fhir/CodeSystem/hello-world") + .setCode("quantity-example").setVersion(def.getResourceVersion())); ValidationResult result = resourceValidator.validate(task); ValidationSupportRule.logValidationMessages(logger, result); @@ -112,9 +127,8 @@ public void testMaximalTaskHelloWorldValid() private Task createValidTaskHelloWorld() { Task task = new Task(); - task.getMeta().addProfile(ConstantsHelloWorld.PROFILE_DSF_TASK_TASK_HELLO_WORLD); - task.setInstantiatesCanonical( - ConstantsHelloWorld.PROFILE_DSF_TASK_HELLO_WORLD_PROCESS_URI + "|" + def.getVersion()); + task.getMeta().addProfile("http://dsf.dev/fhir/StructureDefinition/task-hello-world"); + task.setInstantiatesCanonical("http://dsf.dev/bpe/Process/helloWorld|" + def.getResourceVersion()); task.setStatus(TaskStatus.REQUESTED); task.setIntent(TaskIntent.ORDER); task.setAuthoredOn(new Date()); @@ -123,13 +137,15 @@ private Task createValidTaskHelloWorld() task.getRestriction().addRecipient().setType(ResourceType.Organization.name()) .setIdentifier(NamingSystems.OrganizationIdentifier.withValue("Test_DIC_1")); - task.addInput().setValue(new StringType(ConstantsHelloWorld.PROFILE_DSF_TASK_HELLO_WORLD_MESSAGE_NAME)) - .getType().addCoding(CodeSystems.BpmnMessage.messageName()); + task.addInput().setValue(new StringType("helloWorld")).getType() + .addCoding(CodeSystems.BpmnMessage.messageName()); - task.addInput().setValue(new StringType("string-value")).getType().addCoding( - new Coding().setSystem("http://dsf.dev/fhir/CodeSystem/hello-world").setCode("string-example")); - task.addInput().setValue(new IntegerType(1)).getType().addCoding( - new Coding().setSystem("http://dsf.dev/fhir/CodeSystem/hello-world").setCode("integer-example")); + task.addInput().setValue(new StringType("string-value")).getType() + .addCoding(new Coding().setSystem("http://dsf.dev/fhir/CodeSystem/hello-world") + .setCode("string-example").setVersion(def.getResourceVersion())); + task.addInput().setValue(new IntegerType(1)).getType() + .addCoding(new Coding().setSystem("http://dsf.dev/fhir/CodeSystem/hello-world") + .setCode("integer-example").setVersion(def.getResourceVersion())); return task; } @@ -146,12 +162,29 @@ public void testTaskHelloUserValid() || ResultSeverityEnum.FATAL.equals(m.getSeverity())).count()); } + @Test + public void testTaskHelloUserWithQuestionnaireResponseReferenceOutputValid() + { + Task task = createValidTaskHelloUser(); + task.setStatus(TaskStatus.INPROGRESS); + task.addInput().setValue(new StringType(UUID.randomUUID().toString())).getType().getCodingFirstRep() + .setSystem("http://dsf.dev/fhir/CodeSystem/bpmn-message").setCode("business-key"); + task.addOutput().setValue(new Reference("QuestionnaireResponse/" + UUID.randomUUID().toString())).getType() + .getCodingFirstRep().setSystem("http://dsf.dev/fhir/CodeSystem/hello-world") + .setCode("questionnaire-response-reference").setVersion(def.getResourceVersion()); + + ValidationResult result = resourceValidator.validate(task); + ValidationSupportRule.logValidationMessages(logger, result); + + assertEquals(0, result.getMessages().stream().filter(m -> ResultSeverityEnum.ERROR.equals(m.getSeverity()) + || ResultSeverityEnum.FATAL.equals(m.getSeverity())).count()); + } + private Task createValidTaskHelloUser() { Task task = new Task(); - task.getMeta().addProfile(ConstantsHelloWorld.PROFILE_DSF_TASK_TASK_HELLO_USER); - task.setInstantiatesCanonical( - ConstantsHelloWorld.PROFILE_DSF_TASK_HELLO_USER_PROCESS_URI + "|" + def.getVersion()); + task.getMeta().addProfile("http://dsf.dev/fhir/StructureDefinition/task-hello-user"); + task.setInstantiatesCanonical("http://dsf.dev/bpe/Process/helloUser|" + def.getVersion()); task.setStatus(TaskStatus.REQUESTED); task.setIntent(TaskIntent.ORDER); task.setAuthoredOn(new Date()); @@ -160,9 +193,30 @@ private Task createValidTaskHelloUser() task.getRestriction().addRecipient().setType(ResourceType.Organization.name()) .setIdentifier(NamingSystems.OrganizationIdentifier.withValue("Test_DIC_1")); - task.addInput().setValue(new StringType(ConstantsHelloWorld.PROFILE_DSF_TASK_HELLO_USER_MESSAGE_NAME)).getType() + task.addInput().setValue(new StringType("helloUser")).getType() .addCoding(CodeSystems.BpmnMessage.messageName()); return task; } + + @Test + public void testHelloUserDraftTask() throws Exception + { + testDraftTask(validationRule.readTask(Paths.get("src/main/resources/fhir/Task/dsf-task-hello-user.xml"))); + } + + @Test + public void testHelloWorldDraftTask() throws Exception + { + testDraftTask(validationRule.readTask(Paths.get("src/main/resources/fhir/Task/dsf-task-hello-world.xml"))); + } + + private void testDraftTask(Task task) + { + ValidationResult result = resourceValidator.validate(task); + ValidationSupportRule.logValidationMessages(logger, result); + + assertEquals(0, result.getMessages().stream().filter(m -> ResultSeverityEnum.ERROR.equals(m.getSeverity()) + || ResultSeverityEnum.FATAL.equals(m.getSeverity())).count()); + } } diff --git a/src/test/resources/log4j2.xml b/src/test/resources/log4j2.xml index 191e09b..32c677b 100644 --- a/src/test/resources/log4j2.xml +++ b/src/test/resources/log4j2.xml @@ -10,13 +10,7 @@ - - - - - - - +