diff --git a/dsf-bpe-process-hello-world/pom.xml b/dsf-bpe-process-hello-world/pom.xml index 4fc2b63..05235b7 100755 --- a/dsf-bpe-process-hello-world/pom.xml +++ b/dsf-bpe-process-hello-world/pom.xml @@ -7,7 +7,7 @@ org.highmed.dsf dsf-bpe-example-processes-pom - 0.6.0 + 0.9.0 diff --git a/dsf-bpe-process-hello-world/src/main/java/org/highmed/dsf/bpe/ConstantsHelloWorld.java b/dsf-bpe-process-hello-world/src/main/java/org/highmed/dsf/bpe/ConstantsHelloWorld.java index 39a4bbd..d452e34 100644 --- a/dsf-bpe-process-hello-world/src/main/java/org/highmed/dsf/bpe/ConstantsHelloWorld.java +++ b/dsf-bpe-process-hello-world/src/main/java/org/highmed/dsf/bpe/ConstantsHelloWorld.java @@ -5,11 +5,23 @@ public interface ConstantsHelloWorld { + String PROCESS_NAME_HELLO_WORLD = "helloWorld"; + String PROCESS_NAME_FULL_HELLO_WORLD = "highmedorg_" + PROCESS_NAME_HELLO_WORLD; + + String PROCESS_NAME_HELLO_USER = "helloUser"; + String PROCESS_NAME_FULL_HELLO_USER = "highmedorg_" + PROCESS_NAME_HELLO_USER; + String PROFILE_HIGHMED_TASK_HELLO_WORLD = "http://highmed.org/fhir/StructureDefinition/task-hello-world"; - String PROFILE_HIGHMED_TASK_HELLO_WORLD_AND_LATEST_VERSION = "http://highmed.org/fhir/StructureDefinition/task-hello-world" - + "|" + VERSION; - String PROFILE_HIGHMED_TASK_HELLO_WORLD_PROCESS_URI = PROCESS_HIGHMED_URI_BASE + "helloWorld/"; + String PROFILE_HIGHMED_TASK_HELLO_WORLD_AND_LATEST_VERSION = PROFILE_HIGHMED_TASK_HELLO_WORLD + "|" + VERSION; + String PROFILE_HIGHMED_TASK_HELLO_WORLD_PROCESS_URI = PROCESS_HIGHMED_URI_BASE + PROCESS_NAME_HELLO_WORLD + "/"; String PROFILE_HIGHMED_TASK_HELLO_WORLD_PROCESS_URI_AND_LATEST_VERSION = PROFILE_HIGHMED_TASK_HELLO_WORLD_PROCESS_URI + VERSION; - String PROFILE_HIGHMED_TASK_HELLO_WORLD_MESSAGE_NAME = "helloWorldMessage"; + String PROFILE_HIGHMED_TASK_HELLO_WORLD_MESSAGE_NAME = "helloWorld"; + + String PROFILE_HIGHMED_TASK_HELLO_USER = "http://highmed.org/fhir/StructureDefinition/task-hello-user"; + String PROFILE_HIGHMED_TASK_HELLO_USER_AND_LATEST_VERSION = PROFILE_HIGHMED_TASK_HELLO_USER + "|" + VERSION; + String PROFILE_HIGHMED_TASK_HELLO_USER_PROCESS_URI = PROCESS_HIGHMED_URI_BASE + PROCESS_NAME_HELLO_USER + "/"; + String PROFILE_HIGHMED_TASK_HELLO_USER_PROCESS_URI_AND_LATEST_VERSION = PROFILE_HIGHMED_TASK_HELLO_USER_PROCESS_URI + + VERSION; + String PROFILE_HIGHMED_TASK_HELLO_USER_MESSAGE_NAME = "helloUser"; } diff --git a/dsf-bpe-process-hello-world/src/main/java/org/highmed/dsf/bpe/HelloWorldProcessPluginDefinition.java b/dsf-bpe-process-hello-world/src/main/java/org/highmed/dsf/bpe/HelloWorldProcessPluginDefinition.java index afc7f06..2bb80a5 100644 --- a/dsf-bpe-process-hello-world/src/main/java/org/highmed/dsf/bpe/HelloWorldProcessPluginDefinition.java +++ b/dsf-bpe-process-hello-world/src/main/java/org/highmed/dsf/bpe/HelloWorldProcessPluginDefinition.java @@ -1,5 +1,8 @@ package org.highmed.dsf.bpe; +import static org.highmed.dsf.bpe.ConstantsHelloWorld.PROCESS_NAME_FULL_HELLO_USER; +import static org.highmed.dsf.bpe.ConstantsHelloWorld.PROCESS_NAME_FULL_HELLO_WORLD; + import java.time.LocalDate; import java.util.Arrays; import java.util.List; @@ -9,6 +12,7 @@ import org.highmed.dsf.bpe.spring.config.HelloWorldConfig; import org.highmed.dsf.fhir.resources.AbstractResource; import org.highmed.dsf.fhir.resources.ActivityDefinitionResource; +import org.highmed.dsf.fhir.resources.QuestionnaireResource; import org.highmed.dsf.fhir.resources.ResourceProvider; import org.highmed.dsf.fhir.resources.StructureDefinitionResource; import org.springframework.core.env.PropertyResolver; @@ -17,13 +21,13 @@ public class HelloWorldProcessPluginDefinition implements ProcessPluginDefinition { - public static final String VERSION = "0.6.0"; - public static final LocalDate RELEASE_DATE = LocalDate.of(2022, 5, 10); + public static final String VERSION = "0.9.0"; + public static final LocalDate RELEASE_DATE = LocalDate.of(2022, 10, 24); @Override public String getName() { - return "dsf-bpe-process-hello-world"; + return "dsf-bpe-process-hello-world-and-user"; } @Override @@ -41,7 +45,7 @@ public LocalDate getReleaseDate() @Override public Stream getBpmnFiles() { - return Stream.of("bpe/helloWorld.bpmn"); + return Stream.of("bpe/helloWorld.bpmn", "bpe/helloUser.bpmn"); } @Override @@ -54,11 +58,17 @@ public Stream> getSpringConfigClasses() public ResourceProvider getResourceProvider(FhirContext fhirContext, ClassLoader classLoader, PropertyResolver resolver) { + var aHelloUser = ActivityDefinitionResource.file("fhir/ActivityDefinition/highmed-helloUser.xml"); var aHelloWorld = ActivityDefinitionResource.file("fhir/ActivityDefinition/highmed-helloWorld.xml"); + + var qHelloWorld = QuestionnaireResource.file("fhir/Questionnaire/highmed-questionnaire-hello-user.xml"); + + var tHelloUser = StructureDefinitionResource.file("fhir/StructureDefinition/highmed-task-hello-user.xml"); var tHelloWorld = StructureDefinitionResource.file("fhir/StructureDefinition/highmed-task-hello-world.xml"); - Map> resourcesByProcessKeyAndVersion = Map.of("highmedorg_helloWorld/" + VERSION, - Arrays.asList(aHelloWorld, tHelloWorld)); + Map> resourcesByProcessKeyAndVersion = Map.of( + PROCESS_NAME_FULL_HELLO_USER + "/" + VERSION, Arrays.asList(aHelloUser, qHelloWorld, tHelloUser), + PROCESS_NAME_FULL_HELLO_WORLD + "/" + VERSION, Arrays.asList(aHelloWorld, tHelloWorld)); return ResourceProvider.read(VERSION, RELEASE_DATE, () -> fhirContext.newXmlParser().setStripVersionsFromReferences(false), classLoader, resolver, diff --git a/dsf-bpe-process-hello-world/src/main/java/org/highmed/dsf/bpe/message/.keep b/dsf-bpe-process-hello-world/src/main/java/org/highmed/dsf/bpe/message/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/dsf-bpe-process-hello-world/src/main/java/org/highmed/dsf/bpe/message/README.md b/dsf-bpe-process-hello-world/src/main/java/org/highmed/dsf/bpe/message/README.md new file mode 100644 index 0000000..bc0cbf2 --- /dev/null +++ b/dsf-bpe-process-hello-world/src/main/java/org/highmed/dsf/bpe/message/README.md @@ -0,0 +1 @@ +`message` package typically used for implementing task message send events \ No newline at end of file diff --git a/dsf-bpe-process-hello-world/src/main/java/org/highmed/dsf/bpe/service/HelloWorld.java b/dsf-bpe-process-hello-world/src/main/java/org/highmed/dsf/bpe/service/HelloWorld.java index 81d7f4a..ae78e57 100644 --- a/dsf-bpe-process-hello-world/src/main/java/org/highmed/dsf/bpe/service/HelloWorld.java +++ b/dsf-bpe-process-hello-world/src/main/java/org/highmed/dsf/bpe/service/HelloWorld.java @@ -20,9 +20,9 @@ public HelloWorld(FhirWebserviceClientProvider clientProvider, TaskHelper taskHe } @Override - public void doExecute(DelegateExecution execution) throws Exception + public void doExecute(DelegateExecution execution) { - Task task = getCurrentTaskFromExecutionVariables(); + Task task = getCurrentTaskFromExecutionVariables(execution); logger.info("Hello World from organization with identifier '{}'", task.getRequester().getIdentifier().getValue()); } diff --git a/dsf-bpe-process-hello-world/src/main/java/org/highmed/dsf/bpe/service/LogUserTaskResponse.java b/dsf-bpe-process-hello-world/src/main/java/org/highmed/dsf/bpe/service/LogUserTaskResponse.java new file mode 100644 index 0000000..b8be7a1 --- /dev/null +++ b/dsf-bpe-process-hello-world/src/main/java/org/highmed/dsf/bpe/service/LogUserTaskResponse.java @@ -0,0 +1,48 @@ +package org.highmed.dsf.bpe.service; + +import static org.highmed.dsf.bpe.ConstantsBase.BPMN_EXECUTION_VARIABLE_QUESTIONNAIRE_RESPONSE_COMPLETED; + +import java.util.Objects; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.highmed.dsf.bpe.delegate.AbstractServiceDelegate; +import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper; +import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider; +import org.highmed.dsf.fhir.task.TaskHelper; +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; + +public class LogUserTaskResponse extends AbstractServiceDelegate implements InitializingBean +{ + private static final Logger logger = LoggerFactory.getLogger(LogUserTaskResponse.class); + + private final FhirContext fhirContext; + + public LogUserTaskResponse(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, + ReadAccessHelper readAccessHelper, FhirContext fhirContext) + { + super(clientProvider, taskHelper, readAccessHelper); + this.fhirContext = fhirContext; + } + + @Override + public void afterPropertiesSet() throws Exception + { + super.afterPropertiesSet(); + Objects.requireNonNull(fhirContext, "fhirContext"); + } + + @Override + protected void doExecute(DelegateExecution execution) + { + QuestionnaireResponse questionnaireResponse = (QuestionnaireResponse) execution + .getVariable(BPMN_EXECUTION_VARIABLE_QUESTIONNAIRE_RESPONSE_COMPLETED); + + logger.info("Completed QuestionnaireResponse: {}", + fhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(questionnaireResponse)); + } +} diff --git a/dsf-bpe-process-hello-world/src/main/java/org/highmed/dsf/bpe/spring/config/HelloWorldConfig.java b/dsf-bpe-process-hello-world/src/main/java/org/highmed/dsf/bpe/spring/config/HelloWorldConfig.java index 2299858..62dddc9 100755 --- a/dsf-bpe-process-hello-world/src/main/java/org/highmed/dsf/bpe/spring/config/HelloWorldConfig.java +++ b/dsf-bpe-process-hello-world/src/main/java/org/highmed/dsf/bpe/spring/config/HelloWorldConfig.java @@ -1,6 +1,7 @@ package org.highmed.dsf.bpe.spring.config; import org.highmed.dsf.bpe.service.HelloWorld; +import org.highmed.dsf.bpe.service.LogUserTaskResponse; import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper; import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider; import org.highmed.dsf.fhir.task.TaskHelper; @@ -8,6 +9,8 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import ca.uhn.fhir.context.FhirContext; + @Configuration public class HelloWorldConfig { @@ -20,9 +23,18 @@ public class HelloWorldConfig @Autowired private ReadAccessHelper readAccessHelper; + @Autowired + private FhirContext fhirContext; + @Bean public HelloWorld helloWorld() { return new HelloWorld(clientProvider, taskHelper, readAccessHelper); } + + @Bean + public LogUserTaskResponse logUserTaskResponse() + { + return new LogUserTaskResponse(clientProvider, taskHelper, readAccessHelper, fhirContext); + } } diff --git a/dsf-bpe-process-hello-world/src/main/java/org/highmed/dsf/bpe/variable/.keep b/dsf-bpe-process-hello-world/src/main/java/org/highmed/dsf/bpe/variable/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/dsf-bpe-process-hello-world/src/main/java/org/highmed/dsf/bpe/variable/README.md b/dsf-bpe-process-hello-world/src/main/java/org/highmed/dsf/bpe/variable/README.md new file mode 100644 index 0000000..ab241aa --- /dev/null +++ b/dsf-bpe-process-hello-world/src/main/java/org/highmed/dsf/bpe/variable/README.md @@ -0,0 +1 @@ +`variable` package typically used for implementing custom BPMN variable serializers \ No newline at end of file diff --git a/dsf-bpe-process-hello-world/src/main/resources/bpe/helloUser.bpmn b/dsf-bpe-process-hello-world/src/main/resources/bpe/helloUser.bpmn new file mode 100644 index 0000000..2a480ec --- /dev/null +++ b/dsf-bpe-process-hello-world/src/main/resources/bpe/helloUser.bpmn @@ -0,0 +1,54 @@ + + + + + + Flow_034bfq7 + + + SequenceFlow_0bbhq2r + + + + + SequenceFlow_0bbhq2r + Flow_00nx7hv + + + + Flow_00nx7hv + Flow_034bfq7 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dsf-bpe-process-hello-world/src/main/resources/bpe/helloWorld.bpmn b/dsf-bpe-process-hello-world/src/main/resources/bpe/helloWorld.bpmn index 8ef97b4..68bb0f1 100644 --- a/dsf-bpe-process-hello-world/src/main/resources/bpe/helloWorld.bpmn +++ b/dsf-bpe-process-hello-world/src/main/resources/bpe/helloWorld.bpmn @@ -1,5 +1,5 @@ - + @@ -15,26 +15,26 @@ - + - + - - - + + + diff --git a/dsf-bpe-process-hello-world/src/main/resources/fhir/ActivityDefinition/highmed-helloUser.xml b/dsf-bpe-process-hello-world/src/main/resources/fhir/ActivityDefinition/highmed-helloUser.xml new file mode 100644 index 0000000..acb32fa --- /dev/null +++ b/dsf-bpe-process-hello-world/src/main/resources/fhir/ActivityDefinition/highmed-helloUser.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <subtitle value="Example Template Process as template for implementation of novel processes with user-tasks" /> + <!-- status managed by bpe --> + <status value="unknown" /> + <experimental value="false" /> + <!-- date managed by bpe --> + <date value="#{date}" /> + <publisher value="HiGHmed" /> + <contact> + <name value="HiGHmed" /> + <telecom> + <system value="email" /> + <value value="pmo@highmed.org" /> + </telecom> + </contact> + <description value="Example process as template for implementation of novel processes with user-tasks" /> + <kind value="Task" /> +</ActivityDefinition> \ No newline at end of file diff --git a/dsf-bpe-process-hello-world/src/main/resources/fhir/ActivityDefinition/highmed-helloWorld.xml b/dsf-bpe-process-hello-world/src/main/resources/fhir/ActivityDefinition/highmed-helloWorld.xml index 3f0f9cb..c260fea 100644 --- a/dsf-bpe-process-hello-world/src/main/resources/fhir/ActivityDefinition/highmed-helloWorld.xml +++ b/dsf-bpe-process-hello-world/src/main/resources/fhir/ActivityDefinition/highmed-helloWorld.xml @@ -7,7 +7,7 @@ </meta> <extension url="http://highmed.org/fhir/StructureDefinition/extension-process-authorization"> <extension url="message-name"> - <valueString value="helloWorldMessage" /> + <valueString value="helloWorld" /> </extension> <extension url="task-profile"> <valueCanonical value="http://highmed.org/fhir/StructureDefinition/task-hello-world|#{version}" /> diff --git a/dsf-bpe-process-hello-world/src/main/resources/fhir/Questionnaire/highmed-questionnaire-hello-user.xml b/dsf-bpe-process-hello-world/src/main/resources/fhir/Questionnaire/highmed-questionnaire-hello-user.xml new file mode 100644 index 0000000..d3cd664 --- /dev/null +++ b/dsf-bpe-process-hello-world/src/main/resources/fhir/Questionnaire/highmed-questionnaire-hello-user.xml @@ -0,0 +1,81 @@ +<Questionnaire xmlns="http://hl7.org/fhir"> + <meta> + <profile value="http://highmed.org/fhir/StructureDefinition/questionnaire|0.9.0"/> + <tag> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag"/> + <code value="ALL"/> + </tag> + </meta> + <url value="http://highmed.org/fhir/Questionnaire/hello-user"/> + <!-- version managed by bpe --> + <version value="#{version}"/> + <!-- date managed by bpe --> + <date value="#{date}"/> + <!-- status managed by bpe --> + <status value="unknown"/> + <item> + <linkId value="user-task-id"/> + <type value="string"/> + <text value="The user-task-id of the process execution"/> + </item> + <item> + <linkId value="business-key"/> + <type value="string"/> + <text value="The business-key of the process execution"/> + </item> + <item> + <linkId value="display-example"/> + <type value="display"/> + <text value="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."/> + </item> + <item> + <linkId value="string-example"/> + <type value="string"/> + <text value="Add a string to test the string type"/> + </item> + <item> + <linkId value="text-example"/> + <type value="text"/> + <text value="Add a text to test the text type"/> + </item> + <item> + <linkId value="integer-example"/> + <type value="integer"/> + <text value="Add an integer number to test the integer type"/> + </item> + <item> + <linkId value="decimal-example"/> + <type value="decimal"/> + <text value="Add a decimal number to test the decimal type"/> + </item> + <item> + <linkId value="date-example"/> + <type value="date"/> + <text value="Add a date to test the date type"/> + </item> + <item> + <linkId value="time-example"/> + <type value="time"/> + <text value="Add a time to test the time type"/> + </item> + <item> + <linkId value="date-time-example"/> + <type value="dateTime"/> + <text value="Add a date-time to test the dateTime type"/> + </item> + <item> + <linkId value="url-example"/> + <type value="url"/> + <text value="Add the location of the pdf contract"/> + </item> + <item> + <linkId value="reference-example"/> + <type value="reference"/> + <text value="Add the location (url) of the data-set that should be approved"/> + </item> + <item> + <linkId value="boolean-example"/> + <type value="boolean"/> + <text value="Do you approve the release of the data-set?"/> + </item> +</Questionnaire> \ No newline at end of file diff --git a/dsf-bpe-process-hello-world/src/main/resources/fhir/StructureDefinition/highmed-task-hello-user.xml b/dsf-bpe-process-hello-world/src/main/resources/fhir/StructureDefinition/highmed-task-hello-user.xml new file mode 100644 index 0000000..01a3b58 --- /dev/null +++ b/dsf-bpe-process-hello-world/src/main/resources/fhir/StructureDefinition/highmed-task-hello-user.xml @@ -0,0 +1,63 @@ +<StructureDefinition xmlns="http://hl7.org/fhir"> + <meta> + <tag> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag" /> + <code value="ALL" /> + </tag> + </meta> + <url value="http://highmed.org/fhir/StructureDefinition/task-hello-user" /> + <!-- version managed by bpe --> + <version value="#{version}" /> + <name value="helloUserProcess" /> + <!-- status managed by bpe --> + <status value="unknown" /> + <experimental value="false" /> + <!-- date managed by bpe --> + <date value="#{date}" /> + <fhirVersion value="4.0.1" /> + <kind value="resource" /> + <abstract value="false" /> + <type value="Task" /> + <baseDefinition value="http://highmed.org/fhir/StructureDefinition/task-base" /> + <derivation value="constraint" /> + <differential> + <element id="Task.instantiatesUri"> + <path value="Task.instantiatesUri" /> + <fixedUri value="http://highmed.org/bpe/Process/helloUser/#{version}" /> + </element> + <element id="Task.input"> + <extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-explicit-type-name"> + <valueString value="Parameter" /> + </extension> + <path value="Task.input" /> + <max value="1" /> + </element> + <element id="Task.input:message-name"> + <extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-explicit-type-name"> + <valueString value="Parameter" /> + </extension> + <path value="Task.input" /> + <sliceName value="message-name" /> + </element> + <element id="Task.input:message-name.value[x]"> + <path value="Task.input.value[x]" /> + <fixedString value="helloUser" /> + </element> + <element id="Task.input:business-key"> + <extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-explicit-type-name"> + <valueString value="Parameter" /> + </extension> + <path value="Task.input" /> + <sliceName value="business-key" /> + <max value="0" /> + </element> + <element id="Task.input:correlation-key"> + <extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-explicit-type-name"> + <valueString value="Parameter" /> + </extension> + <path value="Task.input" /> + <sliceName value="correlation-key" /> + <max value="0" /> + </element> + </differential> +</StructureDefinition> \ No newline at end of file diff --git a/dsf-bpe-process-hello-world/src/main/resources/fhir/StructureDefinition/highmed-task-hello-world.xml b/dsf-bpe-process-hello-world/src/main/resources/fhir/StructureDefinition/highmed-task-hello-world.xml index fda138e..194fa38 100644 --- a/dsf-bpe-process-hello-world/src/main/resources/fhir/StructureDefinition/highmed-task-hello-world.xml +++ b/dsf-bpe-process-hello-world/src/main/resources/fhir/StructureDefinition/highmed-task-hello-world.xml @@ -41,7 +41,7 @@ </element> <element id="Task.input:message-name.value[x]"> <path value="Task.input.value[x]" /> - <fixedString value="helloWorldMessage" /> + <fixedString value="helloWorld" /> </element> <element id="Task.input:business-key"> <extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-explicit-type-name"> diff --git a/dsf-bpe-process-hello-world/src/test/java/org/highmed/dsf/bpe/HelloProcessPluginDefinitionTest.java b/dsf-bpe-process-hello-world/src/test/java/org/highmed/dsf/bpe/HelloProcessPluginDefinitionTest.java new file mode 100644 index 0000000..f29e2ac --- /dev/null +++ b/dsf-bpe-process-hello-world/src/test/java/org/highmed/dsf/bpe/HelloProcessPluginDefinitionTest.java @@ -0,0 +1,44 @@ +package org.highmed.dsf.bpe; + +import static org.highmed.dsf.bpe.ConstantsHelloWorld.PROCESS_NAME_FULL_HELLO_USER; +import static org.highmed.dsf.bpe.ConstantsHelloWorld.PROCESS_NAME_FULL_HELLO_WORLD; +import static org.highmed.dsf.bpe.HelloWorldProcessPluginDefinition.VERSION; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.highmed.dsf.fhir.resources.ResourceProvider; +import org.junit.Test; +import org.springframework.core.env.StandardEnvironment; + +import ca.uhn.fhir.context.FhirContext; + +public class HelloProcessPluginDefinitionTest +{ + @Test + public void testHelloUserResourceLoading() + { + ProcessPluginDefinition definition = new HelloWorldProcessPluginDefinition(); + ResourceProvider provider = definition.getResourceProvider(FhirContext.forR4(), getClass().getClassLoader(), + new StandardEnvironment()); + assertNotNull(provider); + + var helloUser = provider.getResources(PROCESS_NAME_FULL_HELLO_USER + "/" + VERSION, + s -> ResourceProvider.empty()); + assertNotNull(helloUser); + assertEquals(3, helloUser.count()); + } + + @Test + public void testHelloWorldResourceLoading() + { + ProcessPluginDefinition definition = new HelloWorldProcessPluginDefinition(); + ResourceProvider provider = definition.getResourceProvider(FhirContext.forR4(), getClass().getClassLoader(), + new StandardEnvironment()); + assertNotNull(provider); + + var helloWorld = provider.getResources(PROCESS_NAME_FULL_HELLO_WORLD + "/" + VERSION, + s -> ResourceProvider.empty()); + assertNotNull(helloWorld); + assertEquals(2, helloWorld.count()); + } +} diff --git a/dsf-bpe-process-hello-world/src/test/java/org/highmed/dsf/bpe/start/AbstractHelloUser3MedicTtpExampleStarter.java b/dsf-bpe-process-hello-world/src/test/java/org/highmed/dsf/bpe/start/AbstractHelloUser3MedicTtpExampleStarter.java new file mode 100644 index 0000000..523d5fa --- /dev/null +++ b/dsf-bpe-process-hello-world/src/test/java/org/highmed/dsf/bpe/start/AbstractHelloUser3MedicTtpExampleStarter.java @@ -0,0 +1,47 @@ +package org.highmed.dsf.bpe.start; + +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN; +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME; +import static org.highmed.dsf.bpe.ConstantsBase.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER; +import static org.highmed.dsf.bpe.ConstantsHelloWorld.PROFILE_HIGHMED_TASK_HELLO_USER_AND_LATEST_VERSION; +import static org.highmed.dsf.bpe.ConstantsHelloWorld.PROFILE_HIGHMED_TASK_HELLO_USER_MESSAGE_NAME; +import static org.highmed.dsf.bpe.ConstantsHelloWorld.PROFILE_HIGHMED_TASK_HELLO_USER_PROCESS_URI_AND_LATEST_VERSION; +import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1; + +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 org.hl7.fhir.r4.model.Task.TaskIntent; +import org.hl7.fhir.r4.model.Task.TaskStatus; + +public abstract class AbstractHelloUser3MedicTtpExampleStarter +{ + protected void main(String[] args, String baseUrl) throws Exception + { + Task task = createStartResource(); + ExampleStarter.forServer(args, baseUrl).startWith(task); + } + + private Task createStartResource() + { + Task task = new Task(); + task.getMeta().addProfile(PROFILE_HIGHMED_TASK_HELLO_USER_AND_LATEST_VERSION); + task.setInstantiatesUri(PROFILE_HIGHMED_TASK_HELLO_USER_PROCESS_URI_AND_LATEST_VERSION); + task.setStatus(TaskStatus.REQUESTED); + task.setIntent(TaskIntent.ORDER); + task.setAuthoredOn(new Date()); + task.getRequester().setType(ResourceType.Organization.name()).getIdentifier() + .setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER) + .setValue(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1); + task.getRestriction().addRecipient().setType(ResourceType.Organization.name()).getIdentifier() + .setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER) + .setValue(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1); + + task.addInput().setValue(new StringType(PROFILE_HIGHMED_TASK_HELLO_USER_MESSAGE_NAME)).getType().addCoding() + .setSystem(CODESYSTEM_HIGHMED_BPMN).setCode(CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME); + + return task; + } +} diff --git a/dsf-bpe-process-hello-world/src/test/java/org/highmed/dsf/bpe/start/HelloUser3MedicTtpDockerExampleStarter.java b/dsf-bpe-process-hello-world/src/test/java/org/highmed/dsf/bpe/start/HelloUser3MedicTtpDockerExampleStarter.java new file mode 100644 index 0000000..4acecd6 --- /dev/null +++ b/dsf-bpe-process-hello-world/src/test/java/org/highmed/dsf/bpe/start/HelloUser3MedicTtpDockerExampleStarter.java @@ -0,0 +1,15 @@ +package org.highmed.dsf.bpe.start; + +import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.MEDIC_1_DOCKER_FHIR_BASE_URL; + +public class HelloUser3MedicTtpDockerExampleStarter extends AbstractHelloUser3MedicTtpExampleStarter +{ + // Environment variable "DSF_CLIENT_CERTIFICATE_PATH" or args[0]: the path to the client-certificate + // highmed-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 + { + new HelloUser3MedicTtpDockerExampleStarter().main(args, MEDIC_1_DOCKER_FHIR_BASE_URL); + } +} diff --git a/dsf-bpe-process-hello-world/src/test/java/org/highmed/dsf/bpe/start/HelloUser3MedicTtpExampleStarter.java b/dsf-bpe-process-hello-world/src/test/java/org/highmed/dsf/bpe/start/HelloUser3MedicTtpExampleStarter.java new file mode 100644 index 0000000..dcf325b --- /dev/null +++ b/dsf-bpe-process-hello-world/src/test/java/org/highmed/dsf/bpe/start/HelloUser3MedicTtpExampleStarter.java @@ -0,0 +1,15 @@ +package org.highmed.dsf.bpe.start; + +import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.MEDIC_1_FHIR_BASE_URL; + +public class HelloUser3MedicTtpExampleStarter extends AbstractHelloUser3MedicTtpExampleStarter +{ + // Environment variable "DSF_CLIENT_CERTIFICATE_PATH" or args[0]: the path to the client-certificate + // highmed-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 + { + new HelloUser3MedicTtpExampleStarter().main(args, MEDIC_1_FHIR_BASE_URL); + } +} diff --git a/dsf-bpe-process-hello-world/src/test/java/org/highmed/dsf/fhir/profile/ActivityDefinitionProfileTest.java b/dsf-bpe-process-hello-world/src/test/java/org/highmed/dsf/fhir/profile/ActivityDefinitionProfileTest.java index 0c21530..a48bd0e 100644 --- a/dsf-bpe-process-hello-world/src/test/java/org/highmed/dsf/fhir/profile/ActivityDefinitionProfileTest.java +++ b/dsf-bpe-process-hello-world/src/test/java/org/highmed/dsf/fhir/profile/ActivityDefinitionProfileTest.java @@ -46,6 +46,21 @@ public class ActivityDefinitionProfileTest private final ProcessAuthorizationHelper processAuthorizationHelper = new ProcessAuthorizationHelperImpl(); + @Test + public void testHelloUserValid() throws Exception + { + ActivityDefinition ad = validationRule + .readActivityDefinition(Paths.get("src/main/resources/fhir/ActivityDefinition/highmed-helloUser.xml")); + + ValidationResult result = resourceValidator.validate(ad); + ValidationSupportRule.logValidationMessages(logger, result); + + assertEquals(0, result.getMessages().stream().filter(m -> ResultSeverityEnum.ERROR.equals(m.getSeverity()) + || ResultSeverityEnum.FATAL.equals(m.getSeverity())).count()); + + assertTrue(processAuthorizationHelper.isValid(ad, taskProfile -> true, orgIdentifier -> true, role -> true)); + } + @Test public void testHelloWorldValid() throws Exception { diff --git a/dsf-bpe-process-hello-world/src/test/java/org/highmed/dsf/fhir/profile/TaskProfileTest.java b/dsf-bpe-process-hello-world/src/test/java/org/highmed/dsf/fhir/profile/TaskProfileTest.java index 3780646..317ffa2 100644 --- a/dsf-bpe-process-hello-world/src/test/java/org/highmed/dsf/fhir/profile/TaskProfileTest.java +++ b/dsf-bpe-process-hello-world/src/test/java/org/highmed/dsf/fhir/profile/TaskProfileTest.java @@ -3,6 +3,9 @@ import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN; import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME; import static org.highmed.dsf.bpe.ConstantsBase.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER; +import static org.highmed.dsf.bpe.ConstantsHelloWorld.PROFILE_HIGHMED_TASK_HELLO_USER; +import static org.highmed.dsf.bpe.ConstantsHelloWorld.PROFILE_HIGHMED_TASK_HELLO_USER_MESSAGE_NAME; +import static org.highmed.dsf.bpe.ConstantsHelloWorld.PROFILE_HIGHMED_TASK_HELLO_USER_PROCESS_URI_AND_LATEST_VERSION; import static org.highmed.dsf.bpe.ConstantsHelloWorld.PROFILE_HIGHMED_TASK_HELLO_WORLD; import static org.highmed.dsf.bpe.ConstantsHelloWorld.PROFILE_HIGHMED_TASK_HELLO_WORLD_MESSAGE_NAME; import static org.highmed.dsf.bpe.ConstantsHelloWorld.PROFILE_HIGHMED_TASK_HELLO_WORLD_PROCESS_URI_AND_LATEST_VERSION; @@ -35,13 +38,44 @@ public class TaskProfileTest @ClassRule public static final ValidationSupportRule validationRule = new ValidationSupportRule(VERSION, RELEASE_DATE, - Arrays.asList("highmed-task-base-0.5.0.xml", "highmed-task-hello-world.xml"), + Arrays.asList("highmed-task-base-0.5.0.xml", "highmed-task-hello-user.xml", "highmed-task-hello-world.xml"), Arrays.asList("highmed-read-access-tag-0.5.0.xml", "highmed-bpmn-message-0.5.0.xml"), Arrays.asList("highmed-read-access-tag-0.5.0.xml", "highmed-bpmn-message-0.5.0.xml")); private ResourceValidator resourceValidator = new ResourceValidatorImpl(validationRule.getFhirContext(), validationRule.getValidationSupport()); + @Test + public void testTaskHelloUserValid() + { + Task task = createValidTaskHelloUser(); + + 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(PROFILE_HIGHMED_TASK_HELLO_USER); + task.setInstantiatesUri(PROFILE_HIGHMED_TASK_HELLO_USER_PROCESS_URI_AND_LATEST_VERSION); + task.setStatus(TaskStatus.REQUESTED); + task.setIntent(TaskIntent.ORDER); + task.setAuthoredOn(new Date()); + task.getRequester().setType(ResourceType.Organization.name()).getIdentifier() + .setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER).setValue("MeDIC 1"); + task.getRestriction().addRecipient().setType(ResourceType.Organization.name()).getIdentifier() + .setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER).setValue("MeDIC 1"); + + task.addInput().setValue(new StringType(PROFILE_HIGHMED_TASK_HELLO_USER_MESSAGE_NAME)).getType().addCoding() + .setSystem(CODESYSTEM_HIGHMED_BPMN).setCode(CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME); + + return task; + } + @Test public void testTaskHelloWorldValid() { diff --git a/pom.xml b/pom.xml index f20b48b..e87881e 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ <groupId>org.highmed.dsf</groupId> <artifactId>dsf-bpe-example-processes-pom</artifactId> - <version>0.6.0</version> + <version>0.9.0</version> <packaging>pom</packaging> <modules> @@ -18,6 +18,8 @@ <compileSource>11</compileSource> <compileTarget>11</compileTarget> + <dsf.version>0.9.0</dsf.version> + <main.basedir>${project.basedir}</main.basedir> </properties> @@ -45,17 +47,17 @@ <dependency> <groupId>org.highmed.dsf</groupId> <artifactId>dsf-bpe-process-base</artifactId> - <version>0.6.0</version> + <version>${dsf.version}</version> </dependency> <dependency> <groupId>org.highmed.dsf</groupId> <artifactId>dsf-bpe-process-hello-world</artifactId> - <version>0.6.0</version> + <version>${dsf.version}</version> </dependency> <dependency> <groupId>org.highmed.dsf</groupId> <artifactId>dsf-fhir-validation</artifactId> - <version>0.6.0</version> + <version>${dsf.version}</version> </dependency> <!-- hhn rwh --> @@ -74,7 +76,7 @@ <dependency> <groupId>org.highmed.dsf</groupId> <artifactId>dsf-bpe-process-base</artifactId> - <version>0.6.0</version> + <version>${dsf.version}</version> <scope>test</scope> <type>test-jar</type> </dependency>