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 DocumentReferenceResourceProvider extends 
021        JpaResourceProviderR4<DocumentReference>
022        {
023
024        @Override
025        public Class<DocumentReference> getResourceType() {
026                return DocumentReference.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="Who/what authenticated the document")
076                        @OptionalParam(name="authenticator", targetTypes={  } )
077                        ReferenceAndListParam theAuthenticator, 
078   
079
080                        @Description(shortDefinition="Who and/or what authored the document")
081                        @OptionalParam(name="author", targetTypes={  } )
082                        ReferenceAndListParam theAuthor, 
083   
084
085                        @Description(shortDefinition="Categorization of document")
086                        @OptionalParam(name="category")
087                        TokenAndListParam theCategory,
088   
089
090                        @Description(shortDefinition="Mime type of the content, with charset etc.")
091                        @OptionalParam(name="contenttype")
092                        TokenAndListParam theContenttype,
093   
094
095                        @Description(shortDefinition="Organization which maintains the document")
096                        @OptionalParam(name="custodian", targetTypes={  } )
097                        ReferenceAndListParam theCustodian, 
098   
099
100                        @Description(shortDefinition="When this document reference was created")
101                        @OptionalParam(name="date")
102                        DateRangeParam theDate, 
103   
104
105                        @Description(shortDefinition="Human-readable description")
106                        @OptionalParam(name="description")
107                        StringAndListParam theDescription, 
108   
109
110                        @Description(shortDefinition="Context of the document  content")
111                        @OptionalParam(name="encounter", targetTypes={  } )
112                        ReferenceAndListParam theEncounter, 
113   
114
115                        @Description(shortDefinition="Main clinical acts documented")
116                        @OptionalParam(name="event")
117                        TokenAndListParam theEvent,
118   
119
120                        @Description(shortDefinition="Kind of facility where patient was seen")
121                        @OptionalParam(name="facility")
122                        TokenAndListParam theFacility,
123   
124
125                        @Description(shortDefinition="Format/content rules for the document")
126                        @OptionalParam(name="format")
127                        TokenAndListParam theFormat,
128   
129
130                        @Description(shortDefinition="Master Version Specific Identifier")
131                        @OptionalParam(name="identifier")
132                        TokenAndListParam theIdentifier,
133   
134
135                        @Description(shortDefinition="Human language of the content (BCP-47)")
136                        @OptionalParam(name="language")
137                        TokenAndListParam theLanguage,
138   
139
140                        @Description(shortDefinition="Uri where the data can be found")
141                        @OptionalParam(name="location")
142                        UriAndListParam theLocation, 
143   
144
145                        @Description(shortDefinition="Who/what is the subject of the document")
146                        @OptionalParam(name="patient", targetTypes={  } )
147                        ReferenceAndListParam thePatient, 
148   
149
150                        @Description(shortDefinition="Time of service that is being documented")
151                        @OptionalParam(name="period")
152                        DateRangeParam thePeriod, 
153   
154
155                        @Description(shortDefinition="Related identifiers or resources")
156                        @OptionalParam(name="related", targetTypes={  } )
157                        ReferenceAndListParam theRelated, 
158   
159
160                        @Description(shortDefinition="Target of the relationship")
161                        @OptionalParam(name="relatesto", targetTypes={  } )
162                        ReferenceAndListParam theRelatesto, 
163   
164
165                        @Description(shortDefinition="replaces | transforms | signs | appends")
166                        @OptionalParam(name="relation")
167                        TokenAndListParam theRelation,
168   
169
170                        @Description(shortDefinition="Combination of relation and relatesTo")
171                        @OptionalParam(name="relationship", compositeTypes= { ReferenceParam.class, TokenParam.class })
172                        CompositeAndListParam<ReferenceParam, TokenParam> theRelationship,
173   
174
175                        @Description(shortDefinition="Document security-tags")
176                        @OptionalParam(name="security-label")
177                        TokenAndListParam theSecurity_label,
178   
179
180                        @Description(shortDefinition="Additional details about where the content was created (e.g. clinical specialty)")
181                        @OptionalParam(name="setting")
182                        TokenAndListParam theSetting,
183   
184
185                        @Description(shortDefinition="current | superseded | entered-in-error")
186                        @OptionalParam(name="status")
187                        TokenAndListParam theStatus,
188   
189
190                        @Description(shortDefinition="Who/what is the subject of the document")
191                        @OptionalParam(name="subject", targetTypes={  } )
192                        ReferenceAndListParam theSubject, 
193   
194
195                        @Description(shortDefinition="Kind of document (LOINC if possible)")
196                        @OptionalParam(name="type")
197                        TokenAndListParam theType,
198
199                        @RawParam
200                        Map<String, List<String>> theAdditionalRawParams,
201
202                        @Description(shortDefinition="Only return resources which were last updated as specified by the given range")
203                        @OptionalParam(name="_lastUpdated")
204                        DateRangeParam theLastUpdated, 
205
206                        @IncludeParam
207                        Set<Include> theIncludes,
208
209                        @IncludeParam(reverse=true)
210                        Set<Include> theRevIncludes,
211
212                        @Sort
213                        SortSpec theSort,
214                        
215                        @ca.uhn.fhir.rest.annotation.Count
216                        Integer theCount,
217
218                        @ca.uhn.fhir.rest.annotation.Offset
219                        Integer theOffset,
220
221                        SummaryEnum theSummaryMode,
222
223                        SearchTotalModeEnum theSearchTotalMode,
224
225                        SearchContainedModeEnum theSearchContainedMode
226
227                        ) {
228                startRequest(theServletRequest);
229                try {
230                        SearchParameterMap paramMap = new SearchParameterMap();
231                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_FILTER, theFtFilter);
232                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_CONTENT, theFtContent);
233                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TEXT, theFtText);
234                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TAG, theSearchForTag);
235                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY, theSearchForSecurity);
236                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE, theSearchForProfile);
237                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SOURCE, theSearchForSource);
238                        paramMap.add("_has", theHas);
239                        paramMap.add("_id", the_id);
240                        paramMap.add("authenticator", theAuthenticator);
241                        paramMap.add("author", theAuthor);
242                        paramMap.add("category", theCategory);
243                        paramMap.add("contenttype", theContenttype);
244                        paramMap.add("custodian", theCustodian);
245                        paramMap.add("date", theDate);
246                        paramMap.add("description", theDescription);
247                        paramMap.add("encounter", theEncounter);
248                        paramMap.add("event", theEvent);
249                        paramMap.add("facility", theFacility);
250                        paramMap.add("format", theFormat);
251                        paramMap.add("identifier", theIdentifier);
252                        paramMap.add("language", theLanguage);
253                        paramMap.add("location", theLocation);
254                        paramMap.add("patient", thePatient);
255                        paramMap.add("period", thePeriod);
256                        paramMap.add("related", theRelated);
257                        paramMap.add("relatesto", theRelatesto);
258                        paramMap.add("relation", theRelation);
259                        paramMap.add("relationship", theRelationship);
260                        paramMap.add("security-label", theSecurity_label);
261                        paramMap.add("setting", theSetting);
262                        paramMap.add("status", theStatus);
263                        paramMap.add("subject", theSubject);
264                        paramMap.add("type", theType);
265                        paramMap.setRevIncludes(theRevIncludes);
266                        paramMap.setLastUpdated(theLastUpdated);
267                        paramMap.setIncludes(theIncludes);
268                        paramMap.setSort(theSort);
269                        paramMap.setCount(theCount);
270                        paramMap.setOffset(theOffset);
271                        paramMap.setSummaryMode(theSummaryMode);
272                        paramMap.setSearchTotalMode(theSearchTotalMode);
273                        paramMap.setSearchContainedMode(theSearchContainedMode);
274
275                        getDao().translateRawParameters(theAdditionalRawParams, paramMap);
276
277                        ca.uhn.fhir.rest.api.server.IBundleProvider retVal = getDao().search(paramMap, theRequestDetails, theServletResponse);
278                        return retVal;
279                } finally {
280                        endRequest(theServletRequest);
281                }
282        }
283
284}