001
002package ca.uhn.fhir.jpa.rp.r5;
003
004import java.util.*;
005
006import org.apache.commons.lang3.StringUtils;
007
008import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
009import ca.uhn.fhir.model.api.Include;
010import ca.uhn.fhir.model.api.annotation.*;
011import org.hl7.fhir.r5.model.*;
012import ca.uhn.fhir.rest.annotation.*;
013import ca.uhn.fhir.rest.param.*;
014import ca.uhn.fhir.rest.api.SortSpec;
015import ca.uhn.fhir.rest.api.SummaryEnum;
016import ca.uhn.fhir.rest.api.SearchTotalModeEnum;
017import ca.uhn.fhir.rest.api.SearchContainedModeEnum;
018
019public class ResearchStudyResourceProvider extends 
020        ca.uhn.fhir.jpa.provider.BaseJpaResourceProvider<ResearchStudy>
021        {
022
023        @Override
024        public Class<ResearchStudy> getResourceType() {
025                return ResearchStudy.class;
026        }
027
028        @Search(allowUnknownParams=true)
029        public ca.uhn.fhir.rest.api.server.IBundleProvider search(
030                        javax.servlet.http.HttpServletRequest theServletRequest,
031                        javax.servlet.http.HttpServletResponse theServletResponse,
032
033                        ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails,
034
035                        @Description(shortDefinition="Search the contents of the resource's data using a filter")
036                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_FILTER)
037                        StringAndListParam theFtFilter,
038
039                        @Description(shortDefinition="Search the contents of the resource's data using a fulltext search")
040                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_CONTENT)
041                        StringAndListParam theFtContent, 
042
043                        @Description(shortDefinition="Search the contents of the resource's narrative using a fulltext search")
044                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_TEXT)
045                        StringAndListParam theFtText, 
046
047                        @Description(shortDefinition="Search for resources which have the given tag")
048                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_TAG)
049                        TokenAndListParam theSearchForTag, 
050
051                        @Description(shortDefinition="Search for resources which have the given security labels")
052                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY)
053                        TokenAndListParam theSearchForSecurity, 
054  
055                        @Description(shortDefinition="Search for resources which have the given profile")
056                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE)
057                        UriAndListParam theSearchForProfile,
058
059                        @Description(shortDefinition="Search for resources which have the given source value (Resource.meta.source)")
060                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_SOURCE)
061                        UriAndListParam theSearchForSource,
062
063                        @Description(shortDefinition="Return resources linked to by the given target")
064                        @OptionalParam(name="_has")
065                        HasAndListParam theHas, 
066
067   
068
069                        @Description(shortDefinition="The ID of the resource")
070                        @OptionalParam(name="_id")
071                        TokenAndListParam the_id,
072   
073
074                        @Description(shortDefinition="Search on the narrative of the resource")
075                        @OptionalParam(name="_text")
076                        SpecialAndListParam the_text,
077   
078
079                        @Description(shortDefinition="Classification for the study")
080                        @OptionalParam(name="classifier")
081                        TokenAndListParam theClassifier,
082   
083
084                        @Description(shortDefinition="Condition being studied")
085                        @OptionalParam(name="condition")
086                        TokenAndListParam theCondition,
087   
088
089                        @Description(shortDefinition="When the study began and ended")
090                        @OptionalParam(name="date")
091                        DateRangeParam theDate, 
092   
093
094                        @Description(shortDefinition="Detailed narrative of the study")
095                        @OptionalParam(name="description")
096                        StringAndListParam theDescription, 
097   
098
099                        @Description(shortDefinition="Inclusion and exclusion criteria")
100                        @OptionalParam(name="eligibility", targetTypes={  } )
101                        ReferenceAndListParam theEligibility, 
102   
103
104                        @Description(shortDefinition="Drugs, devices, etc. under study, as a code")
105                        @OptionalParam(name="focus-code")
106                        TokenAndListParam theFocus_code,
107   
108
109                        @Description(shortDefinition="Drugs, devices, etc. under study, as a reference")
110                        @OptionalParam(name="focus-reference", targetTypes={  } )
111                        ReferenceAndListParam theFocus_reference, 
112   
113
114                        @Description(shortDefinition="Business Identifier for study")
115                        @OptionalParam(name="identifier")
116                        TokenAndListParam theIdentifier,
117   
118
119                        @Description(shortDefinition="Used to search for the study")
120                        @OptionalParam(name="keyword")
121                        TokenAndListParam theKeyword,
122   
123
124                        @Description(shortDefinition="Name for this study")
125                        @OptionalParam(name="name")
126                        StringAndListParam theName, 
127   
128
129                        @Description(shortDefinition="Free text description of the objective of the study")
130                        @OptionalParam(name="objective-description")
131                        StringAndListParam theObjective_description, 
132   
133
134                        @Description(shortDefinition="The kind of study objective")
135                        @OptionalParam(name="objective-type")
136                        TokenAndListParam theObjective_type,
137   
138
139                        @Description(shortDefinition="Part of larger study")
140                        @OptionalParam(name="part-of", targetTypes={  } )
141                        ReferenceAndListParam thePart_of, 
142   
143
144                        @Description(shortDefinition="The stage in the progression of a study")
145                        @OptionalParam(name="phase")
146                        TokenAndListParam thePhase,
147   
148
149                        @Description(shortDefinition="Steps followed in executing study")
150                        @OptionalParam(name="protocol", targetTypes={  } )
151                        ReferenceAndListParam theProtocol, 
152   
153
154                        @Description(shortDefinition="Actual number of participants enrolled in study across all groups")
155                        @OptionalParam(name="recruitment-actual")
156                        NumberAndListParam theRecruitment_actual, 
157   
158
159                        @Description(shortDefinition="Target number of participants enrolled in study across all groups")
160                        @OptionalParam(name="recruitment-target")
161                        NumberAndListParam theRecruitment_target, 
162   
163
164                        @Description(shortDefinition="Geographic area for the study")
165                        @OptionalParam(name="region")
166                        TokenAndListParam theRegion,
167   
168
169                        @Description(shortDefinition="Facility where study activities are conducted")
170                        @OptionalParam(name="site", targetTypes={  } )
171                        ReferenceAndListParam theSite, 
172   
173
174                        @Description(shortDefinition="active | active-but-not-recruiting | administratively-completed | approved | closed-to-accrual | closed-to-accrual-and-intervention | completed | disapproved | enrolling-by-invitation | in-review | not-yet-recruiting | recruiting | temporarily-closed-to-accrual | temporarily-closed-to-accrual-and-intervention | terminated | withdrawn")
175                        @OptionalParam(name="status")
176                        TokenAndListParam theStatus,
177   
178
179                        @Description(shortDefinition="Classifications of the study design characteristics")
180                        @OptionalParam(name="study-design")
181                        TokenAndListParam theStudy_design,
182   
183
184                        @Description(shortDefinition="The human readable name of the research study")
185                        @OptionalParam(name="title")
186                        StringAndListParam theTitle, 
187
188                        @RawParam
189                        Map<String, List<String>> theAdditionalRawParams,
190
191                        @Description(shortDefinition="Only return resources which were last updated as specified by the given range")
192                        @OptionalParam(name="_lastUpdated")
193                        DateRangeParam theLastUpdated, 
194
195                        @IncludeParam
196                        Set<Include> theIncludes,
197
198                        @IncludeParam(reverse=true)
199                        Set<Include> theRevIncludes,
200
201                        @Sort
202                        SortSpec theSort,
203                        
204                        @ca.uhn.fhir.rest.annotation.Count
205                        Integer theCount,
206
207                        @ca.uhn.fhir.rest.annotation.Offset
208                        Integer theOffset,
209
210                        SummaryEnum theSummaryMode,
211
212                        SearchTotalModeEnum theSearchTotalMode,
213
214                        SearchContainedModeEnum theSearchContainedMode
215
216                        ) {
217                startRequest(theServletRequest);
218                try {
219                        SearchParameterMap paramMap = new SearchParameterMap();
220                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_FILTER, theFtFilter);
221                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_CONTENT, theFtContent);
222                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TEXT, theFtText);
223                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TAG, theSearchForTag);
224                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY, theSearchForSecurity);
225                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE, theSearchForProfile);
226                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SOURCE, theSearchForSource);
227                        paramMap.add("_has", theHas);
228                        paramMap.add("_id", the_id);
229                        paramMap.add("_text", the_text);
230                        paramMap.add("classifier", theClassifier);
231                        paramMap.add("condition", theCondition);
232                        paramMap.add("date", theDate);
233                        paramMap.add("description", theDescription);
234                        paramMap.add("eligibility", theEligibility);
235                        paramMap.add("focus-code", theFocus_code);
236                        paramMap.add("focus-reference", theFocus_reference);
237                        paramMap.add("identifier", theIdentifier);
238                        paramMap.add("keyword", theKeyword);
239                        paramMap.add("name", theName);
240                        paramMap.add("objective-description", theObjective_description);
241                        paramMap.add("objective-type", theObjective_type);
242                        paramMap.add("part-of", thePart_of);
243                        paramMap.add("phase", thePhase);
244                        paramMap.add("protocol", theProtocol);
245                        paramMap.add("recruitment-actual", theRecruitment_actual);
246                        paramMap.add("recruitment-target", theRecruitment_target);
247                        paramMap.add("region", theRegion);
248                        paramMap.add("site", theSite);
249                        paramMap.add("status", theStatus);
250                        paramMap.add("study-design", theStudy_design);
251                        paramMap.add("title", theTitle);
252                        paramMap.setRevIncludes(theRevIncludes);
253                        paramMap.setLastUpdated(theLastUpdated);
254                        paramMap.setIncludes(theIncludes);
255                        paramMap.setSort(theSort);
256                        paramMap.setCount(theCount);
257                        paramMap.setOffset(theOffset);
258                        paramMap.setSummaryMode(theSummaryMode);
259                        paramMap.setSearchTotalMode(theSearchTotalMode);
260                        paramMap.setSearchContainedMode(theSearchContainedMode);
261
262                        getDao().translateRawParameters(theAdditionalRawParams, paramMap);
263
264                        ca.uhn.fhir.rest.api.server.IBundleProvider retVal = getDao().search(paramMap, theRequestDetails, theServletResponse);
265                        return retVal;
266                } finally {
267                        endRequest(theServletRequest);
268                }
269        }
270
271}