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.model.api.IQueryParameterType; 023import ca.uhn.fhir.rest.param.CompositeParam; 024import ca.uhn.fhir.rest.param.ReferenceParam; 025import org.hl7.fhir.instance.model.api.IBaseResource; 026 027import java.lang.annotation.ElementType; 028import java.lang.annotation.Retention; 029import java.lang.annotation.RetentionPolicy; 030import java.lang.annotation.Target; 031 032/** 033 * Parameter annotation which specifies a search parameter for a {@link Search} method. 034 */ 035@Retention(RetentionPolicy.RUNTIME) 036@Target(value = ElementType.PARAMETER) 037public @interface RequiredParam { 038 039 /** 040 * For reference parameters ({@link ReferenceParam}) this value may be used to indicate which chain values (if any) are <b>not</b> valid for the given parameter. Values here will supercede any 041 * values specified in {@link #chainWhitelist()} 042 * <p> 043 * If the parameter annotated with this annotation is not a {@link ReferenceParam}, this value must not be populated. 044 * </p> 045 */ 046 String[] chainBlacklist() default {}; 047 048 /** 049 * For reference parameters ({@link ReferenceParam}) this value may be 050 * used to indicate which chain values (if any) are valid for the given 051 * parameter. If the list contains the value {@link OptionalParam#ALLOW_CHAIN_ANY}, all values are valid. (this is the default) 052 * If the list contains the value {@link OptionalParam#ALLOW_CHAIN_NOTCHAINED} 053 * then the reference param only supports the empty chain (i.e. the resource 054 * ID). 055 * <p> 056 * Valid values for this parameter include: 057 * </p> 058 * <ul> 059 * <li><code>chainWhitelist={ OptionalParam.ALLOW_CHAIN_NOTCHAINED }</code> - Only allow resource reference (no chaining allowed for this parameter)</li> 060 * <li><code>chainWhitelist={ OptionalParam.ALLOW_CHAIN_ANY }</code> - Allow any chaining at all (including a non chained value, <b>this is the default</b>)</li> 061 * <li><code>chainWhitelist={ "foo", "bar" }</code> - Allow property.foo and property.bar</li> 062 * </ul> 063 * <p> 064 * Any values specified in 065 * {@link #chainBlacklist()} will supercede (have priority over) values 066 * here. 067 * </p> 068 * <p> 069 * If the parameter annotated with this annotation is not a {@link ReferenceParam}, 070 * this value must not be populated. 071 * </p> 072 */ 073 String[] chainWhitelist() default {OptionalParam.ALLOW_CHAIN_ANY}; 074 075 /** 076 * For composite parameters ({@link CompositeParam}) this parameter may be used to indicate the parameter type(s) which may be referenced by this param. 077 * <p> 078 * If the parameter annotated with this annotation is not a {@link CompositeParam}, this value must not be populated. 079 * </p> 080 */ 081 Class<? extends IQueryParameterType>[] compositeTypes() default {}; 082 083 /** 084 * This is the name for the parameter. Generally this should be a simple string (e.g. "name", or "identifier") which will be the name of the URL parameter used to populate this method parameter. 085 * <p> 086 * Most resource model classes have constants which may be used to supply values for this field, e.g. Patient.SP_NAME or Observation.SP_DATE 087 * </p> 088 * <p> 089 * If you wish to specify a parameter for a resource reference which only accepts a specific chained value, it is also valid to supply a chained name here, such as "patient.name". It is 090 * recommended to supply this using constants where possible, e.g. <code>Observation.SP_SUBJECT + '.' + Patient.SP_IDENTIFIER</code> 091 * </p> 092 */ 093 String name(); 094 095 /** 096 * For resource reference parameters ({@link ReferenceParam}) this parameter may be used to indicate the resource type(s) which may be referenced by this param. 097 * <p> 098 * If the parameter annotated with this annotation is not a {@link ReferenceParam}, this value must not be populated. 099 * </p> 100 */ 101 Class<? extends IBaseResource>[] targetTypes() default {}; 102}