Skip to content
This repository was archived by the owner on Oct 6, 2025. It is now read-only.

Commit cb4cc6a

Browse files
committed
added bundle size to GTH output, fixed errors not showing up in output
Changes to the Task resource need to be stored in the leading task process variable since it is the only one that survives the return task restarting the process via the intermediate message throw events. The start-data-translate process Task now shows the size (in bytes) of the encrypted transfer bundle.
1 parent f0003e3 commit cb4cc6a

12 files changed

Lines changed: 200 additions & 9 deletions

File tree

codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/ConstantsDataTransfer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public interface ConstantsDataTransfer
4343
String CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_EXPORT_TO = "export-to";
4444
String CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_DATA_REFERENCE = "data-reference";
4545
String CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_DRY_RUN = "dry-run";
46+
String CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_ENCRYPTED_BUNDLE_SIZE = "encrypted-bundle-size";
4647

4748
String PROFILE_NUM_CODEX_TASK_DATA_TRIGGER_PROCESS_URI = "http://www.netzwerk-universitaetsmedizin.de/bpe/Process/dataTrigger/";
4849
String PROFILE_NUM_CODEX_TASK_DATA_TRIGGER_PROCESS_URI_AND_LATEST_VERSION = PROFILE_NUM_CODEX_TASK_DATA_TRIGGER_PROCESS_URI

codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/receive/LogError.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,15 @@ protected void doExecute(DelegateExecution execution) throws BpmnError, Exceptio
7171
task.addOutput(output);
7272

7373
if (CODESYSTEM_NUM_CODEX_DATA_TRANSFER_ERROR_SOURCE_VALUE_CRR.equals(errorSource))
74-
logger.warn("Error while executing local process: code: '{}', message: {}", errorCode, errorMessage);
74+
logger.error("Error while executing local process; code: '{}', message: {}", errorCode, errorMessage);
7575
else
76-
logger.warn("Error while executing process at {}: code: '{}', message: {}", errorSource, errorCode,
76+
logger.error("Error while executing process at {}; code: '{}', message: {}", errorSource, errorCode,
7777
errorMessage);
7878

7979
errorLogger.logDataReceiveFailed(getLeadingTaskFromExecutionVariables().getIdElement()
8080
.withServerBase(getFhirWebserviceClientProvider().getLocalBaseUrl(), ResourceType.Task.name()));
8181
}
82+
83+
updateLeadingTaskInExecutionVariables(task);
8284
}
8385
}

codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/receive/LogValidationError.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,7 @@ protected void doExecute(DelegateExecution execution) throws BpmnError, Exceptio
7373
OperationOutcome outcome = (OperationOutcome) entry.getResponse().getOutcome();
7474
errorOutputParameterGenerator.createCrrValidationError(outcome).forEach(task::addOutput);
7575
});
76+
77+
updateLeadingTaskInExecutionVariables(task);
7678
}
7779
}

codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/send/LogError.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,15 @@ protected void doExecute(DelegateExecution execution) throws BpmnError, Exceptio
7272
task.addOutput(output);
7373

7474
if (CODESYSTEM_NUM_CODEX_DATA_TRANSFER_ERROR_SOURCE_VALUE_MEDIC.equals(errorSource))
75-
logger.warn("Error while executing local process: code: '{}', message: {}", errorCode, errorMessage);
75+
logger.error("Error while executing local process; code: '{}', message: {}", errorCode, errorMessage);
7676
else
77-
logger.warn("Error while executing process at {}: code: '{}', message: {}", errorSource, errorCode,
77+
logger.error("Error while executing process at {}; code: '{}', message: {}", errorSource, errorCode,
7878
errorMessage);
7979

8080
errorLogger.logDataReceiveFailed(getLeadingTaskFromExecutionVariables().getIdElement()
8181
.withServerBase(getFhirWebserviceClientProvider().getLocalBaseUrl(), ResourceType.Task.name()));
8282
}
83+
84+
updateLeadingTaskInExecutionVariables(task);
8385
}
8486
}

codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/send/LogValidationError.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ private void addErrorsToTask(Bundle bundle, Map<String, String> sourceIdsByBundl
9292

9393
errorOutputParameterGenerator.createCrrValidationError(sourceId, outcome).forEach(task::addOutput);
9494
});
95+
96+
updateLeadingTaskInExecutionVariables(task);
9597
}
9698

9799
private void logValidationDetails(Bundle bundle, Map<String, String> sourceIdsByBundleUuid)

codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/translate/DownloadDataFromDic.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.BPMN_EXECUTION_VARIABLE_RETURN_TARGET;
55
import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.CODESYSTEM_NUM_CODEX_DATA_TRANSFER;
66
import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_DATA_REFERENCE;
7+
import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_ENCRYPTED_BUNDLE_SIZE;
78
import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_ORGANIZATION_ROLE;
89
import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_ORGANIZATION_ROLE_VALUE_MEDIC;
910
import static org.highmed.dsf.bpe.ConstantsBase.NAMINGSYSTEM_HIGHMED_ENDPOINT_IDENTIFIER;
@@ -30,6 +31,7 @@
3031
import org.hl7.fhir.r4.model.Endpoint;
3132
import org.hl7.fhir.r4.model.IdType;
3233
import org.hl7.fhir.r4.model.Identifier;
34+
import org.hl7.fhir.r4.model.IntegerType;
3335
import org.hl7.fhir.r4.model.Reference;
3436
import org.hl7.fhir.r4.model.Task;
3537
import org.hl7.fhir.r4.model.Type;
@@ -61,7 +63,7 @@ public void afterPropertiesSet() throws Exception
6163
@Override
6264
protected void doExecute(DelegateExecution execution) throws BpmnError, Exception
6365
{
64-
Task task = getCurrentTaskFromExecutionVariables();
66+
Task task = getLeadingTaskFromExecutionVariables();
6567
String dicIdentifierValue = task.getRequester().getIdentifier().getValue();
6668

6769
Endpoint targetEndpoint = getEndpoint(CODESYSTEM_HIGHMED_ORGANIZATION_ROLE_VALUE_MEDIC, dicIdentifierValue);
@@ -77,7 +79,13 @@ protected void doExecute(DelegateExecution execution) throws BpmnError, Exceptio
7779
{
7880
byte[] encrypted = binary.readAllBytes();
7981
execution.setVariable(BPMN_EXECUTION_VARIABLE_BUNDLE, Variables.byteArrayValue(encrypted));
82+
83+
task.addOutput().setValue(new IntegerType(encrypted.length)).getType().getCodingFirstRep()
84+
.setSystem(CODESYSTEM_NUM_CODEX_DATA_TRANSFER)
85+
.setCode(CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_ENCRYPTED_BUNDLE_SIZE);
8086
}
87+
88+
updateLeadingTaskInExecutionVariables(task);
8189
}
8290

8391
private Optional<String> getDataReference(Task task)

codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/translate/LogError.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,15 @@ protected void doExecute(DelegateExecution execution) throws BpmnError, Exceptio
5656
logger.debug("Setting Task.status failed, adding error");
5757

5858
Task task = getLeadingTaskFromExecutionVariables();
59-
task.setStatus(TaskStatus.FAILED);
6059

6160
String errorCode = (String) execution.getVariable(BPMN_EXECUTION_VARIABLE_ERROR_CODE);
6261
String errorMessage = (String) execution.getVariable(BPMN_EXECUTION_VARIABLE_ERROR_MESSAGE);
6362
String errorSource = (String) execution.getVariable(BPMN_EXECUTION_VARIABLE_ERROR_SOURCE);
6463

