Skip to content

Commit ca58b48

Browse files
committed
use constants in update resource process
1 parent a8f4ea6 commit ca58b48

File tree

3 files changed

+50
-22
lines changed

3 files changed

+50
-22
lines changed

dsf-bpe-process-update-resources/pom.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
<artifactId>dsf-bpe-process-base</artifactId>
1717
<scope>provided</scope>
1818
</dependency>
19-
19+
20+
2021
<dependency>
2122
<groupId>de.hs-heilbronn.mi</groupId>
2223
<artifactId>log4j2-utils</artifactId>
@@ -27,6 +28,12 @@
2728
<artifactId>dsf-fhir-validation</artifactId>
2829
<scope>test</scope>
2930
</dependency>
31+
<dependency>
32+
<groupId>org.highmed.dsf</groupId>
33+
<artifactId>dsf-bpe-process-base</artifactId>
34+
<scope>test</scope>
35+
<type>test-jar</type>
36+
</dependency>
3037
</dependencies>
3138

3239
<build>

dsf-bpe-process-update-resources/src/main/java/org/highmed/dsf/bpe/variables/ConstantsUpdateResources.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,9 @@ public interface ConstantsUpdateResources
55
String CODESYSTEM_HIGHMED_UPDATE_RESOURCE = "http://highmed.org/fhir/CodeSystem/update-resources";
66
String CODESYSTEM_HIGHMED_UPDATE_RESOURCE_VALUE_BUNDLE_REFERENCE = "bundle-reference";
77
String CODESYSTEM_HIGHMED_UPDATE_RESOURCE_VALUE_ORGANIZATION_IDENTIFIER_SEARCH_PARAMETER = "organization-identifier-search-parameter";
8+
9+
String REQUEST_UPDATE_RESOURCES_TASK_PROFILE = "http://highmed.org/fhir/StructureDefinition/highmed-task-request-update-resources";
10+
String REQUEST_UPDATE_RESOURCES_PROCESS_URI = "http://highmed.org/bpe/Process/requestUpdateResources";
11+
String REQUEST_UPDATE_RESOURCES_PROCESS_LATEST_VERSION = "0.4.0";
12+
String REQUEST_UPDATE_RESOURCES_MESSAGE_NAME = "requestUpdateResourcesMessage";
813
}

dsf-bpe-process-update-resources/src/test/java/org/highmed/dsf/bpe/start/UpdateResource3MedicTtpExampleStarter.java

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
package org.highmed.dsf.bpe.start;
22

3+
import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN;
4+
import static org.highmed.dsf.bpe.ConstantsBase.CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME;
5+
import static org.highmed.dsf.bpe.ConstantsBase.ORGANIZATION_IDENTIFIER_SYSTEM;
6+
import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.CERTIFICATE_PASSWORD;
7+
import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.CERTIFICATE_PATH;
8+
import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.ORGANIZATION_IDENTIFIER_VALUE_TTP;
9+
import static org.highmed.dsf.bpe.start.ConstantsExampleStarters.TTP_FHIR_BASE_URL;
10+
import static org.highmed.dsf.bpe.variables.ConstantsUpdateResources.CODESYSTEM_HIGHMED_UPDATE_RESOURCE;
11+
import static org.highmed.dsf.bpe.variables.ConstantsUpdateResources.CODESYSTEM_HIGHMED_UPDATE_RESOURCE_VALUE_BUNDLE_REFERENCE;
12+
import static org.highmed.dsf.bpe.variables.ConstantsUpdateResources.CODESYSTEM_HIGHMED_UPDATE_RESOURCE_VALUE_ORGANIZATION_IDENTIFIER_SEARCH_PARAMETER;
13+
import static org.highmed.dsf.bpe.variables.ConstantsUpdateResources.REQUEST_UPDATE_RESOURCES_MESSAGE_NAME;
14+
import static org.highmed.dsf.bpe.variables.ConstantsUpdateResources.REQUEST_UPDATE_RESOURCES_PROCESS_LATEST_VERSION;
15+
import static org.highmed.dsf.bpe.variables.ConstantsUpdateResources.REQUEST_UPDATE_RESOURCES_PROCESS_URI;
16+
import static org.highmed.dsf.bpe.variables.ConstantsUpdateResources.REQUEST_UPDATE_RESOURCES_TASK_PROFILE;
17+
318
import java.io.IOException;
419
import java.nio.file.Paths;
520
import java.security.KeyStore;
@@ -18,12 +33,14 @@
1833
import org.hl7.fhir.r4.model.Bundle;
1934
import org.hl7.fhir.r4.model.IdType;
2035
import org.hl7.fhir.r4.model.Reference;
36+
import org.hl7.fhir.r4.model.ResourceType;
2137
import org.hl7.fhir.r4.model.StringType;
2238
import org.hl7.fhir.r4.model.Task;
2339
import org.hl7.fhir.r4.model.Task.TaskIntent;
2440
import org.hl7.fhir.r4.model.Task.TaskStatus;
2541

2642
import ca.uhn.fhir.context.FhirContext;
43+
2744
import de.rwh.utils.crypto.CertificateHelper;
2845
import de.rwh.utils.crypto.io.CertificateReader;
2946

