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  
18  public class PersonResourceProvider extends 
19  	JpaResourceProviderDstu2<Person>
20  	{
21  
22  	@Override
23  	public Class<Person> getResourceType() {
24  		return Person.class;
25  	}
26  
27  	@Search(allowUnknownParams=true)
28  	public ca.uhn.fhir.rest.api.server.IBundleProvider search(
29  			javax.servlet.http.HttpServletRequest theServletRequest,
30  			javax.servlet.http.HttpServletResponse theServletResponse,
31  
32  			ca.uhn.fhir.rest.api.server.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.api.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.api.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.api.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.api.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.api.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="An address in any kind of address/part")
68  			@OptionalParam(name="address")
69  			StringAndListParam theAddress, 
70    
71  			@Description(shortDefinition="A city specified in an address")
72  			@OptionalParam(name="address-city")
73  			StringAndListParam theAddress_city, 
74    
75  			@Description(shortDefinition="A country specified in an address")
76  			@OptionalParam(name="address-country")
77  			StringAndListParam theAddress_country, 
78    
79  			@Description(shortDefinition="A postal code specified in an address")
80  			@OptionalParam(name="address-postalcode")
81  			StringAndListParam theAddress_postalcode, 
82    
83  			@Description(shortDefinition="A state specified in an address")
84  			@OptionalParam(name="address-state")
85  			StringAndListParam theAddress_state, 
86    
87  			@Description(shortDefinition="A use code specified in an address")
88  			@OptionalParam(name="address-use")
89  			TokenAndListParam theAddress_use, 
90    
91  			@Description(shortDefinition="The person's date of birth")
92  			@OptionalParam(name="birthdate")
93  			DateRangeParam theBirthdate, 
94    
95  			@Description(shortDefinition="A value in an email contact")
96  			@OptionalParam(name="email")
97  			TokenAndListParam theEmail, 
98    
99  			@Description(shortDefinition="The gender of the person")
100 			@OptionalParam(name="gender")
101 			TokenAndListParam theGender, 
102   
103 			@Description(shortDefinition="A person Identifier")
104 			@OptionalParam(name="identifier")
105 			TokenAndListParam theIdentifier, 
106   
107 			@Description(shortDefinition="Any link has this Patient, Person, RelatedPerson or Practitioner reference")
108 			@OptionalParam(name="link", targetTypes={  } )
109 			ReferenceAndListParam theLink, 
110   
111 			@Description(shortDefinition="A portion of name in any name part")
112 			@OptionalParam(name="name")
113 			StringAndListParam theName, 
114   
115 			@Description(shortDefinition="The organization at which this person record is being managed")
116 			@OptionalParam(name="organization", targetTypes={  } )
117 			ReferenceAndListParam theOrganization, 
118   
119 			@Description(shortDefinition="The Person links to this Patient")
120 			@OptionalParam(name="patient", targetTypes={  } )
121 			ReferenceAndListParam thePatient, 
122   
123 			@Description(shortDefinition="A value in a phone contact")
124 			@OptionalParam(name="phone")
125 			TokenAndListParam thePhone, 
126   
127 			@Description(shortDefinition="A portion of name using some kind of phonetic matching algorithm")
128 			@OptionalParam(name="phonetic")
129 			StringAndListParam thePhonetic, 
130   
131 			@Description(shortDefinition="The Person links to this Practitioner")
132 			@OptionalParam(name="practitioner", targetTypes={  } )
133 			ReferenceAndListParam thePractitioner, 
134   
135 			@Description(shortDefinition="The Person links to this RelatedPerson")
136 			@OptionalParam(name="relatedperson", targetTypes={  } )
137 			ReferenceAndListParam theRelatedperson, 
138   
139 			@Description(shortDefinition="The value in any kind of contact")
140 			@OptionalParam(name="telecom")
141 			TokenAndListParam theTelecom, 
142 
143 			@RawParam
144 			Map<String, List<String>> theAdditionalRawParams,
145 
146 			@IncludeParam(reverse=true)
147 			Set<Include> theRevIncludes,
148 			@Description(shortDefinition="Only return resources which were last updated as specified by the given range")
149 			@OptionalParam(name="_lastUpdated")
150 			DateRangeParam theLastUpdated, 
151 
152 			@IncludeParam(allow= {
153 					"Person:link" , 					"Person:organization" , 					"Person:patient" , 					"Person:practitioner" , 					"Person:relatedperson" , 						"Person:link" , 					"Person:organization" , 					"Person:patient" , 					"Person:practitioner" , 					"Person:relatedperson" , 						"Person:link" , 					"Person:organization" , 					"Person:patient" , 					"Person:practitioner" , 					"Person:relatedperson" , 						"Person:link" , 					"Person:organization" , 					"Person:patient" , 					"Person:practitioner" , 					"Person:relatedperson" , 						"Person:link" , 					"Person:organization" , 					"Person:patient" , 					"Person:practitioner" , 					"Person:relatedperson" 					, "*"
154 			}) 
155 			Set<Include> theIncludes,
156 			
157 			@Sort 
158 			SortSpec theSort,
159 			
160 			@ca.uhn.fhir.rest.annotation.Count
161 			Integer theCount
162 	) {
163 		startRequest(theServletRequest);
164 		try {
165 			SearchParameterMap paramMap = new SearchParameterMap();
166 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_CONTENT, theFtContent);
167 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TEXT, theFtText);
168 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TAG, theSearchForTag);
169 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY, theSearchForSecurity);
170 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE, theSearchForProfile);
171 			paramMap.add("_has", theHas);
172 			paramMap.add("_id", the_id);
173 			paramMap.add("_language", the_language);
174 			paramMap.add("address", theAddress);
175 			paramMap.add("address-city", theAddress_city);
176 			paramMap.add("address-country", theAddress_country);
177 			paramMap.add("address-postalcode", theAddress_postalcode);
178 			paramMap.add("address-state", theAddress_state);
179 			paramMap.add("address-use", theAddress_use);
180 			paramMap.add("birthdate", theBirthdate);
181 			paramMap.add("email", theEmail);
182 			paramMap.add("gender", theGender);
183 			paramMap.add("identifier", theIdentifier);
184 			paramMap.add("link", theLink);
185 			paramMap.add("name", theName);
186 			paramMap.add("organization", theOrganization);
187 			paramMap.add("patient", thePatient);
188 			paramMap.add("phone", thePhone);
189 			paramMap.add("phonetic", thePhonetic);
190 			paramMap.add("practitioner", thePractitioner);
191 			paramMap.add("relatedperson", theRelatedperson);
192 			paramMap.add("telecom", theTelecom);
193 			paramMap.setRevIncludes(theRevIncludes);
194 			paramMap.setLastUpdated(theLastUpdated);
195 			paramMap.setIncludes(theIncludes);
196 			paramMap.setSort(theSort);
197 			paramMap.setCount(theCount);
198 
199 			getDao().translateRawParameters(theAdditionalRawParams, paramMap);
200 
201 			ca.uhn.fhir.rest.api.server.IBundleProvider retVal = getDao().search(paramMap, theRequestDetails, theServletResponse);
202 			return retVal;
203 		} finally {
204 			endRequest(theServletRequest);
205 		}
206 	}
207 
208 }