001
002package ca.uhn.fhir.jpa.rp.r4;
003
004import java.util.*;
005
006import org.apache.commons.lang3.StringUtils;
007
008import ca.uhn.fhir.jpa.provider.r4.*;
009import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
010import ca.uhn.fhir.model.api.Include;
011import ca.uhn.fhir.model.api.annotation.*;
012import org.hl7.fhir.r4.model.*;
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        BaseJpaResourceProviderEncounterR4
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                        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                        TokenAndListParam the_id,
073   
074
075                        @Description(shortDefinition="The set of accounts that may be used for billing for this Encounter")
076                        @OptionalParam(name="account", targetTypes={  } )
077                        ReferenceAndListParam theAccount, 
078   
079
080                        @Description(shortDefinition="The appointment that scheduled this encounter")
081                        @OptionalParam(name="appointment", targetTypes={  } )
082                        ReferenceAndListParam theAppointment, 
083   
084
085                        @Description(shortDefinition="The ServiceRequest that initiated this encounter")
086                        @OptionalParam(name="based-on", targetTypes={  } )
087                        ReferenceAndListParam theBased_on, 
088   
089
090                        @Description(shortDefinition="Classification of patient encounter")
091                        @OptionalParam(name="class")
092                        TokenAndListParam theClass,
093   
094
095                        @Description(shortDefinition="A date within the period the Encounter lasted")
096                        @OptionalParam(name="date")
097                        DateRangeParam theDate, 
098   
099
100                        @Description(shortDefinition="The diagnosis or procedure relevant to the encounter")
101                        @OptionalParam(name="diagnosis", targetTypes={  } )
102                        ReferenceAndListParam theDiagnosis, 
103   
104
105                        @Description(shortDefinition="Episode(s) of care that this encounter should be recorded against")
106                        @OptionalParam(name="episode-of-care", targetTypes={  } )
107                        ReferenceAndListParam theEpisode_of_care, 
108   
109
110                        @Description(shortDefinition="Identifier(s) by which this encounter is known")
111                        @OptionalParam(name="identifier")
112                        TokenAndListParam theIdentifier,
113   
114
115                        @Description(shortDefinition="Length of encounter in days")
116                        @OptionalParam(name="length")
117                        QuantityAndListParam theLength, 
118   
119
120                        @Description(shortDefinition="Location the encounter takes place")
121                        @OptionalParam(name="location", targetTypes={  } )
122                        ReferenceAndListParam theLocation, 
123   
124
125                        @Description(shortDefinition="Time period during which the patient was present at the location")
126                        @OptionalParam(name="location-period")
127                        DateRangeParam theLocation_period, 
128   
129
130                        @Description(shortDefinition="Another Encounter this encounter is part of")
131                        @OptionalParam(name="part-of", targetTypes={  } )
132                        ReferenceAndListParam thePart_of, 
133   
134
135                        @Description(shortDefinition="Persons involved in the encounter other than the patient")
136                        @OptionalParam(name="participant", targetTypes={  } )
137                        ReferenceAndListParam theParticipant, 
138   
139
140                        @Description(shortDefinition="Role of participant in encounter")
141                        @OptionalParam(name="participant-type")
142                        TokenAndListParam theParticipant_type,
143   
144
145                        @Description(shortDefinition="The patient or group present at the encounter")
146                        @OptionalParam(name="patient", targetTypes={  } )
147                        ReferenceAndListParam thePatient, 
148   
149
150                        @Description(shortDefinition="Persons involved in the encounter other than the patient")
151                        @OptionalParam(name="practitioner", targetTypes={  } )
152                        ReferenceAndListParam thePractitioner, 
153   
154
155                        @Description(shortDefinition="Coded reason the encounter takes place")
156                        @OptionalParam(name="reason-code")
157                        TokenAndListParam theReason_code,
158   
159
160                        @Description(shortDefinition="Reason the encounter takes place (reference)")
161                        @OptionalParam(name="reason-reference", targetTypes={  } )
162                        ReferenceAndListParam theReason_reference, 
163   
164
165                        @Description(shortDefinition="The organization (facility) responsible for this encounter")
166                        @OptionalParam(name="service-provider", targetTypes={  } )
167                        ReferenceAndListParam theService_provider, 
168   
169
170                        @Description(shortDefinition="Wheelchair, translator, stretcher, etc.")
171                        @OptionalParam(name="special-arrangement")
172                        TokenAndListParam theSpecial_arrangement,
173   
174
175                        @Description(shortDefinition="planned | arrived | triaged | in-progress | onleave | finished | cancelled +")
176                        @OptionalParam(name="status")
177                        TokenAndListParam theStatus,
178   
179
180                        @Description(shortDefinition="The patient or group present at the encounter")
181                        @OptionalParam(name="subject", targetTypes={  } )
182                        ReferenceAndListParam theSubject, 
183   
184
185                        @Description(shortDefinition="Specific type of encounter")
186                        @OptionalParam(name="type")
187                        TokenAndListParam theType,
188
189                        @RawParam
190                        Map<String, List<String>> theAdditionalRawParams,
191
192                        @Description(shortDefinition="Only return resources which were last updated as specified by the given range")
193                        @OptionalParam(name="_lastUpdated")
194                        DateRangeParam theLastUpdated, 
195
196                        @IncludeParam
197                        Set<Include> theIncludes,
198
199                        @IncludeParam(reverse=true)
200                        Set<Include> theRevIncludes,
201
202                        @Sort
203                        SortSpec theSort,
204                        
205                        @ca.uhn.fhir.rest.annotation.Count
206                        Integer theCount,
207
208                        @ca.uhn.fhir.rest.annotation.Offset
209                        Integer theOffset,
210
211                        SummaryEnum theSummaryMode,
212
213                        SearchTotalModeEnum theSearchTotalMode,
214
215                        SearchContainedModeEnum theSearchContainedMode
216
217                        ) {
218                startRequest(theServletRequest);
219                try {
220                        SearchParameterMap paramMap = new SearchParameterMap();
221                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_FILTER, theFtFilter);
222                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_CONTENT, theFtContent);
223                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TEXT, theFtText);
224                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TAG, theSearchForTag);
225                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY, theSearchForSecurity);
226                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE, theSearchForProfile);
227                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SOURCE, theSearchForSource);
228                        paramMap.add("_has", theHas);
229                        paramMap.add("_id", the_id);
230                        paramMap.add("account", theAccount);
231                        paramMap.add("appointment", theAppointment);
232                        paramMap.add("based-on", theBased_on);
233                        paramMap.add("class", theClass);
234                        paramMap.add("date", theDate);
235                        paramMap.add("diagnosis", theDiagnosis);
236                        paramMap.add("episode-of-care", theEpisode_of_care);
237                        paramMap.add("identifier", theIdentifier);
238                        paramMap.add("length", theLength);
239                        paramMap.add("location", theLocation);
240                        paramMap.add("location-period", theLocation_period);
241                        paramMap.add("part-of", thePart_of);
242                        paramMap.add("participant", theParticipant);
243                        paramMap.add("participant-type", theParticipant_type);
244                        paramMap.add("patient", thePatient);
245                        paramMap.add("practitioner", thePractitioner);
246                        paramMap.add("reason-code", theReason_code);
247                        paramMap.add("reason-reference", theReason_reference);
248                        paramMap.add("service-provider", theService_provider);
249                        paramMap.add("special-arrangement", theSpecial_arrangement);
250                        paramMap.add("status", theStatus);
251                        paramMap.add("subject", theSubject);
252                        paramMap.add("type", theType);
253                        paramMap.setRevIncludes(theRevIncludes);
254                        paramMap.setLastUpdated(theLastUpdated);
255                        paramMap.setIncludes(theIncludes);
256                        paramMap.setSort(theSort);
257                        paramMap.setCount(theCount);
258                        paramMap.setOffset(theOffset);
259                        paramMap.setSummaryMode(theSummaryMode);
260                        paramMap.setSearchTotalMode(theSearchTotalMode);
261                        paramMap.setSearchContainedMode(theSearchContainedMode);
262
263                        getDao().translateRawParameters(theAdditionalRawParams, paramMap);
264
265                        ca.uhn.fhir.rest.api.server.IBundleProvider retVal = getDao().search(paramMap, theRequestDetails, theServletResponse);
266                        return retVal;
267                } finally {
268                        endRequest(theServletRequest);
269                }
270        }
271
272}