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 DeviceResourceProvider extends 
19  	JpaResourceProviderDstu2<Device>
20  	{
21  
22  	@Override
23  	public Class<Device> getResourceType() {
24  		return Device.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="Instance id from manufacturer, owner, and others")
68  			@OptionalParam(name="identifier")
69  			TokenAndListParam theIdentifier, 
70    
71  			@Description(shortDefinition="A location, where the resource is found")
72  			@OptionalParam(name="location", targetTypes={  } )
73  			ReferenceAndListParam theLocation, 
74    
75  			@Description(shortDefinition="The manufacturer of the device")
76  			@OptionalParam(name="manufacturer")
77  			StringAndListParam theManufacturer, 
78    
79  			@Description(shortDefinition="The model of the device")
80  			@OptionalParam(name="model")
81  			StringAndListParam theModel, 
82    
83  			@Description(shortDefinition="The organization responsible for the device")
84  			@OptionalParam(name="organization", targetTypes={  } )
85  			ReferenceAndListParam theOrganization, 
86    
87  			@Description(shortDefinition="Patient information, if the resource is affixed to a person")
88  			@OptionalParam(name="patient", targetTypes={  } )
89  			ReferenceAndListParam thePatient, 
90    
91  			@Description(shortDefinition="The type of the device")
92  			@OptionalParam(name="type")
93  			TokenAndListParam theType, 
94    
95  			@Description(shortDefinition="FDA mandated Unique Device Identifier")
96  			@OptionalParam(name="udi")
97  			StringAndListParam theUdi, 
98    
99  			@Description(shortDefinition="Network address to contact device")
100 			@OptionalParam(name="url")
101 			UriAndListParam theUrl, 
102 
103 			@RawParam
104 			Map<String, List<String>> theAdditionalRawParams,
105 
106 			@IncludeParam(reverse=true)
107 			Set<Include> theRevIncludes,
108 			@Description(shortDefinition="Only return resources which were last updated as specified by the given range")
109 			@OptionalParam(name="_lastUpdated")
110 			DateRangeParam theLastUpdated, 
111 
112 			@IncludeParam(allow= {
113 					"Device:location" , 					"Device:organization" , 					"Device:patient" , 						"Device:location" , 					"Device:organization" , 					"Device:patient" , 						"Device:location" , 					"Device:organization" , 					"Device:patient" 					, "*"
114 			}) 
115 			Set<Include> theIncludes,
116 			
117 			@Sort 
118 			SortSpec theSort,
119 			
120 			@ca.uhn.fhir.rest.annotation.Count
121 			Integer theCount
122 	) {
123 		startRequest(theServletRequest);
124 		try {
125 			SearchParameterMap paramMap = new SearchParameterMap();
126 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_CONTENT, theFtContent);
127 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TEXT, theFtText);
128 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TAG, theSearchForTag);
129 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY, theSearchForSecurity);
130 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE, theSearchForProfile);
131 			paramMap.add("_has", theHas);
132 			paramMap.add("_id", the_id);
133 			paramMap.add("_language", the_language);
134 			paramMap.add("identifier", theIdentifier);
135 			paramMap.add("location", theLocation);
136 			paramMap.add("manufacturer", theManufacturer);
137 			paramMap.add("model", theModel);
138 			paramMap.add("organization", theOrganization);
139 			paramMap.add("patient", thePatient);
140 			paramMap.add("type", theType);
141 			paramMap.add("udi", theUdi);
142 			paramMap.add("url", theUrl);
143 			paramMap.setRevIncludes(theRevIncludes);
144 			paramMap.setLastUpdated(theLastUpdated);
145 			paramMap.setIncludes(theIncludes);
146 			paramMap.setSort(theSort);
147 			paramMap.setCount(theCount);
148 
149 			getDao().translateRawParameters(theAdditionalRawParams, paramMap);
150 
151 			ca.uhn.fhir.rest.api.server.IBundleProvider retVal = getDao().search(paramMap, theRequestDetails, theServletResponse);
152 			return retVal;
153 		} finally {
154 			endRequest(theServletRequest);
155 		}
156 	}
157 
158 }