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 PatientResourceProvider extends 
021        ca.uhn.fhir.jpa.provider.BaseJpaResourceProviderPatient<Patient>
022        {
023
024        @Override
025        public Class<Patient> getResourceType() {
026                return Patient.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="The language of the resource")
065                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_LANGUAGE)
066                        TokenAndListParam theResourceLanguage,
067
068                        @Description(shortDefinition="Search for resources which have the given source value (Resource.meta.source)")
069                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_SOURCE)
070                        UriAndListParam theSearchForSource,
071
072                        @Description(shortDefinition="Return resources linked to by the given target")
073                        @OptionalParam(name="_has")
074                        HasAndListParam theHas, 
075
076   
077
078                        @Description(shortDefinition="The ID of the resource")
079                        @OptionalParam(name="_id")
080                        StringAndListParam the_id, 
081   
082
083                        @Description(shortDefinition="Whether the patient record is active")
084                        @OptionalParam(name="active")
085                        TokenAndListParam theActive,
086   
087
088                        @Description(shortDefinition="An address in any kind of address/part of the patient")
089                        @OptionalParam(name="address")
090                        StringAndListParam theAddress, 
091   
092
093                        @Description(shortDefinition="A city specified in an address")
094                        @OptionalParam(name="address-city")
095                        StringAndListParam theAddress_city, 
096   
097
098                        @Description(shortDefinition="A country specified in an address")
099                        @OptionalParam(name="address-country")
100                        StringAndListParam theAddress_country, 
101   
102
103                        @Description(shortDefinition="A postalCode specified in an address")
104                        @OptionalParam(name="address-postalcode")
105                        StringAndListParam theAddress_postalcode, 
106   
107
108                        @Description(shortDefinition="A state specified in an address")
109                        @OptionalParam(name="address-state")
110                        StringAndListParam theAddress_state, 
111   
112
113                        @Description(shortDefinition="A use code specified in an address")
114                        @OptionalParam(name="address-use")
115                        TokenAndListParam theAddress_use,
116   
117
118                        @Description(shortDefinition="The breed for animal patients")
119                        @OptionalParam(name="animal-breed")
120                        TokenAndListParam theAnimal_breed,
121   
122
123                        @Description(shortDefinition="The species for animal patients")
124                        @OptionalParam(name="animal-species")
125                        TokenAndListParam theAnimal_species,
126   
127
128                        @Description(shortDefinition="The patient's date of birth")
129                        @OptionalParam(name="birthdate")
130                        DateRangeParam theBirthdate, 
131   
132
133                        @Description(shortDefinition="Patient's nominated care provider, could be a care manager, not the organization that manages the record")
134                        @OptionalParam(name="careprovider", targetTypes={  } )
135                        ReferenceAndListParam theCareprovider, 
136   
137
138                        @Description(shortDefinition="The date of death has been provided and satisfies this search value")
139                        @OptionalParam(name="deathdate")
140                        DateRangeParam theDeathdate, 
141   
142
143                        @Description(shortDefinition="This patient has been marked as deceased, or as a death date entered")
144                        @OptionalParam(name="deceased")
145                        TokenAndListParam theDeceased,
146   
147
148                        @Description(shortDefinition="A value in an email contact")
149                        @OptionalParam(name="email")
150                        TokenAndListParam theEmail,
151   
152
153                        @Description(shortDefinition="A portion of the family name of the patient")
154                        @OptionalParam(name="family")
155                        StringAndListParam theFamily, 
156   
157
158                        @Description(shortDefinition="Gender of the patient")
159                        @OptionalParam(name="gender")
160                        TokenAndListParam theGender,
161   
162
163                        @Description(shortDefinition="A portion of the given name of the patient")
164                        @OptionalParam(name="given")
165                        StringAndListParam theGiven, 
166   
167
168                        @Description(shortDefinition="A patient identifier")
169                        @OptionalParam(name="identifier")
170                        TokenAndListParam theIdentifier,
171   
172
173                        @Description(shortDefinition="Language code (irrespective of use value)")
174                        @OptionalParam(name="language")
175                        TokenAndListParam theLanguage,
176   
177
178                        @Description(shortDefinition="All patients linked to the given patient")
179                        @OptionalParam(name="link", targetTypes={  } )
180                        ReferenceAndListParam theLink, 
181   
182
183                        @Description(shortDefinition="A portion of either family or given name of the patient")
184                        @OptionalParam(name="name")
185                        StringAndListParam theName, 
186   
187
188                        @Description(shortDefinition="The organization at which this person is a patient")
189                        @OptionalParam(name="organization", targetTypes={  } )
190                        ReferenceAndListParam theOrganization, 
191   
192
193                        @Description(shortDefinition="A value in a phone contact")
194                        @OptionalParam(name="phone")
195                        TokenAndListParam thePhone,
196   
197
198                        @Description(shortDefinition="A portion of either family or given name using some kind of phonetic matching algorithm")
199                        @OptionalParam(name="phonetic")
200                        StringAndListParam thePhonetic, 
201   
202
203                        @Description(shortDefinition="The value in any kind of telecom details of the patient")
204                        @OptionalParam(name="telecom")
205                        TokenAndListParam theTelecom,
206
207                        @RawParam
208                        Map<String, List<String>> theAdditionalRawParams,
209
210                        @Description(shortDefinition="Only return resources which were last updated as specified by the given range")
211                        @OptionalParam(name="_lastUpdated")
212                        DateRangeParam theLastUpdated, 
213
214                        @IncludeParam
215                        Set<Include> theIncludes,
216
217                        @IncludeParam(reverse=true)
218                        Set<Include> theRevIncludes,
219
220                        @Sort
221                        SortSpec theSort,
222                        
223                        @ca.uhn.fhir.rest.annotation.Count
224                        Integer theCount,
225
226                        @ca.uhn.fhir.rest.annotation.Offset
227                        Integer theOffset,
228
229                        SummaryEnum theSummaryMode,
230
231                        SearchTotalModeEnum theSearchTotalMode,
232
233                        SearchContainedModeEnum theSearchContainedMode
234
235                        ) {
236                startRequest(theServletRequest);
237                try {
238                        SearchParameterMap paramMap = new SearchParameterMap();
239                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_FILTER, theFtFilter);
240                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_CONTENT, theFtContent);
241                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TEXT, theFtText);
242                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TAG, theSearchForTag);
243                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY, theSearchForSecurity);
244                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE, theSearchForProfile);
245                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SOURCE, theSearchForSource);
246                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_LIST, theList);
247                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_LANGUAGE, theResourceLanguage);
248
249                        paramMap.add("_has", theHas);
250                        paramMap.add("_id", the_id);
251                        paramMap.add("active", theActive);
252                        paramMap.add("address", theAddress);
253                        paramMap.add("address-city", theAddress_city);
254                        paramMap.add("address-country", theAddress_country);
255                        paramMap.add("address-postalcode", theAddress_postalcode);
256                        paramMap.add("address-state", theAddress_state);
257                        paramMap.add("address-use", theAddress_use);
258                        paramMap.add("animal-breed", theAnimal_breed);
259                        paramMap.add("animal-species", theAnimal_species);
260                        paramMap.add("birthdate", theBirthdate);
261                        paramMap.add("careprovider", theCareprovider);
262                        paramMap.add("deathdate", theDeathdate);
263                        paramMap.add("deceased", theDeceased);
264                        paramMap.add("email", theEmail);
265                        paramMap.add("family", theFamily);
266                        paramMap.add("gender", theGender);
267                        paramMap.add("given", theGiven);
268                        paramMap.add("identifier", theIdentifier);
269                        paramMap.add("language", theLanguage);
270                        paramMap.add("link", theLink);
271                        paramMap.add("name", theName);
272                        paramMap.add("organization", theOrganization);
273                        paramMap.add("phone", thePhone);
274                        paramMap.add("phonetic", thePhonetic);
275                        paramMap.add("telecom", theTelecom);
276                        paramMap.setRevIncludes(theRevIncludes);
277                        paramMap.setLastUpdated(theLastUpdated);
278                        paramMap.setIncludes(theIncludes);
279                        paramMap.setSort(theSort);
280                        paramMap.setCount(theCount);
281                        paramMap.setOffset(theOffset);
282                        paramMap.setSummaryMode(theSummaryMode);
283                        paramMap.setSearchTotalMode(theSearchTotalMode);
284                        paramMap.setSearchContainedMode(theSearchContainedMode);
285
286                        getDao().translateRawParameters(theAdditionalRawParams, paramMap);
287
288                        ca.uhn.fhir.rest.api.server.IBundleProvider retVal = getDao().search(paramMap, theRequestDetails, theServletResponse);
289                        return retVal;
290                } finally {
291                        endRequest(theServletRequest);
292                }
293        }
294
295}