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