View Javadoc
1   package ca.uhn.fhir.rest.param;
2   
3   /*
4    * #%L
5    * HAPI FHIR - Core Library
6    * %%
7    * Copyright (C) 2014 - 2018 University Health Network
8    * %%
9    * Licensed under the Apache License, Version 2.0 (the "License");
10   * you may not use this file except in compliance with the License.
11   * You may obtain a copy of the License at
12   * 
13   *      http://www.apache.org/licenses/LICENSE-2.0
14   * 
15   * Unless required by applicable law or agreed to in writing, software
16   * distributed under the License is distributed on an "AS IS" BASIS,
17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   * See the License for the specific language governing permissions and
19   * limitations under the License.
20   * #L%
21   */
22  
23  import java.util.List;
24  
25  import ca.uhn.fhir.model.api.ICompositeDatatype;
26  import ca.uhn.fhir.model.api.IElement;
27  import ca.uhn.fhir.model.api.IQueryParameterType;
28  import ca.uhn.fhir.model.api.annotation.Child;
29  import ca.uhn.fhir.model.api.annotation.Description;
30  import ca.uhn.fhir.model.base.composite.BaseCodingDt;
31  import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt;
32  import ca.uhn.fhir.model.primitive.BooleanDt;
33  import ca.uhn.fhir.model.primitive.CodeDt;
34  import ca.uhn.fhir.model.primitive.StringDt;
35  import ca.uhn.fhir.model.primitive.UriDt;
36  import ca.uhn.fhir.util.CoverageIgnore;
37  
38  @CoverageIgnore
39  public class InternalCodingDt extends BaseCodingDt implements ICompositeDatatype {
40  
41  	private static final long serialVersionUID = 993056016725918652L;
42  
43  	/**
44  	 * Constructor
45  	 */
46  	public InternalCodingDt() {
47  		super();
48  	}
49  
50  	/**
51  	 * Creates a new Coding with the given system and code
52  	 */
53  	public InternalCodingDt(String theSystem, String theCode) {
54  		setSystem(theSystem);
55  		setCode(theCode);
56  	}
57  
58  	@Child(name = "system", type = UriDt.class, order = 0, min = 0, max = 1)
59  	@Description(shortDefinition = "Identity of the terminology system", formalDefinition = "The identification of the code system that defines the meaning of the symbol in the code.")
60  	private UriDt mySystem;
61  
62  	@Child(name = "version", type = StringDt.class, order = 1, min = 0, max = 1)
63  	@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")
64  	private StringDt myVersion;
65  
66  	@Child(name = "code", type = CodeDt.class, order = 2, min = 0, max = 1)
67  	@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)")
68  	private CodeDt myCode;
69  
70  	@Child(name = "display", type = StringDt.class, order = 3, min = 0, max = 1)
71  	@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.")
72  	private StringDt myDisplay;
73  
74  	@Child(name = "primary", type = BooleanDt.class, order = 4, min = 0, max = 1)
75  	@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)")
76  	private BooleanDt myPrimary;
77  
78  	@Override
79  	public boolean isEmpty() {
80  		return super.isBaseEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(mySystem, myVersion, myCode, myDisplay, myPrimary);
81  	}
82  
83  	@Deprecated //override deprecated method
84  	@Override
85  	public <T extends IElement> List<T> getAllPopulatedChildElementsOfType(Class<T> theType) {
86  		return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(theType, mySystem, myVersion, myCode, myDisplay, myPrimary);
87  	}
88  
89  	/**
90  	 * 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>.
91  	 *
92  	 * <p>
93  	 * <b>Definition:</b> The identification of the code system that defines the meaning of the symbol in the code.
94  	 * </p>
95  	 */
96  	@Override
97  	public UriDt getSystemElement() {
98  		if (mySystem == null) {
99  			mySystem = new UriDt();
100 		}
101 		return mySystem;
102 	}
103 
104 	/**
105 	 * Sets the value(s) for <b>system</b> (Identity of the terminology system)
106 	 *
107 	 * <p>
108 	 * <b>Definition:</b> The identification of the code system that defines the meaning of the symbol in the code.
109 	 * </p>
110 	 */
111 	public InternalCodingDt setSystem(UriDt theValue) {
112 		mySystem = theValue;
113 		return this;
114 	}
115 
116 	/**
117 	 * Sets the value for <b>system</b> (Identity of the terminology system)
118 	 *
119 	 * <p>
120 	 * <b>Definition:</b> The identification of the code system that defines the meaning of the symbol in the code.
121 	 * </p>
122 	 */
123 	@Override
124 	public InternalCodingDt setSystem(String theUri) {
125 		mySystem = new UriDt(theUri);
126 		return this;
127 	}
128 
129 	/**
130 	 * 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>.
131 	 *
132 	 * <p>
133 	 * <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
134 	 * 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
135 	 * </p>
136 	 */
137 	public StringDt getVersion() {
138 		if (myVersion == null) {
139 			myVersion = new StringDt();
140 		}
141 		return myVersion;
142 	}
143 
144 	/**
145 	 * Sets the value(s) for <b>version</b> (Version of the system - if relevant)
146 	 *
147 	 * <p>
148 	 * <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
149 	 * 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
150 	 * </p>
151 	 */
152 	public InternalCodingDt setVersion(StringDt theValue) {
153 		myVersion = theValue;
154 		return this;
155 	}
156 
157 	/**
158 	 * Sets the value for <b>version</b> (Version of the system - if relevant)
159 	 *
160 	 * <p>
161 	 * <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
162 	 * 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
163 	 * </p>
164 	 */
165 	public InternalCodingDt setVersion(String theString) {
166 		myVersion = new StringDt(theString);
167 		return this;
168 	}
169 
170 	/**
171 	 * 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>.
172 	 *
173 	 * <p>
174 	 * <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)
175 	 * </p>
176 	 */
177 	@Override
178 	public CodeDt getCodeElement() {
179 		if (myCode == null) {
180 			myCode = new CodeDt();
181 		}
182 		return myCode;
183 	}
184 
185 	/**
186 	 * Sets the value(s) for <b>code</b> (Symbol in syntax defined by the system)
187 	 *
188 	 * <p>
189 	 * <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)
190 	 * </p>
191 	 */
192 	public InternalCodingDt setCode(CodeDt theValue) {
193 		myCode = theValue;
194 		return this;
195 	}
196 
197 	/**
198 	 * Sets the value for <b>code</b> (Symbol in syntax defined by the system)
199 	 *
200 	 * <p>
201 	 * <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)
202 	 * </p>
203 	 */
204 	@Override
205 	public InternalCodingDt setCode(String theCode) {
206 		myCode = new CodeDt(theCode);
207 		return this;
208 	}
209 
210 	/**
211 	 * 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>.
212 	 *
213 	 * <p>
214 	 * <b>Definition:</b> A representation of the meaning of the code in the system, following the rules of the system.
215 	 * </p>
216 	 */
217 	public StringDt getDisplay() {
218 		if (myDisplay == null) {
219 			myDisplay = new StringDt();
220 		}
221 		return myDisplay;
222 	}
223 
224 	/**
225 	 * Sets the value(s) for <b>display</b> (Representation defined by the system)
226 	 *
227 	 * <p>
228 	 * <b>Definition:</b> A representation of the meaning of the code in the system, following the rules of the system.
229 	 * </p>
230 	 */
231 	public InternalCodingDt setDisplay(StringDt theValue) {
232 		myDisplay = theValue;
233 		return this;
234 	}
235 
236 	/**
237 	 * Sets the value for <b>display</b> (Representation defined by the system)
238 	 *
239 	 * <p>
240 	 * <b>Definition:</b> A representation of the meaning of the code in the system, following the rules of the system.
241 	 * </p>
242 	 */
243 	@Override
244 	public InternalCodingDt setDisplay(String theString) {
245 		myDisplay = new StringDt(theString);
246 		return this;
247 	}
248 
249 	/**
250 	 * 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>.
251 	 *
252 	 * <p>
253 	 * <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)
254 	 * </p>
255 	 */
256 	public BooleanDt getPrimary() {
257 		if (myPrimary == null) {
258 			myPrimary = new BooleanDt();
259 		}
260 		return myPrimary;
261 	}
262 
263 	/**
264 	 * Sets the value(s) for <b>primary</b> (If this code was chosen directly by the user)
265 	 *
266 	 * <p>
267 	 * <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)
268 	 * </p>
269 	 */
270 	public InternalCodingDt setPrimary(BooleanDt theValue) {
271 		myPrimary = theValue;
272 		return this;
273 	}
274 
275 	/**
276 	 * Sets the value for <b>primary</b> (If this code was chosen directly by the user)
277 	 *
278 	 * <p>
279 	 * <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)
280 	 * </p>
281 	 */
282 	public InternalCodingDt setPrimary(boolean theBoolean) {
283 		myPrimary = new BooleanDt(theBoolean);
284 		return this;
285 	}
286 
287 	/**
288 	 * 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>.
289 	 *
290 	 * <p>
291 	 * <b>Definition:</b> The set of possible coded values this coding was chosen from or constrained by
292 	 * </p>
293 	 */
294 	public BaseResourceReferenceDt getValueSet() {
295 		throw new UnsupportedOperationException();
296 	}
297 
298 	@Override
299 	public StringDt getDisplayElement() {
300 		return getDisplay();
301 	}
302 
303 	@Deprecated //override deprecated method
304 	@Override
305 	public Boolean getMissing() {
306 		throw new UnsupportedOperationException();
307 	}
308 
309 	@Deprecated //override deprecated method
310 	@Override
311 	public IQueryParameterType setMissing(Boolean theMissing) {
312 		throw new UnsupportedOperationException();
313 	}
314 
315 }