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