View Javadoc
1   
2   package ca.uhn.fhir.jpa.rp.dstu3;
3   
4   import java.util.*;
5   
6   import org.apache.commons.lang3.StringUtils;
7   
8   import ca.uhn.fhir.jpa.provider.dstu3.*;
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.dstu3.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 AdverseEventResourceProvider extends 
18  	JpaResourceProviderDstu3<AdverseEvent>
19  	{
20  
21  	@Override
22  	public Class<AdverseEvent> getResourceType() {
23  		return AdverseEvent.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="AE | PAE An adverse event is an event that caused harm to a patient,  an adverse reaction is a something that is a subject-specific event that is a result of an exposure to a medication, food, device or environmental substance, a potential adverse event is something that occurred and that could have caused harm to a patient but did not")
67  			@OptionalParam(name="category")
68  			TokenAndListParam theCategory, 
69    
70  			@Description(shortDefinition="When the event occurred")
71  			@OptionalParam(name="date")
72  			DateRangeParam theDate, 
73    
74  			@Description(shortDefinition="Location where adverse event occurred")
75  			@OptionalParam(name="location", targetTypes={  } )
76  			ReferenceAndListParam theLocation, 
77    
78  			@Description(shortDefinition="Adverse Reaction Events linked to exposure to substance")
79  			@OptionalParam(name="reaction", targetTypes={  } )
80  			ReferenceAndListParam theReaction, 
81    
82  			@Description(shortDefinition="Who recorded the adverse event")
83  			@OptionalParam(name="recorder", targetTypes={  } )
84  			ReferenceAndListParam theRecorder, 
85    
86  			@Description(shortDefinition="Mild | Moderate | Severe")
87  			@OptionalParam(name="seriousness")
88  			TokenAndListParam theSeriousness, 
89    
90  			@Description(shortDefinition="AdverseEvent.study")
91  			@OptionalParam(name="study", targetTypes={  } )
92  			ReferenceAndListParam theStudy, 
93    
94  			@Description(shortDefinition="Subject or group impacted by event")
95  			@OptionalParam(name="subject", targetTypes={  } )
96  			ReferenceAndListParam theSubject, 
97    
98  			@Description(shortDefinition="Refers to the specific entity that caused the adverse event")
99  			@OptionalParam(name="substance", targetTypes={  } )
100 			ReferenceAndListParam theSubstance, 
101   
102 			@Description(shortDefinition="actual | potential")
103 			@OptionalParam(name="type")
104 			TokenAndListParam theType, 
105 
106 			@RawParam
107 			Map<String, List<String>> theAdditionalRawParams,
108 
109 			@IncludeParam(reverse=true)
110 			Set<Include> theRevIncludes,
111 			@Description(shortDefinition="Only return resources which were last updated as specified by the given range")
112 			@OptionalParam(name="_lastUpdated")
113 			DateRangeParam theLastUpdated, 
114 
115 			@IncludeParam(allow= {
116 					"AdverseEvent:location" , 					"AdverseEvent:reaction" , 					"AdverseEvent:recorder" , 					"AdverseEvent:study" , 					"AdverseEvent:subject" , 					"AdverseEvent:substance" , 						"AdverseEvent:location" , 					"AdverseEvent:reaction" , 					"AdverseEvent:recorder" , 					"AdverseEvent:study" , 					"AdverseEvent:subject" , 					"AdverseEvent:substance" , 						"AdverseEvent:location" , 					"AdverseEvent:reaction" , 					"AdverseEvent:recorder" , 					"AdverseEvent:study" , 					"AdverseEvent:subject" , 					"AdverseEvent:substance" , 						"AdverseEvent:location" , 					"AdverseEvent:reaction" , 					"AdverseEvent:recorder" , 					"AdverseEvent:study" , 					"AdverseEvent:subject" , 					"AdverseEvent:substance" , 						"AdverseEvent:location" , 					"AdverseEvent:reaction" , 					"AdverseEvent:recorder" , 					"AdverseEvent:study" , 					"AdverseEvent:subject" , 					"AdverseEvent:substance" , 						"AdverseEvent:location" , 					"AdverseEvent:reaction" , 					"AdverseEvent:recorder" , 					"AdverseEvent:study" , 					"AdverseEvent:subject" , 					"AdverseEvent:substance" 					, "*"
117 			}) 
118 			Set<Include> theIncludes,
119 			
120 			@Sort 
121 			SortSpec theSort,
122 			
123 			@ca.uhn.fhir.rest.annotation.Count
124 			Integer theCount
125 	) {
126 		startRequest(theServletRequest);
127 		try {
128 			SearchParameterMap paramMap = new SearchParameterMap();
129 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_CONTENT, theFtContent);
130 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TEXT, theFtText);
131 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TAG, theSearchForTag);
132 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY, theSearchForSecurity);
133 			paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE, theSearchForProfile);
134 			paramMap.add("_has", theHas);
135 			paramMap.add("_id", the_id);
136 			paramMap.add("_language", the_language);
137 			paramMap.add("category", theCategory);
138 			paramMap.add("date", theDate);
139 			paramMap.add("location", theLocation);
140 			paramMap.add("reaction", theReaction);
141 			paramMap.add("recorder", theRecorder);
142 			paramMap.add("seriousness", theSeriousness);
143 			paramMap.add("study", theStudy);
144 			paramMap.add("subject", theSubject);
145 			paramMap.add("substance", theSubstance);
146 			paramMap.add("type", theType);
147 			paramMap.setRevIncludes(theRevIncludes);
148 			paramMap.setLastUpdated(theLastUpdated);
149 			paramMap.setIncludes(theIncludes);
150 			paramMap.setSort(theSort);
151 			paramMap.setCount(theCount);
152 
153 			getDao().translateRawParameters(theAdditionalRawParams, paramMap);
154 
155 			ca.uhn.fhir.rest.api.server.IBundleProvider retVal = getDao().search(paramMap, theRequestDetails, theServletResponse);
156 			return retVal;
157 		} finally {
158 			endRequest(theServletRequest);
159 		}
160 	}
161 
162 }