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 - 2019 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 */ 076 @Deprecated 077 IQuery<Y> limitTo(int theLimitTo); 078 079 /** 080 * Request that the client return the specified bundle type, e.g. <code>org.hl7.fhir.dstu2.model.Bundle.class</code> 081 * or <code>ca.uhn.fhir.model.dstu2.resource.Bundle.class</code> 082 */ 083 <B extends IBaseBundle> IQuery<B> returnBundle(Class<B> theClass); 084 085 /** 086 * Request that the server modify the response using the <code>_total</code> param 087 * 088 * THIS IS AN EXPERIMENTAL FEATURE - Use with caution, as it may be 089 * removed or modified in a future version. 090 */ 091 IQuery<Y> totalMode(SearchTotalModeEnum theTotalMode); 092 093 /** 094 * Add a "_revinclude" specification 095 * 096 * @since HAPI FHIR 1.0 - Note that option was added to FHIR itself in DSTU2 097 */ 098 IQuery<Y> revInclude(Include theIncludeTarget); 099 100 /** 101 * Adds a sort criteria 102 * 103 * @see #sort(SortSpec) for an alternate way of speciyfing sorts 104 */ 105 ISort<Y> sort(); 106 107 /** 108 * Adds a sort using a {@link SortSpec} object 109 * 110 * @see #sort() for an alternate way of speciyfing sorts 111 */ 112 IQuery<Y> sort(SortSpec theSortSpec); 113 114 /** 115 * Forces the query to perform the search using the given method (allowable methods are described in the 116 * <a href="http://www.hl7.org/fhir/search.html">FHIR Search Specification</a>) 117 * <p> 118 * This can be used to force the use of an HTTP POST instead of an HTTP GET 119 * </p> 120 * 121 * @see SearchStyleEnum 122 * @since 0.6 123 */ 124 IQuery<Y> usingStyle(SearchStyleEnum theStyle); 125 126 /** 127 * {@inheritDoc} 128 */ 129 // This is here as an overridden method to allow mocking clients with Mockito to work 130 @Override 131 IQuery<Y> where(ICriterion<?> theCriterion); 132 133 /** 134 * Matches any of the profiles given as argument. This would result in an OR search for resources matching one or more profiles. 135 * To do an AND search, make multiple calls to {@link #withProfile(String)}. 136 * 137 * @param theProfileUris The URIs of a given profile to search for resources which match. 138 */ 139 IQuery<Y> withAnyProfile(Collection<String> theProfileUris); 140 141 IQuery<Y> withIdAndCompartment(String theResourceId, String theCompartmentName); 142 143 /** 144 * Match only resources where the resource has the given profile declaration. This parameter corresponds to 145 * the <code>_profile</code> URL parameter. 146 * 147 * @param theProfileUri The URI of a given profile to search for resources which match 148 */ 149 IQuery<Y> withProfile(String theProfileUri); 150 151 /** 152 * Match only resources where the resource has the given security tag. This parameter corresponds to 153 * the <code>_security</code> URL parameter. 154 * 155 * @param theSystem The tag code system, or <code>null</code> to match any code system (this may not be supported on all servers) 156 * @param theCode The tag code. Must not be <code>null</code> or empty. 157 */ 158 IQuery<Y> withSecurity(String theSystem, String theCode); 159 160 /** 161 * Match only resources where the resource has the given tag. This parameter corresponds to 162 * the <code>_tag</code> URL parameter. 163 * 164 * @param theSystem The tag code system, or <code>null</code> to match any code system (this may not be supported on all servers) 165 * @param theCode The tag code. Must not be <code>null</code> or empty. 166 */ 167 IQuery<Y> withTag(String theSystem, String theCode); 168 169// Y execute(); 170 171}