Prerequisites • Exercise 0 • Exercise 1 • Exercise 1.1 • Exercise 2 • Exercise 3 • Exercise 4 • Exercise 5 • Exercise 6 • Exercise 7
In this exercise you will pass additional information into a running process in two different ways: via an environment variable (configured outside the process, at deployment time) and via a FHIR Task Input Parameter (supplied at the start of every process).
Both values will be accessible inside the execute method of your DicTask service class.
Solutions to this exercise are found on the branch solutions/exercise-2.
Background reading (documentation links for this exercise)
-
Add a new boolean variable to the
TutorialConfigclass. It will enable/disable logging and have its value injected from an environment variable. Add the annotation and specify the default value asfalse. You may freely choose a name for your environment variable here. Just make sure you follow the naming convention explained in Environment Variables. -
Modify the constructor of the
DicTaskclass to use the newly created variable. Don't forget to change theDicTaskbean inTutorialConfig. If you previously registered it throughActivityPrototypeBeanCreatoryou now have to register it as a separate Bean becauseActivityPrototypeBeanCreatorcan only create beans through default constructors (scope has to beprototype).Don't know how to register prototype beans?
Take a look at the documentation on Spring Integration.
-
Use the value of the environment variable in the
DicTaskclass to decide whether the log message from exercise 1 should be printed. -
Add the new environment variable to the
dic-bpeservice indev-setup/docker-compose.ymland set the value to"true". -
Create a new CodeSystem with url
http://example.org/fhir/CodeSystem/tutorialhaving a concept with codetutorial-inputand name the filetutorial.xml. Don't forget to add theread-access-tag.Don't know how to create a CodeSystem?
Check out this guide.
Don't know where to put the CodeSystem?
tutorial-process/src/main/resources/fhir/CodeSystem. -
Create a new ValueSet with url
http://example.org/fhir/ValueSet/tutorialthat includes all concepts from the CodeSystem and name the filetutorial.xml. Don't forget to add theread-access-tag.Don't know how to create a ValueSet?
Check out this guide.
Don't know where to put the ValueSet?
tutorial-process/src/main/resources/fhir/ValueSet. -
Add a new input parameter of type
tutorial-inputwithTask.input.value[x]as astringto the StructureDefinition profile filetutorial-process/src/main/resources/fhir/StructureDefinition/task-start-dic-process.xml.Note: The
task-start-dic-process.xmlexists both under theStructureDefinitionandTaskdirectories underresources. In terms of Object Oriented Programming, the StructureDefinition is the class and the Task resource is an instance.Don't know how to add a new input parameter?
Check out this guide.
-
Make sure the return value for
TutorialProcessPluginDefinition#getFhirResourcesByProcessIdalso includes the new CodeSystem and ValueSet resources for theexampleorg_dicProcess. The processexampleorg_dicProcessnow requires these additional FHIR resources becausetask-start-dic-processreferences them — without registering them here, the DSF BPE server will reject the StructureDefinition (and thus process deployment) because it can't find the resources referenced in it. -
Read the new input parameter in the
DicTaskclass from the start Task and add the value to the log message from exercise 1.Don't know how to get the input parameter?
The
TaskHelperinstance will prove useful here. Use it in conjunction withvariablesto get the right Task resource from the BPMN process execution. -
We just changed the elements a Task resource has to include. So you need to change
example-task.xmlfor cURL orTask/task-start-dic-process.xml, if you want to use the web interface, to include the new input parameter. The actual value may be any arbitrary string. This also means that we need to change the plugin version, since a Task made according to the old StructureDefinition won't be valid for processes still expecting the old StructureDefinition. The new resource version shall be1.1. If yourProcessPluginDefinitionimplementation is implementing theProcessPluginDefinitioninterface, you have to change the version in both thegetVersionmethod of yourProcessPluginDefinitionand thepom.xmlfile of thetutorial-processmodule. If your implementation is inheriting fromAbstractProcessPluginDefinitionand has a plugin.properties file configured at the resource root with theversion=${project.version}entry, changing the version in thepom.xmlis sufficient. The latter way is recommended.
Execute a maven build of the dsf-process-tutorial parent module via:
mvn clean install -Pexercise-2
Verify that the build was successful and no test failures occurred.
To verify the exampleorg_dicProcess can be executed successfully, we need to deploy it into a DSF instance and execute the process. The maven install build is configured to create a process jar file with all necessary resources and copy the jar to the appropriate locations of the docker dev setup.
-
Start the DSF FHIR server for the
dic.dsf.testorganization in a console at location.../dsf-process-tutorial/dev-setup:docker compose up dic-fhirVerify the DSF FHIR server started successfully at https://dic/fhir.
-
Start the DSF BPE server for the
dic.dsf.testorganization in second console at location.../dsf-process-tutorial/dev-setup:docker compose up dic-bpeVerify the DSF BPE server started successfully and deployed the
exampleorg_dicProcess. -
Start the
exampleorg_dicProcessby posting an appropriate FHIR Task resource to the DSF FHIR server of thedic.dsf.testorganization using either cURL or the DSF FHIR server's web interface. Check out Starting A Process Via Task Resources again if you are unsure.Verify that the
exampleorg_dicProcesswas executed by the DSF BPE server. The BPE server should:- Print a message showing that the process was started.
- If logging is enabled - print the log message and the value of the input parameter you added to the
DicTaskimplementation. - Print a message showing that the process finished.
Check that you can disable logging of your message by modifying the docker-compose.yml file and configuring your environment variable with the value "false" or removing the environment variable.
Note: Changes to environment variable require recreating the docker container.
Prerequisites • Exercise 0 • Exercise 1 • Exercise 1.1 • Exercise 2 • Exercise 3 • Exercise 4 • Exercise 5 • Exercise 6 • Exercise 7