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