001package ca.uhn.fhir.rest.annotation;
002
003/*
004 * #%L
005 * HAPI FHIR - Core Library
006 * %%
007 * Copyright (C) 2014 - 2016 University Health Network
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 * 
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 * 
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023import java.lang.annotation.Retention;
024import java.lang.annotation.RetentionPolicy;
025
026import org.hl7.fhir.instance.model.api.IBaseResource;
027
028import ca.uhn.fhir.model.api.IQueryParameterType;
029import ca.uhn.fhir.rest.param.CompositeParam;
030import ca.uhn.fhir.rest.param.ReferenceParam;
031//import ca.uhn.fhir.testmodel.Patient; // TODO: qualify this correctly
032
033@Retention(RetentionPolicy.RUNTIME)
034/**
035 * Parameter annotation which specifies a search parameter for a {@link Search} method. 
036 */
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
103}