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 EncounterResourceProvider extends 
021        ca.uhn.fhir.jpa.provider.BaseJpaResourceProviderEncounter<Encounter>
022        {
023
024        @Override
025        public Class<Encounter> getResourceType() {
026                return Encounter.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="Search for resources which have the given source value (Resource.meta.source)")
065                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_SOURCE)
066                        UriAndListParam theSearchForSource,
067
068                        @Description(shortDefinition="Return resources linked to by the given target")
069                        @OptionalParam(name="_has")
070                        HasAndListParam theHas, 
071
072   
073
074                        @Description(shortDefinition="The ID of the resource")
075                        @OptionalParam(name="_id")
076                        StringAndListParam the_id, 
077   
078
079                        @Description(shortDefinition="")
080                        @OptionalParam(name="appointment", targetTypes={  } )
081                        ReferenceAndListParam theAppointment, 
082   
083
084                        @Description(shortDefinition="")
085                        @OptionalParam(name="condition", targetTypes={  } )
086                        ReferenceAndListParam theCondition, 
087   
088
089                        @Description(shortDefinition="A date within the period the Encounter lasted")
090                        @OptionalParam(name="date")
091                        DateRangeParam theDate, 
092   
093
094                        @Description(shortDefinition="")
095                        @OptionalParam(name="episodeofcare", targetTypes={  } )
096                        ReferenceAndListParam theEpisodeofcare, 
097   
098
099                        @Description(shortDefinition="")
100                        @OptionalParam(name="identifier")
101                        TokenAndListParam theIdentifier,
102   
103
104                        @Description(shortDefinition="")
105                        @OptionalParam(name="incomingreferral", targetTypes={  } )
106                        ReferenceAndListParam theIncomingreferral, 
107   
108
109                        @Description(shortDefinition="")
110                        @OptionalParam(name="indication", targetTypes={  } )
111                        ReferenceAndListParam theIndication, 
112   
113
114                        @Description(shortDefinition="Length of encounter in days")
115                        @OptionalParam(name="length")
116                        NumberAndListParam theLength, 
117   
118
119                        @Description(shortDefinition="")
120                        @OptionalParam(name="location", targetTypes={  } )
121                        ReferenceAndListParam theLocation, 
122   
123
124                        @Description(shortDefinition="")
125                        @OptionalParam(name="location-period")
126                        DateRangeParam theLocation_period, 
127   
128
129                        @Description(shortDefinition="")
130                        @OptionalParam(name="part-of", targetTypes={  } )
131                        ReferenceAndListParam thePart_of, 
132   
133
134                        @Description(shortDefinition="")
135                        @OptionalParam(name="participant", targetTypes={  } )
136                        ReferenceAndListParam theParticipant, 
137   
138
139                        @Description(shortDefinition="")
140                        @OptionalParam(name="participant-type")
141                        TokenAndListParam theParticipant_type,
142   
143
144                        @Description(shortDefinition="")
145                        @OptionalParam(name="patient", targetTypes={  } )
146                        ReferenceAndListParam thePatient, 
147   
148
149                        @Description(shortDefinition="")
150                        @OptionalParam(name="practitioner", targetTypes={  } )
151                        ReferenceAndListParam thePractitioner, 
152   
153
154                        @Description(shortDefinition="")
155                        @OptionalParam(name="procedure", targetTypes={  } )
156                        ReferenceAndListParam theProcedure, 
157   
158
159                        @Description(shortDefinition="")
160                        @OptionalParam(name="reason")
161                        TokenAndListParam theReason,
162   
163
164                        @Description(shortDefinition="")
165                        @OptionalParam(name="special-arrangement")
166                        TokenAndListParam theSpecial_arrangement,
167   
168
169                        @Description(shortDefinition="")
170                        @OptionalParam(name="status")
171                        TokenAndListParam theStatus,
172   
173
174                        @Description(shortDefinition="")
175                        @OptionalParam(name="type")
176                        TokenAndListParam theType,
177
178                        @RawParam
179                        Map<String, List<String>> theAdditionalRawParams,
180
181                        @Description(shortDefinition="Only return resources which were last updated as specified by the given range")
182                        @OptionalParam(name="_lastUpdated")
183                        DateRangeParam theLastUpdated, 
184
185                        @IncludeParam
186                        Set<Include> theIncludes,
187
188                        @IncludeParam(reverse=true)
189                        Set<Include> theRevIncludes,
190
191                        @Sort
192                        SortSpec theSort,
193                        
194                        @ca.uhn.fhir.rest.annotation.Count
195                        Integer theCount,
196
197                        @ca.uhn.fhir.rest.annotation.Offset
198                        Integer theOffset,
199
200                        SummaryEnum theSummaryMode,
201
202                        SearchTotalModeEnum theSearchTotalMode,
203
204                        SearchContainedModeEnum theSearchContainedMode
205
206                        ) {
207                startRequest(theServletRequest);
208                try {
209                        SearchParameterMap paramMap = new SearchParameterMap();
210                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_FILTER, theFtFilter);
211                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_CONTENT, theFtContent);
212                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TEXT, theFtText);
213                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TAG, theSearchForTag);
214                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY, theSearchForSecurity);
215                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE, theSearchForProfile);
216                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SOURCE, theSearchForSource);
217                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_LIST, theList);
218                        paramMap.add("_has", theHas);
219                        paramMap.add("_id", the_id);
220                        paramMap.add("appointment", theAppointment);
221                        paramMap.add("condition", theCondition);
222                        paramMap.add("date", theDate);
223                        paramMap.add("episodeofcare", theEpisodeofcare);
224                        paramMap.add("identifier", theIdentifier);
225                        paramMap.add("incomingreferral", theIncomingreferral);
226                        paramMap.add("indication", theIndication);
227                        paramMap.add("length", theLength);
228                        paramMap.add("location", theLocation);
229                        paramMap.add("location-period", theLocation_period);
230                        paramMap.add("part-of", thePart_of);
231                        paramMap.add("participant", theParticipant);
232                        paramMap.add("participant-type", theParticipant_type);
233                        paramMap.add("patient", thePatient);
234                        paramMap.add("practitioner", thePractitioner);
235                        paramMap.add("procedure", theProcedure);
236                        paramMap.add("reason", theReason);
237                        paramMap.add("special-arrangement", theSpecial_arrangement);
238                        paramMap.add("status", theStatus);
239                        paramMap.add("type", theType);
240                        paramMap.setRevIncludes(theRevIncludes);
241                        paramMap.setLastUpdated(theLastUpdated);
242                        paramMap.setIncludes(theIncludes);
243                        paramMap.setSort(theSort);
244                        paramMap.setCount(theCount);
245                        paramMap.setOffset(theOffset);
246                        paramMap.setSummaryMode(theSummaryMode);
247                        paramMap.setSearchTotalMode(theSearchTotalMode);
248                        paramMap.setSearchContainedMode(theSearchContainedMode);
249
250                        getDao().translateRawParameters(theAdditionalRawParams, paramMap);
251
252                        ca.uhn.fhir.rest.api.server.IBundleProvider retVal = getDao().search(paramMap, theRequestDetails, theServletResponse);
253                        return retVal;
254                } finally {
255                        endRequest(theServletRequest);
256                }
257        }
258
259}