001package ca.uhn.fhir.rest.annotation;
002
003/*
004 * #%L
005 * HAPI FHIR - Core Library
006 * %%
007 * Copyright (C) 2014 - 2021 Smile CDR, Inc.
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.ElementType;
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.IResource;
031import ca.uhn.fhir.model.primitive.IdDt;
032//import ca.uhn.fhir.testmodel.Patient; // TODO: qualify this correctly
033
034/**
035 * RESTful method annotation to be used for the FHIR
036 * <a href="http://hl7.org/implement/standards/fhir/http.html#history">history</a> method.
037 * 
038 * <p>
039 * History returns a feed containing all versions (or a selected range of versions) of 
040 * a resource or a specific set of resources.
041 * </p>
042 * <p>
043 * The history command supports three usage patterns, as described in the
044 * <a href="http://hl7.org/implement/standards/fhir/http.html#history">FHIR history</a> documentation:
045 * </p>
046 * <ul>
047 * <li>
048 *   A search for the history of all resources on a server. In this case, {@link #type()} 
049 *   should be set to {@link IResource} (as is the default) and the method should not have an ID parameter.
050 *   <ul><li>
051 *      To invoke this pattern: <code>GET [base]/_history{?[parameters]&amp;_format=[mime-type]}</code>
052 *   </li></ul>
053 * </li>
054 * <li>
055 *   A search for the history of all instances of a specific resource type on a server. In this case, {@link #type()} 
056 *   should be set to the specific resource type (e.g. <code>Patient.class</code>) and the method should not have an ID parameter.
057 *   <ul><li>
058 *      To invoke this pattern: <code>GET [base]/[type]/_history{?[parameters]&amp;_format=[mime-type]}</code>
059 *   </li></ul>
060 * </li>
061 * <li>
062 *   A search for the history of a specific instances of a specific resource type on a server. In this case, {@link #type()} 
063 *   should be set to the specific resource type (e.g. <code>Patient.class</code> and the method should 
064 *   have one parameter of type {@link IdDt} annotated with the {@link IdParam} annotation. 
065 *   <ul><li>
066 *      To invoke this pattern: <code>GET [base]/[type]/[id]/_history{?[parameters]&amp;_format=[mime-type]}</code>
067 *   </li></ul>
068 * </li>
069 * </ul>
070 * 
071 * @see Count
072 * @see Since
073 */
074@Retention(RetentionPolicy.RUNTIME)
075@Target(value=ElementType.METHOD)
076public @interface History {
077        
078        /**
079         * The resource type that this method applies to. See the {@link History History annotation type documentation}
080         * for information on usage patterns.  
081         */
082        Class<? extends IBaseResource> type() default IBaseResource.class;
083
084        /**
085         * This method allows the return type for this method to be specified in a
086         * non-type-specific way, using the text name of the resource, e.g. "Patient".
087         *
088         * This attribute should be populate, or {@link #type()} should be, but not both.
089         *
090         * @since 5.4.0
091         */
092        String typeName() default "";
093
094}