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 DocumentReferenceResourceProvider extends 
021        ca.uhn.fhir.jpa.provider.BaseJpaResourceProvider<DocumentReference>
022        {
023
024        @Override
025        public Class<DocumentReference> getResourceType() {
026                return DocumentReference.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="")
076                        @OptionalParam(name="authenticator", targetTypes={  } )
077                        ReferenceAndListParam theAuthenticator, 
078   
079
080                        @Description(shortDefinition="")
081                        @OptionalParam(name="author", targetTypes={  } )
082                        ReferenceAndListParam theAuthor, 
083   
084
085                        @Description(shortDefinition="")
086                        @OptionalParam(name="class")
087                        TokenAndListParam theClass,
088   
089
090                        @Description(shortDefinition="")
091                        @OptionalParam(name="created")
092                        DateRangeParam theCreated, 
093   
094
095                        @Description(shortDefinition="")
096                        @OptionalParam(name="custodian", targetTypes={  } )
097                        ReferenceAndListParam theCustodian, 
098   
099
100                        @Description(shortDefinition="")
101                        @OptionalParam(name="description")
102                        StringAndListParam theDescription, 
103   
104
105                        @Description(shortDefinition="")
106                        @OptionalParam(name="encounter", targetTypes={  } )
107                        ReferenceAndListParam theEncounter, 
108   
109
110                        @Description(shortDefinition="")
111                        @OptionalParam(name="event")
112                        TokenAndListParam theEvent,
113   
114
115                        @Description(shortDefinition="")
116                        @OptionalParam(name="facility")
117                        TokenAndListParam theFacility,
118   
119
120                        @Description(shortDefinition="")
121                        @OptionalParam(name="format")
122                        TokenAndListParam theFormat,
123   
124
125                        @Description(shortDefinition="")
126                        @OptionalParam(name="identifier")
127                        TokenAndListParam theIdentifier,
128   
129
130                        @Description(shortDefinition="")
131                        @OptionalParam(name="indexed")
132                        DateRangeParam theIndexed, 
133   
134
135                        @Description(shortDefinition="")
136                        @OptionalParam(name="language")
137                        TokenAndListParam theLanguage,
138   
139
140                        @Description(shortDefinition="")
141                        @OptionalParam(name="location")
142                        UriAndListParam theLocation, 
143   
144
145                        @Description(shortDefinition="")
146                        @OptionalParam(name="patient", targetTypes={  } )
147                        ReferenceAndListParam thePatient, 
148   
149
150                        @Description(shortDefinition="")
151                        @OptionalParam(name="period")
152                        DateRangeParam thePeriod, 
153   
154
155                        @Description(shortDefinition="")
156                        @OptionalParam(name="related-id")
157                        TokenAndListParam theRelated_id,
158   
159
160                        @Description(shortDefinition="")
161                        @OptionalParam(name="related-ref", targetTypes={  } )
162                        ReferenceAndListParam theRelated_ref, 
163   
164
165                        @Description(shortDefinition="")
166                        @OptionalParam(name="relatesto", targetTypes={  } )
167                        ReferenceAndListParam theRelatesto, 
168   
169
170                        @Description(shortDefinition="Combination of relation and relatesTo")
171                        @OptionalParam(name="relatesto-relation", compositeTypes= { ReferenceParam.class, TokenParam.class })
172                        CompositeAndListParam<ReferenceParam, TokenParam> theRelatesto_relation,
173   
174
175                        @Description(shortDefinition="")
176                        @OptionalParam(name="relation")
177                        TokenAndListParam theRelation,
178   
179
180                        @Description(shortDefinition="")
181                        @OptionalParam(name="securitylabel")
182                        TokenAndListParam theSecuritylabel,
183   
184
185                        @Description(shortDefinition="")
186                        @OptionalParam(name="setting")
187                        TokenAndListParam theSetting,
188   
189
190                        @Description(shortDefinition="")
191                        @OptionalParam(name="status")
192                        TokenAndListParam theStatus,
193   
194
195                        @Description(shortDefinition="")
196                        @OptionalParam(name="subject", targetTypes={  } )
197                        ReferenceAndListParam theSubject, 
198   
199
200                        @Description(shortDefinition="")
201                        @OptionalParam(name="type")
202                        TokenAndListParam theType,
203
204                        @RawParam
205                        Map<String, List<String>> theAdditionalRawParams,
206
207                        @Description(shortDefinition="Only return resources which were last updated as specified by the given range")
208                        @OptionalParam(name="_lastUpdated")
209                        DateRangeParam theLastUpdated, 
210
211                        @IncludeParam
212                        Set<Include> theIncludes,
213
214                        @IncludeParam(reverse=true)
215                        Set<Include> theRevIncludes,
216
217                        @Sort
218                        SortSpec theSort,
219                        
220                        @ca.uhn.fhir.rest.annotation.Count
221                        Integer theCount,
222
223                        @ca.uhn.fhir.rest.annotation.Offset
224                        Integer theOffset,
225
226                        SummaryEnum theSummaryMode,
227
228                        SearchTotalModeEnum theSearchTotalMode,
229
230                        SearchContainedModeEnum theSearchContainedMode
231
232                        ) {
233                startRequest(theServletRequest);
234                try {
235                        SearchParameterMap paramMap = new SearchParameterMap();
236                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_FILTER, theFtFilter);
237                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_CONTENT, theFtContent);
238                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TEXT, theFtText);
239                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TAG, theSearchForTag);
240                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY, theSearchForSecurity);
241                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE, theSearchForProfile);
242                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SOURCE, theSearchForSource);
243                        paramMap.add("_has", theHas);
244                        paramMap.add("_id", the_id);
245                        paramMap.add("authenticator", theAuthenticator);
246                        paramMap.add("author", theAuthor);
247                        paramMap.add("class", theClass);
248                        paramMap.add("created", theCreated);
249                        paramMap.add("custodian", theCustodian);
250                        paramMap.add("description", theDescription);
251                        paramMap.add("encounter", theEncounter);
252                        paramMap.add("event", theEvent);
253                        paramMap.add("facility", theFacility);
254                        paramMap.add("format", theFormat);
255                        paramMap.add("identifier", theIdentifier);
256                        paramMap.add("indexed", theIndexed);
257                        paramMap.add("language", theLanguage);
258                        paramMap.add("location", theLocation);
259                        paramMap.add("patient", thePatient);
260                        paramMap.add("period", thePeriod);
261                        paramMap.add("related-id", theRelated_id);
262                        paramMap.add("related-ref", theRelated_ref);
263                        paramMap.add("relatesto", theRelatesto);
264                        paramMap.add("relatesto-relation", theRelatesto_relation);
265                        paramMap.add("relation", theRelation);
266                        paramMap.add("securitylabel", theSecuritylabel);
267                        paramMap.add("setting", theSetting);
268                        paramMap.add("status", theStatus);
269                        paramMap.add("subject", theSubject);
270                        paramMap.add("type", theType);
271                        paramMap.setRevIncludes(theRevIncludes);
272                        paramMap.setLastUpdated(theLastUpdated);
273                        paramMap.setIncludes(theIncludes);
274                        paramMap.setSort(theSort);
275                        paramMap.setCount(theCount);
276                        paramMap.setOffset(theOffset);
277                        paramMap.setSummaryMode(theSummaryMode);
278                        paramMap.setSearchTotalMode(theSearchTotalMode);
279                        paramMap.setSearchContainedMode(theSearchContainedMode);
280
281                        getDao().translateRawParameters(theAdditionalRawParams, paramMap);
282
283                        ca.uhn.fhir.rest.api.server.IBundleProvider retVal = getDao().search(paramMap, theRequestDetails, theServletResponse);
284                        return retVal;
285                } finally {
286                        endRequest(theServletRequest);
287                }
288        }
289
290}