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