001/*- 002 * #%L 003 * HAPI FHIR - Core Library 004 * %% 005 * Copyright (C) 2014 - 2024 Smile CDR, Inc. 006 * %% 007 * Licensed under the Apache License, Version 2.0 (the "License"); 008 * you may not use this file except in compliance with the License. 009 * You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 * #L% 019 */ 020package ca.uhn.fhir.rest.client.api; 021 022import ca.uhn.fhir.model.primitive.IdDt; 023import ca.uhn.fhir.model.primitive.UriDt; 024import ca.uhn.fhir.rest.api.MethodOutcome; 025import ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException; 026import ca.uhn.fhir.rest.client.exceptions.FhirClientInappropriateForServerException; 027import ca.uhn.fhir.rest.gclient.ICreate; 028import ca.uhn.fhir.rest.gclient.IDelete; 029import ca.uhn.fhir.rest.gclient.IFetchConformanceUntyped; 030import ca.uhn.fhir.rest.gclient.IGetPage; 031import ca.uhn.fhir.rest.gclient.IHistory; 032import ca.uhn.fhir.rest.gclient.IMeta; 033import ca.uhn.fhir.rest.gclient.IOperation; 034import ca.uhn.fhir.rest.gclient.IPatch; 035import ca.uhn.fhir.rest.gclient.IRead; 036import ca.uhn.fhir.rest.gclient.ITransaction; 037import ca.uhn.fhir.rest.gclient.IUntypedQuery; 038import ca.uhn.fhir.rest.gclient.IUpdate; 039import ca.uhn.fhir.rest.gclient.IValidate; 040import org.hl7.fhir.instance.model.api.IBaseBundle; 041import org.hl7.fhir.instance.model.api.IBaseResource; 042 043public interface IGenericClient extends IRestfulClient { 044 045 /** 046 * Fetch the capability statement for the server 047 */ 048 IFetchConformanceUntyped capabilities(); 049 050 /** 051 * Fluent method for the "create" operation, which creates a new resource instance on the server 052 */ 053 ICreate create(); 054 055 /** 056 * Fluent method for the "delete" operation, which performs a logical delete on a server resource 057 */ 058 IDelete delete(); 059 060 /** 061 * Retrieves the server's conformance statement 062 * 063 * @deprecated As of HAPI 3.0.0 this method has been deprecated, as the operation is now called "capabilities". Use {@link #capabilities()} instead 064 */ 065 IFetchConformanceUntyped fetchConformance(); 066 067 /** 068 * Force the client to fetch the server's conformance statement and validate that it is appropriate for this client. 069 * 070 * @throws FhirClientConnectionException 071 * if the conformance statement cannot be read, or if the client 072 * @throws FhirClientInappropriateForServerException 073 * If the conformance statement indicates that the server is inappropriate for this client (e.g. it implements the wrong version of FHIR) 074 */ 075 void forceConformanceCheck() throws FhirClientConnectionException; 076 077 /** 078 * Implementation of the "history" method 079 */ 080 IHistory history(); 081 082 /** 083 * Loads the previous/next bundle of resources from a paged set, using the link specified in the "link type=next" tag within the atom bundle. 084 */ 085 IGetPage loadPage(); 086 087 /** 088 * Fluent method for the "meta" operations, which can be used to get, add and remove tags and other 089 * Meta elements from a resource or across the server. 090 * 091 * @since 1.1 092 */ 093 IMeta meta(); 094 095 /** 096 * Implementation of the FHIR "extended operations" action 097 */ 098 IOperation operation(); 099 100 /** 101 * Fluent method for the "patch" operation, which performs a logical patch on a server resource 102 */ 103 IPatch patch(); 104 105 /** 106 * Fluent method for "read" and "vread" methods. 107 */ 108 IRead read(); 109 110 /** 111 * Implementation of the "instance read" method. 112 * 113 * @param theType 114 * The type of resource to load 115 * @param theId 116 * The ID to load 117 * @return The resource 118 * 119 * @deprecated Use {@link #read() read() fluent method} instead (deprecated in HAPI FHIR 3.0.0) 120 */ 121 @Deprecated 122 <T extends IBaseResource> T read(Class<T> theType, String theId); 123 124 /** 125 * Perform the "read" operation (retrieve the latest version of a resource instance by ID) using an absolute URL. 126 * 127 * @param theType 128 * The resource type that is being retrieved 129 * @param theUrl 130 * The absolute URL, e.g. "http://example.com/fhir/Patient/123" 131 * @return The returned resource from the server 132 * @deprecated Use {@link #read() read() fluent method} instead (deprecated in HAPI FHIR 3.0.0) 133 */ 134 @Deprecated 135 <T extends IBaseResource> T read(Class<T> theType, UriDt theUrl); 136 137 /** 138 * Perform the "read" operation (retrieve the latest version of a resource instance by ID) using an absolute URL. 139 * 140 * @param theUrl 141 * The absolute URL, e.g. "http://example.com/fhir/Patient/123" 142 * @return The returned resource from the server 143 * @deprecated Use {@link #read() read() fluent method} instead (deprecated in HAPI FHIR 3.0.0) 144 */ 145 @Deprecated 146 IBaseResource read(UriDt theUrl); 147 148 /** 149 * Register a new interceptor for this client. An interceptor can be used to add additional logging, or add security headers, or pre-process responses, etc. 150 */ 151 @Override 152 void registerInterceptor(Object theInterceptor); 153 154 /** 155 * Search for resources matching a given set of criteria. Searching is a very powerful 156 * feature in FHIR with many features for specifying exactly what should be seaerched for 157 * and how it should be returned. See the <a href="http://www.hl7.org/fhir/search.html">specification on search</a> 158 * for more information. 159 */ 160 <T extends IBaseBundle> IUntypedQuery<T> search(); 161 162 /** 163 * If set to <code>true</code>, the client will log all requests and all responses. This is probably not a good production setting since it will result in a lot of extra logging, but it can be 164 * useful for troubleshooting. 165 * 166 * @param theLogRequestAndResponse 167 * Should requests and responses be logged 168 * @deprecated Use LoggingInterceptor as a client interceptor registered to your 169 * client instead, as this provides much more fine-grained control over what is logged. This 170 * method will be removed at some point (deprecated in HAPI 1.6 - 2016-06-16) 171 */ 172 @Deprecated 173 void setLogRequestAndResponse(boolean theLogRequestAndResponse); 174 175 /** 176 * Send a transaction (collection of resources) to the server to be executed as a single unit 177 */ 178 ITransaction transaction(); 179 180 /** 181 * Remove an intercaptor that was previously registered using {@link IRestfulClient#registerInterceptor(Object)} 182 */ 183 @Override 184 void unregisterInterceptor(Object theInterceptor); 185 186 /** 187 * Fluent method for the "update" operation, which updates a resource instance on the server 188 */ 189 IUpdate update(); 190 191 /** 192 * Implementation of the "instance update" method. 193 * 194 * @param theId 195 * The ID to update 196 * @param theResource 197 * The new resource body 198 * @return An outcome containing the results and possibly the new version ID 199 * @deprecated Use {@link #update() update() fluent method} instead (deprecated in HAPI FHIR 3.0.0) 200 */ 201 @Deprecated 202 MethodOutcome update(IdDt theId, IBaseResource theResource); 203 204 /** 205 * Implementation of the "instance update" method. 206 * 207 * @param theId 208 * The ID to update 209 * @param theResource 210 * The new resource body 211 * @return An outcome containing the results and possibly the new version ID 212 * @deprecated Use {@link #update() update() fluent method} instead (deprecated in HAPI FHIR 3.0.0) 213 */ 214 @Deprecated 215 MethodOutcome update(String theId, IBaseResource theResource); 216 217 /** 218 * Validate a resource 219 */ 220 IValidate validate(); 221 222 /** 223 * Implementation of the "type validate" method. 224 * 225 * @param theResource 226 * The resource to validate 227 * @return An outcome containing any validation issues 228 * @deprecated Use {@link #validate() validate() fluent method} instead (deprecated in HAPI FHIR 3.0.0) 229 */ 230 @Deprecated 231 MethodOutcome validate(IBaseResource theResource); 232 233 /** 234 * Implementation of the "instance vread" method. Note that this method expects <code>theId</code> to contain a resource ID as well as a version ID, and will fail if it does not. 235 * <p> 236 * Note that if an absolute resource ID is passed in (i.e. a URL containing a protocol and host as well as the resource type and ID) the server base for the client will be ignored, and the URL 237 * passed in will be queried. 238 * </p> 239 * 240 * @param theType 241 * The type of resource to load 242 * @param theId 243 * The ID to load, including the resource ID and the resource version ID. Valid values include "Patient/123/_history/222", or "http://example.com/fhir/Patient/123/_history/222" 244 * @return The resource 245 * @deprecated Use {@link #read() read() fluent method} instead (deprecated in HAPI FHIR 3.0.0) 246 */ 247 @Deprecated 248 <T extends IBaseResource> T vread(Class<T> theType, IdDt theId); 249 250 /** 251 * Implementation of the "instance vread" method. 252 * 253 * @param theType 254 * The type of resource to load 255 * @param theId 256 * The ID to load 257 * @param theVersionId 258 * The version ID 259 * @return The resource 260 * @deprecated Use {@link #read() read() fluent method} instead (deprecated in HAPI FHIR 3.0.0) 261 */ 262 @Deprecated 263 <T extends IBaseResource> T vread(Class<T> theType, String theId, String theVersionId); 264}