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