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