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 BundleResourceProvider extends 
20  	JpaResourceProviderR4<Bundle>
21  	{
22  
23  	@Override
24  	public Class<Bundle> getResourceType() {
25  		return Bundle.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="The first resource in the bundle, if the bundle type is \"document\" - this is a composition, and this parameter provides access to search its contents")
73  			@OptionalParam(name="composition", targetTypes={  } )
74  			ReferenceAndListParam theComposition, 
75    
76  			@Description(shortDefinition="Persistent identifier for the bundle")
77  			@OptionalParam(name="identifier")
78  			TokenAndListParam theIdentifier,
79    
80  			@Description(shortDefinition="The first resource in the bundle, if the bundle type is \"message\" - this is a message header, and this parameter provides access to search its contents")
81  			@OptionalParam(name="message", targetTypes={  } )
82  			ReferenceAndListParam theMessage, 
83    
84  			@Description(shortDefinition="When the bundle was assembled")
85  			@OptionalParam(name="timestamp")
86  			DateRangeParam theTimestamp, 
87    
88  			@Description(shortDefinition="document | message | transaction | transaction-response | batch | batch-response | history | searchset | collection")
89  			@OptionalParam(name="type")
90  			TokenAndListParam theType,
91  
92  			@RawParam
93  			Map<String, List<String>> theAdditionalRawParams,
94  
95  			@IncludeParam(reverse=true)
96  			Set<Include> theRevIncludes,
97  			@Description(shortDefinition="Only return resources which were last updated as specified by the given range")
98  			@OptionalParam(name="_lastUpdated")
99  			DateRangeParam theLastUpdated, 
100 
101 			@IncludeParam(allow= {
102 					"Bundle:composition" , 					"Bundle:message" , 						"Bundle:composition" , 					"Bundle:message" 					, "*"
103 			}) 
104 			Set<Include> theIncludes,
105 			
106 			@Sort 
107 			SortSpec theSort,
108 			
109 			@ca.uhn.fhir.rest.annotation.Count
110 			Integer theCount,
111 
112 			SummaryEnum theSummaryMode,
113 
114 			SearchTotalModeEnum theSearchTotalMode
115 
116 			) {
117 		startRequest(theServletRequest);
118 		try {
119 			SearchParameterMap paramMap = new SearchParameterMap();
120 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_FILTER, theFtFilter);
121 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_CONTENT, theFtContent);
122 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TEXT, theFtText);
123 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TAG, theSearchForTag);
124 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY, theSearchForSecurity);
125 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE, theSearchForProfile);
126 			paramMap.add("_has", theHas);
127 			paramMap.add("_id", the_id);
128 			paramMap.add("_language", the_language);
129 			paramMap.add("composition", theComposition);
130 			paramMap.add("identifier", theIdentifier);
131 			paramMap.add("message", theMessage);
132 			paramMap.add("timestamp", theTimestamp);
133 			paramMap.add("type", theType);
134 			paramMap.setRevIncludes(theRevIncludes);
135 			paramMap.setLastUpdated(theLastUpdated);
136 			paramMap.setIncludes(theIncludes);
137 			paramMap.setSort(theSort);
138 			paramMap.setCount(theCount);
139 			paramMap.setSummaryMode(theSummaryMode);
140 			paramMap.setSearchTotalMode(theSearchTotalMode);
141 
142 			getDao().translateRawParameters(theAdditionalRawParams, paramMap);
143 
144 			ca.uhn.fhir.rest.api.server.IBundleProvider retVal = getDao().search(paramMap, theRequestDetails, theServletResponse);
145 			return retVal;
146 		} finally {
147 			endRequest(theServletRequest);
148 		}
149 	}
150 
151 }