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