001package ca.uhn.fhir.rest.gclient;
002
003import ca.uhn.fhir.model.api.Include;
004import ca.uhn.fhir.rest.api.SearchStyleEnum;
005import ca.uhn.fhir.rest.api.SearchTotalModeEnum;
006import ca.uhn.fhir.rest.api.SortSpec;
007import ca.uhn.fhir.rest.api.SummaryEnum;
008import ca.uhn.fhir.rest.param.DateRangeParam;
009import org.hl7.fhir.instance.model.api.IBaseBundle;
010
011import java.util.Collection;
012import java.util.List;
013import java.util.Map;
014
015/*
016 * #%L
017 * HAPI FHIR - Core Library
018 * %%
019 * Copyright (C) 2014 - 2020 University Health Network
020 * %%
021 * Licensed under the Apache License, Version 2.0 (the "License");
022 * you may not use this file except in compliance with the License.
023 * You may obtain a copy of the License at
024 *
025 *      http://www.apache.org/licenses/LICENSE-2.0
026 *
027 * Unless required by applicable law or agreed to in writing, software
028 * distributed under the License is distributed on an "AS IS" BASIS,
029 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
030 * See the License for the specific language governing permissions and
031 * limitations under the License.
032 * #L%
033 */
034
035public interface IQuery<Y> extends IBaseQuery<IQuery<Y>>, IClientExecutable<IQuery<Y>, Y> {
036
037        /**
038         * {@inheritDoc}
039         */
040        // This is here as an overridden method to allow mocking clients with Mockito to work
041        @Override
042        IQuery<Y> and(ICriterion<?> theCriterion);
043
044        /**
045         * Specifies the <code>_count</code> parameter, which indicates to the server how many resources should be returned
046         * on a single page.
047         *
048         * @since 1.4
049         */
050        IQuery<Y> count(int theCount);
051
052        /**
053         * Add an "_include" specification or an "_include:recurse" specification. If you are using
054         * a constant from one of the built-in structures you can select whether you want recursive
055         * behaviour by using the following syntax:
056         * <ul>
057         * <li><b>Recurse:</b> <code>.include(Patient.INCLUDE_ORGANIZATION.asRecursive())</code>
058         * <li><b>No Recurse:</b> <code>.include(Patient.INCLUDE_ORGANIZATION.asNonRecursive())</code>
059         * </ul>
060         */
061        IQuery<Y> include(Include theInclude);
062
063        /**
064         * Add a "_lastUpdated" specification
065         *
066         * @since HAPI FHIR 1.1 - Note that option was added to FHIR itself in DSTU2
067         */
068        IQuery<Y> lastUpdated(DateRangeParam theLastUpdated);
069
070        /**
071         * Specifies the <code>_count</code> parameter, which indicates to the server how many resources should be returned
072         * on a single page.
073         *
074         * @deprecated This parameter is badly named, since FHIR calls this parameter "_count" and not "_limit". Use {@link #count(int)} instead (it also sets the _count parameter)
075         * @see #count(int)
076         */
077        @Deprecated
078        IQuery<Y> limitTo(int theLimitTo);
079
080        /**
081         * Request that the client return the specified bundle type, e.g. <code>org.hl7.fhir.dstu2.model.Bundle.class</code>
082         * or <code>ca.uhn.fhir.model.dstu2.resource.Bundle.class</code>
083         */
084        <B extends IBaseBundle> IQuery<B> returnBundle(Class<B> theClass);
085
086        /**
087         * Request that the server modify the response using the <code>_total</code> param
088         *
089         * THIS IS AN EXPERIMENTAL FEATURE - Use with caution, as it may be
090         * removed or modified in a future version.
091         */
092        IQuery<Y> totalMode(SearchTotalModeEnum theTotalMode);
093
094        /**
095         * Add a "_revinclude" specification
096         *
097         * @since HAPI FHIR 1.0 - Note that option was added to FHIR itself in DSTU2
098         */
099        IQuery<Y> revInclude(Include theIncludeTarget);
100
101        /**
102         * Adds a sort criteria
103         *
104         * @see #sort(SortSpec) for an alternate way of speciyfing sorts
105         */
106        ISort<Y> sort();
107
108        /**
109         * Adds a sort using a {@link SortSpec} object
110         *
111         * @see #sort() for an alternate way of speciyfing sorts
112         */
113        IQuery<Y> sort(SortSpec theSortSpec);
114
115        /**
116         * Forces the query to perform the search using the given method (allowable methods are described in the
117         * <a href="http://www.hl7.org/fhir/search.html">FHIR Search Specification</a>)
118         * <p>
119         * This can be used to force the use of an HTTP POST instead of an HTTP GET
120         * </p>
121         *
122         * @see SearchStyleEnum
123         * @since 0.6
124         */
125        IQuery<Y> usingStyle(SearchStyleEnum theStyle);
126
127        /**
128         * {@inheritDoc}
129         */
130        // This is here as an overridden method to allow mocking clients with Mockito to work
131        @Override
132        IQuery<Y> where(ICriterion<?> theCriterion);
133
134        /**
135         * Matches any of the profiles given as argument. This would result in an OR search for resources matching one or more profiles.
136         * To do an AND search, make multiple calls to {@link #withProfile(String)}.
137         *
138         * @param theProfileUris The URIs of a given profile to search for resources which match.
139         */
140        IQuery<Y> withAnyProfile(Collection<String> theProfileUris);
141
142        IQuery<Y> withIdAndCompartment(String theResourceId, String theCompartmentName);
143
144        /**
145         * Match only resources where the resource has the given profile declaration. This parameter corresponds to
146         * the <code>_profile</code> URL parameter.
147         *
148         * @param theProfileUri The URI of a given profile to search for resources which match
149         */
150        IQuery<Y> withProfile(String theProfileUri);
151
152        /**
153         * Match only resources where the resource has the given security tag. This parameter corresponds to
154         * the <code>_security</code> URL parameter.
155         *
156         * @param theSystem The tag code system, or <code>null</code> to match any code system (this may not be supported on all servers)
157         * @param theCode   The tag code. Must not be <code>null</code> or empty.
158         */
159        IQuery<Y> withSecurity(String theSystem, String theCode);
160
161        /**
162         * Match only resources where the resource has the given tag. This parameter corresponds to
163         * the <code>_tag</code> URL parameter.
164         *
165         * @param theSystem The tag code system, or <code>null</code> to match any code system (this may not be supported on all servers)
166         * @param theCode   The tag code. Must not be <code>null</code> or empty.
167         */
168        IQuery<Y> withTag(String theSystem, String theCode);
169
170//      Y execute();
171
172}