Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release/1.0.0.0-RC2'
Browse files Browse the repository at this point in the history
* origin/release/1.0.0.0-RC2:
  1.0.0.0-RC2
  update to dsf 1.2.0, mii-common 1.0.0.0-RC2 and process date
  email message in the same format as in other tasks
  same structure for all emails
  update to dsf 1.2.0-RC1, use start task if possible
  remove not needed function
  move data-set status CodeSystem into common library
  remove copy-paste report occurances
  reset version to SNAPSHOT
  • Loading branch information
wetret committed Sep 13, 2023
2 parents 3e96133 + d19dac2 commit 6f6a08a
Show file tree
Hide file tree
Showing 23 changed files with 270 additions and 494 deletions.
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

<groupId>de.medizininformatik-initiative</groupId>
<artifactId>mii-process-data-transfer</artifactId>
<version>1.0.0.0-RC1</version>
<version>1.0.0.0-RC2</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<compileSource>17</compileSource>
<compileTarget>17</compileTarget>

<dsf.version>1.1.0</dsf.version>
<dsf.version>1.2.0</dsf.version>
<testSetup.location>../mii-processes-test-setup</testSetup.location>
</properties>

Expand Down Expand Up @@ -45,7 +45,7 @@
<dependency>
<groupId>de.medizininformatik-initiative</groupId>
<artifactId>mii-processes-common</artifactId>
<version>1.0.0.0-RC1</version>
<version>1.0.0.0-RC2</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -211,7 +211,7 @@
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/medizininformatik-initiative/mii-process-report</url>
<url>https://maven.pkg.github.com/medizininformatik-initiative/mii-process-data-transfer</url>
</repository>
</distributionManagement>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public interface ConstantsDataTransfer
String PROFILE_TASK_DATA_SEND_PROCESS_URI = ConstantsBase.PROCESS_MII_URI_BASE + PROCESS_NAME_DATA_RECEIVE;
String PROFILE_TASK_DATA_SEND_MESSAGE_NAME = "dataSend";

String PROFILE_TASK_DATA_RECEIVE = "http://medizininformatik-initiative.de/fhir/StructureDefinition/task-data-receive";
String PROFILE_TASK_DATA_RECEIVE_PROCESS_URI = ConstantsBase.PROCESS_MII_URI_BASE + PROCESS_NAME_DATA_SEND;
String PROFILE_TASK_DATA_RECEIVE_MESSAGE_NAME = "dataReceive";
String PROFILE_TASK_DATA_STATUS = "http://medizininformatik-initiative.de/fhir/StructureDefinition/task-data-status";
String PROFILE_TASK_DATA_STATUS_PROCESS_URI = ConstantsBase.PROCESS_MII_URI_BASE + PROCESS_NAME_DATA_SEND;
String PROFILE_TASK_DATA_STATUS_MESSAGE_NAME = "dataStatus";

String BPMN_EXECUTION_VARIABLE_PROJECT_IDENTIFIER = "projectIdentifier";
String BPMN_EXECUTION_VARIABLE_DMS_IDENTIFIER = "dms-identifier";
Expand All @@ -40,15 +40,4 @@ public interface ConstantsDataTransfer
String CODESYSTEM_DATA_TRANSFER_VALUE_DATA_SET_REFERENCE = "data-set-reference";
String CODESYSTEM_DATA_TRANSFER_VALUE_DOCUMENT_REFERENCE_LOCATION = "document-reference-location";
String CODESYSTEM_DATA_TRANSFER_VALUE_DATA_SET_STATUS = "data-set-status";

String CODESYSTEM_DATA_SET_STATUS = "http://medizininformatik-initiative.de/fhir/CodeSystem/data-set-status";
String CODESYSTEM_DATA_SET_STATUS_VALUE_NOT_ALLOWED = "not-allowed";
String CODESYSTEM_DATA_SET_STATUS_VALUE_NOT_REACHABLE = "not-reachable";
String CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIPT_MISSING = "receipt-missing";
String CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIPT_OK = "receipt-ok";
String CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIPT_ERROR = "receipt-error";
String CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIVE_OK = "receive-ok";
String CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIVE_ERROR = "receive-error";

