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.annotation.IdParam;
20 import ca.uhn.fhir.rest.annotation.Operation;
21 import ca.uhn.fhir.rest.annotation.OperationParam;
22 import ca.uhn.fhir.rest.param.TokenParam;
23 import ca.uhn.fhir.rest.param.UriParam;
24 import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
25 import org.hl7.fhir.dstu3.model.IdType;
26 import org.hl7.fhir.dstu3.model.Identifier;
27 import org.hl7.fhir.dstu3.model.Parameters;
28 import org.hl7.fhir.dstu3.model.Patient;
29 import org.hl7.fhir.dstu3.model.UriType;
30 import org.openehealth.ipf.commons.ihe.fhir.AbstractPlainProvider;
31
32 import javax.servlet.http.HttpServletRequest;
33 import javax.servlet.http.HttpServletResponse;
34
35 import static org.openehealth.ipf.commons.ihe.fhir.Constants.SOURCE_IDENTIFIER_NAME;
36 import static org.openehealth.ipf.commons.ihe.fhir.Constants.TARGET_SYSTEM_NAME;
37
38
39
40
41
42
43
44
45 public class Iti83ResourceProvider extends AbstractPlainProvider {
46
47
48
49
50
51
52
53
54
55 @SuppressWarnings("unused")
56 @Operation(name = Iti83Constants.PIXM_OPERATION_NAME, type = Patient.class, idempotent = true, returnParameters = {@OperationParam(name = "return", type = Identifier.class, max = 100)})
57 public Parameters pixmQuery(
58 @OperationParam(name = SOURCE_IDENTIFIER_NAME) TokenParam sourceIdentifierParam,
59 @OperationParam(name = TARGET_SYSTEM_NAME) UriParam targetSystemParam,
60 HttpServletRequest httpServletRequest,
61 HttpServletResponse httpServletResponse) {
62
63 Identifier sourceIdentifier = new Identifier()
64 .setSystem(sourceIdentifierParam.getSystem())
65 .setValue(sourceIdentifierParam.getValue());
66 UriType targetUri = targetSystemParam == null ? null : new UriType(targetSystemParam.getValue());
67
68 Parameters inParams = new Parameters();
69 inParams.addParameter().setName(SOURCE_IDENTIFIER_NAME).setValue(sourceIdentifier);
70 inParams.addParameter().setName(TARGET_SYSTEM_NAME).setValue(targetUri);
71
72
73 return requestResource(inParams, Parameters.class, httpServletRequest, httpServletResponse);
74 }
75
76
77
78
79
80
81
82
83
84
85
86
87 @Operation(name = Iti83Constants.PIXM_OPERATION_NAME, type = Patient.class, idempotent = true, returnParameters = {@OperationParam(name = "return", type = Identifier.class, max = 100)})
88 public Parameters pixmRetrieve(
89 @IdParam IdType resourceId,
90 @OperationParam(name = TARGET_SYSTEM_NAME) UriParam targetSystemParam,
91 HttpServletRequest httpServletRequest,
92 HttpServletResponse httpServletResponse) {
93 if (resourceId == null) throw new InvalidRequestException("Must provide ID with READ request");
94 UriType targetUri = targetSystemParam == null ? null : new UriType(targetSystemParam.getValue());
95
96 Parameters inParams = new Parameters();
97 inParams.addParameter().setName(SOURCE_IDENTIFIER_NAME).setValue(new Identifier().setValue(resourceId.getIdPart()));
98 inParams.addParameter().setName(TARGET_SYSTEM_NAME).setValue(targetUri);
99
100
101 return requestResource(inParams, Parameters.class, httpServletRequest, httpServletResponse);
102 }
103 }