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 LocationResourceProvider extends 
19  	JpaResourceProviderDstu2<Location>
20  	{
21  
22  	@Override
23  	public Class<Location> getResourceType() {
24  		return Location.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="A (part of the) address of the location")
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="")
92  			@OptionalParam(name="identifier")
93  			TokenAndListParam theIdentifier, 
94    
95  			@Description(shortDefinition="A (portion of the) name of the location")
96  			@OptionalParam(name="name")
97  			StringAndListParam theName, 
98    
99  			@Description(shortDefinition="The coordinates expressed as [lat],[long] (using the WGS84 datum, see notes) to find locations near to (servers may search using a square rather than a circle for efficiency)")
100 			@OptionalParam(name="near")
101 			TokenAndListParam theNear, 
102   
103 			@Description(shortDefinition="A distance quantity to limit the near search to locations within a specific distance")
104 			@OptionalParam(name="near-distance")
105 			TokenAndListParam theNear_distance, 
106   
107 			@Description(shortDefinition="Searches for locations that are managed by the provided organization")
108 			@OptionalParam(name="organization", targetTypes={  } )
109 			ReferenceAndListParam theOrganization, 
110   
111 			@Description(shortDefinition="The location of which this location is a part")
112 			@OptionalParam(name="partof", targetTypes={  } )
113 			ReferenceAndListParam thePartof, 
114   
115 			@Description(shortDefinition="Searches for locations with a specific kind of status")
116 			@OptionalParam(name="status")
117 			TokenAndListParam theStatus, 
118   
119 			@Description(shortDefinition="A code for the type of location")
120 			@OptionalParam(name="type")
121 			TokenAndListParam theType, 
122 
123 			@RawParam
124 			Map<String, List<String>> theAdditionalRawParams,
125 
126 			@IncludeParam(reverse=true)
127 			Set<Include> theRevIncludes,
128 			@Description(shortDefinition="Only return resources which were last updated as specified by the given range")
129 			@OptionalParam(name="_lastUpdated")
130 			DateRangeParam theLastUpdated, 
131 
132 			@IncludeParam(allow= {
133 					"Location:organization" , 					"Location:partof" , 						"Location:organization" , 					"Location:partof" 					, "*"
134 			}) 
135 			Set<Include> theIncludes,
136 			
137 			@Sort 
138 			SortSpec theSort,
139 			
140 			@ca.uhn.fhir.rest.annotation.Count
141 			Integer theCount
142 	) {
143 		startRequest(theServletRequest);
144 		try {
145 			SearchParameterMap paramMap = new SearchParameterMap();
146 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_CONTENT, theFtContent);
147 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TEXT, theFtText);
148 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TAG, theSearchForTag);
149 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY, theSearchForSecurity);
150 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE, theSearchForProfile);
151 			paramMap.add("_has", theHas);
152 			paramMap.add("_id", the_id);
153 			paramMap.add("_language", the_language);
154 			paramMap.add("address", theAddress);
155 			paramMap.add("address-city", theAddress_city);
156 			paramMap.add("address-country", theAddress_country);
157 			paramMap.add("address-postalcode", theAddress_postalcode);
158 			paramMap.add("address-state", theAddress_state);
159 			paramMap.add("address-use", theAddress_use);
160 			paramMap.add("identifier", theIdentifier);
161 			paramMap.add("name", theName);
162 			paramMap.add("near", theNear);
163 			paramMap.add("near-distance", theNear_distance);
164 			paramMap.add("organization", theOrganization);
165 			paramMap.add("partof", thePartof);
166 			paramMap.add("status", theStatus);
167 			paramMap.add("type", theType);
168 			paramMap.setRevIncludes(theRevIncludes);
169 			paramMap.setLastUpdated(theLastUpdated);
170 			paramMap.setIncludes(theIncludes);
171 			paramMap.setSort(theSort);
172 			paramMap.setCount(theCount);
173 
174 			getDao().translateRawParameters(theAdditionalRawParams, paramMap);
175 
176 			ca.uhn.fhir.rest.api.server.IBundleProvider retVal = getDao().search(paramMap, theRequestDetails, theServletResponse);
177 			return retVal;
178 		} finally {
179 			endRequest(theServletRequest);
180 		}
181 	}
182 
183 }