001package ca.uhn.fhir.rest.param;
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 java.util.List;
024
025import ca.uhn.fhir.model.api.ICompositeDatatype;
026import ca.uhn.fhir.model.api.IElement;
027import ca.uhn.fhir.model.api.annotation.Child;
028import ca.uhn.fhir.model.api.annotation.Description;
029import ca.uhn.fhir.model.base.composite.BaseCodingDt;
030import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt;
031import ca.uhn.fhir.model.primitive.BooleanDt;
032import ca.uhn.fhir.model.primitive.CodeDt;
033import ca.uhn.fhir.model.primitive.StringDt;
034import ca.uhn.fhir.model.primitive.UriDt;
035import ca.uhn.fhir.util.CoverageIgnore;
036
037@CoverageIgnore
038public class InternalCodingDt extends BaseCodingDt implements ICompositeDatatype {
039
040        /**
041         * Constructor
042         */
043        public InternalCodingDt() {
044                super();
045        }
046
047        /**
048         * Creates a new Coding with the given system and code
049         */
050        public InternalCodingDt(String theSystem, String theCode) {
051                setSystem(theSystem);
052                setCode(theCode);
053        }
054
055        @Child(name = "system", type = UriDt.class, order = 0, min = 0, max = 1)
056        @Description(shortDefinition = "Identity of the terminology system", formalDefinition = "The identification of the code system that defines the meaning of the symbol in the code.")
057        private UriDt mySystem;
058
059        @Child(name = "version", type = StringDt.class, order = 1, min = 0, max = 1)
060        @Description(shortDefinition = "Version of the system - if relevant", formalDefinition = "The version of the code system which was used when choosing this code. Note that a well-maintained code system does not need the version reported, because the meaning of codes is consistent across versions. However this cannot consistently be assured. and When the meaning is not guaranteed to be consistent, the version SHOULD be exchanged")
061        private StringDt myVersion;
062
063        @Child(name = "code", type = CodeDt.class, order = 2, min = 0, max = 1)
064        @Description(shortDefinition = "Symbol in syntax defined by the system", formalDefinition = "A symbol in syntax defined by the system. The symbol may be a predefined code or an expression in a syntax defined by the coding system (e.g. post-coordination)")
065        private CodeDt myCode;
066
067        @Child(name = "display", type = StringDt.class, order = 3, min = 0, max = 1)
068        @Description(shortDefinition = "Representation defined by the system", formalDefinition = "A representation of the meaning of the code in the system, following the rules of the system.")
069        private StringDt myDisplay;
070
071        @Child(name = "primary", type = BooleanDt.class, order = 4, min = 0, max = 1)
072        @Description(shortDefinition = "If this code was chosen directly by the user", formalDefinition = "Indicates that this code was chosen by a user directly - i.e. off a pick list of available items (codes or displays)")
073        private BooleanDt myPrimary;
074
075        @Override
076        public boolean isEmpty() {
077                return super.isBaseEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(mySystem, myVersion, myCode, myDisplay, myPrimary);
078        }
079
080        @Override
081        public <T extends IElement> List<T> getAllPopulatedChildElementsOfType(Class<T> theType) {
082                return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(theType, mySystem, myVersion, myCode, myDisplay, myPrimary);
083        }
084
085        /**
086         * Gets the value(s) for <b>system</b> (Identity of the terminology system). creating it if it does not exist. Will not return <code>null</code>.
087         *
088         * <p>
089         * <b>Definition:</b> The identification of the code system that defines the meaning of the symbol in the code.
090         * </p>
091         */
092        public UriDt getSystemElement() {
093                if (mySystem == null) {
094                        mySystem = new UriDt();
095                }
096                return mySystem;
097        }
098
099        /**
100         * Sets the value(s) for <b>system</b> (Identity of the terminology system)
101         *
102         * <p>
103         * <b>Definition:</b> The identification of the code system that defines the meaning of the symbol in the code.
104         * </p>
105         */
106        public InternalCodingDt setSystem(UriDt theValue) {
107                mySystem = theValue;
108                return this;
109        }
110
111        /**
112         * Sets the value for <b>system</b> (Identity of the terminology system)
113         *
114         * <p>
115         * <b>Definition:</b> The identification of the code system that defines the meaning of the symbol in the code.
116         * </p>
117         */
118        public InternalCodingDt setSystem(String theUri) {
119                mySystem = new UriDt(theUri);
120                return this;
121        }
122
123        /**
124         * Gets the value(s) for <b>version</b> (Version of the system - if relevant). creating it if it does not exist. Will not return <code>null</code>.
125         *
126         * <p>
127         * <b>Definition:</b> The version of the code system which was used when choosing this code. Note that a well-maintained code system does not need the version reported, because the meaning of codes
128         * is consistent across versions. However this cannot consistently be assured. and When the meaning is not guaranteed to be consistent, the version SHOULD be exchanged
129         * </p>
130         */
131        public StringDt getVersion() {
132                if (myVersion == null) {
133                        myVersion = new StringDt();
134                }
135                return myVersion;
136        }
137
138        /**
139         * Sets the value(s) for <b>version</b> (Version of the system - if relevant)
140         *
141         * <p>
142         * <b>Definition:</b> The version of the code system which was used when choosing this code. Note that a well-maintained code system does not need the version reported, because the meaning of codes
143         * is consistent across versions. However this cannot consistently be assured. and When the meaning is not guaranteed to be consistent, the version SHOULD be exchanged
144         * </p>
145         */
146        public InternalCodingDt setVersion(StringDt theValue) {
147                myVersion = theValue;
148                return this;
149        }
150
151        /**
152         * Sets the value for <b>version</b> (Version of the system - if relevant)
153         *
154         * <p>
155         * <b>Definition:</b> The version of the code system which was used when choosing this code. Note that a well-maintained code system does not need the version reported, because the meaning of codes
156         * is consistent across versions. However this cannot consistently be assured. and When the meaning is not guaranteed to be consistent, the version SHOULD be exchanged
157         * </p>
158         */
159        public InternalCodingDt setVersion(String theString) {
160                myVersion = new StringDt(theString);
161                return this;
162        }
163
164        /**
165         * Gets the value(s) for <b>code</b> (Symbol in syntax defined by the system). creating it if it does not exist. Will not return <code>null</code>.
166         *
167         * <p>
168         * <b>Definition:</b> A symbol in syntax defined by the system. The symbol may be a predefined code or an expression in a syntax defined by the coding system (e.g. post-coordination)
169         * </p>
170         */
171        public CodeDt getCodeElement() {
172                if (myCode == null) {
173                        myCode = new CodeDt();
174                }
175                return myCode;
176        }
177
178        /**
179         * Sets the value(s) for <b>code</b> (Symbol in syntax defined by the system)
180         *
181         * <p>
182         * <b>Definition:</b> A symbol in syntax defined by the system. The symbol may be a predefined code or an expression in a syntax defined by the coding system (e.g. post-coordination)
183         * </p>
184         */
185        public InternalCodingDt setCode(CodeDt theValue) {
186                myCode = theValue;
187                return this;
188        }
189
190        /**
191         * Sets the value for <b>code</b> (Symbol in syntax defined by the system)
192         *
193         * <p>
194         * <b>Definition:</b> A symbol in syntax defined by the system. The symbol may be a predefined code or an expression in a syntax defined by the coding system (e.g. post-coordination)
195         * </p>
196         */
197        public InternalCodingDt setCode(String theCode) {
198                myCode = new CodeDt(theCode);
199                return this;
200        }
201
202        /**
203         * Gets the value(s) for <b>display</b> (Representation defined by the system). creating it if it does not exist. Will not return <code>null</code>.
204         *
205         * <p>
206         * <b>Definition:</b> A representation of the meaning of the code in the system, following the rules of the system.
207         * </p>
208         */
209        public StringDt getDisplay() {
210                if (myDisplay == null) {
211                        myDisplay = new StringDt();
212                }
213                return myDisplay;
214        }
215
216        /**
217         * Sets the value(s) for <b>display</b> (Representation defined by the system)
218         *
219         * <p>
220         * <b>Definition:</b> A representation of the meaning of the code in the system, following the rules of the system.
221         * </p>
222         */
223        public InternalCodingDt setDisplay(StringDt theValue) {
224                myDisplay = theValue;
225                return this;
226        }
227
228        /**
229         * Sets the value for <b>display</b> (Representation defined by the system)
230         *
231         * <p>
232         * <b>Definition:</b> A representation of the meaning of the code in the system, following the rules of the system.
233         * </p>
234         */
235        public InternalCodingDt setDisplay(String theString) {
236                myDisplay = new StringDt(theString);
237                return this;
238        }
239
240        /**
241         * Gets the value(s) for <b>primary</b> (If this code was chosen directly by the user). creating it if it does not exist. Will not return <code>null</code>.
242         *
243         * <p>
244         * <b>Definition:</b> Indicates that this code was chosen by a user directly - i.e. off a pick list of available items (codes or displays)
245         * </p>
246         */
247        public BooleanDt getPrimary() {
248                if (myPrimary == null) {
249                        myPrimary = new BooleanDt();
250                }
251                return myPrimary;
252        }
253
254        /**
255         * Sets the value(s) for <b>primary</b> (If this code was chosen directly by the user)
256         *
257         * <p>
258         * <b>Definition:</b> Indicates that this code was chosen by a user directly - i.e. off a pick list of available items (codes or displays)
259         * </p>
260         */
261        public InternalCodingDt setPrimary(BooleanDt theValue) {
262                myPrimary = theValue;
263                return this;
264        }
265
266        /**
267         * Sets the value for <b>primary</b> (If this code was chosen directly by the user)
268         *
269         * <p>
270         * <b>Definition:</b> Indicates that this code was chosen by a user directly - i.e. off a pick list of available items (codes or displays)
271         * </p>
272         */
273        public InternalCodingDt setPrimary(boolean theBoolean) {
274                myPrimary = new BooleanDt(theBoolean);
275                return this;
276        }
277
278        /**
279         * Gets the value(s) for <b>valueSet</b> (Set this coding was chosen from). creating it if it does not exist. Will not return <code>null</code>.
280         *
281         * <p>
282         * <b>Definition:</b> The set of possible coded values this coding was chosen from or constrained by
283         * </p>
284         */
285        public BaseResourceReferenceDt getValueSet() {
286                throw new UnsupportedOperationException();
287        }
288
289        @Override
290        public StringDt getDisplayElement() {
291                return getDisplay();
292        }
293
294        @Override
295        public Boolean getMissing() {
296                throw new UnsupportedOperationException();
297        }
298
299        @Override
300        public void setMissing(Boolean theMissing) {
301                throw new UnsupportedOperationException();
302        }
303
304}