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 RelatedPersonResourceProvider extends 
022        JpaResourceProviderDstu2<RelatedPerson>
023        {
024
025        @Override
026        public Class<RelatedPerson> getResourceType() {
027                return RelatedPerson.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="An address in any kind of address/part")
077                        @OptionalParam(name="address")
078                        StringAndListParam theAddress, 
079   
080
081                        @Description(shortDefinition="A city specified in an address")
082                        @OptionalParam(name="address-city")
083                        StringAndListParam theAddress_city, 
084   
085
086                        @Description(shortDefinition="A country specified in an address")
087                        @OptionalParam(name="address-country")
088                        StringAndListParam theAddress_country, 
089   
090
091                        @Description(shortDefinition="A postal code specified in an address")
092                        @OptionalParam(name="address-postalcode")
093                        StringAndListParam theAddress_postalcode, 
094   
095
096                        @Description(shortDefinition="A state specified in an address")
097                        @OptionalParam(name="address-state")
098                        StringAndListParam theAddress_state, 
099   
100
101                        @Description(shortDefinition="A use code specified in an address")
102                        @OptionalParam(name="address-use")
103                        TokenAndListParam theAddress_use,
104   
105
106                        @Description(shortDefinition="The Related Person's date of birth")
107                        @OptionalParam(name="birthdate")
108                        DateRangeParam theBirthdate, 
109   
110
111                        @Description(shortDefinition="A value in an email contact")
112                        @OptionalParam(name="email")
113                        TokenAndListParam theEmail,
114   
115
116                        @Description(shortDefinition="Gender of the person")
117                        @OptionalParam(name="gender")
118                        TokenAndListParam theGender,
119   
120
121                        @Description(shortDefinition="A patient Identifier")
122                        @OptionalParam(name="identifier")
123                        TokenAndListParam theIdentifier,
124   
125
126                        @Description(shortDefinition="A portion of name in any name part")
127                        @OptionalParam(name="name")
128                        StringAndListParam theName, 
129   
130
131                        @Description(shortDefinition="The patient this person is related to")
132                        @OptionalParam(name="patient", targetTypes={  } )
133                        ReferenceAndListParam thePatient, 
134   
135
136                        @Description(shortDefinition="A value in a phone contact")
137                        @OptionalParam(name="phone")
138                        TokenAndListParam thePhone,
139   
140
141                        @Description(shortDefinition="A portion of name using some kind of phonetic matching algorithm")
142                        @OptionalParam(name="phonetic")
143                        StringAndListParam thePhonetic, 
144   
145
146                        @Description(shortDefinition="The value in any kind of contact")
147                        @OptionalParam(name="telecom")
148                        TokenAndListParam theTelecom,
149
150                        @RawParam
151                        Map<String, List<String>> theAdditionalRawParams,
152
153                        @Description(shortDefinition="Only return resources which were last updated as specified by the given range")
154                        @OptionalParam(name="_lastUpdated")
155                        DateRangeParam theLastUpdated, 
156
157                        @IncludeParam
158                        Set<Include> theIncludes,
159
160                        @IncludeParam(reverse=true)
161                        Set<Include> theRevIncludes,
162
163                        @Sort
164                        SortSpec theSort,
165                        
166                        @ca.uhn.fhir.rest.annotation.Count
167                        Integer theCount,
168
169                        @ca.uhn.fhir.rest.annotation.Offset
170                        Integer theOffset,
171
172                        SummaryEnum theSummaryMode,
173
174                        SearchTotalModeEnum theSearchTotalMode,
175
176                        SearchContainedModeEnum theSearchContainedMode
177
178                        ) {
179                startRequest(theServletRequest);
180                try {
181                        SearchParameterMap paramMap = new SearchParameterMap();
182                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_FILTER, theFtFilter);
183                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_CONTENT, theFtContent);
184                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TEXT, theFtText);
185                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_TAG, theSearchForTag);
186                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SECURITY, theSearchForSecurity);
187                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_PROFILE, theSearchForProfile);
188                        paramMap.add(ca.uhn.fhir.rest.api.Constants.PARAM_SOURCE, theSearchForSource);
189                        paramMap.add("_has", theHas);
190                        paramMap.add("_id", the_id);
191                        paramMap.add("address", theAddress);
192                        paramMap.add("address-city", theAddress_city);
193                        paramMap.add("address-country", theAddress_country);
194                        paramMap.add("address-postalcode", theAddress_postalcode);
195                        paramMap.add("address-state", theAddress_state);
196                        paramMap.add("address-use", theAddress_use);
197                        paramMap.add("birthdate", theBirthdate);
198                        paramMap.add("email", theEmail);
199                        paramMap.add("gender", theGender);
200                        paramMap.add("identifier", theIdentifier);
201                        paramMap.add("name", theName);
202                        paramMap.add("patient", thePatient);
203                        paramMap.add("phone", thePhone);
204                        paramMap.add("phonetic", thePhonetic);
205                        paramMap.add("telecom", theTelecom);
206                        paramMap.setRevIncludes(theRevIncludes);
207                        paramMap.setLastUpdated(theLastUpdated);
208                        paramMap.setIncludes(theIncludes);
209                        paramMap.setSort(theSort);
210                        paramMap.setCount(theCount);
211                        paramMap.setOffset(theOffset);
212                        paramMap.setSummaryMode(theSummaryMode);
213                        paramMap.setSearchTotalMode(theSearchTotalMode);
214                        paramMap.setSearchContainedMode(theSearchContainedMode);
215
216                        getDao().translateRawParameters(theAdditionalRawParams, paramMap);
217
218                        ca.uhn.fhir.rest.api.server.IBundleProvider retVal = getDao().search(paramMap, theRequestDetails, theServletResponse);
219                        return retVal;
220                } finally {
221                        endRequest(theServletRequest);
222                }
223        }
224
225}