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