String EXTENSION_DATA_SET_STATUS_ERROR_URL = "http://medizininformatik-initiative.de/fhir/StructureDefinition/extension-data-set-status-error";
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public class DataTransferProcessPluginDefinition implements ProcessPluginDefinition
{
public static final String VERSION = "1.0.0.0";
public static final LocalDate RELEASE_DATE = LocalDate.of(2022, 8, 31);
public static final LocalDate RELEASE_DATE = LocalDate.of(2022, 9, 13);

@Override
public String getName()
Expand Down Expand Up @@ -52,29 +52,29 @@ public Map<String, List<String>> getFhirResourcesByProcessId()
var aSend = "fhir/ActivityDefinition/data-transfer-send.xml";

var cCrypto = "fhir/CodeSystem/mii-cryptography.xml";
var cDaSeSt = "fhir/CodeSystem/data-set-status.xml";
var cDaSeSt = "fhir/CodeSystem/mii-data-set-status.xml";
var cDaTr = "fhir/CodeSystem/data-transfer.xml";

var eDaSeStEr = "fhir/StructureDefinition/extension-data-set-status-error.xml";

var nPrId = "fhir/NamingSystem/mii-project-identifier.xml";

var sReceive = "fhir/StructureDefinition/task-data-receive.xml";
var sSend = "fhir/StructureDefinition/task-data-send.xml";
var sSendStart = "fhir/StructureDefinition/task-data-send-start.xml";
var sStatus = "fhir/StructureDefinition/task-data-status.xml";

var tSendStart = "fhir/Task/task-data-send-start.xml";

var vCrypto = "fhir/ValueSet/mii-cryptography.xml";
var vDaSeStRe = "fhir/ValueSet/data-set-status-receive.xml";
var vDaSeStSe = "fhir/ValueSet/data-set-status-send.xml";
var vDaSeStRe = "fhir/ValueSet/mii-data-set-status-receive.xml";
var vDaSeStSe = "fhir/ValueSet/mii-data-set-status-send.xml";
var vDaTr = "fhir/ValueSet/data-transfer.xml";

return Map.of( //
ConstantsDataTransfer.PROCESS_NAME_FULL_DATA_RECEIVE, //
Arrays.asList(aReceive, cCrypto, cDaSeSt, cDaTr, eDaSeStEr, nPrId, sSend, vCrypto, vDaSeStRe, vDaTr), //
ConstantsDataTransfer.PROCESS_NAME_FULL_DATA_SEND, //
Arrays.asList(aSend, cDaSeSt, cDaTr, eDaSeStEr, nPrId, sSendStart, sReceive, tSendStart, vDaSeStSe,
Arrays.asList(aSend, cDaSeSt, cDaTr, eDaSeStEr, nPrId, sStatus, sSendStart, tSendStart, vDaSeStSe,
vDaTr));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import org.springframework.beans.factory.InitializingBean;

import de.medizininformatik_initiative.process.data_transfer.ConstantsDataTransfer;
import de.medizininformatik_initiative.process.data_transfer.util.DataSetStatusGenerator;
import de.medizininformatik_initiative.processes.common.util.ConstantsBase;
import de.medizininformatik_initiative.processes.common.util.DataSetStatusGenerator;
import dev.dsf.bpe.v1.ProcessPluginApi;
import dev.dsf.bpe.v1.activity.AbstractTaskMessageSend;
import dev.dsf.bpe.v1.variables.Variables;
Expand Down Expand Up @@ -74,36 +74,26 @@ protected IdType doSend(FhirWebserviceClient client, Task task)
.create(task);
}

@Override
protected void handleIntermediateThrowEventError(DelegateExecution execution, Variables variables,
Exception exception, String errorMessage)
{
handleError(variables, exception);
}

@Override
protected void handleSendTaskError(DelegateExecution execution, Variables variables, Exception exception,
String errorMessage)
{
handleError(variables, exception);
}

private void handleError(Variables variables, Exception exception)
{
Task task = variables.getStartTask();

String statusCode = ConstantsDataTransfer.CODESYSTEM_DATA_SET_STATUS_VALUE_NOT_REACHABLE;
String statusCode = ConstantsBase.CODESYSTEM_DATA_SET_STATUS_VALUE_NOT_REACHABLE;
if (exception instanceof WebApplicationException webApplicationException)
{
if (webApplicationException.getResponse() != null
&& webApplicationException.getResponse().getStatus() == Response.Status.FORBIDDEN.getStatusCode())
{
statusCode = ConstantsDataTransfer.CODESYSTEM_DATA_SET_STATUS_VALUE_NOT_ALLOWED;
statusCode = ConstantsBase.CODESYSTEM_DATA_SET_STATUS_VALUE_NOT_ALLOWED;
}
}

task.setStatus(Task.TaskStatus.FAILED);
task.addOutput(statusGenerator.createDataSetStatusOutput(statusCode, "Send data-set failed"));
task.addOutput(
statusGenerator.createDataSetStatusOutput(statusCode, ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER,
ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER_VALUE_DATA_SET_STATUS, "Send data-set failed"));
variables.updateTask(task);

variables.setString(ConstantsDataTransfer.BPMN_EXECUTION_VARIABLE_DATA_SEND_ERROR_MESSAGE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@

import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.hl7.fhir.r4.model.Coding;
import org.hl7.fhir.r4.model.IdType;
import org.hl7.fhir.r4.model.Task;
import org.hl7.fhir.r4.model.Type;
import org.springframework.beans.factory.InitializingBean;

import de.medizininformatik_initiative.process.data_transfer.ConstantsDataTransfer;
import de.medizininformatik_initiative.process.data_transfer.util.DataSetStatusGenerator;
import de.medizininformatik_initiative.processes.common.util.ConstantsBase;
import de.medizininformatik_initiative.processes.common.util.DataSetStatusGenerator;
import dev.dsf.bpe.v1.ProcessPluginApi;
import dev.dsf.bpe.v1.activity.AbstractTaskMessageSend;
import dev.dsf.bpe.v1.variables.Variables;
import dev.dsf.fhir.client.FhirWebserviceClient;

public class SendReceipt extends AbstractTaskMessageSend implements InitializingBean
{
Expand Down Expand Up @@ -42,9 +45,20 @@ protected Stream<Task.ParameterComponent> getAdditionalInputParameters(DelegateE
return createReceiptOk();
}

@Override
protected IdType doSend(FhirWebserviceClient client, Task task)
{
return client.withMinimalReturn()
.withRetry(ConstantsBase.DSF_CLIENT_RETRY_6_TIMES, ConstantsBase.DSF_CLIENT_RETRY_INTERVAL_5MIN)
.create(task);
}

private Stream<Task.ParameterComponent> createReceiptError(Variables variables)
{
return statusGenerator.transformOutputToInputComponent(variables.getStartTask())
return statusGenerator
.transformOutputToInputComponent(variables.getStartTask(),
ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER,
ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER_VALUE_DATA_SET_STATUS)
.map(this::receiveToReceiptStatus);
}

Expand All @@ -53,9 +67,9 @@ private Task.ParameterComponent receiveToReceiptStatus(Task.ParameterComponent p
Type value = parameterComponent.getValue();
if (value instanceof Coding coding)
{
if (ConstantsDataTransfer.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIVE_ERROR.equals(coding.getCode()))
if (ConstantsBase.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIVE_ERROR.equals(coding.getCode()))
{
coding.setCode(ConstantsDataTransfer.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIPT_ERROR);
coding.setCode(ConstantsBase.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIPT_ERROR);
}
}

Expand All @@ -67,8 +81,8 @@ private Stream<Task.ParameterComponent> createReceiptOk()
Task.ParameterComponent parameterComponent = new Task.ParameterComponent();
parameterComponent.getType().addCoding().setSystem(ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER)
.setCode(ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER_VALUE_DATA_SET_STATUS);
parameterComponent.setValue(new Coding().setSystem(ConstantsDataTransfer.CODESYSTEM_DATA_SET_STATUS)
.setCode(ConstantsDataTransfer.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIPT_OK));
parameterComponent.setValue(new Coding().setSystem(ConstantsBase.CODESYSTEM_DATA_SET_STATUS)
.setCode(ConstantsBase.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIPT_OK));

return Stream.of(parameterComponent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@

import ca.uhn.fhir.context.FhirContext;
import de.medizininformatik_initiative.process.data_transfer.ConstantsDataTransfer;
import de.medizininformatik_initiative.process.data_transfer.util.DataSetStatusGenerator;
import de.medizininformatik_initiative.processes.common.crypto.KeyProvider;
import de.medizininformatik_initiative.processes.common.crypto.RsaAesGcmUtil;
import de.medizininformatik_initiative.processes.common.fhir.client.logging.DataLogger;
import de.medizininformatik_initiative.processes.common.util.ConstantsBase;
import de.medizininformatik_initiative.processes.common.util.DataSetStatusGenerator;
import dev.dsf.bpe.v1.ProcessPluginApi;
import dev.dsf.bpe.v1.activity.AbstractServiceDelegate;
import dev.dsf.bpe.v1.variables.Variables;
Expand Down Expand Up @@ -78,7 +79,9 @@ protected void doExecute(DelegateExecution execution, Variables variables)
{
task.setStatus(Task.TaskStatus.FAILED);
task.addOutput(statusGenerator.createDataSetStatusOutput(
ConstantsDataTransfer.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIVE_ERROR, "Decrypt data-set failed"));
ConstantsBase.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIVE_ERROR,
ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER,
ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER_VALUE_DATA_SET_STATUS, "Decrypt data-set failed"));
variables.updateTask(task);

variables.setString(ConstantsDataTransfer.BPMN_EXECUTION_VARIABLE_DATA_RECEIVE_ERROR_MESSAGE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import org.springframework.beans.factory.InitializingBean;

import de.medizininformatik_initiative.process.data_transfer.ConstantsDataTransfer;
import de.medizininformatik_initiative.process.data_transfer.util.DataSetStatusGenerator;
import de.medizininformatik_initiative.processes.common.util.ConstantsBase;
import de.medizininformatik_initiative.processes.common.util.DataSetStatusGenerator;
import dev.dsf.bpe.v1.ProcessPluginApi;
import dev.dsf.bpe.v1.activity.AbstractServiceDelegate;
import dev.dsf.bpe.v1.variables.Variables;
Expand Down Expand Up @@ -70,7 +70,9 @@ protected void doExecute(DelegateExecution execution, Variables variables)
{
task.setStatus(Task.TaskStatus.FAILED);
task.addOutput(statusGenerator.createDataSetStatusOutput(
ConstantsDataTransfer.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIVE_ERROR, "Download data-set failed"));
ConstantsBase.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIVE_ERROR,
ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER,
ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER_VALUE_DATA_SET_STATUS, "Download data-set failed"));
variables.updateTask(task);

variables.setString(ConstantsDataTransfer.BPMN_EXECUTION_VARIABLE_DATA_RECEIVE_ERROR_MESSAGE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,25 @@ public HandleErrorReceive(ProcessPluginApi api)
protected void doExecute(DelegateExecution delegateExecution, Variables variables)
{
Task task = variables.getStartTask();
String projectIdentifier = variables
.getString(ConstantsDataTransfer.BPMN_EXECUTION_VARIABLE_PROJECT_IDENTIFIER);
String error = variables.getString(ConstantsDataTransfer.BPMN_EXECUTION_VARIABLE_DATA_RECEIVE_ERROR_MESSAGE);

if (Task.TaskStatus.FAILED.equals(task.getStatus()))
{
sendMail(task, variables);
api.getFhirWebserviceClientProvider().getLocalWebserviceClient()
.withRetry(ConstantsBase.DSF_CLIENT_RETRY_6_TIMES, ConstantsBase.DSF_CLIENT_RETRY_INTERVAL_5MIN)
.update(task);
}
sendMail(task, projectIdentifier, error);
api.getFhirWebserviceClientProvider().getLocalWebserviceClient()
.withRetry(ConstantsBase.DSF_CLIENT_RETRY_6_TIMES, ConstantsBase.DSF_CLIENT_RETRY_INTERVAL_5MIN)
.update(task);
}

private void sendMail(Task task, Variables variables)
private void sendMail(Task task, String projectIdentifier, String error)
{
String error = variables.getString(ConstantsDataTransfer.BPMN_EXECUTION_VARIABLE_DATA_RECEIVE_ERROR_MESSAGE);

String subject = "Error in process '" + ConstantsDataTransfer.PROCESS_NAME_FULL_DATA_RECEIVE + "'";
String message = "Could not download and insert new data-set in process '"
+ ConstantsDataTransfer.PROCESS_NAME_FULL_DATA_RECEIVE + "' from organization '"
+ task.getRequester().getIdentifier().getValue() + "' in Task with id '" + task.getId() + "':\n"
+ "- status code: " + ConstantsDataTransfer.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIVE_ERROR + "\n"
+ "- error: " + (error == null ? "none" : error);
+ ConstantsDataTransfer.PROCESS_NAME_FULL_DATA_RECEIVE + "' for Task with id '" + task.getId()
+ "' from organization '" + task.getRequester().getIdentifier().getValue()
+ "' for project-identifier '" + projectIdentifier + "':\n" + "- status code: "
+ ConstantsBase.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIVE_ERROR + "\n" + "- error: "
+ (error == null ? "none" : error);

api.getMailService().send(subject, message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.hl7.fhir.r4.model.Task;

import de.medizininformatik_initiative.process.data_transfer.ConstantsDataTransfer;
import de.medizininformatik_initiative.processes.common.util.ConstantsBase;
import dev.dsf.bpe.v1.ProcessPluginApi;
import dev.dsf.bpe.v1.activity.AbstractServiceDelegate;
import dev.dsf.bpe.v1.variables.Variables;
Expand Down Expand Up @@ -36,14 +37,14 @@ private void sendMail(Task task, Variables variables)

String statusCode = task.getOutput().stream().filter(o -> o.getValue() instanceof Coding)
.map(o -> (Coding) o.getValue())
.filter(c -> ConstantsDataTransfer.CODESYSTEM_DATA_SET_STATUS.equals(c.getSystem()))
.map(c -> c.getCode()).findFirst().orElse("unknown");
.filter(c -> ConstantsBase.CODESYSTEM_DATA_SET_STATUS.equals(c.getSystem())).map(c -> c.getCode())
.findFirst().orElse("unknown");

String subject = "Error in process '" + ConstantsDataTransfer.BPMN_EXECUTION_VARIABLE_DATA_SEND_ERROR + "'";
String message = "Could not send data-set in process '" + ConstantsDataTransfer.PROCESS_NAME_FULL_DATA_SEND
+ "' to DMS with identifier '" + dmsIdentifier + "' for project-identifier '" + projectIdentifier
+ "' in Task with id '" + task.getId() + "':\n" + "- status code: " + statusCode + "\n" + "- error: "
+ (error == null ? "none" : error);
+ "' for Task with id '" + task.getId() + "' to DMS with identifier '" + dmsIdentifier
+ "' for project-identifier '" + projectIdentifier + "':\n" + "- status code: " + statusCode + "\n"
+ "- error: " + (error == null ? "none" : error);

api.getMailService().send(subject, message);
}
Expand Down
Loading

0 comments on commit 6f6a08a

Please sign in to comment.