@@ -32,48 +49,47 @@ public class UpdateResource3MedicTtpExampleStarter
3249
public static void main(String[] args)
3350
throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException
3451
{
35-
char[] keyStorePassword = "password".toCharArray();
36-
KeyStore keyStore = CertificateReader.fromPkcs12(Paths.get(
37-
"../../dsf-tools/dsf-tools-test-data-generator/cert/Webbrowser_Test_User/Webbrowser_Test_User_certificate.p12"),
38-
keyStorePassword);
52+
KeyStore keyStore = CertificateReader.fromPkcs12(Paths.get(CERTIFICATE_PATH), CERTIFICATE_PASSWORD);
3953
KeyStore trustStore = CertificateHelper.extractTrust(keyStore);
4054

4155
FhirContext context = FhirContext.forR4();
4256
ReferenceCleaner referenceCleaner = new ReferenceCleanerImpl(new ReferenceExtractorImpl());
43-
FhirWebserviceClient client = new FhirWebserviceClientJersey("https://ttp/fhir/", trustStore, keyStore,
44-
keyStorePassword, null, null, null, 0, 0, null, context, referenceCleaner);
57+
FhirWebserviceClient client = new FhirWebserviceClientJersey(TTP_FHIR_BASE_URL, trustStore, keyStore,
58+
CERTIFICATE_PASSWORD, null, null, null, 0, 0, null, context, referenceCleaner);
4559

4660
Bundle searchResult = client.searchWithStrictHandling(Bundle.class, Map.of("identifier",
4761
Collections.singletonList("http://highmed.org/fhir/CodeSystem/update-allow-list|highmed_allow_list")));
62+
4863
if (searchResult.getTotal() != 1 && searchResult.getEntryFirstRep().getResource() instanceof Bundle)
4964
throw new IllegalStateException("Expected a single allow list Bundle");
5065
Bundle allowList = (Bundle) searchResult.getEntryFirstRep().getResource();
5166

5267
System.out.println(context.newXmlParser().encodeResourceToString(allowList));
5368

5469
Task task = new Task();
55-
task.getMeta().addProfile("http://highmed.org/fhir/StructureDefinition/highmed-task-request-update-resources");
56-
task.setInstantiatesUri("http://highmed.org/bpe/Process/requestUpdateResources/0.4.0");
70+
task.getMeta().addProfile(REQUEST_UPDATE_RESOURCES_TASK_PROFILE);
71+
task.setInstantiatesUri(
72+
REQUEST_UPDATE_RESOURCES_PROCESS_URI + "/" + REQUEST_UPDATE_RESOURCES_PROCESS_LATEST_VERSION);
5773
task.setStatus(TaskStatus.REQUESTED);
5874
task.setIntent(TaskIntent.ORDER);
5975
task.setAuthoredOn(new Date());
60-
task.getRequester().setType("Organization").getIdentifier()
61-
.setSystem("http://highmed.org/fhir/NamingSystem/organization-identifier").setValue("Test_TTP");
62-
task.getRestriction().addRecipient().setType("Organization").getIdentifier()
63-
.setSystem("http://highmed.org/fhir/NamingSystem/organization-identifier").setValue("Test_TTP");
76+
task.getRequester().setType(ResourceType.Organization.name()).getIdentifier()
77+
.setSystem(ORGANIZATION_IDENTIFIER_SYSTEM).setValue(ORGANIZATION_IDENTIFIER_VALUE_TTP);
78+
task.getRestriction().addRecipient().setType(ResourceType.Organization.name()).getIdentifier()
79+
.setSystem(ORGANIZATION_IDENTIFIER_SYSTEM).setValue(ORGANIZATION_IDENTIFIER_VALUE_TTP);
6480

65-
task.addInput().setValue(new StringType("requestUpdateResourcesMessage")).getType().addCoding()
66-
.setSystem("http://highmed.org/fhir/CodeSystem/bpmn-message").setCode("message-name");
81+
task.addInput().setValue(new StringType(REQUEST_UPDATE_RESOURCES_MESSAGE_NAME)).getType().addCoding()
82+
.setSystem(CODESYSTEM_HIGHMED_BPMN).setCode(CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME);
6783

68-
task.addInput()
69-
.setValue(new Reference(new IdType("Bundle", allowList.getIdElement().getIdPart(),
70-
allowList.getIdElement().getVersionIdPart())))
71-
.getType().addCoding().setSystem("http://highmed.org/fhir/CodeSystem/update-resources")
72-
.setCode("bundle-reference");
84+
task.addInput().setValue(new Reference(
85+
new IdType(ResourceType.Bundle.name(), allowList.getIdElement().getIdPart(),
86+
allowList.getIdElement().getVersionIdPart()))).getType().addCoding()
87+
.setSystem(CODESYSTEM_HIGHMED_UPDATE_RESOURCE)
88+
.setCode(CODESYSTEM_HIGHMED_UPDATE_RESOURCE_VALUE_BUNDLE_REFERENCE);
7389

7490
task.addInput().setValue(new StringType("http://highmed.org/fhir/NamingSystem/organization-identifier|"))
75-
.getType().addCoding().setSystem("http://highmed.org/fhir/CodeSystem/update-resources")
76-
.setCode("organization-identifier-search-parameter");
91+
.getType().addCoding().setSystem(CODESYSTEM_HIGHMED_UPDATE_RESOURCE)
92+
.setCode(CODESYSTEM_HIGHMED_UPDATE_RESOURCE_VALUE_ORGANIZATION_IDENTIFIER_SEARCH_PARAMETER);
7793

7894
client.withMinimalReturn().create(task);
7995
}

0 commit comments

Comments
 (0)