1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.openehealth.ipf.commons.ihe.fhir.iti83;
18
19 import ca.uhn.fhir.rest.client.api.IGenericClient;
20 import ca.uhn.fhir.rest.gclient.IClientExecutable;
21 import ca.uhn.fhir.rest.gclient.IOperationUntypedWithInput;
22 import org.hl7.fhir.dstu3.model.Parameters;
23 import org.hl7.fhir.dstu3.model.Patient;
24 import org.hl7.fhir.dstu3.model.StringType;
25 import org.openehealth.ipf.commons.ihe.fhir.ClientRequestFactory;
26
27 import java.util.Map;
28
29
30
31
32
33
34
35 public class Iti83ClientRequestFactory implements ClientRequestFactory<IOperationUntypedWithInput<Parameters>> {
36
37 @Override
38 public IClientExecutable<IOperationUntypedWithInput<Parameters>, ?> getClientExecutable(IGenericClient client, Object requestData, Map<String, Object> parameters) {
39
40 if (requestData instanceof Parameters) {
41 return getClientExecutable(client, (Parameters) requestData);
42 } else {
43 Parameters p = new Parameters();
44 parameters.entrySet().stream()
45 .filter(entry -> Iti83Constants.ITI83_PARAMETERS.contains(entry.getKey()))
46 .forEach(entry -> p.addParameter()
47 .setName(entry.getKey())
48 .setValue(new StringType(entry.getValue().toString())));
49 return getClientExecutable(client, p);
50 }
51
52 }
53
54 private IClientExecutable<IOperationUntypedWithInput<Parameters>, ?> getClientExecutable(IGenericClient client, Parameters requestData) {
55 return client.operation()
56 .onType(Patient.class)
57 .named(Iti83Constants.PIXM_OPERATION_NAME)
58 .withParameters(requestData)
59 .useHttpGet();
60 }
61 }