001
002package ca.uhn.fhir.jpa.rp.dstu2;
003
004import java.util.*;
005
006import org.apache.commons.lang3.StringUtils;
007
008import ca.uhn.fhir.jpa.provider.*;
009import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
010import ca.uhn.fhir.model.api.Include;
011import ca.uhn.fhir.model.api.annotation.*;
012import ca.uhn.fhir.model.dstu2.composite.*;
013import ca.uhn.fhir.model.dstu2.resource.*; //
014import ca.uhn.fhir.rest.annotation.*;
015import ca.uhn.fhir.rest.param.*;
016import ca.uhn.fhir.rest.api.SortSpec;
017import ca.uhn.fhir.rest.api.SummaryEnum;
018import ca.uhn.fhir.rest.api.SearchTotalModeEnum;
019import ca.uhn.fhir.rest.api.SearchContainedModeEnum;
020
021public class CommunicationResourceProvider extends 
022        JpaResourceProviderDstu2<Communication>
023        {
024
025        @Override
026        public Class<Communication> getResourceType() {
027                return Communication.class;
028        }
029
030        @Search(allowUnknownParams=true)
031        public ca.uhn.fhir.rest.api.server.IBundleProvider search(
032                        javax.servlet.http.HttpServletRequest theServletRequest,
033                        javax.servlet.http.HttpServletResponse theServletResponse,
034
035                        ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails,
036
037                        @Description(shortDefinition="Search the contents of the resource's data using a filter")
038                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_FILTER)
039                        StringAndListParam theFtFilter,
040
041                        @Description(shortDefinition="Search the contents of the resource's data using a fulltext search")
042                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_CONTENT)
043                        StringAndListParam theFtContent, 
044
045                        @Description(shortDefinition="Search the contents of the resource's narrative using a fulltext search")
046                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_TEXT)
047                        StringAndListParam theFtText, 
048
049                        @Description(shortDefinition="Search for resources which have the given tag")
050                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_TAG)
051                        TokenAndListParam theSearchForTag, 
052
053                        @Description(shortDefinition="Search for resources which have the given security labels")
054                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY)
055                        TokenAndListParam theSearchForSecurity, 
056  
057                        @Description(shortDefinition="Search for resources which have the given profile")
058                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE)
059                        UriAndListParam theSearchForProfile,
060
061                        @Description(shortDefinition="Search for resources which have the given source value (Resource.meta.source)")
062                        @OptionalParam(name=ca.uhn.fhir.rest.api.Constants.PARAM_SOURCE)
063                        UriAndListParam theSearchForSource,
064
065                        @Description(shortDefinition="Return resources linked to by the given target")
066                        @OptionalParam(name="_has")
067                        HasAndListParam theHas, 
068
069   
070
071                        @Description(shortDefinition="The ID of the resource")
072                        @OptionalParam(name="_id")
073                        StringAndListParam the_id, 
074   
075
076                        @Description(shortDefinition="")
077                        @OptionalParam(name="category")
078                        TokenAndListParam theCategory,
079   
080
081                        @Description(shortDefinition="")
082                        @OptionalParam(name="encounter", targetTypes={  } )
083                        ReferenceAndListParam theEncounter, 
084   
085
086                        @Description(shortDefinition="")
087                        @OptionalParam(name="identifier")
088                        TokenAndListParam theIdentifier,
089   
090
091                        @Description(shortDefinition="")
092                        @OptionalParam(name="medium")
093                        TokenAndListParam theMedium,
094   
095
096                        @Description(shortDefinition="")
097                        @OptionalParam(name="patient", targetTypes={  } )
098                        ReferenceAndListParam thePatient, 
099   
100
101                        @Description(shortDefinition="")
102                        @OptionalParam(name="received")
103                        DateRangeParam theReceived, 
104   
105
106                        @Description(shortDefinition="")
107                        @OptionalParam(name="recipient", targetTypes={  } )
108                        ReferenceAndListParam theRecipient, 
109   
110
111                        @Description(shortDefinition="")
112                        @OptionalParam(name="request", targetTypes={  } )
113                        ReferenceAndListParam theRequest, 
114   
115
116                        @Description(shortDefinition="")
117                        @OptionalParam(name="sender", targetTypes={  } )
118                        ReferenceAndListParam theSender, 
119   
120
121                        @Description(shortDefinition="")
122                        @OptionalParam(name="sent")
123                        DateRangeParam theSent, 
124   
125
126                        @Description(shortDefinition="")
127                        @OptionalParam(name="status")
128                        TokenAndListParam theStatus,
129   
130
131                        @Description(shortDefinition="")
132                        @OptionalParam(name="subject", targetTypes={  } )
133                        ReferenceAndListParam theSubject, 
134
135                        @RawParam
136                        Map<String, List<String>> theAdditionalRawParams,
137
138                        @Description(shortDefinition="Only return resources which were last updated as specified by the given range")
139                        @OptionalParam(name="_lastUpdated")
140                        DateRangeParam theLastUpdated, 
141
142                        @IncludeParam
143                        Set<Include> theIncludes,
144
145                        @IncludeParam(reverse=true)
146                        Set<Include> theRevIncludes,
147
148                        @Sort
149                        SortSpec theSort,
150                        
151                        @ca.uhn.fhir.rest.annotation.Count
152                        Integer theCount,
153
154                        @ca.uhn.fhir.rest.annotation.Offset
155                        Integer theOffset,
156
157                        SummaryEnum theSummaryMode,
158
159                        SearchTotalModeEnum theSearchTotalMode,
160
161                        SearchContainedModeEnum theSearchContainedMode
162
163                        ) {
164                startRequest(theServletRequest);
165                try {
166                        SearchParameterMap paramMap = new SearchParameterMap();
167                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_FILTER, theFtFilter);
168                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_CONTENT, theFtContent);
169                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TEXT, theFtText);
170                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TAG, theSearchForTag);
171                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY, theSearchForSecurity);
172                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE, theSearchForProfile);
173                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SOURCE, theSearchForSource);
174                        paramMap.add("_has", theHas);
175                        paramMap.add("_id", the_id);
176                        paramMap.add("category", theCategory);
177                        paramMap.add("encounter", theEncounter);
178                        paramMap.add("identifier", theIdentifier);
179                        paramMap.add("medium", theMedium);
180                        paramMap.add("patient", thePatient);
181                        paramMap.add("received", theReceived);
182                        paramMap.add("recipient", theRecipient);
183                        paramMap.add("request", theRequest);
184                        paramMap.add("sender", theSender);
185                        paramMap.add("sent", theSent);
186                        paramMap.add("status", theStatus);
187                        paramMap.add("subject", theSubject);
188                        paramMap.setRevIncludes(theRevIncludes);
189                        paramMap.setLastUpdated(theLastUpdated);
190                        paramMap.setIncludes(theIncludes);
191                        paramMap.setSort(theSort);
192                        paramMap.setCount(theCount);
193                        paramMap.setOffset(theOffset);
194                        paramMap.setSummaryMode(theSummaryMode);
195                        paramMap.setSearchTotalMode(theSearchTotalMode);
196                        paramMap.setSearchContainedMode(theSearchContainedMode);
197
198                        getDao().translateRawParameters(theAdditionalRawParams, paramMap);
199
200                        ca.uhn.fhir.rest.api.server.IBundleProvider retVal = getDao().search(paramMap, theRequestDetails, theServletResponse);
201                        return retVal;
202                } finally {
203                        endRequest(theServletRequest);
204                }
205        }
206
207}