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.model.api;
021
022import org.hl7.fhir.instance.model.api.IBaseMetaType;
023
024import ca.uhn.fhir.model.api.annotation.ResourceDef;
025import ca.uhn.fhir.model.base.composite.BaseContainedDt;
026import ca.uhn.fhir.model.base.composite.BaseNarrativeDt;
027import ca.uhn.fhir.model.base.resource.ResourceMetadataMap;
028import ca.uhn.fhir.model.primitive.CodeDt;
029import ca.uhn.fhir.model.primitive.IdDt;
030
031/**
032 * 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.
033 * 
034 * <p>
035 * 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.
036 * </p>
037 */
038public interface IResource extends ICompositeElement, org.hl7.fhir.instance.model.api.IBaseResource {
039
040        /**
041         * Returns the contained resource list for this resource.
042         * <p>
043         * 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
044         * 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
045         * fields (such as <code>Patient#setManagingOrganization(ResourceReferenceDt)</code> ) and the resource will be automatically contained. In a client, contained resources will be automatically
046         * populated into their appropriate fields by the HAPI parser.
047         * </p>
048         * TODO: document contained resources and link there
049         */
050        BaseContainedDt getContained();
051
052        /**
053         * 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
054         * the resource. For example, a Patient resource might have any number of medical record numbers but these are not stored here.
055         * <p>
056         * 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>
057         * </p>
058         */
059        IdDt getId();
060
061        /**
062         * 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>
063         */
064        CodeDt getLanguage();
065
066        /**
067         * Returns a view of the {@link #getResourceMetadata() resource metadata} map.
068         * Note that getters from this map return immutable objects, but the <code>addFoo()</code>
069         * and <code>setFoo()</code> methods may be used to modify metadata. 
070         * 
071         * @since 1.5
072         */
073        @Override
074        IBaseMetaType getMeta();
075
076        /**
077         * 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.
078         * <p>
079         * Keys in this map are enumerated in the {@link ResourceMetadataKeyEnum}, and each key has a specific value type that it must use.
080         * </p>
081         * 
082         * @see ResourceMetadataKeyEnum for a list of allowable keys and the object types that values of a given key must use.
083         */
084        ResourceMetadataMap getResourceMetadata();
085
086        /**
087         * 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.
088         * 
089         * @return the name of this resource, e.g. "Patient", or "Observation"
090         */
091        String getResourceName();
092
093        /**
094         * Returns the FHIR version represented by this structure
095         */
096        @Override
097        public ca.uhn.fhir.context.FhirVersionEnum getStructureFhirVersionEnum();
098
099        /**
100         * Returns the narrative block for this resource
101         */
102        BaseNarrativeDt<?> getText();
103
104        /**
105         * 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
106         * resource. For example, a Patient resource might have any number of medical record numbers but these are not stored here.
107         * <p>
108         * 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>
109         * </p>
110         */
111        void setId(IdDt theId);
112
113        /**
114         * 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>
115         */
116        void setLanguage(CodeDt theLanguage);
117
118        /**
119         * 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.
120         * 
121         * @throws NullPointerException
122         *            The map must not be null
123         */
124        void setResourceMetadata(ResourceMetadataMap theMap);
125
126}