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