1
1
package org .highmed .dsf .bpe .start ;
2
2
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 .EXTENSION_QUERY_URI ;
6
+ import static org .highmed .dsf .bpe .ConstantsBase .ORGANIZATION_IDENTIFIER_SYSTEM ;
7
+ import static org .highmed .dsf .bpe .start .ConstantsExampleStarters .CERTIFICATE_PASSWORD ;
8
+ import static org .highmed .dsf .bpe .start .ConstantsExampleStarters .CERTIFICATE_PATH ;
9
+ import static org .highmed .dsf .bpe .start .ConstantsExampleStarters .MEDIC_1_FHIR_BASE_URL ;
10
+ import static org .highmed .dsf .bpe .start .ConstantsExampleStarters .ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1 ;
11
+ import static org .highmed .dsf .bpe .start .ConstantsExampleStarters .ORGANIZATION_IDENTIFIER_VALUE_MEDIC_2 ;
12
+ import static org .highmed .dsf .bpe .start .ConstantsExampleStarters .ORGANIZATION_IDENTIFIER_VALUE_MEDIC_3 ;
13
+ import static org .highmed .dsf .bpe .start .ConstantsExampleStarters .ORGANIZATION_IDENTIFIER_VALUE_TTP ;
14
+ import static org .highmed .dsf .bpe .variables .ConstantsFeasibility .CODESYSTEM_HIGHMED_FEASIBILITY ;
15
+ import static org .highmed .dsf .bpe .variables .ConstantsFeasibility .CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_NEEDS_CONSENT_CHECK ;
16
+ import static org .highmed .dsf .bpe .variables .ConstantsFeasibility .CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_NEEDS_RECORD_LINKAGE ;
17
+ import static org .highmed .dsf .bpe .variables .ConstantsFeasibility .CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_RESEARCH_STUDY_REFERENCE ;
18
+ import static org .highmed .dsf .bpe .variables .ConstantsFeasibility .EXTENSION_PARTICIPATING_MEDIC_URI ;
19
+ import static org .highmed .dsf .bpe .variables .ConstantsFeasibility .EXTENSION_PARTICIPATING_TTP_URI ;
20
+ import static org .highmed .dsf .bpe .variables .ConstantsFeasibility .FEASIBILITY_RESEARCH_STUDY_PROFILE ;
21
+ import static org .highmed .dsf .bpe .variables .ConstantsFeasibility .GROUP_PROFILE ;
22
+ import static org .highmed .dsf .bpe .variables .ConstantsFeasibility .REQUEST_FEASIBILITY_MESSAGE_NAME ;
23
+ import static org .highmed .dsf .bpe .variables .ConstantsFeasibility .REQUEST_FEASIBILITY_PROCESS_URI_AND_LATEST_VERSION ;
24
+ import static org .highmed .dsf .bpe .variables .ConstantsFeasibility .REQUEST_FEASIBILITY_TASK_PROFILE ;
25
+ import static org .highmed .dsf .bpe .variables .ConstantsFeasibility .RESEARCH_STUDY_IDENTIFIER_SYSTEM ;
26
+
3
27
import java .io .IOException ;
4
28
import java .nio .file .Paths ;
5
29
import java .security .KeyStore ;
31
55
import org .hl7 .fhir .r4 .model .Reference ;
32
56
import org .hl7 .fhir .r4 .model .ResearchStudy ;
33
57
import org .hl7 .fhir .r4 .model .ResearchStudy .ResearchStudyStatus ;
58
+ import org .hl7 .fhir .r4 .model .ResourceType ;
34
59
import org .hl7 .fhir .r4 .model .StringType ;
35
60
import org .hl7 .fhir .r4 .model .Task ;
36
61
import org .hl7 .fhir .r4 .model .Task .TaskIntent ;
@@ -46,16 +71,13 @@ public class RequestSimpleFeasibilityFromMedicsViaMedic1ExampleStarter
46
71
public static void main (String [] args )
47
72
throws KeyStoreException , CertificateException , NoSuchAlgorithmException , IOException
48
73
{
49
- char [] keyStorePassword = "password" .toCharArray ();
50
- KeyStore keyStore = CertificateReader .fromPkcs12 (Paths .get (
51
- "../../dsf-tools/dsf-tools-test-data-generator/cert/Webbrowser_Test_User/Webbrowser_Test_User_certificate.p12" ),
52
- keyStorePassword );
74
+ KeyStore keyStore = CertificateReader .fromPkcs12 (Paths .get (CERTIFICATE_PATH ), CERTIFICATE_PASSWORD );
53
75
KeyStore trustStore = CertificateHelper .extractTrust (keyStore );
54
76
55
77
FhirContext context = FhirContext .forR4 ();
56
78
ReferenceCleaner referenceCleaner = new ReferenceCleanerImpl (new ReferenceExtractorImpl ());
57
- FhirWebserviceClient client = new FhirWebserviceClientJersey ("https://medic1/fhir/" , trustStore , keyStore ,
58
- keyStorePassword , null , null , null , 0 , 0 , null , context , referenceCleaner );
79
+ FhirWebserviceClient client = new FhirWebserviceClientJersey (MEDIC_1_FHIR_BASE_URL , trustStore , keyStore ,
80
+ CERTIFICATE_PASSWORD , null , null , null , 0 , 0 , null , context , referenceCleaner );
59
81
60
82
try
61
83
{
@@ -67,13 +89,13 @@ public static void main(String[] args)
67
89
Bundle bundle = new Bundle ();
68
90
bundle .setType (BundleType .TRANSACTION );
69
91
bundle .addEntry ().setResource (group1 ).setFullUrl (group1 .getIdElement ().getIdPart ()).getRequest ()
70
- .setMethod (HTTPVerb .POST ).setUrl (" Group" );
92
+ .setMethod (HTTPVerb .POST ).setUrl (ResourceType . Group . name () );
71
93
bundle .addEntry ().setResource (group2 ).setFullUrl (group2 .getIdElement ().getIdPart ()).getRequest ()
72
- .setMethod (HTTPVerb .POST ).setUrl (" Group" );
94
+ .setMethod (HTTPVerb .POST ).setUrl (ResourceType . Group . name () );
73
95
bundle .addEntry ().setResource (researchStudy ).setFullUrl (researchStudy .getIdElement ().getIdPart ())
74
- .getRequest ().setMethod (HTTPVerb .POST ).setUrl (" ResearchStudy" );
96
+ .getRequest ().setMethod (HTTPVerb .POST ).setUrl (ResourceType . ResearchStudy . name () );
75
97
bundle .addEntry ().setResource (task ).setFullUrl (task .getIdElement ().getIdPart ()).getRequest ()
76
- .setMethod (HTTPVerb .POST ).setUrl (" Task" );
98
+ .setMethod (HTTPVerb .POST ).setUrl (ResourceType . Task . name () );
77
99
78
100
client .withMinimalReturn ().postBundle (bundle );
79
101
}
@@ -95,13 +117,13 @@ private static Group createGroup(String name)
95
117
Group group = new Group ();
96
118
group .setIdElement (new IdType ("urn:uuid:" + UUID .randomUUID ().toString ()));
97
119
98
- group .getMeta ().addProfile ("http://highmed.org/fhir/StructureDefinition/highmed-group" );
120
+ group .getMeta ().addProfile (GROUP_PROFILE );
99
121
group .getText ().getDiv ().addText ("This is the description" );
100
122
group .getText ().setStatus (Narrative .NarrativeStatus .ADDITIONAL );
101
123
group .setType (GroupType .PERSON );
102
124
group .setActual (false );
103
125
group .setActive (true );
104
- group .addExtension ().setUrl ("http://highmed.org/fhir/StructureDefinition/query" ).setValue (
126
+ group .addExtension ().setUrl (EXTENSION_QUERY_URI ).setValue (
105
127
new Expression ().setLanguageElement (ConstantsBase .AQL_QUERY_TYPE )
106
128
.setExpression ("SELECT COUNT(e) FROM EHR e" ));
107
129
group .setName (name );
@@ -114,30 +136,29 @@ private static ResearchStudy createResearchStudy(Group group1, Group group2)
114
136
ResearchStudy researchStudy = new ResearchStudy ();
115
137
researchStudy .setIdElement (new IdType ("urn:uuid:" + UUID .randomUUID ().toString ()));
116
138
117
- researchStudy .getMeta ()
118
- .addProfile ("http://highmed.org/fhir/StructureDefinition/highmed-research-study-feasibility" );
119
- researchStudy .addIdentifier ().setSystem ("http://highmed.org/fhir/NamingSystem/research-study-identifier" )
139
+ researchStudy .getMeta ().addProfile (FEASIBILITY_RESEARCH_STUDY_PROFILE );
140
+ researchStudy .addIdentifier ().setSystem (RESEARCH_STUDY_IDENTIFIER_SYSTEM )
120
141
.setValue (UUID .randomUUID ().toString ());
121
142
researchStudy .setStatus (ResearchStudyStatus .ACTIVE );
122
143
researchStudy .addEnrollment ().setReference (group1 .getIdElement ().getIdPart ());
123
144
researchStudy .addEnrollment ().setReference (group2 .getIdElement ().getIdPart ());
124
145
125
- researchStudy .addExtension ().setUrl ("http://highmed.org/fhir/StructureDefinition/participating-medic" ).setValue (
126
- new Reference ().setType (" Organization" ).setIdentifier (
127
- new Identifier ().setSystem ("http://highmed.org/fhir/NamingSystem/organization-identifier" )
128
- .setValue ("Test_MeDIC_1" )));
129
- researchStudy .addExtension ().setUrl ("http://highmed.org/fhir/StructureDefinition/participating-medic" ).setValue (
130
- new Reference ().setType (" Organization" ).setIdentifier (
131
- new Identifier ().setSystem ("http://highmed.org/fhir/NamingSystem/organization-identifier" )
132
- .setValue ("Test_MeDIC_2" )));
133
- researchStudy .addExtension ().setUrl ("http://highmed.org/fhir/StructureDefinition/participating-medic" ).setValue (
134
- new Reference ().setType (" Organization" ).setIdentifier (
135
- new Identifier ().setSystem ("http://highmed.org/fhir/NamingSystem/organization-identifier" )
136
- .setValue ("Test_MeDIC_3" )));
137
- researchStudy .addExtension ().setUrl ("http://highmed.org/fhir/StructureDefinition/participating-ttp" ).setValue (
138
- new Reference ().setType (" Organization" ).setIdentifier (
139
- new Identifier ().setSystem ("http://highmed.org/fhir/NamingSystem/organization-identifier" )
140
- .setValue ("Test_TTP" )));
146
+ researchStudy .addExtension ().setUrl (EXTENSION_PARTICIPATING_MEDIC_URI ).setValue (
147
+ new Reference ().setType (ResourceType . Organization . name () ).setIdentifier (
148
+ new Identifier ().setSystem (ORGANIZATION_IDENTIFIER_SYSTEM )
149
+ .setValue (ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1 )));
150
+ researchStudy .addExtension ().setUrl (EXTENSION_PARTICIPATING_MEDIC_URI ).setValue (
151
+ new Reference ().setType (ResourceType . Organization . name () ).setIdentifier (
152
+ new Identifier ().setSystem (ORGANIZATION_IDENTIFIER_SYSTEM )
153
+ .setValue (ORGANIZATION_IDENTIFIER_VALUE_MEDIC_2 )));
154
+ researchStudy .addExtension ().setUrl (EXTENSION_PARTICIPATING_MEDIC_URI ).setValue (
155
+ new Reference ().setType (ResourceType . Organization . name () ).setIdentifier (
156
+ new Identifier ().setSystem (ORGANIZATION_IDENTIFIER_SYSTEM )
157
+ .setValue (ORGANIZATION_IDENTIFIER_VALUE_MEDIC_3 )));
158
+ researchStudy .addExtension ().setUrl (EXTENSION_PARTICIPATING_TTP_URI ).setValue (
159
+ new Reference ().setType (ResourceType . Organization . name () ).setIdentifier (
160
+ new Identifier ().setSystem (ORGANIZATION_IDENTIFIER_SYSTEM )
161
+ .setValue (ORGANIZATION_IDENTIFIER_VALUE_TTP )));
141
162
142
163
return researchStudy ;
143
164
}
@@ -147,27 +168,26 @@ private static Task createTask(ResearchStudy researchStudy)
147
168
Task task = new Task ();
148
169
task .setIdElement (new IdType ("urn:uuid:" + UUID .randomUUID ().toString ()));
149
170
150
- task .getMeta ()
151
- .addProfile ("http://highmed.org/fhir/StructureDefinition/highmed-task-request-simple-feasibility" );
152
- task .setInstantiatesUri ("http://highmed.org/bpe/Process/requestSimpleFeasibility/0.4.0" );
171
+ task .getMeta ().addProfile (REQUEST_FEASIBILITY_TASK_PROFILE );
172
+ task .setInstantiatesUri (REQUEST_FEASIBILITY_PROCESS_URI_AND_LATEST_VERSION );
153
173
task .setStatus (TaskStatus .REQUESTED );
154
174
task .setIntent (TaskIntent .ORDER );
155
175
task .setAuthoredOn (new Date ());
156
- task .getRequester ().setType (" Organization" ).getIdentifier ()
157
- .setSystem ("http://highmed.org/fhir/NamingSystem/organization-identifier" ).setValue ("Test_MeDIC_1" );
158
- task .getRestriction ().addRecipient ().setType (" Organization" ).getIdentifier ()
159
- .setSystem ("http://highmed.org/fhir/NamingSystem/organization-identifier" ).setValue ("Test_MeDIC_1" );
160
-
161
- task .addInput ().setValue (new StringType ("requestSimpleFeasibilityMessage" )).getType ().addCoding ()
162
- .setSystem ("http://highmed.org/fhir/CodeSystem/bpmn-message" ).setCode ("message-name" );
163
- task .addInput ().setValue (
164
- new Reference (). setReference ( researchStudy . getIdElement (). getIdPart ()). setType ( "ResearchStudy" ) )
165
- .getType (). addCoding (). setSystem ("http://highmed.org/fhir/CodeSystem/feasibility" )
166
- .setCode ("research-study-reference" );
167
- task .addInput ().setValue (new BooleanType (true )).getType ().addCoding ()
168
- .setSystem ( "http://highmed.org/fhir/CodeSystem/feasibility" ). setCode ("needs-record-linkage" );
169
- task .addInput ().setValue (new BooleanType (true )).getType ().addCoding ()
170
- .setSystem ( "http://highmed.org/fhir/CodeSystem/feasibility" ). setCode ("needs-consent-check" );
176
+ task .getRequester ().setType (ResourceType . Organization . name () ).getIdentifier ()
177
+ .setSystem (ORGANIZATION_IDENTIFIER_SYSTEM ).setValue (ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1 );
178
+ task .getRestriction ().addRecipient ().setType (ResourceType . Organization . name () ).getIdentifier ()
179
+ .setSystem (ORGANIZATION_IDENTIFIER_SYSTEM ).setValue (ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1 );
180
+
181
+ task .addInput ().setValue (new StringType (REQUEST_FEASIBILITY_MESSAGE_NAME )).getType ().addCoding ()
182
+ .setSystem (CODESYSTEM_HIGHMED_BPMN ).setCode (CODESYSTEM_HIGHMED_BPMN_VALUE_MESSAGE_NAME );
183
+ task .addInput ().setValue (new Reference (). setReference ( researchStudy . getIdElement (). getIdPart ())
184
+ . setType ( ResourceType . ResearchStudy . name ())). getType (). addCoding ( )
185
+ .setSystem (CODESYSTEM_HIGHMED_FEASIBILITY )
186
+ .setCode (CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_RESEARCH_STUDY_REFERENCE );
187
+ task .addInput ().setValue (new BooleanType (true )).getType ().addCoding (). setSystem ( CODESYSTEM_HIGHMED_FEASIBILITY )
188
+ .setCode (CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_NEEDS_RECORD_LINKAGE );
189
+ task .addInput ().setValue (new BooleanType (true )).getType ().addCoding (). setSystem ( CODESYSTEM_HIGHMED_FEASIBILITY )
190
+ .setCode (CODESYSTEM_HIGHMED_FEASIBILITY_VALUE_NEEDS_CONSENT_CHECK );
171
191
172
192
return task ;
173
193
}
0 commit comments