1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.openehealth.ipf.commons.ihe.fhir.iti78;
18
19 import ca.uhn.fhir.model.api.Include;
20 import ca.uhn.fhir.rest.annotation.*;
21 import ca.uhn.fhir.rest.api.SortSpec;
22 import ca.uhn.fhir.rest.api.server.IBundleProvider;
23 import ca.uhn.fhir.rest.param.*;
24 import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
25 import org.hl7.fhir.dstu3.model.IdType;
26 import org.hl7.fhir.dstu3.model.Patient;
27 import org.hl7.fhir.instance.model.api.IAnyResource;
28 import org.openehealth.ipf.commons.ihe.fhir.AbstractPlainProvider;
29
30 import javax.servlet.http.HttpServletRequest;
31 import javax.servlet.http.HttpServletResponse;
32 import java.util.Set;
33
34
35
36
37
38
39
40 public class Iti78ResourceProvider extends AbstractPlainProvider {
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 @SuppressWarnings("unused")
61 @Search(type = PdqPatient.class)
62 public IBundleProvider pdqmSearch(
63 @OptionalParam(name = Patient.SP_IDENTIFIER) TokenAndListParam identifiers,
64 @OptionalParam(name = Patient.SP_ACTIVE) TokenParam active,
65 @OptionalParam(name = Patient.SP_FAMILY) StringAndListParam family,
66 @OptionalParam(name = Patient.SP_GIVEN) StringAndListParam given,
67 @OptionalParam(name = Patient.SP_BIRTHDATE) DateAndListParam birthDate,
68 @OptionalParam(name = Patient.SP_ADDRESS) StringParam address,
69 @OptionalParam(name = Patient.SP_ADDRESS_CITY) StringParam city,
70 @OptionalParam(name = Patient.SP_ADDRESS_COUNTRY) StringParam country,
71 @OptionalParam(name = Patient.SP_ADDRESS_STATE) StringParam state,
72 @OptionalParam(name = Patient.SP_ADDRESS_POSTALCODE) StringParam postalCode,
73 @OptionalParam(name = Patient.SP_GENDER) TokenParam gender,
74 @OptionalParam(name = IAnyResource.SP_RES_ID) TokenParam resourceId,
75 @OptionalParam(name = Patient.SP_TELECOM) StringParam telecom,
76 @Sort SortSpec sortSpec,
77 @IncludeParam Set<Include> includeSpec,
78
79 HttpServletRequest httpServletRequest,
80 HttpServletResponse httpServletResponse) {
81
82 Iti78SearchParameters searchParameters = Iti78SearchParameters.builder()
83 .identifiers(identifiers)
84 .active(active)
85 .family(family)
86 .given(given)
87 .birthDate(birthDate)
88 .address(address)
89 .city(city)
90 .country(country)
91 .state(state)
92 .postalCode(postalCode)
93 .gender(gender)
94 ._id(resourceId)
95 .telecom(telecom)
96 .sortSpec(sortSpec)
97 .includeSpec(includeSpec)
98 .fhirContext(getFhirContext())
99 .build();
100
101
102 return requestBundleProvider(null, searchParameters, httpServletRequest, httpServletResponse);
103 }
104
105
106
107
108
109
110
111
112
113
114 @SuppressWarnings("unused")
115 @Read(version = true, type = Patient.class)
116 public Patient pdqmRetrieve(
117 @IdParam IdType id,
118 HttpServletRequest httpServletRequest,
119 HttpServletResponse httpServletResponse) {
120
121 if (id == null) throw new InvalidRequestException("Must provide ID with READ request");
122
123 return requestResource(id, Patient.class, httpServletRequest, httpServletResponse);
124 }
125
126 }