View Javadoc
1   
2   package ca.uhn.fhir.jpa.rp.dstu2;
3   
4   import java.util.*;
5   
6   import org.apache.commons.lang3.StringUtils;
7   
8   import ca.uhn.fhir.jpa.provider.*;
9   import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
10  import ca.uhn.fhir.model.api.Include;
11  import ca.uhn.fhir.model.api.annotation.*;
12  import ca.uhn.fhir.model.dstu2.composite.*;
13  import ca.uhn.fhir.model.dstu2.resource.*; //
14  import ca.uhn.fhir.rest.annotation.*;
15  import ca.uhn.fhir.rest.param.*;
16  import ca.uhn.fhir.rest.api.SortSpec;
17  import ca.uhn.fhir.rest.api.SummaryEnum;
18  import ca.uhn.fhir.rest.api.SearchTotalModeEnum;
19  
20  public class ObservationResourceProvider extends 
21  	JpaResourceProviderDstu2<Observation>
22  	{
23  
24  	@Override
25  	public Class<Observation> getResourceType() {
26  		return Observation.class;
27  	}
28  
29  	@Search(allowUnknownParams=true)
30  	public ca.uhn.fhir.rest.api.server.IBundleProvider search(
31  			javax.servlet.http.HttpServletRequest theServletRequest,
32  			javax.servlet.http.HttpServletResponse theServletResponse,
33  
34  			ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails,
35  			
36  			@Description(shortDefinition="Search the contents of the resource's data using a fulltext search")
37  			@OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_CONTENT)
38  			StringAndListParam theFtContent, 
39  
40  			@Description(shortDefinition="Search the contents of the resource's narrative using a fulltext search")
41  			@OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_TEXT)
42  			StringAndListParam theFtText, 
43  
44  			@Description(shortDefinition="Search for resources which have the given tag")
45  			@OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_TAG)
46  			TokenAndListParam theSearchForTag, 
47  
48  			@Description(shortDefinition="Search for resources which have the given security labels")
49  			@OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY)
50  			TokenAndListParam theSearchForSecurity, 
51    
52  			@Description(shortDefinition="Search for resources which have the given profile")
53  			@OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE)
54  			UriAndListParam theSearchForProfile, 
55  
56  			@Description(shortDefinition="Return resources linked to by the given target")
57  			@OptionalParam(name="_has")
58  			HasAndListParam theHas, 
59  
60    
61  			@Description(shortDefinition="The ID of the resource")
62  			@OptionalParam(name="_id")
63  			StringAndListParam the_id, 
64    
65  			@Description(shortDefinition="The language of the resource")
66  			@OptionalParam(name="_language")
67  			StringAndListParam the_language, 
68    
69  			@Description(shortDefinition="The classification of the type of observation")
70  			@OptionalParam(name="category")
71  			TokenAndListParam theCategory,
72    
73  			@Description(shortDefinition="The code of the observation type")
74  			@OptionalParam(name="code")
75  			TokenAndListParam theCode,
76    
77  			@Description(shortDefinition="Both code and one of the value parameters")
78  			@OptionalParam(name="code-value-concept", compositeTypes= { TokenParam.class, TokenParam.class })
79  			CompositeAndListParam<TokenParam, TokenParam> theCode_value_concept,
80    
81  			@Description(shortDefinition="Both code and one of the value parameters")
82  			@OptionalParam(name="code-value-date", compositeTypes= { TokenParam.class, DateParam.class })
83  			CompositeAndListParam<TokenParam, DateParam> theCode_value_date,
84    
85  			@Description(shortDefinition="Both code and one of the value parameters")
86  			@OptionalParam(name="code-value-quantity", compositeTypes= { TokenParam.class, QuantityParam.class })
87  			CompositeAndListParam<TokenParam, QuantityParam> theCode_value_quantity,
88    
89  			@Description(shortDefinition="Both code and one of the value parameters")
90  			@OptionalParam(name="code-value-string", compositeTypes= { TokenParam.class, StringParam.class })
91  			CompositeAndListParam<TokenParam, StringParam> theCode_value_string,
92    
93  			@Description(shortDefinition="The component code of the observation type")
94  			@OptionalParam(name="component-code")
95  			TokenAndListParam theComponent_code,
96    
97  			@Description(shortDefinition="Both component code and one of the component value parameters")
98  			@OptionalParam(name="component-code-component-value-concept", compositeTypes= { TokenParam.class, TokenParam.class })
99  			CompositeAndListParam<TokenParam, TokenParam> theComponent_code_component_value_concept,
100   
101 			@Description(shortDefinition="Both component code and one of the component value parameters")
102 			@OptionalParam(name="component-code-component-value-quantity", compositeTypes= { TokenParam.class, QuantityParam.class })
103 			CompositeAndListParam<TokenParam, QuantityParam> theComponent_code_component_value_quantity,
104   
105 			@Description(shortDefinition="Both component code and one of the component value parameters")
106 			@OptionalParam(name="component-code-component-value-string", compositeTypes= { TokenParam.class, StringParam.class })
107 			CompositeAndListParam<TokenParam, StringParam> theComponent_code_component_value_string,
108   
109 			@Description(shortDefinition="The reason why the expected value in the element Observation.component.value[x] is missing.")
110 			@OptionalParam(name="component-data-absent-reason")
111 			TokenAndListParam theComponent_data_absent_reason,
112   
113 			@Description(shortDefinition="The value of the component observation, if the value is a CodeableConcept")
114 			@OptionalParam(name="component-value-concept")
115 			TokenAndListParam theComponent_value_concept,
116   
117 			@Description(shortDefinition="The value of the component observation, if the value is a Quantity, or a SampledData (just search on the bounds of the values in sampled data)")
118 			@OptionalParam(name="component-value-quantity")
119 			QuantityAndListParam theComponent_value_quantity, 
120   
121 			@Description(shortDefinition="The value of the component observation, if the value is a string, and also searches in CodeableConcept.text")
122 			@OptionalParam(name="component-value-string")
123 			StringAndListParam theComponent_value_string, 
124   
125 			@Description(shortDefinition="The reason why the expected value in the element Observation.value[x] is missing.")
126 			@OptionalParam(name="data-absent-reason")
127 			TokenAndListParam theData_absent_reason,
128   
129 			@Description(shortDefinition="Obtained date/time. If the obtained element is a period, a date that falls in the period")
130 			@OptionalParam(name="date")
131 			DateRangeParam theDate, 
132   
133 			@Description(shortDefinition="The Device that generated the observation data.")
134 			@OptionalParam(name="device", targetTypes={  } )
135 			ReferenceAndListParam theDevice, 
136   
137 			@Description(shortDefinition="Healthcare event related to the observation")
138 			@OptionalParam(name="encounter", targetTypes={  } )
139 			ReferenceAndListParam theEncounter, 
140   
141 			@Description(shortDefinition="The unique id for a particular observation")
142 			@OptionalParam(name="identifier")
143 			TokenAndListParam theIdentifier,
144   
145 			@Description(shortDefinition="The subject that the observation is about (if patient)")
146 			@OptionalParam(name="patient", targetTypes={  } )
147 			ReferenceAndListParam thePatient, 
148   
149 			@Description(shortDefinition="Who performed the observation")
150 			@OptionalParam(name="performer", targetTypes={  } )
151 			ReferenceAndListParam thePerformer, 
152   
153 			@Description(shortDefinition="")
154 			@OptionalParam(name="related-target", targetTypes={  } )
155 			ReferenceAndListParam theRelated_target, 
156   
157 			@Description(shortDefinition="Related Observations - search on related-type and related-target together")
158 			@OptionalParam(name="related-target-related-type", compositeTypes= { ReferenceParam.class, TokenParam.class })
159 			CompositeAndListParam<ReferenceParam, TokenParam> theRelated_target_related_type,
160   
161 			@Description(shortDefinition="")
162 			@OptionalParam(name="related-type")
163 			TokenAndListParam theRelated_type,
164   
165 			@Description(shortDefinition="")
166 			@OptionalParam(name="specimen", targetTypes={  } )
167 			ReferenceAndListParam theSpecimen, 
168   
169 			@Description(shortDefinition="The status of the observation")
170 			@OptionalParam(name="status")
171 			TokenAndListParam theStatus,
172   
173 			@Description(shortDefinition="The subject that the observation is about")
174 			@OptionalParam(name="subject", targetTypes={  } )
175 			ReferenceAndListParam theSubject, 
176   
177 			@Description(shortDefinition="The value of the observation, if the value is a CodeableConcept")
178 			@OptionalParam(name="value-concept")
179 			TokenAndListParam theValue_concept,
180   
181 			@Description(shortDefinition="The value of the observation, if the value is a date or period of time")
182 			@OptionalParam(name="value-date")
183 			DateRangeParam theValue_date, 
184   
185 			@Description(shortDefinition="The value of the observation, if the value is a Quantity, or a SampledData (just search on the bounds of the values in sampled data)")
186 			@OptionalParam(name="value-quantity")
187 			QuantityAndListParam theValue_quantity, 
188   
189 			@Description(shortDefinition="The value of the observation, if the value is a string, and also searches in CodeableConcept.text")
190 			@OptionalParam(name="value-string")
191 			StringAndListParam theValue_string, 
192 
193 			@RawParam
194 			Map<String, List<String>> theAdditionalRawParams,
195 
196 			@IncludeParam(reverse=true)
197 			Set<Include> theRevIncludes,
198 			@Description(shortDefinition="Only return resources which were last updated as specified by the given range")
199 			@OptionalParam(name="_lastUpdated")
200 			DateRangeParam theLastUpdated, 
201 
202 			@IncludeParam(allow= {
203 					"Observation:device" , 					"Observation:encounter" , 					"Observation:patient" , 					"Observation:performer" , 					"Observation:related-target" , 					"Observation:specimen" , 					"Observation:subject" , 						"Observation:device" , 					"Observation:encounter" , 					"Observation:patient" , 					"Observation:performer" , 					"Observation:related-target" , 					"Observation:specimen" , 					"Observation:subject" , 						"Observation:device" , 					"Observation:encounter" , 					"Observation:patient" , 					"Observation:performer" , 					"Observation:related-target" , 					"Observation:specimen" , 					"Observation:subject" , 						"Observation:device" , 					"Observation:encounter" , 					"Observation:patient" , 					"Observation:performer" , 					"Observation:related-target" , 					"Observation:specimen" , 					"Observation:subject" , 						"Observation:device" , 					"Observation:encounter" , 					"Observation:patient" , 					"Observation:performer" , 					"Observation:related-target" , 					"Observation:specimen" , 					"Observation:subject" , 						"Observation:device" , 					"Observation:encounter" , 					"Observation:patient" , 					"Observation:performer" , 					"Observation:related-target" , 					"Observation:specimen" , 					"Observation:subject" , 						"Observation:device" , 					"Observation:encounter" , 					"Observation:patient" , 					"Observation:performer" , 					"Observation:related-target" , 					"Observation:specimen" , 					"Observation:subject" 					, "*"
204 			}) 
205 			Set<Include> theIncludes,
206 			
207 			@Sort 
208 			SortSpec theSort,
209 			
210 			@ca.uhn.fhir.rest.annotation.Count
211 			Integer theCount,
212 
213 			SummaryEnum theSummaryMode,
214 
215 			SearchTotalModeEnum theSearchTotalMode
216 
217 			) {
218 		startRequest(theServletRequest);
219 		try {
220 			SearchParameterMap paramMap = new SearchParameterMap();
221 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_CONTENT, theFtContent);
222 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TEXT, theFtText);
223 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TAG, theSearchForTag);
224 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY, theSearchForSecurity);
225 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE, theSearchForProfile);
226 			paramMap.add("_has", theHas);
227 			paramMap.add("_id", the_id);
228 			paramMap.add("_language", the_language);
229 			paramMap.add("category", theCategory);
230 			paramMap.add("code", theCode);
231 			paramMap.add("code-value-concept", theCode_value_concept);
232 			paramMap.add("code-value-date", theCode_value_date);
233 			paramMap.add("code-value-quantity", theCode_value_quantity);
234 			paramMap.add("code-value-string", theCode_value_string);
235 			paramMap.add("component-code", theComponent_code);
236 			paramMap.add("component-code-component-value-concept", theComponent_code_component_value_concept);
237 			paramMap.add("component-code-component-value-quantity", theComponent_code_component_value_quantity);
238 			paramMap.add("component-code-component-value-string", theComponent_code_component_value_string);
239 			paramMap.add("component-data-absent-reason", theComponent_data_absent_reason);
240 			paramMap.add("component-value-concept", theComponent_value_concept);
241 			paramMap.add("component-value-quantity", theComponent_value_quantity);
242 			paramMap.add("component-value-string", theComponent_value_string);
243 			paramMap.add("data-absent-reason", theData_absent_reason);
244 			paramMap.add("date", theDate);
245 			paramMap.add("device", theDevice);
246 			paramMap.add("encounter", theEncounter);
247 			paramMap.add("identifier", theIdentifier);
248 			paramMap.add("patient", thePatient);
249 			paramMap.add("performer", thePerformer);
250 			paramMap.add("related-target", theRelated_target);
251 			paramMap.add("related-target-related-type", theRelated_target_related_type);
252 			paramMap.add("related-type", theRelated_type);
253 			paramMap.add("specimen", theSpecimen);
254 			paramMap.add("status", theStatus);
255 			paramMap.add("subject", theSubject);
256 			paramMap.add("value-concept", theValue_concept);
257 			paramMap.add("value-date", theValue_date);
258 			paramMap.add("value-quantity", theValue_quantity);
259 			paramMap.add("value-string", theValue_string);
260 			paramMap.setRevIncludes(theRevIncludes);
261 			paramMap.setLastUpdated(theLastUpdated);
262 			paramMap.setIncludes(theIncludes);
263 			paramMap.setSort(theSort);
264 			paramMap.setCount(theCount);
265 			paramMap.setSummaryMode(theSummaryMode);
266 			paramMap.setSearchTotalMode(theSearchTotalMode);
267 
268 			getDao().translateRawParameters(theAdditionalRawParams, paramMap);
269 
270 			ca.uhn.fhir.rest.api.server.IBundleProvider retVal = getDao().search(paramMap, theRequestDetails, theServletResponse);
271 			return retVal;
272 		} finally {
273 			endRequest(theServletRequest);
274 		}
275 	}
276 
277 }