001
002package ca.uhn.fhir.jpa.rp.dstu3;
003
004import java.util.*;
005
006import org.apache.commons.lang3.StringUtils;
007
008import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
009import ca.uhn.fhir.model.api.Include;
010import ca.uhn.fhir.model.api.annotation.*;
011import org.hl7.fhir.dstu3.model.*;
012import ca.uhn.fhir.rest.annotation.*;
013import ca.uhn.fhir.rest.param.*;
014import ca.uhn.fhir.rest.api.SortSpec;
015import ca.uhn.fhir.rest.api.SummaryEnum;
016import ca.uhn.fhir.rest.api.SearchTotalModeEnum;
017import ca.uhn.fhir.rest.api.SearchContainedModeEnum;
018
019public class ObservationResourceProvider extends 
020        ca.uhn.fhir.jpa.provider.BaseJpaResourceProviderObservation<Observation>
021        {
022
023        @Override
024        public Class<Observation> getResourceType() {
025                return Observation.class;
026        }
027
028        @Search(allowUnknownParams=true)
029        public ca.uhn.fhir.rest.api.server.IBundleProvider search(
030                        javax.servlet.http.HttpServletRequest theServletRequest,
031                        javax.servlet.http.HttpServletResponse theServletResponse,
032
033                        ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails,
034
035                        @Description(shortDefinition="Search the contents of the resource's data using a filter")
036                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_FILTER)
037                        StringAndListParam theFtFilter,
038
039                        @Description(shortDefinition="Search the contents of the resource's data using a fulltext search")
040                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_CONTENT)
041                        StringAndListParam theFtContent, 
042
043                        @Description(shortDefinition="Search the contents of the resource's narrative using a fulltext search")
044                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_TEXT)
045                        StringAndListParam theFtText, 
046
047                        @Description(shortDefinition="Search for resources which have the given tag")
048                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_TAG)
049                        TokenAndListParam theSearchForTag, 
050
051                        @Description(shortDefinition="Search for resources which have the given security labels")
052                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY)
053                        TokenAndListParam theSearchForSecurity, 
054  
055                        @Description(shortDefinition="Search for resources which have the given profile")
056                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE)
057                        UriAndListParam theSearchForProfile,
058
059                        @Description(shortDefinition="Search for resources which have the given source value (Resource.meta.source)")
060                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_SOURCE)
061                        UriAndListParam theSearchForSource,
062
063                        @Description(shortDefinition="Return resources linked to by the given target")
064                        @OptionalParam(name="_has")
065                        HasAndListParam theHas, 
066
067   
068
069                        @Description(shortDefinition="The ID of the resource")
070                        @OptionalParam(name="_id")
071                        TokenAndListParam the_id,
072   
073
074                        @Description(shortDefinition="Reference to the test or procedure request.")
075                        @OptionalParam(name="based-on", targetTypes={  } )
076                        ReferenceAndListParam theBased_on, 
077   
078
079                        @Description(shortDefinition="The classification of the type of observation")
080                        @OptionalParam(name="category")
081                        TokenAndListParam theCategory,
082   
083
084                        @Description(shortDefinition="The code of the observation type")
085                        @OptionalParam(name="code")
086                        TokenAndListParam theCode,
087   
088
089                        @Description(shortDefinition="Code and coded value parameter pair")
090                        @OptionalParam(name="code-value-concept", compositeTypes= { TokenParam.class, TokenParam.class })
091                        CompositeAndListParam<TokenParam, TokenParam> theCode_value_concept,
092   
093
094                        @Description(shortDefinition="Code and date/time value parameter pair")
095                        @OptionalParam(name="code-value-date", compositeTypes= { TokenParam.class, DateParam.class })
096                        CompositeAndListParam<TokenParam, DateParam> theCode_value_date,
097   
098
099                        @Description(shortDefinition="Code and quantity value parameter pair")
100                        @OptionalParam(name="code-value-quantity", compositeTypes= { TokenParam.class, QuantityParam.class })
101                        CompositeAndListParam<TokenParam, QuantityParam> theCode_value_quantity,
102   
103
104                        @Description(shortDefinition="Code and string value parameter pair")
105                        @OptionalParam(name="code-value-string", compositeTypes= { TokenParam.class, StringParam.class })
106                        CompositeAndListParam<TokenParam, StringParam> theCode_value_string,
107   
108
109                        @Description(shortDefinition="The code of the observation type or component type")
110                        @OptionalParam(name="combo-code")
111                        TokenAndListParam theCombo_code,
112   
113
114                        @Description(shortDefinition="Code and coded value parameter pair, including in components")
115                        @OptionalParam(name="combo-code-value-concept", compositeTypes= { TokenParam.class, TokenParam.class })
116                        CompositeAndListParam<TokenParam, TokenParam> theCombo_code_value_concept,
117   
118
119                        @Description(shortDefinition="Code and quantity value parameter pair, including in components")
120                        @OptionalParam(name="combo-code-value-quantity", compositeTypes= { TokenParam.class, QuantityParam.class })
121                        CompositeAndListParam<TokenParam, QuantityParam> theCombo_code_value_quantity,
122   
123
124                        @Description(shortDefinition="The reason why the expected value in the element Observation.value[x] or Observation.component.value[x] is missing.")
125                        @OptionalParam(name="combo-data-absent-reason")
126                        TokenAndListParam theCombo_data_absent_reason,
127   
128
129                        @Description(shortDefinition="The value or component value of the observation, if the value is a CodeableConcept")
130                        @OptionalParam(name="combo-value-concept")
131                        TokenAndListParam theCombo_value_concept,
132   
133
134                        @Description(shortDefinition="The value or component value of the observation, if the value is a Quantity, or a SampledData (just search on the bounds of the values in sampled data)")
135                        @OptionalParam(name="combo-value-quantity")
136                        QuantityAndListParam theCombo_value_quantity, 
137   
138
139                        @Description(shortDefinition="The component code of the observation type")
140                        @OptionalParam(name="component-code")
141                        TokenAndListParam theComponent_code,
142   
143
144                        @Description(shortDefinition="Component code and component coded value parameter pair")
145                        @OptionalParam(name="component-code-value-concept", compositeTypes= { TokenParam.class, TokenParam.class })
146                        CompositeAndListParam<TokenParam, TokenParam> theComponent_code_value_concept,
147   
148
149                        @Description(shortDefinition="Component code and component quantity value parameter pair")
150                        @OptionalParam(name="component-code-value-quantity", compositeTypes= { TokenParam.class, QuantityParam.class })
151                        CompositeAndListParam<TokenParam, QuantityParam> theComponent_code_value_quantity,
152   
153
154                        @Description(shortDefinition="The reason why the expected value in the element Observation.component.value[x] is missing.")
155                        @OptionalParam(name="component-data-absent-reason")
156                        TokenAndListParam theComponent_data_absent_reason,
157   
158
159                        @Description(shortDefinition="The value of the component observation, if the value is a CodeableConcept")
160                        @OptionalParam(name="component-value-concept")
161                        TokenAndListParam theComponent_value_concept,
162   
163
164                        @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)")
165                        @OptionalParam(name="component-value-quantity")
166                        QuantityAndListParam theComponent_value_quantity, 
167   
168
169                        @Description(shortDefinition="Healthcare event  (Episode-of-care or Encounter) related to the observation")
170                        @OptionalParam(name="context", targetTypes={  } )
171                        ReferenceAndListParam theContext, 
172   
173
174                        @Description(shortDefinition="The reason why the expected value in the element Observation.value[x] is missing.")
175                        @OptionalParam(name="data-absent-reason")
176                        TokenAndListParam theData_absent_reason,
177   
178
179                        @Description(shortDefinition="Obtained date/time. If the obtained element is a period, a date that falls in the period")
180                        @OptionalParam(name="date")
181                        DateRangeParam theDate, 
182   
183
184                        @Description(shortDefinition="The Device that generated the observation data.")
185                        @OptionalParam(name="device", targetTypes={  } )
186                        ReferenceAndListParam theDevice, 
187   
188
189                        @Description(shortDefinition="Encounter related to the observation")
190                        @OptionalParam(name="encounter", targetTypes={  } )
191                        ReferenceAndListParam theEncounter, 
192   
193
194                        @Description(shortDefinition="The unique id for a particular observation")
195                        @OptionalParam(name="identifier")
196                        TokenAndListParam theIdentifier,
197   
198
199                        @Description(shortDefinition="The method used for the observation")
200                        @OptionalParam(name="method")
201                        TokenAndListParam theMethod,
202   
203
204                        @Description(shortDefinition="The subject that the observation is about (if patient)")
205                        @OptionalParam(name="patient", targetTypes={  } )
206                        ReferenceAndListParam thePatient, 
207   
208
209                        @Description(shortDefinition="Who performed the observation")
210                        @OptionalParam(name="performer", targetTypes={  } )
211                        ReferenceAndListParam thePerformer, 
212   
213
214                        @Description(shortDefinition="Related Observations - search on related-type and related-target together")
215                        @OptionalParam(name="related", compositeTypes= { ReferenceParam.class, TokenParam.class })
216                        CompositeAndListParam<ReferenceParam, TokenParam> theRelated,
217   
218
219                        @Description(shortDefinition="Resource that is related to this one")
220                        @OptionalParam(name="related-target", targetTypes={  } )
221                        ReferenceAndListParam theRelated_target, 
222   
223
224                        @Description(shortDefinition="has-member | derived-from | sequel-to | replaces | qualified-by | interfered-by")
225                        @OptionalParam(name="related-type")
226                        TokenAndListParam theRelated_type,
227   
228
229                        @Description(shortDefinition="Specimen used for this observation")
230                        @OptionalParam(name="specimen", targetTypes={  } )
231                        ReferenceAndListParam theSpecimen, 
232   
233
234                        @Description(shortDefinition="The status of the observation")
235                        @OptionalParam(name="status")
236                        TokenAndListParam theStatus,
237   
238
239                        @Description(shortDefinition="The subject that the observation is about")
240                        @OptionalParam(name="subject", targetTypes={  } )
241                        ReferenceAndListParam theSubject, 
242   
243
244                        @Description(shortDefinition="The value of the observation, if the value is a CodeableConcept")
245                        @OptionalParam(name="value-concept")
246                        TokenAndListParam theValue_concept,
247   
248
249                        @Description(shortDefinition="The value of the observation, if the value is a date or period of time")
250                        @OptionalParam(name="value-date")
251                        DateRangeParam theValue_date, 
252   
253
254                        @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)")
255                        @OptionalParam(name="value-quantity")
256                        QuantityAndListParam theValue_quantity, 
257   
258
259                        @Description(shortDefinition="The value of the observation, if the value is a string, and also searches in CodeableConcept.text")
260                        @OptionalParam(name="value-string")
261                        StringAndListParam theValue_string, 
262
263                        @RawParam
264                        Map<String, List<String>> theAdditionalRawParams,
265
266                        @Description(shortDefinition="Only return resources which were last updated as specified by the given range")
267                        @OptionalParam(name="_lastUpdated")
268                        DateRangeParam theLastUpdated, 
269
270                        @IncludeParam
271                        Set<Include> theIncludes,
272
273                        @IncludeParam(reverse=true)
274                        Set<Include> theRevIncludes,
275
276                        @Sort
277                        SortSpec theSort,
278                        
279                        @ca.uhn.fhir.rest.annotation.Count
280                        Integer theCount,
281
282                        @ca.uhn.fhir.rest.annotation.Offset
283                        Integer theOffset,
284
285                        SummaryEnum theSummaryMode,
286
287                        SearchTotalModeEnum theSearchTotalMode,
288
289                        SearchContainedModeEnum theSearchContainedMode
290
291                        ) {
292                startRequest(theServletRequest);
293                try {
294                        SearchParameterMap paramMap = new SearchParameterMap();
295                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_FILTER, theFtFilter);
296                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_CONTENT, theFtContent);
297                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TEXT, theFtText);
298                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TAG, theSearchForTag);
299                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY, theSearchForSecurity);
300                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE, theSearchForProfile);
301                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SOURCE, theSearchForSource);
302                        paramMap.add("_has", theHas);
303                        paramMap.add("_id", the_id);
304                        paramMap.add("based-on", theBased_on);
305                        paramMap.add("category", theCategory);
306                        paramMap.add("code", theCode);
307                        paramMap.add("code-value-concept", theCode_value_concept);
308                        paramMap.add("code-value-date", theCode_value_date);
309                        paramMap.add("code-value-quantity", theCode_value_quantity);
310                        paramMap.add("code-value-string", theCode_value_string);
311                        paramMap.add("combo-code", theCombo_code);
312                        paramMap.add("combo-code-value-concept", theCombo_code_value_concept);
313                        paramMap.add("combo-code-value-quantity", theCombo_code_value_quantity);
314                        paramMap.add("combo-data-absent-reason", theCombo_data_absent_reason);
315                        paramMap.add("combo-value-concept", theCombo_value_concept);
316                        paramMap.add("combo-value-quantity", theCombo_value_quantity);
317                        paramMap.add("component-code", theComponent_code);
318                        paramMap.add("component-code-value-concept", theComponent_code_value_concept);
319                        paramMap.add("component-code-value-quantity", theComponent_code_value_quantity);
320                        paramMap.add("component-data-absent-reason", theComponent_data_absent_reason);
321                        paramMap.add("component-value-concept", theComponent_value_concept);
322                        paramMap.add("component-value-quantity", theComponent_value_quantity);
323                        paramMap.add("context", theContext);
324                        paramMap.add("data-absent-reason", theData_absent_reason);
325                        paramMap.add("date", theDate);
326                        paramMap.add("device", theDevice);
327                        paramMap.add("encounter", theEncounter);
328                        paramMap.add("identifier", theIdentifier);
329                        paramMap.add("method", theMethod);
330                        paramMap.add("patient", thePatient);
331                        paramMap.add("performer", thePerformer);
332                        paramMap.add("related", theRelated);
333                        paramMap.add("related-target", theRelated_target);
334                        paramMap.add("related-type", theRelated_type);
335                        paramMap.add("specimen", theSpecimen);
336                        paramMap.add("status", theStatus);
337                        paramMap.add("subject", theSubject);
338                        paramMap.add("value-concept", theValue_concept);
339                        paramMap.add("value-date", theValue_date);
340                        paramMap.add("value-quantity", theValue_quantity);
341                        paramMap.add("value-string", theValue_string);
342                        paramMap.setRevIncludes(theRevIncludes);
343                        paramMap.setLastUpdated(theLastUpdated);
344                        paramMap.setIncludes(theIncludes);
345                        paramMap.setSort(theSort);
346                        paramMap.setCount(theCount);
347                        paramMap.setOffset(theOffset);
348                        paramMap.setSummaryMode(theSummaryMode);
349                        paramMap.setSearchTotalMode(theSearchTotalMode);
350                        paramMap.setSearchContainedMode(theSearchContainedMode);
351
352                        getDao().translateRawParameters(theAdditionalRawParams, paramMap);
353
354                        ca.uhn.fhir.rest.api.server.IBundleProvider retVal = getDao().search(paramMap, theRequestDetails, theServletResponse);
355                        return retVal;
356                } finally {
357                        endRequest(theServletRequest);
358                }
359        }
360
361}