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.dao.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  
17  public class ServiceRequestResourceProvider extends 
18  	JpaResourceProviderR4<ServiceRequest>
19  	{
20  
21  	@Override
22  	public Class<ServiceRequest> getResourceType() {
23  		return ServiceRequest.class;
24  	}
25  
26  	@Search(allowUnknownParams=true)
27  	public ca.uhn.fhir.rest.api.server.IBundleProvider search(
28  			javax.servlet.http.HttpServletRequest theServletRequest,
29  			javax.servlet.http.HttpServletResponse theServletResponse,
30  
31  			ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails,
32  			
33  			@Description(shortDefinition="Search the contents of the resource's data using a fulltext search")
34  			@OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_CONTENT)
35  			StringAndListParam theFtContent, 
36  
37  			@Description(shortDefinition="Search the contents of the resource's narrative using a fulltext search")
38  			@OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_TEXT)
39  			StringAndListParam theFtText, 
40  
41  			@Description(shortDefinition="Search for resources which have the given tag")
42  			@OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_TAG)
43  			TokenAndListParam theSearchForTag, 
44  
45  			@Description(shortDefinition="Search for resources which have the given security labels")
46  			@OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY)
47  			TokenAndListParam theSearchForSecurity, 
48    
49  			@Description(shortDefinition="Search for resources which have the given profile")
50  			@OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE)
51  			UriAndListParam theSearchForProfile, 
52  
53  			@Description(shortDefinition="Return resources linked to by the given target")
54  			@OptionalParam(name="_has")
55  			HasAndListParam theHas, 
56  
57    
58  			@Description(shortDefinition="The ID of the resource")
59  			@OptionalParam(name="_id")
60  			TokenAndListParam the_id, 
61    
62  			@Description(shortDefinition="The language of the resource")
63  			@OptionalParam(name="_language")
64  			StringAndListParam the_language, 
65    
66  			@Description(shortDefinition="Date request signed")
67  			@OptionalParam(name="authored")
68  			DateRangeParam theAuthored, 
69    
70  			@Description(shortDefinition="What request fulfills")
71  			@OptionalParam(name="based-on", targetTypes={  } )
72  			ReferenceAndListParam theBased_on, 
73    
74  			@Description(shortDefinition="Where procedure is going to be done")
75  			@OptionalParam(name="body-site")
76  			TokenAndListParam theBody_site, 
77    
78  			@Description(shortDefinition="Classification of service")
79  			@OptionalParam(name="category")
80  			TokenAndListParam theCategory, 
81    
82  			@Description(shortDefinition="What is being requested/ordered")
83  			@OptionalParam(name="code")
84  			TokenAndListParam theCode, 
85    
86  			@Description(shortDefinition="Encounter or Episode during which request was created")
87  			@OptionalParam(name="context", targetTypes={  } )
88  			ReferenceAndListParam theContext, 
89    
90  			@Description(shortDefinition="An encounter in which this request is made")
91  			@OptionalParam(name="encounter", targetTypes={  } )
92  			ReferenceAndListParam theEncounter, 
93    
94  			@Description(shortDefinition="Identifiers assigned to this order")
95  			@OptionalParam(name="identifier")
96  			TokenAndListParam theIdentifier, 
97    
98  			@Description(shortDefinition="Protocol or definition")
99  			@OptionalParam(name="instantiates")
100 			UriAndListParam theInstantiates, 
101   
102 			@Description(shortDefinition="proposal | plan | order +")
103 			@OptionalParam(name="intent")
104 			TokenAndListParam theIntent, 
105   
106 			@Description(shortDefinition="When service should occur")
107 			@OptionalParam(name="occurrence")
108 			DateRangeParam theOccurrence, 
109   
110 			@Description(shortDefinition="Search by subject - a patient")
111 			@OptionalParam(name="patient", targetTypes={  } )
112 			ReferenceAndListParam thePatient, 
113   
114 			@Description(shortDefinition="Requested performer")
115 			@OptionalParam(name="performer", targetTypes={  } )
116 			ReferenceAndListParam thePerformer, 
117   
118 			@Description(shortDefinition="Performer role")
119 			@OptionalParam(name="performer-type")
120 			TokenAndListParam thePerformer_type, 
121   
122 			@Description(shortDefinition="routine | urgent | asap | stat")
123 			@OptionalParam(name="priority")
124 			TokenAndListParam thePriority, 
125   
126 			@Description(shortDefinition="What request replaces")
127 			@OptionalParam(name="replaces", targetTypes={  } )
128 			ReferenceAndListParam theReplaces, 
129   
130 			@Description(shortDefinition="Who/what is requesting service")
131 			@OptionalParam(name="requester", targetTypes={  } )
132 			ReferenceAndListParam theRequester, 
133   
134 			@Description(shortDefinition="Composite Request ID")
135 			@OptionalParam(name="requisition")
136 			TokenAndListParam theRequisition, 
137   
138 			@Description(shortDefinition="Specimen to be tested")
139 			@OptionalParam(name="specimen", targetTypes={  } )
140 			ReferenceAndListParam theSpecimen, 
141   
142 			@Description(shortDefinition="draft | active | suspended | completed | entered-in-error | cancelled")
143 			@OptionalParam(name="status")
144 			TokenAndListParam theStatus, 
145   
146 			@Description(shortDefinition="Search by subject")
147 			@OptionalParam(name="subject", targetTypes={  } )
148 			ReferenceAndListParam theSubject, 
149 
150 			@RawParam
151 			Map<String, List<String>> theAdditionalRawParams,
152 
153 			@IncludeParam(reverse=true)
154 			Set<Include> theRevIncludes,
155 			@Description(shortDefinition="Only return resources which were last updated as specified by the given range")
156 			@OptionalParam(name="_lastUpdated")
157 			DateRangeParam theLastUpdated, 
158 
159 			@IncludeParam(allow= {
160 					"ServiceRequest:based-on" , 					"ServiceRequest:context" , 					"ServiceRequest:encounter" , 					"ServiceRequest:patient" , 					"ServiceRequest:performer" , 					"ServiceRequest:replaces" , 					"ServiceRequest:requester" , 					"ServiceRequest:specimen" , 					"ServiceRequest:subject" , 						"ServiceRequest:based-on" , 					"ServiceRequest:context" , 					"ServiceRequest:encounter" , 					"ServiceRequest:patient" , 					"ServiceRequest:performer" , 					"ServiceRequest:replaces" , 					"ServiceRequest:requester" , 					"ServiceRequest:specimen" , 					"ServiceRequest:subject" , 						"ServiceRequest:based-on" , 					"ServiceRequest:context" , 					"ServiceRequest:encounter" , 					"ServiceRequest:patient" , 					"ServiceRequest:performer" , 					"ServiceRequest:replaces" , 					"ServiceRequest:requester" , 					"ServiceRequest:specimen" , 					"ServiceRequest:subject" , 						"ServiceRequest:based-on" , 					"ServiceRequest:context" , 					"ServiceRequest:encounter" , 					"ServiceRequest:patient" , 					"ServiceRequest:performer" , 					"ServiceRequest:replaces" , 					"ServiceRequest:requester" , 					"ServiceRequest:specimen" , 					"ServiceRequest:subject" , 						"ServiceRequest:based-on" , 					"ServiceRequest:context" , 					"ServiceRequest:encounter" , 					"ServiceRequest:patient" , 					"ServiceRequest:performer" , 					"ServiceRequest:replaces" , 					"ServiceRequest:requester" , 					"ServiceRequest:specimen" , 					"ServiceRequest:subject" , 						"ServiceRequest:based-on" , 					"ServiceRequest:context" , 					"ServiceRequest:encounter" , 					"ServiceRequest:patient" , 					"ServiceRequest:performer" , 					"ServiceRequest:replaces" , 					"ServiceRequest:requester" , 					"ServiceRequest:specimen" , 					"ServiceRequest:subject" , 						"ServiceRequest:based-on" , 					"ServiceRequest:context" , 					"ServiceRequest:encounter" , 					"ServiceRequest:patient" , 					"ServiceRequest:performer" , 					"ServiceRequest:replaces" , 					"ServiceRequest:requester" , 					"ServiceRequest:specimen" , 					"ServiceRequest:subject" , 						"ServiceRequest:based-on" , 					"ServiceRequest:context" , 					"ServiceRequest:encounter" , 					"ServiceRequest:patient" , 					"ServiceRequest:performer" , 					"ServiceRequest:replaces" , 					"ServiceRequest:requester" , 					"ServiceRequest:specimen" , 					"ServiceRequest:subject" , 						"ServiceRequest:based-on" , 					"ServiceRequest:context" , 					"ServiceRequest:encounter" , 					"ServiceRequest:patient" , 					"ServiceRequest:performer" , 					"ServiceRequest:replaces" , 					"ServiceRequest:requester" , 					"ServiceRequest:specimen" , 					"ServiceRequest:subject" 					, "*"
161 			}) 
162 			Set<Include> theIncludes,
163 			
164 			@Sort 
165 			SortSpec theSort,
166 			
167 			@ca.uhn.fhir.rest.annotation.Count
168 			Integer theCount
169 	) {
170 		startRequest(theServletRequest);
171 		try {
172 			SearchParameterMap paramMap = new SearchParameterMap();
173 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_CONTENT, theFtContent);
174 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TEXT, theFtText);
175 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TAG, theSearchForTag);
176 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY, theSearchForSecurity);
177 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE, theSearchForProfile);
178 			paramMap.add("_has", theHas);
179 			paramMap.add("_id", the_id);
180 			paramMap.add("_language", the_language);
181 			paramMap.add("authored", theAuthored);
182 			paramMap.add("based-on", theBased_on);
183 			paramMap.add("body-site", theBody_site);
184 			paramMap.add("category", theCategory);
185 			paramMap.add("code", theCode);
186 			paramMap.add("context", theContext);
187 			paramMap.add("encounter", theEncounter);
188 			paramMap.add("identifier", theIdentifier);
189 			paramMap.add("instantiates", theInstantiates);
190 			paramMap.add("intent", theIntent);
191 			paramMap.add("occurrence", theOccurrence);
192 			paramMap.add("patient", thePatient);
193 			paramMap.add("performer", thePerformer);
194 			paramMap.add("performer-type", thePerformer_type);
195 			paramMap.add("priority", thePriority);
196 			paramMap.add("replaces", theReplaces);
197 			paramMap.add("requester", theRequester);
198 			paramMap.add("requisition", theRequisition);
199 			paramMap.add("specimen", theSpecimen);
200 			paramMap.add("status", theStatus);
201 			paramMap.add("subject", theSubject);
202 			paramMap.setRevIncludes(theRevIncludes);
203 			paramMap.setLastUpdated(theLastUpdated);
204 			paramMap.setIncludes(theIncludes);
205 			paramMap.setSort(theSort);
206 			paramMap.setCount(theCount);
207 
208 			getDao().translateRawParameters(theAdditionalRawParams, paramMap);
209 
210 			ca.uhn.fhir.rest.api.server.IBundleProvider retVal = getDao().search(paramMap, theRequestDetails, theServletResponse);
211 			return retVal;
212 		} finally {
213 			endRequest(theServletRequest);
214 		}
215 	}
216 
217 }