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