001
002package ca.uhn.fhir.jpa.rp.r5;
003
004import java.util.*;
005
006import org.apache.commons.lang3.StringUtils;
007
008import ca.uhn.fhir.jpa.provider.r5.*;
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.r5.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 PatientResourceProvider extends 
021        BaseJpaResourceProviderPatientR5
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                        TokenAndListParam the_id,
073   
074
075                        @Description(shortDefinition="Search on the narrative of the resource")
076                        @OptionalParam(name="_text")
077                        SpecialAndListParam the_text,
078   
079
080                        @Description(shortDefinition="Whether the patient record is active")
081                        @OptionalParam(name="active")
082                        TokenAndListParam theActive,
083   
084
085                        @Description(shortDefinition="Multiple Resources: * [Patient](patient.html): A server defined search that may match any of the string fields in the Address, including line, city, district, state, country, postalCode, and/or text* [Person](person.html): A server defined search that may match any of the string fields in the Address, including line, city, district, state, country, postalCode, and/or text* [Practitioner](practitioner.html): A server defined search that may match any of the string fields in the Address, including line, city, district, state, country, postalCode, and/or text* [RelatedPerson](relatedperson.html): A server defined search that may match any of the string fields in the Address, including line, city, district, state, country, postalCode, and/or text")
086                        @OptionalParam(name="address")
087                        StringAndListParam theAddress, 
088   
089
090                        @Description(shortDefinition="Multiple Resources: * [Patient](patient.html): A city specified in an address* [Person](person.html): A city specified in an address* [Practitioner](practitioner.html): A city specified in an address* [RelatedPerson](relatedperson.html): A city specified in an address")
091                        @OptionalParam(name="address-city")
092                        StringAndListParam theAddress_city, 
093   
094
095                        @Description(shortDefinition="Multiple Resources: * [Patient](patient.html): A country specified in an address* [Person](person.html): A country specified in an address* [Practitioner](practitioner.html): A country specified in an address* [RelatedPerson](relatedperson.html): A country specified in an address")
096                        @OptionalParam(name="address-country")
097                        StringAndListParam theAddress_country, 
098   
099
100                        @Description(shortDefinition="Multiple Resources: * [Patient](patient.html): A postalCode specified in an address* [Person](person.html): A postal code specified in an address* [Practitioner](practitioner.html): A postalCode specified in an address* [RelatedPerson](relatedperson.html): A postal code specified in an address")
101                        @OptionalParam(name="address-postalcode")
102                        StringAndListParam theAddress_postalcode, 
103   
104
105                        @Description(shortDefinition="Multiple Resources: * [Patient](patient.html): A state specified in an address* [Person](person.html): A state specified in an address* [Practitioner](practitioner.html): A state specified in an address* [RelatedPerson](relatedperson.html): A state specified in an address")
106                        @OptionalParam(name="address-state")
107                        StringAndListParam theAddress_state, 
108   
109
110                        @Description(shortDefinition="Multiple Resources: * [Patient](patient.html): A use code specified in an address* [Person](person.html): A use code specified in an address* [Practitioner](practitioner.html): A use code specified in an address* [RelatedPerson](relatedperson.html): A use code specified in an address")
111                        @OptionalParam(name="address-use")
112                        TokenAndListParam theAddress_use,
113   
114
115                        @Description(shortDefinition="Searches for patients based on age as calculated based on current date and date of birth.  Deceased patients are excluded from the search.")
116                        @OptionalParam(name="age")
117                        NumberAndListParam theAge, 
118   
119
120                        @Description(shortDefinition="Search based on whether a patient was part of a multiple birth or not.")
121                        @OptionalParam(name="birthOrderBoolean")
122                        TokenAndListParam theBirthOrderBoolean,
123   
124
125                        @Description(shortDefinition="Multiple Resources: * [Patient](patient.html): The patient's date of birth* [Person](person.html): The person's date of birth* [RelatedPerson](relatedperson.html): The Related Person's date of birth")
126                        @OptionalParam(name="birthdate")
127                        DateRangeParam theBirthdate, 
128   
129
130                        @Description(shortDefinition="The date of death has been provided and satisfies this search value")
131                        @OptionalParam(name="death-date")
132                        DateRangeParam theDeath_date, 
133   
134
135                        @Description(shortDefinition="This patient has been marked as deceased, or has a death date entered")
136                        @OptionalParam(name="deceased")
137                        TokenAndListParam theDeceased,
138   
139
140                        @Description(shortDefinition="Multiple Resources: * [Patient](patient.html): A value in an email contact* [Person](person.html): A value in an email contact* [Practitioner](practitioner.html): A value in an email contact* [PractitionerRole](practitionerrole.html): A value in an email contact* [RelatedPerson](relatedperson.html): A value in an email contact")
141                        @OptionalParam(name="email")
142                        TokenAndListParam theEmail,
143   
144
145                        @Description(shortDefinition="Multiple Resources: * [Patient](patient.html): A portion of the family name of the patient* [Practitioner](practitioner.html): A portion of the family name")
146                        @OptionalParam(name="family")
147                        StringAndListParam theFamily, 
148   
149
150                        @Description(shortDefinition="Multiple Resources: * [Patient](patient.html): Gender of the patient* [Person](person.html): The gender of the person* [Practitioner](practitioner.html): Gender of the practitioner* [RelatedPerson](relatedperson.html): Gender of the related person")
151                        @OptionalParam(name="gender")
152                        TokenAndListParam theGender,
153   
154
155                        @Description(shortDefinition="Patient's nominated general practitioner, not the organization that manages the record")
156                        @OptionalParam(name="general-practitioner", targetTypes={  } )
157                        ReferenceAndListParam theGeneral_practitioner, 
158   
159
160                        @Description(shortDefinition="Multiple Resources: * [Patient](patient.html): A portion of the given name of the patient* [Practitioner](practitioner.html): A portion of the given name")
161                        @OptionalParam(name="given")
162                        StringAndListParam theGiven, 
163   
164
165                        @Description(shortDefinition="A patient identifier")
166                        @OptionalParam(name="identifier")
167                        TokenAndListParam theIdentifier,
168   
169
170                        @Description(shortDefinition="Language code (irrespective of use value)")
171                        @OptionalParam(name="language")
172                        TokenAndListParam theLanguage,
173   
174
175                        @Description(shortDefinition="All patients linked to the given patient")
176                        @OptionalParam(name="link", targetTypes={  } )
177                        ReferenceAndListParam theLink, 
178   
179
180                        @Description(shortDefinition="Search based on patient's mother's maiden name")
181                        @OptionalParam(name="mothersMaidenName")
182                        StringAndListParam theMothersMaidenName, 
183   
184
185                        @Description(shortDefinition="A server defined search that may match any of the string fields in the HumanName, including family, given, prefix, suffix, and/or text")
186                        @OptionalParam(name="name")
187                        StringAndListParam theName, 
188   
189
190                        @Description(shortDefinition="The organization that is the custodian of the patient record")
191                        @OptionalParam(name="organization", targetTypes={  } )
192                        ReferenceAndListParam theOrganization, 
193   
194
195                        @Description(shortDefinition="Search by url for a participation agreement, which is stored in a DocumentReference")
196                        @OptionalParam(name="part-agree", targetTypes={  } )
197                        ReferenceAndListParam thePart_agree, 
198   
199
200                        @Description(shortDefinition="Multiple Resources: * [Patient](patient.html): A value in a phone contact* [Person](person.html): A value in a phone contact* [Practitioner](practitioner.html): A value in a phone contact* [PractitionerRole](practitionerrole.html): A value in a phone contact* [RelatedPerson](relatedperson.html): A value in a phone contact")
201                        @OptionalParam(name="phone")
202                        TokenAndListParam thePhone,
203   
204
205                        @Description(shortDefinition="Multiple Resources: * [Patient](patient.html): A portion of either family or given name using some kind of phonetic matching algorithm* [Person](person.html): A portion of name using some kind of phonetic matching algorithm* [Practitioner](practitioner.html): A portion of either family or given name using some kind of phonetic matching algorithm* [RelatedPerson](relatedperson.html): A portion of name using some kind of phonetic matching algorithm")
206                        @OptionalParam(name="phonetic")
207                        StringAndListParam thePhonetic, 
208   
209
210                        @Description(shortDefinition="Multiple Resources: * [Patient](patient.html): The value in any kind of telecom details of the patient* [Person](person.html): The value in any kind of contact* [Practitioner](practitioner.html): The value in any kind of contact* [PractitionerRole](practitionerrole.html): The value in any kind of contact* [RelatedPerson](relatedperson.html): The value in any kind of contact")
211                        @OptionalParam(name="telecom")
212                        TokenAndListParam theTelecom,
213
214                        @RawParam
215                        Map<String, List<String>> theAdditionalRawParams,
216
217                        @Description(shortDefinition="Only return resources which were last updated as specified by the given range")
218                        @OptionalParam(name="_lastUpdated")
219                        DateRangeParam theLastUpdated, 
220
221                        @IncludeParam
222                        Set<Include> theIncludes,
223
224                        @IncludeParam(reverse=true)
225                        Set<Include> theRevIncludes,
226
227                        @Sort
228                        SortSpec theSort,
229                        
230                        @ca.uhn.fhir.rest.annotation.Count
231                        Integer theCount,
232
233                        @ca.uhn.fhir.rest.annotation.Offset
234                        Integer theOffset,
235
236                        SummaryEnum theSummaryMode,
237
238                        SearchTotalModeEnum theSearchTotalMode,
239
240                        SearchContainedModeEnum theSearchContainedMode
241
242                        ) {
243                startRequest(theServletRequest);
244                try {
245                        SearchParameterMap paramMap = new SearchParameterMap();
246                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_FILTER, theFtFilter);
247                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_CONTENT, theFtContent);
248                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TEXT, theFtText);
249                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TAG, theSearchForTag);
250                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY, theSearchForSecurity);
251                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE, theSearchForProfile);
252                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SOURCE, theSearchForSource);
253                        paramMap.add("_has", theHas);
254                        paramMap.add("_id", the_id);
255                        paramMap.add("_text", the_text);
256                        paramMap.add("active", theActive);
257                        paramMap.add("address", theAddress);
258                        paramMap.add("address-city", theAddress_city);
259                        paramMap.add("address-country", theAddress_country);
260                        paramMap.add("address-postalcode", theAddress_postalcode);
261                        paramMap.add("address-state", theAddress_state);
262                        paramMap.add("address-use", theAddress_use);
263                        paramMap.add("age", theAge);
264                        paramMap.add("birthOrderBoolean", theBirthOrderBoolean);
265                        paramMap.add("birthdate", theBirthdate);
266                        paramMap.add("death-date", theDeath_date);
267                        paramMap.add("deceased", theDeceased);
268                        paramMap.add("email", theEmail);
269                        paramMap.add("family", theFamily);
270                        paramMap.add("gender", theGender);
271                        paramMap.add("general-practitioner", theGeneral_practitioner);
272                        paramMap.add("given", theGiven);
273                        paramMap.add("identifier", theIdentifier);
274                        paramMap.add("language", theLanguage);
275                        paramMap.add("link", theLink);
276                        paramMap.add("mothersMaidenName", theMothersMaidenName);
277                        paramMap.add("name", theName);
278                        paramMap.add("organization", theOrganization);
279                        paramMap.add("part-agree", thePart_agree);
280                        paramMap.add("phone", thePhone);
281                        paramMap.add("phonetic", thePhonetic);
282                        paramMap.add("telecom", theTelecom);
283                        paramMap.setRevIncludes(theRevIncludes);
284                        paramMap.setLastUpdated(theLastUpdated);
285                        paramMap.setIncludes(theIncludes);
286                        paramMap.setSort(theSort);
287                        paramMap.setCount(theCount);
288                        paramMap.setOffset(theOffset);
289                        paramMap.setSummaryMode(theSummaryMode);
290                        paramMap.setSearchTotalMode(theSearchTotalMode);
291                        paramMap.setSearchContainedMode(theSearchContainedMode);
292
293                        getDao().translateRawParameters(theAdditionalRawParams, paramMap);
294
295                        ca.uhn.fhir.rest.api.server.IBundleProvider retVal = getDao().search(paramMap, theRequestDetails, theServletResponse);
296                        return retVal;
297                } finally {
298                        endRequest(theServletRequest);
299                }
300        }
301
302}