001/* 002 * #%L 003 * HAPI FHIR - Core Library 004 * %% 005 * Copyright (C) 2014 - 2023 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 java.lang.annotation.ElementType; 023import java.lang.annotation.Retention; 024import java.lang.annotation.RetentionPolicy; 025import java.lang.annotation.Target; 026 027import org.hl7.fhir.instance.model.api.IBaseResource; 028 029import ca.uhn.fhir.rest.client.api.IBasicClient; 030import ca.uhn.fhir.rest.client.api.IRestfulClient; 031 032 033/** 034 * RESTful method annotation used for a method which provides 035 * the FHIR "search" method. 036 * 037 * See the <a href="http://hl7.org/implement/standards/fhir/http.html#search">FHIR Search</a> definition 038 * for more information. 039 */ 040@Retention(RetentionPolicy.RUNTIME) 041@Target(value=ElementType.METHOD) 042public @interface Search { 043 044 /** 045 * If specified, this the name for the Named Query 046 * 047 * <p> 048 * See the FHIR specification section on 049 * <a href="http://www.hl7.org/implement/standards/fhir/search.html#advanced">named queries</a> 050 * </p> 051 */ 052 String queryName() default ""; 053 054 /** 055 * If specified, this the name for the compartment 056 * 057 * <p> 058 * See the FHIR specification section on 059 * <a href="http://hl7-fhir.github.io/extras.html#compartments">compartments</a> 060 * </p> 061 */ 062 String compartmentName() default ""; 063 064 /** 065 * The return type for this method. This generally does not need 066 * to be populated for IResourceProvider instances in a server implementation, 067 * but often does need to be populated in client implementations using {@link IBasicClient} or 068 * {@link IRestfulClient}, or in plain providers on a server. 069 * <p> 070 * This value also does not need to be populated if the return type for a method annotated with 071 * this annotation is sufficient to determine the type of resource provided. E.g. if the 072 * method returns <code>Patient</code> or <code>List<Patient></code>, the server/client 073 * will automatically determine that the Patient resource is the return type, and this value 074 * may be left blank. 075 * </p> 076 */ 077 // NB: Read, Search (maybe others) share this annotation method, so update the javadocs everywhere 078 Class<? extends IBaseResource> type() default IBaseResource.class; 079 080 /** 081 * This method allows the return type for this method to be specified in a 082 * non-type-specific way, using the text name of the resource, e.g. "Patient". 083 * 084 * This attribute should be populate, or {@link #type()} should be, but not both. 085 * 086 * @since 5.4.0 087 */ 088 String typeName() default ""; 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 104}