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