View Javadoc
1   package ca.uhn.fhir.rest.annotation;
2   
3   /*
4    * #%L
5    * HAPI FHIR - Core Library
6    * %%
7    * Copyright (C) 2014 - 2018 University Health Network
8    * %%
9    * Licensed under the Apache License, Version 2.0 (the "License");
10   * you may not use this file except in compliance with the License.
11   * You may obtain a copy of the License at
12   * 
13   *      http://www.apache.org/licenses/LICENSE-2.0
14   * 
15   * Unless required by applicable law or agreed to in writing, software
16   * distributed under the License is distributed on an "AS IS" BASIS,
17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   * See the License for the specific language governing permissions and
19   * limitations under the License.
20   * #L%
21   */
22  
23  import java.lang.annotation.ElementType;
24  import java.lang.annotation.Retention;
25  import java.lang.annotation.RetentionPolicy;
26  import java.lang.annotation.Target;
27  
28  import org.hl7.fhir.instance.model.api.IBaseResource;
29  
30  import ca.uhn.fhir.rest.client.api.IBasicClient;
31  import ca.uhn.fhir.rest.client.api.IRestfulClient;
32  
33  
34  /**
35   * RESTful method annotation used for a method which provides
36   * the FHIR "search" method.
37   * 
38   * See the <a href="http://hl7.org/implement/standards/fhir/http.html#search">FHIR Search</a> definition
39   * for more information.
40   */
41  @Retention(RetentionPolicy.RUNTIME)
42  @Target(value=ElementType.METHOD)
43  public @interface Search {
44  	
45  	/**
46  	 * If specified, this the name for the Named Query
47  	 * 
48  	 * <p>
49  	 * See the FHIR specification section on 
50  	 * 	<a href="http://www.hl7.org/implement/standards/fhir/search.html#advanced">named queries</a>
51  	 * </p>
52  	 */
53  	String queryName() default "";
54  
55  	/**
56  	 * If specified, this the name for the compartment
57  	 * 
58  	 * <p>
59  	 * See the FHIR specification section on 
60  	 * 	<a href="http://hl7-fhir.github.io/extras.html#compartments">compartments</a>
61  	 * </p>
62  	 */
63  	String compartmentName() default "";
64  
65  	/**
66  	 * The return type for this method. This generally does not need
67  	 * to be populated for IResourceProvider instances in a server implementation, 
68  	 * but often does need to be populated in client implementations using {@link IBasicClient} or
69  	 * {@link IRestfulClient}, or in plain providers on a server.
70  	 * <p>
71  	 * This value also does not need to be populated if the return type for a method annotated with 
72  	 * this annotation is sufficient to determine the type of resource provided. E.g. if the 
73  	 * method returns <code>Patient</code> or <code>List&lt;Patient&gt;</code>, the server/client 
74  	 * will automatically determine that the Patient resource is the return type, and this value
75  	 * may be left blank. 
76  	 * </p>
77  	 */
78  	// NB: Read, Search (maybe others) share this annotation method, so update the javadocs everywhere
79  	Class<? extends IBaseResource> type() default IBaseResource.class;
80  
81  	/**
82  	 * This is an experimental option - Use with caution
83  	 */
84  	boolean dynamic() default false;
85  	
86  	/**
87  	 * In a REST server, should this method be invoked even if it does not have method parameters 
88  	 * which correspond to all of the URL parameters passed in by the client (default is <code>false</code>).
89  	 * <p>
90  	 * Use this method with caution: Methods marked with a value of <code>true</code> will
91  	 * be greedy, meaning they may handle invocations you had intended to be handled by other
92  	 * search methods. Such a method may be invoked as long as any method parameters
93  	 * marked as {@link RequiredParam required} have been satisfied. If there are other methods
94  	 * which have parameters marked as {@link OptionalParam optional} which would technically be
95  	 * a better match, either the this method or the other method might be called.
96  	 * </p>
97  	 */
98  	boolean allowUnknownParams() default false;
99  }