001
002package ca.uhn.fhir.jpa.rp.r4;
003
004import java.util.*;
005
006import org.apache.commons.lang3.StringUtils;
007
008import ca.uhn.fhir.jpa.provider.r4.*;
009import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
010import ca.uhn.fhir.model.api.Include;
011import ca.uhn.fhir.model.api.annotation.*;
012import org.hl7.fhir.r4.model.*;
013import ca.uhn.fhir.rest.annotation.*;
014import ca.uhn.fhir.rest.param.*;
015import ca.uhn.fhir.rest.api.SortSpec;
016import ca.uhn.fhir.rest.api.SummaryEnum;
017import ca.uhn.fhir.rest.api.SearchTotalModeEnum;
018import ca.uhn.fhir.rest.api.SearchContainedModeEnum;
019
020public class AuditEventResourceProvider extends 
021        JpaResourceProviderR4<AuditEvent>
022        {
023
024        @Override
025        public Class<AuditEvent> getResourceType() {
026                return AuditEvent.class;
027        }
028
029        @Search(allowUnknownParams=true)
030        public ca.uhn.fhir.rest.api.server.IBundleProvider search(
031                        javax.servlet.http.HttpServletRequest theServletRequest,
032                        javax.servlet.http.HttpServletResponse theServletResponse,
033
034                        ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails,
035
036                        @Description(shortDefinition="Search the contents of the resource's data using a filter")
037                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_FILTER)
038                        StringAndListParam theFtFilter,
039
040                        @Description(shortDefinition="Search the contents of the resource's data using a fulltext search")
041                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_CONTENT)
042                        StringAndListParam theFtContent, 
043
044                        @Description(shortDefinition="Search the contents of the resource's narrative using a fulltext search")
045                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_TEXT)
046                        StringAndListParam theFtText, 
047
048                        @Description(shortDefinition="Search for resources which have the given tag")
049                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_TAG)
050                        TokenAndListParam theSearchForTag, 
051
052                        @Description(shortDefinition="Search for resources which have the given security labels")
053                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY)
054                        TokenAndListParam theSearchForSecurity, 
055  
056                        @Description(shortDefinition="Search for resources which have the given profile")
057                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE)
058                        UriAndListParam theSearchForProfile,
059
060                        @Description(shortDefinition="Search for resources which have the given source value (Resource.meta.source)")
061                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_SOURCE)
062                        UriAndListParam theSearchForSource,
063
064                        @Description(shortDefinition="Return resources linked to by the given target")
065                        @OptionalParam(name="_has")
066                        HasAndListParam theHas, 
067
068   
069
070                        @Description(shortDefinition="The ID of the resource")
071                        @OptionalParam(name="_id")
072                        TokenAndListParam the_id,
073   
074
075                        @Description(shortDefinition="Type of action performed during the event")
076                        @OptionalParam(name="action")
077                        TokenAndListParam theAction,
078   
079
080                        @Description(shortDefinition="Identifier for the network access point of the user device")
081                        @OptionalParam(name="address")
082                        StringAndListParam theAddress, 
083   
084
085                        @Description(shortDefinition="Identifier of who")
086                        @OptionalParam(name="agent", targetTypes={  } )
087                        ReferenceAndListParam theAgent, 
088   
089
090                        @Description(shortDefinition="Human friendly name for the agent")
091                        @OptionalParam(name="agent-name")
092                        StringAndListParam theAgent_name, 
093   
094
095                        @Description(shortDefinition="Agent role in the event")
096                        @OptionalParam(name="agent-role")
097                        TokenAndListParam theAgent_role,
098   
099
100                        @Description(shortDefinition="Alternative User identity")
101                        @OptionalParam(name="altid")
102                        TokenAndListParam theAltid,
103   
104
105                        @Description(shortDefinition="Time when the event was recorded")
106                        @OptionalParam(name="date")
107                        DateRangeParam theDate, 
108   
109
110                        @Description(shortDefinition="Specific instance of resource")
111                        @OptionalParam(name="entity", targetTypes={  } )
112                        ReferenceAndListParam theEntity, 
113   
114
115                        @Description(shortDefinition="Descriptor for entity")
116                        @OptionalParam(name="entity-name")
117                        StringAndListParam theEntity_name, 
118   
119
120                        @Description(shortDefinition="What role the entity played")
121                        @OptionalParam(name="entity-role")
122                        TokenAndListParam theEntity_role,
123   
124
125                        @Description(shortDefinition="Type of entity involved")
126                        @OptionalParam(name="entity-type")
127                        TokenAndListParam theEntity_type,
128   
129
130                        @Description(shortDefinition="Whether the event succeeded or failed")
131                        @OptionalParam(name="outcome")
132                        TokenAndListParam theOutcome,
133   
134
135                        @Description(shortDefinition="Identifier of who")
136                        @OptionalParam(name="patient", targetTypes={  } )
137                        ReferenceAndListParam thePatient, 
138   
139
140                        @Description(shortDefinition="Policy that authorized event")
141                        @OptionalParam(name="policy")
142                        UriAndListParam thePolicy, 
143   
144
145                        @Description(shortDefinition="Logical source location within the enterprise")
146                        @OptionalParam(name="site")
147                        TokenAndListParam theSite,
148   
149
150                        @Description(shortDefinition="The identity of source detecting the event")
151                        @OptionalParam(name="source", targetTypes={  } )
152                        ReferenceAndListParam theSource, 
153   
154
155                        @Description(shortDefinition="More specific type/id for the event")
156                        @OptionalParam(name="subtype")
157                        TokenAndListParam theSubtype,
158   
159
160                        @Description(shortDefinition="Type/identifier of event")
161                        @OptionalParam(name="type")
162                        TokenAndListParam theType,
163
164                        @RawParam
165                        Map<String, List<String>> theAdditionalRawParams,
166
167                        @Description(shortDefinition="Only return resources which were last updated as specified by the given range")
168                        @OptionalParam(name="_lastUpdated")
169                        DateRangeParam theLastUpdated, 
170
171                        @IncludeParam
172                        Set<Include> theIncludes,
173
174                        @IncludeParam(reverse=true)
175                        Set<Include> theRevIncludes,
176
177                        @Sort
178                        SortSpec theSort,
179                        
180                        @ca.uhn.fhir.rest.annotation.Count
181                        Integer theCount,
182
183                        @ca.uhn.fhir.rest.annotation.Offset
184                        Integer theOffset,
185
186                        SummaryEnum theSummaryMode,
187
188                        SearchTotalModeEnum theSearchTotalMode,
189
190                        SearchContainedModeEnum theSearchContainedMode
191
192                        ) {
193                startRequest(theServletRequest);
194                try {
195                        SearchParameterMap paramMap = new SearchParameterMap();
196                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_FILTER, theFtFilter);
197                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_CONTENT, theFtContent);
198                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TEXT, theFtText);
199                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TAG, theSearchForTag);
200                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY, theSearchForSecurity);
201                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE, theSearchForProfile);
202                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SOURCE, theSearchForSource);
203                        paramMap.add("_has", theHas);
204                        paramMap.add("_id", the_id);
205                        paramMap.add("action", theAction);
206                        paramMap.add("address", theAddress);
207                        paramMap.add("agent", theAgent);
208                        paramMap.add("agent-name", theAgent_name);
209                        paramMap.add("agent-role", theAgent_role);
210                        paramMap.add("altid", theAltid);
211                        paramMap.add("date", theDate);
212                        paramMap.add("entity", theEntity);
213                        paramMap.add("entity-name", theEntity_name);
214                        paramMap.add("entity-role", theEntity_role);
215                        paramMap.add("entity-type", theEntity_type);
216                        paramMap.add("outcome", theOutcome);
217                        paramMap.add("patient", thePatient);
218                        paramMap.add("policy", thePolicy);
219                        paramMap.add("site", theSite);
220                        paramMap.add("source", theSource);
221                        paramMap.add("subtype", theSubtype);
222                        paramMap.add("type", theType);
223                        paramMap.setRevIncludes(theRevIncludes);
224                        paramMap.setLastUpdated(theLastUpdated);
225                        paramMap.setIncludes(theIncludes);
226                        paramMap.setSort(theSort);
227                        paramMap.setCount(theCount);
228                        paramMap.setOffset(theOffset);
229                        paramMap.setSummaryMode(theSummaryMode);
230                        paramMap.setSearchTotalMode(theSearchTotalMode);
231                        paramMap.setSearchContainedMode(theSearchContainedMode);
232
233                        getDao().translateRawParameters(theAdditionalRawParams, paramMap);
234
235                        ca.uhn.fhir.rest.api.server.IBundleProvider retVal = getDao().search(paramMap, theRequestDetails, theServletResponse);
236                        return retVal;
237                } finally {
238                        endRequest(theServletRequest);
239                }
240        }
241
242}