Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/hotfix/106_DSF_0.9.0_Backport' into
Browse files Browse the repository at this point in the history
release/0.6.0.1
  • Loading branch information
hhund committed Oct 17, 2022
2 parents d1b1868 + 315fb57 commit 4e07a83
Show file tree
Hide file tree
Showing 62 changed files with 228 additions and 203 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ codex-processes-ap1-test-data-generator/rsa/*.pem
###
codex-processes-ap1-docker-test-setup/**/bpe/log/*.log
codex-processes-ap1-docker-test-setup/**/bpe/log/*.log.gz
codex-processes-ap1-docker-test-setup/**/bpe/last_event/time.file
codex-processes-ap1-docker-test-setup/**/bpe/plugin/*.jar
codex-processes-ap1-docker-test-setup/**/bpe/process/*.jar

Expand Down
2 changes: 1 addition & 1 deletion codex-process-data-transfer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>de.netzwerk-universitaetsmedizin.codex</groupId>
<artifactId>codex-processes-ap1</artifactId>
<version>0.6.0</version>
<version>0.6.0.1</version>
</parent>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class DataTransferProcessPluginDefinition implements ProcessPluginDefinit
private static final Logger logger = LoggerFactory.getLogger(DataTransferProcessPluginDefinition.class);

public static final String VERSION = "0.6.0";
public static final LocalDate DATE = LocalDate.of(2022, 7, 12);
public static final LocalDate DATE = LocalDate.of(2022, 10, 18);

@Override
public String getName()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public final class GeccoFhirClientStub implements GeccoFhirClient
private static final Logger logger = LoggerFactory.getLogger(GeccoFhirClientStub.class);

private static final String condition = "{\"resourceType\":\"Condition\",\"meta\":{\"profile\":[\"https://www.netzwerk-universitaetsmedizin.de/fhir/StructureDefinition/chronic-lung-diseases\"]},\"clinicalStatus\":{\"coding\":[{\"system\":\"http://terminology.hl7.org/CodeSystem/condition-clinical\",\"code\":\"active\",\"display\":\"Active\"}]},\"verificationStatus\":{\"coding\":[{\"system\":\"http://terminology.hl7.org/CodeSystem/condition-ver-status\",\"code\":\"confirmed\",\"display\":\"Confirmed\"},{\"system\":\"http://snomed.info/sct\",\"code\":\"410605003\",\"display\":\"Confirmed present (qualifier value)\"}]},\"category\":[{\"coding\":[{\"system\":\"http://snomed.info/sct\",\"code\":\"418112009\",\"display\":\"Pulmonary medicine\"}]}],\"code\":{\"coding\":[{\"system\":\"http://snomed.info/sct\",\"code\":\"413839001\",\"display\":\"Chronic lung disease\"}]},\"recordedDate\":\"2020-11-10T15:50:41.000+01:00\"}";
private static final String patient = "{\"resourceType\":\"Patient\",\"meta\":{\"profile\":[\"https://www.netzwerk-universitaetsmedizin.de/fhir/StructureDefinition/Patient\"]},\"extension\":[{\"url\":\"https://www.netzwerk-universitaetsmedizin.de/fhir/StructureDefinition/ethnic-group\",\"valueCoding\":{\"system\":\"http://snomed.info/sct\",\"code\":\"186019001\",\"display\":\"Other ethnic, mixed origin\"}},{\"url\":\"https://www.netzwerk-universitaetsmedizin.de/fhir/StructureDefinition/age\",\"extension\":[{\"url\":\"dateTimeOfDocumentation\",\"valueDateTime\":\"2020-10-01\"},{\"url\":\"age\",\"valueAge\":{\"value\":67,\"unit\":\"years\",\"system\":\"http://unitsofmeasure.org\",\"code\":\"a\"}}]}],\"birthDate\":\"1953-09-30\"}";
private static final String patient = "{\"resourceType\":\"Patient\",\"meta\":{\"profile\":[\"https://www.netzwerk-universitaetsmedizin.de/fhir/StructureDefinition/Patient\"]},\"extension\":[{\"url\":\"https://www.netzwerk-universitaetsmedizin.de/fhir/StructureDefinition/ethnic-group\",\"valueCoding\":{\"system\":\"http://snomed.info/sct\",\"code\":\"26242008\",\"display\":\"Mixed (qualifier value)\"}},{\"url\":\"https://www.netzwerk-universitaetsmedizin.de/fhir/StructureDefinition/age\",\"extension\":[{\"url\":\"dateTimeOfDocumentation\",\"valueDateTime\":\"2020-10-01\"},{\"url\":\"age\",\"valueAge\":{\"value\":67,\"unit\":\"years\",\"system\":\"http://unitsofmeasure.org\",\"code\":\"a\"}}]}],\"birthDate\":\"1953-09-30\"}";
private static final String observation = "{\"resourceType\":\"Observation\",\"meta\":{\"profile\":[\"https://www.netzwerk-universitaetsmedizin.de/fhir/StructureDefinition/sars-cov-2-rt-pcr\"]},\"identifier\":[{\"type\":{\"coding\":[{\"system\":\"http://terminology.hl7.org/CodeSystem/v2-0203\",\"code\":\"OBI\"}]}}],\"status\":\"final\",\"category\":[{\"coding\":[{\"system\":\"http://loinc.org\",\"code\":\"26436-6\"},{\"system\":\"http://terminology.hl7.org/CodeSystem/observation-category\",\"code\":\"laboratory\"}]}],\"code\":{\"coding\":[{\"system\":\"http://loinc.org\",\"code\":\"94500-6\",\"display\":\"SARS-CoV-2 (COVID-19) RNA [Presence] in Respiratory specimen by NAA with probe detection\"}],\"text\":\"SARS-CoV-2-RNA (PCR)\"},\"effectiveDateTime\":\"2020-11-10T15:50:41.000+01:00\",\"valueCodeableConcept\":{\"coding\":[{\"system\":\"http://snomed.info/sct\",\"code\":\"260373001\",\"display\":\"Detected (qualifier value)\"}],\"text\":\"SARS-CoV-2-RNA positiv\"}}";

private final GeccoClient geccoClient;
Expand Down Expand Up @@ -82,15 +82,18 @@ public Stream<DomainResource> getNewData(String pseudonym, DateWithPrecision exp
logger.warn("Returning demo resources for {}", pseudonym);

Patient p = geccoClient.getFhirContext().newJsonParser().parseResource(Patient.class, patient);
p.setIdElement(new IdType(UUID.randomUUID().toString()));
p.addIdentifier().setSystem(NAMING_SYSTEM_NUM_CODEX_DIC_PSEUDONYM).setValue(pseudonym).getType()
.getCodingFirstRep().setSystem(IDENTIFIER_NUM_CODEX_DIC_PSEUDONYM_TYPE_SYSTEM)
.setCode(IDENTIFIER_NUM_CODEX_DIC_PSEUDONYM_TYPE_CODE);
p.setIdElement(new IdType("Patient", UUID.randomUUID().toString()));

Condition c = geccoClient.getFhirContext().newJsonParser().parseResource(Condition.class, condition);
c.setIdElement(new IdType(UUID.randomUUID().toString()));
c.setSubject(new Reference(p.getIdElement()));

Observation o = geccoClient.getFhirContext().newJsonParser().parseResource(Observation.class, observation);
o.setIdElement(new IdType(UUID.randomUUID().toString()));
o.setSubject(new Reference(p.getIdElement()));

return Stream.of(p, c, o);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class CrrKeyProviderImpl implements CrrKeyProvider

/**
* One or both parameters should be <code>null</code>
*
*
* @param crrPrivateKeyFile
* @param crrPublicKeyFile
* @return
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,90 @@
package de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.logging;

import java.util.Objects;

import org.highmed.dsf.bpe.service.MailService;
import org.hl7.fhir.r4.model.IdType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;

public class ErrorLogger
public class ErrorLogger implements InitializingBean
{
private static final Logger validationLogger = LoggerFactory.getLogger("validation-error-logger");
private static final Logger errorLogger = LoggerFactory.getLogger("error-logger");

private final MailService mailService;

private final boolean sendValidationFailedMail;
private final boolean sendProcessFailedMail;

public ErrorLogger(MailService mailService, boolean sendValidationFailedMail, boolean sendProcessFailedMail)
{
this.mailService = mailService;

this.sendValidationFailedMail = sendValidationFailedMail;
this.sendProcessFailedMail = sendProcessFailedMail;
}

@Override
public void afterPropertiesSet() throws Exception
{
Objects.requireNonNull(mailService, "mailService");
}

public void logValidationFailed(IdType taskId)
{
validationLogger.debug("Validation of FHIR resources failed, started by Task {}", taskId.getValue());
validationLogger.debug("Validation of FHIR resources failed in process started by {}",
taskId.toVersionless().getValue());

if (sendValidationFailedMail)
mailService.send("Validation Error",
"Validation of FHIR resources failed in process started by " + taskId.toVersionless().getValue());
}

public void logValidationFailedLocal(IdType taskId)
{
validationLogger.debug("Local validation of FHIR resources failed, started by Task {}", taskId.getValue());
validationLogger.debug("Local validation of FHIR resources failed in process started by {}",
taskId.toVersionless().getValue());

if (sendValidationFailedMail)
mailService.send("Validation Error", "Local validation of FHIR resources failed in process started by "
+ taskId.toVersionless().getValue());
}

public void logValidationFailedRemote(IdType taskId)
{
validationLogger.debug("Remote validation of FHIR resources failed, started by Task {}", taskId.getValue());
validationLogger.debug("Remote validation of FHIR resources failed in process started by {}",
taskId.toVersionless().getValue());

if (sendValidationFailedMail)
mailService.send("Validation Error", "Remote validation of FHIR resources failed in process started by "
+ taskId.toVersionless().getValue());
}

public void logDataSendFailed(IdType taskId)
{
errorLogger.debug("Send process failed, started by Task {}", taskId.getValue());
errorLogger.debug("Send process failed started by {}", taskId.toVersionless().getValue());

if (sendProcessFailedMail)
mailService.send("Proccess Failed", "Send process failed started by " + taskId.toVersionless().getValue());
}

public void logDataTranslateFailed(IdType taskId)
{
errorLogger.debug("Translate process failed, started by Task {}", taskId.getValue());
errorLogger.debug("Translate process failed started by {}", taskId.toVersionless().getValue());

if (sendProcessFailedMail)
mailService.send("Proccess Failed",
"Translate process failed started by " + taskId.toVersionless().getValue());
}

public void logDataReceiveFailed(IdType taskId)
{
errorLogger.debug("Receive process failed, started by Task {}", taskId.getValue());
errorLogger.debug("Receive process failed started by {}", taskId.toVersionless().getValue());

if (sendProcessFailedMail)
mailService.send("Proccess Failed",
"Receive process failed started by " + taskId.toVersionless().getValue());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,27 @@

import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.BPMN_EXECUTION_VARIABLE_RETURN_TARGET;

import java.util.stream.Stream;

import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper;
import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider;
import org.highmed.dsf.fhir.organization.OrganizationProvider;
import org.highmed.dsf.fhir.task.AbstractTaskMessageSend;
import org.highmed.dsf.fhir.task.TaskHelper;
import org.highmed.dsf.fhir.variables.Target;
import org.hl7.fhir.r4.model.Task.ParameterComponent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import ca.uhn.fhir.context.FhirContext;

public class ContinueSendProcess extends AbstractTaskMessageSend
{
private static final Logger logger = LoggerFactory.getLogger(ContinueSendProcess.class);

public ContinueSendProcess(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper,
ReadAccessHelper readAccessHelper, OrganizationProvider organizationProvider, FhirContext fhirContext)
{
super(clientProvider, taskHelper, readAccessHelper, organizationProvider, fhirContext);
}

@Override
protected Target getTarget()
protected Target getTarget(DelegateExecution execution)
{
return (Target) execution.getVariable(BPMN_EXECUTION_VARIABLE_RETURN_TARGET);
}

@Override
protected void sendTask(Target target, String instantiatesUri, String messageName, String businessKey,
String profile, Stream<ParameterComponent> additionalInputParameters)
{
// TODO implement continue send
logger.debug("implement continue send");

super.sendTask(target, instantiatesUri, messageName, businessKey, profile, additionalInputParameters);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void afterPropertiesSet() throws Exception
}

@Override
protected Target getTarget()
protected Target getTarget(DelegateExecution execution)
{
return (Target) execution.getVariable(BPMN_EXECUTION_VARIABLE_RETURN_TARGET);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public ContinueSendProcessWithValidationError(FhirWebserviceClientProvider clien
}

@Override
protected Target getTarget()
protected Target getTarget(DelegateExecution execution)
{
return (Target) execution.getVariable(BPMN_EXECUTION_VARIABLE_RETURN_TARGET);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,27 @@

import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.BPMN_EXECUTION_VARIABLE_RETURN_TARGET;

import java.util.stream.Stream;

import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper;
import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider;
import org.highmed.dsf.fhir.organization.OrganizationProvider;
import org.highmed.dsf.fhir.task.AbstractTaskMessageSend;
import org.highmed.dsf.fhir.task.TaskHelper;
import org.highmed.dsf.fhir.variables.Target;
import org.hl7.fhir.r4.model.Task.ParameterComponent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import ca.uhn.fhir.context.FhirContext;

public class ContinueTranslateProcess extends AbstractTaskMessageSend
{
private static final Logger logger = LoggerFactory.getLogger(ContinueTranslateProcess.class);

public ContinueTranslateProcess(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper,
ReadAccessHelper readAccessHelper, OrganizationProvider organizationProvider, FhirContext fhirContext)
{
super(clientProvider, taskHelper, readAccessHelper, organizationProvider, fhirContext);
}

@Override
protected Target getTarget()
protected Target getTarget(DelegateExecution execution)
{
return (Target) execution.getVariable(BPMN_EXECUTION_VARIABLE_RETURN_TARGET);
}

@Override
protected void sendTask(Target target, String instantiatesUri, String messageName, String businessKey,
String profile, Stream<ParameterComponent> additionalInputParameters)
{

// TODO implement continue translate
logger.debug("implement continue translate");

super.sendTask(target, instantiatesUri, messageName, businessKey, profile, additionalInputParameters);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void afterPropertiesSet() throws Exception
}

@Override
protected Target getTarget()
protected Target getTarget(DelegateExecution execution)
{
return (Target) execution.getVariable(BPMN_EXECUTION_VARIABLE_RETURN_TARGET);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public ContinueTranslateProcessWithValidationError(FhirWebserviceClientProvider
}

@Override
protected Target getTarget()
protected Target getTarget(DelegateExecution execution)
{
return (Target) execution.getVariable(BPMN_EXECUTION_VARIABLE_RETURN_TARGET);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ protected Stream<ParameterComponent> getAdditionalInputParameters(DelegateExecut
}

@Override
protected void sendTask(Target target, String instantiatesUri, String messageName, String businessKey,
String profile, Stream<ParameterComponent> additionalInputParameters)
protected void sendTask(DelegateExecution execution, Target target, String instantiatesUri, String messageName,
String businessKey, String profile, Stream<ParameterComponent> additionalInputParameters)
{
String crrBusinessKey = createAndSaveAlternativeBusinessKey();
String crrBusinessKey = createAndSaveAlternativeBusinessKey(execution);

logger.debug("DIC businessKey {}, CRR businessKey {}", businessKey, crrBusinessKey);

super.sendTask(target, instantiatesUri, messageName, crrBusinessKey, profile, additionalInputParameters);
super.sendTask(execution, target, instantiatesUri, messageName, crrBusinessKey, profile,
additionalInputParameters);
}

private ParameterComponent pseudonymParameter(DelegateExecution execution)
Expand Down Expand Up @@ -82,7 +83,7 @@ private ParameterComponent dataReferenceParameter(DelegateExecution execution)
}

@Override
protected void handleSendTaskError(Exception exception, String errorMessage)
protected void handleSendTaskError(DelegateExecution execution, Exception exception, String errorMessage)
{
throw new BpmnError(CODESYSTEM_NUM_CODEX_DATA_TRANSFER_ERROR_VALUE_CRR_NOT_REACHABLE,
"Error while sending Task to CRR: " + exception.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ public StartSendProcess(FhirWebserviceClientProvider clientProvider, TaskHelper
}

@Override
protected void sendTask(Target target, String instantiatesUri, String messageName, String businessKey,
String profile, Stream<ParameterComponent> additionalInputParameters)
protected void sendTask(DelegateExecution execution, Target target, String instantiatesUri, String messageName,
String businessKey, String profile, Stream<ParameterComponent> additionalInputParameters)
{
// can't use same business key as trigger process
super.sendTask(target, instantiatesUri, messageName, UUID.randomUUID().toString(), profile,
super.sendTask(execution, target, instantiatesUri, messageName, UUID.randomUUID().toString(), profile,
additionalInputParameters);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private ParameterComponent dataReferenceParameter(DelegateExecution execution)
}

@Override
protected void handleSendTaskError(Exception exception, String errorMessage)
protected void handleSendTaskError(DelegateExecution execution, Exception exception, String errorMessage)
{
throw new BpmnError(CODESYSTEM_NUM_CODEX_DATA_TRANSFER_ERROR_VALUE_GTH_NOT_REACHABLE,
"Error while sending Task to GTH: " + exception.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private void decryptGeccoData(DelegateExecution execution)
throws InvalidKeyException, BadPaddingException, IllegalBlockSizeException, NoSuchPaddingException,
NoSuchAlgorithmException, InvalidAlgorithmParameterException, IOException
{
Task task = getCurrentTaskFromExecutionVariables();
Task task = getCurrentTaskFromExecutionVariables(execution);
Optional<String> pseudonym = getPseudonym(task);

byte[] encrypted = (byte[]) execution.getVariable(BPMN_EXECUTION_VARIABLE_BUNDLE);
Expand All @@ -108,7 +108,7 @@ private Optional<String> getPseudonym(Task task)
{
return getInputParameterValues(task, CODESYSTEM_NUM_CODEX_DATA_TRANSFER,
CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_PSEUDONYM, Identifier.class).findFirst()
.map(Identifier::getValue);
.map(Identifier::getValue);
}

private <T extends Type> Stream<T> getInputParameterValues(Task task, String system, String code, Class<T> type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected void doExecute(DelegateExecution execution) throws BpmnError, Exceptio
TargetValues.create(Target.createUniDirectionalTarget(gthIdentifierValue,
getEndpointIdentifier(targetEndpoint), targetEndpoint.getAddress())));

Task task = getCurrentTaskFromExecutionVariables();
Task task = getCurrentTaskFromExecutionVariables(execution);

IdType id = getDataReference(task).map(ref -> new IdType(ref)).get();

Expand All @@ -93,7 +93,7 @@ private Optional<String> getDataReference(Task task)
{
return getInputParameterValues(task, CODESYSTEM_NUM_CODEX_DATA_TRANSFER,
CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_DATA_REFERENCE, Reference.class).findFirst()
.map(Reference::getReference);
.map(Reference::getReference);
}

private <T extends Type> Stream<T> getInputParameterValues(Task task, String system, String code, Class<T> type)
Expand Down
Loading

0 comments on commit 4e07a83

Please sign in to comment.