64+
// only fail if local error
65+
if (errorSource == null || CODESYSTEM_NUM_CODEX_DATA_TRANSFER_ERROR_SOURCE_VALUE_GTH.equals(errorSource))
66+
task.setStatus(TaskStatus.FAILED);
67+
6568
if (!CODESYSTEM_NUM_CODEX_DATA_TRANSFER_ERROR_VALUE_VALIDATION_FAILED.equals(errorCode))
6669
{
6770
errorSource = errorSource != null ? errorSource : CODESYSTEM_NUM_CODEX_DATA_TRANSFER_ERROR_SOURCE_VALUE_GTH;
@@ -71,13 +74,15 @@ protected void doExecute(DelegateExecution execution) throws BpmnError, Exceptio
7174
task.addOutput(output);
7275

7376
if (CODESYSTEM_NUM_CODEX_DATA_TRANSFER_ERROR_SOURCE_VALUE_GTH.equals(errorSource))
74-
logger.warn("Error while executing local process: code: '{}', message: {}", errorCode, errorMessage);
75-
else
76-
logger.warn("Error while executing process at {}: code: '{}', message: {}", errorSource, errorCode,
77+
logger.error("Error while executing local process; code: '{}', message: {}", errorCode, errorMessage);
78+
else // not an error if error source remote
79+
logger.warn("Error while executing process at {}; code: '{}', message: {}", errorSource, errorCode,
7780
errorMessage);
7881

7982
errorLogger.logDataReceiveFailed(getLeadingTaskFromExecutionVariables().getIdElement()
8083
.withServerBase(getFhirWebserviceClientProvider().getLocalBaseUrl(), ResourceType.Task.name()));
8184
}
85+
86+
updateLeadingTaskInExecutionVariables(task);
8287
}
8388
}

codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/translate/LogValidationError.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,6 @@ protected void doExecute(DelegateExecution execution) throws BpmnError, Exceptio
5959
CODESYSTEM_NUM_CODEX_DATA_TRANSFER_ERROR_VALUE_VALIDATION_FAILED,
6060
"Validation failed while inserting into CRR");
6161
task.addOutput(output);
62+
updateLeadingTaskInExecutionVariables(task);
6263
}
6364
}

codex-process-data-transfer/src/main/resources/fhir/CodeSystem/num-codex-data-transfer.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,9 @@
5151
<display value="Dry Run" />
5252
<definition value="Boolean parameter to instruct the data-send process to abort after validating the generated transfer bundle but before transferring data to GTH/CRR" />
5353
</concept>
54+
<concept>
55+
<code value="encrypted-bundle-size" />
56+
<display value="Encrypted Bundle Size" />
57+
<definition value="Output parameter describing the encrypted transfer bundle size in byte" />
58+
</concept>
5459
</CodeSystem>

codex-process-data-transfer/src/main/resources/fhir/StructureDefinition/num-codex-task-start-data-receive.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,30 @@
134134
<path value="Task.input.value[x].identifier" />
135135
<max value="0" />
136136
</element>
137+
<element id="Task.output:error">
138+
<path value="Task.output" />
139+
<sliceName value="error" />
140+
</element>
141+
<element id="Task.output:error.extension">
142+
<path value="Task.output.extension" />
143+
<slicing>
144+
<discriminator>
145+
<type value="value" />
146+
<path value="url" />
147+
</discriminator>
148+
<rules value="open" />
149+
</slicing>
150+
<min value="0" />
151+
</element>
152+
<element id="Task.output:error.extension:error-metadata">
153+
<path value="Task.output.extension" />
154+
<sliceName value="error-metadata" />
155+
<min value="0" />
156+
<type>
157+
<code value="Extension" />
158+
<profile value="https://www.netzwerk-universitaetsmedizin.de/fhir/StructureDefinition/error-metadata" />
159+
</type>
160+
<isModifier value="false" />
161+
</element>
137162
</differential>
138163
</StructureDefinition>

0 commit comments

Comments
 (0)