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