001package ca.uhn.fhir.rest.annotation;
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 java.lang.annotation.ElementType;
024import java.lang.annotation.Retention;
025import java.lang.annotation.RetentionPolicy;
026import java.lang.annotation.Target;
027
028import org.hl7.fhir.instance.model.api.IBaseResource;
029
030import ca.uhn.fhir.rest.client.api.IBasicClient;
031import ca.uhn.fhir.rest.client.api.IRestfulClient;
032import ca.uhn.fhir.rest.server.IDynamicSearchResourceProvider;
033import ca.uhn.fhir.rest.server.IResourceProvider;
034
035
036/**
037 * RESTful method annotation used for a method which provides
038 * the FHIR "search" method.
039 * 
040 * See the <a href="http://hl7.org/implement/standards/fhir/http.html#search">FHIR Search</a> definition
041 * for more information.
042 */
043@Retention(RetentionPolicy.RUNTIME)
044@Target(value=ElementType.METHOD)
045public @interface Search {
046        
047        /**
048         * If specified, this the name for the Named Query
049         * 
050         * <p>
051         * See the FHIR specification section on 
052         *      <a href="http://www.hl7.org/implement/standards/fhir/search.html#advanced">named queries</a>
053         * </p>
054         */
055        String queryName() default "";
056
057        /**
058         * If specified, this the name for the compartment
059         * 
060         * <p>
061         * See the FHIR specification section on 
062         *      <a href="http://hl7-fhir.github.io/extras.html#compartments">compartments</a>
063         * </p>
064         */
065        String compartmentName() default "";
066
067        /**
068         * The return type for this method. This generally does not need
069         * to be populated for {@link IResourceProvider resource providers} in a server implementation, 
070         * but often does need to be populated in client implementations using {@link IBasicClient} or
071         * {@link IRestfulClient}, or in plain providers on a server.
072         * <p>
073         * This value also does not need to be populated if the return type for a method annotated with 
074         * this annotation is sufficient to determine the type of resource provided. E.g. if the 
075         * method returns <code>Patient</code> or <code>List&lt;Patient&gt;</code>, the server/client 
076         * will automatically determine that the Patient resource is the return type, and this value
077         * may be left blank. 
078         * </p>
079         */
080        // NB: Read, Search (maybe others) share this annotation method, so update the javadocs everywhere
081        Class<? extends IBaseResource> type() default IBaseResource.class;
082
083        /**
084         * This is an experimental option - Use with caution
085         * 
086         * @see IDynamicSearchResourceProvider
087         */
088        boolean dynamic() default false;
089        
090        /**
091         * In a REST server, should this method be invoked even if it does not have method parameters 
092         * which correspond to all of the URL parameters passed in by the client (default is <code>false</code>).
093         * <p>
094         * Use this method with caution: Methods marked with a value of <code>true</code> will
095         * be greedy, meaning they may handle invocations you had intended to be handled by other
096         * search methods. Such a method may be invoked as long as any method parameters
097         * marked as {@link RequiredParam required} have been satisfied. If there are other methods
098         * which have parameters marked as {@link OptionalParam optional} which would technically be
099         * a better match, either the this method or the other method might be called.
100         * </p>
101         */
102        boolean allowUnknownParams() default false;
103}