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