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