-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SEP] Send tasks #22
Open
w2ptr
wants to merge
9
commits into
philips-labs:main
Choose a base branch
from
HiflowTUe:send-tasks
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[SEP] Send tasks #22
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a1adc97
Added scripts for easily building and serving
JortvD 259c718
Add sh variants that will prefix the different subsystems
JortvD 9979c66
Make sure that the subsystems windows stay open
JortvD eab01e2
Merge pull request #1 from HiflowTUe/new-scripts
JortvD d5c30aa
Increase tail length
JortvD 239aa17
Fix incorrect query for docker logs tail of the HAPI FHIR
JortvD d36fbac
Remove bat scripts due to logs issues
JortvD 96a1bf2
Merge pull request #2 from HiflowTUe/new-scripts
JortvD 08104b4
Add support for event tasks
JortvD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
engine/camunda/src/main/java/org/camunda/bpm/delegate/SendTaskEntry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package org.camunda.bpm.delegate; | ||
|
||
import java.io.IOException; | ||
import java.util.Properties; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
import org.camunda.bpm.engine.delegate.DelegateExecution; | ||
import org.camunda.bpm.engine.delegate.JavaDelegate; | ||
import org.camunda.bpm.model.bpmn.BpmnModelInstance; | ||
import org.camunda.bpm.model.bpmn.impl.instance.DataObjectReferenceImpl; | ||
import org.camunda.bpm.model.bpmn.instance.DataInputAssociation; | ||
import org.camunda.bpm.model.bpmn.instance.Documentation; | ||
import org.camunda.bpm.model.bpmn.instance.ItemAwareElement; | ||
import org.camunda.bpm.model.bpmn.instance.SendTask; | ||
|
||
import kong.unirest.HttpResponse; | ||
import kong.unirest.JsonNode; | ||
import kong.unirest.Unirest; | ||
|
||
public class SendTaskEntry implements JavaDelegate { | ||
@Override | ||
public void execute(DelegateExecution delegateExecution) throws Exception { | ||
Properties properties = new Properties(); | ||
try { | ||
properties.load(getClass().getClassLoader().getResourceAsStream("config.properties")); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
SendTask sendTask = null; | ||
try { | ||
sendTask = delegateExecution.getProcessEngine().getRepositoryService().getBpmnModelInstance(delegateExecution.getProcessDefinitionId()).getModelElementById(delegateExecution.getCurrentActivityId()); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
String data = ""; | ||
|
||
try { | ||
BpmnModelInstance bpmModel = delegateExecution.getProcessEngine().getRepositoryService().getBpmnModelInstance(delegateExecution.getProcessDefinitionId()); | ||
for (DataInputAssociation dataInputAssociation : sendTask.getDataInputAssociations()) { | ||
for (ItemAwareElement source : dataInputAssociation.getSources()) { | ||
DataObjectReferenceImpl dataReference = bpmModel.getModelElementById(source.getId()); | ||
for (Documentation documentation : dataReference.getDocumentations()) { | ||
data = documentation.getRawTextContent(); | ||
} | ||
} | ||
} | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
StringBuffer sb = new StringBuffer(); | ||
Matcher m = Pattern.compile("\\$\\((.*?)\\)").matcher(data); | ||
int count = 1; | ||
while (m.find()) { | ||
String reqVariable = m.group(count); | ||
m.appendReplacement(sb, (String) delegateExecution.getVariable(reqVariable)); | ||
count++; | ||
} | ||
m.appendTail(sb); | ||
|
||
HttpResponse<JsonNode> httpResponse = Unirest.post(properties.getProperty("wfc.url") + | ||
"/PostObservationValue/") | ||
.body(sb.toString()) | ||
.asJson(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/bash | ||
CURRENT_DIR=$(pwd) | ||
CURRENT_DIR_LENGTH=${#CURRENT_DIR} | ||
if [ "${CURRENT_DIR: -12}" != "/new_scripts" ]; then | ||
echo "" | ||
echo "You are not in the correct directory. Please run this script from the root directory of the project." | ||
echo "" | ||
exit 1 | ||
fi | ||
|
||
echo "--------------- Now building apps... ---------------" | ||
cd .. | ||
|
||
echo "" | ||
echo "---------- Camunda build-script starting ----------" | ||
cd engine/camunda | ||
mvn -B package --file pom.xml | ||
cd ../.. | ||
echo "---------- Camunda build-script finished ----------" | ||
|
||
echo "" | ||
echo "---------- Caregiver app build-script starting ----------" | ||
cd caregiver_application | ||
pip install -r requirements.txt | ||
cd .. | ||
echo "---------- Caregiver app build-script finished ----------" | ||
|
||
echo "" | ||
echo "---------- Management Dashboard build-script starting ----------" | ||
cd management_dashboard | ||
npm install | ||
cd .. | ||
echo "---------- Management Dashboard build-script finished ----------" | ||
|
||
echo "" | ||
echo "---------- WFC build-script starting ----------" | ||
cd workflow_capability_core | ||
mvn -B package --file pom.xml | ||
cd .. | ||
echo "---------- WFC build-script finished ----------" | ||
|
||
cd scripts | ||
echo "" | ||
echo "----------------- Apps built! -----------------" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/bash | ||
|
||
# Ask if demos should be served | ||
read -p "Serve all of the demos? (y/n) [n]: " SERVE_DEMOS | ||
|
||
echo "---- Removing docker containers ----" | ||
docker container stop $(docker container ls -aq) | ||
docker container rm $(docker container ls -aq) | ||
|
||
echo "---- Starting Postgres ----" | ||
docker run -d -p 5432:5432 -e POSTGRES_PASSWORD=admin postgres | ||
sleep 5 | ||
|
||
echo "---- Starting FHIR store ----" | ||
docker run -d -p 8180:8080 -v "/$(pwd)/../fhir_jpa_config:/data" -e "--spring.config.location=file:///data/application.yaml" hapiproject/hapi:latest | ||
# get container id of this container | ||
CONTAINER_ID=$(docker ps --filter "ancestor=hapiproject/hapi:latest" --format "{{.ID}}") | ||
sleep 5 | ||
|
||
echo "--- Wait until HAPI FHIR has started ---" | ||
# We wait by checking the last line of the logs of the container for the string "Started Application in" | ||
while true; do | ||
CONTAINER_LOG_LAST_LINE=$(docker logs --tail 20 $CONTAINER_ID) | ||
if [[ $CONTAINER_LOG_LAST_LINE == *"Started Application in"* ]]; then | ||
break | ||
fi | ||
sleep 1 | ||
done | ||
|
||
echo "-- STARTING CAMUNDA --" | ||
cd .. | ||
bash -eo pipefail -c "java -jar engine/camunda/target/camunda_engine-0.0.2-SNAPSHOT.jar | awk '{print \"[CAM] \"\$0}'" & | ||
cd new_scripts | ||
|
||
echo "-- STARTING CAREGIVER APP --" | ||
cd .. | ||
bash -eo pipefail -c "python caregiver_application/main.py | awk '{print \"[CGA] \"\$0}'" & | ||
cd new_scripts | ||
|
||
# echo "-- STARTING MANAGEMENT DASHBOARD --" | ||
# cd .. | ||
# cd management_dashboard | ||
# npm run start & | ||
# cd .. | ||
# cd new_scripts | ||
|
||
sleep 10 | ||
|
||
echo "-- STARTING WFC --" | ||
cd .. | ||
if [ "$SERVE_DEMOS" == "y" ]; then | ||
bash -eo pipefail -c "java -jar workflow_capability_core/target/workflow_capability_core-0.0.2-SNAPSHOT.jar withAllDemos | awk '{print \"[WFC] \"\$0}'" & | ||
else | ||
bash -eo pipefail -c "java -jar workflow_capability_core/target/workflow_capability_core-0.0.2-SNAPSHOT.jar | awk '{print \"[WFC] \"\$0}'" & | ||
fi | ||
cd new_scripts | ||
|
||
read -n 1 -s -r -p "Press any key to continue..." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,10 @@ | |
import kong.unirest.HttpResponse; | ||
import kong.unirest.JsonNode; | ||
import kong.unirest.Unirest; | ||
|
||
import org.hl7.fhir.instance.model.api.IBaseResource; | ||
import org.hl7.fhir.r4.model.Bundle; | ||
import org.hl7.fhir.r4.model.Observation; | ||
import org.hl7.fhir.r4.model.Resource; | ||
import org.hl7.fhir.r4.model.StringType; | ||
import org.hl7.fhir.r4.model.Subscription; | ||
|
@@ -32,6 +35,27 @@ public EngineQueryHandler() throws IOException { | |
pendingRequests = new HashMap<>(); | ||
} | ||
|
||
public void postFhirResource(@NotNull String data) { | ||
FhirContext ctx = FhirContext.forR4(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Get cached FhirContext |
||
try { | ||
IParser parser = ctx.newJsonParser(); | ||
IBaseResource resource = parser.parseResource(data); | ||
String fhirResource = resource.fhirType(); | ||
|
||
postFhirObject(fhirResource, data); | ||
} | ||
catch (Exception e) { | ||
System.out.println("Incorrect data" + e); | ||
} | ||
} | ||
|
||
private void postFhirObject(String fhirResource, String data) { | ||
HttpResponse<JsonNode> httpResponse = Unirest.post(properties.get("config.fhirUrl") + "/fhir/" + | ||
fhirResource) | ||
.header("Content-Type", "application/json") | ||
.body(data) | ||
.asJson(); | ||
} | ||
|
||
public Resource getFhirResource(@NotNull String query, String returnMessage, String processID, String variableName) { | ||
FhirContext ctx = FhirContext.forR4(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We expect the SendTaskExecutionListener here