View Javadoc
1   
2   package ca.uhn.fhir.jpa.rp.r4;
3   
4   import java.util.*;
5   
6   import org.apache.commons.lang3.StringUtils;
7   
8   import ca.uhn.fhir.jpa.provider.r4.*;
9   import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
10  import ca.uhn.fhir.model.api.Include;
11  import ca.uhn.fhir.model.api.annotation.*;
12  import org.hl7.fhir.r4.model.*;
13  import ca.uhn.fhir.rest.annotation.*;
14  import ca.uhn.fhir.rest.param.*;
15  import ca.uhn.fhir.rest.api.SortSpec;
16  import ca.uhn.fhir.rest.api.SummaryEnum;
17  import ca.uhn.fhir.rest.api.SearchTotalModeEnum;
18  
19  public class DeviceResourceProvider extends 
20  	JpaResourceProviderR4<Device>
21  	{
22  
23  	@Override
24  	public Class<Device> getResourceType() {
25  		return Device.class;
26  	}
27  
28  	@Search(allowUnknownParams=true)
29  	public ca.uhn.fhir.rest.api.server.IBundleProvider search(
30  			javax.servlet.http.HttpServletRequest theServletRequest,
31  			javax.servlet.http.HttpServletResponse theServletResponse,
32  
33  			ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails,
34  
35  			@Description(shortDefinition="Search the contents of the resource's data using a filter")
36  			@OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_FILTER)
37  			StringAndListParam theFtFilter,
38  
39  			@Description(shortDefinition="Search the contents of the resource's data using a fulltext search")
40  			@OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_CONTENT)
41  			StringAndListParam theFtContent, 
42  
43  			@Description(shortDefinition="Search the contents of the resource's narrative using a fulltext search")
44  			@OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_TEXT)
45  			StringAndListParam theFtText, 
46  
47  			@Description(shortDefinition="Search for resources which have the given tag")
48  			@OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_TAG)
49  			TokenAndListParam theSearchForTag, 
50  
51  			@Description(shortDefinition="Search for resources which have the given security labels")
52  			@OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY)
53  			TokenAndListParam theSearchForSecurity, 
54    
55  			@Description(shortDefinition="Search for resources which have the given profile")
56  			@OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE)
57  			UriAndListParam theSearchForProfile, 
58  
59  			@Description(shortDefinition="Return resources linked to by the given target")
60  			@OptionalParam(name="_has")
61  			HasAndListParam theHas, 
62  
63    
64  			@Description(shortDefinition="The ID of the resource")
65  			@OptionalParam(name="_id")
66  			TokenAndListParam the_id,
67    
68  			@Description(shortDefinition="The language of the resource")
69  			@OptionalParam(name="_language")
70  			StringAndListParam the_language, 
71    
72  			@Description(shortDefinition="A server defined search that may match any of the string fields in Device.deviceName or Device.type.")
73  			@OptionalParam(name="device-name")
74  			StringAndListParam theDevice_name, 
75    
76  			@Description(shortDefinition="Instance id from manufacturer, owner, and others")
77  			@OptionalParam(name="identifier")
78  			TokenAndListParam theIdentifier,
79    
80  			@Description(shortDefinition="A location, where the resource is found")
81  			@OptionalParam(name="location", targetTypes={  } )
82  			ReferenceAndListParam theLocation, 
83    
84  			@Description(shortDefinition="The manufacturer of the device")
85  			@OptionalParam(name="manufacturer")
86  			StringAndListParam theManufacturer, 
87    
88  			@Description(shortDefinition="The model of the device")
89  			@OptionalParam(name="model")
90  			StringAndListParam theModel, 
91    
92  			@Description(shortDefinition="The organization responsible for the device")
93  			@OptionalParam(name="organization", targetTypes={  } )
94  			ReferenceAndListParam theOrganization, 
95    
96  			@Description(shortDefinition="Patient information, if the resource is affixed to a person")
97  			@OptionalParam(name="patient", targetTypes={  } )
98  			ReferenceAndListParam thePatient, 
99    
100 			@Description(shortDefinition="active | inactive | entered-in-error | unknown")
101 			@OptionalParam(name="status")
102 			TokenAndListParam theStatus,
103   
104 			@Description(shortDefinition="The type of the device")
105 			@OptionalParam(name="type")
106 			TokenAndListParam theType,
107   
108 			@Description(shortDefinition="UDI Barcode (RFID or other technology) string in *HRF* format.")
109 			@OptionalParam(name="udi-carrier")
110 			StringAndListParam theUdi_carrier, 
111   
112 			@Description(shortDefinition="The udi Device Identifier (DI)")
113 			@OptionalParam(name="udi-di")
114 			StringAndListParam theUdi_di, 
115   
116 			@Description(shortDefinition="Network address to contact device")
117 			@OptionalParam(name="url")
118 			UriAndListParam theUrl, 
119 
120 			@RawParam
121 			Map<String, List<String>> theAdditionalRawParams,
122 
123 			@IncludeParam(reverse=true)
124 			Set<Include> theRevIncludes,
125 			@Description(shortDefinition="Only return resources which were last updated as specified by the given range")
126 			@OptionalParam(name="_lastUpdated")
127 			DateRangeParam theLastUpdated, 
128 
129 			@IncludeParam(allow= {
130 					"Device:location" , 					"Device:organization" , 					"Device:patient" , 						"Device:location" , 					"Device:organization" , 					"Device:patient" , 						"Device:location" , 					"Device:organization" , 					"Device:patient" 					, "*"
131 			}) 
132 			Set<Include> theIncludes,
133 			
134 			@Sort 
135 			SortSpec theSort,
136 			
137 			@ca.uhn.fhir.rest.annotation.Count
138 			Integer theCount,
139 
140 			SummaryEnum theSummaryMode,
141 
142 			SearchTotalModeEnum theSearchTotalMode
143 
144 			) {
145 		startRequest(theServletRequest);
146 		try {
147 			SearchParameterMap paramMap = new SearchParameterMap();
148 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_FILTER, theFtFilter);
149 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_CONTENT, theFtContent);
150 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TEXT, theFtText);
151 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TAG, theSearchForTag);
152 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY, theSearchForSecurity);
153 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE, theSearchForProfile);
154 			paramMap.add("_has", theHas);
155 			paramMap.add("_id", the_id);
156 			paramMap.add("_language", the_language);
157 			paramMap.add("device-name", theDevice_name);
158 			paramMap.add("identifier", theIdentifier);
159 			paramMap.add("location", theLocation);
160 			paramMap.add("manufacturer", theManufacturer);
161 			paramMap.add("model", theModel);
162 			paramMap.add("organization", theOrganization);
163 			paramMap.add("patient", thePatient);
164 			paramMap.add("status", theStatus);
165 			paramMap.add("type", theType);
166 			paramMap.add("udi-carrier", theUdi_carrier);
167 			paramMap.add("udi-di", theUdi_di);
168 			paramMap.add("url", theUrl);
169 			paramMap.setRevIncludes(theRevIncludes);
170 			paramMap.setLastUpdated(theLastUpdated);
171 			paramMap.setIncludes(theIncludes);
172 			paramMap.setSort(theSort);
173 			paramMap.setCount(theCount);
174 			paramMap.setSummaryMode(theSummaryMode);
175 			paramMap.setSearchTotalMode(theSearchTotalMode);
176 
177 			getDao().translateRawParameters(theAdditionalRawParams, paramMap);
178 
179 			ca.uhn.fhir.rest.api.server.IBundleProvider retVal = getDao().search(paramMap, theRequestDetails, theServletResponse);
180 			return retVal;
181 		} finally {
182 			endRequest(theServletRequest);
183 		}
184 	}
185 
186 }