View Javadoc
1   package ca.uhn.fhir.model.api;
2   
3   import org.hl7.fhir.instance.model.api.IBaseMetaType;
4   
5   /*
6    * #%L
7    * HAPI FHIR - Core Library
8    * %%
9    * Copyright (C) 2014 - 2018 University Health Network
10   * %%
11   * Licensed under the Apache License, Version 2.0 (the "License");
12   * you may not use this file except in compliance with the License.
13   * You may obtain a copy of the License at
14   * 
15   *      http://www.apache.org/licenses/LICENSE-2.0
16   * 
17   * Unless required by applicable law or agreed to in writing, software
18   * distributed under the License is distributed on an "AS IS" BASIS,
19   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20   * See the License for the specific language governing permissions and
21   * limitations under the License.
22   * #L%
23   */
24  
25  import ca.uhn.fhir.model.api.annotation.ResourceDef;
26  import ca.uhn.fhir.model.base.composite.BaseContainedDt;
27  import ca.uhn.fhir.model.base.composite.BaseNarrativeDt;
28  import ca.uhn.fhir.model.base.resource.ResourceMetadataMap;
29  import ca.uhn.fhir.model.primitive.CodeDt;
30  import ca.uhn.fhir.model.primitive.IdDt;
31  
32  /**
33   * This interface is the parent interface for all FHIR Resource definition classes. Classes implementing this interface should be annotated with the {@link ResourceDef @ResourceDef} annotation.
34   * 
35   * <p>
36   * Note that this class is a part of HAPI's model API, used to define structure classes. Users will often interact with this interface, but should not need to implement it directly.
37   * </p>
38   */
39  public interface IResource extends ICompositeElement, org.hl7.fhir.instance.model.api.IBaseResource {
40  
41  	/**
42  	 * Returns the contained resource list for this resource.
43  	 * <p>
44  	 * Usage note: HAPI will generally populate and use the resources from this list automatically (placing inline resources in the contained list when encoding, and copying contained resources from
45  	 * this list to their appropriate references when parsing) so it is generally not neccesary to interact with this list directly. Instead, in a server you can place resource instances in reference
46  	 * fields (such as <code>Patient#setManagingOrganization(ResourceReferenceDt)</code> ) and the resource will be automatically contained. In a client, contained resources will be automatically
47  	 * populated into their appropriate fields by the HAPI parser.
48  	 * </p>
49  	 * TODO: document contained resources and link there
50  	 */
51  	BaseContainedDt getContained();
52  
53  	/**
54  	 * Returns the ID of this resource. Note that this identifier is the URL (or a portion of the URL) used to access this resource, and is not the same thing as any business identifiers stored within
55  	 * the resource. For example, a Patient resource might have any number of medical record numbers but these are not stored here.
56  	 * <p>
57  	 * This ID is specified as the "Logical ID" and "Version ID" in the FHIR specification, see <a href="http://www.hl7.org/implement/standards/fhir/resources.html#metadata">here</a>
58  	 * </p>
59  	 */
60  	IdDt getId();
61  
62  	/**
63  	 * Gets the language of the resource itself - <b>NOTE that this language attribute applies to the resource itself, it is not (for example) the language spoken by a practitioner or patient</b>
64  	 */
65  	CodeDt getLanguage();
66  
67  	/**
68  	 * Returns a view of the {@link #getResourceMetadata() resource metadata} map.
69  	 * Note that getters from this map return immutable objects, but the <code>addFoo()</code>
70  	 * and <code>setFoo()</code> methods may be used to modify metadata. 
71  	 * 
72  	 * @since 1.5
73  	 */
74  	@Override
75  	IBaseMetaType getMeta();
76  
77  	/**
78  	 * Returns the metadata map for this object, creating it if neccesary. Metadata entries are used to get/set feed bundle entries, such as the resource version, or the last updated timestamp.
79  	 * <p>
80  	 * Keys in this map are enumerated in the {@link ResourceMetadataKeyEnum}, and each key has a specific value type that it must use.
81  	 * </p>
82  	 * 
83  	 * @see ResourceMetadataKeyEnum for a list of allowable keys and the object types that values of a given key must use.
84  	 */
85  	ResourceMetadataMap getResourceMetadata();
86  
87  	/**
88  	 * Returns a String representing the name of this Resource. This return value is not used for anything by HAPI itself, but is provided as a convenience to developers using the API.
89  	 * 
90  	 * @return the name of this resource, e.g. "Patient", or "Observation"
91  	 */
92  	String getResourceName();
93  
94  	/**
95  	 * Returns the FHIR version represented by this structure
96  	 */
97  	@Override
98  	public ca.uhn.fhir.context.FhirVersionEnum getStructureFhirVersionEnum();
99  
100 	/**
101 	 * Returns the narrative block for this resource
102 	 */
103 	BaseNarrativeDt<?> getText();
104 
105 	/**
106 	 * Sets the ID of this resource. Note that this identifier is the URL (or a portion of the URL) used to access this resource, and is not the same thing as any business identifiers stored within the
107 	 * resource. For example, a Patient resource might have any number of medical record numbers but these are not stored here.
108 	 * <p>
109 	 * This ID is specified as the "Logical ID" and "Version ID" in the FHIR specification, see <a href="http://www.hl7.org/implement/standards/fhir/resources.html#metadata">here</a>
110 	 * </p>
111 	 */
112 	void setId(IdDt theId);
113 
114 	/**
115 	 * Sets the language of the resource itself - <b>NOTE that this language attribute applies to the resource itself, it is not (for example) the language spoken by a practitioner or patient</b>
116 	 */
117 	void setLanguage(CodeDt theLanguage);
118 
119 	/**
120 	 * Sets the metadata map for this object. Metadata entries are used to get/set feed bundle entries, such as the resource version, or the last updated timestamp.
121 	 * 
122 	 * @throws NullPointerException
123 	 *            The map must not be null
124 	 */
125 	void setResourceMetadata(ResourceMetadataMap theMap);
126 
127 }