diff --git a/dsf-bpe-process-feasibility/pom.xml b/dsf-bpe-process-feasibility/pom.xml index d8db1740..1e9f0cee 100644 --- a/dsf-bpe-process-feasibility/pom.xml +++ b/dsf-bpe-process-feasibility/pom.xml @@ -69,7 +69,7 @@ ${project.version} - ${dsf.location}/dsf-docker-test-setup/bpe/app/process + ${dsf.location}/dsf-docker-test-setup/bpe/process @@ -86,7 +86,7 @@ ${project.version} - ${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic1/bpe/app/process + ${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic1/bpe/process @@ -103,7 +103,7 @@ ${project.version} - ${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic2/bpe/app/process + ${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic2/bpe/process @@ -120,7 +120,7 @@ ${project.version} - ${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic3/bpe/app/process + ${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic3/bpe/process @@ -137,7 +137,79 @@ ${project.version} - ${dsf.location}/dsf-docker-test-setup-3medic-ttp/ttp/bpe/app/process + ${dsf.location}/dsf-docker-test-setup-3medic-ttp/ttp/bpe/process + + + + copy-process-to-docker-test-setup-3medic-ttp-docker/medic1 + package + + copy + + + + + ${project.groupId} + ${project.artifactId} + ${project.version} + + + ${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/medic1/bpe/process + + + + + copy-process-to-docker-test-setup-3medic-ttp-docker/medic2 + package + + copy + + + + + ${project.groupId} + ${project.artifactId} + ${project.version} + + + ${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/medic2/bpe/process + + + + + copy-process-to-docker-test-setup-3medic-ttp-docker/medic3 + package + + copy + + + + + ${project.groupId} + ${project.artifactId} + ${project.version} + + + ${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/medic3/bpe/process + + + + + copy-process-to-docker-test-setup-3medic-ttp-docker/ttp + package + + copy + + + + + ${project.groupId} + ${project.artifactId} + ${project.version} + + + ${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/ttp/bpe/process + @@ -148,35 +220,63 @@ - ${dsf.location}/dsf-docker-test-setup/bpe/app/process + ${dsf.location}/dsf-docker-test-setup/bpe/process + + ${project.artifactId}-${project.version}.jar + + false + + + ${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic1/bpe/process + + ${project.artifactId}-${project.version}.jar + + false + + + ${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic2/bpe/process + + ${project.artifactId}-${project.version}.jar + + false + + + ${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic3/bpe/process + + ${project.artifactId}-${project.version}.jar + + false + + + ${dsf.location}/dsf-docker-test-setup-3medic-ttp/ttp/bpe/process ${project.artifactId}-${project.version}.jar false - ${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic1/bpe/app/process + ${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/medic1/bpe/process ${project.artifactId}-${project.version}.jar false - ${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic2/bpe/app/process + ${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/medic2/bpe/process ${project.artifactId}-${project.version}.jar false - ${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic3/bpe/app/process + ${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/medic3/bpe/process ${project.artifactId}-${project.version}.jar false - ${dsf.location}/dsf-docker-test-setup-3medic-ttp/ttp/bpe/app/process + ${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/ttp/bpe/process ${project.artifactId}-${project.version}.jar diff --git a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/FeasibilityProcessPluginDefinition.java b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/FeasibilityProcessPluginDefinition.java index 48999d88..8bd27bbe 100644 --- a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/FeasibilityProcessPluginDefinition.java +++ b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/FeasibilityProcessPluginDefinition.java @@ -13,6 +13,7 @@ import org.highmed.dsf.fhir.resources.ResourceProvider; import org.highmed.dsf.fhir.resources.StructureDefinitionResource; import org.highmed.dsf.fhir.resources.ValueSetResource; +import org.springframework.core.env.PropertyResolver; import ca.uhn.fhir.context.FhirContext; @@ -45,7 +46,8 @@ public Stream> getSpringConfigClasses() } @Override - public ResourceProvider getResourceProvider(FhirContext fhirContext, ClassLoader classLoader) + public ResourceProvider getResourceProvider(FhirContext fhirContext, ClassLoader classLoader, + PropertyResolver resolver) { var aCom = ActivityDefinitionResource.file("fhir/ActivityDefinition/highmed-computeFeasibility.xml"); var aExe = ActivityDefinitionResource.file("fhir/ActivityDefinition/highmed-executeFeasibility.xml"); @@ -64,12 +66,12 @@ public ResourceProvider getResourceProvider(FhirContext fhirContext, ClassLoader var vF = ValueSetResource.file("fhir/ValueSet/highmed-feasibility.xml"); - Map> resourcesByProcessKeyAndVersion = Map.of("computeFeasibility/" + VERSION, - Arrays.asList(aCom, cF, sTCom, sTResS, vF), "executeFeasibility/" + VERSION, - Arrays.asList(aExe, cF, sTExe, vF), "requestFeasibility/" + VERSION, - Arrays.asList(aReq, cF, sTReq, sTResM, sTErr, vF)); + Map> resourcesByProcessKeyAndVersion = Map.of( + "highmedorg_computeFeasibility/" + VERSION, Arrays.asList(aCom, cF, sTCom, sTResS, vF), + "highmedorg_executeFeasibility/" + VERSION, Arrays.asList(aExe, cF, sTExe, vF), + "highmedorg_requestFeasibility/" + VERSION, Arrays.asList(aReq, cF, sTReq, sTResM, sTErr, vF)); return ResourceProvider.read(VERSION, () -> fhirContext.newXmlParser().setStripVersionsFromReferences(false), - classLoader, resourcesByProcessKeyAndVersion); + classLoader, resolver, resourcesByProcessKeyAndVersion); } } diff --git a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/message/SendMedicRequest.java b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/message/SendMedicRequest.java index e32f436c..83c00837 100644 --- a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/message/SendMedicRequest.java +++ b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/message/SendMedicRequest.java @@ -14,6 +14,7 @@ import org.camunda.bpm.engine.delegate.DelegateExecution; import org.highmed.dsf.bpe.variables.BloomFilterConfig; +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; @@ -28,9 +29,9 @@ public class SendMedicRequest extends AbstractTaskMessageSend { public SendMedicRequest(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, - OrganizationProvider organizationProvider, FhirContext fhirContext) + ReadAccessHelper readAccessHelper, OrganizationProvider organizationProvider, FhirContext fhirContext) { - super(clientProvider, taskHelper, organizationProvider, fhirContext); + super(clientProvider, taskHelper, readAccessHelper, organizationProvider, fhirContext); } @Override diff --git a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/message/SendMultiMedicErrors.java b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/message/SendMultiMedicErrors.java index 4735ae64..dc996bf4 100644 --- a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/message/SendMultiMedicErrors.java +++ b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/message/SendMultiMedicErrors.java @@ -6,6 +6,7 @@ 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; @@ -20,9 +21,9 @@ public class SendMultiMedicErrors extends AbstractTaskMessageSend { public SendMultiMedicErrors(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, - OrganizationProvider organizationProvider, FhirContext fhirContext) + ReadAccessHelper readAccessHelper, OrganizationProvider organizationProvider, FhirContext fhirContext) { - super(clientProvider, taskHelper, organizationProvider, fhirContext); + super(clientProvider, taskHelper, readAccessHelper, organizationProvider, fhirContext); } @Override diff --git a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/message/SendMultiMedicResults.java b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/message/SendMultiMedicResults.java index 6b3e8e68..ecba92d7 100644 --- a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/message/SendMultiMedicResults.java +++ b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/message/SendMultiMedicResults.java @@ -14,6 +14,7 @@ import org.camunda.bpm.engine.delegate.DelegateExecution; import org.highmed.dsf.bpe.variables.FinalFeasibilityQueryResult; import org.highmed.dsf.bpe.variables.FinalFeasibilityQueryResults; +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; @@ -29,9 +30,9 @@ public class SendMultiMedicResults extends AbstractTaskMessageSend { public SendMultiMedicResults(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, - OrganizationProvider organizationProvider, FhirContext fhirContext) + ReadAccessHelper readAccessHelper, OrganizationProvider organizationProvider, FhirContext fhirContext) { - super(clientProvider, taskHelper, organizationProvider, fhirContext); + super(clientProvider, taskHelper, readAccessHelper, organizationProvider, fhirContext); } @Override diff --git a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/message/SendSingleMedicResults.java b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/message/SendSingleMedicResults.java index 5cd7a69e..ba5fb173 100644 --- a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/message/SendSingleMedicResults.java +++ b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/message/SendSingleMedicResults.java @@ -11,6 +11,7 @@ import org.camunda.bpm.engine.delegate.DelegateExecution; import org.highmed.dsf.bpe.variables.FeasibilityQueryResult; import org.highmed.dsf.bpe.variables.FeasibilityQueryResults; +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; @@ -29,9 +30,9 @@ public class SendSingleMedicResults extends AbstractTaskMessageSend private static final Logger logger = LoggerFactory.getLogger(SendSingleMedicResults.class); public SendSingleMedicResults(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, - OrganizationProvider organizationProvider, FhirContext fhirContext) + ReadAccessHelper readAccessHelper, OrganizationProvider organizationProvider, FhirContext fhirContext) { - super(clientProvider, taskHelper, organizationProvider, fhirContext); + super(clientProvider, taskHelper, readAccessHelper, organizationProvider, fhirContext); } @Override diff --git a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/message/SendTtpRequest.java b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/message/SendTtpRequest.java index 68851316..1992ec01 100644 --- a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/message/SendTtpRequest.java +++ b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/message/SendTtpRequest.java @@ -9,6 +9,7 @@ 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; @@ -21,9 +22,9 @@ public class SendTtpRequest extends AbstractTaskMessageSend { public SendTtpRequest(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, - OrganizationProvider organizationProvider, FhirContext fhirContext) + ReadAccessHelper readAccessHelper, OrganizationProvider organizationProvider, FhirContext fhirContext) { - super(clientProvider, taskHelper, organizationProvider, fhirContext); + super(clientProvider, taskHelper, readAccessHelper, organizationProvider, fhirContext); } @Override diff --git a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/CalculateMultiMedicResults.java b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/CalculateMultiMedicResults.java index 421a0398..f5ae3c9a 100644 --- a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/CalculateMultiMedicResults.java +++ b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/CalculateMultiMedicResults.java @@ -14,14 +14,16 @@ import org.highmed.dsf.bpe.variables.FinalFeasibilityQueryResult; import org.highmed.dsf.bpe.variables.FinalFeasibilityQueryResults; import org.highmed.dsf.bpe.variables.FinalFeasibilityQueryResultsValues; +import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper; import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider; import org.highmed.dsf.fhir.task.TaskHelper; public class CalculateMultiMedicResults extends AbstractServiceDelegate { - public CalculateMultiMedicResults(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper) + public CalculateMultiMedicResults(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, + ReadAccessHelper readAccessHelper) { - super(clientProvider, taskHelper); + super(clientProvider, taskHelper, readAccessHelper); } @Override diff --git a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/CheckFeasibilityResources.java b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/CheckFeasibilityResources.java index edbca48c..1fe346a9 100644 --- a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/CheckFeasibilityResources.java +++ b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/CheckFeasibilityResources.java @@ -11,6 +11,7 @@ import org.camunda.bpm.engine.delegate.DelegateExecution; import org.highmed.dsf.bpe.delegate.AbstractServiceDelegate; +import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper; import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider; import org.highmed.dsf.fhir.task.TaskHelper; import org.highmed.dsf.fhir.variables.FhirResourcesList; @@ -20,9 +21,10 @@ public class CheckFeasibilityResources extends AbstractServiceDelegate { - public CheckFeasibilityResources(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper) + public CheckFeasibilityResources(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, + ReadAccessHelper readAccessHelper) { - super(clientProvider, taskHelper); + super(clientProvider, taskHelper, readAccessHelper); } @Override diff --git a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/CheckMultiMedicResults.java b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/CheckMultiMedicResults.java index b2c527f0..d8f9f83e 100644 --- a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/CheckMultiMedicResults.java +++ b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/CheckMultiMedicResults.java @@ -14,6 +14,7 @@ import org.highmed.dsf.bpe.delegate.AbstractServiceDelegate; import org.highmed.dsf.bpe.variables.FinalFeasibilityQueryResult; import org.highmed.dsf.bpe.variables.FinalFeasibilityQueryResults; +import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper; import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider; import org.highmed.dsf.fhir.task.TaskHelper; import org.hl7.fhir.r4.model.Extension; @@ -25,9 +26,10 @@ public class CheckMultiMedicResults extends AbstractServiceDelegate { - public CheckMultiMedicResults(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper) + public CheckMultiMedicResults(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, + ReadAccessHelper readAccessHelper) { - super(clientProvider, taskHelper); + super(clientProvider, taskHelper, readAccessHelper); } @Override diff --git a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/CheckQueries.java b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/CheckQueries.java index 428b73a4..e2ca8358 100644 --- a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/CheckQueries.java +++ b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/CheckQueries.java @@ -1,5 +1,11 @@ package org.highmed.dsf.bpe.service; +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN; +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN_VALUE_ERROR; +import static org.highmed.dsf.bpe.ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_COHORTS; +import static org.highmed.dsf.bpe.ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_QUERIES; +import static org.highmed.dsf.bpe.ConstantsFeasibility.FEASIBILITY_QUERY_PREFIX; + import java.util.HashMap; import java.util.List; import java.util.Map; @@ -7,9 +13,8 @@ import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; -import org.highmed.dsf.bpe.ConstantsBase; -import org.highmed.dsf.bpe.ConstantsFeasibility; import org.highmed.dsf.bpe.delegate.AbstractServiceDelegate; +import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper; import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider; import org.highmed.dsf.fhir.group.GroupHelper; import org.highmed.dsf.fhir.task.TaskHelper; @@ -26,9 +31,11 @@ public class CheckQueries extends AbstractServiceDelegate implements Initializin private final GroupHelper groupHelper; - public CheckQueries(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, GroupHelper groupHelper) + public CheckQueries(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, + ReadAccessHelper readAccessHelper, GroupHelper groupHelper) { - super(clientProvider, taskHelper); + super(clientProvider, taskHelper, readAccessHelper); + this.groupHelper = groupHelper; } @@ -36,14 +43,15 @@ public CheckQueries(FhirWebserviceClientProvider clientProvider, TaskHelper task public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); + Objects.requireNonNull(groupHelper, "groupHelper"); } @Override protected void doExecute(DelegateExecution execution) throws Exception { - List cohorts = ((FhirResourcesList) execution - .getVariable(ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_COHORTS)).getResourcesAndCast(); + List cohorts = ((FhirResourcesList) execution.getVariable(BPMN_EXECUTION_VARIABLE_COHORTS)) + .getResourcesAndCast(); Map queries = new HashMap<>(); @@ -53,15 +61,15 @@ protected void doExecute(DelegateExecution execution) throws Exception String aqlQuery = groupHelper.extractAqlQuery(group); String groupId = group.getId(); - if (!aqlQuery.startsWith(ConstantsFeasibility.FEASIBILITY_QUERY_PREFIX)) + if (!aqlQuery.startsWith(FEASIBILITY_QUERY_PREFIX)) { String errorMessage = "Initial single medic feasibility query check failed, wrong format for query of group with id '" - + groupId + "', expected query to start with '" + ConstantsFeasibility.FEASIBILITY_QUERY_PREFIX - + "' but got '" + aqlQuery + "'"; + + groupId + "', expected query to start with '" + FEASIBILITY_QUERY_PREFIX + "' but got '" + + aqlQuery + "'"; logger.info(errorMessage); - leadingTask.getOutput().add(getTaskHelper().createOutput(ConstantsBase.CODESYSTEM_HIGHMED_BPMN, - ConstantsBase.CODESYSTEM_HIGHMED_BPMN_VALUE_ERROR, errorMessage)); + leadingTask.getOutput().add(getTaskHelper().createOutput(CODESYSTEM_HIGHMED_BPMN, + CODESYSTEM_HIGHMED_BPMN_VALUE_ERROR, errorMessage)); } else { @@ -69,6 +77,6 @@ protected void doExecute(DelegateExecution execution) throws Exception } }); - execution.setVariable(ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_QUERIES, queries); + execution.setVariable(BPMN_EXECUTION_VARIABLE_QUERIES, queries); } } diff --git a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/CheckSingleMedicResults.java b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/CheckSingleMedicResults.java index 831b9b55..019f2ea8 100644 --- a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/CheckSingleMedicResults.java +++ b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/CheckSingleMedicResults.java @@ -1,16 +1,19 @@ package org.highmed.dsf.bpe.service; +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN; +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN_VALUE_ERROR; +import static org.highmed.dsf.bpe.ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_QUERY_RESULTS; + import java.util.ArrayList; import java.util.List; import java.util.Optional; import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.highmed.dsf.bpe.ConstantsBase; -import org.highmed.dsf.bpe.ConstantsFeasibility; import org.highmed.dsf.bpe.delegate.AbstractServiceDelegate; import org.highmed.dsf.bpe.variables.FeasibilityQueryResult; import org.highmed.dsf.bpe.variables.FeasibilityQueryResults; import org.highmed.dsf.bpe.variables.FeasibilityQueryResultsValues; +import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper; import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider; import org.highmed.dsf.fhir.task.TaskHelper; import org.hl7.fhir.r4.model.Task; @@ -21,16 +24,17 @@ public class CheckSingleMedicResults extends AbstractServiceDelegate { private static final Logger logger = LoggerFactory.getLogger(CheckSingleMedicResults.class); - public CheckSingleMedicResults(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper) + public CheckSingleMedicResults(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, + ReadAccessHelper readAccessHelper) { - super(clientProvider, taskHelper); + super(clientProvider, taskHelper, readAccessHelper); } @Override protected void doExecute(DelegateExecution execution) throws Exception { FeasibilityQueryResults results = (FeasibilityQueryResults) execution - .getVariable(ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_QUERY_RESULTS); + .getVariable(BPMN_EXECUTION_VARIABLE_QUERY_RESULTS); Task currentTask = getCurrentTaskFromExecutionVariables(); List filteredResults = filterErroneousResultsAndAddErrorsToCurrentTaskOutputs(results, @@ -38,7 +42,7 @@ protected void doExecute(DelegateExecution execution) throws Exception // TODO: add percentage filter over results - execution.setVariable(ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_QUERY_RESULTS, + execution.setVariable(BPMN_EXECUTION_VARIABLE_QUERY_RESULTS, FeasibilityQueryResultsValues.create(new FeasibilityQueryResults(filteredResults))); } @@ -71,7 +75,7 @@ private void addError(Task task, String cohortId, String error) String errorMessage = "Feasibility query result check failed for group with id '" + cohortId + "': " + error; logger.info(errorMessage); - task.getOutput().add(getTaskHelper().createOutput(ConstantsBase.CODESYSTEM_HIGHMED_BPMN, - ConstantsBase.CODESYSTEM_HIGHMED_BPMN_VALUE_ERROR, errorMessage)); + task.getOutput().add(getTaskHelper().createOutput(CODESYSTEM_HIGHMED_BPMN, CODESYSTEM_HIGHMED_BPMN_VALUE_ERROR, + errorMessage)); } } diff --git a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/CheckTtpComputedMultiMedicResults.java b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/CheckTtpComputedMultiMedicResults.java index 709bad6b..fc7f1501 100644 --- a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/CheckTtpComputedMultiMedicResults.java +++ b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/CheckTtpComputedMultiMedicResults.java @@ -17,6 +17,7 @@ import org.highmed.dsf.bpe.variables.FinalFeasibilityQueryResult; import org.highmed.dsf.bpe.variables.FinalFeasibilityQueryResults; import org.highmed.dsf.bpe.variables.FinalFeasibilityQueryResultsValues; +import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper; import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider; import org.highmed.dsf.fhir.task.TaskHelper; import org.hl7.fhir.r4.model.Task; @@ -27,9 +28,10 @@ public class CheckTtpComputedMultiMedicResults extends AbstractServiceDelegate { private static final Logger logger = LoggerFactory.getLogger(CheckTtpComputedMultiMedicResults.class); - public CheckTtpComputedMultiMedicResults(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper) + public CheckTtpComputedMultiMedicResults(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, + ReadAccessHelper readAccessHelper) { - super(clientProvider, taskHelper); + super(clientProvider, taskHelper, readAccessHelper); } @Override diff --git a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/DownloadFeasibilityResources.java b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/DownloadFeasibilityResources.java index 2090dbda..cf5b8b76 100644 --- a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/DownloadFeasibilityResources.java +++ b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/DownloadFeasibilityResources.java @@ -23,6 +23,7 @@ import org.highmed.dsf.bpe.delegate.AbstractServiceDelegate; import org.highmed.dsf.bpe.variables.BloomFilterConfig; import org.highmed.dsf.bpe.variables.BloomFilterConfigValues; +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.TaskHelper; @@ -46,10 +47,11 @@ public class DownloadFeasibilityResources extends AbstractServiceDelegate implem private final OrganizationProvider organizationProvider; - public DownloadFeasibilityResources(OrganizationProvider organizationProvider, - FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper) + public DownloadFeasibilityResources(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, + ReadAccessHelper readAccessHelper, OrganizationProvider organizationProvider) { - super(clientProvider, taskHelper); + super(clientProvider, taskHelper, readAccessHelper); + this.organizationProvider = organizationProvider; } @@ -57,6 +59,7 @@ public DownloadFeasibilityResources(OrganizationProvider organizationProvider, public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); + Objects.requireNonNull(organizationProvider, "organizationProvider"); } @@ -110,7 +113,7 @@ private FhirWebserviceClient getWebserviceClient(IdType researchStudyId) } else { - return getFhirWebserviceClientProvider().getRemoteWebserviceClient(researchStudyId.getBaseUrl()); + return getFhirWebserviceClientProvider().getWebserviceClient(researchStudyId.getBaseUrl()); } } diff --git a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/DownloadResearchStudyResource.java b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/DownloadResearchStudyResource.java index 31841399..f18ba427 100644 --- a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/DownloadResearchStudyResource.java +++ b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/DownloadResearchStudyResource.java @@ -17,6 +17,7 @@ import org.camunda.bpm.engine.delegate.DelegateExecution; import org.highmed.dsf.bpe.delegate.AbstractServiceDelegate; +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.TaskHelper; @@ -37,10 +38,10 @@ public class DownloadResearchStudyResource extends AbstractServiceDelegate imple private final OrganizationProvider organizationProvider; - public DownloadResearchStudyResource(OrganizationProvider organizationProvider, - FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper) + public DownloadResearchStudyResource(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, + ReadAccessHelper readAccessHelper, OrganizationProvider organizationProvider) { - super(clientProvider, taskHelper); + super(clientProvider, taskHelper, readAccessHelper); this.organizationProvider = organizationProvider; } diff --git a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/DownloadResultSets.java b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/DownloadResultSets.java index 5df78880..6f49b179 100644 --- a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/DownloadResultSets.java +++ b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/DownloadResultSets.java @@ -16,6 +16,7 @@ import org.highmed.dsf.bpe.variables.FeasibilityQueryResult; import org.highmed.dsf.bpe.variables.FeasibilityQueryResults; import org.highmed.dsf.bpe.variables.FeasibilityQueryResultsValues; +import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper; import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider; import org.highmed.dsf.fhir.task.TaskHelper; import org.highmed.fhir.client.FhirWebserviceClient; @@ -33,9 +34,9 @@ public class DownloadResultSets extends AbstractServiceDelegate private final ObjectMapper openEhrObjectMapper; public DownloadResultSets(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, - ObjectMapper openEhrObjectMapper) + ReadAccessHelper readAccessHelper, ObjectMapper openEhrObjectMapper) { - super(clientProvider, taskHelper); + super(clientProvider, taskHelper, readAccessHelper); this.openEhrObjectMapper = openEhrObjectMapper; } @@ -68,7 +69,7 @@ private List download(FeasibilityQueryResults results) private FeasibilityQueryResult download(FeasibilityQueryResult result) { IdType id = new IdType(result.getResultSetUrl()); - FhirWebserviceClient client = getFhirWebserviceClientProvider().getRemoteWebserviceClient(id.getBaseUrl()); + FhirWebserviceClient client = getFhirWebserviceClientProvider().getWebserviceClient(id.getBaseUrl()); InputStream binary = readBinaryResource(client, id.getIdPart()); ResultSet resultSet = deserializeResultSet(binary); diff --git a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/ExecuteQueries.java b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/ExecuteQueries.java index a2ae34df..7c814ecd 100644 --- a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/ExecuteQueries.java +++ b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/ExecuteQueries.java @@ -1,16 +1,21 @@ package org.highmed.dsf.bpe.service; +import static org.highmed.dsf.bpe.ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_NEEDS_CONSENT_CHECK; +import static org.highmed.dsf.bpe.ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_NEEDS_RECORD_LINKAGE; +import static org.highmed.dsf.bpe.ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_QUERIES; +import static org.highmed.dsf.bpe.ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_QUERY_RESULTS; + import java.util.List; import java.util.Map; import java.util.Objects; import java.util.stream.Collectors; import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.highmed.dsf.bpe.ConstantsFeasibility; import org.highmed.dsf.bpe.delegate.AbstractServiceDelegate; import org.highmed.dsf.bpe.variables.FeasibilityQueryResult; import org.highmed.dsf.bpe.variables.FeasibilityQueryResults; import org.highmed.dsf.bpe.variables.FeasibilityQueryResultsValues; +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.TaskHelper; @@ -24,9 +29,9 @@ public class ExecuteQueries extends AbstractServiceDelegate implements Initializ private final OrganizationProvider organizationProvider; public ExecuteQueries(FhirWebserviceClientProvider clientProvider, OpenEhrClient openehrClient, - TaskHelper taskHelper, OrganizationProvider organizationProvider) + TaskHelper taskHelper, ReadAccessHelper readAccessHelper, OrganizationProvider organizationProvider) { - super(clientProvider, taskHelper); + super(clientProvider, taskHelper, readAccessHelper); this.openehrClient = openehrClient; this.organizationProvider = organizationProvider; @@ -46,19 +51,16 @@ protected void doExecute(DelegateExecution execution) throws Exception { // @SuppressWarnings("unchecked") - Map queries = (Map) execution - .getVariable(ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_QUERIES); + Map queries = (Map) execution.getVariable(BPMN_EXECUTION_VARIABLE_QUERIES); - Boolean needsConsentCheck = (Boolean) execution - .getVariable(ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_NEEDS_CONSENT_CHECK); - Boolean needsRecordLinkage = (Boolean) execution - .getVariable(ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_NEEDS_RECORD_LINKAGE); + Boolean needsConsentCheck = (Boolean) execution.getVariable(BPMN_EXECUTION_VARIABLE_NEEDS_CONSENT_CHECK); + Boolean needsRecordLinkage = (Boolean) execution.getVariable(BPMN_EXECUTION_VARIABLE_NEEDS_RECORD_LINKAGE); boolean idQuery = Boolean.TRUE.equals(needsConsentCheck) || Boolean.TRUE.equals(needsRecordLinkage); List results = queries.entrySet().stream() .map(entry -> executeQuery(entry.getKey(), entry.getValue(), idQuery)).collect(Collectors.toList()); - execution.setVariable(ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_QUERY_RESULTS, + execution.setVariable(BPMN_EXECUTION_VARIABLE_QUERY_RESULTS, FeasibilityQueryResultsValues.create(new FeasibilityQueryResults(results))); } diff --git a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/ExecuteRecordLink.java b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/ExecuteRecordLink.java index da6d2119..34159b7d 100644 --- a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/ExecuteRecordLink.java +++ b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/ExecuteRecordLink.java @@ -1,5 +1,8 @@ package org.highmed.dsf.bpe.service; +import static org.highmed.dsf.bpe.ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_FINAL_QUERY_RESULTS; +import static org.highmed.dsf.bpe.ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_QUERY_RESULTS; + import java.util.List; import java.util.Map; import java.util.Objects; @@ -7,13 +10,13 @@ import java.util.stream.Collectors; import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.highmed.dsf.bpe.ConstantsFeasibility; import org.highmed.dsf.bpe.delegate.AbstractServiceDelegate; import org.highmed.dsf.bpe.variables.FeasibilityQueryResult; import org.highmed.dsf.bpe.variables.FeasibilityQueryResults; import org.highmed.dsf.bpe.variables.FinalFeasibilityQueryResult; import org.highmed.dsf.bpe.variables.FinalFeasibilityQueryResults; import org.highmed.dsf.bpe.variables.FinalFeasibilityQueryResultsValues; +import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper; import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider; import org.highmed.dsf.fhir.task.TaskHelper; import org.highmed.pseudonymization.domain.PersonWithMdat; @@ -31,9 +34,9 @@ public class ExecuteRecordLink extends AbstractServiceDelegate private final ResultSetTranslatorFromMedicRbfOnly translator; public ExecuteRecordLink(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, - ResultSetTranslatorFromMedicRbfOnly translator) + ReadAccessHelper readAccessHelper, ResultSetTranslatorFromMedicRbfOnly translator) { - super(clientProvider, taskHelper); + super(clientProvider, taskHelper, readAccessHelper); this.translator = translator; } @@ -50,7 +53,7 @@ public void afterPropertiesSet() throws Exception protected void doExecute(DelegateExecution execution) throws Exception { FeasibilityQueryResults results = (FeasibilityQueryResults) execution - .getVariable(ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_QUERY_RESULTS); + .getVariable(BPMN_EXECUTION_VARIABLE_QUERY_RESULTS); Map> byCohortId = results.getResults().stream() .collect(Collectors.groupingBy(FeasibilityQueryResult::getCohortId)); @@ -60,7 +63,7 @@ protected void doExecute(DelegateExecution execution) throws Exception List matchedResults = byCohortId.entrySet().stream() .map(e -> match(matcher, e.getKey(), e.getValue())).collect(Collectors.toList()); - execution.setVariable(ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_FINAL_QUERY_RESULTS, + execution.setVariable(BPMN_EXECUTION_VARIABLE_FINAL_QUERY_RESULTS, FinalFeasibilityQueryResultsValues.create(new FinalFeasibilityQueryResults(matchedResults))); } diff --git a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/FilterQueryResultsByConsent.java b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/FilterQueryResultsByConsent.java index ebdb9f02..7a16b970 100644 --- a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/FilterQueryResultsByConsent.java +++ b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/FilterQueryResultsByConsent.java @@ -1,34 +1,37 @@ package org.highmed.dsf.bpe.service; +import static org.highmed.dsf.bpe.ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_QUERY_RESULTS; + import java.util.List; import java.util.stream.Collectors; import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.highmed.dsf.bpe.ConstantsFeasibility; import org.highmed.dsf.bpe.delegate.AbstractServiceDelegate; import org.highmed.dsf.bpe.variables.FeasibilityQueryResult; import org.highmed.dsf.bpe.variables.FeasibilityQueryResults; import org.highmed.dsf.bpe.variables.FeasibilityQueryResultsValues; +import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper; import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider; import org.highmed.dsf.fhir.task.TaskHelper; import org.highmed.openehr.model.structure.ResultSet; public class FilterQueryResultsByConsent extends AbstractServiceDelegate { - public FilterQueryResultsByConsent(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper) + public FilterQueryResultsByConsent(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, + ReadAccessHelper readAccessHelper) { - super(clientProvider, taskHelper); + super(clientProvider, taskHelper, readAccessHelper); } @Override protected void doExecute(DelegateExecution execution) throws Exception { FeasibilityQueryResults results = (FeasibilityQueryResults) execution - .getVariable(ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_QUERY_RESULTS); + .getVariable(BPMN_EXECUTION_VARIABLE_QUERY_RESULTS); List filteredResults = filterResults(results.getResults()); - execution.setVariable(ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_QUERY_RESULTS, + execution.setVariable(BPMN_EXECUTION_VARIABLE_QUERY_RESULTS, FeasibilityQueryResultsValues.create(new FeasibilityQueryResults(filteredResults))); } diff --git a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/GenerateBloomFilters.java b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/GenerateBloomFilters.java index 6a10c6b1..faa94230 100644 --- a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/GenerateBloomFilters.java +++ b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/GenerateBloomFilters.java @@ -1,11 +1,11 @@ package org.highmed.dsf.bpe.service; import static org.highmed.dsf.bpe.ConstantsBase.BPMN_EXECUTION_VARIABLE_TTP_IDENTIFIER; -import static org.highmed.dsf.bpe.ConstantsBase.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER; import static org.highmed.dsf.bpe.ConstantsBase.OPENEHR_MIMETYPE_JSON; import static org.highmed.dsf.bpe.ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_BLOOM_FILTER_CONFIG; import static org.highmed.dsf.bpe.ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_QUERY_RESULTS; import static org.highmed.dsf.bpe.ConstantsFeasibility.PROFILE_HIGHMED_TASK_LOCAL_SERVICES_PROCESS_URI; +import static org.highmed.pseudonymization.translation.ResultSetTranslatorToTtpRbfOnlyImpl.FILTER_ON_IDAT_NOT_FOUND_EXCEPTION; import java.security.Key; import java.util.List; @@ -19,6 +19,7 @@ import org.highmed.dsf.bpe.variables.FeasibilityQueryResult; import org.highmed.dsf.bpe.variables.FeasibilityQueryResults; import org.highmed.dsf.bpe.variables.FeasibilityQueryResultsValues; +import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper; import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider; import org.highmed.dsf.fhir.task.TaskHelper; import org.highmed.mpi.client.MasterPatientIndexClient; @@ -32,7 +33,6 @@ import org.highmed.pseudonymization.translation.ResultSetTranslatorToTtpRbfOnlyImpl; import org.hl7.fhir.r4.model.Binary; import org.hl7.fhir.r4.model.IdType; -import org.hl7.fhir.r4.model.Reference; import org.hl7.fhir.r4.model.ResourceType; import org.hl7.fhir.r4.model.Task; import org.slf4j.Logger; @@ -58,10 +58,11 @@ public class GenerateBloomFilters extends AbstractServiceDelegate private final BouncyCastleProvider bouncyCastleProvider; public GenerateBloomFilters(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, - String ehrIdColumnPath, MasterPatientIndexClient masterPatientIndexClient, ObjectMapper openEhrObjectMapper, + ReadAccessHelper readAccessHelper, String ehrIdColumnPath, + MasterPatientIndexClient masterPatientIndexClient, ObjectMapper openEhrObjectMapper, BouncyCastleProvider bouncyCastleProvider) { - super(clientProvider, taskHelper); + super(clientProvider, taskHelper, readAccessHelper); this.ehrIdColumnPath = ehrIdColumnPath; this.masterPatientIndexClient = masterPatientIndexClient; @@ -116,7 +117,7 @@ protected ResultSetTranslatorToTtpRbfOnly createResultSetTranslator(BloomFilterC return new ResultSetTranslatorToTtpRbfOnlyImpl(ehrIdColumnPath, createRecordBloomFilterGenerator(bloomFilterConfig.getPermutationSeed(), bloomFilterConfig.getHmacSha2Key(), bloomFilterConfig.getHmacSha3Key()), - masterPatientIndexClient, ResultSetTranslatorToTtpRbfOnlyImpl.FILTER_ON_IDAT_NOT_FOUND_EXCEPTION); + masterPatientIndexClient, FILTER_ON_IDAT_NOT_FOUND_EXCEPTION); } protected RecordBloomFilterGenerator createRecordBloomFilterGenerator(long permutationSeed, Key hmacSha2Key, @@ -149,14 +150,11 @@ private ResultSet translate(ResultSetTranslatorToTtpRbfOnly resultSetTranslator, } } - protected String saveResultSetAsBinaryForTtp(ResultSet resultSet, String securityIdentifier) + protected String saveResultSetAsBinaryForTtp(ResultSet resultSet, String ttpIdentifier) { byte[] content = serializeResultSet(resultSet); - Reference securityContext = new Reference(); - securityContext.setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER).setValue(securityIdentifier); - Binary binary = new Binary().setContentType(OPENEHR_MIMETYPE_JSON).setSecurityContext(securityContext) - .setData(content); + Binary binary = new Binary().setContentType(OPENEHR_MIMETYPE_JSON).setData(content); + getReadAccessHelper().addOrganization(binary, ttpIdentifier); IdType created = createBinaryResource(binary); return new IdType(getFhirWebserviceClientProvider().getLocalBaseUrl(), ResourceType.Binary.name(), diff --git a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/GenerateCountFromIds.java b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/GenerateCountFromIds.java index ef41cf4e..ccc83771 100644 --- a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/GenerateCountFromIds.java +++ b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/GenerateCountFromIds.java @@ -1,33 +1,36 @@ package org.highmed.dsf.bpe.service; +import static org.highmed.dsf.bpe.ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_QUERY_RESULTS; + import java.util.List; import java.util.stream.Collectors; import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.highmed.dsf.bpe.ConstantsFeasibility; import org.highmed.dsf.bpe.delegate.AbstractServiceDelegate; import org.highmed.dsf.bpe.variables.FeasibilityQueryResult; import org.highmed.dsf.bpe.variables.FeasibilityQueryResults; import org.highmed.dsf.bpe.variables.FeasibilityQueryResultsValues; +import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper; import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider; import org.highmed.dsf.fhir.task.TaskHelper; public class GenerateCountFromIds extends AbstractServiceDelegate { - public GenerateCountFromIds(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper) + public GenerateCountFromIds(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, + ReadAccessHelper readAccessHelper) { - super(clientProvider, taskHelper); + super(clientProvider, taskHelper, readAccessHelper); } @Override protected void doExecute(DelegateExecution execution) throws Exception { FeasibilityQueryResults results = (FeasibilityQueryResults) execution - .getVariable(ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_QUERY_RESULTS); + .getVariable(BPMN_EXECUTION_VARIABLE_QUERY_RESULTS); List filteredResults = count(results.getResults()); - execution.setVariable(ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_QUERY_RESULTS, + execution.setVariable(BPMN_EXECUTION_VARIABLE_QUERY_RESULTS, FeasibilityQueryResultsValues.create(new FeasibilityQueryResults(filteredResults))); } diff --git a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/HandleErrorMultiMedicResults.java b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/HandleErrorMultiMedicResults.java index 6b55accd..79161ffd 100644 --- a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/HandleErrorMultiMedicResults.java +++ b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/HandleErrorMultiMedicResults.java @@ -1,17 +1,21 @@ package org.highmed.dsf.bpe.service; +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN; +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN_VALUE_ERROR; + import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.highmed.dsf.bpe.ConstantsBase; import org.highmed.dsf.bpe.delegate.AbstractServiceDelegate; +import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper; import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider; import org.highmed.dsf.fhir.task.TaskHelper; import org.hl7.fhir.r4.model.Task; public class HandleErrorMultiMedicResults extends AbstractServiceDelegate { - public HandleErrorMultiMedicResults(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper) + public HandleErrorMultiMedicResults(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, + ReadAccessHelper readAccessHelper) { - super(clientProvider, taskHelper); + super(clientProvider, taskHelper, readAccessHelper); } @Override @@ -23,13 +27,13 @@ protected void doExecute(DelegateExecution execution) throws Exception currentTask.getInput().forEach(input -> { boolean isErrorInput = input.getType().getCoding().stream() - .anyMatch(code -> code.getSystem().equals(ConstantsBase.CODESYSTEM_HIGHMED_BPMN) - && code.getCode().equals(ConstantsBase.CODESYSTEM_HIGHMED_BPMN_VALUE_ERROR)); + .anyMatch(code -> code.getSystem().equals(CODESYSTEM_HIGHMED_BPMN) + && code.getCode().equals(CODESYSTEM_HIGHMED_BPMN_VALUE_ERROR)); if (isErrorInput) { - leadingTask.getOutput().add(getTaskHelper().createOutput(ConstantsBase.CODESYSTEM_HIGHMED_BPMN, - ConstantsBase.CODESYSTEM_HIGHMED_BPMN_VALUE_ERROR, input.getValue().primitiveValue())); + leadingTask.getOutput().add(getTaskHelper().createOutput(CODESYSTEM_HIGHMED_BPMN, + CODESYSTEM_HIGHMED_BPMN_VALUE_ERROR, input.getValue().primitiveValue())); } }); diff --git a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/ModifyQueries.java b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/ModifyQueries.java index 83cc1bb9..1df227ae 100644 --- a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/ModifyQueries.java +++ b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/ModifyQueries.java @@ -11,6 +11,7 @@ import org.camunda.bpm.engine.delegate.DelegateExecution; import org.highmed.dsf.bpe.delegate.AbstractServiceDelegate; +import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper; import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider; import org.highmed.dsf.fhir.task.TaskHelper; import org.springframework.beans.factory.InitializingBean; @@ -19,9 +20,11 @@ public class ModifyQueries extends AbstractServiceDelegate implements Initializi { private final String ehrIdColumnPath; - public ModifyQueries(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, String ehrIdColumnPath) + public ModifyQueries(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, + ReadAccessHelper readAccessHelper, String ehrIdColumnPath) { - super(clientProvider, taskHelper); + super(clientProvider, taskHelper, readAccessHelper); + this.ehrIdColumnPath = ehrIdColumnPath; } @@ -29,6 +32,7 @@ public ModifyQueries(FhirWebserviceClientProvider clientProvider, TaskHelper tas public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); + Objects.requireNonNull(ehrIdColumnPath, "ehrIdColumnPath"); } diff --git a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/SelectRequestTargets.java b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/SelectRequestTargets.java index 016da37b..08795a72 100644 --- a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/SelectRequestTargets.java +++ b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/SelectRequestTargets.java @@ -1,7 +1,13 @@ package org.highmed.dsf.bpe.service; +import static org.highmed.dsf.bpe.ConstantsBase.BPMN_EXECUTION_VARIABLE_TARGET; +import static org.highmed.dsf.bpe.ConstantsBase.BPMN_EXECUTION_VARIABLE_TARGETS; +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_ORGANIZATION_TYPE; +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_ORGANIZATION_TYPE_VALUE_MEDIC; +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_ORGANIZATION_TYPE_VALUE_TTP; import static org.highmed.dsf.bpe.ConstantsBase.EXTENSION_HIGHMED_PARTICIPATING_MEDIC; import static org.highmed.dsf.bpe.ConstantsBase.EXTENSION_HIGHMED_PARTICIPATING_TTP; +import static org.highmed.dsf.bpe.ConstantsBase.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_HIGHMED_CONSORTIUM; import static org.highmed.dsf.bpe.ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_BLOOM_FILTER_CONFIG; import static org.highmed.dsf.bpe.ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_NEEDS_RECORD_LINKAGE; import static org.highmed.dsf.bpe.ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_RESEARCH_STUDY; @@ -17,17 +23,19 @@ import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.highmed.dsf.bpe.ConstantsBase; import org.highmed.dsf.bpe.delegate.AbstractServiceDelegate; import org.highmed.dsf.bpe.variables.BloomFilterConfig; import org.highmed.dsf.bpe.variables.BloomFilterConfigValues; +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.organization.EndpointProvider; import org.highmed.dsf.fhir.task.TaskHelper; import org.highmed.dsf.fhir.variables.Target; import org.highmed.dsf.fhir.variables.TargetValues; import org.highmed.dsf.fhir.variables.Targets; import org.highmed.dsf.fhir.variables.TargetsValues; +import org.hl7.fhir.r4.model.Extension; +import org.hl7.fhir.r4.model.Identifier; import org.hl7.fhir.r4.model.Reference; import org.hl7.fhir.r4.model.ResearchStudy; @@ -35,16 +43,17 @@ public class SelectRequestTargets extends AbstractServiceDelegate { private static final Random random = new Random(); - private final OrganizationProvider organizationProvider; + private final EndpointProvider endpointProvider; private final KeyGenerator hmacSha2Generator; private final KeyGenerator hmacSha3Generator; public SelectRequestTargets(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, - OrganizationProvider organizationProvider, BouncyCastleProvider bouncyCastleProvider) + ReadAccessHelper readAccessHelper, EndpointProvider endpointProvider, + BouncyCastleProvider bouncyCastleProvider) { - super(clientProvider, taskHelper); + super(clientProvider, taskHelper, readAccessHelper); - this.organizationProvider = organizationProvider; + this.endpointProvider = endpointProvider; try { @@ -63,7 +72,8 @@ public SelectRequestTargets(FhirWebserviceClientProvider clientProvider, TaskHel public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); - Objects.requireNonNull(organizationProvider, "organizationProvider"); + + Objects.requireNonNull(endpointProvider, "endpointProvider"); } @Override @@ -71,11 +81,8 @@ protected void doExecute(DelegateExecution execution) throws Exception { ResearchStudy researchStudy = (ResearchStudy) execution.getVariable(BPMN_EXECUTION_VARIABLE_RESEARCH_STUDY); - execution.setVariable(ConstantsBase.BPMN_EXECUTION_VARIABLE_TARGETS, - TargetsValues.create(getMedicTargets(researchStudy))); - - execution.setVariable(ConstantsBase.BPMN_EXECUTION_VARIABLE_TARGET, - TargetValues.create(getTtpTarget(researchStudy))); + execution.setVariable(BPMN_EXECUTION_VARIABLE_TARGETS, TargetsValues.create(getMedicTargets(researchStudy))); + execution.setVariable(BPMN_EXECUTION_VARIABLE_TARGET, TargetValues.create(getTtpTarget(researchStudy))); Boolean needsRecordLinkage = (Boolean) execution.getVariable(BPMN_EXECUTION_VARIABLE_NEEDS_RECORD_LINKAGE); if (Boolean.TRUE.equals(needsRecordLinkage)) @@ -94,8 +101,12 @@ private BloomFilterConfig createBloomFilterConfig() private Targets getMedicTargets(ResearchStudy researchStudy) { List targets = researchStudy.getExtensionsByUrl(EXTENSION_HIGHMED_PARTICIPATING_MEDIC).stream() - .filter(e -> e.getValue() instanceof Reference).map(e -> (Reference) e.getValue()) - .map(r -> Target.createBiDirectionalTarget(r.getIdentifier().getValue(), UUID.randomUUID().toString())) + .filter(Extension::hasValue).map(Extension::getValue).filter(v -> v instanceof Reference) + .map(v -> (Reference) v).filter(Reference::hasIdentifier).map(Reference::getIdentifier) + .filter(Identifier::hasValue).map(Identifier::getValue) + .map(medicIdentifier -> Target.createBiDirectionalTarget(medicIdentifier, + getAddress(CODESYSTEM_HIGHMED_ORGANIZATION_TYPE_VALUE_MEDIC, medicIdentifier), + UUID.randomUUID().toString())) .collect(Collectors.toList()); return new Targets(targets); @@ -104,7 +115,19 @@ private Targets getMedicTargets(ResearchStudy researchStudy) private Target getTtpTarget(ResearchStudy researchStudy) { return researchStudy.getExtensionsByUrl(EXTENSION_HIGHMED_PARTICIPATING_TTP).stream() - .filter(e -> e.getValue() instanceof Reference).map(e -> (Reference) e.getValue()) - .map(r -> Target.createUniDirectionalTarget(r.getIdentifier().getValue())).findFirst().get(); + .filter(Extension::hasValue).map(Extension::getValue).filter(v -> v instanceof Reference) + .map(v -> (Reference) v).filter(Reference::hasIdentifier).map(Reference::getIdentifier) + .filter(Identifier::hasValue).map(Identifier::getValue) + .map(ttpIdentifier -> Target.createUniDirectionalTarget(ttpIdentifier, + getAddress(CODESYSTEM_HIGHMED_ORGANIZATION_TYPE_VALUE_TTP, ttpIdentifier))) + .findFirst().get(); + } + + private String getAddress(String role, String identifier) + { + return endpointProvider + .getFirstConsortiumEndpointAdress(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_HIGHMED_CONSORTIUM, + CODESYSTEM_HIGHMED_ORGANIZATION_TYPE, role, identifier) + .get(); } } diff --git a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/SelectResponseTargetMedic.java b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/SelectResponseTargetMedic.java index 5e078184..c087f26c 100644 --- a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/SelectResponseTargetMedic.java +++ b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/SelectResponseTargetMedic.java @@ -1,28 +1,32 @@ package org.highmed.dsf.bpe.service; +import static org.highmed.dsf.bpe.ConstantsBase.BPMN_EXECUTION_VARIABLE_TARGET; +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_ORGANIZATION_TYPE; +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_ORGANIZATION_TYPE_VALUE_MEDIC; +import static org.highmed.dsf.bpe.ConstantsBase.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_HIGHMED_CONSORTIUM; + import java.util.Objects; import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.highmed.dsf.bpe.ConstantsBase; import org.highmed.dsf.bpe.delegate.AbstractServiceDelegate; +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.organization.EndpointProvider; import org.highmed.dsf.fhir.task.TaskHelper; import org.highmed.dsf.fhir.variables.Target; import org.highmed.dsf.fhir.variables.TargetValues; -import org.hl7.fhir.r4.model.Task; import org.springframework.beans.factory.InitializingBean; public class SelectResponseTargetMedic extends AbstractServiceDelegate implements InitializingBean { - private final OrganizationProvider organizationProvider; + private final EndpointProvider endpointProvider; public SelectResponseTargetMedic(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, - OrganizationProvider organizationProvider) + ReadAccessHelper readAccessHelper, EndpointProvider endpointProvider) { - super(clientProvider, taskHelper); + super(clientProvider, taskHelper, readAccessHelper); - this.organizationProvider = organizationProvider; + this.endpointProvider = endpointProvider; } @Override @@ -30,15 +34,19 @@ public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); - Objects.requireNonNull(organizationProvider, "organizationProvider"); + Objects.requireNonNull(endpointProvider, "endpointProvider"); } @Override protected void doExecute(DelegateExecution execution) throws Exception { - Task task = getLeadingTaskFromExecutionVariables(); - - Target medicTarget = Target.createUniDirectionalTarget(task.getRequester().getIdentifier().getValue()); - execution.setVariable(ConstantsBase.BPMN_EXECUTION_VARIABLE_TARGET, TargetValues.create(medicTarget)); + String medicIndentifier = getLeadingTaskFromExecutionVariables().getRequester().getIdentifier().getValue(); + + Target medicTarget = Target.createUniDirectionalTarget(medicIndentifier, + endpointProvider.getFirstConsortiumEndpointAdress( + NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_HIGHMED_CONSORTIUM, + CODESYSTEM_HIGHMED_ORGANIZATION_TYPE, CODESYSTEM_HIGHMED_ORGANIZATION_TYPE_VALUE_MEDIC, + medicIndentifier).get()); + execution.setVariable(BPMN_EXECUTION_VARIABLE_TARGET, TargetValues.create(medicTarget)); } } diff --git a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/SelectResponseTargetTtp.java b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/SelectResponseTargetTtp.java index 7c08e1b0..328701e1 100644 --- a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/SelectResponseTargetTtp.java +++ b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/SelectResponseTargetTtp.java @@ -1,12 +1,20 @@ package org.highmed.dsf.bpe.service; +import static org.highmed.dsf.bpe.ConstantsBase.BPMN_EXECUTION_VARIABLE_TARGET; +import static org.highmed.dsf.bpe.ConstantsBase.BPMN_EXECUTION_VARIABLE_TTP_IDENTIFIER; +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN; +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN_VALUE_CORRELATION_KEY; +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_ORGANIZATION_TYPE; +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_ORGANIZATION_TYPE_VALUE_TTP; +import static org.highmed.dsf.bpe.ConstantsBase.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_HIGHMED_CONSORTIUM; + import java.util.Objects; import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.highmed.dsf.bpe.ConstantsBase; import org.highmed.dsf.bpe.delegate.AbstractServiceDelegate; +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.organization.EndpointProvider; import org.highmed.dsf.fhir.task.TaskHelper; import org.highmed.dsf.fhir.variables.Target; import org.highmed.dsf.fhir.variables.TargetValues; @@ -15,30 +23,37 @@ public class SelectResponseTargetTtp extends AbstractServiceDelegate implements InitializingBean { - private final OrganizationProvider organizationProvider; + private final EndpointProvider endpointProvider; public SelectResponseTargetTtp(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, - OrganizationProvider organizationProvider) + ReadAccessHelper readAccessHelper, EndpointProvider endpointProvider) { - super(clientProvider, taskHelper); - this.organizationProvider = organizationProvider; + super(clientProvider, taskHelper, readAccessHelper); + + this.endpointProvider = endpointProvider; } @Override public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); - Objects.requireNonNull(organizationProvider, "organizationProvider"); + + Objects.requireNonNull(endpointProvider, "endpointProvider"); } @Override protected void doExecute(DelegateExecution execution) throws Exception { - String ttpIdentifier = (String) execution.getVariable(ConstantsBase.BPMN_EXECUTION_VARIABLE_TTP_IDENTIFIER); + String ttpIdentifier = (String) execution.getVariable(BPMN_EXECUTION_VARIABLE_TTP_IDENTIFIER); String correlationKey = getCorrelationKey(execution); - Target ttpTarget = Target.createBiDirectionalTarget(ttpIdentifier, correlationKey); - execution.setVariable(ConstantsBase.BPMN_EXECUTION_VARIABLE_TARGET, TargetValues.create(ttpTarget)); + Target ttpTarget = Target.createBiDirectionalTarget(ttpIdentifier, + endpointProvider.getFirstConsortiumEndpointAdress( + NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_HIGHMED_CONSORTIUM, + CODESYSTEM_HIGHMED_ORGANIZATION_TYPE, CODESYSTEM_HIGHMED_ORGANIZATION_TYPE_VALUE_TTP, + ttpIdentifier).get(), + correlationKey); + execution.setVariable(BPMN_EXECUTION_VARIABLE_TARGET, TargetValues.create(ttpTarget)); } private String getCorrelationKey(DelegateExecution execution) @@ -46,8 +61,8 @@ private String getCorrelationKey(DelegateExecution execution) Task task = getCurrentTaskFromExecutionVariables(); return getTaskHelper() - .getFirstInputParameterStringValue(task, ConstantsBase.CODESYSTEM_HIGHMED_BPMN, - ConstantsBase.CODESYSTEM_HIGHMED_BPMN_VALUE_CORRELATION_KEY) + .getFirstInputParameterStringValue(task, CODESYSTEM_HIGHMED_BPMN, + CODESYSTEM_HIGHMED_BPMN_VALUE_CORRELATION_KEY) .orElseThrow(() -> new IllegalStateException( "No correlation key found, this error should have been caught by resource validation")); } diff --git a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/StoreCorrelationKeys.java b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/StoreCorrelationKeys.java index aab08ec4..ab70cc74 100644 --- a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/StoreCorrelationKeys.java +++ b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/StoreCorrelationKeys.java @@ -1,5 +1,6 @@ package org.highmed.dsf.bpe.service; +import static org.highmed.dsf.bpe.ConstantsBase.BPMN_EXECUTION_VARIABLE_TARGETS; import static org.highmed.dsf.bpe.ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_NEEDS_RECORD_LINKAGE; import static org.highmed.dsf.bpe.ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_QUERY_RESULTS; import static org.highmed.dsf.bpe.ConstantsFeasibility.CODESYSTEM_HIGHMED_FEASIBILITY; @@ -10,10 +11,10 @@ import java.util.stream.Collectors; import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.highmed.dsf.bpe.ConstantsBase; import org.highmed.dsf.bpe.delegate.AbstractServiceDelegate; import org.highmed.dsf.bpe.variables.FeasibilityQueryResults; import org.highmed.dsf.bpe.variables.FeasibilityQueryResultsValues; +import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper; import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider; import org.highmed.dsf.fhir.task.TaskHelper; import org.highmed.dsf.fhir.variables.Target; @@ -23,9 +24,10 @@ public class StoreCorrelationKeys extends AbstractServiceDelegate { - public StoreCorrelationKeys(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper) + public StoreCorrelationKeys(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, + ReadAccessHelper readAccessHelper) { - super(clientProvider, taskHelper); + super(clientProvider, taskHelper, readAccessHelper); } @Override @@ -36,11 +38,10 @@ protected void doExecute(DelegateExecution execution) throws Exception List targets = getTaskHelper() .getInputParameterStringValues(task, CODESYSTEM_HIGHMED_FEASIBILITY, CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_PARTICIPATING_MEDIC_CORRELATION_KEY) - .map(correlationKey -> Target.createBiDirectionalTarget("", correlationKey)) + .map(correlationKey -> Target.createBiDirectionalTarget("", "", correlationKey)) .collect(Collectors.toList()); - execution.setVariable(ConstantsBase.BPMN_EXECUTION_VARIABLE_TARGETS, - TargetsValues.create(new Targets(targets))); + execution.setVariable(BPMN_EXECUTION_VARIABLE_TARGETS, TargetsValues.create(new Targets(targets))); boolean needsRecordLinkage = getNeedsRecordLinkageCheck(task); execution.setVariable(BPMN_EXECUTION_VARIABLE_NEEDS_RECORD_LINKAGE, needsRecordLinkage); diff --git a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/StoreResults.java b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/StoreResults.java index c57b9c56..9ebdab5d 100644 --- a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/StoreResults.java +++ b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/service/StoreResults.java @@ -17,6 +17,7 @@ import org.highmed.dsf.bpe.variables.FeasibilityQueryResult; import org.highmed.dsf.bpe.variables.FeasibilityQueryResults; import org.highmed.dsf.bpe.variables.FeasibilityQueryResultsValues; +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.TaskHelper; @@ -30,9 +31,9 @@ public class StoreResults extends AbstractServiceDelegate implements Initializin private final OrganizationProvider organizationProvider; public StoreResults(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, - OrganizationProvider organizationProvider) + ReadAccessHelper readAccessHelper, OrganizationProvider organizationProvider) { - super(clientProvider, taskHelper); + super(clientProvider, taskHelper, readAccessHelper); this.organizationProvider = organizationProvider; } @@ -97,5 +98,4 @@ private List getResults(Task task, boolean needsRecordLi }).collect(Collectors.toList()); } } - } diff --git a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/spring/config/FeasibilityConfig.java b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/spring/config/FeasibilityConfig.java index 1abc6a6a..b674a878 100644 --- a/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/spring/config/FeasibilityConfig.java +++ b/dsf-bpe-process-feasibility/src/main/java/org/highmed/dsf/bpe/spring/config/FeasibilityConfig.java @@ -27,8 +27,10 @@ import org.highmed.dsf.bpe.service.SelectResponseTargetTtp; import org.highmed.dsf.bpe.service.StoreCorrelationKeys; import org.highmed.dsf.bpe.service.StoreResults; +import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper; import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider; import org.highmed.dsf.fhir.group.GroupHelper; +import org.highmed.dsf.fhir.organization.EndpointProvider; import org.highmed.dsf.fhir.organization.OrganizationProvider; import org.highmed.dsf.fhir.task.TaskHelper; import org.highmed.mpi.client.MasterPatientIndexClient; @@ -62,9 +64,15 @@ public class FeasibilityConfig @Autowired private OrganizationProvider organizationProvider; + @Autowired + private EndpointProvider endpointProvider; + @Autowired private TaskHelper taskHelper; + @Autowired + private ReadAccessHelper readAccessHelper; + @Autowired private GroupHelper groupHelper; @@ -87,37 +95,40 @@ public class FeasibilityConfig @Bean public DownloadResearchStudyResource downloadResearchStudyResource() { - return new DownloadResearchStudyResource(organizationProvider, fhirClientProvider, taskHelper); + return new DownloadResearchStudyResource(fhirClientProvider, taskHelper, readAccessHelper, + organizationProvider); } @Bean public SelectRequestTargets selectRequestTargets() { - return new SelectRequestTargets(fhirClientProvider, taskHelper, organizationProvider, bouncyCastleProvider()); + return new SelectRequestTargets(fhirClientProvider, taskHelper, readAccessHelper, endpointProvider, + bouncyCastleProvider()); } @Bean public SendTtpRequest sendTtpRequest() { - return new SendTtpRequest(fhirClientProvider, taskHelper, organizationProvider, fhirContext); + return new SendTtpRequest(fhirClientProvider, taskHelper, readAccessHelper, organizationProvider, fhirContext); } @Bean public SendMedicRequest sendMedicRequest() { - return new SendMedicRequest(fhirClientProvider, taskHelper, organizationProvider, fhirContext); + return new SendMedicRequest(fhirClientProvider, taskHelper, readAccessHelper, organizationProvider, + fhirContext); } @Bean public CheckMultiMedicResults checkMultiMedicResults() { - return new CheckMultiMedicResults(fhirClientProvider, taskHelper); + return new CheckMultiMedicResults(fhirClientProvider, taskHelper, readAccessHelper); } @Bean public HandleErrorMultiMedicResults handleErrorMultiMedicResults() { - return new HandleErrorMultiMedicResults(fhirClientProvider, taskHelper); + return new HandleErrorMultiMedicResults(fhirClientProvider, taskHelper, readAccessHelper); } // @@ -127,43 +138,44 @@ public HandleErrorMultiMedicResults handleErrorMultiMedicResults() @Bean public DownloadFeasibilityResources downloadFeasibilityResources() { - return new DownloadFeasibilityResources(organizationProvider, fhirClientProvider, taskHelper); + return new DownloadFeasibilityResources(fhirClientProvider, taskHelper, readAccessHelper, organizationProvider); } @Bean public CheckFeasibilityResources checkFeasibilityResources() { - return new CheckFeasibilityResources(fhirClientProvider, taskHelper); + return new CheckFeasibilityResources(fhirClientProvider, taskHelper, readAccessHelper); } @Bean public CheckQueries checkQueries() { - return new CheckQueries(fhirClientProvider, taskHelper, groupHelper); + return new CheckQueries(fhirClientProvider, taskHelper, readAccessHelper, groupHelper); } @Bean public ModifyQueries modifyQueries() { - return new ModifyQueries(fhirClientProvider, taskHelper, ehrIdColumnPath); + return new ModifyQueries(fhirClientProvider, taskHelper, readAccessHelper, ehrIdColumnPath); } @Bean public ExecuteQueries executeQueries() { - return new ExecuteQueries(fhirClientProvider, openEhrClient(), taskHelper, organizationProvider); + return new ExecuteQueries(fhirClientProvider, openEhrClient(), taskHelper, readAccessHelper, + organizationProvider); } @Bean public FilterQueryResultsByConsent filterQueryResultsByConsent() { - return new FilterQueryResultsByConsent(fhirClientProvider, taskHelper); + return new FilterQueryResultsByConsent(fhirClientProvider, taskHelper, readAccessHelper); } @Bean public GenerateCountFromIds generateCountFromIds() { - return new GenerateCountFromIds(fhirClientProvider, taskHelper); + return new GenerateCountFromIds(fhirClientProvider, taskHelper, readAccessHelper); } @Bean @@ -181,8 +193,8 @@ public OpenEhrClient openEhrClient() @Bean public GenerateBloomFilters generateBloomFilters() { - return new GenerateBloomFilters(fhirClientProvider, taskHelper, ehrIdColumnPath, masterPatientIndexClient(), - objectMapper, bouncyCastleProvider()); + return new GenerateBloomFilters(fhirClientProvider, taskHelper, readAccessHelper, ehrIdColumnPath, + masterPatientIndexClient(), objectMapper, bouncyCastleProvider()); } @Bean @@ -194,19 +206,20 @@ public BouncyCastleProvider bouncyCastleProvider() @Bean public CheckSingleMedicResults checkSingleMedicResults() { - return new CheckSingleMedicResults(fhirClientProvider, taskHelper); + return new CheckSingleMedicResults(fhirClientProvider, taskHelper, readAccessHelper); } @Bean public SelectResponseTargetTtp selectResponseTargetTtp() { - return new SelectResponseTargetTtp(fhirClientProvider, taskHelper, organizationProvider); + return new SelectResponseTargetTtp(fhirClientProvider, taskHelper, readAccessHelper, endpointProvider); } @Bean public SendSingleMedicResults sendSingleMedicResults() { - return new SendSingleMedicResults(fhirClientProvider, taskHelper, organizationProvider, fhirContext); + return new SendSingleMedicResults(fhirClientProvider, taskHelper, readAccessHelper, organizationProvider, + fhirContext); } // @@ -216,19 +229,19 @@ public SendSingleMedicResults sendSingleMedicResults() @Bean public StoreCorrelationKeys storeCorrelationKeys() { - return new StoreCorrelationKeys(fhirClientProvider, taskHelper); + return new StoreCorrelationKeys(fhirClientProvider, taskHelper, readAccessHelper); } @Bean public StoreResults storeResults() { - return new StoreResults(fhirClientProvider, taskHelper, organizationProvider); + return new StoreResults(fhirClientProvider, taskHelper, readAccessHelper, organizationProvider); } @Bean public DownloadResultSets downloadResultSets() { - return new DownloadResultSets(fhirClientProvider, taskHelper, objectMapper); + return new DownloadResultSets(fhirClientProvider, taskHelper, readAccessHelper, objectMapper); } @Bean @@ -240,36 +253,39 @@ public ResultSetTranslatorFromMedicRbfOnly resultSetTranslatorFromMedicRbfOnly() @Bean public ExecuteRecordLink executeRecordLink() { - return new ExecuteRecordLink(fhirClientProvider, taskHelper, resultSetTranslatorFromMedicRbfOnly()); + return new ExecuteRecordLink(fhirClientProvider, taskHelper, readAccessHelper, + resultSetTranslatorFromMedicRbfOnly()); } @Bean public CalculateMultiMedicResults calculateMultiMedicResults() { - return new CalculateMultiMedicResults(fhirClientProvider, taskHelper); + return new CalculateMultiMedicResults(fhirClientProvider, taskHelper, readAccessHelper); } @Bean public CheckTtpComputedMultiMedicResults checkTtpComputedMultiMedicResults() { - return new CheckTtpComputedMultiMedicResults(fhirClientProvider, taskHelper); + return new CheckTtpComputedMultiMedicResults(fhirClientProvider, taskHelper, readAccessHelper); } @Bean public SelectResponseTargetMedic selectResponseTargetMedic() { - return new SelectResponseTargetMedic(fhirClientProvider, taskHelper, organizationProvider); + return new SelectResponseTargetMedic(fhirClientProvider, taskHelper, readAccessHelper, endpointProvider); } @Bean public SendMultiMedicResults sendMultiMedicResults() { - return new SendMultiMedicResults(fhirClientProvider, taskHelper, organizationProvider, fhirContext); + return new SendMultiMedicResults(fhirClientProvider, taskHelper, readAccessHelper, organizationProvider, + fhirContext); } @Bean public SendMultiMedicErrors sendMultiMedicErrors() { - return new SendMultiMedicErrors(fhirClientProvider, taskHelper, organizationProvider, fhirContext); + return new SendMultiMedicErrors(fhirClientProvider, taskHelper, readAccessHelper, organizationProvider, + fhirContext); } } diff --git a/dsf-bpe-process-feasibility/src/main/resources/bpe/computeFeasibility.bpmn b/dsf-bpe-process-feasibility/src/main/resources/bpe/computeFeasibility.bpmn index 18ccd7a4..07f17b2e 100644 --- a/dsf-bpe-process-feasibility/src/main/resources/bpe/computeFeasibility.bpmn +++ b/dsf-bpe-process-feasibility/src/main/resources/bpe/computeFeasibility.bpmn @@ -1,6 +1,6 @@ - - + + SequenceFlow_1lfe4wr SequenceFlow_0xxpamp @@ -45,10 +45,9 @@ - requestFeasibility - http://highmed.org/fhir/StructureDefinition/task-multi-medic-result-feasibility - 0.5.0 + http://highmed.org/bpe/Process/requestFeasibility/0.5.0 resultMultiMedicFeasibilityMessage + http://highmed.org/fhir/StructureDefinition/task-multi-medic-result-feasibility Flow_1r6dq8y @@ -97,10 +96,9 @@ - requestFeasibility - http://highmed.org/fhir/StructureDefinition/task-multi-medic-error-feasibility - 0.5.0 + http://highmed.org/bpe/Process/requestFeasibility/0.5.0 errorMultiMedicFeasibilityMessage + http://highmed.org/fhir/StructureDefinition/task-multi-medic-error-feasibility Flow_1tmnvhl @@ -125,7 +123,7 @@ - + diff --git a/dsf-bpe-process-feasibility/src/main/resources/bpe/executeFeasibility.bpmn b/dsf-bpe-process-feasibility/src/main/resources/bpe/executeFeasibility.bpmn index 28ecd7dc..6e1ba9f2 100644 --- a/dsf-bpe-process-feasibility/src/main/resources/bpe/executeFeasibility.bpmn +++ b/dsf-bpe-process-feasibility/src/main/resources/bpe/executeFeasibility.bpmn @@ -1,6 +1,6 @@ - - + + SequenceFlow_0q803rh SequenceFlow_04ouilq @@ -24,9 +24,8 @@ + http://highmed.org/bpe/Process/computeFeasibility/0.5.0 resultSingleMedicFeasibilityMessage - 0.5.0 - computeFeasibility http://highmed.org/fhir/StructureDefinition/task-single-medic-result-feasibility @@ -132,7 +131,7 @@ - + diff --git a/dsf-bpe-process-feasibility/src/main/resources/bpe/requestFeasibility.bpmn b/dsf-bpe-process-feasibility/src/main/resources/bpe/requestFeasibility.bpmn index 120b1ce3..e9e704df 100644 --- a/dsf-bpe-process-feasibility/src/main/resources/bpe/requestFeasibility.bpmn +++ b/dsf-bpe-process-feasibility/src/main/resources/bpe/requestFeasibility.bpmn @@ -1,6 +1,6 @@ - - + + SequenceFlow_11k77gx @@ -12,8 +12,7 @@ - executeFeasibility - 0.5.0 + http://highmed.org/bpe/Process/executeFeasibility/0.5.0 executeFeasibilityMessage http://highmed.org/fhir/StructureDefinition/task-execute-feasibility @@ -33,8 +32,7 @@ - computeFeasibility - 0.5.0 + http://highmed.org/bpe/Process/computeFeasibility/0.5.0 computeFeasibilityMessage http://highmed.org/fhir/StructureDefinition/task-compute-feasibility @@ -97,7 +95,7 @@ - + diff --git a/dsf-bpe-process-feasibility/src/main/resources/fhir/ActivityDefinition/highmed-computeFeasibility.xml b/dsf-bpe-process-feasibility/src/main/resources/fhir/ActivityDefinition/highmed-computeFeasibility.xml index 2350bef3..2b8becf9 100644 --- a/dsf-bpe-process-feasibility/src/main/resources/fhir/ActivityDefinition/highmed-computeFeasibility.xml +++ b/dsf-bpe-process-feasibility/src/main/resources/fhir/ActivityDefinition/highmed-computeFeasibility.xml @@ -1,84 +1,116 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + <subtitle value="Process to compute feasibility result" /> <!-- status managed by bpe --> <status value="unknown" /> <experimental value="false" /> - <date value="2021-01-26" /> + <date value="2021-06-09" /> <publisher value="HiGHmed" /> <contact> <name value="HiGHmed" /> diff --git a/dsf-bpe-process-feasibility/src/main/resources/fhir/ActivityDefinition/highmed-executeFeasibility.xml b/dsf-bpe-process-feasibility/src/main/resources/fhir/ActivityDefinition/highmed-executeFeasibility.xml index 0cfb4c67..e98c22a7 100644 --- a/dsf-bpe-process-feasibility/src/main/resources/fhir/ActivityDefinition/highmed-executeFeasibility.xml +++ b/dsf-bpe-process-feasibility/src/main/resources/fhir/ActivityDefinition/highmed-executeFeasibility.xml @@ -1,58 +1,88 @@ <ActivityDefinition xmlns="http://hl7.org/fhir"> <meta> <tag> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="REMOTE" /> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag" /> + <code value="ALL" /> </tag> </meta> <extension url="http://highmed.org/fhir/StructureDefinition/extension-process-authorization"> <extension url="message-name"> <valueString value="executeFeasibilityMessage" /> </extension> - <extension url="authorization-roles"> - <extension url="authorization-role"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="LOCAL" /> - </valueCoding> - </extension> - <extension url="authorization-role"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="REMOTE" /> - </valueCoding> - </extension> + <extension url="task-profile"> + <valueCanonical value="http://highmed.org/fhir/StructureDefinition/task-execute-feasibility" /> </extension> - <extension url="requester-organization-types"> - <extension url="requester-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="MeDIC" /> - </valueCoding> - </extension> + <extension url="requester"> + <valueCoding> + <extension url="http://highmed.org/fhir/StructureDefinition/extension-process-authorization-consortium-role"> + <extension url="consortium"> + <valueIdentifier> + <system value="http://highmed.org/sid/organization-identifier" /> + <value value="highmed.org" /> + </valueIdentifier> + </extension> + <extension url="role"> + <valueCoding> + <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> + <code value="MeDIC" /> + </valueCoding> + </extension> + </extension> + <system value="http://highmed.org/fhir/CodeSystem/process-authorization" /> + <code value="LOCAL_ROLE" /> + </valueCoding> </extension> - <extension url="recipient-organization-types"> - <extension url="recipient-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="MeDIC" /> - </valueCoding> - </extension> + <extension url="requester"> + <valueCoding> + <extension url="http://highmed.org/fhir/StructureDefinition/extension-process-authorization-consortium-role"> + <extension url="consortium"> + <valueIdentifier> + <system value="http://highmed.org/sid/organization-identifier" /> + <value value="highmed.org" /> + </valueIdentifier> + </extension> + <extension url="role"> + <valueCoding> + <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> + <code value="MeDIC" /> + </valueCoding> + </extension> + </extension> + <system value="http://highmed.org/fhir/CodeSystem/process-authorization" /> + <code value="REMOTE_ROLE" /> + </valueCoding> </extension> - <extension url="task-profile"> - <valueCanonical value="http://highmed.org/fhir/StructureDefinition/task-execute-feasibility" /> + <extension url="recipient"> + <valueCoding> + <extension url="http://highmed.org/fhir/StructureDefinition/extension-process-authorization-consortium-role"> + <extension url="consortium"> + <valueIdentifier> + <system value="http://highmed.org/sid/organization-identifier" /> + <value value="highmed.org" /> + </valueIdentifier> + </extension> + <extension url="role"> + <valueCoding> + <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> + <code value="MeDIC" /> + </valueCoding> + </extension> + </extension> + <system value="http://highmed.org/fhir/CodeSystem/process-authorization" /> + <code value="LOCAL_ROLE" /> + </valueCoding> </extension> </extension> <url value="http://highmed.org/bpe/Process/executeFeasibility" /> <!-- version managed by bpe --> <version value="${version}" /> - <name value="executeFeasibility" /> + <name value="ExecuteFeasibility" /> <title value="Execute a Feasibility" /> <subtitle value="Process to execute a feasibility query" /> <!-- status managed by bpe --> <status value="unknown" /> <experimental value="false" /> - <date value="2021-01-26" /> + <date value="2021-06-09" /> <publisher value="HiGHmed" /> <contact> <name value="HiGHmed" /> diff --git a/dsf-bpe-process-feasibility/src/main/resources/fhir/ActivityDefinition/highmed-requestFeasibility.xml b/dsf-bpe-process-feasibility/src/main/resources/fhir/ActivityDefinition/highmed-requestFeasibility.xml index 3e038f8a..c033d843 100644 --- a/dsf-bpe-process-feasibility/src/main/resources/fhir/ActivityDefinition/highmed-requestFeasibility.xml +++ b/dsf-bpe-process-feasibility/src/main/resources/fhir/ActivityDefinition/highmed-requestFeasibility.xml @@ -1,116 +1,164 @@ <ActivityDefinition xmlns="http://hl7.org/fhir"> <meta> <tag> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="REMOTE" /> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag" /> + <code value="ALL" /> </tag> </meta> <extension url="http://highmed.org/fhir/StructureDefinition/extension-process-authorization"> <extension url="message-name"> <valueString value="requestFeasibilityMessage" /> </extension> - <extension url="authorization-roles"> - <extension url="authorization-role"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="LOCAL" /> - </valueCoding> - </extension> - </extension> - <extension url="requester-organization-types"> - <extension url="requester-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="MeDIC" /> - </valueCoding> - </extension> + <extension url="task-profile"> + <valueCanonical value="http://highmed.org/fhir/StructureDefinition/task-request-feasibility" /> </extension> - <extension url="recipient-organization-types"> - <extension url="recipient-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="MeDIC" /> - </valueCoding> - </extension> + <extension url="requester"> + <valueCoding> + <extension url="http://highmed.org/fhir/StructureDefinition/extension-process-authorization-consortium-role"> + <extension url="consortium"> + <valueIdentifier> + <system value="http://highmed.org/sid/organization-identifier" /> + <value value="highmed.org" /> + </valueIdentifier> + </extension> + <extension url="role"> + <valueCoding> + <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> + <code value="MeDIC" /> + </valueCoding> + </extension> + </extension> + <system value="http://highmed.org/fhir/CodeSystem/process-authorization" /> + <code value="LOCAL_ROLE" /> + </valueCoding> </extension> - <extension url="task-profile"> - <valueCanonical value="http://highmed.org/fhir/StructureDefinition/highmed-task-request-feasibility" /> + <extension url="recipient"> + <valueCoding> + <extension url="http://highmed.org/fhir/StructureDefinition/extension-process-authorization-consortium-role"> + <extension url="consortium"> + <valueIdentifier> + <system value="http://highmed.org/sid/organization-identifier" /> + <value value="highmed.org" /> + </valueIdentifier> + </extension> + <extension url="role"> + <valueCoding> + <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> + <code value="MeDIC" /> + </valueCoding> + </extension> + </extension> + <system value="http://highmed.org/fhir/CodeSystem/process-authorization" /> + <code value="LOCAL_ROLE" /> + </valueCoding> </extension> </extension> <extension url="http://highmed.org/fhir/StructureDefinition/extension-process-authorization"> <extension url="message-name"> <valueString value="resultMultiMedicFeasibilityMessage" /> </extension> - <extension url="authorization-roles"> - <extension url="authorization-role"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="REMOTE" /> - </valueCoding> - </extension> - </extension> - <extension url="requester-organization-types"> - <extension url="requester-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="TTP" /> - </valueCoding> - </extension> - </extension> - <extension url="recipient-organization-types"> - <extension url="recipient-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="MeDIC" /> - </valueCoding> - </extension> - </extension> <extension url="task-profile"> <valueCanonical value="http://highmed.org/fhir/StructureDefinition/task-multi-medic-result-feasibility" /> </extension> + <extension url="requester"> + <valueCoding> + <extension url="http://highmed.org/fhir/StructureDefinition/extension-process-authorization-consortium-role"> + <extension url="consortium"> + <valueIdentifier> + <system value="http://highmed.org/sid/organization-identifier" /> + <value value="highmed.org" /> + </valueIdentifier> + </extension> + <extension url="role"> + <valueCoding> + <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> + <code value="TTP" /> + </valueCoding> + </extension> + </extension> + <system value="http://highmed.org/fhir/CodeSystem/process-authorization" /> + <code value="REMOTE_ROLE" /> + </valueCoding> + </extension> + <extension url="recipient"> + <valueCoding> + <extension url="http://highmed.org/fhir/StructureDefinition/extension-process-authorization-consortium-role"> + <extension url="consortium"> + <valueIdentifier> + <system value="http://highmed.org/sid/organization-identifier" /> + <value value="highmed.org" /> + </valueIdentifier> + </extension> + <extension url="role"> + <valueCoding> + <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> + <code value="MeDIC" /> + </valueCoding> + </extension> + </extension> + <system value="http://highmed.org/fhir/CodeSystem/process-authorization" /> + <code value="LOCAL_ROLE" /> + </valueCoding> + </extension> </extension> <extension url="http://highmed.org/fhir/StructureDefinition/extension-process-authorization"> <extension url="message-name"> <valueString value="errorMultiMedicFeasibilityMessage" /> </extension> - <extension url="authorization-roles"> - <extension url="authorization-role"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="REMOTE" /> - </valueCoding> - </extension> - </extension> - <extension url="requester-organization-types"> - <extension url="requester-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="TTP" /> - </valueCoding> - </extension> - </extension> - <extension url="recipient-organization-types"> - <extension url="recipient-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="MeDIC" /> - </valueCoding> - </extension> - </extension> <extension url="task-profile"> <valueCanonical value="http://highmed.org/fhir/StructureDefinition/task-multi-medic-error-feasibility" /> </extension> + <extension url="requester"> + <valueCoding> + <extension url="http://highmed.org/fhir/StructureDefinition/extension-process-authorization-consortium-role"> + <extension url="consortium"> + <valueIdentifier> + <system value="http://highmed.org/sid/organization-identifier" /> + <value value="highmed.org" /> + </valueIdentifier> + </extension> + <extension url="role"> + <valueCoding> + <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> + <code value="TTP" /> + </valueCoding> + </extension> + </extension> + <system value="http://highmed.org/fhir/CodeSystem/process-authorization" /> + <code value="REMOTE_ROLE" /> + </valueCoding> + </extension> + <extension url="recipient"> + <valueCoding> + <extension url="http://highmed.org/fhir/StructureDefinition/extension-process-authorization-consortium-role"> + <extension url="consortium"> + <valueIdentifier> + <system value="http://highmed.org/sid/organization-identifier" /> + <value value="highmed.org" /> + </valueIdentifier> + </extension> + <extension url="role"> + <valueCoding> + <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> + <code value="MeDIC" /> + </valueCoding> + </extension> + </extension> + <system value="http://highmed.org/fhir/CodeSystem/process-authorization" /> + <code value="LOCAL_ROLE" /> + </valueCoding> + </extension> </extension> <url value="http://highmed.org/bpe/Process/requestFeasibility" /> <!-- version managed by bpe --> <version value="${version}" /> - <name value="requestFeasibility" /> + <name value="RequestFeasibility" /> <title value="Request feasibility" /> <subtitle value="Feasibility Request Process" /> <!-- status managed by bpe --> <status value="unknown" /> <experimental value="false" /> - <date value="2021-01-26" /> + <date value="2021-06-09" /> <publisher value="HiGHmed" /> <contact> <name value="HiGHmed" /> diff --git a/dsf-bpe-process-feasibility/src/main/resources/fhir/CodeSystem/highmed-feasibility.xml b/dsf-bpe-process-feasibility/src/main/resources/fhir/CodeSystem/highmed-feasibility.xml index dc13d98e..9be78431 100644 --- a/dsf-bpe-process-feasibility/src/main/resources/fhir/CodeSystem/highmed-feasibility.xml +++ b/dsf-bpe-process-feasibility/src/main/resources/fhir/CodeSystem/highmed-feasibility.xml @@ -1,68 +1,68 @@ <CodeSystem xmlns="http://hl7.org/fhir"> <meta> <tag> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role"/> - <code value="REMOTE"/> - </tag> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag" /> + <code value="ALL" /> + </tag> </meta> - <url value="http://highmed.org/fhir/CodeSystem/feasibility"/> + <url value="http://highmed.org/fhir/CodeSystem/feasibility" /> <!-- version managed by bpe --> <version value="${version}" /> - <name value="HiGHmed_Feasibility"/> - <title value="HiGHmed Feasibility"/> + <name value="HiGHmed_Feasibility" /> + <title value="HiGHmed Feasibility" /> <!-- status managed by bpe --> <status value="unknown" /> - <experimental value="false"/> - <date value="2021-01-26"/> - <publisher value="HiGHmed"/> - <description value="CodeSystem with standard values for feasibility processes"/> - <caseSensitive value="true"/> - <hierarchyMeaning value="grouped-by"/> - <versionNeeded value="false"/> - <content value="complete"/> - <concept> - <code value="research-study-reference"/> - <display value="Research Study Reference"/> - <definition value="HiGHmed Research Study Reference to define what data is requested from which MeDICs and for what purpose"/> + <experimental value="false" /> + <date value="2021-01-26" /> + <publisher value="HiGHmed" /> + <description value="CodeSystem with standard values for feasibility processes" /> + <caseSensitive value="true" /> + <hierarchyMeaning value="grouped-by" /> + <versionNeeded value="false" /> + <content value="complete" /> + <concept> + <code value="research-study-reference" /> + <display value="Research Study Reference" /> + <definition value="HiGHmed Research Study Reference to define what data is requested from which MeDICs and for what purpose" /> </concept> <concept> - <code value="needs-record-linkage"/> - <display value="Needs Record Linkage"/> - <definition value="Boolean indicating if a data analysis needs record linkage"/> + <code value="needs-record-linkage" /> + <display value="Needs Record Linkage" /> + <definition value="Boolean indicating if a data analysis needs record linkage" /> </concept> <concept> - <code value="needs-consent-check"/> - <display value="Needs Consent Check"/> - <definition value="Boolean indicating if a data analysis needs consent check"/> + <code value="needs-consent-check" /> + <display value="Needs Consent Check" /> + <definition value="Boolean indicating if a data analysis needs consent check" /> </concept> <concept> - <code value="bloom-filter-configuration"/> - <display value="Bloom Filter Cconfiguration"/> - <definition value="Base64 binary encoded bloom filter configuration"/> + <code value="bloom-filter-configuration" /> + <display value="Bloom Filter Cconfiguration" /> + <definition value="Base64 binary encoded bloom filter configuration" /> </concept> <concept> - <code value="medic-correlation-key"/> - <display value="MeDIC Correlation Key"/> - <definition value="MeDIC Correlation Key transfered to TTP for correlating incoming medic results"/> + <code value="medic-correlation-key" /> + <display value="MeDIC Correlation Key" /> + <definition value="MeDIC Correlation Key transfered to TTP for correlating incoming medic results" /> </concept> <concept> - <code value="single-medic-result"/> - <display value="Single MeDIC Result"/> - <definition value="Result of a single feasibility query execution"/> + <code value="single-medic-result" /> + <display value="Single MeDIC Result" /> + <definition value="Result of a single feasibility query execution" /> </concept> <concept> - <code value="single-medic-result-reference"/> - <display value="Single MeDIC Result Reference"/> - <definition value="Reference to an openEHR ResultSet as a result of a single feasibility query execution"/> + <code value="single-medic-result-reference" /> + <display value="Single MeDIC Result Reference" /> + <definition value="Reference to an openEHR ResultSet as a result of a single feasibility query execution" /> </concept> <concept> - <code value="participating-medics"/> - <display value="Participating MeDICs"/> - <definition value="Count of all MeDICs who participated in a feasibility query"/> + <code value="participating-medics" /> + <display value="Participating MeDICs" /> + <definition value="Count of all MeDICs who participated in a feasibility query" /> </concept> <concept> - <code value="multi-medic-result"/> - <display value="Multi MeDIC Result"/> - <definition value="Aggregated result of all single medic results"/> + <code value="multi-medic-result" /> + <display value="Multi MeDIC Result" /> + <definition value="Aggregated result of all single medic results" /> </concept> </CodeSystem> \ No newline at end of file diff --git a/dsf-bpe-process-feasibility/src/main/resources/fhir/StructureDefinition/highmed-task-compute-feasibility.xml b/dsf-bpe-process-feasibility/src/main/resources/fhir/StructureDefinition/highmed-task-compute-feasibility.xml index 748ad5d0..63005a24 100644 --- a/dsf-bpe-process-feasibility/src/main/resources/fhir/StructureDefinition/highmed-task-compute-feasibility.xml +++ b/dsf-bpe-process-feasibility/src/main/resources/fhir/StructureDefinition/highmed-task-compute-feasibility.xml @@ -1,8 +1,8 @@ <StructureDefinition xmlns="http://hl7.org/fhir"> <meta> <tag> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="REMOTE" /> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag" /> + <code value="ALL" /> </tag> </meta> <url value="http://highmed.org/fhir/StructureDefinition/task-compute-feasibility" /> @@ -12,7 +12,7 @@ <!-- status managed by bpe --> <status value="unknown" /> <experimental value="false" /> - <date value="2021-01-26" /> + <date value="2021-06-09" /> <fhirVersion value="4.0.1" /> <kind value="resource" /> <abstract value="false" /> diff --git a/dsf-bpe-process-feasibility/src/main/resources/fhir/StructureDefinition/highmed-task-error-feasibility.xml b/dsf-bpe-process-feasibility/src/main/resources/fhir/StructureDefinition/highmed-task-error-feasibility.xml index 8a2d65a4..fb1002ff 100644 --- a/dsf-bpe-process-feasibility/src/main/resources/fhir/StructureDefinition/highmed-task-error-feasibility.xml +++ b/dsf-bpe-process-feasibility/src/main/resources/fhir/StructureDefinition/highmed-task-error-feasibility.xml @@ -1,9 +1,8 @@ -<?xml version="1.0" encoding="utf-8"?> <StructureDefinition xmlns="http://hl7.org/fhir"> <meta> <tag> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="REMOTE" /> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag" /> + <code value="ALL" /> </tag> </meta> <url value="http://highmed.org/fhir/StructureDefinition/task-multi-medic-error-feasibility" /> @@ -13,7 +12,7 @@ <!-- status managed by bpe --> <status value="unknown" /> <experimental value="false" /> - <date value="2021-01-26" /> + <date value="2021-06-09" /> <fhirVersion value="4.0.1" /> <kind value="resource" /> <abstract value="false" /> diff --git a/dsf-bpe-process-feasibility/src/main/resources/fhir/StructureDefinition/highmed-task-execute-feasibility.xml b/dsf-bpe-process-feasibility/src/main/resources/fhir/StructureDefinition/highmed-task-execute-feasibility.xml index 613de1d9..2052b375 100644 --- a/dsf-bpe-process-feasibility/src/main/resources/fhir/StructureDefinition/highmed-task-execute-feasibility.xml +++ b/dsf-bpe-process-feasibility/src/main/resources/fhir/StructureDefinition/highmed-task-execute-feasibility.xml @@ -1,8 +1,8 @@ <StructureDefinition xmlns="http://hl7.org/fhir"> <meta> <tag> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="REMOTE" /> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag" /> + <code value="ALL" /> </tag> </meta> <url value="http://highmed.org/fhir/StructureDefinition/task-execute-feasibility" /> @@ -12,7 +12,7 @@ <!-- status managed by bpe --> <status value="unknown" /> <experimental value="false" /> - <date value="2021-01-26" /> + <date value="2021-06-09" /> <fhirVersion value="4.0.1" /> <kind value="resource" /> <abstract value="false" /> diff --git a/dsf-bpe-process-feasibility/src/main/resources/fhir/StructureDefinition/highmed-task-multi-medic-result-feasibility.xml b/dsf-bpe-process-feasibility/src/main/resources/fhir/StructureDefinition/highmed-task-multi-medic-result-feasibility.xml index 26ee63ab..cfbbabb4 100644 --- a/dsf-bpe-process-feasibility/src/main/resources/fhir/StructureDefinition/highmed-task-multi-medic-result-feasibility.xml +++ b/dsf-bpe-process-feasibility/src/main/resources/fhir/StructureDefinition/highmed-task-multi-medic-result-feasibility.xml @@ -1,8 +1,8 @@ <StructureDefinition xmlns="http://hl7.org/fhir"> <meta> <tag> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="REMOTE" /> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag" /> + <code value="ALL" /> </tag> </meta> <url value="http://highmed.org/fhir/StructureDefinition/task-multi-medic-result-feasibility" /> @@ -12,7 +12,7 @@ <!-- status managed by bpe --> <status value="unknown" /> <experimental value="false" /> - <date value="2021-01-26" /> + <date value="2021-06-09" /> <fhirVersion value="4.0.1" /> <kind value="resource" /> <abstract value="false" /> diff --git a/dsf-bpe-process-feasibility/src/main/resources/fhir/StructureDefinition/highmed-task-request-feasibility.xml b/dsf-bpe-process-feasibility/src/main/resources/fhir/StructureDefinition/highmed-task-request-feasibility.xml index 40c7c523..4b17dac7 100644 --- a/dsf-bpe-process-feasibility/src/main/resources/fhir/StructureDefinition/highmed-task-request-feasibility.xml +++ b/dsf-bpe-process-feasibility/src/main/resources/fhir/StructureDefinition/highmed-task-request-feasibility.xml @@ -1,8 +1,8 @@ <StructureDefinition xmlns="http://hl7.org/fhir"> <meta> <tag> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="REMOTE" /> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag" /> + <code value="ALL" /> </tag> </meta> <url value="http://highmed.org/fhir/StructureDefinition/task-request-feasibility" /> @@ -12,7 +12,7 @@ <!-- status managed by bpe --> <status value="unknown" /> <experimental value="false" /> - <date value="2021-01-26" /> + <date value="2021-06-09" /> <fhirVersion value="4.0.1" /> <kind value="resource" /> <abstract value="false" /> diff --git a/dsf-bpe-process-feasibility/src/main/resources/fhir/StructureDefinition/highmed-task-single-medic-result-feasibility.xml b/dsf-bpe-process-feasibility/src/main/resources/fhir/StructureDefinition/highmed-task-single-medic-result-feasibility.xml index e93132dc..46199c9d 100644 --- a/dsf-bpe-process-feasibility/src/main/resources/fhir/StructureDefinition/highmed-task-single-medic-result-feasibility.xml +++ b/dsf-bpe-process-feasibility/src/main/resources/fhir/StructureDefinition/highmed-task-single-medic-result-feasibility.xml @@ -1,8 +1,8 @@ <StructureDefinition xmlns="http://hl7.org/fhir"> <meta> <tag> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="REMOTE" /> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag" /> + <code value="ALL" /> </tag> </meta> <url value="http://highmed.org/fhir/StructureDefinition/task-single-medic-result-feasibility" /> @@ -12,7 +12,7 @@ <!-- status managed by bpe --> <status value="unknown" /> <experimental value="false" /> - <date value="2021-01-26" /> + <date value="2021-06-09" /> <fhirVersion value="4.0.1" /> <kind value="resource" /> <abstract value="false" /> diff --git a/dsf-bpe-process-feasibility/src/main/resources/fhir/ValueSet/highmed-feasibility.xml b/dsf-bpe-process-feasibility/src/main/resources/fhir/ValueSet/highmed-feasibility.xml index 1595f413..4d1d41b3 100644 --- a/dsf-bpe-process-feasibility/src/main/resources/fhir/ValueSet/highmed-feasibility.xml +++ b/dsf-bpe-process-feasibility/src/main/resources/fhir/ValueSet/highmed-feasibility.xml @@ -1,25 +1,25 @@ <ValueSet xmlns="http://hl7.org/fhir"> <meta> <tag> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role"/> - <code value="REMOTE"/> - </tag> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag" /> + <code value="ALL" /> + </tag> </meta> - <url value="http://highmed.org/fhir/ValueSet/feasibility"/> + <url value="http://highmed.org/fhir/ValueSet/feasibility" /> <!-- version managed by bpe --> <version value="${version}" /> - <name value="HiGHmed_Feasibility"/> - <title value="HiGHmed Feasibility"/> + <name value="HiGHmed_Feasibility" /> + <title value="HiGHmed Feasibility" /> <!-- status managed by bpe --> <status value="unknown" /> - <experimental value="false"/> - <date value="2021-01-26"/> - <publisher value="HiGHmed"/> - <description value="ValueSet with standard values for feasibility processes"/> - <immutable value="true"/> + <experimental value="false" /> + <date value="2021-06-09" /> + <publisher value="HiGHmed" /> + <description value="ValueSet with standard values for feasibility processes" /> + <immutable value="true" /> <compose> <include> - <system value="http://highmed.org/fhir/CodeSystem/feasibility"/> + <system value="http://highmed.org/fhir/CodeSystem/feasibility" /> </include> </compose> </ValueSet> \ No newline at end of file diff --git a/dsf-bpe-process-feasibility/src/test/java/org/highmed/dsf/bpe/start/AbstractRequestFeasibilityFromMedicsViaMedic1ExampleStarter.java b/dsf-bpe-process-feasibility/src/test/java/org/highmed/dsf/bpe/start/AbstractRequestFeasibilityFromMedicsViaMedic1ExampleStarter.java new file mode 100644 index 00000000..1cc918ac --- /dev/null +++ b/dsf-bpe-process-feasibility/src/test/java/org/highmed/dsf/bpe/start/AbstractRequestFeasibilityFromMedicsViaMedic1ExampleStarter.java @@ -0,0 +1,165 @@ +package org.highmed.dsf.bpe.start; + +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN; +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME; +import static org.highmed.dsf.bpe.ConstantsBase.CODE_TYPE_AQL_QUERY; +import static org.highmed.dsf.bpe.ConstantsBase.EXTENSION_HIGHMED_PARTICIPATING_MEDIC; +import static org.highmed.dsf.bpe.ConstantsBase.EXTENSION_HIGHMED_PARTICIPATING_TTP; +import static org.highmed.dsf.bpe.ConstantsBase.EXTENSION_HIGHMED_QUERY; +import static org.highmed.dsf.bpe.ConstantsBase.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER; +import static org.highmed.dsf.bpe.ConstantsBase.NAMINGSYSTEM_HIGHMED_RESEARCH_STUDY_IDENTIFIER; +import static org.highmed.dsf.bpe.ConstantsBase.PROFILE_HIGHEMD_RESEARCH_STUDY; +import static org.highmed.dsf.bpe.ConstantsBase.PROFILE_HIGHMED_GROUP; +import static org.highmed.dsf.bpe.ConstantsFeasibility.CODESYSTEM_HIGHMED_FEASIBILITY; +import static org.highmed.dsf.bpe.ConstantsFeasibility.CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_NEEDS_CONSENT_CHECK; +import static org.highmed.dsf.bpe.ConstantsFeasibility.CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_NEEDS_RECORD_LINKAGE; +import static org.highmed.dsf.bpe.ConstantsFeasibility.CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_RESEARCH_STUDY_REFERENCE; +import static org.highmed.dsf.bpe.ConstantsFeasibility.PROFILE_HIGHMED_TASK_REQUEST_FEASIBILITY; +import static org.highmed.dsf.bpe.ConstantsFeasibility.PROFILE_HIGHMED_TASK_REQUEST_FEASIBILITY_MESSAGE_NAME; +import static org.highmed.dsf.bpe.ConstantsFeasibility.PROFILE_HIGHMED_TASK_REQUEST_FEASIBILITY_PROCESS_URI_AND_LATEST_VERSION; +import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1; +import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_2; +import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_3; +import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_TTP; + +import java.util.Arrays; +import java.util.Date; +import java.util.UUID; + +import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper; +import org.highmed.dsf.fhir.authorization.read.ReadAccessHelperImpl; +import org.hl7.fhir.r4.model.BooleanType; +import org.hl7.fhir.r4.model.Bundle; +import org.hl7.fhir.r4.model.Bundle.BundleType; +import org.hl7.fhir.r4.model.Bundle.HTTPVerb; +import org.hl7.fhir.r4.model.Expression; +import org.hl7.fhir.r4.model.Group; +import org.hl7.fhir.r4.model.Group.GroupType; +import org.hl7.fhir.r4.model.IdType; +import org.hl7.fhir.r4.model.Identifier; +import org.hl7.fhir.r4.model.Narrative; +import org.hl7.fhir.r4.model.Reference; +import org.hl7.fhir.r4.model.ResearchStudy; +import org.hl7.fhir.r4.model.ResearchStudy.ResearchStudyStatus; +import org.hl7.fhir.r4.model.ResourceType; +import org.hl7.fhir.r4.model.StringType; +import org.hl7.fhir.r4.model.Task; +import org.hl7.fhir.r4.model.Task.TaskIntent; +import org.hl7.fhir.r4.model.Task.TaskStatus; + +public abstract class AbstractRequestFeasibilityFromMedicsViaMedic1ExampleStarter +{ + private final String[] medicIdentifier = new String[] { NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1, + NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_2, + NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_3 }; + private final String ttpIdentifier = NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_TTP; + + private final ReadAccessHelper readAccessHelper = new ReadAccessHelperImpl(); + + protected void main(String[] args, String baseUrl) throws Exception + { + Bundle bundle = createStartResource(); + ExampleStarter.forServer(args, baseUrl).startWith(bundle); + } + + private Bundle createStartResource() + { + Group group1 = createGroup("Group 1"); + Group group2 = createGroup("Group 2"); + ResearchStudy researchStudy = createResearchStudy(group1, group2); + Task task = createTask(researchStudy); + + Bundle bundle = new Bundle(); + bundle.setType(BundleType.TRANSACTION); + bundle.addEntry().setResource(group1).setFullUrl(group1.getIdElement().getIdPart()).getRequest() + .setMethod(HTTPVerb.POST).setUrl(ResourceType.Group.name()); + bundle.addEntry().setResource(group2).setFullUrl(group2.getIdElement().getIdPart()).getRequest() + .setMethod(HTTPVerb.POST).setUrl(ResourceType.Group.name()); + bundle.addEntry().setResource(researchStudy).setFullUrl(researchStudy.getIdElement().getIdPart()).getRequest() + .setMethod(HTTPVerb.POST).setUrl(ResourceType.ResearchStudy.name()); + bundle.addEntry().setResource(task).setFullUrl(task.getIdElement().getIdPart()).getRequest() + .setMethod(HTTPVerb.POST).setUrl(ResourceType.Task.name()); + + return bundle; + } + + private Group createGroup(String name) + { + Group group = new Group(); + group.setIdElement(new IdType("urn:uuid:" + UUID.randomUUID().toString())); + + group.getMeta().addProfile(PROFILE_HIGHMED_GROUP); + group.getText().getDiv().addText("This is the description"); + group.getText().setStatus(Narrative.NarrativeStatus.ADDITIONAL); + group.setType(GroupType.PERSON); + group.setActual(false); + group.setActive(true); + group.addExtension().setUrl(EXTENSION_HIGHMED_QUERY).setValue( + new Expression().setLanguageElement(CODE_TYPE_AQL_QUERY).setExpression("SELECT COUNT(e) FROM EHR e")); + group.setName(name); + + Arrays.stream(medicIdentifier).forEach(i -> readAccessHelper.addOrganization(group, i)); + readAccessHelper.addOrganization(group, ttpIdentifier); + + return group; + } + + private ResearchStudy createResearchStudy(Group group1, Group group2) + { + ResearchStudy researchStudy = new ResearchStudy(); + researchStudy.setIdElement(new IdType("urn:uuid:" + UUID.randomUUID().toString())); + + researchStudy.getMeta().addProfile(PROFILE_HIGHEMD_RESEARCH_STUDY); + researchStudy.addIdentifier().setSystem(NAMINGSYSTEM_HIGHMED_RESEARCH_STUDY_IDENTIFIER) + .setValue(UUID.randomUUID().toString()); + researchStudy.setStatus(ResearchStudyStatus.ACTIVE); + researchStudy.addEnrollment().setReference(group1.getIdElement().getIdPart()); + researchStudy.addEnrollment().setReference(group2.getIdElement().getIdPart()); + + Arrays.stream(medicIdentifier) + .forEach(i -> researchStudy.addExtension().setUrl(EXTENSION_HIGHMED_PARTICIPATING_MEDIC) + .setValue(new Reference().setType(ResourceType.Organization.name()).setIdentifier( + new Identifier().setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER).setValue(i)))); + + researchStudy.addExtension().setUrl(EXTENSION_HIGHMED_PARTICIPATING_TTP) + .setValue(new Reference().setType(ResourceType.Organization.name()).setIdentifier(new Identifier() + .setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER).setValue(ttpIdentifier))); + + Arrays.stream(medicIdentifier).forEach(i -> readAccessHelper.addOrganization(researchStudy, i)); + readAccessHelper.addOrganization(researchStudy, ttpIdentifier); + + return researchStudy; + } + + private Task createTask(ResearchStudy researchStudy) + { + Task task = new Task(); + task.setIdElement(new IdType("urn:uuid:" + UUID.randomUUID().toString())); + + task.getMeta().addProfile(PROFILE_HIGHMED_TASK_REQUEST_FEASIBILITY); + task.setInstantiatesUri(PROFILE_HIGHMED_TASK_REQUEST_FEASIBILITY_PROCESS_URI_AND_LATEST_VERSION); + task.setStatus(TaskStatus.REQUESTED); + task.setIntent(TaskIntent.ORDER); + task.setAuthoredOn(new Date()); + task.getRequester().setType(ResourceType.Organization.name()).getIdentifier() + .setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER) + .setValue(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1); + task.getRestriction().addRecipient().setType(ResourceType.Organization.name()).getIdentifier() + .setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER) + .setValue(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1); + + task.addInput().setValue(new StringType(PROFILE_HIGHMED_TASK_REQUEST_FEASIBILITY_MESSAGE_NAME)).getType() + .addCoding().setSystem(CODESYSTEM_HIGHMED_BPMN).setCode(CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME); + task.addInput() + .setValue(new Reference().setReference(researchStudy.getIdElement().getIdPart()) + .setType(ResourceType.ResearchStudy.name())) + .getType().addCoding().setSystem(CODESYSTEM_HIGHMED_FEASIBILITY) + .setCode(CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_RESEARCH_STUDY_REFERENCE); + task.addInput().setValue(new BooleanType(true)).getType().addCoding().setSystem(CODESYSTEM_HIGHMED_FEASIBILITY) + .setCode(CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_NEEDS_RECORD_LINKAGE); + task.addInput().setValue(new BooleanType(true)).getType().addCoding().setSystem(CODESYSTEM_HIGHMED_FEASIBILITY) + .setCode(CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_NEEDS_CONSENT_CHECK); + + return task; + } +} diff --git a/dsf-bpe-process-feasibility/src/test/java/org/highmed/dsf/bpe/start/RequestFeasibilityFromMedicsViaMedic1DockerExampleStarter.java b/dsf-bpe-process-feasibility/src/test/java/org/highmed/dsf/bpe/start/RequestFeasibilityFromMedicsViaMedic1DockerExampleStarter.java new file mode 100644 index 00000000..5010341f --- /dev/null +++ b/dsf-bpe-process-feasibility/src/test/java/org/highmed/dsf/bpe/start/RequestFeasibilityFromMedicsViaMedic1DockerExampleStarter.java @@ -0,0 +1,16 @@ +package org.highmed.dsf.bpe.start; + +import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.MEDIC_1_DOCKER_FHIR_BASE_URL; + +public class RequestFeasibilityFromMedicsViaMedic1DockerExampleStarter + extends AbstractRequestFeasibilityFromMedicsViaMedic1ExampleStarter +{ + // Environment variable "DSF_CLIENT_CERTIFICATE_PATH" or args[0]: the path to the client-certificate + // highmed-dsf/dsf-tools/dsf-tools-test-data-generator/cert/Webbrowser_Test_User/Webbrowser_Test_User_certificate.p12 + // Environment variable "DSF_CLIENT_CERTIFICATE_PASSWORD" or args[1]: the password of the client-certificate + // password + public static void main(String[] args) throws Exception + { + new RequestFeasibilityFromMedicsViaMedic1DockerExampleStarter().main(args, MEDIC_1_DOCKER_FHIR_BASE_URL); + } +} diff --git a/dsf-bpe-process-feasibility/src/test/java/org/highmed/dsf/bpe/start/RequestFeasibilityFromMedicsViaMedic1ExampleStarter.java b/dsf-bpe-process-feasibility/src/test/java/org/highmed/dsf/bpe/start/RequestFeasibilityFromMedicsViaMedic1ExampleStarter.java index c50c2e56..4cb5ab05 100644 --- a/dsf-bpe-process-feasibility/src/test/java/org/highmed/dsf/bpe/start/RequestFeasibilityFromMedicsViaMedic1ExampleStarter.java +++ b/dsf-bpe-process-feasibility/src/test/java/org/highmed/dsf/bpe/start/RequestFeasibilityFromMedicsViaMedic1ExampleStarter.java @@ -1,51 +1,9 @@ package org.highmed.dsf.bpe.start; -import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN; -import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME; -import static org.highmed.dsf.bpe.ConstantsBase.CODE_TYPE_AQL_QUERY; -import static org.highmed.dsf.bpe.ConstantsBase.EXTENSION_HIGHMED_PARTICIPATING_MEDIC; -import static org.highmed.dsf.bpe.ConstantsBase.EXTENSION_HIGHMED_PARTICIPATING_TTP; -import static org.highmed.dsf.bpe.ConstantsBase.EXTENSION_HIGHMED_QUERY; -import static org.highmed.dsf.bpe.ConstantsBase.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER; -import static org.highmed.dsf.bpe.ConstantsBase.NAMINGSYSTEM_HIGHMED_RESEARCH_STUDY_IDENTIFIER; -import static org.highmed.dsf.bpe.ConstantsBase.PROFILE_HIGHEMD_RESEARCH_STUDY; -import static org.highmed.dsf.bpe.ConstantsBase.PROFILE_HIGHMED_GROUP; -import static org.highmed.dsf.bpe.ConstantsFeasibility.CODESYSTEM_HIGHMED_FEASIBILITY; -import static org.highmed.dsf.bpe.ConstantsFeasibility.CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_NEEDS_CONSENT_CHECK; -import static org.highmed.dsf.bpe.ConstantsFeasibility.CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_NEEDS_RECORD_LINKAGE; -import static org.highmed.dsf.bpe.ConstantsFeasibility.CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_RESEARCH_STUDY_REFERENCE; -import static org.highmed.dsf.bpe.ConstantsFeasibility.PROFILE_HIGHMED_TASK_REQUEST_FEASIBILITY; -import static org.highmed.dsf.bpe.ConstantsFeasibility.PROFILE_HIGHMED_TASK_REQUEST_FEASIBILITY_MESSAGE_NAME; -import static org.highmed.dsf.bpe.ConstantsFeasibility.PROFILE_HIGHMED_TASK_REQUEST_FEASIBILITY_PROCESS_URI_AND_LATEST_VERSION; import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.MEDIC_1_FHIR_BASE_URL; -import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1; -import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_2; -import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_3; -import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_TTP; - -import java.util.Date; -import java.util.UUID; - -import org.hl7.fhir.r4.model.BooleanType; -import org.hl7.fhir.r4.model.Bundle; -import org.hl7.fhir.r4.model.Bundle.BundleType; -import org.hl7.fhir.r4.model.Bundle.HTTPVerb; -import org.hl7.fhir.r4.model.Expression; -import org.hl7.fhir.r4.model.Group; -import org.hl7.fhir.r4.model.Group.GroupType; -import org.hl7.fhir.r4.model.IdType; -import org.hl7.fhir.r4.model.Identifier; -import org.hl7.fhir.r4.model.Narrative; -import org.hl7.fhir.r4.model.Reference; -import org.hl7.fhir.r4.model.ResearchStudy; -import org.hl7.fhir.r4.model.ResearchStudy.ResearchStudyStatus; -import org.hl7.fhir.r4.model.ResourceType; -import org.hl7.fhir.r4.model.StringType; -import org.hl7.fhir.r4.model.Task; -import org.hl7.fhir.r4.model.Task.TaskIntent; -import org.hl7.fhir.r4.model.Task.TaskStatus; public class RequestFeasibilityFromMedicsViaMedic1ExampleStarter + extends AbstractRequestFeasibilityFromMedicsViaMedic1ExampleStarter { // Environment variable "DSF_CLIENT_CERTIFICATE_PATH" or args[0]: the path to the client-certificate // highmed-dsf/dsf-tools/dsf-tools-test-data-generator/cert/Webbrowser_Test_User/Webbrowser_Test_User_certificate.p12 @@ -53,110 +11,6 @@ public class RequestFeasibilityFromMedicsViaMedic1ExampleStarter // password public static void main(String[] args) throws Exception { - Bundle bundle = createStartResource(); - ExampleStarter.forServer(args, MEDIC_1_FHIR_BASE_URL).startWith(bundle); - } - - private static Bundle createStartResource() - { - Group group1 = createGroup("Group 1"); - Group group2 = createGroup("Group 2"); - ResearchStudy researchStudy = createResearchStudy(group1, group2); - Task task = createTask(researchStudy); - - Bundle bundle = new Bundle(); - bundle.setType(BundleType.TRANSACTION); - bundle.addEntry().setResource(group1).setFullUrl(group1.getIdElement().getIdPart()).getRequest() - .setMethod(HTTPVerb.POST).setUrl(ResourceType.Group.name()); - bundle.addEntry().setResource(group2).setFullUrl(group2.getIdElement().getIdPart()).getRequest() - .setMethod(HTTPVerb.POST).setUrl(ResourceType.Group.name()); - bundle.addEntry().setResource(researchStudy).setFullUrl(researchStudy.getIdElement().getIdPart()).getRequest() - .setMethod(HTTPVerb.POST).setUrl(ResourceType.ResearchStudy.name()); - bundle.addEntry().setResource(task).setFullUrl(task.getIdElement().getIdPart()).getRequest() - .setMethod(HTTPVerb.POST).setUrl(ResourceType.Task.name()); - - return bundle; - } - - private static Group createGroup(String name) - { - Group group = new Group(); - group.setIdElement(new IdType("urn:uuid:" + UUID.randomUUID().toString())); - - group.getMeta().addProfile(PROFILE_HIGHMED_GROUP); - group.getText().getDiv().addText("This is the description"); - group.getText().setStatus(Narrative.NarrativeStatus.ADDITIONAL); - group.setType(GroupType.PERSON); - group.setActual(false); - group.setActive(true); - group.addExtension().setUrl(EXTENSION_HIGHMED_QUERY).setValue( - new Expression().setLanguageElement(CODE_TYPE_AQL_QUERY).setExpression("SELECT COUNT(e) FROM EHR e")); - group.setName(name); - - return group; - } - - private static ResearchStudy createResearchStudy(Group group1, Group group2) - { - ResearchStudy researchStudy = new ResearchStudy(); - researchStudy.setIdElement(new IdType("urn:uuid:" + UUID.randomUUID().toString())); - - researchStudy.getMeta().addProfile(PROFILE_HIGHEMD_RESEARCH_STUDY); - researchStudy.addIdentifier().setSystem(NAMINGSYSTEM_HIGHMED_RESEARCH_STUDY_IDENTIFIER) - .setValue(UUID.randomUUID().toString()); - researchStudy.setStatus(ResearchStudyStatus.ACTIVE); - researchStudy.addEnrollment().setReference(group1.getIdElement().getIdPart()); - researchStudy.addEnrollment().setReference(group2.getIdElement().getIdPart()); - - researchStudy.addExtension().setUrl(EXTENSION_HIGHMED_PARTICIPATING_MEDIC) - .setValue(new Reference().setType(ResourceType.Organization.name()) - .setIdentifier(new Identifier().setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER) - .setValue(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1))); - researchStudy.addExtension().setUrl(EXTENSION_HIGHMED_PARTICIPATING_MEDIC) - .setValue(new Reference().setType(ResourceType.Organization.name()) - .setIdentifier(new Identifier().setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER) - .setValue(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_2))); - researchStudy.addExtension().setUrl(EXTENSION_HIGHMED_PARTICIPATING_MEDIC) - .setValue(new Reference().setType(ResourceType.Organization.name()) - .setIdentifier(new Identifier().setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER) - .setValue(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_3))); - researchStudy.addExtension().setUrl(EXTENSION_HIGHMED_PARTICIPATING_TTP) - .setValue(new Reference().setType(ResourceType.Organization.name()) - .setIdentifier(new Identifier().setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER) - .setValue(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_TTP))); - - return researchStudy; - } - - private static Task createTask(ResearchStudy researchStudy) - { - Task task = new Task(); - task.setIdElement(new IdType("urn:uuid:" + UUID.randomUUID().toString())); - - task.getMeta().addProfile(PROFILE_HIGHMED_TASK_REQUEST_FEASIBILITY); - task.setInstantiatesUri(PROFILE_HIGHMED_TASK_REQUEST_FEASIBILITY_PROCESS_URI_AND_LATEST_VERSION); - task.setStatus(TaskStatus.REQUESTED); - task.setIntent(TaskIntent.ORDER); - task.setAuthoredOn(new Date()); - task.getRequester().setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER) - .setValue(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1); - task.getRestriction().addRecipient().setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER) - .setValue(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1); - - task.addInput().setValue(new StringType(PROFILE_HIGHMED_TASK_REQUEST_FEASIBILITY_MESSAGE_NAME)).getType() - .addCoding().setSystem(CODESYSTEM_HIGHMED_BPMN).setCode(CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME); - task.addInput() - .setValue(new Reference().setReference(researchStudy.getIdElement().getIdPart()) - .setType(ResourceType.ResearchStudy.name())) - .getType().addCoding().setSystem(CODESYSTEM_HIGHMED_FEASIBILITY) - .setCode(CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_RESEARCH_STUDY_REFERENCE); - task.addInput().setValue(new BooleanType(true)).getType().addCoding().setSystem(CODESYSTEM_HIGHMED_FEASIBILITY) - .setCode(CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_NEEDS_RECORD_LINKAGE); - task.addInput().setValue(new BooleanType(true)).getType().addCoding().setSystem(CODESYSTEM_HIGHMED_FEASIBILITY) - .setCode(CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_NEEDS_CONSENT_CHECK); - - return task; + new RequestFeasibilityFromMedicsViaMedic1ExampleStarter().main(args, MEDIC_1_FHIR_BASE_URL); } } diff --git a/dsf-bpe-process-feasibility/src/test/java/org/highmed/dsf/fhir/profile/ActivityDefinitionProfileTest.java b/dsf-bpe-process-feasibility/src/test/java/org/highmed/dsf/fhir/profile/ActivityDefinitionProfileTest.java new file mode 100644 index 00000000..e12cd5bc --- /dev/null +++ b/dsf-bpe-process-feasibility/src/test/java/org/highmed/dsf/fhir/profile/ActivityDefinitionProfileTest.java @@ -0,0 +1,116 @@ +package org.highmed.dsf.fhir.profile; + +import static org.highmed.dsf.bpe.FeasibilityProcessPluginDefinition.VERSION; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; + +import org.highmed.dsf.fhir.authorization.process.ProcessAuthorizationHelper; +import org.highmed.dsf.fhir.authorization.process.ProcessAuthorizationHelperImpl; +import org.highmed.dsf.fhir.validation.ResourceValidator; +import org.highmed.dsf.fhir.validation.ResourceValidatorImpl; +import org.highmed.dsf.fhir.validation.ValidationSupportRule; +import org.hl7.fhir.r4.model.ActivityDefinition; +import org.junit.ClassRule; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import ca.uhn.fhir.validation.ResultSeverityEnum; +import ca.uhn.fhir.validation.ValidationResult; + +public class ActivityDefinitionProfileTest +{ + private static final Logger logger = LoggerFactory.getLogger(ActivityDefinitionProfileTest.class); + + @ClassRule + public static final ValidationSupportRule validationRule = new ValidationSupportRule(VERSION, + Arrays.asList("highmed-activity-definition-0.5.0.xml", "highmed-extension-process-authorization-0.5.0.xml", + "highmed-extension-process-authorization-consortium-role-0.5.0.xml", + "highmed-extension-process-authorization-organization-0.5.0.xml", + "highmed-coding-process-authorization-local-all-0.5.0.xml", + "highmed-coding-process-authorization-local-consortium-role-0.5.0.xml", + "highmed-coding-process-authorization-local-organization-0.5.0.xml", + "highmed-coding-process-authorization-remote-all-0.5.0.xml", + "highmed-coding-process-authorization-remote-consortium-role-0.5.0.xml", + "highmed-coding-process-authorization-remote-organization-0.5.0.xml"), + Arrays.asList("highmed-read-access-tag-0.5.0.xml", "highmed-process-authorization-0.5.0.xml"), + Arrays.asList("highmed-read-access-tag-0.5.0.xml", "highmed-process-authorization-recipient-0.5.0.xml", + "highmed-process-authorization-requester-0.5.0.xml")); + + private final ResourceValidator resourceValidator = new ResourceValidatorImpl(validationRule.getFhirContext(), + validationRule.getValidationSupport()); + + private final ProcessAuthorizationHelper processAuthorizationHelper = new ProcessAuthorizationHelperImpl(); + + @Test + public void testComputeFeasibilityValid() throws Exception + { + try (InputStream in = Files + .newInputStream(Paths.get("src/main/resources/fhir/ActivityDefinition/highmed-computeFeasibility.xml"))) + { + ActivityDefinition ad = validationRule.getFhirContext().newXmlParser() + .parseResource(ActivityDefinition.class, in); + + ValidationResult result = resourceValidator.validate(ad); + ValidationSupportRule.logValidationMessages(logger, result); + + assertEquals(0, result.getMessages().stream().filter(m -> ResultSeverityEnum.ERROR.equals(m.getSeverity()) + || ResultSeverityEnum.FATAL.equals(m.getSeverity())).count()); + + assertTrue(processAuthorizationHelper.isValid(ad, taskProfile -> true, orgIdentifier -> + { + System.err.println("Org: " + orgIdentifier); + return true; + }, role -> + { + System.err.println("Role:" + role); + return true; + })); + } + } + + @Test + public void testExecuteFeasibilityValid() throws Exception + { + try (InputStream in = Files + .newInputStream(Paths.get("src/main/resources/fhir/ActivityDefinition/highmed-executeFeasibility.xml"))) + { + ActivityDefinition ad = validationRule.getFhirContext().newXmlParser() + .parseResource(ActivityDefinition.class, in); + + ValidationResult result = resourceValidator.validate(ad); + ValidationSupportRule.logValidationMessages(logger, result); + + assertEquals(0, result.getMessages().stream().filter(m -> ResultSeverityEnum.ERROR.equals(m.getSeverity()) + || ResultSeverityEnum.FATAL.equals(m.getSeverity())).count()); + + assertTrue( + processAuthorizationHelper.isValid(ad, taskProfile -> true, orgIdentifier -> true, role -> true)); + } + } + + @Test + public void testRequestFeasibilityValid() throws Exception + { + try (InputStream in = Files + .newInputStream(Paths.get("src/main/resources/fhir/ActivityDefinition/highmed-requestFeasibility.xml"))) + { + ActivityDefinition ad = validationRule.getFhirContext().newXmlParser() + .parseResource(ActivityDefinition.class, in); + + ValidationResult result = resourceValidator.validate(ad); + ValidationSupportRule.logValidationMessages(logger, result); + + assertEquals(0, result.getMessages().stream().filter(m -> ResultSeverityEnum.ERROR.equals(m.getSeverity()) + || ResultSeverityEnum.FATAL.equals(m.getSeverity())).count()); + + assertTrue( + processAuthorizationHelper.isValid(ad, taskProfile -> true, orgIdentifier -> true, role -> true)); + } + } +} \ No newline at end of file diff --git a/dsf-bpe-process-feasibility/src/test/java/org/highmed/dsf/fhir/profile/TaskProfileTest.java b/dsf-bpe-process-feasibility/src/test/java/org/highmed/dsf/fhir/profile/TaskProfileTest.java index 67935edc..b3cea862 100644 --- a/dsf-bpe-process-feasibility/src/test/java/org/highmed/dsf/fhir/profile/TaskProfileTest.java +++ b/dsf-bpe-process-feasibility/src/test/java/org/highmed/dsf/fhir/profile/TaskProfileTest.java @@ -73,9 +73,9 @@ public class TaskProfileTest "highmed-task-request-feasibility.xml", "highmed-task-execute-feasibility.xml", "highmed-task-single-medic-result-feasibility.xml", "highmed-task-compute-feasibility.xml", "highmed-task-multi-medic-result-feasibility.xml", "highmed-task-error-feasibility.xml"), - Arrays.asList("highmed-authorization-role-0.5.0.xml", "highmed-bpmn-message-0.5.0.xml", + Arrays.asList("highmed-read-access-tag-0.5.0.xml", "highmed-bpmn-message-0.5.0.xml", "highmed-feasibility.xml"), - Arrays.asList("highmed-authorization-role-0.5.0.xml", "highmed-bpmn-message-0.5.0.xml", + Arrays.asList("highmed-read-access-tag-0.5.0.xml", "highmed-bpmn-message-0.5.0.xml", "highmed-feasibility.xml")); private ResourceValidator resourceValidator = new ResourceValidatorImpl(validationRule.getFhirContext(), diff --git a/dsf-bpe-process-local-services/pom.xml b/dsf-bpe-process-local-services/pom.xml index 517bc74f..2ac21bd4 100644 --- a/dsf-bpe-process-local-services/pom.xml +++ b/dsf-bpe-process-local-services/pom.xml @@ -70,7 +70,7 @@ <version>${project.version}</version> </artifactItem> </artifactItems> - <outputDirectory>${dsf.location}/dsf-docker-test-setup/bpe/app/process</outputDirectory> + <outputDirectory>${dsf.location}/dsf-docker-test-setup/bpe/process</outputDirectory> </configuration> </execution> <execution> @@ -87,7 +87,7 @@ <version>${project.version}</version> </artifactItem> </artifactItems> - <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic1/bpe/app/process</outputDirectory> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic1/bpe/process</outputDirectory> </configuration> </execution> <execution> @@ -104,7 +104,7 @@ <version>${project.version}</version> </artifactItem> </artifactItems> - <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic2/bpe/app/process</outputDirectory> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic2/bpe/process</outputDirectory> </configuration> </execution> <execution> @@ -121,7 +121,7 @@ <version>${project.version}</version> </artifactItem> </artifactItems> - <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic3/bpe/app/process</outputDirectory> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic3/bpe/process</outputDirectory> </configuration> </execution> <execution> @@ -138,7 +138,79 @@ <version>${project.version}</version> </artifactItem> </artifactItems> - <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/ttp/bpe/app/process</outputDirectory> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/ttp/bpe/process</outputDirectory> + </configuration> + </execution> + <execution> + <id>copy-process-to-docker-test-setup-3medic-ttp-docker/medic1</id> + <phase>package</phase> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>${project.groupId}</groupId> + <artifactId>${project.artifactId}</artifactId> + <version>${project.version}</version> + </artifactItem> + </artifactItems> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/medic1/bpe/process + </outputDirectory> + </configuration> + </execution> + <execution> + <id>copy-process-to-docker-test-setup-3medic-ttp-docker/medic2</id> + <phase>package</phase> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>${project.groupId}</groupId> + <artifactId>${project.artifactId}</artifactId> + <version>${project.version}</version> + </artifactItem> + </artifactItems> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/medic2/bpe/process + </outputDirectory> + </configuration> + </execution> + <execution> + <id>copy-process-to-docker-test-setup-3medic-ttp-docker/medic3</id> + <phase>package</phase> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>${project.groupId}</groupId> + <artifactId>${project.artifactId}</artifactId> + <version>${project.version}</version> + </artifactItem> + </artifactItems> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/medic3/bpe/process + </outputDirectory> + </configuration> + </execution> + <execution> + <id>copy-process-to-docker-test-setup-3medic-ttp-docker/ttp</id> + <phase>package</phase> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>${project.groupId}</groupId> + <artifactId>${project.artifactId}</artifactId> + <version>${project.version}</version> + </artifactItem> + </artifactItems> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/ttp/bpe/process + </outputDirectory> </configuration> </execution> </executions> @@ -149,35 +221,63 @@ <configuration> <filesets> <fileset> - <directory>${dsf.location}/dsf-docker-test-setup/bpe/app/process</directory> + <directory>${dsf.location}/dsf-docker-test-setup/bpe/process</directory> + <includes> + <include>${project.artifactId}-${project.version}.jar</include> + </includes> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic1/bpe/process</directory> + <includes> + <include>${project.artifactId}-${project.version}.jar</include> + </includes> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic2/bpe/process</directory> + <includes> + <include>${project.artifactId}-${project.version}.jar</include> + </includes> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic3/bpe/process</directory> + <includes> + <include>${project.artifactId}-${project.version}.jar</include> + </includes> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/ttp/bpe/process</directory> <includes> <include>${project.artifactId}-${project.version}.jar</include> </includes> <followSymlinks>false</followSymlinks> </fileset> <fileset> - <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic1/bpe/app/process</directory> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/medic1/bpe/process</directory> <includes> <include>${project.artifactId}-${project.version}.jar</include> </includes> <followSymlinks>false</followSymlinks> </fileset> <fileset> - <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic2/bpe/app/process</directory> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/medic2/bpe/process</directory> <includes> <include>${project.artifactId}-${project.version}.jar</include> </includes> <followSymlinks>false</followSymlinks> </fileset> <fileset> - <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic3/bpe/app/process</directory> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/medic3/bpe/process</directory> <includes> <include>${project.artifactId}-${project.version}.jar</include> </includes> <followSymlinks>false</followSymlinks> </fileset> <fileset> - <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/ttp/bpe/app/process</directory> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/ttp/bpe/process</directory> <includes> <include>${project.artifactId}-${project.version}.jar</include> </includes> diff --git a/dsf-bpe-process-local-services/src/main/java/org/highmed/dsf/bpe/LocalServicesProcessPluginDefinition.java b/dsf-bpe-process-local-services/src/main/java/org/highmed/dsf/bpe/LocalServicesProcessPluginDefinition.java index f7ad8ac3..c9e431f4 100644 --- a/dsf-bpe-process-local-services/src/main/java/org/highmed/dsf/bpe/LocalServicesProcessPluginDefinition.java +++ b/dsf-bpe-process-local-services/src/main/java/org/highmed/dsf/bpe/LocalServicesProcessPluginDefinition.java @@ -13,6 +13,7 @@ import org.highmed.dsf.fhir.resources.ResourceProvider; import org.highmed.dsf.fhir.resources.StructureDefinitionResource; import org.highmed.dsf.fhir.resources.ValueSetResource; +import org.springframework.core.env.PropertyResolver; import ca.uhn.fhir.context.FhirContext; @@ -54,7 +55,8 @@ public List<String> getDependencyNamesAndVersions() } @Override - public ResourceProvider getResourceProvider(FhirContext fhirContext, ClassLoader classLoader) + public ResourceProvider getResourceProvider(FhirContext fhirContext, ClassLoader classLoader, + PropertyResolver resolver) { var aL = ActivityDefinitionResource.file("fhir/ActivityDefinition/highmed-localServicesIntegration.xml"); var sTL = StructureDefinitionResource @@ -66,9 +68,9 @@ public ResourceProvider getResourceProvider(FhirContext fhirContext, ClassLoader "http://highmed.org/fhir/CodeSystem/feasibility", DEPENDENCY_FEASIBILITY_VERSION); Map<String, List<AbstractResource>> resourcesByProcessKeyAndVersion = Map - .of("localServicesIntegration/" + VERSION, Arrays.asList(aL, sTL, vF, cF)); + .of("highmedorg_localServicesIntegration/" + VERSION, Arrays.asList(aL, sTL, vF, cF)); return ResourceProvider.read(VERSION, () -> fhirContext.newXmlParser().setStripVersionsFromReferences(false), - classLoader, resourcesByProcessKeyAndVersion); + classLoader, resolver, resourcesByProcessKeyAndVersion); } } diff --git a/dsf-bpe-process-local-services/src/main/java/org/highmed/dsf/bpe/service/ExtractInputValues.java b/dsf-bpe-process-local-services/src/main/java/org/highmed/dsf/bpe/service/ExtractInputValues.java index ab944ce2..e80f59cb 100644 --- a/dsf-bpe-process-local-services/src/main/java/org/highmed/dsf/bpe/service/ExtractInputValues.java +++ b/dsf-bpe-process-local-services/src/main/java/org/highmed/dsf/bpe/service/ExtractInputValues.java @@ -8,7 +8,6 @@ import static org.highmed.dsf.bpe.ConstantsFeasibility.BPMN_EXECUTION_VARIABLE_NEEDS_CONSENT_CHECK; import java.util.List; -import java.util.UUID; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -17,20 +16,22 @@ import org.highmed.dsf.bpe.delegate.AbstractServiceDelegate; import org.highmed.dsf.bpe.variables.BloomFilterConfig; import org.highmed.dsf.bpe.variables.BloomFilterConfigValues; +import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper; import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider; import org.highmed.dsf.fhir.task.TaskHelper; import org.highmed.dsf.fhir.variables.FhirResourcesListValues; import org.hl7.fhir.r4.model.Expression; import org.hl7.fhir.r4.model.Group; -import org.hl7.fhir.r4.model.IdType; +import org.hl7.fhir.r4.model.Group.GroupType; import org.hl7.fhir.r4.model.Task; import org.springframework.beans.factory.InitializingBean; public class ExtractInputValues extends AbstractServiceDelegate implements InitializingBean { - public ExtractInputValues(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper) + public ExtractInputValues(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, + ReadAccessHelper readAccessHelper) { - super(clientProvider, taskHelper); + super(clientProvider, taskHelper, readAccessHelper); } @Override @@ -67,10 +68,13 @@ private List<Group> getCohortDefinitions(Stream<String> queries) return queries.map(q -> { Group group = new Group(); - group.setIdElement(new IdType(UUID.randomUUID().toString())); + group.setType(GroupType.PERSON); + group.setActual(false); group.addExtension().setUrl(EXTENSION_HIGHMED_QUERY) .setValue(new Expression().setLanguageElement(CODE_TYPE_AQL_QUERY).setExpression(q)); - return group; + getReadAccessHelper().addLocal(group); + + return getFhirWebserviceClientProvider().getLocalWebserviceClient().create(group); }).collect(Collectors.toList()); } diff --git a/dsf-bpe-process-local-services/src/main/java/org/highmed/dsf/bpe/service/StoreResult.java b/dsf-bpe-process-local-services/src/main/java/org/highmed/dsf/bpe/service/StoreResult.java index 24f49b2d..0d1b19dd 100644 --- a/dsf-bpe-process-local-services/src/main/java/org/highmed/dsf/bpe/service/StoreResult.java +++ b/dsf-bpe-process-local-services/src/main/java/org/highmed/dsf/bpe/service/StoreResult.java @@ -7,6 +7,7 @@ import org.highmed.dsf.bpe.delegate.AbstractServiceDelegate; import org.highmed.dsf.bpe.variables.FeasibilityQueryResult; import org.highmed.dsf.bpe.variables.FeasibilityQueryResults; +import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper; import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider; import org.highmed.dsf.fhir.task.TaskHelper; import org.hl7.fhir.r4.model.Extension; @@ -20,9 +21,10 @@ public class StoreResult extends AbstractServiceDelegate implements Initializing { private static final Logger logger = LoggerFactory.getLogger(StoreResult.class); - public StoreResult(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper) + public StoreResult(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, + ReadAccessHelper readAccessHelper) { - super(clientProvider, taskHelper); + super(clientProvider, taskHelper, readAccessHelper); } @Override diff --git a/dsf-bpe-process-local-services/src/main/java/org/highmed/dsf/bpe/spring/config/LocalServicesConfig.java b/dsf-bpe-process-local-services/src/main/java/org/highmed/dsf/bpe/spring/config/LocalServicesConfig.java index 1cee133b..12681ab6 100644 --- a/dsf-bpe-process-local-services/src/main/java/org/highmed/dsf/bpe/spring/config/LocalServicesConfig.java +++ b/dsf-bpe-process-local-services/src/main/java/org/highmed/dsf/bpe/spring/config/LocalServicesConfig.java @@ -10,6 +10,7 @@ import org.highmed.dsf.bpe.service.GenerateCountFromIds; import org.highmed.dsf.bpe.service.ModifyQueries; import org.highmed.dsf.bpe.service.StoreResult; +import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper; import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider; import org.highmed.dsf.fhir.group.GroupHelper; import org.highmed.dsf.fhir.organization.OrganizationProvider; @@ -44,6 +45,9 @@ public class LocalServicesConfig @Autowired private TaskHelper taskHelper; + @Autowired + private ReadAccessHelper readAccessHelper; + @Autowired private GroupHelper groupHelper; @@ -59,38 +63,38 @@ public class LocalServicesConfig @Bean public ExtractInputValues extractInputValues() { - return new ExtractInputValues(fhirClientProvider, taskHelper); + return new ExtractInputValues(fhirClientProvider, taskHelper, readAccessHelper); } @Bean public StoreResult storeResult() { - return new StoreResult(fhirClientProvider, taskHelper); + return new StoreResult(fhirClientProvider, taskHelper, readAccessHelper); } @Bean public CheckSingleMedicResults checkSingleMedicResults() { - return new CheckSingleMedicResults(fhirClientProvider, taskHelper); + return new CheckSingleMedicResults(fhirClientProvider, taskHelper, readAccessHelper); } @Bean public ModifyQueries modifyQueries() { - return new ModifyQueries(fhirClientProvider, taskHelper, ehrIdColumnPath); + return new ModifyQueries(fhirClientProvider, taskHelper, readAccessHelper, ehrIdColumnPath); } @Bean public FilterQueryResultsByConsent filterQueryResultsByConsent() { - return new FilterQueryResultsByConsent(fhirClientProvider, taskHelper); + return new FilterQueryResultsByConsent(fhirClientProvider, taskHelper, readAccessHelper); } @Bean public GenerateBloomFilters generateBloomFilters() { - return new GenerateBloomFilters(fhirClientProvider, taskHelper, ehrIdColumnPath, masterPatientIndexClient(), - objectMapper, bouncyCastleProvider()); + return new GenerateBloomFilters(fhirClientProvider, taskHelper, readAccessHelper, ehrIdColumnPath, + masterPatientIndexClient(), objectMapper, bouncyCastleProvider()); } @Bean @@ -108,13 +112,14 @@ public BouncyCastleProvider bouncyCastleProvider() @Bean public GenerateCountFromIds generateCountFromIds() { - return new GenerateCountFromIds(fhirClientProvider, taskHelper); + return new GenerateCountFromIds(fhirClientProvider, taskHelper, readAccessHelper); } @Bean public ExecuteQueries executeQueries() { - return new ExecuteQueries(fhirClientProvider, openEhrClient(), taskHelper, organizationProvider); + return new ExecuteQueries(fhirClientProvider, openEhrClient(), taskHelper, readAccessHelper, + organizationProvider); } @Bean @@ -126,6 +131,6 @@ public OpenEhrClient openEhrClient() @Bean public CheckQueries checkQueries() { - return new CheckQueries(fhirClientProvider, taskHelper, groupHelper); + return new CheckQueries(fhirClientProvider, taskHelper, readAccessHelper, groupHelper); } } diff --git a/dsf-bpe-process-local-services/src/main/resources/bpe/localServicesIntegration.bpmn b/dsf-bpe-process-local-services/src/main/resources/bpe/localServicesIntegration.bpmn index 64d97c45..42da7ac9 100644 --- a/dsf-bpe-process-local-services/src/main/resources/bpe/localServicesIntegration.bpmn +++ b/dsf-bpe-process-local-services/src/main/resources/bpe/localServicesIntegration.bpmn @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_0drkcb5" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.7.1"> - <bpmn:process id="localServicesIntegration" isExecutable="true" camunda:versionTag="0.5.0"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_0drkcb5" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.8.1"> + <bpmn:process id="highmedorg_localServicesIntegration" isExecutable="true" camunda:versionTag="0.5.0"> <bpmn:serviceTask id="checkResults" name="check results" camunda:class="org.highmed.dsf.bpe.service.CheckSingleMedicResults"> <bpmn:incoming>SequenceFlow_0q803rh</bpmn:incoming> <bpmn:outgoing>SequenceFlow_04ouilq</bpmn:outgoing> @@ -122,7 +122,11 @@ <bpmn:message id="Message_1yz2a31" name="localServicesIntegrationMessage" /> <bpmn:message id="Message_1dr71re" name="resultSingleMedicFeasibilityMessage" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> - <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="localServicesIntegration"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="highmedorg_localServicesIntegration"> + <bpmndi:BPMNEdge id="SequenceFlow_07wtgee_di" bpmnElement="SequenceFlow_07wtgee"> + <di:waypoint x="599" y="272" /> + <di:waypoint x="667" y="272" /> + </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_125i149_di" bpmnElement="Flow_125i149"> <di:waypoint x="400" y="272" /> <di:waypoint x="499" y="272" /> @@ -216,10 +220,6 @@ <dc:Bounds x="722" y="254" width="21" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_07wtgee_di" bpmnElement="SequenceFlow_07wtgee"> - <di:waypoint x="599" y="272" /> - <di:waypoint x="667" y="272" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_04ouilq_di" bpmnElement="SequenceFlow_04ouilq"> <di:waypoint x="1760" y="272" /> <di:waypoint x="1860" y="272" /> @@ -237,9 +237,6 @@ <dc:Bounds x="180" y="297" width="22" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ServiceTask_1pt9xhp_di" bpmnElement="checkQueries"> - <dc:Bounds x="499" y="232" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ExclusiveGateway_1dln3in_di" bpmnElement="ExclusiveGateway_1dln3in" isMarkerVisible="true"> <dc:Bounds x="667" y="247" width="50" height="50" /> </bpmndi:BPMNShape> @@ -282,6 +279,9 @@ <bpmndi:BPMNShape id="Activity_1y9z4ut_di" bpmnElement="storeResult"> <dc:Bounds x="1860" y="232" width="100" height="80" /> </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_1pt9xhp_di" bpmnElement="checkQueries"> + <dc:Bounds x="499" y="232" width="100" height="80" /> + </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn:definitions> diff --git a/dsf-bpe-process-local-services/src/main/resources/fhir/ActivityDefinition/highmed-localServicesIntegration.xml b/dsf-bpe-process-local-services/src/main/resources/fhir/ActivityDefinition/highmed-localServicesIntegration.xml index 38321a2b..e02e4a28 100644 --- a/dsf-bpe-process-local-services/src/main/resources/fhir/ActivityDefinition/highmed-localServicesIntegration.xml +++ b/dsf-bpe-process-local-services/src/main/resources/fhir/ActivityDefinition/highmed-localServicesIntegration.xml @@ -1,62 +1,76 @@ <ActivityDefinition xmlns="http://hl7.org/fhir"> <meta> <tag> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role"/> - <code value="REMOTE"/> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag" /> + <code value="ALL" /> </tag> </meta> <extension url="http://highmed.org/fhir/StructureDefinition/extension-process-authorization"> <extension url="message-name"> - <valueString value="localServicesIntegrationMessage"/> + <valueString value="localServicesIntegrationMessage" /> </extension> - <extension url="authorization-roles"> - <extension url="authorization-role"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role"/> - <code value="LOCAL"/> - </valueCoding> - </extension> - </extension> - <extension url="requester-organization-types"> - <extension url="requester-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type"/> - <code value="MeDIC"/> - </valueCoding> - </extension> + <extension url="task-profile"> + <valueCanonical value="http://highmed.org/fhir/StructureDefinition/task-local-services-integration" /> </extension> - <extension url="recipient-organization-types"> - <extension url="recipient-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type"/> - <code value="MeDIC"/> - </valueCoding> - </extension> + <extension url="requester"> + <valueCoding> + <extension url="http://highmed.org/fhir/StructureDefinition/extension-process-authorization-consortium-role"> + <extension url="consortium"> + <valueIdentifier> + <system value="http://highmed.org/sid/organization-identifier" /> + <value value="highmed.org" /> + </valueIdentifier> + </extension> + <extension url="role"> + <valueCoding> + <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> + <code value="MeDIC" /> + </valueCoding> + </extension> + </extension> + <system value="http://highmed.org/fhir/CodeSystem/process-authorization" /> + <code value="LOCAL_ROLE" /> + </valueCoding> </extension> - <extension url="task-profile"> - <valueCanonical - value="http://highmed.org/fhir/StructureDefinition/task-local-services-integration"/> + <extension url="recipient"> + <valueCoding> + <extension url="http://highmed.org/fhir/StructureDefinition/extension-process-authorization-consortium-role"> + <extension url="consortium"> + <valueIdentifier> + <system value="http://highmed.org/sid/organization-identifier" /> + <value value="highmed.org" /> + </valueIdentifier> + </extension> + <extension url="role"> + <valueCoding> + <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> + <code value="MeDIC" /> + </valueCoding> + </extension> + </extension> + <system value="http://highmed.org/fhir/CodeSystem/process-authorization" /> + <code value="LOCAL_ROLE" /> + </valueCoding> </extension> </extension> - <url value="http://highmed.org/bpe/Process/localServicesIntegration"/> + <url value="http://highmed.org/bpe/Process/localServicesIntegration" /> <!-- version managed by bpe --> <version value="${version}" /> - <name value="localServicesIntegration"/> - <title value="Local services integration"/> - <subtitle value="Service integration process"/> + <name value="LocalServicesIntegration" /> + <title value="Local services integration" /> + <subtitle value="Service integration process" /> <!-- status managed by bpe --> <status value="unknown" /> - <experimental value="false"/> - <date value="2021-01-26"/> - <publisher value="HiGHmed"/> + <experimental value="false" /> + <date value="2021-06-09" /> + <publisher value="HiGHmed" /> <contact> - <name value="HiGHmed"/> + <name value="HiGHmed" /> <telecom> - <system value="email"/> - <value value="pmo@highmed.org"/> + <system value="email" /> + <value value="pmo@highmed.org" /> </telecom> </contact> - <description - value="Process to test the integration of local external services like the MPI, the openEHR repository or the PEP."/> - <kind value="Task"/> + <description value="Process to test the integration of local external services like the MPI, the openEHR repository or the PEP." /> + <kind value="Task" /> </ActivityDefinition> \ No newline at end of file diff --git a/dsf-bpe-process-local-services/src/main/resources/fhir/StructureDefinition/highmed-task-local-services-integration.xml b/dsf-bpe-process-local-services/src/main/resources/fhir/StructureDefinition/highmed-task-local-services-integration.xml index 809557d6..866ef05c 100644 --- a/dsf-bpe-process-local-services/src/main/resources/fhir/StructureDefinition/highmed-task-local-services-integration.xml +++ b/dsf-bpe-process-local-services/src/main/resources/fhir/StructureDefinition/highmed-task-local-services-integration.xml @@ -2,8 +2,8 @@ <StructureDefinition xmlns="http://hl7.org/fhir"> <meta> <tag> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="LOCAL" /> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag" /> + <code value="ALL" /> </tag> </meta> <url value="http://highmed.org/fhir/StructureDefinition/task-local-services-integration" /> @@ -13,7 +13,7 @@ <!-- status managed by bpe --> <status value="unknown" /> <experimental value="false" /> - <date value="2021-01-26" /> + <date value="2021-06-09" /> <fhirVersion value="4.0.1" /> <kind value="resource" /> <abstract value="false" /> diff --git a/dsf-bpe-process-local-services/src/test/java/org/highmed/dsf/bpe/start/AbstractLocalServicesMedic1ExampleStarter.java b/dsf-bpe-process-local-services/src/test/java/org/highmed/dsf/bpe/start/AbstractLocalServicesMedic1ExampleStarter.java new file mode 100644 index 00000000..853f315e --- /dev/null +++ b/dsf-bpe-process-local-services/src/test/java/org/highmed/dsf/bpe/start/AbstractLocalServicesMedic1ExampleStarter.java @@ -0,0 +1,91 @@ +package org.highmed.dsf.bpe.start; + +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN; +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME; +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_QUERY_TYPE; +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGMED_QUERY_TYPE_VALUE_AQL; +import static org.highmed.dsf.bpe.ConstantsBase.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER; +import static org.highmed.dsf.bpe.ConstantsFeasibility.CODESYSTEM_HIGHMED_FEASIBILITY; +import static org.highmed.dsf.bpe.ConstantsFeasibility.CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_BLOOM_FILTER_CONFIG; +import static org.highmed.dsf.bpe.ConstantsFeasibility.CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_NEEDS_CONSENT_CHECK; +import static org.highmed.dsf.bpe.ConstantsFeasibility.CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_NEEDS_RECORD_LINKAGE; +import static org.highmed.dsf.bpe.ConstantsLocalServices.PROFILE_HIGHMED_TASK_LOCAL_SERVICES; +import static org.highmed.dsf.bpe.ConstantsLocalServices.PROFILE_HIGHMED_TASK_LOCAL_SERVICES_MESSAGE_NAME; +import static org.highmed.dsf.bpe.ConstantsLocalServices.PROFILE_HIGHMED_TASK_LOCAL_SERVICES_PROCESS_URI_AND_LATEST_VERSION; +import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1; + +import java.util.Date; +import java.util.Random; + +import javax.crypto.KeyGenerator; + +import org.bouncycastle.jce.provider.BouncyCastleProvider; +import org.highmed.dsf.bpe.variables.BloomFilterConfig; +import org.hl7.fhir.r4.model.Base64BinaryType; +import org.hl7.fhir.r4.model.BooleanType; +import org.hl7.fhir.r4.model.ResourceType; +import org.hl7.fhir.r4.model.StringType; +import org.hl7.fhir.r4.model.Task; + +public abstract class AbstractLocalServicesMedic1ExampleStarter +{ + private static boolean NEEDS_CONSENT_CHECK = true; + private static boolean NEEDS_RECORD_LINKAGE = true; + + protected void main(String[] args, String baseUrl) throws Exception + { + Task task = createStartResource(); + ExampleStarter.forServer(args, baseUrl).startWith(task); + } + + private Task createStartResource() + { + Task task = new Task(); + + task.getMeta().addProfile(PROFILE_HIGHMED_TASK_LOCAL_SERVICES); + task.setInstantiatesUri(PROFILE_HIGHMED_TASK_LOCAL_SERVICES_PROCESS_URI_AND_LATEST_VERSION); + task.setStatus(Task.TaskStatus.REQUESTED); + task.setIntent(Task.TaskIntent.ORDER); + task.setAuthoredOn(new Date()); + + task.getRequester().setType(ResourceType.Organization.name()).getIdentifier() + .setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER) + .setValue(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1); + task.getRestriction().addRecipient().setType(ResourceType.Organization.name()).getIdentifier() + .setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER) + .setValue(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1); + + task.addInput().setValue(new StringType(PROFILE_HIGHMED_TASK_LOCAL_SERVICES_MESSAGE_NAME)).getType().addCoding() + .setSystem(CODESYSTEM_HIGHMED_BPMN).setCode(CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME); + + task.addInput().setValue(new StringType("SELECT COUNT(e) FROM EHR e;")).getType().addCoding() + .setSystem(CODESYSTEM_HIGHMED_QUERY_TYPE).setCode(CODESYSTEM_HIGMED_QUERY_TYPE_VALUE_AQL); + task.addInput().setValue(new BooleanType(NEEDS_CONSENT_CHECK)).getType().addCoding() + .setSystem(CODESYSTEM_HIGHMED_FEASIBILITY) + .setCode(CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_NEEDS_CONSENT_CHECK); + task.addInput().setValue(new BooleanType(NEEDS_RECORD_LINKAGE)).getType().addCoding() + .setSystem(CODESYSTEM_HIGHMED_FEASIBILITY) + .setCode(CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_NEEDS_RECORD_LINKAGE); + + if (NEEDS_RECORD_LINKAGE) + { + try + { + BouncyCastleProvider bouncyCastleProvider = new BouncyCastleProvider(); + BloomFilterConfig bloomFilterConfig = new BloomFilterConfig(new Random().nextLong(), + KeyGenerator.getInstance("HmacSHA256", bouncyCastleProvider).generateKey(), + KeyGenerator.getInstance("HmacSHA3-256", bouncyCastleProvider).generateKey()); + + task.addInput().setValue(new Base64BinaryType(bloomFilterConfig.toBytes())).getType().addCoding() + .setSystem(CODESYSTEM_HIGHMED_FEASIBILITY) + .setCode(CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_BLOOM_FILTER_CONFIG); + } + catch (Exception exception) + { + throw new RuntimeException("Could not create BloomFilterConfig", exception); + } + } + + return task; + } +} diff --git a/dsf-bpe-process-local-services/src/test/java/org/highmed/dsf/bpe/start/LocalServicesMedic1DockerExampleStarter.java b/dsf-bpe-process-local-services/src/test/java/org/highmed/dsf/bpe/start/LocalServicesMedic1DockerExampleStarter.java new file mode 100644 index 00000000..bc56c526 --- /dev/null +++ b/dsf-bpe-process-local-services/src/test/java/org/highmed/dsf/bpe/start/LocalServicesMedic1DockerExampleStarter.java @@ -0,0 +1,15 @@ +package org.highmed.dsf.bpe.start; + +import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.MEDIC_1_DOCKER_FHIR_BASE_URL; + +public class LocalServicesMedic1DockerExampleStarter extends AbstractLocalServicesMedic1ExampleStarter +{ + // Environment variable "DSF_CLIENT_CERTIFICATE_PATH" or args[0]: the path to the client-certificate + // highmed-dsf/dsf-tools/dsf-tools-test-data-generator/cert/Webbrowser_Test_User/Webbrowser_Test_User_certificate.p12 + // Environment variable "DSF_CLIENT_CERTIFICATE_PASSWORD" or args[1]: the password of the client-certificate + // password + public static void main(String[] args) throws Exception + { + new LocalServicesMedic1ExampleStarter().main(args, MEDIC_1_DOCKER_FHIR_BASE_URL); + } +} \ No newline at end of file diff --git a/dsf-bpe-process-local-services/src/test/java/org/highmed/dsf/bpe/start/LocalServicesMedic1ExampleStarter.java b/dsf-bpe-process-local-services/src/test/java/org/highmed/dsf/bpe/start/LocalServicesMedic1ExampleStarter.java index 2015c40f..50625119 100644 --- a/dsf-bpe-process-local-services/src/test/java/org/highmed/dsf/bpe/start/LocalServicesMedic1ExampleStarter.java +++ b/dsf-bpe-process-local-services/src/test/java/org/highmed/dsf/bpe/start/LocalServicesMedic1ExampleStarter.java @@ -1,96 +1,15 @@ package org.highmed.dsf.bpe.start; -import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN; -import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME; -import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_QUERY_TYPE; -import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGMED_QUERY_TYPE_VALUE_AQL; -import static org.highmed.dsf.bpe.ConstantsBase.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER; -import static org.highmed.dsf.bpe.ConstantsFeasibility.CODESYSTEM_HIGHMED_FEASIBILITY; -import static org.highmed.dsf.bpe.ConstantsFeasibility.CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_BLOOM_FILTER_CONFIG; -import static org.highmed.dsf.bpe.ConstantsFeasibility.CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_NEEDS_CONSENT_CHECK; -import static org.highmed.dsf.bpe.ConstantsFeasibility.CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_NEEDS_RECORD_LINKAGE; -import static org.highmed.dsf.bpe.ConstantsLocalServices.PROFILE_HIGHMED_TASK_LOCAL_SERVICES; -import static org.highmed.dsf.bpe.ConstantsLocalServices.PROFILE_HIGHMED_TASK_LOCAL_SERVICES_MESSAGE_NAME; -import static org.highmed.dsf.bpe.ConstantsLocalServices.PROFILE_HIGHMED_TASK_LOCAL_SERVICES_PROCESS_URI_AND_LATEST_VERSION; import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.MEDIC_1_FHIR_BASE_URL; -import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1; -import java.util.Date; -import java.util.Random; - -import javax.crypto.KeyGenerator; - -import org.bouncycastle.jce.provider.BouncyCastleProvider; -import org.highmed.dsf.bpe.variables.BloomFilterConfig; -import org.hl7.fhir.r4.model.Base64BinaryType; -import org.hl7.fhir.r4.model.BooleanType; -import org.hl7.fhir.r4.model.ResourceType; -import org.hl7.fhir.r4.model.StringType; -import org.hl7.fhir.r4.model.Task; - -public class LocalServicesMedic1ExampleStarter +public class LocalServicesMedic1ExampleStarter extends AbstractLocalServicesMedic1ExampleStarter { - private static boolean NEEDS_CONSENT_CHECK = true; - private static boolean NEEDS_RECORD_LINKAGE = true; - // Environment variable "DSF_CLIENT_CERTIFICATE_PATH" or args[0]: the path to the client-certificate // highmed-dsf/dsf-tools/dsf-tools-test-data-generator/cert/Webbrowser_Test_User/Webbrowser_Test_User_certificate.p12 // Environment variable "DSF_CLIENT_CERTIFICATE_PASSWORD" or args[1]: the password of the client-certificate // password public static void main(String[] args) throws Exception { - Task task = createStartResource(); - ExampleStarter.forServer(args, MEDIC_1_FHIR_BASE_URL).startWith(task); - } - - private static Task createStartResource() - { - Task task = new Task(); - - task.getMeta().addProfile(PROFILE_HIGHMED_TASK_LOCAL_SERVICES); - task.setInstantiatesUri(PROFILE_HIGHMED_TASK_LOCAL_SERVICES_PROCESS_URI_AND_LATEST_VERSION); - task.setStatus(Task.TaskStatus.REQUESTED); - task.setIntent(Task.TaskIntent.ORDER); - task.setAuthoredOn(new Date()); - - task.getRequester().setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER) - .setValue(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1); - task.getRestriction().addRecipient().setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER) - .setValue(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1); - - task.addInput().setValue(new StringType(PROFILE_HIGHMED_TASK_LOCAL_SERVICES_MESSAGE_NAME)).getType().addCoding() - .setSystem(CODESYSTEM_HIGHMED_BPMN).setCode(CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME); - - task.addInput().setValue(new StringType("SELECT COUNT(e) FROM EHR e;")).getType().addCoding() - .setSystem(CODESYSTEM_HIGHMED_QUERY_TYPE).setCode(CODESYSTEM_HIGMED_QUERY_TYPE_VALUE_AQL); - task.addInput().setValue(new BooleanType(NEEDS_CONSENT_CHECK)).getType().addCoding() - .setSystem(CODESYSTEM_HIGHMED_FEASIBILITY) - .setCode(CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_NEEDS_CONSENT_CHECK); - task.addInput().setValue(new BooleanType(NEEDS_RECORD_LINKAGE)).getType().addCoding() - .setSystem(CODESYSTEM_HIGHMED_FEASIBILITY) - .setCode(CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_NEEDS_RECORD_LINKAGE); - - if (NEEDS_RECORD_LINKAGE) - { - try - { - BouncyCastleProvider bouncyCastleProvider = new BouncyCastleProvider(); - BloomFilterConfig bloomFilterConfig = new BloomFilterConfig(new Random().nextLong(), - KeyGenerator.getInstance("HmacSHA256", bouncyCastleProvider).generateKey(), - KeyGenerator.getInstance("HmacSHA3-256", bouncyCastleProvider).generateKey()); - - task.addInput().setValue(new Base64BinaryType(bloomFilterConfig.toBytes())).getType().addCoding() - .setSystem(CODESYSTEM_HIGHMED_FEASIBILITY) - .setCode(CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_BLOOM_FILTER_CONFIG); - } - catch (Exception exception) - { - throw new RuntimeException("Could not create BloomFilterConfig", exception); - } - } - - return task; + new LocalServicesMedic1ExampleStarter().main(args, MEDIC_1_FHIR_BASE_URL); } } diff --git a/dsf-bpe-process-local-services/src/test/java/org/highmed/dsf/fhir/profile/ActivityDefinitionProfileTest.java b/dsf-bpe-process-local-services/src/test/java/org/highmed/dsf/fhir/profile/ActivityDefinitionProfileTest.java new file mode 100644 index 00000000..c804f720 --- /dev/null +++ b/dsf-bpe-process-local-services/src/test/java/org/highmed/dsf/fhir/profile/ActivityDefinitionProfileTest.java @@ -0,0 +1,69 @@ +package org.highmed.dsf.fhir.profile; + +import static org.highmed.dsf.bpe.LocalServicesProcessPluginDefinition.VERSION; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; + +import org.highmed.dsf.fhir.authorization.process.ProcessAuthorizationHelper; +import org.highmed.dsf.fhir.authorization.process.ProcessAuthorizationHelperImpl; +import org.highmed.dsf.fhir.validation.ResourceValidator; +import org.highmed.dsf.fhir.validation.ResourceValidatorImpl; +import org.highmed.dsf.fhir.validation.ValidationSupportRule; +import org.hl7.fhir.r4.model.ActivityDefinition; +import org.junit.ClassRule; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import ca.uhn.fhir.validation.ResultSeverityEnum; +import ca.uhn.fhir.validation.ValidationResult; + +public class ActivityDefinitionProfileTest +{ + private static final Logger logger = LoggerFactory.getLogger(ActivityDefinitionProfileTest.class); + + @ClassRule + public static final ValidationSupportRule validationRule = new ValidationSupportRule(VERSION, + Arrays.asList("highmed-activity-definition-0.5.0.xml", "highmed-extension-process-authorization-0.5.0.xml", + "highmed-extension-process-authorization-consortium-role-0.5.0.xml", + "highmed-extension-process-authorization-organization-0.5.0.xml", + "highmed-coding-process-authorization-local-all-0.5.0.xml", + "highmed-coding-process-authorization-local-consortium-role-0.5.0.xml", + "highmed-coding-process-authorization-local-organization-0.5.0.xml", + "highmed-coding-process-authorization-remote-all-0.5.0.xml", + "highmed-coding-process-authorization-remote-consortium-role-0.5.0.xml", + "highmed-coding-process-authorization-remote-organization-0.5.0.xml"), + Arrays.asList("highmed-read-access-tag-0.5.0.xml", "highmed-process-authorization-0.5.0.xml"), + Arrays.asList("highmed-read-access-tag-0.5.0.xml", "highmed-process-authorization-recipient-0.5.0.xml", + "highmed-process-authorization-requester-0.5.0.xml")); + + private final ResourceValidator resourceValidator = new ResourceValidatorImpl(validationRule.getFhirContext(), + validationRule.getValidationSupport()); + + private final ProcessAuthorizationHelper processAuthorizationHelper = new ProcessAuthorizationHelperImpl(); + + @Test + public void testLocalServicesIntegrationValid() throws Exception + { + try (InputStream in = Files.newInputStream( + Paths.get("src/main/resources/fhir/ActivityDefinition/highmed-localServicesIntegration.xml"))) + { + ActivityDefinition ad = validationRule.getFhirContext().newXmlParser() + .parseResource(ActivityDefinition.class, in); + + ValidationResult result = resourceValidator.validate(ad); + ValidationSupportRule.logValidationMessages(logger, result); + + assertEquals(0, result.getMessages().stream().filter(m -> ResultSeverityEnum.ERROR.equals(m.getSeverity()) + || ResultSeverityEnum.FATAL.equals(m.getSeverity())).count()); + + assertTrue( + processAuthorizationHelper.isValid(ad, taskProfile -> true, orgIdentifier -> true, role -> true)); + } + } +} \ No newline at end of file diff --git a/dsf-bpe-process-local-services/src/test/java/org/highmed/dsf/fhir/profile/TaskProfileTest.java b/dsf-bpe-process-local-services/src/test/java/org/highmed/dsf/fhir/profile/TaskProfileTest.java index 6be24426..fa64f641 100644 --- a/dsf-bpe-process-local-services/src/test/java/org/highmed/dsf/fhir/profile/TaskProfileTest.java +++ b/dsf-bpe-process-local-services/src/test/java/org/highmed/dsf/fhir/profile/TaskProfileTest.java @@ -44,9 +44,9 @@ public class TaskProfileTest Arrays.asList("highmed-task-base-0.5.0.xml", "highmed-group-0.5.0.xml", "highmed-extension-group-id-0.5.0.xml", "highmed-extension-query-0.5.0.xml", "highmed-task-local-services-integration.xml"), - Arrays.asList("highmed-authorization-role-0.5.0.xml", "highmed-bpmn-message-0.5.0.xml", + Arrays.asList("highmed-read-access-tag-0.5.0.xml", "highmed-bpmn-message-0.5.0.xml", "highmed-feasibility.xml", "highmed-query-type-0.5.0.xml"), - Arrays.asList("highmed-authorization-role-0.5.0.xml", "highmed-bpmn-message-0.5.0.xml", + Arrays.asList("highmed-read-access-tag-0.5.0.xml", "highmed-bpmn-message-0.5.0.xml", "highmed-feasibility.xml", "highmed-query-type-0.5.0.xml")); private ResourceValidator resourceValidator = new ResourceValidatorImpl(validationRule.getFhirContext(), diff --git a/dsf-bpe-process-ping/pom.xml b/dsf-bpe-process-ping/pom.xml index 925ae232..b04cc233 100644 --- a/dsf-bpe-process-ping/pom.xml +++ b/dsf-bpe-process-ping/pom.xml @@ -63,7 +63,7 @@ <version>${project.version}</version> </artifactItem> </artifactItems> - <outputDirectory>${dsf.location}/dsf-docker-test-setup/bpe/app/process</outputDirectory> + <outputDirectory>${dsf.location}/dsf-docker-test-setup/bpe/process</outputDirectory> </configuration> </execution> <execution> @@ -80,7 +80,7 @@ <version>${project.version}</version> </artifactItem> </artifactItems> - <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic1/bpe/app/process</outputDirectory> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic1/bpe/process</outputDirectory> </configuration> </execution> <execution> @@ -97,7 +97,7 @@ <version>${project.version}</version> </artifactItem> </artifactItems> - <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic2/bpe/app/process</outputDirectory> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic2/bpe/process</outputDirectory> </configuration> </execution> <execution> @@ -114,7 +114,7 @@ <version>${project.version}</version> </artifactItem> </artifactItems> - <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic3/bpe/app/process</outputDirectory> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic3/bpe/process</outputDirectory> </configuration> </execution> <execution> @@ -131,7 +131,79 @@ <version>${project.version}</version> </artifactItem> </artifactItems> - <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/ttp/bpe/app/process</outputDirectory> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/ttp/bpe/process</outputDirectory> + </configuration> + </execution> + <execution> + <id>copy-process-to-docker-test-setup-3medic-ttp-docker/medic1</id> + <phase>package</phase> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>${project.groupId}</groupId> + <artifactId>${project.artifactId}</artifactId> + <version>${project.version}</version> + </artifactItem> + </artifactItems> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/medic1/bpe/process + </outputDirectory> + </configuration> + </execution> + <execution> + <id>copy-process-to-docker-test-setup-3medic-ttp-docker/medic2</id> + <phase>package</phase> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>${project.groupId}</groupId> + <artifactId>${project.artifactId}</artifactId> + <version>${project.version}</version> + </artifactItem> + </artifactItems> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/medic2/bpe/process + </outputDirectory> + </configuration> + </execution> + <execution> + <id>copy-process-to-docker-test-setup-3medic-ttp-docker/medic3</id> + <phase>package</phase> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>${project.groupId}</groupId> + <artifactId>${project.artifactId}</artifactId> + <version>${project.version}</version> + </artifactItem> + </artifactItems> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/medic3/bpe/process + </outputDirectory> + </configuration> + </execution> + <execution> + <id>copy-process-to-docker-test-setup-3medic-ttp-docker/ttp</id> + <phase>package</phase> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>${project.groupId}</groupId> + <artifactId>${project.artifactId}</artifactId> + <version>${project.version}</version> + </artifactItem> + </artifactItems> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/ttp/bpe/process + </outputDirectory> </configuration> </execution> </executions> @@ -142,35 +214,63 @@ <configuration> <filesets> <fileset> - <directory>${dsf.location}/dsf-docker-test-setup/bpe/app/process</directory> + <directory>${dsf.location}/dsf-docker-test-setup/bpe/process</directory> + <includes> + <include>${project.artifactId}-${project.version}.jar</include> + </includes> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic1/bpe/process</directory> + <includes> + <include>${project.artifactId}-${project.version}.jar</include> + </includes> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic2/bpe/process</directory> + <includes> + <include>${project.artifactId}-${project.version}.jar</include> + </includes> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic3/bpe/process</directory> + <includes> + <include>${project.artifactId}-${project.version}.jar</include> + </includes> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/ttp/bpe/process</directory> <includes> <include>${project.artifactId}-${project.version}.jar</include> </includes> <followSymlinks>false</followSymlinks> </fileset> <fileset> - <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic1/bpe/app/process</directory> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/medic1/bpe/process</directory> <includes> <include>${project.artifactId}-${project.version}.jar</include> </includes> <followSymlinks>false</followSymlinks> </fileset> <fileset> - <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic2/bpe/app/process</directory> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/medic2/bpe/process</directory> <includes> <include>${project.artifactId}-${project.version}.jar</include> </includes> <followSymlinks>false</followSymlinks> </fileset> <fileset> - <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic3/bpe/app/process</directory> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/medic3/bpe/process</directory> <includes> <include>${project.artifactId}-${project.version}.jar</include> </includes> <followSymlinks>false</followSymlinks> </fileset> <fileset> - <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/ttp/bpe/app/process</directory> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/ttp/bpe/process</directory> <includes> <include>${project.artifactId}-${project.version}.jar</include> </includes> diff --git a/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/PingProcessPluginDefinition.java b/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/PingProcessPluginDefinition.java index b058d755..180a53a7 100644 --- a/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/PingProcessPluginDefinition.java +++ b/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/PingProcessPluginDefinition.java @@ -10,6 +10,7 @@ import org.highmed.dsf.fhir.resources.ActivityDefinitionResource; import org.highmed.dsf.fhir.resources.ResourceProvider; import org.highmed.dsf.fhir.resources.StructureDefinitionResource; +import org.springframework.core.env.PropertyResolver; import ca.uhn.fhir.context.FhirContext; @@ -42,7 +43,8 @@ public Stream<Class<?>> getSpringConfigClasses() } @Override - public ResourceProvider getResourceProvider(FhirContext fhirContext, ClassLoader classLoader) + public ResourceProvider getResourceProvider(FhirContext fhirContext, ClassLoader classLoader, + PropertyResolver resolver) { var aPing = ActivityDefinitionResource.file("fhir/ActivityDefinition/highmed-ping.xml"); var aPong = ActivityDefinitionResource.file("fhir/ActivityDefinition/highmed-pong.xml"); @@ -51,10 +53,10 @@ public ResourceProvider getResourceProvider(FhirContext fhirContext, ClassLoader .file("fhir/StructureDefinition/highmed-task-start-ping-process.xml"); var tPong = StructureDefinitionResource.file("fhir/StructureDefinition/highmed-task-ping.xml"); - Map<String, List<AbstractResource>> resourcesByProcessKeyAndVersion = Map.of("ping/" + VERSION, - Arrays.asList(aPing, tPong, tStartPing), "pong/" + VERSION, Arrays.asList(aPong, tPing)); + Map<String, List<AbstractResource>> resourcesByProcessKeyAndVersion = Map.of("highmedorg_ping/" + VERSION, + Arrays.asList(aPing, tPong, tStartPing), "highmedorg_pong/" + VERSION, Arrays.asList(aPong, tPing)); return ResourceProvider.read(VERSION, () -> fhirContext.newXmlParser().setStripVersionsFromReferences(false), - classLoader, resourcesByProcessKeyAndVersion); + classLoader, resolver, resourcesByProcessKeyAndVersion); } } diff --git a/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/message/SendPing.java b/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/message/SendPing.java index 13205a49..8a64cc1e 100644 --- a/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/message/SendPing.java +++ b/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/message/SendPing.java @@ -1,5 +1,6 @@ package org.highmed.dsf.bpe.message; +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; @@ -10,8 +11,8 @@ public class SendPing extends AbstractTaskMessageSend { public SendPing(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, - OrganizationProvider organizationProvider, FhirContext fhirContext) + ReadAccessHelper readAccessHelper, OrganizationProvider organizationProvider, FhirContext fhirContext) { - super(clientProvider, taskHelper, organizationProvider, fhirContext); + super(clientProvider, taskHelper, readAccessHelper, organizationProvider, fhirContext); } } diff --git a/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/message/SendPong.java b/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/message/SendPong.java index 1d98a3c5..3ba8659c 100644 --- a/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/message/SendPong.java +++ b/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/message/SendPong.java @@ -1,5 +1,6 @@ package org.highmed.dsf.bpe.message; +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; @@ -10,8 +11,8 @@ public class SendPong extends AbstractTaskMessageSend { public SendPong(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, - OrganizationProvider organizationProvider, FhirContext fhirContext) + ReadAccessHelper readAccessHelper, OrganizationProvider organizationProvider, FhirContext fhirContext) { - super(clientProvider, taskHelper, organizationProvider, fhirContext); + super(clientProvider, taskHelper, readAccessHelper, organizationProvider, fhirContext); } } diff --git a/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/service/LogPing.java b/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/service/LogPing.java index 41de1434..e436c9f6 100644 --- a/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/service/LogPing.java +++ b/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/service/LogPing.java @@ -2,6 +2,7 @@ import org.camunda.bpm.engine.delegate.DelegateExecution; import org.highmed.dsf.bpe.delegate.AbstractServiceDelegate; +import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper; import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider; import org.highmed.dsf.fhir.task.TaskHelper; import org.hl7.fhir.r4.model.Task; @@ -12,9 +13,10 @@ public class LogPing extends AbstractServiceDelegate { private static final Logger logger = LoggerFactory.getLogger(LogPing.class); - public LogPing(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper) + public LogPing(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, + ReadAccessHelper readAccessHelper) { - super(clientProvider, taskHelper); + super(clientProvider, taskHelper, readAccessHelper); } @Override diff --git a/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/service/LogPong.java b/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/service/LogPong.java index 97a79692..400ee43d 100644 --- a/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/service/LogPong.java +++ b/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/service/LogPong.java @@ -2,6 +2,7 @@ import org.camunda.bpm.engine.delegate.DelegateExecution; import org.highmed.dsf.bpe.delegate.AbstractServiceDelegate; +import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper; import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider; import org.highmed.dsf.fhir.task.TaskHelper; import org.hl7.fhir.r4.model.Task; @@ -12,9 +13,10 @@ public class LogPong extends AbstractServiceDelegate { private static final Logger logger = LoggerFactory.getLogger(LogPong.class); - public LogPong(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper) + public LogPong(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, + ReadAccessHelper readAccessHelper) { - super(clientProvider, taskHelper); + super(clientProvider, taskHelper, readAccessHelper); } @Override diff --git a/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/service/SelectPingTargets.java b/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/service/SelectPingTargets.java index 79b5e30a..9066782e 100644 --- a/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/service/SelectPingTargets.java +++ b/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/service/SelectPingTargets.java @@ -9,8 +9,9 @@ import org.camunda.bpm.engine.delegate.DelegateExecution; import org.highmed.dsf.bpe.delegate.AbstractServiceDelegate; +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.organization.EndpointProvider; import org.highmed.dsf.fhir.task.TaskHelper; import org.highmed.dsf.fhir.variables.Target; import org.highmed.dsf.fhir.variables.Targets; @@ -19,13 +20,14 @@ public class SelectPingTargets extends AbstractServiceDelegate implements InitializingBean { - private final OrganizationProvider organizationProvider; + private final EndpointProvider endpointProvider; public SelectPingTargets(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, - OrganizationProvider organizationProvider) + ReadAccessHelper readAccessHelper, EndpointProvider endpointProvider) { - super(clientProvider, taskHelper); - this.organizationProvider = organizationProvider; + super(clientProvider, taskHelper, readAccessHelper); + + this.endpointProvider = endpointProvider; } @Override @@ -33,14 +35,17 @@ public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); - Objects.requireNonNull(organizationProvider, "organizationProvider"); + Objects.requireNonNull(endpointProvider, "endpointProvider"); } @Override public void doExecute(DelegateExecution execution) throws Exception { - List<Target> targets = organizationProvider.getRemoteIdentifiers().stream().map( - identifier -> Target.createBiDirectionalTarget(identifier.getValue(), UUID.randomUUID().toString())) + String localAddress = endpointProvider.getLocalEndpoint().getAddress(); + + List<Target> targets = endpointProvider.getDefaultEndpointAdressesByOrganizationIdentifier().entrySet().stream() + .filter(a -> !localAddress.equals(a.getValue())) + .map(e -> Target.createBiDirectionalTarget(e.getKey(), e.getValue(), UUID.randomUUID().toString())) .collect(Collectors.toList()); execution.setVariable(BPMN_EXECUTION_VARIABLE_TARGETS, TargetsValues.create(new Targets(targets))); diff --git a/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/service/SelectPongTarget.java b/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/service/SelectPongTarget.java index f0d0cb0a..b064d657 100644 --- a/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/service/SelectPongTarget.java +++ b/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/service/SelectPongTarget.java @@ -4,9 +4,13 @@ import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN; import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN_VALUE_CORRELATION_KEY; +import java.util.Objects; + import org.camunda.bpm.engine.delegate.DelegateExecution; import org.highmed.dsf.bpe.delegate.AbstractServiceDelegate; +import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper; import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider; +import org.highmed.dsf.fhir.organization.EndpointProvider; import org.highmed.dsf.fhir.task.TaskHelper; import org.highmed.dsf.fhir.variables.Target; import org.highmed.dsf.fhir.variables.TargetValues; @@ -16,9 +20,22 @@ public class SelectPongTarget extends AbstractServiceDelegate implements InitializingBean { - public SelectPongTarget(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper) + private final EndpointProvider endpointProvider; + + public SelectPongTarget(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, + ReadAccessHelper readAccessHelper, EndpointProvider endpointProvider) + { + super(clientProvider, taskHelper, readAccessHelper); + + this.endpointProvider = endpointProvider; + } + + @Override + public void afterPropertiesSet() throws Exception { - super(clientProvider, taskHelper); + super.afterPropertiesSet(); + + Objects.requireNonNull(endpointProvider, "endpointProvider"); } @Override @@ -30,7 +47,9 @@ public void doExecute(DelegateExecution execution) throws Exception CODESYSTEM_HIGHMED_BPMN_VALUE_CORRELATION_KEY).get(); Identifier targetOrganizationIdentifier = task.getRequester().getIdentifier(); - execution.setVariable(BPMN_EXECUTION_VARIABLE_TARGET, TargetValues - .create(Target.createBiDirectionalTarget(targetOrganizationIdentifier.getValue(), correlationKey))); + execution.setVariable(BPMN_EXECUTION_VARIABLE_TARGET, + TargetValues.create(Target.createBiDirectionalTarget(targetOrganizationIdentifier.getValue(), + endpointProvider.getFirstDefaultEndpointAddress(targetOrganizationIdentifier.getValue()).get(), + correlationKey))); } } diff --git a/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/spring/config/PingConfig.java b/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/spring/config/PingConfig.java index b1dd4a66..a67497cf 100644 --- a/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/spring/config/PingConfig.java +++ b/dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/spring/config/PingConfig.java @@ -6,7 +6,9 @@ import org.highmed.dsf.bpe.service.LogPong; import org.highmed.dsf.bpe.service.SelectPingTargets; import org.highmed.dsf.bpe.service.SelectPongTarget; +import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper; import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider; +import org.highmed.dsf.fhir.organization.EndpointProvider; import org.highmed.dsf.fhir.organization.OrganizationProvider; import org.highmed.dsf.fhir.task.TaskHelper; import org.springframework.beans.factory.annotation.Autowired; @@ -21,11 +23,17 @@ public class PingConfig @Autowired private FhirWebserviceClientProvider clientProvider; + @Autowired + private TaskHelper taskHelper; + + @Autowired + private ReadAccessHelper readAccessHelper; + @Autowired private OrganizationProvider organizationProvider; @Autowired - private TaskHelper taskHelper; + private EndpointProvider endpointProvider; @Autowired private FhirContext fhirContext; @@ -33,36 +41,36 @@ public class PingConfig @Bean public SendPing sendPing() { - return new SendPing(clientProvider, taskHelper, organizationProvider, fhirContext); + return new SendPing(clientProvider, taskHelper, readAccessHelper, organizationProvider, fhirContext); } @Bean public SendPong sendPong() { - return new SendPong(clientProvider, taskHelper, organizationProvider, fhirContext); + return new SendPong(clientProvider, taskHelper, readAccessHelper, organizationProvider, fhirContext); } @Bean public LogPing logPing() { - return new LogPing(clientProvider, taskHelper); + return new LogPing(clientProvider, taskHelper, readAccessHelper); } @Bean public LogPong logPong() { - return new LogPong(clientProvider, taskHelper); + return new LogPong(clientProvider, taskHelper, readAccessHelper); } @Bean public SelectPingTargets selectPingTargets() { - return new SelectPingTargets(clientProvider, taskHelper, organizationProvider); + return new SelectPingTargets(clientProvider, taskHelper, readAccessHelper, endpointProvider); } @Bean public SelectPongTarget selectPongTarget() { - return new SelectPongTarget(clientProvider, taskHelper); + return new SelectPongTarget(clientProvider, taskHelper, readAccessHelper, endpointProvider); } } diff --git a/dsf-bpe-process-ping/src/main/resources/bpe/ping.bpmn b/dsf-bpe-process-ping/src/main/resources/bpe/ping.bpmn index 2d32fb25..3301f3b9 100644 --- a/dsf-bpe-process-ping/src/main/resources/bpe/ping.bpmn +++ b/dsf-bpe-process-ping/src/main/resources/bpe/ping.bpmn @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_0azvmx1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.7.1"> - <bpmn:process id="ping" isExecutable="true" camunda:versionTag="0.5.0"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_0azvmx1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.8.1"> + <bpmn:process id="highmedorg_ping" isExecutable="true" camunda:versionTag="0.5.0"> <bpmn:sequenceFlow id="SequenceFlow_0k1j79c" sourceRef="StartEvent_1" targetRef="selectTargets" /> <bpmn:sequenceFlow id="SequenceFlow_05ia6lz" sourceRef="selectTargets" targetRef="sendPing" /> <bpmn:serviceTask id="selectTargets" name="selectTargets" camunda:class="org.highmed.dsf.bpe.service.SelectPingTargets"> @@ -10,8 +10,7 @@ <bpmn:sendTask id="sendPing" name="sendPing" camunda:class="org.highmed.dsf.bpe.message.SendPing"> <bpmn:extensionElements> <camunda:inputOutput> - <camunda:inputParameter name="processDefinitionKey">pong</camunda:inputParameter> - <camunda:inputParameter name="versionTag">0.5.0</camunda:inputParameter> + <camunda:inputParameter name="instantiatesUri">http://highmed.org/bpe/Process/pong/0.5.0</camunda:inputParameter> <camunda:inputParameter name="messageName">pingMessage</camunda:inputParameter> <camunda:inputParameter name="profile">http://highmed.org/fhir/StructureDefinition/task-ping</camunda:inputParameter> </camunda:inputOutput> @@ -68,7 +67,7 @@ <bpmn:message id="Message_10o3b8y" name="pongMessage" /> <bpmn:message id="Message_1pklz6t" name="startPingProcessMessage" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> - <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ping"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="highmedorg_ping"> <bpmndi:BPMNEdge id="SequenceFlow_1vng5zz_di" bpmnElement="SequenceFlow_1vng5zz"> <di:waypoint x="530" y="120" /> <di:waypoint x="606" y="120" /> @@ -83,19 +82,19 @@ <di:waypoint x="1154" y="120" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_05ia6lz_di" bpmnElement="SequenceFlow_05ia6lz"> - <di:waypoint x="359" y="120" /> + <di:waypoint x="370" y="120" /> <di:waypoint x="430" y="120" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0k1j79c_di" bpmnElement="SequenceFlow_0k1j79c"> <di:waypoint x="209" y="120" /> - <di:waypoint x="259" y="120" /> + <di:waypoint x="270" y="120" /> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ServiceTask_1cxtndb_di" bpmnElement="selectTargets"> - <dc:Bounds x="259" y="80" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNShape id="SendTask_01t32b2_di" bpmnElement="sendPing"> <dc:Bounds x="430" y="80" width="100" height="80" /> </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_1cxtndb_di" bpmnElement="selectTargets"> + <dc:Bounds x="270" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> <bpmndi:BPMNShape id="SubProcess_0szmntn_di" bpmnElement="SubProcess_0szmntn" isExpanded="true"> <dc:Bounds x="606" y="60" width="458" height="120" /> </bpmndi:BPMNShape> diff --git a/dsf-bpe-process-ping/src/main/resources/bpe/pong.bpmn b/dsf-bpe-process-ping/src/main/resources/bpe/pong.bpmn index e3af4ee4..a5a3f2aa 100644 --- a/dsf-bpe-process-ping/src/main/resources/bpe/pong.bpmn +++ b/dsf-bpe-process-ping/src/main/resources/bpe/pong.bpmn @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_15v05m6" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.5.0"> - <bpmn:process id="pong" isExecutable="true" camunda:versionTag="0.5.0"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_15v05m6" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.8.1"> + <bpmn:process id="highmedorg_pong" isExecutable="true" camunda:versionTag="0.5.0"> <bpmn:startEvent id="StartEvent_1"> <bpmn:outgoing>SequenceFlow_07w11cw</bpmn:outgoing> <bpmn:messageEventDefinition messageRef="Message_0u91abp" /> @@ -9,9 +9,8 @@ <bpmn:endEvent id="EndEvent_1ivxrjg"> <bpmn:extensionElements> <camunda:inputOutput> + <camunda:inputParameter name="instantiatesUri">http://highmed.org/bpe/Process/ping/0.5.0</camunda:inputParameter> <camunda:inputParameter name="messageName">pongMessage</camunda:inputParameter> - <camunda:inputParameter name="versionTag">0.5.0</camunda:inputParameter> - <camunda:inputParameter name="processDefinitionKey">ping</camunda:inputParameter> <camunda:inputParameter name="profile">http://highmed.org/fhir/StructureDefinition/task-pong</camunda:inputParameter> </camunda:inputOutput> </bpmn:extensionElements> @@ -32,31 +31,31 @@ <bpmn:message id="Message_0u91abp" name="pingMessage" /> <bpmn:message id="Message_1h0kvyq" name="pong" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> - <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="pong"> - <bpmndi:BPMNShape id="StartEvent_1qh431z_di" bpmnElement="StartEvent_1"> - <dc:Bounds x="173" y="102" width="36" height="36" /> - </bpmndi:BPMNShape> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="highmedorg_pong"> + <bpmndi:BPMNEdge id="SequenceFlow_1ism9wt_di" bpmnElement="SequenceFlow_1ism9wt"> + <di:waypoint x="528" y="120" /> + <di:waypoint x="580" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_09i9zb8_di" bpmnElement="SequenceFlow_09i9zb8"> + <di:waypoint x="362" y="120" /> + <di:waypoint x="428" y="120" /> + </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_07w11cw_di" bpmnElement="SequenceFlow_07w11cw"> <di:waypoint x="209" y="120" /> <di:waypoint x="262" y="120" /> </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_1qh431z_di" bpmnElement="StartEvent_1"> + <dc:Bounds x="173" y="102" width="36" height="36" /> + </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_108jj6g_di" bpmnElement="EndEvent_1ivxrjg"> <dc:Bounds x="580" y="102" width="36" height="36" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_09i9zb8_di" bpmnElement="SequenceFlow_09i9zb8"> - <di:waypoint x="362" y="120" /> - <di:waypoint x="428" y="120" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_1uea92o_di" bpmnElement="logPing"> <dc:Bounds x="262" y="80" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_0ko681m_di" bpmnElement="selectTarget"> <dc:Bounds x="428" y="80" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1ism9wt_di" bpmnElement="SequenceFlow_1ism9wt"> - <di:waypoint x="528" y="120" /> - <di:waypoint x="580" y="120" /> - </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn:definitions> diff --git a/dsf-bpe-process-ping/src/main/resources/fhir/ActivityDefinition/highmed-ping.xml b/dsf-bpe-process-ping/src/main/resources/fhir/ActivityDefinition/highmed-ping.xml index a86cb581..d6d7bf61 100644 --- a/dsf-bpe-process-ping/src/main/resources/fhir/ActivityDefinition/highmed-ping.xml +++ b/dsf-bpe-process-ping/src/main/resources/fhir/ActivityDefinition/highmed-ping.xml @@ -1,108 +1,60 @@ <ActivityDefinition xmlns="http://hl7.org/fhir"> <meta> <tag> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="REMOTE" /> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag" /> + <code value="ALL" /> </tag> </meta> <extension url="http://highmed.org/fhir/StructureDefinition/extension-process-authorization"> <extension url="message-name"> <valueString value="startPingProcessMessage" /> </extension> - <extension url="authorization-roles"> - <extension url="authorization-role"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="LOCAL" /> - </valueCoding> - </extension> - </extension> - <extension url="requester-organization-types"> - <extension url="requester-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="TTP" /> - </valueCoding> - </extension> - <extension url="requester-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="MeDIC" /> - </valueCoding> - </extension> - </extension> - <extension url="recipient-organization-types"> - <extension url="recipient-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="TTP" /> - </valueCoding> - </extension> - <extension url="recipient-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="MeDIC" /> - </valueCoding> - </extension> - </extension> <extension url="task-profile"> <valueCanonical value="http://highmed.org/fhir/StructureDefinition/task-start-ping-process" /> </extension> + <extension url="requester"> + <valueCoding> + <system value="http://highmed.org/fhir/CodeSystem/process-authorization" /> + <code value="LOCAL_ALL" /> + </valueCoding> + </extension> + <extension url="recipient"> + <valueCoding> + <system value="http://highmed.org/fhir/CodeSystem/process-authorization" /> + <code value="LOCAL_ALL" /> + </valueCoding> + </extension> </extension> <extension url="http://highmed.org/fhir/StructureDefinition/extension-process-authorization"> <extension url="message-name"> <valueString value="pongMessage" /> </extension> - <extension url="authorization-roles"> - <extension url="authorization-role"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="REMOTE" /> - </valueCoding> - </extension> - </extension> - <extension url="requester-organization-types"> - <extension url="requester-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="TTP" /> - </valueCoding> - </extension> - <extension url="requester-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="MeDIC" /> - </valueCoding> - </extension> - </extension> - <extension url="recipient-organization-types"> - <extension url="recipient-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="TTP" /> - </valueCoding> - </extension> - <extension url="recipient-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="MeDIC" /> - </valueCoding> - </extension> - </extension> <extension url="task-profile"> <valueCanonical value="http://highmed.org/fhir/StructureDefinition/task-pong" /> </extension> + <extension url="requester"> + <valueCoding> + <system value="http://highmed.org/fhir/CodeSystem/process-authorization" /> + <code value="REMOTE_ALL" /> + </valueCoding> + </extension> + <extension url="recipient"> + <valueCoding> + <system value="http://highmed.org/fhir/CodeSystem/process-authorization" /> + <code value="LOCAL_ALL" /> + </valueCoding> + </extension> </extension> <url value="http://highmed.org/bpe/Process/ping" /> <!-- version managed by bpe --> <version value="${version}" /> - <name value="ping" /> + <name value="Ping" /> <title value="PING process" /> <subtitle value="Communication Testing Process" /> <!-- status managed by bpe --> <status value="unknown" /> <experimental value="false" /> - <date value="2021-01-26" /> + <date value="2021-06-08" /> <publisher value="HiGHmed" /> <contact> <name value="HiGHmed" /> @@ -111,6 +63,6 @@ <value value="pmo@highmed.org" /> </telecom> </contact> - <description value="Process to send PING messages to remote Organizations and to receive corresponding PONG message" /> + <description value="Process to send PING messages to remote Organizations and to receive corresponding PONG messages" /> <kind value="Task" /> </ActivityDefinition> \ No newline at end of file diff --git a/dsf-bpe-process-ping/src/main/resources/fhir/ActivityDefinition/highmed-pong.xml b/dsf-bpe-process-ping/src/main/resources/fhir/ActivityDefinition/highmed-pong.xml index 8c2d3ef8..4f705257 100644 --- a/dsf-bpe-process-ping/src/main/resources/fhir/ActivityDefinition/highmed-pong.xml +++ b/dsf-bpe-process-ping/src/main/resources/fhir/ActivityDefinition/highmed-pong.xml @@ -1,64 +1,40 @@ <ActivityDefinition xmlns="http://hl7.org/fhir"> <meta> <tag> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="REMOTE" /> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag" /> + <code value="ALL" /> </tag> </meta> <extension url="http://highmed.org/fhir/StructureDefinition/extension-process-authorization"> <extension url="message-name"> <valueString value="pingMessage" /> </extension> - <extension url="authorization-roles"> - <extension url="authorization-role"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="REMOTE" /> - </valueCoding> - </extension> - </extension> - <extension url="requester-organization-types"> - <extension url="requester-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="TTP" /> - </valueCoding> - </extension> - <extension url="requester-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="MeDIC" /> - </valueCoding> - </extension> - </extension> - <extension url="recipient-organization-types"> - <extension url="recipient-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="TTP" /> - </valueCoding> - </extension> - <extension url="recipient-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="MeDIC" /> - </valueCoding> - </extension> - </extension> <extension url="task-profile"> <valueCanonical value="http://highmed.org/fhir/StructureDefinition/task-ping" /> </extension> + <extension url="requester"> + <valueCoding> + <system value="http://highmed.org/fhir/CodeSystem/process-authorization" /> + <code value="REMOTE_ALL" /> + </valueCoding> + </extension> + <extension url="recipient"> + <valueCoding> + <system value="http://highmed.org/fhir/CodeSystem/process-authorization" /> + <code value="LOCAL_ALL" /> + </valueCoding> + </extension> </extension> <url value="http://highmed.org/bpe/Process/pong" /> <!-- version managed by bpe --> <version value="${version}" /> - <name value="pong" /> + <name value="Pong" /> <title value="PONG process" /> <subtitle value="Communication Testing Process" /> <!-- status managed by bpe --> <status value="unknown" /> <experimental value="false" /> - <date value="2021-01-26" /> + <date value="2021-06-08" /> <publisher value="HiGHmed" /> <contact> <name value="HiGHmed" /> @@ -67,6 +43,6 @@ <value value="pmo@highmed.org" /> </telecom> </contact> - <description value="Process startet by PING messages and to send corresponding PONG messages back remote Organizations" /> + <description value="Process startet by PING messages and to send corresponding PONG messages back to remote Organizations" /> <kind value="Task" /> </ActivityDefinition> \ No newline at end of file diff --git a/dsf-bpe-process-ping/src/main/resources/fhir/StructureDefinition/highmed-task-ping.xml b/dsf-bpe-process-ping/src/main/resources/fhir/StructureDefinition/highmed-task-ping.xml index 1acf758e..a5eca4f7 100644 --- a/dsf-bpe-process-ping/src/main/resources/fhir/StructureDefinition/highmed-task-ping.xml +++ b/dsf-bpe-process-ping/src/main/resources/fhir/StructureDefinition/highmed-task-ping.xml @@ -1,8 +1,8 @@ <StructureDefinition xmlns="http://hl7.org/fhir"> <meta> <tag> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="REMOTE" /> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag" /> + <code value="ALL" /> </tag> </meta> <url value="http://highmed.org/fhir/StructureDefinition/task-ping" /> @@ -12,7 +12,7 @@ <!-- status managed by bpe --> <status value="unknown" /> <experimental value="false" /> - <date value="2021-01-26" /> + <date value="2021-06-08" /> <fhirVersion value="4.0.1" /> <kind value="resource" /> <abstract value="false" /> diff --git a/dsf-bpe-process-ping/src/main/resources/fhir/StructureDefinition/highmed-task-pong.xml b/dsf-bpe-process-ping/src/main/resources/fhir/StructureDefinition/highmed-task-pong.xml index a7ec929c..0c7dc81a 100644 --- a/dsf-bpe-process-ping/src/main/resources/fhir/StructureDefinition/highmed-task-pong.xml +++ b/dsf-bpe-process-ping/src/main/resources/fhir/StructureDefinition/highmed-task-pong.xml @@ -1,8 +1,8 @@ <StructureDefinition xmlns="http://hl7.org/fhir"> <meta> <tag> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="REMOTE" /> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag" /> + <code value="ALL" /> </tag> </meta> <url value="http://highmed.org/fhir/StructureDefinition/task-pong" /> @@ -12,7 +12,7 @@ <!-- status managed by bpe --> <status value="unknown" /> <experimental value="false" /> - <date value="2021-01-26" /> + <date value="2021-06-08" /> <fhirVersion value="4.0.1" /> <kind value="resource" /> <abstract value="false" /> diff --git a/dsf-bpe-process-ping/src/main/resources/fhir/StructureDefinition/highmed-task-start-ping-process.xml b/dsf-bpe-process-ping/src/main/resources/fhir/StructureDefinition/highmed-task-start-ping-process.xml index 82d5f3c7..e81f8374 100644 --- a/dsf-bpe-process-ping/src/main/resources/fhir/StructureDefinition/highmed-task-start-ping-process.xml +++ b/dsf-bpe-process-ping/src/main/resources/fhir/StructureDefinition/highmed-task-start-ping-process.xml @@ -1,8 +1,8 @@ <StructureDefinition xmlns="http://hl7.org/fhir"> <meta> <tag> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="REMOTE" /> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag" /> + <code value="ALL" /> </tag> </meta> <url value="http://highmed.org/fhir/StructureDefinition/task-start-ping-process" /> @@ -12,7 +12,7 @@ <!-- status managed by bpe --> <status value="unknown" /> <experimental value="false" /> - <date value="2021-01-26" /> + <date value="2021-06-08" /> <fhirVersion value="4.0.1" /> <kind value="resource" /> <abstract value="false" /> diff --git a/dsf-bpe-process-ping/src/test/java/org/highmed/dsf/bpe/start/AbstractPing3MedicFromTtpExampleStarter.java b/dsf-bpe-process-ping/src/test/java/org/highmed/dsf/bpe/start/AbstractPing3MedicFromTtpExampleStarter.java new file mode 100644 index 00000000..ee760643 --- /dev/null +++ b/dsf-bpe-process-ping/src/test/java/org/highmed/dsf/bpe/start/AbstractPing3MedicFromTtpExampleStarter.java @@ -0,0 +1,47 @@ +package org.highmed.dsf.bpe.start; + +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN; +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME; +import static org.highmed.dsf.bpe.ConstantsBase.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER; +import static org.highmed.dsf.bpe.ConstantsPing.PROFILE_HIGHMED_TASK_PING_PROCESS_URI_AND_LATEST_VERSION; +import static org.highmed.dsf.bpe.ConstantsPing.PROFILE_HIGHMED_TASK_START_PING; +import static org.highmed.dsf.bpe.ConstantsPing.PROFILE_HIGHMED_TASK_START_PING_MESSAGE_NAME; +import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_TTP; + +import java.util.Date; + +import org.hl7.fhir.r4.model.ResourceType; +import org.hl7.fhir.r4.model.StringType; +import org.hl7.fhir.r4.model.Task; +import org.hl7.fhir.r4.model.Task.TaskIntent; +import org.hl7.fhir.r4.model.Task.TaskStatus; + +public abstract class AbstractPing3MedicFromTtpExampleStarter +{ + protected void main(String[] args, String baseUrl) throws Exception + { + Task task = createStartResource(); + ExampleStarter.forServer(args, baseUrl).startWith(task); + } + + private Task createStartResource() + { + Task task = new Task(); + task.getMeta().addProfile(PROFILE_HIGHMED_TASK_START_PING); + task.setInstantiatesUri(PROFILE_HIGHMED_TASK_PING_PROCESS_URI_AND_LATEST_VERSION); + task.setStatus(TaskStatus.REQUESTED); + task.setIntent(TaskIntent.ORDER); + task.setAuthoredOn(new Date()); + task.getRequester().setType(ResourceType.Organization.name()).getIdentifier() + .setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER) + .setValue(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_TTP); + task.getRestriction().addRecipient().setType(ResourceType.Organization.name()).getIdentifier() + .setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER) + .setValue(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_TTP); + + task.addInput().setValue(new StringType(PROFILE_HIGHMED_TASK_START_PING_MESSAGE_NAME)).getType().addCoding() + .setSystem(CODESYSTEM_HIGHMED_BPMN).setCode(CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME); + + return task; + } +} diff --git a/dsf-bpe-process-ping/src/test/java/org/highmed/dsf/bpe/start/Ping3MedicFromTtpDockerExampleStarter.java b/dsf-bpe-process-ping/src/test/java/org/highmed/dsf/bpe/start/Ping3MedicFromTtpDockerExampleStarter.java new file mode 100644 index 00000000..815e80ef --- /dev/null +++ b/dsf-bpe-process-ping/src/test/java/org/highmed/dsf/bpe/start/Ping3MedicFromTtpDockerExampleStarter.java @@ -0,0 +1,15 @@ +package org.highmed.dsf.bpe.start; + +import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.TTP_DOCKER_FHIR_BASE_URL; + +public class Ping3MedicFromTtpDockerExampleStarter extends AbstractPing3MedicFromTtpExampleStarter +{ + // Environment variable "DSF_CLIENT_CERTIFICATE_PATH" or args[0]: the path to the client-certificate + // highmed-dsf/dsf-tools/dsf-tools-test-data-generator/cert/Webbrowser_Test_User/Webbrowser_Test_User_certificate.p12 + // Environment variable "DSF_CLIENT_CERTIFICATE_PASSWORD" or args[1]: the password of the client-certificate + // password + public static void main(String[] args) throws Exception + { + new Ping3MedicFromTtpDockerExampleStarter().main(args, TTP_DOCKER_FHIR_BASE_URL); + } +} diff --git a/dsf-bpe-process-ping/src/test/java/org/highmed/dsf/bpe/start/Ping3MedicFromTtpExampleStarter.java b/dsf-bpe-process-ping/src/test/java/org/highmed/dsf/bpe/start/Ping3MedicFromTtpExampleStarter.java index f08d97d5..6a3041a3 100644 --- a/dsf-bpe-process-ping/src/test/java/org/highmed/dsf/bpe/start/Ping3MedicFromTtpExampleStarter.java +++ b/dsf-bpe-process-ping/src/test/java/org/highmed/dsf/bpe/start/Ping3MedicFromTtpExampleStarter.java @@ -1,23 +1,8 @@ package org.highmed.dsf.bpe.start; -import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN; -import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME; -import static org.highmed.dsf.bpe.ConstantsBase.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER; -import static org.highmed.dsf.bpe.ConstantsPing.PROFILE_HIGHMED_TASK_PING_PROCESS_URI_AND_LATEST_VERSION; -import static org.highmed.dsf.bpe.ConstantsPing.PROFILE_HIGHMED_TASK_START_PING; -import static org.highmed.dsf.bpe.ConstantsPing.PROFILE_HIGHMED_TASK_START_PING_MESSAGE_NAME; -import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_TTP; import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.TTP_FHIR_BASE_URL; -import java.util.Date; - -import org.hl7.fhir.r4.model.ResourceType; -import org.hl7.fhir.r4.model.StringType; -import org.hl7.fhir.r4.model.Task; -import org.hl7.fhir.r4.model.Task.TaskIntent; -import org.hl7.fhir.r4.model.Task.TaskStatus; - -public class Ping3MedicFromTtpExampleStarter +public class Ping3MedicFromTtpExampleStarter extends AbstractPing3MedicFromTtpExampleStarter { // Environment variable "DSF_CLIENT_CERTIFICATE_PATH" or args[0]: the path to the client-certificate // highmed-dsf/dsf-tools/dsf-tools-test-data-generator/cert/Webbrowser_Test_User/Webbrowser_Test_User_certificate.p12 @@ -25,28 +10,6 @@ public class Ping3MedicFromTtpExampleStarter // password public static void main(String[] args) throws Exception { - Task task = createStartResource(); - ExampleStarter.forServer(args, TTP_FHIR_BASE_URL).startWith(task); - } - - private static Task createStartResource() - { - Task task = new Task(); - task.getMeta().addProfile(PROFILE_HIGHMED_TASK_START_PING); - task.setInstantiatesUri(PROFILE_HIGHMED_TASK_PING_PROCESS_URI_AND_LATEST_VERSION); - task.setStatus(TaskStatus.REQUESTED); - task.setIntent(TaskIntent.ORDER); - task.setAuthoredOn(new Date()); - task.getRequester().setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER) - .setValue(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_TTP); - task.getRestriction().addRecipient().setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER) - .setValue(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_TTP); - - task.addInput().setValue(new StringType(PROFILE_HIGHMED_TASK_START_PING_MESSAGE_NAME)).getType().addCoding() - .setSystem(CODESYSTEM_HIGHMED_BPMN).setCode(CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME); - - return task; + new Ping3MedicFromTtpExampleStarter().main(args, TTP_FHIR_BASE_URL); } } diff --git a/dsf-bpe-process-ping/src/test/java/org/highmed/dsf/fhir/profiles/ActivityDefinitionProfileTest.java b/dsf-bpe-process-ping/src/test/java/org/highmed/dsf/fhir/profiles/ActivityDefinitionProfileTest.java new file mode 100644 index 00000000..36e45fae --- /dev/null +++ b/dsf-bpe-process-ping/src/test/java/org/highmed/dsf/fhir/profiles/ActivityDefinitionProfileTest.java @@ -0,0 +1,89 @@ +package org.highmed.dsf.fhir.profiles; + +import static org.highmed.dsf.bpe.PingProcessPluginDefinition.VERSION; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; + +import org.highmed.dsf.fhir.authorization.process.ProcessAuthorizationHelper; +import org.highmed.dsf.fhir.authorization.process.ProcessAuthorizationHelperImpl; +import org.highmed.dsf.fhir.validation.ResourceValidator; +import org.highmed.dsf.fhir.validation.ResourceValidatorImpl; +import org.highmed.dsf.fhir.validation.ValidationSupportRule; +import org.hl7.fhir.r4.model.ActivityDefinition; +import org.junit.ClassRule; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import ca.uhn.fhir.validation.ResultSeverityEnum; +import ca.uhn.fhir.validation.ValidationResult; + +public class ActivityDefinitionProfileTest +{ + private static final Logger logger = LoggerFactory.getLogger(ActivityDefinitionProfileTest.class); + + @ClassRule + public static final ValidationSupportRule validationRule = new ValidationSupportRule(VERSION, + Arrays.asList("highmed-activity-definition-0.5.0.xml", "highmed-extension-process-authorization-0.5.0.xml", + "highmed-extension-process-authorization-consortium-role-0.5.0.xml", + "highmed-extension-process-authorization-organization-0.5.0.xml", + "highmed-coding-process-authorization-local-all-0.5.0.xml", + "highmed-coding-process-authorization-local-consortium-role-0.5.0.xml", + "highmed-coding-process-authorization-local-organization-0.5.0.xml", + "highmed-coding-process-authorization-remote-all-0.5.0.xml", + "highmed-coding-process-authorization-remote-consortium-role-0.5.0.xml", + "highmed-coding-process-authorization-remote-organization-0.5.0.xml"), + Arrays.asList("highmed-read-access-tag-0.5.0.xml", "highmed-process-authorization-0.5.0.xml"), + Arrays.asList("highmed-read-access-tag-0.5.0.xml", "highmed-process-authorization-recipient-0.5.0.xml", + "highmed-process-authorization-requester-0.5.0.xml")); + + private final ResourceValidator resourceValidator = new ResourceValidatorImpl(validationRule.getFhirContext(), + validationRule.getValidationSupport()); + + private final ProcessAuthorizationHelper processAuthorizationHelper = new ProcessAuthorizationHelperImpl(); + + @Test + public void testPingValid() throws Exception + { + try (InputStream in = Files + .newInputStream(Paths.get("src/main/resources/fhir/ActivityDefinition/highmed-ping.xml"))) + { + ActivityDefinition ad = validationRule.getFhirContext().newXmlParser() + .parseResource(ActivityDefinition.class, in); + + ValidationResult result = resourceValidator.validate(ad); + ValidationSupportRule.logValidationMessages(logger, result); + + assertEquals(0, result.getMessages().stream().filter(m -> ResultSeverityEnum.ERROR.equals(m.getSeverity()) + || ResultSeverityEnum.FATAL.equals(m.getSeverity())).count()); + + assertTrue( + processAuthorizationHelper.isValid(ad, taskProfile -> true, orgIdentifier -> true, role -> true)); + } + } + + @Test + public void testPongValid() throws Exception + { + try (InputStream in = Files + .newInputStream(Paths.get("src/main/resources/fhir/ActivityDefinition/highmed-pong.xml"))) + { + ActivityDefinition ad = validationRule.getFhirContext().newXmlParser() + .parseResource(ActivityDefinition.class, in); + + ValidationResult result = resourceValidator.validate(ad); + ValidationSupportRule.logValidationMessages(logger, result); + + assertEquals(0, result.getMessages().stream().filter(m -> ResultSeverityEnum.ERROR.equals(m.getSeverity()) + || ResultSeverityEnum.FATAL.equals(m.getSeverity())).count()); + + assertTrue( + processAuthorizationHelper.isValid(ad, taskProfile -> true, orgIdentifier -> true, role -> true)); + } + } +} \ No newline at end of file diff --git a/dsf-bpe-process-ping/src/test/java/org/highmed/dsf/fhir/profiles/TaskProfileTest.java b/dsf-bpe-process-ping/src/test/java/org/highmed/dsf/fhir/profiles/TaskProfileTest.java index d704ab05..a89d86dd 100644 --- a/dsf-bpe-process-ping/src/test/java/org/highmed/dsf/fhir/profiles/TaskProfileTest.java +++ b/dsf-bpe-process-ping/src/test/java/org/highmed/dsf/fhir/profiles/TaskProfileTest.java @@ -44,8 +44,8 @@ public class TaskProfileTest public static final ValidationSupportRule validationRule = new ValidationSupportRule(VERSION, Arrays.asList("highmed-task-base-0.5.0.xml", "highmed-task-start-ping-process.xml", "highmed-task-ping.xml", "highmed-task-pong.xml"), - Arrays.asList("highmed-authorization-role-0.5.0.xml", "highmed-bpmn-message-0.5.0.xml"), - Arrays.asList("highmed-authorization-role-0.5.0.xml", "highmed-bpmn-message-0.5.0.xml")); + Arrays.asList("highmed-read-access-tag-0.5.0.xml", "highmed-bpmn-message-0.5.0.xml"), + Arrays.asList("highmed-read-access-tag-0.5.0.xml", "highmed-bpmn-message-0.5.0.xml")); private ResourceValidator resourceValidator = new ResourceValidatorImpl(validationRule.getFhirContext(), validationRule.getValidationSupport()); diff --git a/dsf-bpe-process-update-allow-list/pom.xml b/dsf-bpe-process-update-allow-list/pom.xml index 1a4fdb32..0200b57e 100644 --- a/dsf-bpe-process-update-allow-list/pom.xml +++ b/dsf-bpe-process-update-allow-list/pom.xml @@ -63,7 +63,7 @@ <version>${project.version}</version> </artifactItem> </artifactItems> - <outputDirectory>${dsf.location}/dsf-docker-test-setup/bpe/app/process</outputDirectory> + <outputDirectory>${dsf.location}/dsf-docker-test-setup/bpe/process</outputDirectory> </configuration> </execution> <execution> @@ -80,7 +80,7 @@ <version>${project.version}</version> </artifactItem> </artifactItems> - <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic1/bpe/app/process</outputDirectory> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic1/bpe/process</outputDirectory> </configuration> </execution> <execution> @@ -97,7 +97,7 @@ <version>${project.version}</version> </artifactItem> </artifactItems> - <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic2/bpe/app/process</outputDirectory> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic2/bpe/process</outputDirectory> </configuration> </execution> <execution> @@ -114,7 +114,7 @@ <version>${project.version}</version> </artifactItem> </artifactItems> - <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic3/bpe/app/process</outputDirectory> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic3/bpe/process</outputDirectory> </configuration> </execution> <execution> @@ -131,7 +131,79 @@ <version>${project.version}</version> </artifactItem> </artifactItems> - <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/ttp/bpe/app/process</outputDirectory> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/ttp/bpe/process</outputDirectory> + </configuration> + </execution> + <execution> + <id>copy-process-to-docker-test-setup-3medic-ttp-docker/medic1</id> + <phase>package</phase> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>${project.groupId}</groupId> + <artifactId>${project.artifactId}</artifactId> + <version>${project.version}</version> + </artifactItem> + </artifactItems> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/medic1/bpe/process + </outputDirectory> + </configuration> + </execution> + <execution> + <id>copy-process-to-docker-test-setup-3medic-ttp-docker/medic2</id> + <phase>package</phase> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>${project.groupId}</groupId> + <artifactId>${project.artifactId}</artifactId> + <version>${project.version}</version> + </artifactItem> + </artifactItems> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/medic2/bpe/process + </outputDirectory> + </configuration> + </execution> + <execution> + <id>copy-process-to-docker-test-setup-3medic-ttp-docker/medic3</id> + <phase>package</phase> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>${project.groupId}</groupId> + <artifactId>${project.artifactId}</artifactId> + <version>${project.version}</version> + </artifactItem> + </artifactItems> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/medic3/bpe/process + </outputDirectory> + </configuration> + </execution> + <execution> + <id>copy-process-to-docker-test-setup-3medic-ttp-docker/ttp</id> + <phase>package</phase> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>${project.groupId}</groupId> + <artifactId>${project.artifactId}</artifactId> + <version>${project.version}</version> + </artifactItem> + </artifactItems> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/ttp/bpe/process + </outputDirectory> </configuration> </execution> </executions> @@ -142,35 +214,63 @@ <configuration> <filesets> <fileset> - <directory>${dsf.location}/dsf-docker-test-setup/bpe/app/process</directory> + <directory>${dsf.location}/dsf-docker-test-setup/bpe/process</directory> + <includes> + <include>${project.artifactId}-${project.version}.jar</include> + </includes> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic1/bpe/process</directory> + <includes> + <include>${project.artifactId}-${project.version}.jar</include> + </includes> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic2/bpe/process</directory> + <includes> + <include>${project.artifactId}-${project.version}.jar</include> + </includes> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic3/bpe/process</directory> + <includes> + <include>${project.artifactId}-${project.version}.jar</include> + </includes> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/ttp/bpe/process</directory> <includes> <include>${project.artifactId}-${project.version}.jar</include> </includes> <followSymlinks>false</followSymlinks> </fileset> <fileset> - <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic1/bpe/app/process</directory> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/medic1/bpe/process</directory> <includes> <include>${project.artifactId}-${project.version}.jar</include> </includes> <followSymlinks>false</followSymlinks> </fileset> <fileset> - <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic2/bpe/app/process</directory> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/medic2/bpe/process</directory> <includes> <include>${project.artifactId}-${project.version}.jar</include> </includes> <followSymlinks>false</followSymlinks> </fileset> <fileset> - <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic3/bpe/app/process</directory> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/medic3/bpe/process</directory> <includes> <include>${project.artifactId}-${project.version}.jar</include> </includes> <followSymlinks>false</followSymlinks> </fileset> <fileset> - <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/ttp/bpe/app/process</directory> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/ttp/bpe/process</directory> <includes> <include>${project.artifactId}-${project.version}.jar</include> </includes> diff --git a/dsf-bpe-process-update-allow-list/src/main/java/org/highmed/dsf/bpe/ConstantsUpdateAllowList.java b/dsf-bpe-process-update-allow-list/src/main/java/org/highmed/dsf/bpe/ConstantsUpdateAllowList.java index 56a226c4..2e0c3e33 100644 --- a/dsf-bpe-process-update-allow-list/src/main/java/org/highmed/dsf/bpe/ConstantsUpdateAllowList.java +++ b/dsf-bpe-process-update-allow-list/src/main/java/org/highmed/dsf/bpe/ConstantsUpdateAllowList.java @@ -6,7 +6,7 @@ public interface ConstantsUpdateAllowList { String CODESYSTEM_HIGHMED_UPDATE_ALLOW_LIST = "http://highmed.org/fhir/CodeSystem/update-allow-list"; - String CODESYSTEM_HIGHMED_UPDATE_ALLOW_LIST_VALUE_ALLOW_LIST = "highmed_allow_list"; + String CODESYSTEM_HIGHMED_UPDATE_ALLOW_LIST_VALUE_ALLOW_LIST = "allow_list"; String PROFILE_HIGHMED_TASK_DOWNLOAD_ALLOW_LIST = "http://highmed.org/fhir/StructureDefinition/task-download-allow-list"; String PROFILE_HIGHMED_TASK_DOWNLOAD_ALLOW_LIST_PROCESS_URI = PROCESS_HIGHMED_URI_BASE + "downloadAllowList/"; diff --git a/dsf-bpe-process-update-allow-list/src/main/java/org/highmed/dsf/bpe/UpdateAllowListProcessPluginDefinition.java b/dsf-bpe-process-update-allow-list/src/main/java/org/highmed/dsf/bpe/UpdateAllowListProcessPluginDefinition.java index c2f1b9df..0f330987 100644 --- a/dsf-bpe-process-update-allow-list/src/main/java/org/highmed/dsf/bpe/UpdateAllowListProcessPluginDefinition.java +++ b/dsf-bpe-process-update-allow-list/src/main/java/org/highmed/dsf/bpe/UpdateAllowListProcessPluginDefinition.java @@ -12,6 +12,7 @@ import org.highmed.dsf.fhir.resources.ResourceProvider; import org.highmed.dsf.fhir.resources.StructureDefinitionResource; import org.highmed.dsf.fhir.resources.ValueSetResource; +import org.springframework.core.env.PropertyResolver; import ca.uhn.fhir.context.FhirContext; @@ -44,7 +45,8 @@ public Stream<Class<?>> getSpringConfigClasses() } @Override - public ResourceProvider getResourceProvider(FhirContext fhirContext, ClassLoader classLoader) + public ResourceProvider getResourceProvider(FhirContext fhirContext, ClassLoader classLoader, + PropertyResolver resolver) { var aDown = ActivityDefinitionResource.file("fhir/ActivityDefinition/highmed-downloadAllowList.xml"); var aUp = ActivityDefinitionResource.file("fhir/ActivityDefinition/highmed-updateAllowList.xml"); @@ -53,10 +55,11 @@ public ResourceProvider getResourceProvider(FhirContext fhirContext, ClassLoader var sUp = StructureDefinitionResource.file("fhir/StructureDefinition/highmed-task-update-allow-list.xml"); var v = ValueSetResource.file("fhir/ValueSet/highmed-update-allow-list.xml"); - Map<String, List<AbstractResource>> resourcesByProcessKeyAndVersion = Map.of("downloadAllowList/" + VERSION, - Arrays.asList(aDown, c, sDown, v), "updateAllowList/" + VERSION, Arrays.asList(aUp, c, sUp, v)); + Map<String, List<AbstractResource>> resourcesByProcessKeyAndVersion = Map.of( + "highmedorg_downloadAllowList/" + VERSION, Arrays.asList(aDown, c, sDown, v), + "highmedorg_updateAllowList/" + VERSION, Arrays.asList(aUp, c, sUp, v)); return ResourceProvider.read(VERSION, () -> fhirContext.newXmlParser().setStripVersionsFromReferences(false), - classLoader, resourcesByProcessKeyAndVersion); + classLoader, resolver, resourcesByProcessKeyAndVersion); } } diff --git a/dsf-bpe-process-update-allow-list/src/main/java/org/highmed/dsf/bpe/service/DownloadAllowList.java b/dsf-bpe-process-update-allow-list/src/main/java/org/highmed/dsf/bpe/service/DownloadAllowList.java index f59d3411..7945405e 100644 --- a/dsf-bpe-process-update-allow-list/src/main/java/org/highmed/dsf/bpe/service/DownloadAllowList.java +++ b/dsf-bpe-process-update-allow-list/src/main/java/org/highmed/dsf/bpe/service/DownloadAllowList.java @@ -12,6 +12,7 @@ import org.camunda.bpm.engine.delegate.DelegateExecution; import org.highmed.dsf.bpe.delegate.AbstractServiceDelegate; +import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper; import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider; import org.highmed.dsf.fhir.task.TaskHelper; import org.highmed.fhir.client.FhirWebserviceClient; @@ -31,9 +32,11 @@ public class DownloadAllowList extends AbstractServiceDelegate private final FhirContext context; - public DownloadAllowList(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, FhirContext context) + public DownloadAllowList(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, + ReadAccessHelper readAccessHelper, FhirContext context) { - super(clientProvider, taskHelper); + super(clientProvider, taskHelper, readAccessHelper); + this.context = context; } @@ -50,7 +53,7 @@ protected void doExecute(DelegateExecution execution) throws Exception Task task = getCurrentTaskFromExecutionVariables(); IdType bundleId = getBundleId(task); FhirWebserviceClient requesterClient = getFhirWebserviceClientProvider() - .getRemoteWebserviceClient(bundleId.getBaseUrl()); + .getWebserviceClient(bundleId.getBaseUrl()); Bundle bundle; try diff --git a/dsf-bpe-process-update-allow-list/src/main/java/org/highmed/dsf/bpe/service/UpdateAllowList.java b/dsf-bpe-process-update-allow-list/src/main/java/org/highmed/dsf/bpe/service/UpdateAllowList.java index 5c8d6a04..cc72a034 100644 --- a/dsf-bpe-process-update-allow-list/src/main/java/org/highmed/dsf/bpe/service/UpdateAllowList.java +++ b/dsf-bpe-process-update-allow-list/src/main/java/org/highmed/dsf/bpe/service/UpdateAllowList.java @@ -1,34 +1,34 @@ package org.highmed.dsf.bpe.service; import static org.highmed.dsf.bpe.ConstantsBase.NAMINGSYSTEM_HIGHMED_ENDPOINT_IDENTIFIER; +import static org.highmed.dsf.bpe.ConstantsBase.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER; import static org.highmed.dsf.bpe.ConstantsUpdateAllowList.CODESYSTEM_HIGHMED_UPDATE_ALLOW_LIST; import static org.highmed.dsf.bpe.ConstantsUpdateAllowList.CODESYSTEM_HIGHMED_UPDATE_ALLOW_LIST_VALUE_ALLOW_LIST; import java.util.Collections; +import java.util.List; import java.util.Map; -import java.util.Objects; -import java.util.Optional; import java.util.UUID; -import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Collectors; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.highmed.dsf.bpe.delegate.AbstractServiceDelegate; +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.TaskHelper; import org.highmed.fhir.client.FhirWebserviceClient; import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent; import org.hl7.fhir.r4.model.Bundle.BundleType; import org.hl7.fhir.r4.model.Bundle.HTTPVerb; -import org.hl7.fhir.r4.model.Bundle.SearchEntryMode; import org.hl7.fhir.r4.model.Endpoint; import org.hl7.fhir.r4.model.IdType; import org.hl7.fhir.r4.model.Identifier; import org.hl7.fhir.r4.model.Organization; +import org.hl7.fhir.r4.model.OrganizationAffiliation; import org.hl7.fhir.r4.model.Reference; +import org.hl7.fhir.r4.model.Resource; import org.hl7.fhir.r4.model.Task; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,22 +40,10 @@ public class UpdateAllowList extends AbstractServiceDelegate implements Initiali { private static final Logger logger = LoggerFactory.getLogger(UpdateAllowList.class); - private final OrganizationProvider organizationProvider; - - public UpdateAllowList(OrganizationProvider organizationProvider, FhirWebserviceClientProvider clientProvider, - TaskHelper taskHelper) - { - super(clientProvider, taskHelper); - - this.organizationProvider = organizationProvider; - } - - @Override - public void afterPropertiesSet() throws Exception + public UpdateAllowList(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, + ReadAccessHelper readAccessHelper) { - super.afterPropertiesSet(); - - Objects.requireNonNull(organizationProvider, "organizationProvider"); + super(clientProvider, taskHelper, readAccessHelper); } @Override @@ -65,18 +53,35 @@ public void doExecute(DelegateExecution execution) throws Exception Bundle searchSet = client.searchWithStrictHandling(Organization.class, Map.of("active", Collections.singletonList("true"), "identifier", - Collections.singletonList(organizationProvider.getDefaultIdentifierSystem() + "|"), "_include", - Collections.singletonList("Organization:endpoint"))); + Collections.singletonList(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER + "|"), "_include", + Collections.singletonList("Organization:endpoint"), "_revinclude", + Collections.singletonList("OrganizationAffiliation:participating-organization"))); + + Map<String, String> identifierByTypeAndId = searchSet.getEntry().stream() + .filter(BundleEntryComponent::hasResource).map(BundleEntryComponent::getResource) + .filter(r -> r instanceof Organization || r instanceof Endpoint).filter(Resource::hasIdElement) + .collect(Collectors.toMap(r -> r.getIdElement().toUnqualifiedVersionless().getValue(), + this::getIdentifierValue)); + Map<String, String> tempIdsByTypeAndId = searchSet.getEntry().stream().filter(BundleEntryComponent::hasResource) + .map(BundleEntryComponent::getResource) + .filter(r -> r instanceof Organization || r instanceof Endpoint || r instanceof OrganizationAffiliation) + .filter(Resource::hasIdElement) + .collect(Collectors.toMap(r -> r.getIdElement().toUnqualifiedVersionless().getValue(), + r -> "urn:uuid:" + UUID.randomUUID().toString())); Bundle transaction = new Bundle().setType(BundleType.TRANSACTION); - transaction.getMeta().addTag().setSystem("http://highmed.org/fhir/CodeSystem/authorization-role") - .setCode("REMOTE"); + + getReadAccessHelper().addAll(transaction); + transaction.getIdentifier().setSystem(CODESYSTEM_HIGHMED_UPDATE_ALLOW_LIST) .setValue(CODESYSTEM_HIGHMED_UPDATE_ALLOW_LIST_VALUE_ALLOW_LIST); - searchSet.getEntry().stream() - .filter(e -> e.hasSearch() && SearchEntryMode.MATCH.equals(e.getSearch().getMode()) && e.hasResource() - && e.getResource() instanceof Organization) - .map(e -> (Organization) e.getResource()).forEach(addAllowListEntry(transaction, searchSet)); + + List<BundleEntryComponent> entries = searchSet.getEntry().stream().filter(BundleEntryComponent::hasResource) + .map(BundleEntryComponent::getResource) + .filter(r -> r instanceof Organization || r instanceof Endpoint || r instanceof OrganizationAffiliation) + .map(toAllowListBundleEntry(identifierByTypeAndId, tempIdsByTypeAndId)).collect(Collectors.toList()); + + transaction.setEntry(entries); logger.debug("Uploading new allow list transaction bundle: {}", FhirContext.forR4().newJsonParser().encodeResourceToString(transaction)); @@ -91,67 +96,143 @@ public void doExecute(DelegateExecution execution) throws Exception .setCode(CODESYSTEM_HIGHMED_UPDATE_ALLOW_LIST_VALUE_ALLOW_LIST); } - private Consumer<? super Organization> addAllowListEntry(Bundle transaction, Bundle searchSet) + private String getIdentifierValue(Resource resource) { - return organization -> - { - Identifier identifier = getDefaultIdentifier(organization).get(); - - BundleEntryComponent organizationEntry = transaction.addEntry(); - String organizationId = "urn:uuid:" + UUID.randomUUID(); - organizationEntry.setFullUrl(organizationId); - organizationEntry.getRequest().setMethod(HTTPVerb.PUT) - .setUrl("Organization?identifier=" + identifier.getSystem() + "|" + identifier.getValue()); - - organization.setIdElement(new IdType(organizationId)); - organization.getMeta().setVersionIdElement(null).setLastUpdatedElement(null); - organizationEntry.setResource(organization); - - organization.setEndpoint(organization.getEndpoint().stream() - .map(addAllowListEntryReturnReference(transaction, organizationId, searchSet)) - .filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList())); - }; + if (resource instanceof Organization) + return ((Organization) resource).getIdentifier().stream().filter(Identifier::hasSystem) + .filter(i -> NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER.equals(i.getSystem())).findFirst() + .filter(Identifier::hasValue).map(Identifier::getValue) + .orElseThrow(() -> new RuntimeException("Organization is missing identifier value with system " + + NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER)); + else if (resource instanceof Endpoint) + return ((Endpoint) resource).getIdentifier().stream().filter(Identifier::hasSystem) + .filter(i -> NAMINGSYSTEM_HIGHMED_ENDPOINT_IDENTIFIER.equals(i.getSystem())).findFirst() + .filter(Identifier::hasValue).map(Identifier::getValue) + .orElseThrow(() -> new RuntimeException("Endpoint is missing identifier value with system " + + NAMINGSYSTEM_HIGHMED_ENDPOINT_IDENTIFIER)); + else + throw new IllegalStateException("Organization or Endpoint expected"); } - private Function<Reference, Optional<Reference>> addAllowListEntryReturnReference(Bundle transaction, - String organizationId, Bundle searchSet) + private Function<Resource, BundleEntryComponent> toAllowListBundleEntry(Map<String, String> identifierByTypeAndId, + Map<String, String> tempIdsByTypeAndId) { - return endpointRef -> getEndpoint(endpointRef, searchSet).map(endpoint -> + return resource -> { - Identifier identifier = getDefaultIdentifier(endpoint).get(); + if (resource instanceof Organization) + return toOrganizationEntry((Organization) resource, identifierByTypeAndId, tempIdsByTypeAndId); + else if (resource instanceof Endpoint) + return toEndpointEntry((Endpoint) resource, identifierByTypeAndId, tempIdsByTypeAndId); + else if (resource instanceof OrganizationAffiliation) + return toOrganizationAffiliationEntry((OrganizationAffiliation) resource, identifierByTypeAndId, + tempIdsByTypeAndId); + else + throw new IllegalStateException("Organization, Endpoint or OrganizationAffiliation expected"); + }; + } - BundleEntryComponent endpointEntry = transaction.addEntry(); - String endpointId = "urn:uuid:" + UUID.randomUUID(); - endpointEntry.setFullUrl(endpointId); - endpointEntry.getRequest().setMethod(HTTPVerb.PUT) - .setUrl("Endpoint?identifier=" + identifier.getSystem() + "|" + identifier.getValue()); + private BundleEntryComponent toOrganizationEntry(Organization organization, + Map<String, String> identifierByTypeAndId, Map<String, String> tempIdsByTypeAndId) + { + String typeAndId = organization.getIdElement().toUnqualifiedVersionless().getValue(); + String uuid = tempIdsByTypeAndId.get(typeAndId); + String organizationIdentifier = identifierByTypeAndId.get(typeAndId); - endpoint.setIdElement(new IdType(endpointId)); - endpoint.getMeta().setVersionIdElement(null).setLastUpdatedElement(null); - endpoint.setManagingOrganization(new Reference().setReference(organizationId).setType("Organization")); - endpointEntry.setResource(endpoint); + organization.setIdElement(new IdType(uuid)); + organization.getMeta().setVersionIdElement(null).setLastUpdatedElement(null); - return new Reference().setReference(endpointId).setType("Endpoint"); - }); + if (organization.hasEndpoint()) + { + List<Reference> endpoints = organization.getEndpoint().stream() + .map(e -> tempIdsByTypeAndId.get(e.getReference())) + .map(tempId -> new Reference().setType("Endpoint").setReference(tempId)) + .collect(Collectors.toList()); + organization.setEndpoint(endpoints); + } + + BundleEntryComponent entry = new BundleEntryComponent(); + entry.setFullUrl(uuid); + entry.setResource(organization); + entry.getRequest().setMethod(HTTPVerb.PUT).setUrl("Organization?identifier=" + + NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER + "|" + organizationIdentifier); + return entry; } - private Optional<Identifier> getDefaultIdentifier(Organization org) + private BundleEntryComponent toEndpointEntry(Endpoint endpoint, Map<String, String> identifierByTypeAndId, + Map<String, String> tempIdsByTypeAndId) { - return org.getIdentifier().stream() - .filter(i -> organizationProvider.getDefaultIdentifierSystem().equals(i.getSystem())).findFirst(); - } + String typeAndId = endpoint.getIdElement().toUnqualifiedVersionless().getValue(); + String uuid = tempIdsByTypeAndId.get(typeAndId); + String endpointIdentifier = identifierByTypeAndId.get(typeAndId); - private Optional<Identifier> getDefaultIdentifier(Endpoint ept) - { - return ept.getIdentifier().stream().filter(i -> NAMINGSYSTEM_HIGHMED_ENDPOINT_IDENTIFIER.equals(i.getSystem())) - .findFirst(); + endpoint.setIdElement(new IdType(uuid)); + endpoint.getMeta().setVersionIdElement(null).setLastUpdatedElement(null); + + if (endpoint.hasManagingOrganization()) + { + String organizationTempId = tempIdsByTypeAndId.get(endpoint.getManagingOrganization().getReference()); + endpoint.setManagingOrganization(new Reference().setType("Organization").setReference(organizationTempId)); + } + + BundleEntryComponent entry = new BundleEntryComponent(); + entry.setFullUrl(uuid); + entry.setResource(endpoint); + entry.getRequest().setMethod(HTTPVerb.PUT) + .setUrl("Endpoint?identifier=" + NAMINGSYSTEM_HIGHMED_ENDPOINT_IDENTIFIER + "|" + endpointIdentifier); + return entry; } - private Optional<Endpoint> getEndpoint(Reference endpoint, Bundle searchSet) + private BundleEntryComponent toOrganizationAffiliationEntry(OrganizationAffiliation affiliation, + Map<String, String> identifierByTypeAndId, Map<String, String> tempIdsByTypeAndId) { - return searchSet.getEntry().stream() - .filter(e -> e.hasResource() && e.getResource() instanceof Endpoint - && e.getFullUrl().endsWith(endpoint.getReference())) - .map(e -> (Endpoint) e.getResource()).findFirst(); + String uuid = tempIdsByTypeAndId.get(affiliation.getIdElement().toUnqualifiedVersionless().getValue()); + + affiliation.setIdElement(new IdType(uuid)); + affiliation.getMeta().setVersionIdElement(null).setLastUpdatedElement(null); + + String primaryOrganizatioIdentifier; + if (affiliation.hasOrganization()) + { + String ref = affiliation.getOrganization().getReference(); + primaryOrganizatioIdentifier = identifierByTypeAndId.get(ref); + String primaryOrganizationTempId = tempIdsByTypeAndId.get(ref); + + affiliation + .setOrganization(new Reference().setType("Organization").setReference(primaryOrganizationTempId)); + } + else + throw new IllegalStateException("OrganizationAffiliation with primary organization expected"); + + String participatingOrganizationIdentifier; + if (affiliation.hasParticipatingOrganization()) + { + String ref = affiliation.getParticipatingOrganization().getReference(); + participatingOrganizationIdentifier = identifierByTypeAndId.get(ref); + String participatingOrganizationTempId = tempIdsByTypeAndId.get(ref); + + affiliation.setParticipatingOrganization( + new Reference().setType("Organization").setReference(participatingOrganizationTempId)); + } + else + throw new IllegalStateException("OrganizationAffiliation with participating organization expected"); + + if (affiliation.hasEndpoint()) + { + List<Reference> endpoints = affiliation.getEndpoint().stream() + .map(e -> tempIdsByTypeAndId.get(e.getReference())) + .map(tempId -> new Reference().setType("Endpoint").setReference(tempId)) + .collect(Collectors.toList()); + affiliation.setEndpoint(endpoints); + } + + BundleEntryComponent entry = new BundleEntryComponent(); + entry.setFullUrl(uuid); + entry.setResource(affiliation); + entry.getRequest().setMethod(HTTPVerb.PUT) + .setUrl("OrganizationAffiliation?primary-organization:identifier=" + + NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER + "|" + primaryOrganizatioIdentifier + + "&participating-organization:identifier=" + NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER + "|" + + participatingOrganizationIdentifier); + return entry; } } diff --git a/dsf-bpe-process-update-allow-list/src/main/java/org/highmed/dsf/bpe/spring/config/UpdateAllowListConfig.java b/dsf-bpe-process-update-allow-list/src/main/java/org/highmed/dsf/bpe/spring/config/UpdateAllowListConfig.java index 55702ba9..92a894ff 100644 --- a/dsf-bpe-process-update-allow-list/src/main/java/org/highmed/dsf/bpe/spring/config/UpdateAllowListConfig.java +++ b/dsf-bpe-process-update-allow-list/src/main/java/org/highmed/dsf/bpe/spring/config/UpdateAllowListConfig.java @@ -2,8 +2,8 @@ import org.highmed.dsf.bpe.service.DownloadAllowList; import org.highmed.dsf.bpe.service.UpdateAllowList; +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.TaskHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; @@ -18,10 +18,10 @@ public class UpdateAllowListConfig private FhirWebserviceClientProvider clientProvider; @Autowired - private OrganizationProvider organizationProvider; + private TaskHelper taskHelper; @Autowired - private TaskHelper taskHelper; + private ReadAccessHelper readAccessHelper; @Autowired private FhirContext fhirContext; @@ -29,12 +29,12 @@ public class UpdateAllowListConfig @Bean public UpdateAllowList updateAllowList() { - return new UpdateAllowList(organizationProvider, clientProvider, taskHelper); + return new UpdateAllowList(clientProvider, taskHelper, readAccessHelper); } @Bean public DownloadAllowList downloadAllowList() { - return new DownloadAllowList(clientProvider, taskHelper, fhirContext); + return new DownloadAllowList(clientProvider, taskHelper, readAccessHelper, fhirContext); } } diff --git a/dsf-bpe-process-update-allow-list/src/main/resources/bpe/downloadAllowList.bpmn b/dsf-bpe-process-update-allow-list/src/main/resources/bpe/downloadAllowList.bpmn index a325e15c..2ac200dd 100644 --- a/dsf-bpe-process-update-allow-list/src/main/resources/bpe/downloadAllowList.bpmn +++ b/dsf-bpe-process-update-allow-list/src/main/resources/bpe/downloadAllowList.bpmn @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1yb5vw3" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.2.0"> - <bpmn:process id="downloadAllowList" isExecutable="true" camunda:versionTag="0.5.0"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1yb5vw3" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.8.1"> + <bpmn:process id="highmedorg_downloadAllowList" isExecutable="true" camunda:versionTag="0.5.0"> <bpmn:sequenceFlow id="SequenceFlow_0bbhq2r" sourceRef="StartEvent_1" targetRef="downloadAllowListTask" /> <bpmn:endEvent id="EndEvent_0xd0x8k"> <bpmn:incoming>SequenceFlow_0oyvmcd</bpmn:incoming> @@ -17,7 +17,7 @@ </bpmn:process> <bpmn:message id="Message_1nn2wdw" name="downloadAllowListMessage" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> - <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="downloadAllowList"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="highmedorg_downloadAllowList"> <bpmndi:BPMNEdge id="SequenceFlow_0oyvmcd_di" bpmnElement="SequenceFlow_0oyvmcd"> <di:waypoint x="365" y="121" /> <di:waypoint x="415" y="121" /> diff --git a/dsf-bpe-process-update-allow-list/src/main/resources/bpe/updateAllowList.bpmn b/dsf-bpe-process-update-allow-list/src/main/resources/bpe/updateAllowList.bpmn index f3b5263b..58003231 100644 --- a/dsf-bpe-process-update-allow-list/src/main/resources/bpe/updateAllowList.bpmn +++ b/dsf-bpe-process-update-allow-list/src/main/resources/bpe/updateAllowList.bpmn @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1yb5vw3" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.5.0"> - <bpmn:process id="updateAllowList" isExecutable="true" camunda:versionTag="0.5.0"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1yb5vw3" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.8.1"> + <bpmn:process id="highmedorg_updateAllowList" isExecutable="true" camunda:versionTag="0.5.0"> <bpmn:sequenceFlow id="SequenceFlow_0bbhq2r" sourceRef="StartEvent_1" targetRef="updateAllowListTask" /> <bpmn:endEvent id="EndEvent_0xd0x8k"> <bpmn:incoming>SequenceFlow_0oyvmcd</bpmn:incoming> @@ -17,7 +17,11 @@ </bpmn:process> <bpmn:message id="Message_1nn2wdw" name="updateAllowListMessage" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> - <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="updateAllowList"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="highmedorg_updateAllowList"> + <bpmndi:BPMNEdge id="SequenceFlow_0oyvmcd_di" bpmnElement="SequenceFlow_0oyvmcd"> + <di:waypoint x="365" y="121" /> + <di:waypoint x="415" y="121" /> + </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0bbhq2r_di" bpmnElement="SequenceFlow_0bbhq2r"> <di:waypoint x="215" y="121" /> <di:waypoint x="265" y="121" /> @@ -25,10 +29,6 @@ <bpmndi:BPMNShape id="EndEvent_0xd0x8k_di" bpmnElement="EndEvent_0xd0x8k"> <dc:Bounds x="415" y="103" width="36" height="36" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0oyvmcd_di" bpmnElement="SequenceFlow_0oyvmcd"> - <di:waypoint x="365" y="121" /> - <di:waypoint x="415" y="121" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0um3ad2_di" bpmnElement="updateAllowListTask"> <dc:Bounds x="265" y="81" width="100" height="80" /> </bpmndi:BPMNShape> diff --git a/dsf-bpe-process-update-allow-list/src/main/resources/fhir/ActivityDefinition/highmed-downloadAllowList.xml b/dsf-bpe-process-update-allow-list/src/main/resources/fhir/ActivityDefinition/highmed-downloadAllowList.xml index 2195e242..2dcfd59d 100644 --- a/dsf-bpe-process-update-allow-list/src/main/resources/fhir/ActivityDefinition/highmed-downloadAllowList.xml +++ b/dsf-bpe-process-update-allow-list/src/main/resources/fhir/ActivityDefinition/highmed-downloadAllowList.xml @@ -1,64 +1,40 @@ <ActivityDefinition xmlns="http://hl7.org/fhir"> <meta> <tag> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="REMOTE" /> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag" /> + <code value="ALL" /> </tag> </meta> <extension url="http://highmed.org/fhir/StructureDefinition/extension-process-authorization"> <extension url="message-name"> <valueString value="downloadAllowListMessage" /> </extension> - <extension url="authorization-roles"> - <extension url="authorization-role"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="LOCAL" /> - </valueCoding> - </extension> - </extension> - <extension url="requester-organization-types"> - <extension url="requester-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="TTP" /> - </valueCoding> - </extension> - <extension url="requester-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="MeDIC" /> - </valueCoding> - </extension> - </extension> - <extension url="recipient-organization-types"> - <extension url="recipient-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="TTP" /> - </valueCoding> - </extension> - <extension url="recipient-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="MeDIC" /> - </valueCoding> - </extension> - </extension> <extension url="task-profile"> <valueCanonical value="http://highmed.org/fhir/StructureDefinition/task-download-allow-list" /> </extension> + <extension url="requester"> + <valueCoding> + <system value="http://highmed.org/fhir/CodeSystem/process-authorization" /> + <code value="LOCAL_ALL" /> + </valueCoding> + </extension> + <extension url="recipient"> + <valueCoding> + <system value="http://highmed.org/fhir/CodeSystem/process-authorization" /> + <code value="LOCAL_ALL" /> + </valueCoding> + </extension> </extension> <url value="http://highmed.org/bpe/Process/downloadAllowList" /> <!-- version managed by bpe --> <version value="${version}" /> - <name value="downloadAllowList" /> + <name value="DownloadAllowList" /> <title value="Download Allow List" /> <subtitle value="Download Allow List Bundle Process" /> <!-- status managed by bpe --> <status value="unknown" /> <experimental value="false" /> - <date value="2021-01-26" /> + <date value="2021-06-07" /> <publisher value="HiGHmed" /> <contact> <name value="HiGHmed" /> diff --git a/dsf-bpe-process-update-allow-list/src/main/resources/fhir/ActivityDefinition/highmed-updateAllowList.xml b/dsf-bpe-process-update-allow-list/src/main/resources/fhir/ActivityDefinition/highmed-updateAllowList.xml index 1868ee5e..1730c55d 100644 --- a/dsf-bpe-process-update-allow-list/src/main/resources/fhir/ActivityDefinition/highmed-updateAllowList.xml +++ b/dsf-bpe-process-update-allow-list/src/main/resources/fhir/ActivityDefinition/highmed-updateAllowList.xml @@ -1,52 +1,52 @@ <ActivityDefinition xmlns="http://hl7.org/fhir"> <meta> <tag> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="REMOTE" /> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag" /> + <code value="ALL" /> </tag> </meta> <extension url="http://highmed.org/fhir/StructureDefinition/extension-process-authorization"> <extension url="message-name"> <valueString value="updateAllowListMessage" /> </extension> - <extension url="authorization-roles"> - <extension url="authorization-role"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="LOCAL" /> - </valueCoding> - </extension> - </extension> - <extension url="requester-organization-types"> - <extension url="requester-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="TTP" /> - </valueCoding> - </extension> - </extension> - <extension url="recipient-organization-types"> - <extension url="recipient-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="TTP" /> - </valueCoding> - </extension> - </extension> <extension url="task-profile"> <valueCanonical value="http://highmed.org/fhir/StructureDefinition/task-update-allow-list" /> </extension> + <extension url="requester"> + <valueCoding> + <extension url="http://highmed.org/fhir/StructureDefinition/extension-process-authorization-organization"> + <valueIdentifier> + <system value="http://highmed.org/sid/organization-identifier" /> + <value value="${org.highmed.dsf.bpe.allow.list.organization:hs-heilbronn.de}" /> + </valueIdentifier> + </extension> + <system value="http://highmed.org/fhir/CodeSystem/process-authorization" /> + <code value="LOCAL_ORGANIZATION" /> + </valueCoding> + </extension> + <extension url="recipient"> + <valueCoding> + <extension url="http://highmed.org/fhir/StructureDefinition/extension-process-authorization-organization"> + <valueIdentifier> + <system value="http://highmed.org/sid/organization-identifier" /> + <value value="${org.highmed.dsf.bpe.allow.list.organization:hs-heilbronn.de}" /> + </valueIdentifier> + </extension> + <system value="http://highmed.org/fhir/CodeSystem/process-authorization" /> + <code value="LOCAL_ORGANIZATION" /> + </valueCoding> + </extension> </extension> <url value="http://highmed.org/bpe/Process/updateAllowList" /> <!-- version managed by bpe --> <version value="${version}" /> - <name value="updateAllowList" /> + <name value="UpdateAllowList" /> <title value="Update Allow List" /> <subtitle value="Update Allow List Bundle Process" /> <!-- status managed by bpe --> <status value="unknown" /> <experimental value="false" /> - <date value="2021-01-26" /> + <date value="2021-06-07" /> <publisher value="HiGHmed" /> <contact> <name value="HiGHmed" /> diff --git a/dsf-bpe-process-update-allow-list/src/main/resources/fhir/CodeSystem/highmed-update-allow-list.xml b/dsf-bpe-process-update-allow-list/src/main/resources/fhir/CodeSystem/highmed-update-allow-list.xml index b12be1e3..7fad8a3e 100644 --- a/dsf-bpe-process-update-allow-list/src/main/resources/fhir/CodeSystem/highmed-update-allow-list.xml +++ b/dsf-bpe-process-update-allow-list/src/main/resources/fhir/CodeSystem/highmed-update-allow-list.xml @@ -1,28 +1,28 @@ <CodeSystem xmlns="http://hl7.org/fhir"> <meta> <tag> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role"/> - <code value="REMOTE"/> - </tag> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag" /> + <code value="ALL" /> + </tag> </meta> - <url value="http://highmed.org/fhir/CodeSystem/update-allow-list"/> + <url value="http://highmed.org/fhir/CodeSystem/update-allow-list" /> <!-- version managed by bpe --> <version value="${version}" /> - <name value="HiGHmed_Update_Allow_List"/> - <title value="HiGHmed Update Allow List"/> + <name value="HiGHmed_Update_Allow_List" /> + <title value="HiGHmed Update Allow List" /> <!-- status managed by bpe --> <status value="unknown" /> - <experimental value="false"/> - <date value="2021-01-26"/> - <publisher value="HiGHmed"/> - <description value="CodeSystem with standard values for the processes update and download allow list"/> - <caseSensitive value="true"/> - <hierarchyMeaning value="grouped-by"/> - <versionNeeded value="false"/> - <content value="complete"/> + <experimental value="false" /> + <date value="2021-06-07" /> + <publisher value="HiGHmed" /> + <description value="CodeSystem with standard values for the processes update and download allow list" /> + <caseSensitive value="true" /> + <hierarchyMeaning value="grouped-by" /> + <versionNeeded value="false" /> + <content value="complete" /> <concept> - <code value="highmed_allow_list"/> - <display value="HiGHmed Allow List"/> - <definition value="Allow list identifying organizations as part of HiGHmed"/> + <code value="allow_list" /> + <display value="HiGHmed Allow List" /> + <definition value="Allow list identifying organizations" /> </concept> </CodeSystem> \ No newline at end of file diff --git a/dsf-bpe-process-update-allow-list/src/main/resources/fhir/StructureDefinition/highmed-task-download-allow-list.xml b/dsf-bpe-process-update-allow-list/src/main/resources/fhir/StructureDefinition/highmed-task-download-allow-list.xml index c92c0dc9..8111d9d7 100644 --- a/dsf-bpe-process-update-allow-list/src/main/resources/fhir/StructureDefinition/highmed-task-download-allow-list.xml +++ b/dsf-bpe-process-update-allow-list/src/main/resources/fhir/StructureDefinition/highmed-task-download-allow-list.xml @@ -2,8 +2,8 @@ <StructureDefinition xmlns="http://hl7.org/fhir"> <meta> <tag> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="REMOTE" /> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag" /> + <code value="ALL" /> </tag> </meta> <url value="http://highmed.org/fhir/StructureDefinition/task-download-allow-list" /> @@ -13,7 +13,7 @@ <!-- status managed by bpe --> <status value="unknown" /> <experimental value="false" /> - <date value="2021-01-26" /> + <date value="2021-06-07" /> <fhirVersion value="4.0.1" /> <kind value="resource" /> <abstract value="false" /> @@ -74,7 +74,7 @@ <element id="Task.input:bundle-reference.type.coding.code"> <path value="Task.input.type.coding.code" /> <min value="1" /> - <fixedCode value="highmed_allow_list" /> + <fixedCode value="allow_list" /> </element> <element id="Task.input:bundle-reference.value[x]"> <path value="Task.input.value[x]" /> diff --git a/dsf-bpe-process-update-allow-list/src/main/resources/fhir/StructureDefinition/highmed-task-update-allow-list.xml b/dsf-bpe-process-update-allow-list/src/main/resources/fhir/StructureDefinition/highmed-task-update-allow-list.xml index b3566dab..a71e8a5e 100644 --- a/dsf-bpe-process-update-allow-list/src/main/resources/fhir/StructureDefinition/highmed-task-update-allow-list.xml +++ b/dsf-bpe-process-update-allow-list/src/main/resources/fhir/StructureDefinition/highmed-task-update-allow-list.xml @@ -1,8 +1,8 @@ <StructureDefinition xmlns="http://hl7.org/fhir"> <meta> <tag> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="REMOTE" /> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag" /> + <code value="ALL" /> </tag> </meta> <url value="http://highmed.org/fhir/StructureDefinition/task-update-allow-list" /> @@ -12,7 +12,7 @@ <!-- status managed by bpe --> <status value="unknown" /> <experimental value="false" /> - <date value="2021-01-26" /> + <date value="2021-06-07" /> <fhirVersion value="4.0.1" /> <kind value="resource" /> <abstract value="false" /> @@ -86,7 +86,7 @@ <element id="Task.output:allowList.type.coding.code"> <path value="Task.output.type.coding.code" /> <min value="1" /> - <fixedCode value="highmed_allow_list" /> + <fixedCode value="allow_list" /> </element> <element id="Task.output:allowList.value[x]"> <path value="Task.output.value[x]" /> diff --git a/dsf-bpe-process-update-allow-list/src/main/resources/fhir/ValueSet/highmed-update-allow-list.xml b/dsf-bpe-process-update-allow-list/src/main/resources/fhir/ValueSet/highmed-update-allow-list.xml index 4713deaa..46df3f2b 100644 --- a/dsf-bpe-process-update-allow-list/src/main/resources/fhir/ValueSet/highmed-update-allow-list.xml +++ b/dsf-bpe-process-update-allow-list/src/main/resources/fhir/ValueSet/highmed-update-allow-list.xml @@ -1,26 +1,25 @@ <ValueSet xmlns="http://hl7.org/fhir"> <meta> <tag> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role"/> - <code value="REMOTE"/> - </tag> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag" /> + <code value="ALL" /> + </tag> </meta> - <url value="http://highmed.org/fhir/ValueSet/update-allow-list"/> + <url value="http://highmed.org/fhir/ValueSet/update-allow-list" /> <!-- version managed by bpe --> <version value="${version}" /> - <name value="HiGHmed_Update_Allow_List"/> - <title value="HiGHmed Update Allow List"/> + <name value="HiGHmed_Update_Allow_List" /> + <title value="HiGHmed Update Allow List" /> <!-- status managed by bpe --> <status value="unknown" /> - <experimental value="false"/> - <date value="2021-01-26"/> - <publisher value="HiGHmed"/> - <description - value="ValueSet with standard values for the process update allow list"/> - <immutable value="true"/> + <experimental value="false" /> + <date value="2021-06-07" /> + <publisher value="HiGHmed" /> + <description value="ValueSet with standard values for the process update allow list" /> + <immutable value="true" /> <compose> <include> - <system value="http://highmed.org/fhir/CodeSystem/update-allow-list"/> + <system value="http://highmed.org/fhir/CodeSystem/update-allow-list" /> </include> </compose> </ValueSet> \ No newline at end of file diff --git a/dsf-bpe-process-update-allow-list/src/test/java/org/highmed/dsf/bpe/start/AbstractDownloadAllowListFromTtpViaMedic1ExampleStarter.java b/dsf-bpe-process-update-allow-list/src/test/java/org/highmed/dsf/bpe/start/AbstractDownloadAllowListFromTtpViaMedic1ExampleStarter.java new file mode 100644 index 00000000..1410f258 --- /dev/null +++ b/dsf-bpe-process-update-allow-list/src/test/java/org/highmed/dsf/bpe/start/AbstractDownloadAllowListFromTtpViaMedic1ExampleStarter.java @@ -0,0 +1,75 @@ +package org.highmed.dsf.bpe.start; + +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN; +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME; +import static org.highmed.dsf.bpe.ConstantsBase.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER; +import static org.highmed.dsf.bpe.ConstantsUpdateAllowList.CODESYSTEM_HIGHMED_UPDATE_ALLOW_LIST; +import static org.highmed.dsf.bpe.ConstantsUpdateAllowList.CODESYSTEM_HIGHMED_UPDATE_ALLOW_LIST_VALUE_ALLOW_LIST; +import static org.highmed.dsf.bpe.ConstantsUpdateAllowList.PROFILE_HIGHMED_TASK_DOWNLOAD_ALLOW_LIST; +import static org.highmed.dsf.bpe.ConstantsUpdateAllowList.PROFILE_HIGHMED_TASK_DOWNLOAD_ALLOW_LIST_MESSAGE_NAME; +import static org.highmed.dsf.bpe.ConstantsUpdateAllowList.PROFILE_HIGHMED_TASK_DOWNLOAD_ALLOW_LIST_PROCESS_URI_AND_LATEST_VERSION; +import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1; + +import java.util.Collections; +import java.util.Date; +import java.util.Map; + +import org.highmed.fhir.client.FhirWebserviceClient; +import org.hl7.fhir.r4.model.Bundle; +import org.hl7.fhir.r4.model.IdType; +import org.hl7.fhir.r4.model.Reference; +import org.hl7.fhir.r4.model.ResourceType; +import org.hl7.fhir.r4.model.StringType; +import org.hl7.fhir.r4.model.Task; +import org.hl7.fhir.r4.model.Task.TaskIntent; +import org.hl7.fhir.r4.model.Task.TaskStatus; + +public abstract class AbstractDownloadAllowListFromTtpViaMedic1ExampleStarter +{ + protected void main(String[] args, String baseUrl, String ttpUrl) throws Exception + { + ExampleStarter starter = ExampleStarter.forServer(args, baseUrl); + Task task = createStartResource(starter, ttpUrl); + starter.startWith(task); + } + + private Task createStartResource(ExampleStarter starter, String ttpUrl) throws Exception + { + Bundle allowList = getAllowList(starter, ttpUrl); + + Task task = new Task(); + task.getMeta().addProfile(PROFILE_HIGHMED_TASK_DOWNLOAD_ALLOW_LIST); + task.setInstantiatesUri(PROFILE_HIGHMED_TASK_DOWNLOAD_ALLOW_LIST_PROCESS_URI_AND_LATEST_VERSION); + task.setStatus(TaskStatus.REQUESTED); + task.setIntent(TaskIntent.ORDER); + task.setAuthoredOn(new Date()); + task.getRequester().setType(ResourceType.Organization.name()).getIdentifier() + .setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER) + .setValue(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1); + task.getRestriction().addRecipient().setType(ResourceType.Organization.name()).getIdentifier() + .setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER) + .setValue(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1); + + task.addInput().setValue(new StringType(PROFILE_HIGHMED_TASK_DOWNLOAD_ALLOW_LIST_MESSAGE_NAME)).getType() + .addCoding().setSystem(CODESYSTEM_HIGHMED_BPMN).setCode(CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME); + task.addInput() + .setValue(new Reference(new IdType(ttpUrl, ResourceType.Bundle.name(), + allowList.getIdElement().getIdPart(), allowList.getIdElement().getVersionIdPart()))) + .getType().addCoding().setSystem(CODESYSTEM_HIGHMED_UPDATE_ALLOW_LIST) + .setCode(CODESYSTEM_HIGHMED_UPDATE_ALLOW_LIST_VALUE_ALLOW_LIST); + + return task; + } + + private Bundle getAllowList(ExampleStarter starter, String ttpUrl) throws Exception + { + FhirWebserviceClient client = starter.createClient(ttpUrl); + Bundle searchResult = client.searchWithStrictHandling(Bundle.class, Map.of("identifier", + Collections.singletonList("http://highmed.org/fhir/CodeSystem/update-allow-list|allow_list"))); + + if (searchResult.getTotal() != 1 && searchResult.getEntryFirstRep().getResource() instanceof Bundle) + throw new IllegalStateException("Expected a single allow list Bundle"); + + return (Bundle) searchResult.getEntryFirstRep().getResource(); + } +} diff --git a/dsf-bpe-process-update-allow-list/src/test/java/org/highmed/dsf/bpe/start/AbstractUpdateAllowList3MedicTtpExampleStarter.java b/dsf-bpe-process-update-allow-list/src/test/java/org/highmed/dsf/bpe/start/AbstractUpdateAllowList3MedicTtpExampleStarter.java new file mode 100644 index 00000000..89920cf7 --- /dev/null +++ b/dsf-bpe-process-update-allow-list/src/test/java/org/highmed/dsf/bpe/start/AbstractUpdateAllowList3MedicTtpExampleStarter.java @@ -0,0 +1,47 @@ +package org.highmed.dsf.bpe.start; + +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN; +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME; +import static org.highmed.dsf.bpe.ConstantsBase.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER; +import static org.highmed.dsf.bpe.ConstantsUpdateAllowList.PROFILE_HIGHMED_TASK_UPDATE_ALLOW_LIST; +import static org.highmed.dsf.bpe.ConstantsUpdateAllowList.PROFILE_HIGHMED_TASK_UPDATE_ALLOW_LIST_MESSAGE_NAME; +import static org.highmed.dsf.bpe.ConstantsUpdateAllowList.PROFILE_HIGHMED_TASK_UPDATE_ALLOW_LIST_PROCESS_URI_AND_LATEST_VERSION; +import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_TTP; + +import java.util.Date; + +import org.hl7.fhir.r4.model.ResourceType; +import org.hl7.fhir.r4.model.StringType; +import org.hl7.fhir.r4.model.Task; +import org.hl7.fhir.r4.model.Task.TaskIntent; +import org.hl7.fhir.r4.model.Task.TaskStatus; + +public abstract class AbstractUpdateAllowList3MedicTtpExampleStarter +{ + protected void main(String[] args, String baseUrl) throws Exception + { + Task task = createStartResource(); + ExampleStarter.forServer(args, baseUrl).startWith(task); + } + + private Task createStartResource() + { + Task task = new Task(); + task.getMeta().addProfile(PROFILE_HIGHMED_TASK_UPDATE_ALLOW_LIST); + task.setInstantiatesUri(PROFILE_HIGHMED_TASK_UPDATE_ALLOW_LIST_PROCESS_URI_AND_LATEST_VERSION); + task.setStatus(TaskStatus.REQUESTED); + task.setIntent(TaskIntent.ORDER); + task.setAuthoredOn(new Date()); + task.getRequester().setType(ResourceType.Organization.name()).getIdentifier() + .setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER) + .setValue(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_TTP); + task.getRestriction().addRecipient().setType(ResourceType.Organization.name()).getIdentifier() + .setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER) + .setValue(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_TTP); + + task.addInput().setValue(new StringType(PROFILE_HIGHMED_TASK_UPDATE_ALLOW_LIST_MESSAGE_NAME)).getType() + .addCoding().setSystem(CODESYSTEM_HIGHMED_BPMN).setCode(CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME); + + return task; + } +} diff --git a/dsf-bpe-process-update-allow-list/src/test/java/org/highmed/dsf/bpe/start/DownloadAllowListFromTtpViaMedic1DockerExampleStarter.java b/dsf-bpe-process-update-allow-list/src/test/java/org/highmed/dsf/bpe/start/DownloadAllowListFromTtpViaMedic1DockerExampleStarter.java new file mode 100644 index 00000000..85677fc5 --- /dev/null +++ b/dsf-bpe-process-update-allow-list/src/test/java/org/highmed/dsf/bpe/start/DownloadAllowListFromTtpViaMedic1DockerExampleStarter.java @@ -0,0 +1,18 @@ +package org.highmed.dsf.bpe.start; + +import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.MEDIC_1_DOCKER_FHIR_BASE_URL; +import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.TTP_DOCKER_FHIR_BASE_URL; + +public class DownloadAllowListFromTtpViaMedic1DockerExampleStarter + extends AbstractDownloadAllowListFromTtpViaMedic1ExampleStarter +{ + // Environment variable "DSF_CLIENT_CERTIFICATE_PATH" or args[0]: the path to the client-certificate + // highmed-dsf/dsf-tools/dsf-tools-test-data-generator/cert/Webbrowser_Test_User/Webbrowser_Test_User_certificate.p12 + // Environment variable "DSF_CLIENT_CERTIFICATE_PASSWORD" or args[1]: the password of the client-certificate + // password + public static void main(String[] args) throws Exception + { + new DownloadAllowListFromTtpViaMedic1DockerExampleStarter().main(args, MEDIC_1_DOCKER_FHIR_BASE_URL, + TTP_DOCKER_FHIR_BASE_URL); + } +} diff --git a/dsf-bpe-process-update-allow-list/src/test/java/org/highmed/dsf/bpe/start/DownloadAllowListFromTtpViaMedic1ExampleStarter.java b/dsf-bpe-process-update-allow-list/src/test/java/org/highmed/dsf/bpe/start/DownloadAllowListFromTtpViaMedic1ExampleStarter.java index 1338e902..e7cd3d46 100644 --- a/dsf-bpe-process-update-allow-list/src/test/java/org/highmed/dsf/bpe/start/DownloadAllowListFromTtpViaMedic1ExampleStarter.java +++ b/dsf-bpe-process-update-allow-list/src/test/java/org/highmed/dsf/bpe/start/DownloadAllowListFromTtpViaMedic1ExampleStarter.java @@ -1,32 +1,10 @@ package org.highmed.dsf.bpe.start; -import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN; -import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME; -import static org.highmed.dsf.bpe.ConstantsBase.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER; -import static org.highmed.dsf.bpe.ConstantsUpdateAllowList.CODESYSTEM_HIGHMED_UPDATE_ALLOW_LIST; -import static org.highmed.dsf.bpe.ConstantsUpdateAllowList.CODESYSTEM_HIGHMED_UPDATE_ALLOW_LIST_VALUE_ALLOW_LIST; -import static org.highmed.dsf.bpe.ConstantsUpdateAllowList.PROFILE_HIGHMED_TASK_DOWNLOAD_ALLOW_LIST; -import static org.highmed.dsf.bpe.ConstantsUpdateAllowList.PROFILE_HIGHMED_TASK_DOWNLOAD_ALLOW_LIST_MESSAGE_NAME; -import static org.highmed.dsf.bpe.ConstantsUpdateAllowList.PROFILE_HIGHMED_TASK_DOWNLOAD_ALLOW_LIST_PROCESS_URI_AND_LATEST_VERSION; import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.MEDIC_1_FHIR_BASE_URL; -import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1; import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.TTP_FHIR_BASE_URL; -import java.util.Collections; -import java.util.Date; -import java.util.Map; - -import org.highmed.fhir.client.FhirWebserviceClient; -import org.hl7.fhir.r4.model.Bundle; -import org.hl7.fhir.r4.model.IdType; -import org.hl7.fhir.r4.model.Reference; -import org.hl7.fhir.r4.model.ResourceType; -import org.hl7.fhir.r4.model.StringType; -import org.hl7.fhir.r4.model.Task; -import org.hl7.fhir.r4.model.Task.TaskIntent; -import org.hl7.fhir.r4.model.Task.TaskStatus; - public class DownloadAllowListFromTtpViaMedic1ExampleStarter + extends AbstractDownloadAllowListFromTtpViaMedic1ExampleStarter { // Environment variable "DSF_CLIENT_CERTIFICATE_PATH" or args[0]: the path to the client-certificate // highmed-dsf/dsf-tools/dsf-tools-test-data-generator/cert/Webbrowser_Test_User/Webbrowser_Test_User_certificate.p12 @@ -34,48 +12,6 @@ public class DownloadAllowListFromTtpViaMedic1ExampleStarter // password public static void main(String[] args) throws Exception { - ExampleStarter starter = ExampleStarter.forServer(args, MEDIC_1_FHIR_BASE_URL); - Task task = createStartResource(starter); - starter.startWith(task); - } - - private static Task createStartResource(ExampleStarter starter) throws Exception - { - Bundle allowList = getAllowList(starter); - - Task task = new Task(); - task.getMeta().addProfile(PROFILE_HIGHMED_TASK_DOWNLOAD_ALLOW_LIST); - task.setInstantiatesUri(PROFILE_HIGHMED_TASK_DOWNLOAD_ALLOW_LIST_PROCESS_URI_AND_LATEST_VERSION); - task.setStatus(TaskStatus.REQUESTED); - task.setIntent(TaskIntent.ORDER); - task.setAuthoredOn(new Date()); - task.getRequester().setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER) - .setValue(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1); - task.getRestriction().addRecipient().setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER) - .setValue(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1); - - task.addInput().setValue(new StringType(PROFILE_HIGHMED_TASK_DOWNLOAD_ALLOW_LIST_MESSAGE_NAME)).getType() - .addCoding().setSystem(CODESYSTEM_HIGHMED_BPMN).setCode(CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME); - task.addInput() - .setValue(new Reference(new IdType(TTP_FHIR_BASE_URL, ResourceType.Bundle.name(), - allowList.getIdElement().getIdPart(), allowList.getIdElement().getVersionIdPart()))) - .getType().addCoding().setSystem(CODESYSTEM_HIGHMED_UPDATE_ALLOW_LIST) - .setCode(CODESYSTEM_HIGHMED_UPDATE_ALLOW_LIST_VALUE_ALLOW_LIST); - - return task; - } - - private static Bundle getAllowList(ExampleStarter starter) throws Exception - { - FhirWebserviceClient client = starter.createClient(TTP_FHIR_BASE_URL); - Bundle searchResult = client.searchWithStrictHandling(Bundle.class, Map.of("identifier", - Collections.singletonList("http://highmed.org/fhir/CodeSystem/update-allow-list|highmed_allow_list"))); - - if (searchResult.getTotal() != 1 && searchResult.getEntryFirstRep().getResource() instanceof Bundle) - throw new IllegalStateException("Expected a single allow list Bundle"); - - return (Bundle) searchResult.getEntryFirstRep().getResource(); + new DownloadAllowListFromTtpViaMedic1ExampleStarter().main(args, MEDIC_1_FHIR_BASE_URL, TTP_FHIR_BASE_URL); } } diff --git a/dsf-bpe-process-update-allow-list/src/test/java/org/highmed/dsf/bpe/start/UpdateAllowList3MedicTtpDockerExampleStarter.java b/dsf-bpe-process-update-allow-list/src/test/java/org/highmed/dsf/bpe/start/UpdateAllowList3MedicTtpDockerExampleStarter.java new file mode 100644 index 00000000..35346e12 --- /dev/null +++ b/dsf-bpe-process-update-allow-list/src/test/java/org/highmed/dsf/bpe/start/UpdateAllowList3MedicTtpDockerExampleStarter.java @@ -0,0 +1,15 @@ +package org.highmed.dsf.bpe.start; + +import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.TTP_DOCKER_FHIR_BASE_URL; + +public class UpdateAllowList3MedicTtpDockerExampleStarter extends AbstractUpdateAllowList3MedicTtpExampleStarter +{ + // Environment variable "DSF_CLIENT_CERTIFICATE_PATH" or args[0]: the path to the client-certificate + // highmed-dsf/dsf-tools/dsf-tools-test-data-generator/cert/Webbrowser_Test_User/Webbrowser_Test_User_certificate.p12 + // Environment variable "DSF_CLIENT_CERTIFICATE_PASSWORD" or args[1]: the password of the client-certificate + // password + public static void main(String[] args) throws Exception + { + new UpdateAllowList3MedicTtpDockerExampleStarter().main(args, TTP_DOCKER_FHIR_BASE_URL); + } +} diff --git a/dsf-bpe-process-update-allow-list/src/test/java/org/highmed/dsf/bpe/start/UpdateAllowList3MedicTtpExampleStarter.java b/dsf-bpe-process-update-allow-list/src/test/java/org/highmed/dsf/bpe/start/UpdateAllowList3MedicTtpExampleStarter.java index 1144ff88..090fa361 100644 --- a/dsf-bpe-process-update-allow-list/src/test/java/org/highmed/dsf/bpe/start/UpdateAllowList3MedicTtpExampleStarter.java +++ b/dsf-bpe-process-update-allow-list/src/test/java/org/highmed/dsf/bpe/start/UpdateAllowList3MedicTtpExampleStarter.java @@ -1,23 +1,8 @@ package org.highmed.dsf.bpe.start; -import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN; -import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME; -import static org.highmed.dsf.bpe.ConstantsBase.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER; -import static org.highmed.dsf.bpe.ConstantsUpdateAllowList.PROFILE_HIGHMED_TASK_UPDATE_ALLOW_LIST; -import static org.highmed.dsf.bpe.ConstantsUpdateAllowList.PROFILE_HIGHMED_TASK_UPDATE_ALLOW_LIST_MESSAGE_NAME; -import static org.highmed.dsf.bpe.ConstantsUpdateAllowList.PROFILE_HIGHMED_TASK_UPDATE_ALLOW_LIST_PROCESS_URI_AND_LATEST_VERSION; -import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_TTP; import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.TTP_FHIR_BASE_URL; -import java.util.Date; - -import org.hl7.fhir.r4.model.ResourceType; -import org.hl7.fhir.r4.model.StringType; -import org.hl7.fhir.r4.model.Task; -import org.hl7.fhir.r4.model.Task.TaskIntent; -import org.hl7.fhir.r4.model.Task.TaskStatus; - -public class UpdateAllowList3MedicTtpExampleStarter +public class UpdateAllowList3MedicTtpExampleStarter extends AbstractUpdateAllowList3MedicTtpExampleStarter { // Environment variable "DSF_CLIENT_CERTIFICATE_PATH" or args[0]: the path to the client-certificate // highmed-dsf/dsf-tools/dsf-tools-test-data-generator/cert/Webbrowser_Test_User/Webbrowser_Test_User_certificate.p12 @@ -25,28 +10,6 @@ public class UpdateAllowList3MedicTtpExampleStarter // password public static void main(String[] args) throws Exception { - Task task = createStartResource(); - ExampleStarter.forServer(args, TTP_FHIR_BASE_URL).startWith(task); - } - - private static Task createStartResource() - { - Task task = new Task(); - task.getMeta().addProfile(PROFILE_HIGHMED_TASK_UPDATE_ALLOW_LIST); - task.setInstantiatesUri(PROFILE_HIGHMED_TASK_UPDATE_ALLOW_LIST_PROCESS_URI_AND_LATEST_VERSION); - task.setStatus(TaskStatus.REQUESTED); - task.setIntent(TaskIntent.ORDER); - task.setAuthoredOn(new Date()); - task.getRequester().setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER) - .setValue(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_TTP); - task.getRestriction().addRecipient().setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER) - .setValue(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_TTP); - - task.addInput().setValue(new StringType(PROFILE_HIGHMED_TASK_UPDATE_ALLOW_LIST_MESSAGE_NAME)).getType() - .addCoding().setSystem(CODESYSTEM_HIGHMED_BPMN).setCode(CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME); - - return task; + new UpdateAllowList3MedicTtpExampleStarter().main(args, TTP_FHIR_BASE_URL); } } diff --git a/dsf-bpe-process-update-allow-list/src/test/java/org/highmed/dsf/fhir/profile/ActivityDefinitionProfileTest.java b/dsf-bpe-process-update-allow-list/src/test/java/org/highmed/dsf/fhir/profile/ActivityDefinitionProfileTest.java new file mode 100644 index 00000000..1d1797f1 --- /dev/null +++ b/dsf-bpe-process-update-allow-list/src/test/java/org/highmed/dsf/fhir/profile/ActivityDefinitionProfileTest.java @@ -0,0 +1,89 @@ +package org.highmed.dsf.fhir.profile; + +import static org.highmed.dsf.bpe.UpdateAllowListProcessPluginDefinition.VERSION; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; + +import org.highmed.dsf.fhir.authorization.process.ProcessAuthorizationHelper; +import org.highmed.dsf.fhir.authorization.process.ProcessAuthorizationHelperImpl; +import org.highmed.dsf.fhir.validation.ResourceValidator; +import org.highmed.dsf.fhir.validation.ResourceValidatorImpl; +import org.highmed.dsf.fhir.validation.ValidationSupportRule; +import org.hl7.fhir.r4.model.ActivityDefinition; +import org.junit.ClassRule; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import ca.uhn.fhir.validation.ResultSeverityEnum; +import ca.uhn.fhir.validation.ValidationResult; + +public class ActivityDefinitionProfileTest +{ + private static final Logger logger = LoggerFactory.getLogger(ActivityDefinitionProfileTest.class); + + @ClassRule + public static final ValidationSupportRule validationRule = new ValidationSupportRule(VERSION, + Arrays.asList("highmed-activity-definition-0.5.0.xml", "highmed-extension-process-authorization-0.5.0.xml", + "highmed-extension-process-authorization-consortium-role-0.5.0.xml", + "highmed-extension-process-authorization-organization-0.5.0.xml", + "highmed-coding-process-authorization-local-all-0.5.0.xml", + "highmed-coding-process-authorization-local-consortium-role-0.5.0.xml", + "highmed-coding-process-authorization-local-organization-0.5.0.xml", + "highmed-coding-process-authorization-remote-all-0.5.0.xml", + "highmed-coding-process-authorization-remote-consortium-role-0.5.0.xml", + "highmed-coding-process-authorization-remote-organization-0.5.0.xml"), + Arrays.asList("highmed-read-access-tag-0.5.0.xml", "highmed-process-authorization-0.5.0.xml"), + Arrays.asList("highmed-read-access-tag-0.5.0.xml", "highmed-process-authorization-recipient-0.5.0.xml", + "highmed-process-authorization-requester-0.5.0.xml")); + + private final ResourceValidator resourceValidator = new ResourceValidatorImpl(validationRule.getFhirContext(), + validationRule.getValidationSupport()); + + private final ProcessAuthorizationHelper processAuthorizationHelper = new ProcessAuthorizationHelperImpl(); + + @Test + public void testDownloadAllowListValid() throws Exception + { + try (InputStream in = Files + .newInputStream(Paths.get("src/main/resources/fhir/ActivityDefinition/highmed-downloadAllowList.xml"))) + { + ActivityDefinition ad = validationRule.getFhirContext().newXmlParser() + .parseResource(ActivityDefinition.class, in); + + ValidationResult result = resourceValidator.validate(ad); + ValidationSupportRule.logValidationMessages(logger, result); + + assertEquals(0, result.getMessages().stream().filter(m -> ResultSeverityEnum.ERROR.equals(m.getSeverity()) + || ResultSeverityEnum.FATAL.equals(m.getSeverity())).count()); + + assertTrue( + processAuthorizationHelper.isValid(ad, taskProfile -> true, orgIdentifier -> true, role -> true)); + } + } + + @Test + public void testUpdateAllowListValid() throws Exception + { + try (InputStream in = Files + .newInputStream(Paths.get("src/main/resources/fhir/ActivityDefinition/highmed-updateAllowList.xml"))) + { + ActivityDefinition ad = validationRule.getFhirContext().newXmlParser() + .parseResource(ActivityDefinition.class, in); + + ValidationResult result = resourceValidator.validate(ad); + ValidationSupportRule.logValidationMessages(logger, result); + + assertEquals(0, result.getMessages().stream().filter(m -> ResultSeverityEnum.ERROR.equals(m.getSeverity()) + || ResultSeverityEnum.FATAL.equals(m.getSeverity())).count()); + + assertTrue( + processAuthorizationHelper.isValid(ad, taskProfile -> true, orgIdentifier -> true, role -> true)); + } + } +} \ No newline at end of file diff --git a/dsf-bpe-process-update-allow-list/src/test/java/org/highmed/dsf/fhir/profile/TaskProfileTest.java b/dsf-bpe-process-update-allow-list/src/test/java/org/highmed/dsf/fhir/profile/TaskProfileTest.java index 085f10fa..fef1465d 100644 --- a/dsf-bpe-process-update-allow-list/src/test/java/org/highmed/dsf/fhir/profile/TaskProfileTest.java +++ b/dsf-bpe-process-update-allow-list/src/test/java/org/highmed/dsf/fhir/profile/TaskProfileTest.java @@ -44,9 +44,9 @@ public class TaskProfileTest public static final ValidationSupportRule validationRule = new ValidationSupportRule(VERSION, Arrays.asList("highmed-task-base-0.5.0.xml", "highmed-task-update-allow-list.xml", "highmed-task-download-allow-list.xml"), - Arrays.asList("highmed-authorization-role-0.5.0.xml", "highmed-bpmn-message-0.5.0.xml", + Arrays.asList("highmed-read-access-tag-0.5.0.xml", "highmed-bpmn-message-0.5.0.xml", "highmed-update-allow-list.xml"), - Arrays.asList("highmed-authorization-role-0.5.0.xml", "highmed-bpmn-message-0.5.0.xml", + Arrays.asList("highmed-read-access-tag-0.5.0.xml", "highmed-bpmn-message-0.5.0.xml", "highmed-update-allow-list.xml")); private ResourceValidator resourceValidator = new ResourceValidatorImpl(validationRule.getFhirContext(), diff --git a/dsf-bpe-process-update-resources/pom.xml b/dsf-bpe-process-update-resources/pom.xml index 987e7a00..ea1991e9 100644 --- a/dsf-bpe-process-update-resources/pom.xml +++ b/dsf-bpe-process-update-resources/pom.xml @@ -63,7 +63,7 @@ <version>${project.version}</version> </artifactItem> </artifactItems> - <outputDirectory>${dsf.location}/dsf-docker-test-setup/bpe/app/process</outputDirectory> + <outputDirectory>${dsf.location}/dsf-docker-test-setup/bpe/process</outputDirectory> </configuration> </execution> <execution> @@ -80,7 +80,7 @@ <version>${project.version}</version> </artifactItem> </artifactItems> - <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic1/bpe/app/process</outputDirectory> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic1/bpe/process</outputDirectory> </configuration> </execution> <execution> @@ -97,7 +97,7 @@ <version>${project.version}</version> </artifactItem> </artifactItems> - <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic2/bpe/app/process</outputDirectory> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic2/bpe/process</outputDirectory> </configuration> </execution> <execution> @@ -114,7 +114,7 @@ <version>${project.version}</version> </artifactItem> </artifactItems> - <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic3/bpe/app/process</outputDirectory> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic3/bpe/process</outputDirectory> </configuration> </execution> <execution> @@ -131,7 +131,79 @@ <version>${project.version}</version> </artifactItem> </artifactItems> - <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/ttp/bpe/app/process</outputDirectory> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/ttp/bpe/process</outputDirectory> + </configuration> + </execution> + <execution> + <id>copy-process-to-docker-test-setup-3medic-ttp-docker/medic1</id> + <phase>package</phase> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>${project.groupId}</groupId> + <artifactId>${project.artifactId}</artifactId> + <version>${project.version}</version> + </artifactItem> + </artifactItems> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/medic1/bpe/process + </outputDirectory> + </configuration> + </execution> + <execution> + <id>copy-process-to-docker-test-setup-3medic-ttp-docker/medic2</id> + <phase>package</phase> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>${project.groupId}</groupId> + <artifactId>${project.artifactId}</artifactId> + <version>${project.version}</version> + </artifactItem> + </artifactItems> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/medic2/bpe/process + </outputDirectory> + </configuration> + </execution> + <execution> + <id>copy-process-to-docker-test-setup-3medic-ttp-docker/medic3</id> + <phase>package</phase> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>${project.groupId}</groupId> + <artifactId>${project.artifactId}</artifactId> + <version>${project.version}</version> + </artifactItem> + </artifactItems> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/medic3/bpe/process + </outputDirectory> + </configuration> + </execution> + <execution> + <id>copy-process-to-docker-test-setup-3medic-ttp-docker/ttp</id> + <phase>package</phase> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>${project.groupId}</groupId> + <artifactId>${project.artifactId}</artifactId> + <version>${project.version}</version> + </artifactItem> + </artifactItems> + <outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/ttp/bpe/process + </outputDirectory> </configuration> </execution> </executions> @@ -142,35 +214,63 @@ <configuration> <filesets> <fileset> - <directory>${dsf.location}/dsf-docker-test-setup/bpe/app/process</directory> + <directory>${dsf.location}/dsf-docker-test-setup/bpe/process</directory> + <includes> + <include>${project.artifactId}-${project.version}.jar</include> + </includes> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic1/bpe/process</directory> + <includes> + <include>${project.artifactId}-${project.version}.jar</include> + </includes> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic2/bpe/process</directory> + <includes> + <include>${project.artifactId}-${project.version}.jar</include> + </includes> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic3/bpe/process</directory> + <includes> + <include>${project.artifactId}-${project.version}.jar</include> + </includes> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/ttp/bpe/process</directory> <includes> <include>${project.artifactId}-${project.version}.jar</include> </includes> <followSymlinks>false</followSymlinks> </fileset> <fileset> - <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic1/bpe/app/process</directory> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/medic1/bpe/process</directory> <includes> <include>${project.artifactId}-${project.version}.jar</include> </includes> <followSymlinks>false</followSymlinks> </fileset> <fileset> - <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic2/bpe/app/process</directory> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/medic2/bpe/process</directory> <includes> <include>${project.artifactId}-${project.version}.jar</include> </includes> <followSymlinks>false</followSymlinks> </fileset> <fileset> - <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic3/bpe/app/process</directory> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/medic3/bpe/process</directory> <includes> <include>${project.artifactId}-${project.version}.jar</include> </includes> <followSymlinks>false</followSymlinks> </fileset> <fileset> - <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/ttp/bpe/app/process</directory> + <directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp-docker/ttp/bpe/process</directory> <includes> <include>${project.artifactId}-${project.version}.jar</include> </includes> diff --git a/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/ConstantsUpdateResources.java b/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/ConstantsUpdateResources.java index d8468f53..a4a56881 100644 --- a/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/ConstantsUpdateResources.java +++ b/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/ConstantsUpdateResources.java @@ -5,6 +5,8 @@ public interface ConstantsUpdateResources { + String BPMN_EXECUTION_VARIABLE_BUNDLE = "bundle"; + String CODESYSTEM_HIGHMED_UPDATE_RESOURCE = "http://highmed.org/fhir/CodeSystem/update-resources"; String CODESYSTEM_HIGHMED_UPDATE_RESOURCE_VALUE_BUNDLE_REFERENCE = "bundle-reference"; String CODESYSTEM_HIGHMED_UPDATE_RESOURCE_VALUE_ORGANIZATION_IDENTIFIER_SEARCH_PARAMETER = "organization-identifier-search-parameter"; diff --git a/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/UpdateResourcesProcessPluginDefinition.java b/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/UpdateResourcesProcessPluginDefinition.java index b0e87dd1..8bde102e 100644 --- a/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/UpdateResourcesProcessPluginDefinition.java +++ b/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/UpdateResourcesProcessPluginDefinition.java @@ -12,6 +12,7 @@ import org.highmed.dsf.fhir.resources.ResourceProvider; import org.highmed.dsf.fhir.resources.StructureDefinitionResource; import org.highmed.dsf.fhir.resources.ValueSetResource; +import org.springframework.core.env.PropertyResolver; import ca.uhn.fhir.context.FhirContext; @@ -44,7 +45,8 @@ public Stream<Class<?>> getSpringConfigClasses() } @Override - public ResourceProvider getResourceProvider(FhirContext fhirContext, ClassLoader classLoader) + public ResourceProvider getResourceProvider(FhirContext fhirContext, ClassLoader classLoader, + PropertyResolver resolver) { var aExec = ActivityDefinitionResource.file("fhir/ActivityDefinition/highmed-executeUpdateResources.xml"); var aReq = ActivityDefinitionResource.file("fhir/ActivityDefinition/highmed-requestUpdateResources.xml"); @@ -56,10 +58,10 @@ public ResourceProvider getResourceProvider(FhirContext fhirContext, ClassLoader var v = ValueSetResource.file("fhir/ValueSet/highmed-update-resources.xml"); Map<String, List<AbstractResource>> resourcesByProcessKeyAndVersion = Map.of( - "executeUpdateResources/" + VERSION, Arrays.asList(aExec, c, sExec, v), - "requestUpdateResources/" + VERSION, Arrays.asList(aReq, c, sReq, v)); + "highmedorg_executeUpdateResources/" + VERSION, Arrays.asList(aExec, c, sExec, v), + "highmedorg_requestUpdateResources/" + VERSION, Arrays.asList(aReq, c, sReq, v)); return ResourceProvider.read(VERSION, () -> fhirContext.newXmlParser().setStripVersionsFromReferences(false), - classLoader, resourcesByProcessKeyAndVersion); + classLoader, resolver, resourcesByProcessKeyAndVersion); } } diff --git a/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/message/SendRequest.java b/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/message/SendRequest.java index 02c92293..96f24b9f 100644 --- a/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/message/SendRequest.java +++ b/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/message/SendRequest.java @@ -7,6 +7,7 @@ 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; @@ -21,9 +22,9 @@ public class SendRequest extends AbstractTaskMessageSend { public SendRequest(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, - OrganizationProvider organizationProvider, FhirContext fhirContext) + ReadAccessHelper readAccessHelper, OrganizationProvider organizationProvider, FhirContext fhirContext) { - super(clientProvider, taskHelper, organizationProvider, fhirContext); + super(clientProvider, taskHelper, readAccessHelper, organizationProvider, fhirContext); } @Override diff --git a/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/service/CheckRequest.java b/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/service/CheckRequest.java index e05098f6..4e0a8d2d 100644 --- a/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/service/CheckRequest.java +++ b/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/service/CheckRequest.java @@ -1,64 +1,24 @@ package org.highmed.dsf.bpe.service; -import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_ORGANIZATION_TYPE; -import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_ORGANIZATION_TYPE_VALUE_TTP; - -import java.util.Objects; -import java.util.Optional; - import org.camunda.bpm.engine.delegate.DelegateExecution; import org.highmed.dsf.bpe.delegate.AbstractServiceDelegate; +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.TaskHelper; -import org.hl7.fhir.r4.model.Identifier; -import org.hl7.fhir.r4.model.Organization; -import org.hl7.fhir.r4.model.Task; -import org.springframework.beans.factory.InitializingBean; -public class CheckRequest extends AbstractServiceDelegate implements InitializingBean +public class CheckRequest extends AbstractServiceDelegate { - private final OrganizationProvider organizationProvider; - public CheckRequest(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, - OrganizationProvider organizationProvider) + ReadAccessHelper readAccessHelper) { - super(clientProvider, taskHelper); - - this.organizationProvider = organizationProvider; - } - - @Override - public void afterPropertiesSet() throws Exception - { - super.afterPropertiesSet(); - - Objects.requireNonNull(organizationProvider, "organizationProvider"); + super(clientProvider, taskHelper, readAccessHelper); } @Override protected void doExecute(DelegateExecution execution) throws Exception { - Task task = getCurrentTaskFromExecutionVariables(); - - if (requesterIsNotOfTypeTtp(task.getRequester().getIdentifier())) - { - throw new RuntimeException( - "Request check failed: process can only be started by requesting organization of type='" - + CODESYSTEM_HIGHMED_ORGANIZATION_TYPE_VALUE_TTP + "'"); - } - } - - private boolean requesterIsNotOfTypeTtp(Identifier requester) - { - Optional<Organization> organization = organizationProvider.getOrganization(requester.getSystem(), - requester.getValue()); + // TODO check digital signature of bundle - return !organization - .map(value -> value.getType().stream() - .anyMatch(type -> type.getCoding().stream() - .anyMatch(coding -> coding.getSystem().equals(CODESYSTEM_HIGHMED_ORGANIZATION_TYPE) - && coding.getCode().equals(CODESYSTEM_HIGHMED_ORGANIZATION_TYPE_VALUE_TTP)))) - .orElse(false); + // Bundle bundle = (Bundle) execution.getVariable(BPMN_EXECUTION_VARIABLE_BUNDLE); } } diff --git a/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/service/DownloadBundle.java b/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/service/DownloadBundle.java new file mode 100644 index 00000000..30e52801 --- /dev/null +++ b/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/service/DownloadBundle.java @@ -0,0 +1,96 @@ +package org.highmed.dsf.bpe.service; + +import static org.highmed.dsf.bpe.ConstantsUpdateResources.BPMN_EXECUTION_VARIABLE_BUNDLE; +import static org.highmed.dsf.bpe.ConstantsUpdateResources.CODESYSTEM_HIGHMED_UPDATE_RESOURCE; +import static org.highmed.dsf.bpe.ConstantsUpdateResources.CODESYSTEM_HIGHMED_UPDATE_RESOURCE_VALUE_BUNDLE_REFERENCE; + +import java.util.EnumSet; +import java.util.List; +import java.util.stream.Collectors; + +import javax.ws.rs.WebApplicationException; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.highmed.dsf.bpe.delegate.AbstractServiceDelegate; +import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper; +import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider; +import org.highmed.dsf.fhir.task.TaskHelper; +import org.highmed.dsf.fhir.variables.FhirResourceValues; +import org.highmed.fhir.client.FhirWebserviceClient; +import org.hl7.fhir.r4.model.Bundle; +import org.hl7.fhir.r4.model.Bundle.BundleType; +import org.hl7.fhir.r4.model.IdType; +import org.hl7.fhir.r4.model.Reference; +import org.hl7.fhir.r4.model.Task; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DownloadBundle extends AbstractServiceDelegate +{ + private static final Logger logger = LoggerFactory.getLogger(DownloadBundle.class); + + public DownloadBundle(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, + ReadAccessHelper readAccessHelper) + { + super(clientProvider, taskHelper, readAccessHelper); + } + + @Override + protected void doExecute(DelegateExecution execution) throws Exception + { + Task task = getCurrentTaskFromExecutionVariables(); + IdType bundleId = getBundleId(task); + FhirWebserviceClient requesterClient = getFhirWebserviceClientProvider() + .getWebserviceClient(bundleId.getBaseUrl()); + + Bundle bundle; + try + { + if (bundleId.hasVersionIdPart()) + bundle = requesterClient.read(Bundle.class, bundleId.getIdPart(), bundleId.getVersionIdPart()); + else + bundle = requesterClient.read(Bundle.class, bundleId.getIdPart()); + } + catch (WebApplicationException e) + { + logger.error("Error while reading Bundle with id {} from organization {}: {}", bundleId.getValue(), + task.getRequester().getReference(), e.getMessage()); + throw new RuntimeException("Error while reading Bundle with id " + bundleId.getValue() + + " from organization " + task.getRequester().getReference() + ", " + e.getMessage(), e); + } + + if (!EnumSet.of(BundleType.TRANSACTION, BundleType.BATCH).contains(bundle.getType())) + { + logger.error("Bundle type TRANSACTION or BATCH expected, but got {}", bundle.getType()); + throw new RuntimeException("Bundle type TRANSACTION or BATCH expected, but got " + bundle.getType()); + } + + execution.setVariable(BPMN_EXECUTION_VARIABLE_BUNDLE, FhirResourceValues.create(bundle)); + } + + private IdType getBundleId(Task task) + { + List<Reference> bundleReferences = getTaskHelper().getInputParameterReferenceValues(task, + CODESYSTEM_HIGHMED_UPDATE_RESOURCE, CODESYSTEM_HIGHMED_UPDATE_RESOURCE_VALUE_BUNDLE_REFERENCE) + .collect(Collectors.toList()); + + if (bundleReferences.size() != 1) + { + logger.error("Task input parameter {} contains unexpected number of Bundle IDs, expected 1, got {}", + CODESYSTEM_HIGHMED_UPDATE_RESOURCE_VALUE_BUNDLE_REFERENCE, bundleReferences.size()); + throw new RuntimeException( + "Task input parameter " + CODESYSTEM_HIGHMED_UPDATE_RESOURCE_VALUE_BUNDLE_REFERENCE + + " contains unexpected number of Bundle IDs, expected 1, got " + bundleReferences.size()); + } + else if (!bundleReferences.get(0).hasReference() + || !bundleReferences.get(0).getReference().contains("/Bundle/")) + { + logger.error("Task input parameter {} has no Bundle reference", + CODESYSTEM_HIGHMED_UPDATE_RESOURCE_VALUE_BUNDLE_REFERENCE); + throw new RuntimeException("Task input parameter " + + CODESYSTEM_HIGHMED_UPDATE_RESOURCE_VALUE_BUNDLE_REFERENCE + " has no Bundle reference"); + } + + return new IdType(bundleReferences.get(0).getReference()); + } +} diff --git a/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/service/SelectResourceAndTargets.java b/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/service/SelectResourceAndTargets.java index 648abf44..17410614 100644 --- a/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/service/SelectResourceAndTargets.java +++ b/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/service/SelectResourceAndTargets.java @@ -13,12 +13,15 @@ import org.camunda.bpm.engine.delegate.DelegateExecution; import org.highmed.dsf.bpe.delegate.AbstractServiceDelegate; +import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper; import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider; +import org.highmed.dsf.fhir.organization.EndpointProvider; import org.highmed.dsf.fhir.organization.OrganizationProvider; import org.highmed.dsf.fhir.task.TaskHelper; import org.highmed.dsf.fhir.variables.Target; import org.highmed.dsf.fhir.variables.Targets; import org.highmed.dsf.fhir.variables.TargetsValues; +import org.hl7.fhir.r4.model.Endpoint; import org.hl7.fhir.r4.model.Reference; import org.hl7.fhir.r4.model.Task; import org.slf4j.Logger; @@ -33,13 +36,16 @@ public class SelectResourceAndTargets extends AbstractServiceDelegate implements private static final Pattern BUNDLE_ID_PATTERN = Pattern.compile(BUNDLE_ID_PATTERN_STRING); private final OrganizationProvider organizationProvider; + private final EndpointProvider endpointProvider; public SelectResourceAndTargets(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, - OrganizationProvider organizationProvider) + ReadAccessHelper readAccessHelper, OrganizationProvider organizationProvider, + EndpointProvider endpointProvider) { - super(clientProvider, taskHelper); + super(clientProvider, taskHelper, readAccessHelper); this.organizationProvider = organizationProvider; + this.endpointProvider = endpointProvider; } @Override @@ -80,8 +86,10 @@ else if (!BUNDLE_ID_PATTERN.matcher(references.get(0).getReference()).matches()) List<Target> targets = targetIdentifierSearchParameters.stream() .flatMap(organizationProvider::searchRemoteOrganizationsIdentifiers) - .map(identifier -> Target.createUniDirectionalTarget(identifier.getValue())) - .collect(Collectors.toList()); + .map(identifier -> Target.createUniDirectionalTarget(identifier.getValue(), + endpointProvider.getFirstDefaultEndpoint(identifier.getValue()).filter(Endpoint::hasAddress) + .map(Endpoint::getAddress).orElse(null))) + .filter(t -> t.getTargetEndpointUrl() != null).collect(Collectors.toList()); execution.setVariable(BPMN_EXECUTION_VARIABLE_TARGETS, TargetsValues.create(new Targets(targets))); } } diff --git a/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/service/UpdateResources.java b/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/service/UpdateResources.java index 9c0b845d..a23df160 100644 --- a/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/service/UpdateResources.java +++ b/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/service/UpdateResources.java @@ -1,22 +1,19 @@ package org.highmed.dsf.bpe.service; +import static org.highmed.dsf.bpe.ConstantsUpdateResources.BPMN_EXECUTION_VARIABLE_BUNDLE; import static org.highmed.dsf.bpe.ConstantsUpdateResources.CODESYSTEM_HIGHMED_UPDATE_RESOURCE; import static org.highmed.dsf.bpe.ConstantsUpdateResources.CODESYSTEM_HIGHMED_UPDATE_RESOURCE_VALUE_BUNDLE_REFERENCE; -import java.util.EnumSet; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; -import javax.ws.rs.WebApplicationException; - import org.camunda.bpm.engine.delegate.DelegateExecution; import org.highmed.dsf.bpe.delegate.AbstractServiceDelegate; +import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper; import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider; import org.highmed.dsf.fhir.task.TaskHelper; -import org.highmed.fhir.client.FhirWebserviceClient; import org.hl7.fhir.r4.model.Bundle; -import org.hl7.fhir.r4.model.Bundle.BundleType; import org.hl7.fhir.r4.model.IdType; import org.hl7.fhir.r4.model.Reference; import org.hl7.fhir.r4.model.Task; @@ -32,9 +29,11 @@ public class UpdateResources extends AbstractServiceDelegate implements Initiali private final FhirContext context; - public UpdateResources(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, FhirContext context) + public UpdateResources(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, + ReadAccessHelper readAccessHelper, FhirContext context) { - super(clientProvider, taskHelper); + super(clientProvider, taskHelper, readAccessHelper); + this.context = context; } @@ -42,6 +41,7 @@ public UpdateResources(FhirWebserviceClientProvider clientProvider, TaskHelper t public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); + Objects.requireNonNull(context, "fhirContext"); } @@ -50,30 +50,8 @@ public void doExecute(DelegateExecution execution) throws Exception { Task task = getCurrentTaskFromExecutionVariables(); IdType bundleId = getBundleId(task); - FhirWebserviceClient requesterClient = getFhirWebserviceClientProvider() - .getRemoteWebserviceClient(bundleId.getBaseUrl()); - Bundle bundle; - try - { - if (bundleId.hasVersionIdPart()) - bundle = requesterClient.read(Bundle.class, bundleId.getIdPart(), bundleId.getVersionIdPart()); - else - bundle = requesterClient.read(Bundle.class, bundleId.getIdPart()); - } - catch (WebApplicationException e) - { - logger.error("Error while reading Bundle with id {} from organization {}: {}", bundleId.getValue(), - task.getRequester().getReference(), e.getMessage()); - throw new RuntimeException("Error while reading Bundle with id " + bundleId.getValue() - + " from organization " + task.getRequester().getReference() + ", " + e.getMessage(), e); - } - - if (!EnumSet.of(BundleType.TRANSACTION, BundleType.BATCH).contains(bundle.getType())) - { - logger.error("Bundle type TRANSACTION or BATCH expected, but got {}", bundle.getType()); - throw new RuntimeException("Bundle type TRANSACTION or BATCH expected, but got " + bundle.getType()); - } + Bundle bundle = (Bundle) execution.getVariable(BPMN_EXECUTION_VARIABLE_BUNDLE); try { diff --git a/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/spring/config/UpdateResourcesConfig.java b/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/spring/config/UpdateResourcesConfig.java index 8625f6f6..e5ff7d51 100644 --- a/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/spring/config/UpdateResourcesConfig.java +++ b/dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/spring/config/UpdateResourcesConfig.java @@ -2,9 +2,12 @@ import org.highmed.dsf.bpe.message.SendRequest; import org.highmed.dsf.bpe.service.CheckRequest; +import org.highmed.dsf.bpe.service.DownloadBundle; import org.highmed.dsf.bpe.service.SelectResourceAndTargets; import org.highmed.dsf.bpe.service.UpdateResources; +import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper; import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider; +import org.highmed.dsf.fhir.organization.EndpointProvider; import org.highmed.dsf.fhir.organization.OrganizationProvider; import org.highmed.dsf.fhir.task.TaskHelper; import org.springframework.beans.factory.annotation.Autowired; @@ -19,11 +22,17 @@ public class UpdateResourcesConfig @Autowired private FhirWebserviceClientProvider clientProvider; + @Autowired + private TaskHelper taskHelper; + + @Autowired + private ReadAccessHelper readAccessHelper; + @Autowired private OrganizationProvider organizationProvider; @Autowired - private TaskHelper taskHelper; + private EndpointProvider endpointProvider; @Autowired private FhirContext fhirContext; @@ -31,24 +40,31 @@ public class UpdateResourcesConfig @Bean public SendRequest sendRequest() { - return new SendRequest(clientProvider, taskHelper, organizationProvider, fhirContext); + return new SendRequest(clientProvider, taskHelper, readAccessHelper, organizationProvider, fhirContext); } @Bean public SelectResourceAndTargets selectUpdateResourcesTargets() { - return new SelectResourceAndTargets(clientProvider, taskHelper, organizationProvider); + return new SelectResourceAndTargets(clientProvider, taskHelper, readAccessHelper, organizationProvider, + endpointProvider); } @Bean - public UpdateResources updateResources() + public DownloadBundle downloadBundle() { - return new UpdateResources(clientProvider, taskHelper, fhirContext); + return new DownloadBundle(clientProvider, taskHelper, readAccessHelper); } @Bean public CheckRequest checkRequest() { - return new CheckRequest(clientProvider, taskHelper, organizationProvider); + return new CheckRequest(clientProvider, taskHelper, readAccessHelper); + } + + @Bean + public UpdateResources updateResources() + { + return new UpdateResources(clientProvider, taskHelper, readAccessHelper, fhirContext); } } diff --git a/dsf-bpe-process-update-resources/src/main/resources/bpe/executeUpdateResources.bpmn b/dsf-bpe-process-update-resources/src/main/resources/bpe/executeUpdateResources.bpmn index 163eaf4c..b19a714c 100644 --- a/dsf-bpe-process-update-resources/src/main/resources/bpe/executeUpdateResources.bpmn +++ b/dsf-bpe-process-update-resources/src/main/resources/bpe/executeUpdateResources.bpmn @@ -1,11 +1,11 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0k0v4i2" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.5.0"> - <bpmn:process id="executeUpdateResources" isExecutable="true" camunda:versionTag="0.5.0"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0k0v4i2" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.8.1"> + <bpmn:process id="highmedorg_executeUpdateResources" isExecutable="true" camunda:versionTag="0.5.0"> <bpmn:startEvent id="StartEvent_1"> <bpmn:outgoing>SequenceFlow_0djh0eg</bpmn:outgoing> <bpmn:messageEventDefinition messageRef="Message_1r6vnvn" /> </bpmn:startEvent> - <bpmn:sequenceFlow id="SequenceFlow_0djh0eg" sourceRef="StartEvent_1" targetRef="checkRequest" /> + <bpmn:sequenceFlow id="SequenceFlow_0djh0eg" sourceRef="StartEvent_1" targetRef="downloadBundle" /> <bpmn:serviceTask id="updateResources" name="updateResources" camunda:class="org.highmed.dsf.bpe.service.UpdateResources"> <bpmn:incoming>SequenceFlow_141lpsf</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0eygcor</bpmn:outgoing> @@ -16,35 +16,47 @@ <bpmn:sequenceFlow id="SequenceFlow_0eygcor" sourceRef="updateResources" targetRef="EndEvent_1i1w8yx" /> <bpmn:sequenceFlow id="SequenceFlow_141lpsf" sourceRef="checkRequest" targetRef="updateResources" /> <bpmn:serviceTask id="checkRequest" name="checkRequest" camunda:class="org.highmed.dsf.bpe.service.CheckRequest"> - <bpmn:incoming>SequenceFlow_0djh0eg</bpmn:incoming> + <bpmn:incoming>Flow_1iamqwv</bpmn:incoming> <bpmn:outgoing>SequenceFlow_141lpsf</bpmn:outgoing> </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1iamqwv" sourceRef="downloadBundle" targetRef="checkRequest" /> + <bpmn:serviceTask id="downloadBundle" name="downloadBundle" camunda:class="org.highmed.dsf.bpe.service.DownloadBundle"> + <bpmn:incoming>SequenceFlow_0djh0eg</bpmn:incoming> + <bpmn:outgoing>Flow_1iamqwv</bpmn:outgoing> + </bpmn:serviceTask> </bpmn:process> <bpmn:message id="Message_1r6vnvn" name="executeUpdateResourcesMessage" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> - <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="executeUpdateResources"> - <bpmndi:BPMNShape id="StartEvent_1orek60_di" bpmnElement="StartEvent_1"> - <dc:Bounds x="179" y="103" width="36" height="36" /> - </bpmndi:BPMNShape> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="highmedorg_executeUpdateResources"> + <bpmndi:BPMNEdge id="Flow_1iamqwv_di" bpmnElement="Flow_1iamqwv"> + <di:waypoint x="370" y="121" /> + <di:waypoint x="430" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_141lpsf_di" bpmnElement="SequenceFlow_141lpsf"> + <di:waypoint x="530" y="121" /> + <di:waypoint x="593" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0eygcor_di" bpmnElement="SequenceFlow_0eygcor"> + <di:waypoint x="693" y="121" /> + <di:waypoint x="752" y="121" /> + </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0djh0eg_di" bpmnElement="SequenceFlow_0djh0eg"> <di:waypoint x="215" y="121" /> <di:waypoint x="270" y="121" /> </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_1orek60_di" bpmnElement="StartEvent_1"> + <dc:Bounds x="179" y="103" width="36" height="36" /> + </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_1t3955f_di" bpmnElement="updateResources"> - <dc:Bounds x="433" y="81" width="100" height="80" /> + <dc:Bounds x="593" y="81" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_1i1w8yx_di" bpmnElement="EndEvent_1i1w8yx"> - <dc:Bounds x="622" y="103" width="36" height="36" /> + <dc:Bounds x="752" y="103" width="36" height="36" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0eygcor_di" bpmnElement="SequenceFlow_0eygcor"> - <di:waypoint x="533" y="121" /> - <di:waypoint x="622" y="121" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_141lpsf_di" bpmnElement="SequenceFlow_141lpsf"> - <di:waypoint x="370" y="121" /> - <di:waypoint x="433" y="121" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_1aaurev_di" bpmnElement="checkRequest"> + <dc:Bounds x="430" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_059xaj1_di" bpmnElement="downloadBundle"> <dc:Bounds x="270" y="81" width="100" height="80" /> </bpmndi:BPMNShape> </bpmndi:BPMNPlane> diff --git a/dsf-bpe-process-update-resources/src/main/resources/bpe/requestUpdateResources.bpmn b/dsf-bpe-process-update-resources/src/main/resources/bpe/requestUpdateResources.bpmn index a8cc6c39..b1870ae7 100644 --- a/dsf-bpe-process-update-resources/src/main/resources/bpe/requestUpdateResources.bpmn +++ b/dsf-bpe-process-update-resources/src/main/resources/bpe/requestUpdateResources.bpmn @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0os0n0z" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.7.1"> - <bpmn:process id="requestUpdateResources" isExecutable="true" camunda:versionTag="0.5.0"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0os0n0z" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.8.1"> + <bpmn:process id="highmedorg_requestUpdateResources" isExecutable="true" camunda:versionTag="0.5.0"> <bpmn:sequenceFlow id="SequenceFlow_1ryplwc" sourceRef="StartEvent_1" targetRef="selectResourceAndTargets" /> <bpmn:sequenceFlow id="SequenceFlow_1u4zxix" sourceRef="selectResourceAndTargets" targetRef="sendRequest" /> <bpmn:endEvent id="EndEvent_1f9cjs7"> @@ -10,8 +10,7 @@ <bpmn:sendTask id="sendRequest" name="sendRequest" camunda:class="org.highmed.dsf.bpe.message.SendRequest"> <bpmn:extensionElements> <camunda:inputOutput> - <camunda:inputParameter name="processDefinitionKey">executeUpdateResources</camunda:inputParameter> - <camunda:inputParameter name="versionTag">0.5.0</camunda:inputParameter> + <camunda:inputParameter name="instantiatesUri">http://highmed.org/bpe/Process/executeUpdateResources/0.5.0</camunda:inputParameter> <camunda:inputParameter name="messageName">executeUpdateResourcesMessage</camunda:inputParameter> <camunda:inputParameter name="profile">http://highmed.org/fhir/StructureDefinition/task-execute-update-resources</camunda:inputParameter> </camunda:inputOutput> @@ -31,7 +30,7 @@ </bpmn:process> <bpmn:message id="Message_1buqzgq" name="requestUpdateResourcesMessage" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> - <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="requestUpdateResources"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="highmedorg_requestUpdateResources"> <bpmndi:BPMNEdge id="SequenceFlow_1xwki6k_di" bpmnElement="SequenceFlow_1xwki6k"> <di:waypoint x="515" y="121" /> <di:waypoint x="565" y="121" /> diff --git a/dsf-bpe-process-update-resources/src/main/resources/fhir/ActivityDefinition/highmed-executeUpdateResources.xml b/dsf-bpe-process-update-resources/src/main/resources/fhir/ActivityDefinition/highmed-executeUpdateResources.xml index 6fa2d639..ef94a41f 100644 --- a/dsf-bpe-process-update-resources/src/main/resources/fhir/ActivityDefinition/highmed-executeUpdateResources.xml +++ b/dsf-bpe-process-update-resources/src/main/resources/fhir/ActivityDefinition/highmed-executeUpdateResources.xml @@ -1,58 +1,46 @@ <ActivityDefinition xmlns="http://hl7.org/fhir"> <meta> <tag> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="REMOTE" /> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag" /> + <code value="ALL" /> </tag> </meta> <extension url="http://highmed.org/fhir/StructureDefinition/extension-process-authorization"> <extension url="message-name"> <valueString value="executeUpdateResourcesMessage" /> </extension> - <extension url="authorization-roles"> - <extension url="authorization-role"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="REMOTE" /> - </valueCoding> - </extension> - </extension> - <extension url="requester-organization-types"> - <extension url="requester-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="TTP" /> - </valueCoding> - </extension> - </extension> - <extension url="recipient-organization-types"> - <extension url="recipient-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="TTP" /> - </valueCoding> - </extension> - <extension url="recipient-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="MeDIC" /> - </valueCoding> - </extension> - </extension> <extension url="task-profile"> <valueCanonical value="http://highmed.org/fhir/StructureDefinition/task-execute-update-resources" /> </extension> + <extension url="requester"> + <valueCoding> + <extension url="http://highmed.org/fhir/StructureDefinition/extension-process-authorization-organization"> + <valueIdentifier> + <system value="http://highmed.org/sid/organization-identifier" /> + <value value="${org.highmed.dsf.bpe.allow.list.organization:hs-heilbronn.de}" /> + </valueIdentifier> + </extension> + <system value="http://highmed.org/fhir/CodeSystem/process-authorization" /> + <code value="REMOTE_ORGANIZATION" /> + </valueCoding> + </extension> + <extension url="recipient"> + <valueCoding> + <system value="http://highmed.org/fhir/CodeSystem/process-authorization" /> + <code value="LOCAL_ALL" /> + </valueCoding> + </extension> </extension> <url value="http://highmed.org/bpe/Process/executeUpdateResources" /> <!-- version managed by bpe --> <version value="${version}" /> - <name value="executeUpdateResources" /> + <name value="ExecuteUpdateResources" /> <title value="Execute Update of Resources" /> <subtitle value="Process to Download and Execute FHIR Bundle" /> <!-- status managed by bpe --> <status value="unknown" /> <experimental value="false" /> - <date value="2021-01-26" /> + <date value="2021-06-07" /> <publisher value="HiGHmed" /> <contact> <name value="HiGHmed" /> diff --git a/dsf-bpe-process-update-resources/src/main/resources/fhir/ActivityDefinition/highmed-requestUpdateResources.xml b/dsf-bpe-process-update-resources/src/main/resources/fhir/ActivityDefinition/highmed-requestUpdateResources.xml index 9dadde3f..e7bec910 100644 --- a/dsf-bpe-process-update-resources/src/main/resources/fhir/ActivityDefinition/highmed-requestUpdateResources.xml +++ b/dsf-bpe-process-update-resources/src/main/resources/fhir/ActivityDefinition/highmed-requestUpdateResources.xml @@ -1,52 +1,52 @@ <ActivityDefinition xmlns="http://hl7.org/fhir"> <meta> <tag> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="REMOTE" /> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag" /> + <code value="ALL" /> </tag> </meta> <extension url="http://highmed.org/fhir/StructureDefinition/extension-process-authorization"> <extension url="message-name"> <valueString value="requestUpdateResourcesMessage" /> </extension> - <extension url="authorization-roles"> - <extension url="authorization-role"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="LOCAL" /> - </valueCoding> - </extension> - </extension> - <extension url="requester-organization-types"> - <extension url="requester-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="TTP" /> - </valueCoding> - </extension> - </extension> - <extension url="recipient-organization-types"> - <extension url="recipient-organization-type"> - <valueCoding> - <system value="http://highmed.org/fhir/CodeSystem/organization-type" /> - <code value="TTP" /> - </valueCoding> - </extension> - </extension> <extension url="task-profile"> <valueCanonical value="http://highmed.org/fhir/StructureDefinition/task-request-update-resources" /> </extension> + <extension url="requester"> + <valueCoding> + <extension url="http://highmed.org/fhir/StructureDefinition/extension-process-authorization-organization"> + <valueIdentifier> + <system value="http://highmed.org/sid/organization-identifier" /> + <value value="${org.highmed.dsf.bpe.allow.list.organization:hs-heilbronn.de}" /> + </valueIdentifier> + </extension> + <system value="http://highmed.org/fhir/CodeSystem/process-authorization" /> + <code value="LOCAL_ORGANIZATION" /> + </valueCoding> + </extension> + <extension url="recipient"> + <valueCoding> + <extension url="http://highmed.org/fhir/StructureDefinition/extension-process-authorization-organization"> + <valueIdentifier> + <system value="http://highmed.org/sid/organization-identifier" /> + <value value="${org.highmed.dsf.bpe.allow.list.organization:hs-heilbronn.de}" /> + </valueIdentifier> + </extension> + <system value="http://highmed.org/fhir/CodeSystem/process-authorization" /> + <code value="LOCAL_ORGANIZATION" /> + </valueCoding> + </extension> </extension> <url value="http://highmed.org/bpe/Process/requestUpdateResources" /> <!-- version managed by bpe --> <version value="${version}" /> - <name value="requestUpdateResources" /> + <name value="RequestUpdateResources" /> <title value="Request Update of Resources" /> <subtitle value="Process to Request a Bundle Download" /> <!-- status managed by bpe --> <status value="unknown" /> <experimental value="false" /> - <date value="2021-01-26" /> + <date value="2021-06-07" /> <publisher value="HiGHmed" /> <contact> <name value="HiGHmed" /> diff --git a/dsf-bpe-process-update-resources/src/main/resources/fhir/CodeSystem/highmed-update-resources.xml b/dsf-bpe-process-update-resources/src/main/resources/fhir/CodeSystem/highmed-update-resources.xml index 0909b4eb..9ea9e494 100644 --- a/dsf-bpe-process-update-resources/src/main/resources/fhir/CodeSystem/highmed-update-resources.xml +++ b/dsf-bpe-process-update-resources/src/main/resources/fhir/CodeSystem/highmed-update-resources.xml @@ -1,33 +1,33 @@ <CodeSystem xmlns="http://hl7.org/fhir"> <meta> <tag> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role"/> - <code value="REMOTE"/> - </tag> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag" /> + <code value="ALL" /> + </tag> </meta> - <url value="http://highmed.org/fhir/CodeSystem/update-resources"/> + <url value="http://highmed.org/fhir/CodeSystem/update-resources" /> <!-- version managed by bpe --> <version value="${version}" /> - <name value="HiGHmed_Update_Resources"/> - <title value="HiGHmed Update Resources"/> + <name value="HiGHmed_Update_Resources" /> + <title value="HiGHmed Update Resources" /> <!-- status managed by bpe --> <status value="unknown" /> - <experimental value="false"/> - <date value="2021-01-26"/> - <publisher value="HiGHmed"/> - <description value="CodeSystem with standard values for the process update resources"/> - <caseSensitive value="true"/> - <hierarchyMeaning value="grouped-by"/> - <versionNeeded value="false"/> - <content value="complete"/> + <experimental value="false" /> + <date value="2021-06-07" /> + <publisher value="HiGHmed" /> + <description value="CodeSystem with standard values for the process update resources" /> + <caseSensitive value="true" /> + <hierarchyMeaning value="grouped-by" /> + <versionNeeded value="false" /> + <content value="complete" /> <concept> - <code value="bundle-reference"/> - <display value="Bundle Reference"/> - <definition value="Bundle reference to be downloaded to update local resources"/> + <code value="bundle-reference" /> + <display value="Bundle Reference" /> + <definition value="Bundle reference to be downloaded to update local resources" /> </concept> <concept> - <code value="organization-identifier-search-parameter"/> - <display value="Organization Identifier Search Parameter"/> - <definition value="Organization system identifier as search parameter to define which organization are targets"/> + <code value="organization-identifier-search-parameter" /> + <display value="Organization Identifier Search Parameter" /> + <definition value="Organization system identifier as search parameter to define which organization are targets" /> </concept> </CodeSystem> \ No newline at end of file diff --git a/dsf-bpe-process-update-resources/src/main/resources/fhir/StructureDefinition/highmed-task-execute-update-resources.xml b/dsf-bpe-process-update-resources/src/main/resources/fhir/StructureDefinition/highmed-task-execute-update-resources.xml index 0075d577..c8b10c94 100644 --- a/dsf-bpe-process-update-resources/src/main/resources/fhir/StructureDefinition/highmed-task-execute-update-resources.xml +++ b/dsf-bpe-process-update-resources/src/main/resources/fhir/StructureDefinition/highmed-task-execute-update-resources.xml @@ -1,8 +1,8 @@ <StructureDefinition xmlns="http://hl7.org/fhir"> <meta> <tag> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="REMOTE" /> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag" /> + <code value="ALL" /> </tag> </meta> <url value="http://highmed.org/fhir/StructureDefinition/task-execute-update-resources" /> @@ -12,7 +12,7 @@ <!-- status managed by bpe --> <status value="unknown" /> <experimental value="false" /> - <date value="2021-01-26" /> + <date value="2021-06-07" /> <fhirVersion value="4.0.1" /> <kind value="resource" /> <abstract value="false" /> diff --git a/dsf-bpe-process-update-resources/src/main/resources/fhir/StructureDefinition/highmed-task-request-update-resources.xml b/dsf-bpe-process-update-resources/src/main/resources/fhir/StructureDefinition/highmed-task-request-update-resources.xml index abd1fe4f..acfbb685 100644 --- a/dsf-bpe-process-update-resources/src/main/resources/fhir/StructureDefinition/highmed-task-request-update-resources.xml +++ b/dsf-bpe-process-update-resources/src/main/resources/fhir/StructureDefinition/highmed-task-request-update-resources.xml @@ -1,8 +1,8 @@ <StructureDefinition xmlns="http://hl7.org/fhir"> <meta> <tag> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role" /> - <code value="REMOTE" /> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag" /> + <code value="ALL" /> </tag> </meta> <url value="http://highmed.org/fhir/StructureDefinition/task-request-update-resources" /> @@ -12,7 +12,7 @@ <!-- status managed by bpe --> <status value="unknown" /> <experimental value="false" /> - <date value="2021-01-26" /> + <date value="2021-06-07" /> <fhirVersion value="4.0.1" /> <kind value="resource" /> <abstract value="false" /> diff --git a/dsf-bpe-process-update-resources/src/main/resources/fhir/ValueSet/highmed-update-resources.xml b/dsf-bpe-process-update-resources/src/main/resources/fhir/ValueSet/highmed-update-resources.xml index 36e81323..13ab8482 100644 --- a/dsf-bpe-process-update-resources/src/main/resources/fhir/ValueSet/highmed-update-resources.xml +++ b/dsf-bpe-process-update-resources/src/main/resources/fhir/ValueSet/highmed-update-resources.xml @@ -1,26 +1,25 @@ <ValueSet xmlns="http://hl7.org/fhir"> <meta> <tag> - <system value="http://highmed.org/fhir/CodeSystem/authorization-role"/> - <code value="REMOTE"/> - </tag> + <system value="http://highmed.org/fhir/CodeSystem/read-access-tag" /> + <code value="ALL" /> + </tag> </meta> - <url value="http://highmed.org/fhir/ValueSet/update-resources"/> + <url value="http://highmed.org/fhir/ValueSet/update-resources" /> <!-- version managed by bpe --> <version value="${version}" /> - <name value="HiGHmed_Update_Resources"/> - <title value="HiGHmed Update Resources"/> + <name value="HiGHmed_Update_Resources" /> + <title value="HiGHmed Update Resources" /> <!-- status managed by bpe --> <status value="unknown" /> - <experimental value="false"/> - <date value="2021-01-26"/> - <publisher value="HiGHmed"/> - <description - value="ValueSet with standard values for the process update resources"/> - <immutable value="true"/> + <experimental value="false" /> + <date value="2021-06-07" /> + <publisher value="HiGHmed" /> + <description value="ValueSet with standard values for the process update resources" /> + <immutable value="true" /> <compose> <include> - <system value="http://highmed.org/fhir/CodeSystem/update-resources"/> + <system value="http://highmed.org/fhir/CodeSystem/update-resources" /> </include> </compose> </ValueSet> \ No newline at end of file diff --git a/dsf-bpe-process-update-resources/src/test/java/org/highmed/dsf/bpe/start/AbstractUpdateResource3MedicTtpExampleStarter.java b/dsf-bpe-process-update-resources/src/test/java/org/highmed/dsf/bpe/start/AbstractUpdateResource3MedicTtpExampleStarter.java new file mode 100644 index 00000000..9fa0731b --- /dev/null +++ b/dsf-bpe-process-update-resources/src/test/java/org/highmed/dsf/bpe/start/AbstractUpdateResource3MedicTtpExampleStarter.java @@ -0,0 +1,81 @@ +package org.highmed.dsf.bpe.start; + +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN; +import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME; +import static org.highmed.dsf.bpe.ConstantsBase.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER; +import static org.highmed.dsf.bpe.ConstantsUpdateResources.CODESYSTEM_HIGHMED_UPDATE_RESOURCE; +import static org.highmed.dsf.bpe.ConstantsUpdateResources.CODESYSTEM_HIGHMED_UPDATE_RESOURCE_VALUE_BUNDLE_REFERENCE; +import static org.highmed.dsf.bpe.ConstantsUpdateResources.CODESYSTEM_HIGHMED_UPDATE_RESOURCE_VALUE_ORGANIZATION_IDENTIFIER_SEARCH_PARAMETER; +import static org.highmed.dsf.bpe.ConstantsUpdateResources.PROFILE_HIGHMED_TASK_REQUEST_UPDATE_RESOURCES; +import static org.highmed.dsf.bpe.ConstantsUpdateResources.PROFILE_HIGHMED_TASK_REQUEST_UPDATE_RESOURCES_MESSAGE_NAME; +import static org.highmed.dsf.bpe.ConstantsUpdateResources.PROFILE_HIGHMED_TASK_REQUEST_UPDATE_RESOURCES_PROCESS_URI_AND_LATEST_VERSION; +import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_TTP; + +import java.util.Collections; +import java.util.Date; +import java.util.Map; + +import org.highmed.fhir.client.FhirWebserviceClient; +import org.hl7.fhir.r4.model.Bundle; +import org.hl7.fhir.r4.model.IdType; +import org.hl7.fhir.r4.model.Reference; +import org.hl7.fhir.r4.model.ResourceType; +import org.hl7.fhir.r4.model.StringType; +import org.hl7.fhir.r4.model.Task; +import org.hl7.fhir.r4.model.Task.TaskIntent; +import org.hl7.fhir.r4.model.Task.TaskStatus; + +public abstract class AbstractUpdateResource3MedicTtpExampleStarter +{ + protected void main(String[] args, String baseUrl) throws Exception + { + ExampleStarter starter = ExampleStarter.forServer(args, baseUrl); + Task task = createStartResource(starter, baseUrl); + starter.startWith(task); + } + + private Task createStartResource(ExampleStarter starter, String ttpUrl) throws Exception + { + Bundle allowList = getAllowList(starter, ttpUrl); + + Task task = new Task(); + task.getMeta().addProfile(PROFILE_HIGHMED_TASK_REQUEST_UPDATE_RESOURCES); + task.setInstantiatesUri(PROFILE_HIGHMED_TASK_REQUEST_UPDATE_RESOURCES_PROCESS_URI_AND_LATEST_VERSION); + task.setStatus(TaskStatus.REQUESTED); + task.setIntent(TaskIntent.ORDER); + task.setAuthoredOn(new Date()); + task.getRequester().setType(ResourceType.Organization.name()).getIdentifier() + .setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER) + .setValue(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_TTP); + task.getRestriction().addRecipient().setType(ResourceType.Organization.name()).getIdentifier() + .setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER) + .setValue(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_TTP); + + task.addInput().setValue(new StringType(PROFILE_HIGHMED_TASK_REQUEST_UPDATE_RESOURCES_MESSAGE_NAME)).getType() + .addCoding().setSystem(CODESYSTEM_HIGHMED_BPMN).setCode(CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME); + + task.addInput() + .setValue(new Reference(new IdType(ResourceType.Bundle.name(), allowList.getIdElement().getIdPart(), + allowList.getIdElement().getVersionIdPart()))) + .getType().addCoding().setSystem(CODESYSTEM_HIGHMED_UPDATE_RESOURCE) + .setCode(CODESYSTEM_HIGHMED_UPDATE_RESOURCE_VALUE_BUNDLE_REFERENCE); + + task.addInput().setValue(new StringType(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER + "|")).getType() + .addCoding().setSystem(CODESYSTEM_HIGHMED_UPDATE_RESOURCE) + .setCode(CODESYSTEM_HIGHMED_UPDATE_RESOURCE_VALUE_ORGANIZATION_IDENTIFIER_SEARCH_PARAMETER); + + return task; + } + + private Bundle getAllowList(ExampleStarter starter, String ttpUrl) throws Exception + { + FhirWebserviceClient client = starter.createClient(ttpUrl); + Bundle searchResult = client.searchWithStrictHandling(Bundle.class, Map.of("identifier", + Collections.singletonList("http://highmed.org/fhir/CodeSystem/update-allow-list|allow_list"))); + + if (searchResult.getTotal() != 1 && searchResult.getEntryFirstRep().getResource() instanceof Bundle) + throw new IllegalStateException("Expected a single allow list Bundle"); + + return (Bundle) searchResult.getEntryFirstRep().getResource(); + } +} diff --git a/dsf-bpe-process-update-resources/src/test/java/org/highmed/dsf/bpe/start/UpdateResource3MedicTtpDockerExampleStarter.java b/dsf-bpe-process-update-resources/src/test/java/org/highmed/dsf/bpe/start/UpdateResource3MedicTtpDockerExampleStarter.java new file mode 100644 index 00000000..da80cea3 --- /dev/null +++ b/dsf-bpe-process-update-resources/src/test/java/org/highmed/dsf/bpe/start/UpdateResource3MedicTtpDockerExampleStarter.java @@ -0,0 +1,15 @@ +package org.highmed.dsf.bpe.start; + +import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.TTP_DOCKER_FHIR_BASE_URL; + +public class UpdateResource3MedicTtpDockerExampleStarter extends AbstractUpdateResource3MedicTtpExampleStarter +{ + // Environment variable "DSF_CLIENT_CERTIFICATE_PATH" or args[0]: the path to the client-certificate + // highmed-dsf/dsf-tools/dsf-tools-test-data-generator/cert/Webbrowser_Test_User/Webbrowser_Test_User_certificate.p12 + // Environment variable "DSF_CLIENT_CERTIFICATE_PASSWORD" or args[1]: the password of the client-certificate + // password + public static void main(String[] args) throws Exception + { + new UpdateResource3MedicTtpDockerExampleStarter().main(args, TTP_DOCKER_FHIR_BASE_URL); + } +} diff --git a/dsf-bpe-process-update-resources/src/test/java/org/highmed/dsf/bpe/start/UpdateResource3MedicTtpExampleStarter.java b/dsf-bpe-process-update-resources/src/test/java/org/highmed/dsf/bpe/start/UpdateResource3MedicTtpExampleStarter.java index 813fdfe7..afd39d7d 100644 --- a/dsf-bpe-process-update-resources/src/test/java/org/highmed/dsf/bpe/start/UpdateResource3MedicTtpExampleStarter.java +++ b/dsf-bpe-process-update-resources/src/test/java/org/highmed/dsf/bpe/start/UpdateResource3MedicTtpExampleStarter.java @@ -1,32 +1,8 @@ package org.highmed.dsf.bpe.start; -import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN; -import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME; -import static org.highmed.dsf.bpe.ConstantsBase.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER; -import static org.highmed.dsf.bpe.ConstantsUpdateResources.CODESYSTEM_HIGHMED_UPDATE_RESOURCE; -import static org.highmed.dsf.bpe.ConstantsUpdateResources.CODESYSTEM_HIGHMED_UPDATE_RESOURCE_VALUE_BUNDLE_REFERENCE; -import static org.highmed.dsf.bpe.ConstantsUpdateResources.CODESYSTEM_HIGHMED_UPDATE_RESOURCE_VALUE_ORGANIZATION_IDENTIFIER_SEARCH_PARAMETER; -import static org.highmed.dsf.bpe.ConstantsUpdateResources.PROFILE_HIGHMED_TASK_REQUEST_UPDATE_RESOURCES; -import static org.highmed.dsf.bpe.ConstantsUpdateResources.PROFILE_HIGHMED_TASK_REQUEST_UPDATE_RESOURCES_MESSAGE_NAME; -import static org.highmed.dsf.bpe.ConstantsUpdateResources.PROFILE_HIGHMED_TASK_REQUEST_UPDATE_RESOURCES_PROCESS_URI_AND_LATEST_VERSION; -import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_TTP; import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.TTP_FHIR_BASE_URL; -import java.util.Collections; -import java.util.Date; -import java.util.Map; - -import org.highmed.fhir.client.FhirWebserviceClient; -import org.hl7.fhir.r4.model.Bundle; -import org.hl7.fhir.r4.model.IdType; -import org.hl7.fhir.r4.model.Reference; -import org.hl7.fhir.r4.model.ResourceType; -import org.hl7.fhir.r4.model.StringType; -import org.hl7.fhir.r4.model.Task; -import org.hl7.fhir.r4.model.Task.TaskIntent; -import org.hl7.fhir.r4.model.Task.TaskStatus; - -public class UpdateResource3MedicTtpExampleStarter +public class UpdateResource3MedicTtpExampleStarter extends AbstractUpdateResource3MedicTtpExampleStarter { // Environment variable "DSF_CLIENT_CERTIFICATE_PATH" or args[0]: the path to the client-certificate // highmed-dsf/dsf-tools/dsf-tools-test-data-generator/cert/Webbrowser_Test_User/Webbrowser_Test_User_certificate.p12 @@ -34,53 +10,6 @@ public class UpdateResource3MedicTtpExampleStarter // password public static void main(String[] args) throws Exception { - ExampleStarter starter = ExampleStarter.forServer(args, TTP_FHIR_BASE_URL); - Task task = createStartResource(starter); - starter.startWith(task); - } - - private static Task createStartResource(ExampleStarter starter) throws Exception - { - Bundle allowList = getAllowList(starter); - - Task task = new Task(); - task.getMeta().addProfile(PROFILE_HIGHMED_TASK_REQUEST_UPDATE_RESOURCES); - task.setInstantiatesUri(PROFILE_HIGHMED_TASK_REQUEST_UPDATE_RESOURCES_PROCESS_URI_AND_LATEST_VERSION); - task.setStatus(TaskStatus.REQUESTED); - task.setIntent(TaskIntent.ORDER); - task.setAuthoredOn(new Date()); - task.getRequester().setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER) - .setValue(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_TTP); - task.getRestriction().addRecipient().setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER) - .setValue(NAMINGSYSTEM_HIGHMED_ORGANIZATION_IDENTIFIER_VALUE_TTP); - - task.addInput().setValue(new StringType(PROFILE_HIGHMED_TASK_REQUEST_UPDATE_RESOURCES_MESSAGE_NAME)).getType() - .addCoding().setSystem(CODESYSTEM_HIGHMED_BPMN).setCode(CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME); - - task.addInput() - .setValue(new Reference(new IdType(ResourceType.Bundle.name(), allowList.getIdElement().getIdPart(), - allowList.getIdElement().getVersionIdPart()))) - .getType().addCoding().setSystem(CODESYSTEM_HIGHMED_UPDATE_RESOURCE) - .setCode(CODESYSTEM_HIGHMED_UPDATE_RESOURCE_VALUE_BUNDLE_REFERENCE); - - task.addInput().setValue(new StringType("http://highmed.org/fhir/NamingSystem/organization-identifier|")) - .getType().addCoding().setSystem(CODESYSTEM_HIGHMED_UPDATE_RESOURCE) - .setCode(CODESYSTEM_HIGHMED_UPDATE_RESOURCE_VALUE_ORGANIZATION_IDENTIFIER_SEARCH_PARAMETER); - - return task; - } - - private static Bundle getAllowList(ExampleStarter starter) throws Exception - { - FhirWebserviceClient client = starter.createClient(TTP_FHIR_BASE_URL); - Bundle searchResult = client.searchWithStrictHandling(Bundle.class, Map.of("identifier", - Collections.singletonList("http://highmed.org/fhir/CodeSystem/update-allow-list|highmed_allow_list"))); - - if (searchResult.getTotal() != 1 && searchResult.getEntryFirstRep().getResource() instanceof Bundle) - throw new IllegalStateException("Expected a single allow list Bundle"); - - return (Bundle) searchResult.getEntryFirstRep().getResource(); + new UpdateResource3MedicTtpExampleStarter().main(args, TTP_FHIR_BASE_URL); } } diff --git a/dsf-bpe-process-update-resources/src/test/java/org/highmed/dsf/fhir/profile/ActivityDefinitionProfileTest.java b/dsf-bpe-process-update-resources/src/test/java/org/highmed/dsf/fhir/profile/ActivityDefinitionProfileTest.java new file mode 100644 index 00000000..8c763dfa --- /dev/null +++ b/dsf-bpe-process-update-resources/src/test/java/org/highmed/dsf/fhir/profile/ActivityDefinitionProfileTest.java @@ -0,0 +1,89 @@ +package org.highmed.dsf.fhir.profile; + +import static org.highmed.dsf.bpe.UpdateResourcesProcessPluginDefinition.VERSION; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; + +import org.highmed.dsf.fhir.authorization.process.ProcessAuthorizationHelper; +import org.highmed.dsf.fhir.authorization.process.ProcessAuthorizationHelperImpl; +import org.highmed.dsf.fhir.validation.ResourceValidator; +import org.highmed.dsf.fhir.validation.ResourceValidatorImpl; +import org.highmed.dsf.fhir.validation.ValidationSupportRule; +import org.hl7.fhir.r4.model.ActivityDefinition; +import org.junit.ClassRule; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import ca.uhn.fhir.validation.ResultSeverityEnum; +import ca.uhn.fhir.validation.ValidationResult; + +public class ActivityDefinitionProfileTest +{ + private static final Logger logger = LoggerFactory.getLogger(ActivityDefinitionProfileTest.class); + + @ClassRule + public static final ValidationSupportRule validationRule = new ValidationSupportRule(VERSION, + Arrays.asList("highmed-activity-definition-0.5.0.xml", "highmed-extension-process-authorization-0.5.0.xml", + "highmed-extension-process-authorization-consortium-role-0.5.0.xml", + "highmed-extension-process-authorization-organization-0.5.0.xml", + "highmed-coding-process-authorization-local-all-0.5.0.xml", + "highmed-coding-process-authorization-local-consortium-role-0.5.0.xml", + "highmed-coding-process-authorization-local-organization-0.5.0.xml", + "highmed-coding-process-authorization-remote-all-0.5.0.xml", + "highmed-coding-process-authorization-remote-consortium-role-0.5.0.xml", + "highmed-coding-process-authorization-remote-organization-0.5.0.xml"), + Arrays.asList("highmed-read-access-tag-0.5.0.xml", "highmed-process-authorization-0.5.0.xml"), + Arrays.asList("highmed-read-access-tag-0.5.0.xml", "highmed-process-authorization-recipient-0.5.0.xml", + "highmed-process-authorization-requester-0.5.0.xml")); + + private final ResourceValidator resourceValidator = new ResourceValidatorImpl(validationRule.getFhirContext(), + validationRule.getValidationSupport()); + + private final ProcessAuthorizationHelper processAuthorizationHelper = new ProcessAuthorizationHelperImpl(); + + @Test + public void testExecuteUpdateResourcesValid() throws Exception + { + try (InputStream in = Files.newInputStream( + Paths.get("src/main/resources/fhir/ActivityDefinition/highmed-executeUpdateResources.xml"))) + { + ActivityDefinition ad = validationRule.getFhirContext().newXmlParser() + .parseResource(ActivityDefinition.class, in); + + ValidationResult result = resourceValidator.validate(ad); + ValidationSupportRule.logValidationMessages(logger, result); + + assertEquals(0, result.getMessages().stream().filter(m -> ResultSeverityEnum.ERROR.equals(m.getSeverity()) + || ResultSeverityEnum.FATAL.equals(m.getSeverity())).count()); + + assertTrue( + processAuthorizationHelper.isValid(ad, taskProfile -> true, orgIdentifier -> true, role -> true)); + } + } + + @Test + public void testRequestUpdateResourcesValid() throws Exception + { + try (InputStream in = Files.newInputStream( + Paths.get("src/main/resources/fhir/ActivityDefinition/highmed-requestUpdateResources.xml"))) + { + ActivityDefinition ad = validationRule.getFhirContext().newXmlParser() + .parseResource(ActivityDefinition.class, in); + + ValidationResult result = resourceValidator.validate(ad); + ValidationSupportRule.logValidationMessages(logger, result); + + assertEquals(0, result.getMessages().stream().filter(m -> ResultSeverityEnum.ERROR.equals(m.getSeverity()) + || ResultSeverityEnum.FATAL.equals(m.getSeverity())).count()); + + assertTrue( + processAuthorizationHelper.isValid(ad, taskProfile -> true, orgIdentifier -> true, role -> true)); + } + } +} \ No newline at end of file diff --git a/dsf-bpe-process-update-resources/src/test/java/org/highmed/dsf/fhir/profile/TaskProfileTest.java b/dsf-bpe-process-update-resources/src/test/java/org/highmed/dsf/fhir/profile/TaskProfileTest.java index c9b8ca88..b90a947f 100644 --- a/dsf-bpe-process-update-resources/src/test/java/org/highmed/dsf/fhir/profile/TaskProfileTest.java +++ b/dsf-bpe-process-update-resources/src/test/java/org/highmed/dsf/fhir/profile/TaskProfileTest.java @@ -55,9 +55,9 @@ public class TaskProfileTest public static final ValidationSupportRule validationRule = new ValidationSupportRule(VERSION, Arrays.asList("highmed-task-base-0.5.0.xml", "highmed-task-request-update-resources.xml", "highmed-task-execute-update-resources.xml"), - Arrays.asList("highmed-authorization-role-0.5.0.xml", "highmed-bpmn-message-0.5.0.xml", + Arrays.asList("highmed-read-access-tag-0.5.0.xml", "highmed-bpmn-message-0.5.0.xml", "highmed-update-resources.xml"), - Arrays.asList("highmed-authorization-role-0.5.0.xml", "highmed-bpmn-message-0.5.0.xml", + Arrays.asList("highmed-read-access-tag-0.5.0.xml", "highmed-bpmn-message-0.5.0.xml", "highmed-update-resources.xml")); private ResourceValidator resourceValidator = new ResourceValidatorImpl(validationRule.getFhirContext(), diff --git a/pom.xml b/pom.xml index 7d725203..f395ad26 100644 --- a/pom.xml +++ b/pom.xml @@ -102,7 +102,7 @@ <dependency> <groupId>de.hs-heilbronn.mi</groupId> <artifactId>log4j2-utils</artifactId> - <version>0.7.0</version> + <version>0.9.0</version> </dependency> <!-- logging --> @@ -115,14 +115,14 @@ <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> - <version>2.12.0</version> + <version>2.12.3</version> </dependency> <!-- testing --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>4.13.1</version> + <version>4.13.2</version> </dependency> <dependency> <groupId>org.highmed.dsf</groupId> @@ -188,12 +188,12 @@ <plugin> <groupId>net.revelc.code.formatter</groupId> <artifactId>formatter-maven-plugin</artifactId> - <version>2.13.0</version> + <version>2.15.0</version> </plugin> <plugin> <groupId>net.revelc.code</groupId> <artifactId>impsort-maven-plugin</artifactId> - <version>1.5.0</version> + <version>1.6.2</version> </plugin> </plugins> </pluginManagement>