001package ca.uhn.fhir.rest.annotation; 002 003import java.lang.annotation.ElementType; 004 005/* 006 * #%L 007 * HAPI FHIR - Core Library 008 * %% 009 * Copyright (C) 2014 - 2021 Smile CDR, Inc. 010 * %% 011 * Licensed under the Apache License, Version 2.0 (the "License"); 012 * you may not use this file except in compliance with the License. 013 * You may obtain a copy of the License at 014 * 015 * http://www.apache.org/licenses/LICENSE-2.0 016 * 017 * Unless required by applicable law or agreed to in writing, software 018 * distributed under the License is distributed on an "AS IS" BASIS, 019 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 020 * See the License for the specific language governing permissions and 021 * limitations under the License. 022 * #L% 023 */ 024 025import java.lang.annotation.Retention; 026import java.lang.annotation.RetentionPolicy; 027import java.lang.annotation.Target; 028 029import org.hl7.fhir.instance.model.api.IBaseResource; 030 031import ca.uhn.fhir.model.api.IQueryParameterType; 032import ca.uhn.fhir.rest.param.CompositeParam; 033import ca.uhn.fhir.rest.param.ReferenceParam; 034 035/** 036 * Parameter annotation which specifies a search parameter for a {@link Search} method. 037 */ 038@Retention(RetentionPolicy.RUNTIME) 039@Target(value=ElementType.PARAMETER) 040public @interface RequiredParam { 041 042 /** 043 * 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 044 * values specified in {@link #chainWhitelist()} 045 * <p> 046 * If the parameter annotated with this annotation is not a {@link ReferenceParam}, this value must not be populated. 047 * </p> 048 */ 049 String[] chainBlacklist() default {}; 050 051 /** 052 * For reference parameters ({@link ReferenceParam}) this value may be 053 * used to indicate which chain values (if any) are valid for the given 054 * parameter. If the list contains the value {@link OptionalParam#ALLOW_CHAIN_ANY}, all values are valid. (this is the default) 055 * If the list contains the value {@link OptionalParam#ALLOW_CHAIN_NOTCHAINED} 056 * then the reference param only supports the empty chain (i.e. the resource 057 * ID). 058 * <p> 059 * Valid values for this parameter include: 060 * </p> 061 * <ul> 062 * <li><code>chainWhitelist={ OptionalParam.ALLOW_CHAIN_NOTCHAINED }</code> - Only allow resource reference (no chaining allowed for this parameter)</li> 063 * <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> 064 * <li><code>chainWhitelist={ "foo", "bar" }</code> - Allow property.foo and property.bar</li> 065 * </ul> 066 * <p> 067 * Any values specified in 068 * {@link #chainBlacklist()} will supercede (have priority over) values 069 * here. 070 * </p> 071 * <p> 072 * If the parameter annotated with this annotation is not a {@link ReferenceParam}, 073 * this value must not be populated. 074 * </p> 075 */ 076 String[] chainWhitelist() default { OptionalParam.ALLOW_CHAIN_ANY }; 077 078 /** 079 * For composite parameters ({@link CompositeParam}) this parameter may be used to indicate the parameter type(s) which may be referenced by this param. 080 * <p> 081 * If the parameter annotated with this annotation is not a {@link CompositeParam}, this value must not be populated. 082 * </p> 083 */ 084 Class<? extends IQueryParameterType>[] compositeTypes() default {}; 085 086 /** 087 * 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. 088 * <p> 089 * 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 090 * </p> 091 * <p> 092 * 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 093 * recommended to supply this using constants where possible, e.g. <code>Observation.SP_SUBJECT + '.' + Patient.SP_IDENTIFIER</code> 094 * </p> 095 */ 096 String name(); 097 098 /** 099 * For resource reference parameters ({@link ReferenceParam}) this parameter may be used to indicate the resource type(s) which may be referenced by this param. 100 * <p> 101 * If the parameter annotated with this annotation is not a {@link ReferenceParam}, this value must not be populated. 102 * </p> 103 */ 104 Class<? extends IBaseResource>[] targetTypes() default {}; 105 106}