View Javadoc
1   
2   package ca.uhn.fhir.jpa.rp.dstu2;
3   
4   import java.util.*;
5   
6   import org.apache.commons.lang3.StringUtils;
7   
8   import ca.uhn.fhir.jpa.provider.*;
9   import ca.uhn.fhir.jpa.dao.SearchParameterMap;
10  import ca.uhn.fhir.model.api.Include;
11  import ca.uhn.fhir.model.api.annotation.*;
12  import ca.uhn.fhir.model.dstu2.composite.*;
13  import ca.uhn.fhir.model.dstu2.resource.*; //
14  import ca.uhn.fhir.rest.annotation.*;
15  import ca.uhn.fhir.rest.param.*;
16  import ca.uhn.fhir.rest.api.SortSpec;
17  import ca.uhn.fhir.rest.api.SummaryEnum;
18  import ca.uhn.fhir.rest.api.SearchTotalModeEnum;
19  
20  public class PatientResourceProvider extends 
21  	BaseJpaResourceProviderPatientDstu2
22  	{
23  
24  	@Override
25  	public Class<Patient> getResourceType() {
26  		return Patient.class;
27  	}
28  
29  	@Search(allowUnknownParams=true)
30  	public ca.uhn.fhir.rest.api.server.IBundleProvider search(
31  			javax.servlet.http.HttpServletRequest theServletRequest,
32  			javax.servlet.http.HttpServletResponse theServletResponse,
33  
34  			ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails,
35  			
36  			@Description(shortDefinition="Search the contents of the resource's data using a fulltext search")
37  			@OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_CONTENT)
38  			StringAndListParam theFtContent, 
39  
40  			@Description(shortDefinition="Search the contents of the resource's narrative using a fulltext search")
41  			@OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_TEXT)
42  			StringAndListParam theFtText, 
43  
44  			@Description(shortDefinition="Search for resources which have the given tag")
45  			@OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_TAG)
46  			TokenAndListParam theSearchForTag, 
47  
48  			@Description(shortDefinition="Search for resources which have the given security labels")
49  			@OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY)
50  			TokenAndListParam theSearchForSecurity, 
51    
52  			@Description(shortDefinition="Search for resources which have the given profile")
53  			@OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE)
54  			UriAndListParam theSearchForProfile, 
55  
56  			@Description(shortDefinition="Return resources linked to by the given target")
57  			@OptionalParam(name="_has")
58  			HasAndListParam theHas, 
59  
60    
61  			@Description(shortDefinition="The ID of the resource")
62  			@OptionalParam(name="_id")
63  			StringAndListParam the_id, 
64    
65  			@Description(shortDefinition="The language of the resource")
66  			@OptionalParam(name="_language")
67  			StringAndListParam the_language, 
68    
69  			@Description(shortDefinition="Whether the patient record is active")
70  			@OptionalParam(name="active")
71  			TokenAndListParam theActive,
72    
73  			@Description(shortDefinition="An address in any kind of address/part of the patient")
74  			@OptionalParam(name="address")
75  			StringAndListParam theAddress, 
76    
77  			@Description(shortDefinition="A city specified in an address")
78  			@OptionalParam(name="address-city")
79  			StringAndListParam theAddress_city, 
80    
81  			@Description(shortDefinition="A country specified in an address")
82  			@OptionalParam(name="address-country")
83  			StringAndListParam theAddress_country, 
84    
85  			@Description(shortDefinition="A postalCode specified in an address")
86  			@OptionalParam(name="address-postalcode")
87  			StringAndListParam theAddress_postalcode, 
88    
89  			@Description(shortDefinition="A state specified in an address")
90  			@OptionalParam(name="address-state")
91  			StringAndListParam theAddress_state, 
92    
93  			@Description(shortDefinition="A use code specified in an address")
94  			@OptionalParam(name="address-use")
95  			TokenAndListParam theAddress_use,
96    
97  			@Description(shortDefinition="The breed for animal patients")
98  			@OptionalParam(name="animal-breed")
99  			TokenAndListParam theAnimal_breed,
100   
101 			@Description(shortDefinition="The species for animal patients")
102 			@OptionalParam(name="animal-species")
103 			TokenAndListParam theAnimal_species,
104   
105 			@Description(shortDefinition="The patient's date of birth")
106 			@OptionalParam(name="birthdate")
107 			DateRangeParam theBirthdate, 
108   
109 			@Description(shortDefinition="Patient's nominated care provider, could be a care manager, not the organization that manages the record")
110 			@OptionalParam(name="careprovider", targetTypes={  } )
111 			ReferenceAndListParam theCareprovider, 
112   
113 			@Description(shortDefinition="The date of death has been provided and satisfies this search value")
114 			@OptionalParam(name="deathdate")
115 			DateRangeParam theDeathdate, 
116   
117 			@Description(shortDefinition="This patient has been marked as deceased, or as a death date entered")
118 			@OptionalParam(name="deceased")
119 			TokenAndListParam theDeceased,
120   
121 			@Description(shortDefinition="A value in an email contact")
122 			@OptionalParam(name="email")
123 			TokenAndListParam theEmail,
124   
125 			@Description(shortDefinition="A portion of the family name of the patient")
126 			@OptionalParam(name="family")
127 			StringAndListParam theFamily, 
128   
129 			@Description(shortDefinition="Gender of the patient")
130 			@OptionalParam(name="gender")
131 			TokenAndListParam theGender,
132   
133 			@Description(shortDefinition="A portion of the given name of the patient")
134 			@OptionalParam(name="given")
135 			StringAndListParam theGiven, 
136   
137 			@Description(shortDefinition="A patient identifier")
138 			@OptionalParam(name="identifier")
139 			TokenAndListParam theIdentifier,
140   
141 			@Description(shortDefinition="Language code (irrespective of use value)")
142 			@OptionalParam(name="language")
143 			TokenAndListParam theLanguage,
144   
145 			@Description(shortDefinition="All patients linked to the given patient")
146 			@OptionalParam(name="link", targetTypes={  } )
147 			ReferenceAndListParam theLink, 
148   
149 			@Description(shortDefinition="A portion of either family or given name of the patient")
150 			@OptionalParam(name="name")
151 			StringAndListParam theName, 
152   
153 			@Description(shortDefinition="The organization at which this person is a patient")
154 			@OptionalParam(name="organization", targetTypes={  } )
155 			ReferenceAndListParam theOrganization, 
156   
157 			@Description(shortDefinition="A value in a phone contact")
158 			@OptionalParam(name="phone")
159 			TokenAndListParam thePhone,
160   
161 			@Description(shortDefinition="A portion of either family or given name using some kind of phonetic matching algorithm")
162 			@OptionalParam(name="phonetic")
163 			StringAndListParam thePhonetic, 
164   
165 			@Description(shortDefinition="The value in any kind of telecom details of the patient")
166 			@OptionalParam(name="telecom")
167 			TokenAndListParam theTelecom,
168 
169 			@RawParam
170 			Map<String, List<String>> theAdditionalRawParams,
171 
172 			@IncludeParam(reverse=true)
173 			Set<Include> theRevIncludes,
174 			@Description(shortDefinition="Only return resources which were last updated as specified by the given range")
175 			@OptionalParam(name="_lastUpdated")
176 			DateRangeParam theLastUpdated, 
177 
178 			@IncludeParam(allow= {
179 					"Patient:careprovider" , 					"Patient:link" , 					"Patient:organization" , 						"Patient:careprovider" , 					"Patient:link" , 					"Patient:organization" , 						"Patient:careprovider" , 					"Patient:link" , 					"Patient:organization" 					, "*"
180 			}) 
181 			Set<Include> theIncludes,
182 			
183 			@Sort 
184 			SortSpec theSort,
185 			
186 			@ca.uhn.fhir.rest.annotation.Count
187 			Integer theCount,
188 
189 			SummaryEnum theSummaryMode,
190 
191 			SearchTotalModeEnum theSearchTotalMode
192 
193 			) {
194 		startRequest(theServletRequest);
195 		try {
196 			SearchParameterMap paramMap = new SearchParameterMap();
197 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_CONTENT, theFtContent);
198 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TEXT, theFtText);
199 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TAG, theSearchForTag);
200 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY, theSearchForSecurity);
201 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE, theSearchForProfile);
202 			paramMap.add("_has", theHas);
203 			paramMap.add("_id", the_id);
204 			paramMap.add("_language", the_language);
205 			paramMap.add("active", theActive);
206 			paramMap.add("address", theAddress);
207 			paramMap.add("address-city", theAddress_city);
208 			paramMap.add("address-country", theAddress_country);
209 			paramMap.add("address-postalcode", theAddress_postalcode);
210 			paramMap.add("address-state", theAddress_state);
211 			paramMap.add("address-use", theAddress_use);
212 			paramMap.add("animal-breed", theAnimal_breed);
213 			paramMap.add("animal-species", theAnimal_species);
214 			paramMap.add("birthdate", theBirthdate);
215 			paramMap.add("careprovider", theCareprovider);
216 			paramMap.add("deathdate", theDeathdate);
217 			paramMap.add("deceased", theDeceased);
218 			paramMap.add("email", theEmail);
219 			paramMap.add("family", theFamily);
220 			paramMap.add("gender", theGender);
221 			paramMap.add("given", theGiven);
222 			paramMap.add("identifier", theIdentifier);
223 			paramMap.add("language", theLanguage);
224 			paramMap.add("link", theLink);
225 			paramMap.add("name", theName);
226 			paramMap.add("organization", theOrganization);
227 			paramMap.add("phone", thePhone);
228 			paramMap.add("phonetic", thePhonetic);
229 			paramMap.add("telecom", theTelecom);
230 			paramMap.setRevIncludes(theRevIncludes);
231 			paramMap.setLastUpdated(theLastUpdated);
232 			paramMap.setIncludes(theIncludes);
233 			paramMap.setSort(theSort);
234 			paramMap.setCount(theCount);
235 			paramMap.setSummaryMode(theSummaryMode);
236 			paramMap.setSearchTotalMode(theSearchTotalMode);
237 
238 			getDao().translateRawParameters(theAdditionalRawParams, paramMap);
239 
240 			ca.uhn.fhir.rest.api.server.IBundleProvider retVal = getDao().search(paramMap, theRequestDetails, theServletResponse);
241 			return retVal;
242 		} finally {
243 			endRequest(theServletRequest);
244 		}
245 	}
246 
247 }