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