diff --git a/pom.xml b/pom.xml index 8b7c161..2584ecb 100644 --- a/pom.xml +++ b/pom.xml @@ -6,14 +6,14 @@ de.medizininformatik-initiative mii-process-data-transfer - 1.0.0.0-RC1 + 1.0.0.0-RC2 UTF-8 17 17 - 1.1.0 + 1.2.0 ../mii-processes-test-setup @@ -45,7 +45,7 @@ de.medizininformatik-initiative mii-processes-common - 1.0.0.0-RC1 + 1.0.0.0-RC2 @@ -211,7 +211,7 @@ github GitHub Packages - https://maven.pkg.github.com/medizininformatik-initiative/mii-process-report + https://maven.pkg.github.com/medizininformatik-initiative/mii-process-data-transfer diff --git a/src/main/java/de/medizininformatik_initiative/process/data_transfer/ConstantsDataTransfer.java b/src/main/java/de/medizininformatik_initiative/process/data_transfer/ConstantsDataTransfer.java index 3cafbab..bdbcf2c 100644 --- a/src/main/java/de/medizininformatik_initiative/process/data_transfer/ConstantsDataTransfer.java +++ b/src/main/java/de/medizininformatik_initiative/process/data_transfer/ConstantsDataTransfer.java @@ -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"; @@ -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"; } diff --git a/src/main/java/de/medizininformatik_initiative/process/data_transfer/DataTransferProcessPluginDefinition.java b/src/main/java/de/medizininformatik_initiative/process/data_transfer/DataTransferProcessPluginDefinition.java index a275304..550cb5b 100644 --- a/src/main/java/de/medizininformatik_initiative/process/data_transfer/DataTransferProcessPluginDefinition.java +++ b/src/main/java/de/medizininformatik_initiative/process/data_transfer/DataTransferProcessPluginDefinition.java @@ -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() @@ -52,29 +52,29 @@ public Map> 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)); } } diff --git a/src/main/java/de/medizininformatik_initiative/process/data_transfer/message/SendData.java b/src/main/java/de/medizininformatik_initiative/process/data_transfer/message/SendData.java index 1fa5269..f3e774e 100644 --- a/src/main/java/de/medizininformatik_initiative/process/data_transfer/message/SendData.java +++ b/src/main/java/de/medizininformatik_initiative/process/data_transfer/message/SendData.java @@ -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; @@ -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, diff --git a/src/main/java/de/medizininformatik_initiative/process/data_transfer/message/SendReceipt.java b/src/main/java/de/medizininformatik_initiative/process/data_transfer/message/SendReceipt.java index d492eea..1540dd1 100644 --- a/src/main/java/de/medizininformatik_initiative/process/data_transfer/message/SendReceipt.java +++ b/src/main/java/de/medizininformatik_initiative/process/data_transfer/message/SendReceipt.java @@ -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 { @@ -42,9 +45,20 @@ protected Stream 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 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); } @@ -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); } } @@ -67,8 +81,8 @@ private Stream 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); } diff --git a/src/main/java/de/medizininformatik_initiative/process/data_transfer/service/DecryptData.java b/src/main/java/de/medizininformatik_initiative/process/data_transfer/service/DecryptData.java index ec21762..a7bb501 100644 --- a/src/main/java/de/medizininformatik_initiative/process/data_transfer/service/DecryptData.java +++ b/src/main/java/de/medizininformatik_initiative/process/data_transfer/service/DecryptData.java @@ -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; @@ -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, diff --git a/src/main/java/de/medizininformatik_initiative/process/data_transfer/service/DownloadData.java b/src/main/java/de/medizininformatik_initiative/process/data_transfer/service/DownloadData.java index c517b1b..d9c539f 100644 --- a/src/main/java/de/medizininformatik_initiative/process/data_transfer/service/DownloadData.java +++ b/src/main/java/de/medizininformatik_initiative/process/data_transfer/service/DownloadData.java @@ -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; @@ -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, diff --git a/src/main/java/de/medizininformatik_initiative/process/data_transfer/service/HandleErrorReceive.java b/src/main/java/de/medizininformatik_initiative/process/data_transfer/service/HandleErrorReceive.java index d1bf921..f9f8e6c 100644 --- a/src/main/java/de/medizininformatik_initiative/process/data_transfer/service/HandleErrorReceive.java +++ b/src/main/java/de/medizininformatik_initiative/process/data_transfer/service/HandleErrorReceive.java @@ -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); } diff --git a/src/main/java/de/medizininformatik_initiative/process/data_transfer/service/HandleErrorSend.java b/src/main/java/de/medizininformatik_initiative/process/data_transfer/service/HandleErrorSend.java index c31d653..1050acd 100644 --- a/src/main/java/de/medizininformatik_initiative/process/data_transfer/service/HandleErrorSend.java +++ b/src/main/java/de/medizininformatik_initiative/process/data_transfer/service/HandleErrorSend.java @@ -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; @@ -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); } diff --git a/src/main/java/de/medizininformatik_initiative/process/data_transfer/service/InsertData.java b/src/main/java/de/medizininformatik_initiative/process/data_transfer/service/InsertData.java index 6e309cd..e8e41e7 100644 --- a/src/main/java/de/medizininformatik_initiative/process/data_transfer/service/InsertData.java +++ b/src/main/java/de/medizininformatik_initiative/process/data_transfer/service/InsertData.java @@ -17,9 +17,10 @@ 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.fhir.client.FhirClient; import de.medizininformatik_initiative.processes.common.fhir.client.FhirClientFactory; +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; @@ -67,17 +68,21 @@ protected void doExecute(DelegateExecution execution, Variables variables) { List createdIds = storeData(variables, fhirClient, bundle, sendingOrganization, projectIdentifier); - task.addOutput(statusGenerator - .createDataSetStatusOutput(ConstantsDataTransfer.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIVE_OK)); + task.addOutput( + statusGenerator.createDataSetStatusOutput(ConstantsBase.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIVE_OK, + ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER, + ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER_VALUE_DATA_SET_STATUS)); variables.updateTask(task); - sendMail(createdIds, sendingOrganization, projectIdentifier); + sendMail(task, createdIds, sendingOrganization, projectIdentifier); } catch (Exception exception) { task.setStatus(Task.TaskStatus.FAILED); task.addOutput(statusGenerator.createDataSetStatusOutput( - ConstantsDataTransfer.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIVE_ERROR, "Insert data-set failed")); + ConstantsBase.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIVE_ERROR, + ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER, + ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER_VALUE_DATA_SET_STATUS, "Insert data-set failed")); variables.updateTask(task); variables.setString(ConstantsDataTransfer.BPMN_EXECUTION_VARIABLE_DATA_RECEIVE_ERROR_MESSAGE, @@ -104,24 +109,25 @@ private List storeData(Variables variables, FhirClient fhirClient, Bundl .map(IdType::new).map(id -> setIdBase(id, fhirClient)).collect(toList()); idsOfCreatedResources.stream().filter(i -> ResourceType.DocumentReference.name().equals(i.getResourceType())) - .forEach(i -> addOutputToLeadingTask(variables, i)); + .forEach(i -> addOutputToStartTask(variables, i)); idsOfCreatedResources.forEach(id -> toLogMessage(id, sendingOrganization, projectIdentifier)); return idsOfCreatedResources; } - private void sendMail(List createdIds, String sendingOrganization, String projectIdentifier) + private void sendMail(Task task, List createdIds, String sendingOrganization, String projectIdentifier) { String subject = "New data-set received in process '" + ConstantsDataTransfer.PROCESS_NAME_FULL_DATA_RECEIVE + "'"; - StringBuilder message = new StringBuilder("New data-set has been stored for project-identifier '") - .append(projectIdentifier).append("' in process '") - .append(ConstantsDataTransfer.PROCESS_NAME_FULL_DATA_RECEIVE).append("' received from organization '") - .append(sendingOrganization).append("' and can be accessed using the following links:\n"); + StringBuilder message = new StringBuilder("A new data-set has been stored in process '" + + ConstantsDataTransfer.PROCESS_NAME_FULL_DATA_RECEIVE + "' for Task with id '" + task.getId() + + "' received from organization '" + sendingOrganization + "' for project-identifier '" + + projectIdentifier + "' with status code '" + ConstantsBase.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIVE_OK + + "' and can be accessed using the following links:\n"); for (IdType id : createdIds) - message.append("- ").append(id.getValue()).append("\n"); + message.append(id.getValue()).append("\n"); api.getMailService().send(subject, message.toString()); } @@ -140,7 +146,7 @@ private void toLogMessage(IdType idType, String sendingOrganization, String proj projectIdentifier); } - private void addOutputToLeadingTask(Variables variables, IdType id) + private void addOutputToStartTask(Variables variables, IdType id) { Task startTask = variables.getStartTask(); startTask.addOutput().setValue(new Reference(id.getValue()).setType(id.getResourceType())).getType().addCoding() diff --git a/src/main/java/de/medizininformatik_initiative/process/data_transfer/service/StoreReceipt.java b/src/main/java/de/medizininformatik_initiative/process/data_transfer/service/StoreReceipt.java index 368989d..261d2e4 100644 --- a/src/main/java/de/medizininformatik_initiative/process/data_transfer/service/StoreReceipt.java +++ b/src/main/java/de/medizininformatik_initiative/process/data_transfer/service/StoreReceipt.java @@ -10,8 +10,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; @@ -64,72 +64,77 @@ else if (Task.TaskStatus.INPROGRESS.equals(startTask.getStatus())) private void handleReceivedResponse(Task startTask, Task currentTask) { - statusGenerator.transformInputToOutput(currentTask, startTask); + statusGenerator.transformInputToOutput(currentTask, startTask, ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER, + ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER_VALUE_DATA_SET_STATUS); if (startTask.getOutput().stream().filter(Task.TaskOutputComponent::hasExtension) .flatMap(o -> o.getExtension().stream()) - .anyMatch(e -> ConstantsDataTransfer.EXTENSION_DATA_SET_STATUS_ERROR_URL.equals(e.getUrl()))) + .anyMatch(e -> ConstantsBase.EXTENSION_DATA_SET_STATUS_ERROR_URL.equals(e.getUrl()))) startTask.setStatus(Task.TaskStatus.FAILED); } private void handleMissingResponse(Task startTask) { startTask.setStatus(Task.TaskStatus.FAILED); - startTask.addOutput(statusGenerator - .createDataSetStatusOutput(ConstantsDataTransfer.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIPT_MISSING)); + startTask.addOutput(statusGenerator.createDataSetStatusOutput( + ConstantsBase.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIPT_MISSING, + ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER, + ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER_VALUE_DATA_SET_STATUS)); } private void writeStatusLogAndSendMail(Task startTask, String projectIdentifier, String dmsIdentifier) { - startTask.getOutput().stream().filter(o -> o.getValue() instanceof Coding).filter( - o -> ConstantsDataTransfer.CODESYSTEM_DATA_SET_STATUS.equals(((Coding) o.getValue()).getSystem())) - .forEach(o -> doWriteStatusLogAndSendMail(o, startTask.getId(), projectIdentifier, dmsIdentifier)); + startTask.getOutput().stream().filter(o -> o.getValue() instanceof Coding) + .filter(o -> ConstantsBase.CODESYSTEM_DATA_SET_STATUS.equals(((Coding) o.getValue()).getSystem())) + .forEach(o -> doWriteStatusLogAndSendMail(o, startTask, projectIdentifier, dmsIdentifier)); } - private void doWriteStatusLogAndSendMail(Task.TaskOutputComponent output, String startTaskId, - String projectIdentifier, String dmsIdentifier) + private void doWriteStatusLogAndSendMail(Task.TaskOutputComponent output, Task task, String projectIdentifier, + String dmsIdentifier) { Coding status = (Coding) output.getValue(); String code = status.getCode(); String error = output.hasExtension() ? output.getExtensionFirstRep().getValueAsPrimitive().getValueAsString() : "none"; - String errorLog = error.isBlank() ? "" : " - " + error; - if (ConstantsDataTransfer.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIPT_OK.equals(code)) + if (ConstantsBase.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIPT_OK.equals(code)) { logger.info( "Task with id '{}' for project-identifier '{}' and DMS with identifier '{}' has data-set status code '{}'", - startTaskId, projectIdentifier, dmsIdentifier, code); - sendSuccessfulMail(projectIdentifier, dmsIdentifier, code); + task, projectIdentifier, dmsIdentifier, code); + + sendSuccessfulMail(task, projectIdentifier, dmsIdentifier, code); } else { + String errorLog = error.isBlank() ? "" : " - " + error; logger.warn( "Task with id '{}' for project-identifier '{}' and DMS with identifier '{}' has data-set status code '{}'{}", - startTaskId, projectIdentifier, dmsIdentifier, code, errorLog); - sendErrorMail(startTaskId, projectIdentifier, dmsIdentifier, code, error); + task.getId(), projectIdentifier, dmsIdentifier, code, errorLog); + + sendErrorMail(task, projectIdentifier, dmsIdentifier, code, error); } } - private void sendSuccessfulMail(String projectIdentifier, String dmsIdentifier, String code) + private void sendSuccessfulMail(Task task, String projectIdentifier, String dmsIdentifier, String code) { String subject = "Data-set successfully delivered in process '" + ConstantsDataTransfer.PROCESS_NAME_FULL_DATA_SEND + "'"; - String message = "A data-set has been successfully delivered and retrieved by the DMS with identifier '" - + dmsIdentifier + "' for project-identifier '" + projectIdentifier + "' with status code '" + code - + "' in process '" + ConstantsDataTransfer.PROCESS_NAME_FULL_DATA_SEND + "'"; + String message = "A data-set has been successfully delivered and retrieved in process '" + + ConstantsDataTransfer.PROCESS_NAME_FULL_DATA_SEND + "' for Task with id '" + task.getId() + + "' to/from DMS with identifier '" + dmsIdentifier + "' for project-identifier '" + projectIdentifier + + "' with status code '" + code + "'"; api.getMailService().send(subject, message); } - private void sendErrorMail(String startTaskId, String projectIdentifier, String dmsIdentifier, String code, - String error) + private void sendErrorMail(Task task, String projectIdentifier, String dmsIdentifier, String code, String error) { String subject = "Error in process '" + ConstantsDataTransfer.PROCESS_NAME_FULL_DATA_SEND + "'"; - String message = "DMS '" + dmsIdentifier - + "' could not download, decrypt, validate or insert data-set for project-identifier '" - + projectIdentifier + "' in process '" + ConstantsDataTransfer.PROCESS_NAME_FULL_DATA_SEND - + "' in Task with id '" + startTaskId + "':\n" + "- status code: " + code + "\n" + "- error: " + error; + String message = "Could not download, decrypt, validate or insert data-set in process '" + + ConstantsDataTransfer.PROCESS_NAME_FULL_DATA_SEND + "' for Task with id '" + task.getId() + + "' at DMS with identifier '" + dmsIdentifier + "' for project-identifier '" + projectIdentifier + + "':\n" + "- status code: " + code + "\n" + "- error: " + error; api.getMailService().send(subject, message); } diff --git a/src/main/java/de/medizininformatik_initiative/process/data_transfer/service/ValidateDataDms.java b/src/main/java/de/medizininformatik_initiative/process/data_transfer/service/ValidateDataDms.java index 8dbc5f2..1eab1ac 100644 --- a/src/main/java/de/medizininformatik_initiative/process/data_transfer/service/ValidateDataDms.java +++ b/src/main/java/de/medizininformatik_initiative/process/data_transfer/service/ValidateDataDms.java @@ -18,8 +18,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 de.medizininformatik_initiative.processes.common.util.MimeTypeHelper; import dev.dsf.bpe.v1.ProcessPluginApi; import dev.dsf.bpe.v1.activity.AbstractServiceDelegate; @@ -52,7 +52,7 @@ public void afterPropertiesSet() throws Exception @Override protected void doExecute(DelegateExecution execution, Variables variables) { - Task task = variables.getLatestTask(); + Task task = variables.getStartTask(); String sendingOrganization = task.getRequester().getIdentifier().getValue(); String projectIdentifier = variables .getString(ConstantsDataTransfer.BPMN_EXECUTION_VARIABLE_PROJECT_IDENTIFIER); @@ -87,15 +87,14 @@ protected void doExecute(DelegateExecution execution, Variables variables) throw new RuntimeException("Bundle contains " + countDr + " DocumentReferences (expected 1)"); } - String identifierRequester = variables.getStartTask().getRequester().getIdentifier().getValue(); String identifierAuthor = documentReferences.stream().filter(DocumentReference::hasAuthor) .flatMap(dr -> dr.getAuthor().stream()).filter(Reference::hasIdentifier) .map(Reference::getIdentifier).filter(Identifier::hasValue).map(Identifier::getValue).findFirst() .orElse("no-author"); - if (!identifierAuthor.equals(identifierRequester)) + if (!identifierAuthor.equals(sendingOrganization)) { throw new RuntimeException("Requester in Task does not match author in DocumentReference (" - + identifierRequester + " != " + identifierAuthor + ")"); + + sendingOrganization + " != " + identifierAuthor + ")"); } long countMi = documentReferences.stream().filter(DocumentReference::hasMasterIdentifier) @@ -127,7 +126,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, "Validate data-set failed")); + ConstantsBase.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIVE_ERROR, + ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER, + ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER_VALUE_DATA_SET_STATUS, "Validate data-set failed")); variables.updateTask(task); variables.setString(ConstantsDataTransfer.BPMN_EXECUTION_VARIABLE_DATA_RECEIVE_ERROR_MESSAGE, diff --git a/src/main/java/de/medizininformatik_initiative/process/data_transfer/spring/config/TransferDataConfig.java b/src/main/java/de/medizininformatik_initiative/process/data_transfer/spring/config/TransferDataConfig.java index 0e036e1..b3b9746 100644 --- a/src/main/java/de/medizininformatik_initiative/process/data_transfer/spring/config/TransferDataConfig.java +++ b/src/main/java/de/medizininformatik_initiative/process/data_transfer/spring/config/TransferDataConfig.java @@ -24,9 +24,9 @@ import de.medizininformatik_initiative.process.data_transfer.service.StoreReceipt; import de.medizininformatik_initiative.process.data_transfer.service.ValidateDataDic; import de.medizininformatik_initiative.process.data_transfer.service.ValidateDataDms; -import de.medizininformatik_initiative.process.data_transfer.util.DataSetStatusGenerator; import de.medizininformatik_initiative.processes.common.crypto.KeyProvider; import de.medizininformatik_initiative.processes.common.crypto.KeyProviderImpl; +import de.medizininformatik_initiative.processes.common.util.DataSetStatusGenerator; import de.medizininformatik_initiative.processes.common.util.MimeTypeHelper; import dev.dsf.bpe.v1.ProcessPluginApi; import dev.dsf.bpe.v1.ProcessPluginDeploymentStateListener; diff --git a/src/main/java/de/medizininformatik_initiative/process/data_transfer/util/DataSetStatusGenerator.java b/src/main/java/de/medizininformatik_initiative/process/data_transfer/util/DataSetStatusGenerator.java deleted file mode 100644 index 26a4507..0000000 --- a/src/main/java/de/medizininformatik_initiative/process/data_transfer/util/DataSetStatusGenerator.java +++ /dev/null @@ -1,101 +0,0 @@ -package de.medizininformatik_initiative.process.data_transfer.util; - -import java.util.stream.Stream; - -import org.hl7.fhir.r4.model.BackboneElement; -import org.hl7.fhir.r4.model.Coding; -import org.hl7.fhir.r4.model.StringType; -import org.hl7.fhir.r4.model.Task; -import org.hl7.fhir.r4.model.Task.ParameterComponent; -import org.hl7.fhir.r4.model.Task.TaskOutputComponent; - -import de.medizininformatik_initiative.process.data_transfer.ConstantsDataTransfer; - -public class DataSetStatusGenerator -{ - public ParameterComponent createDataSetStatusInput(String statusCode) - { - return createDataSetStatusInput(statusCode, null); - } - - public ParameterComponent createDataSetStatusInput(String statusCode, String errorMessage) - { - ParameterComponent input = new ParameterComponent(); - input.setValue(new Coding().setSystem(ConstantsDataTransfer.CODESYSTEM_DATA_SET_STATUS).setCode(statusCode)); - input.getType().addCoding().setSystem(ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER) - .setCode(ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER_VALUE_DATA_SET_STATUS); - - if (errorMessage != null) - addErrorExtension(input, errorMessage); - - return input; - } - - public TaskOutputComponent createDataSetStatusOutput(String statusCode) - { - return createDataSetStatusOutput(statusCode, null); - } - - public TaskOutputComponent createDataSetStatusOutput(String statusCode, String errorMessage) - { - TaskOutputComponent output = new TaskOutputComponent(); - output.setValue(new Coding().setSystem(ConstantsDataTransfer.CODESYSTEM_DATA_SET_STATUS).setCode(statusCode)); - output.getType().addCoding().setSystem(ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER) - .setCode(ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER_VALUE_DATA_SET_STATUS); - - if (errorMessage != null) - addErrorExtension(output, errorMessage); - - return output; - } - - private void addErrorExtension(BackboneElement element, String errorMessage) - { - element.addExtension().setUrl(ConstantsDataTransfer.EXTENSION_DATA_SET_STATUS_ERROR_URL) - .setValue(new StringType(errorMessage)); - } - - public void transformInputToOutput(Task inputTask, Task outputTask) - { - transformInputToOutputComponents(inputTask).forEach(outputTask::addOutput); - } - - public Stream transformInputToOutputComponents(Task inputTask) - { - return inputTask.getInput().stream().filter(i -> i.getType().getCoding().stream() - .anyMatch(c -> ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER.equals(c.getSystem()) - && ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER_VALUE_DATA_SET_STATUS.equals(c.getCode()))) - .map(this::toTaskOutputComponent); - } - - private TaskOutputComponent toTaskOutputComponent(ParameterComponent inputComponent) - { - TaskOutputComponent outputComponent = new TaskOutputComponent().setType(inputComponent.getType()) - .setValue(inputComponent.getValue().copy()); - outputComponent.setExtension(inputComponent.getExtension()); - - return outputComponent; - } - - public void transformOutputToInput(Task outputTask, Task inputTask) - { - transformOutputToInputComponent(outputTask).forEach(inputTask::addInput); - } - - public Stream transformOutputToInputComponent(Task outputTask) - { - return outputTask.getOutput().stream().filter(i -> i.getType().getCoding().stream() - .anyMatch(c -> ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER.equals(c.getSystem()) - && ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER_VALUE_DATA_SET_STATUS.equals(c.getCode()))) - .map(this::toTaskInputComponent); - } - - private ParameterComponent toTaskInputComponent(TaskOutputComponent outputComponent) - { - ParameterComponent inputComponent = new ParameterComponent().setType(outputComponent.getType()) - .setValue(outputComponent.getValue().copy()); - inputComponent.setExtension(outputComponent.getExtension()); - - return inputComponent; - } -} diff --git a/src/main/resources/bpe/receive.bpmn b/src/main/resources/bpe/receive.bpmn index 9b51d69..032b012 100644 --- a/src/main/resources/bpe/receive.bpmn +++ b/src/main/resources/bpe/receive.bpmn @@ -63,10 +63,10 @@ - http://medizininformatik-initiative.de/fhir/StructureDefinition/task-data-receive|#{version} + http://medizininformatik-initiative.de/fhir/StructureDefinition/task-data-status|#{version} - dataReceive + dataStatus http://medizininformatik-initiative.de/bpe/Process/dataSend|#{version} @@ -86,6 +86,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -106,58 +141,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - - + + - - + + + @@ -165,27 +172,20 @@ - - - - - - - - - - - - + + - - + + + + + diff --git a/src/main/resources/bpe/send.bpmn b/src/main/resources/bpe/send.bpmn index cb46a73..4b159c2 100644 --- a/src/main/resources/bpe/send.bpmn +++ b/src/main/resources/bpe/send.bpmn @@ -102,10 +102,20 @@ - + + + + + + + + + + + @@ -136,66 +146,34 @@ - - - - - - - - - - - - - - - - + + + + + + + + - - - - + + + - - - - + + + - - - - - - - - - - - - - - - - - - - - - - @@ -214,22 +192,44 @@ - - + + + + + - - - + + + + + - - + + + + + + + + - + + + + + + + + + + + + diff --git a/src/main/resources/fhir/ActivityDefinition/data-transfer-send.xml b/src/main/resources/fhir/ActivityDefinition/data-transfer-send.xml index 06c5c62..76b9d25 100644 --- a/src/main/resources/fhir/ActivityDefinition/data-transfer-send.xml +++ b/src/main/resources/fhir/ActivityDefinition/data-transfer-send.xml @@ -83,10 +83,10 @@ - + - + diff --git a/src/main/resources/fhir/CodeSystem/data-set-status.xml b/src/main/resources/fhir/CodeSystem/data-set-status.xml deleted file mode 100644 index 8c2c831..0000000 --- a/src/main/resources/fhir/CodeSystem/data-set-status.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - <!-- status managed by bpe --> - <status value="unknown" /> - <experimental value="false" /> - <!-- date managed by bpe --> - <date value="#{date}" /> - <publisher value="Medizininformatik-Initiative" /> - <description value="CodeSystem with standard values for the status of transferring data-sets" /> - <caseSensitive value="true" /> - <hierarchyMeaning value="grouped-by" /> - <versionNeeded value="false" /> - <content value="complete" /> - <concept> - <code value="not-allowed" /> - <display value="Not allowed" /> - <definition value="Not allowed to send data-set to DMS" /> - </concept> - <concept> - <code value="not-reachable" /> - <display value="Not reachable" /> - <definition value="DMS cannot be reached" /> - </concept> - <concept> - <code value="receipt-missing" /> - <display value="Receipt missing" /> - <definition value="No receipt received from DMS" /> - </concept> - <concept> - <code value="receipt-ok" /> - <display value="Receipt ok" /> - <definition value="Ok received from DMS" /> - </concept> - <concept> - <code value="receipt-error" /> - <display value="Receipt error" /> - <definition value="Error received from DMS" /> - </concept> - <concept> - <code value="receive-ok" /> - <display value="Receive ok" /> - <definition value="Report received from DIC" /> - </concept> - <concept> - <code value="receive-error" /> - <display value="Receive error" /> - <definition value="Error receiving report from DIC" /> - </concept> -</CodeSystem> \ No newline at end of file diff --git a/src/main/resources/fhir/StructureDefinition/task-data-send.xml b/src/main/resources/fhir/StructureDefinition/task-data-send.xml index 333e603..e559b93 100644 --- a/src/main/resources/fhir/StructureDefinition/task-data-send.xml +++ b/src/main/resources/fhir/StructureDefinition/task-data-send.xml @@ -205,7 +205,7 @@ <path value="Task.output.type"/> <binding> <strength value="required"/> - <valueSet value="http://medizininformatik-initiative.de/fhir/ValueSet/report|#{version}"/> + <valueSet value="http://medizininformatik-initiative.de/fhir/ValueSet/data-transfer|#{version}"/> </binding> </element> <element id="Task.output:data-set-status.type.coding"> @@ -216,7 +216,7 @@ <element id="Task.output:data-set-status.type.coding.system"> <path value="Task.output.type.coding.system"/> <min value="1"/> - <fixedUri value="http://medizininformatik-initiative.de/fhir/CodeSystem/report"/> + <fixedUri value="http://medizininformatik-initiative.de/fhir/CodeSystem/data-transfer"/> </element> <element id="Task.output:data-set-status.type.coding.code"> <path value="Task.output.type.coding.code"/> diff --git a/src/main/resources/fhir/StructureDefinition/task-data-receive.xml b/src/main/resources/fhir/StructureDefinition/task-data-status.xml similarity index 98% rename from src/main/resources/fhir/StructureDefinition/task-data-receive.xml rename to src/main/resources/fhir/StructureDefinition/task-data-status.xml index a628e18..8bb2b62 100644 --- a/src/main/resources/fhir/StructureDefinition/task-data-receive.xml +++ b/src/main/resources/fhir/StructureDefinition/task-data-status.xml @@ -5,7 +5,7 @@ <code value="ALL" /> </tag> </meta> - <url value="http://medizininformatik-initiative.de/fhir/StructureDefinition/task-data-receive" /> + <url value="http://medizininformatik-initiative.de/fhir/StructureDefinition/task-data-status" /> <!-- version managed by bpe --> <version value="#{version}" /> <name value="TaskDataReceive" /> @@ -36,7 +36,7 @@ </element> <element id="Task.input:message-name.value[x]"> <path value="Task.input.value[x]" /> - <fixedString value="dataReceive" /> + <fixedString value="dataStatus" /> </element> <element id="Task.input:business-key"> <path value="Task.input" /> diff --git a/src/main/resources/fhir/ValueSet/data-set-status-receive.xml b/src/main/resources/fhir/ValueSet/data-set-status-receive.xml deleted file mode 100644 index 06a82d9..0000000 --- a/src/main/resources/fhir/ValueSet/data-set-status-receive.xml +++ /dev/null @@ -1,35 +0,0 @@ -<ValueSet xmlns="http://hl7.org/fhir"> - <meta> - <tag> - <system value="http://dsf.dev/fhir/CodeSystem/read-access-tag" /> - <code value="ALL" /> - </tag> - </meta> - <url value="http://medizininformatik-initiative.de/fhir/ValueSet/data-set-status-receive" /> - <!-- version managed by bpe --> - <version value="#{version}" /> - <name value="MII_Data_Set_Status_Receive" /> - <title value="MII Data-Set Status Receive" /> - <!-- status managed by bpe --> - <status value="unknown" /> - <experimental value="false" /> - <!-- date managed by bpe --> - <date value="#{date}" /> - <publisher value="Medizininformatik-Initiative" /> - <description value="ValueSet with values for the status of receiving data-sets" /> - <immutable value="true" /> - <compose> - <include> - <system value="http://medizininformatik-initiative.de/fhir/CodeSystem/data-set-status" /> - <version value="#{version}" /> - <concept> - <code value="receive-ok" /> - <display value="Receive ok" /> - </concept> - <concept> - <code value="receive-error" /> - <display value="Receive error" /> - </concept> - </include> - </compose> -</ValueSet> \ No newline at end of file diff --git a/src/main/resources/fhir/ValueSet/data-set-status-send.xml b/src/main/resources/fhir/ValueSet/data-set-status-send.xml deleted file mode 100644 index a386ef1..0000000 --- a/src/main/resources/fhir/ValueSet/data-set-status-send.xml +++ /dev/null @@ -1,47 +0,0 @@ -<ValueSet xmlns="http://hl7.org/fhir"> - <meta> - <tag> - <system value="http://dsf.dev/fhir/CodeSystem/read-access-tag" /> - <code value="ALL" /> - </tag> - </meta> - <url value="http://medizininformatik-initiative.de/fhir/ValueSet/data-set-status-send" /> - <!-- version managed by bpe --> - <version value="#{version}" /> - <name value="MII_Data_Set_Status_Send" /> - <title value="MII Data Set Status Send" /> - <!-- status managed by bpe --> - <status value="unknown" /> - <experimental value="false" /> - <!-- date managed by bpe --> - <date value="#{date}" /> - <publisher value="Medizininformatik-Initiative" /> - <description value="ValueSet with values for the status of sending data-sets" /> - <immutable value="true" /> - <compose> - <include> - <system value="http://medizininformatik-initiative.de/fhir/CodeSystem/data-set-status" /> - <version value="#{version}" /> - <concept> - <code value="not-allowed" /> - <display value="Not allowed" /> - </concept> - <concept> - <code value="not-reachable" /> - <display value="Not reachable" /> - </concept> - <concept> - <code value="receipt-missing" /> - <display value="Receipt missing" /> - </concept> - <concept> - <code value="receipt-ok" /> - <display value="Receipt ok" /> - </concept> - <concept> - <code value="receipt-error" /> - <display value="Receipt error" /> - </concept> - </include> - </compose> -</ValueSet> \ No newline at end of file diff --git a/src/test/java/de/medizininformatik_initiative/process/data_transfer/fhir/profile/TaskProfileTest.java b/src/test/java/de/medizininformatik_initiative/process/data_transfer/fhir/profile/TaskProfileTest.java index d1dbb37..8926706 100644 --- a/src/test/java/de/medizininformatik_initiative/process/data_transfer/fhir/profile/TaskProfileTest.java +++ b/src/test/java/de/medizininformatik_initiative/process/data_transfer/fhir/profile/TaskProfileTest.java @@ -22,8 +22,8 @@ import ca.uhn.fhir.validation.ValidationResult; import de.medizininformatik_initiative.process.data_transfer.ConstantsDataTransfer; import de.medizininformatik_initiative.process.data_transfer.DataTransferProcessPluginDefinition; -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.constants.CodeSystems; import dev.dsf.bpe.v1.constants.NamingSystems; import dev.dsf.fhir.validation.ResourceValidator; @@ -39,11 +39,11 @@ public class TaskProfileTest public static final ValidationSupportRule validationRule = new ValidationSupportRule(def.getResourceVersion(), def.getResourceReleaseDate(), Arrays.asList("dsf-task-base-1.0.0.xml", "extension-data-set-status-error.xml", "task-data-send-start.xml", - "task-data-receive.xml", "task-data-send.xml"), + "task-data-send.xml", "task-data-status.xml"), Arrays.asList("dsf-read-access-tag-1.0.0.xml", "dsf-bpmn-message-1.0.0.xml", "data-transfer.xml", - "data-set-status.xml", "mii-cryptography.xml"), + "mii-cryptography.xml", "mii-data-set-status.xml"), Arrays.asList("dsf-read-access-tag-1.0.0.xml", "dsf-bpmn-message-1.0.0.xml", "data-transfer.xml", - "data-set-status-receive.xml", "data-set-status-send.xml", "mii-cryptography.xml")); + "mii-cryptography.xml", "mii-data-set-status-receive.xml", "mii-data-set-status-send.xml")); private final ResourceValidator resourceValidator = new ResourceValidatorImpl(validationRule.getFhirContext(), validationRule.getValidationSupport()); @@ -65,7 +65,9 @@ public void testTaskStartDataSendValidWithReportStatusErrorOutput() { Task task = createValidTaskDataSendStart(); task.addOutput(new DataSetStatusGenerator().createDataSetStatusOutput( - ConstantsDataTransfer.CODESYSTEM_DATA_SET_STATUS_VALUE_NOT_REACHABLE, "some error message")); + ConstantsBase.CODESYSTEM_DATA_SET_STATUS_VALUE_NOT_REACHABLE, + ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER, + ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER_VALUE_DATA_SET_STATUS, "some error message")); ValidationResult result = resourceValidator.validate(task); ValidationSupportRule.logValidationMessages(logger, result); @@ -120,8 +122,10 @@ public void testTaskDataSendValid() public void testTaskDataSendValidWithReportStatusOutput() { Task task = createValidTaskDataSend(); - task.addOutput(new DataSetStatusGenerator() - .createDataSetStatusOutput(ConstantsDataTransfer.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIVE_OK)); + task.addOutput(new DataSetStatusGenerator().createDataSetStatusOutput( + ConstantsBase.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIVE_OK, + ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER, + ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER_VALUE_DATA_SET_STATUS)); ValidationResult result = resourceValidator.validate(task); ValidationSupportRule.logValidationMessages(logger, result); @@ -135,7 +139,9 @@ public void testTaskDataSendValidWithReportStatusErrorOutput() { Task task = createValidTaskDataSend(); task.addOutput(new DataSetStatusGenerator().createDataSetStatusOutput( - ConstantsDataTransfer.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIVE_ERROR, "some error message")); + ConstantsBase.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIVE_ERROR, + ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER, + ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER_VALUE_DATA_SET_STATUS, "some error message")); ValidationResult result = resourceValidator.validate(task); ValidationSupportRule.logValidationMessages(logger, result); @@ -173,13 +179,14 @@ private Task createValidTaskDataSend() return task; } - @Test - public void testTaskDataReceiveValidWithResponseInput() + public void testTaskDataStatusValidWithResponseInput() { - Task task = createValidTaskDataReceive(); - task.addInput(new DataSetStatusGenerator() - .createDataSetStatusInput(ConstantsDataTransfer.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIPT_OK)); + Task task = createValidTaskDataStatus(); + task.addInput(new DataSetStatusGenerator().createDataSetStatusInput( + ConstantsBase.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIPT_OK, + ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER, + ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER_VALUE_DATA_SET_STATUS)); ValidationResult result = resourceValidator.validate(task); ValidationSupportRule.logValidationMessages(logger, result); @@ -189,11 +196,13 @@ public void testTaskDataReceiveValidWithResponseInput() } @Test - public void testTaskDataReceiveValidWithResponseInputError() + public void testTaskDataStatusValidWithResponseInputError() { - Task task = createValidTaskDataReceive(); + Task task = createValidTaskDataStatus(); task.addInput(new DataSetStatusGenerator().createDataSetStatusInput( - ConstantsDataTransfer.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIPT_ERROR, "some error message")); + ConstantsBase.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIPT_ERROR, + ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER, + ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER_VALUE_DATA_SET_STATUS, "some error message")); ValidationResult result = resourceValidator.validate(task); ValidationSupportRule.logValidationMessages(logger, result); @@ -202,12 +211,12 @@ public void testTaskDataReceiveValidWithResponseInputError() || ResultSeverityEnum.FATAL.equals(m.getSeverity())).count()); } - private Task createValidTaskDataReceive() + private Task createValidTaskDataStatus() { Task task = new Task(); - task.getMeta().addProfile(ConstantsDataTransfer.PROFILE_TASK_DATA_RECEIVE + "|" + def.getResourceVersion()); + task.getMeta().addProfile(ConstantsDataTransfer.PROFILE_TASK_DATA_STATUS + "|" + def.getResourceVersion()); task.setInstantiatesCanonical( - ConstantsDataTransfer.PROFILE_TASK_DATA_RECEIVE_PROCESS_URI + "|" + def.getResourceVersion()); + ConstantsDataTransfer.PROFILE_TASK_DATA_STATUS_PROCESS_URI + "|" + def.getResourceVersion()); task.setStatus(TaskStatus.REQUESTED); task.setIntent(TaskIntent.ORDER); task.setAuthoredOn(new Date()); @@ -215,9 +224,8 @@ private Task createValidTaskDataReceive() .setIdentifier(NamingSystems.OrganizationIdentifier.withValue("DIC")); task.getRestriction().addRecipient().setType(ResourceType.Organization.name()) .setIdentifier(NamingSystems.OrganizationIdentifier.withValue("DIC")); - ; - task.addInput().setValue(new StringType(ConstantsDataTransfer.PROFILE_TASK_DATA_RECEIVE_MESSAGE_NAME)).getType() + task.addInput().setValue(new StringType(ConstantsDataTransfer.PROFILE_TASK_DATA_STATUS_MESSAGE_NAME)).getType() .addCoding(CodeSystems.BpmnMessage.messageName()); task.addInput().setValue(new StringType(UUID.randomUUID().toString())).getType() .addCoding(CodeSystems.BpmnMessage.businessKey());