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.provider.*;
009import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
010import ca.uhn.fhir.model.api.Include;
011import ca.uhn.fhir.model.api.annotation.*;
012import ca.uhn.fhir.model.dstu2.composite.*;
013import ca.uhn.fhir.model.dstu2.resource.*; //
014import ca.uhn.fhir.rest.annotation.*;
015import ca.uhn.fhir.rest.param.*;
016import ca.uhn.fhir.rest.api.SortSpec;
017import ca.uhn.fhir.rest.api.SummaryEnum;
018import ca.uhn.fhir.rest.api.SearchTotalModeEnum;
019import ca.uhn.fhir.rest.api.SearchContainedModeEnum;
020
021public class DocumentReferenceResourceProvider extends 
022        JpaResourceProviderDstu2<DocumentReference>
023        {
024
025        @Override
026        public Class<DocumentReference> getResourceType() {
027                return DocumentReference.class;
028        }
029
030        @Search(allowUnknownParams=true)
031        public ca.uhn.fhir.rest.api.server.IBundleProvider search(
032                        javax.servlet.http.HttpServletRequest theServletRequest,
033                        javax.servlet.http.HttpServletResponse theServletResponse,
034
035                        ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails,
036
037                        @Description(shortDefinition="Search the contents of the resource's data using a filter")
038                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_FILTER)
039                        StringAndListParam theFtFilter,
040
041                        @Description(shortDefinition="Search the contents of the resource's data using a fulltext search")
042                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_CONTENT)
043                        StringAndListParam theFtContent, 
044
045                        @Description(shortDefinition="Search the contents of the resource's narrative using a fulltext search")
046                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_TEXT)
047                        StringAndListParam theFtText, 
048
049                        @Description(shortDefinition="Search for resources which have the given tag")
050                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_TAG)
051                        TokenAndListParam theSearchForTag, 
052
053                        @Description(shortDefinition="Search for resources which have the given security labels")
054                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY)
055                        TokenAndListParam theSearchForSecurity, 
056  
057                        @Description(shortDefinition="Search for resources which have the given profile")
058                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE)
059                        UriAndListParam theSearchForProfile,
060
061                        @Description(shortDefinition="Search for resources which have the given source value (Resource.meta.source)")
062                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_SOURCE)
063                        UriAndListParam theSearchForSource,
064
065                        @Description(shortDefinition="Return resources linked to by the given target")
066                        @OptionalParam(name="_has")
067                        HasAndListParam theHas, 
068
069   
070
071                        @Description(shortDefinition="The ID of the resource")
072                        @OptionalParam(name="_id")
073                        StringAndListParam the_id, 
074   
075
076                        @Description(shortDefinition="")
077                        @OptionalParam(name="authenticator", targetTypes={  } )
078                        ReferenceAndListParam theAuthenticator, 
079   
080
081                        @Description(shortDefinition="")
082                        @OptionalParam(name="author", targetTypes={  } )
083                        ReferenceAndListParam theAuthor, 
084   
085
086                        @Description(shortDefinition="")
087                        @OptionalParam(name="class")
088                        TokenAndListParam theClass,
089   
090
091                        @Description(shortDefinition="")
092                        @OptionalParam(name="created")
093                        DateRangeParam theCreated, 
094   
095
096                        @Description(shortDefinition="")
097                        @OptionalParam(name="custodian", targetTypes={  } )
098                        ReferenceAndListParam theCustodian, 
099   
100
101                        @Description(shortDefinition="")
102                        @OptionalParam(name="description")
103                        StringAndListParam theDescription, 
104   
105
106                        @Description(shortDefinition="")
107                        @OptionalParam(name="encounter", targetTypes={  } )
108                        ReferenceAndListParam theEncounter, 
109   
110
111                        @Description(shortDefinition="")
112                        @OptionalParam(name="event")
113                        TokenAndListParam theEvent,
114   
115
116                        @Description(shortDefinition="")
117                        @OptionalParam(name="facility")
118                        TokenAndListParam theFacility,
119   
120
121                        @Description(shortDefinition="")
122                        @OptionalParam(name="format")
123                        TokenAndListParam theFormat,
124   
125
126                        @Description(shortDefinition="")
127                        @OptionalParam(name="identifier")
128                        TokenAndListParam theIdentifier,
129   
130
131                        @Description(shortDefinition="")
132                        @OptionalParam(name="indexed")
133                        DateRangeParam theIndexed, 
134   
135
136                        @Description(shortDefinition="")
137                        @OptionalParam(name="language")
138                        TokenAndListParam theLanguage,
139   
140
141                        @Description(shortDefinition="")
142                        @OptionalParam(name="location")
143                        UriAndListParam theLocation, 
144   
145
146                        @Description(shortDefinition="")
147                        @OptionalParam(name="patient", targetTypes={  } )
148                        ReferenceAndListParam thePatient, 
149   
150
151                        @Description(shortDefinition="")
152                        @OptionalParam(name="period")
153                        DateRangeParam thePeriod, 
154   
155
156                        @Description(shortDefinition="")
157                        @OptionalParam(name="related-id")
158                        TokenAndListParam theRelated_id,
159   
160
161                        @Description(shortDefinition="")
162                        @OptionalParam(name="related-ref", targetTypes={  } )
163                        ReferenceAndListParam theRelated_ref, 
164   
165
166                        @Description(shortDefinition="")
167                        @OptionalParam(name="relatesto", targetTypes={  } )
168                        ReferenceAndListParam theRelatesto, 
169   
170
171                        @Description(shortDefinition="Combination of relation and relatesTo")
172                        @OptionalParam(name="relatesto-relation", compositeTypes= { ReferenceParam.class, TokenParam.class })
173                        CompositeAndListParam<ReferenceParam, TokenParam> theRelatesto_relation,
174   
175
176                        @Description(shortDefinition="")
177                        @OptionalParam(name="relation")
178                        TokenAndListParam theRelation,
179   
180
181                        @Description(shortDefinition="")
182                        @OptionalParam(name="securitylabel")
183                        TokenAndListParam theSecuritylabel,
184   
185
186                        @Description(shortDefinition="")
187                        @OptionalParam(name="setting")
188                        TokenAndListParam theSetting,
189   
190
191                        @Description(shortDefinition="")
192                        @OptionalParam(name="status")
193                        TokenAndListParam theStatus,
194   
195
196                        @Description(shortDefinition="")
197                        @OptionalParam(name="subject", targetTypes={  } )
198                        ReferenceAndListParam theSubject, 
199   
200
201                        @Description(shortDefinition="")
202                        @OptionalParam(name="type")
203                        TokenAndListParam theType,
204
205                        @RawParam
206                        Map<String, List<String>> theAdditionalRawParams,
207
208                        @Description(shortDefinition="Only return resources which were last updated as specified by the given range")
209                        @OptionalParam(name="_lastUpdated")
210                        DateRangeParam theLastUpdated, 
211
212                        @IncludeParam
213                        Set<Include> theIncludes,
214
215                        @IncludeParam(reverse=true)
216                        Set<Include> theRevIncludes,
217
218                        @Sort
219                        SortSpec theSort,
220                        
221                        @ca.uhn.fhir.rest.annotation.Count
222                        Integer theCount,
223
224                        @ca.uhn.fhir.rest.annotation.Offset
225                        Integer theOffset,
226
227                        SummaryEnum theSummaryMode,
228
229                        SearchTotalModeEnum theSearchTotalMode,
230
231                        SearchContainedModeEnum theSearchContainedMode
232
233                        ) {
234                startRequest(theServletRequest);
235                try {
236                        SearchParameterMap paramMap = new SearchParameterMap();
237                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_FILTER, theFtFilter);
238                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_CONTENT, theFtContent);
239                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TEXT, theFtText);
240                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TAG, theSearchForTag);
241                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY, theSearchForSecurity);
242                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE, theSearchForProfile);
243                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SOURCE, theSearchForSource);
244                        paramMap.add("_has", theHas);
245                        paramMap.add("_id", the_id);
246                        paramMap.add("authenticator", theAuthenticator);
247                        paramMap.add("author", theAuthor);
248                        paramMap.add("class", theClass);
249                        paramMap.add("created", theCreated);
250                        paramMap.add("custodian", theCustodian);
251                        paramMap.add("description", theDescription);
252                        paramMap.add("encounter", theEncounter);
253                        paramMap.add("event", theEvent);
254                        paramMap.add("facility", theFacility);
255                        paramMap.add("format", theFormat);
256                        paramMap.add("identifier", theIdentifier);
257                        paramMap.add("indexed", theIndexed);
258                        paramMap.add("language", theLanguage);
259                        paramMap.add("location", theLocation);
260                        paramMap.add("patient", thePatient);
261                        paramMap.add("period", thePeriod);
262                        paramMap.add("related-id", theRelated_id);
263                        paramMap.add("related-ref", theRelated_ref);
264                        paramMap.add("relatesto", theRelatesto);
265                        paramMap.add("relatesto-relation", theRelatesto_relation);
266                        paramMap.add("relation", theRelation);
267                        paramMap.add("securitylabel", theSecuritylabel);
268                        paramMap.add("setting", theSetting);
269                        paramMap.add("status", theStatus);
270                        paramMap.add("subject", theSubject);
271                        paramMap.add("type", theType);
272                        paramMap.setRevIncludes(theRevIncludes);
273                        paramMap.setLastUpdated(theLastUpdated);
274                        paramMap.setIncludes(theIncludes);
275                        paramMap.setSort(theSort);
276                        paramMap.setCount(theCount);
277                        paramMap.setOffset(theOffset);
278                        paramMap.setSummaryMode(theSummaryMode);
279                        paramMap.setSearchTotalMode(theSearchTotalMode);
280                        paramMap.setSearchContainedMode(theSearchContainedMode);
281
282                        getDao().translateRawParameters(theAdditionalRawParams, paramMap);
283
284                        ca.uhn.fhir.rest.api.server.IBundleProvider retVal = getDao().search(paramMap, theRequestDetails, theServletResponse);
285                        return retVal;
286                } finally {
287                        endRequest(theServletRequest);
288                }
289        }
290
291}