10
10
import org .hl7 .fhir .r4 .model .ResourceType ;
11
11
import org .hl7 .fhir .r4 .model .StringType ;
12
12
import org .hl7 .fhir .r4 .model .Task ;
13
+ import org .slf4j .Logger ;
14
+ import org .slf4j .LoggerFactory ;
13
15
14
16
import dev .dsf .bpe .AllowListProcessPluginDefinition ;
15
17
import dev .dsf .bpe .ConstantsAllowList ;
19
21
20
22
public class DownloadAllowListFromTtpViaMedic1ExampleStarter
21
23
{
22
- private static final String REQUESTER_FHIR_BASE_URL = ConstantsExampleStarters . MEDIC_1_FHIR_BASE_URL ;
23
- private static final String REQUESTER_RECIPIENT = ConstantsExampleStarters . NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1 ;
24
+ private static final Logger logger = LoggerFactory . getLogger ( DownloadAllowListFromTtpViaMedic1ExampleStarter . class ) ;
25
+
24
26
private static final String ALLOW_LIST_FHIR_BASE_URL = ConstantsExampleStarters .TTP_FHIR_BASE_URL ;
27
+ private static final Map <String , String > REQUESTER_RECIPIENT = Map .of (
28
+ ConstantsExampleStarters .NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1 ,
29
+ ConstantsExampleStarters .MEDIC_1_FHIR_BASE_URL ,
30
+ ConstantsExampleStarters .NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_2 ,
31
+ ConstantsExampleStarters .MEDIC_2_FHIR_BASE_URL ,
32
+ ConstantsExampleStarters .NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_3 ,
33
+ ConstantsExampleStarters .MEDIC_3_FHIR_BASE_URL );
25
34
26
35
// Environment variable "DSF_CLIENT_CERTIFICATE_PATH" or args[0]: the path to the client-certificate
27
36
// dsf/dsf-tools/dsf-tools-test-data-generator/cert/Webbrowser_Test_User/Webbrowser_Test_User_certificate.p12
28
37
// Environment variable "DSF_CLIENT_CERTIFICATE_PASSWORD" or args[1]: the password of the client-certificate
29
38
// password
30
39
public static void main (String [] args ) throws Exception
31
40
{
32
- ExampleStarter starter = ExampleStarter .forServer (args , REQUESTER_FHIR_BASE_URL );
41
+ ExampleStarter starter = ExampleStarter .forServer (args ,
42
+ REQUESTER_RECIPIENT .entrySet ().iterator ().next ().getValue ());
43
+ IdType allowList = allowList (starter );
33
44
34
- Bundle allowList = allowList ( starter );
35
- Task task = task ( allowList );
45
+ REQUESTER_RECIPIENT . forEach (( identifier , url ) -> start ( args , allowList , identifier , url ) );
46
+ }
36
47
37
- starter .startWith (task );
48
+ private static void start (String [] args , IdType allowList , String identifier , String url )
49
+ {
50
+ try
51
+ {
52
+ Task task = task (identifier , allowList );
53
+ ExampleStarter .forServer (args , url ).startWith (task );
54
+ }
55
+ catch (Exception exception )
56
+ {
57
+ logger .error ("Could not start download allow-list with url '{}' in organization {} with base-url '{}' - {}" ,
58
+ allowList .getValue (), identifier , url , exception .getMessage ());
59
+ }
38
60
}
39
61
40
- private static Task task (Bundle allowList )
62
+ private static Task task (String requesterRecipientIdentifierValue , IdType allowList )
41
63
{
42
64
var def = new AllowListProcessPluginDefinition ();
43
65
@@ -50,22 +72,22 @@ private static Task task(Bundle allowList)
50
72
task .setIntent (Task .TaskIntent .ORDER );
51
73
task .setAuthoredOn (new Date ());
52
74
task .getRequester ().setType (ResourceType .Organization .name ())
53
- .setIdentifier (NamingSystems .OrganizationIdentifier .withValue (REQUESTER_RECIPIENT ));
75
+ .setIdentifier (NamingSystems .OrganizationIdentifier .withValue (requesterRecipientIdentifierValue ));
54
76
task .getRestriction ().addRecipient ().setType (ResourceType .Organization .name ())
55
- .setIdentifier (NamingSystems .OrganizationIdentifier .withValue (REQUESTER_RECIPIENT ));
77
+ .setIdentifier (NamingSystems .OrganizationIdentifier .withValue (requesterRecipientIdentifierValue ));
56
78
57
79
task .addInput ().setValue (new StringType (ConstantsAllowList .PROFILE_DSF_TASK_DOWNLOAD_ALLOW_LIST_MESSAGE_NAME ))
58
80
.getType ().addCoding (CodeSystems .BpmnMessage .messageName ());
59
81
task .addInput ()
60
82
.setValue (new Reference (new IdType (ALLOW_LIST_FHIR_BASE_URL , ResourceType .Bundle .name (),
61
- allowList .getIdElement (). getIdPart (), allowList . getIdElement () .getVersionIdPart ())))
83
+ allowList .getIdPart (), allowList .getVersionIdPart ())))
62
84
.getType ().addCoding ().setSystem (ConstantsAllowList .CODESYSTEM_DSF_ALLOW_LIST )
63
85
.setCode (ConstantsAllowList .CODESYSTEM_DSF_ALLOW_LIST_VALUE_ALLOW_LIST );
64
86
65
87
return task ;
66
88
}
67
89
68
- private static Bundle allowList (ExampleStarter starter ) throws Exception
90
+ private static IdType allowList (ExampleStarter starter ) throws Exception
69
91
{
70
92
FhirWebserviceClient client = starter .createClient (ALLOW_LIST_FHIR_BASE_URL );
71
93
Bundle searchResult = client .searchWithStrictHandling (Bundle .class , Map .of ("identifier" ,
@@ -74,6 +96,6 @@ private static Bundle allowList(ExampleStarter starter) throws Exception
74
96
if (searchResult .getTotal () != 1 && searchResult .getEntryFirstRep ().getResource () instanceof Bundle )
75
97
throw new IllegalStateException ("Expected a single allow list Bundle" );
76
98
77
- return ( Bundle ) searchResult .getEntryFirstRep ().getResource ();
99
+ return searchResult .getEntryFirstRep ().getResource (). getIdElement ();
78
100
}
79
101
}
0 commit comments