View Javadoc
1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  
17  package ca.uhn.fhir.model.dstu.composite;
18  
19  /*
20   * #%L
21   * HAPI FHIR - Core Library
22   * %%
23   * Copyright (C) 2014 University Health Network
24   * %%
25   * Licensed under the Apache License, Version 2.0 (the "License");
26   * you may not use this file except in compliance with the License.
27   * You may obtain a copy of the License at
28   * 
29   *      http://www.apache.org/licenses/LICENSE-2.0
30   * 
31   * Unless required by applicable law or agreed to in writing, software
32   * distributed under the License is distributed on an "AS IS" BASIS,
33   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34   * See the License for the specific language governing permissions and
35   * limitations under the License.
36   * #L%
37   */
38  
39  import java.util.List;
40  
41  import ca.uhn.fhir.model.api.ICompositeDatatype;
42  import ca.uhn.fhir.model.api.IElement;
43  import ca.uhn.fhir.model.api.annotation.Child;
44  import ca.uhn.fhir.model.api.annotation.DatatypeDef;
45  import ca.uhn.fhir.model.api.annotation.Description;
46  import ca.uhn.fhir.model.base.composite.BaseCodingDt;
47  import ca.uhn.fhir.model.primitive.BooleanDt;
48  import ca.uhn.fhir.model.primitive.CodeDt;
49  import ca.uhn.fhir.model.primitive.StringDt;
50  import ca.uhn.fhir.model.primitive.UriDt;
51  
52  /**
53   * HAPI/FHIR <b>CodingDt</b> Datatype
54   * (A reference to a code defined by a terminology system)
55   *
56   * <p>
57   * <b>Definition:</b>
58   * A reference to a code defined by a terminology system
59   * </p> 
60   *
61   * <p>
62   * <b>Requirements:</b>
63   * References to codes are very common in healthcare models
64   * </p> 
65   */
66  @DatatypeDef(name="CodingDt") 
67  public class CodingDt
68          extends  BaseCodingDt         implements ICompositeDatatype
69  {
70  
71  	/**
72  	 * Constructor
73  	 */
74  	public CodingDt() {
75  		// nothing
76  	}
77  
78  	/**
79  	 * Creates a new Coding with the given system and code
80  	 */
81  	public CodingDt(String theSystem, String theCode) {
82  		setSystem(theSystem);
83  		setCode(theCode);
84  	}
85  
86  	@Child(name="system", type=UriDt.class, order=0, min=0, max=1)	
87  	@Description(
88  		shortDefinition="Identity of the terminology system",
89  		formalDefinition="The identification of the code system that defines the meaning of the symbol in the code."
90  	)
91  	private UriDt mySystem;
92  	
93  	@Child(name="version", type=StringDt.class, order=1, min=0, max=1)	
94  	@Description(
95  		shortDefinition="Version of the system - if relevant",
96  		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"
97  	)
98  	private StringDt myVersion;
99  	
100 	@Child(name="code", type=CodeDt.class, order=2, min=0, max=1)	
101 	@Description(
102 		shortDefinition="Symbol in syntax defined by the system",
103 		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)"
104 	)
105 	private CodeDt myCode;
106 	
107 	@Child(name="display", type=StringDt.class, order=3, min=0, max=1)	
108 	@Description(
109 		shortDefinition="Representation defined by the system",
110 		formalDefinition="A representation of the meaning of the code in the system, following the rules of the system."
111 	)
112 	private StringDt myDisplay;
113 	
114 	@Child(name="primary", type=BooleanDt.class, order=4, min=0, max=1)	
115 	@Description(
116 		shortDefinition="If this code was chosen directly by the user",
117 		formalDefinition="Indicates that this code was chosen by a user directly - i.e. off a pick list of available items (codes or displays)"
118 	)
119 	private BooleanDt myPrimary;
120 	
121 	@Child(name="valueSet", order=5, min=0, max=1, type={
122 		ca.uhn.fhir.model.dstu.resource.ValueSet.class	})
123 	@Description(
124 		shortDefinition="Set this coding was chosen from",
125 		formalDefinition="The set of possible coded values this coding was chosen from or constrained by"
126 	)
127 	private ResourceReferenceDt myValueSet;
128 	
129 
130 	@Override
131 	public boolean isEmpty() {
132 		return super.isBaseEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(  mySystem,  myVersion,  myCode,  myDisplay,  myPrimary,  myValueSet);
133 	}
134 	
135 	@Override
136 	public <T extends IElement> List<T> getAllPopulatedChildElementsOfType(Class<T> theType) {
137 		return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(theType, mySystem, myVersion, myCode, myDisplay, myPrimary, myValueSet);
138 	}
139 
140 	/**
141 	 * Gets the value(s) for <b>system</b> (Identity of the terminology system).
142 	 * creating it if it does
143 	 * not exist. Will not return <code>null</code>.
144 	 *
145      * <p>
146      * <b>Definition:</b>
147      * The identification of the code system that defines the meaning of the symbol in the code.
148      * </p> 
149 	 */
150 	public UriDt getSystem() {  
151 		if (mySystem == null) {
152 			mySystem = new UriDt();
153 		}
154 		return mySystem;
155 	}
156 
157 	/**
158 	 * Sets the value(s) for <b>system</b> (Identity of the terminology system)
159 	 *
160      * <p>
161      * <b>Definition:</b>
162      * The identification of the code system that defines the meaning of the symbol in the code.
163      * </p> 
164 	 */
165 	public CodingDt setSystem(UriDt theValue) {
166 		mySystem = theValue;
167 		return this;
168 	}
169 
170  	/**
171 	 * Sets the value for <b>system</b> (Identity of the terminology system)
172 	 *
173      * <p>
174      * <b>Definition:</b>
175      * The identification of the code system that defines the meaning of the symbol in the code.
176      * </p> 
177 	 */
178 	public CodingDt setSystem( String theUri) {
179 		mySystem = new UriDt(theUri); 
180 		return this; 
181 	}
182 
183  
184 	/**
185 	 * Gets the value(s) for <b>version</b> (Version of the system - if relevant).
186 	 * creating it if it does
187 	 * not exist. Will not return <code>null</code>.
188 	 *
189      * <p>
190      * <b>Definition:</b>
191      * 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
192      * </p> 
193 	 */
194 	public StringDt getVersion() {  
195 		if (myVersion == null) {
196 			myVersion = new StringDt();
197 		}
198 		return myVersion;
199 	}
200 
201 	/**
202 	 * Sets the value(s) for <b>version</b> (Version of the system - if relevant)
203 	 *
204      * <p>
205      * <b>Definition:</b>
206      * 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
207      * </p> 
208 	 */
209 	public CodingDt setVersion(StringDt theValue) {
210 		myVersion = theValue;
211 		return this;
212 	}
213 
214  	/**
215 	 * Sets the value for <b>version</b> (Version of the system - if relevant)
216 	 *
217      * <p>
218      * <b>Definition:</b>
219      * 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
220      * </p> 
221 	 */
222 	public CodingDt setVersion( String theString) {
223 		myVersion = new StringDt(theString); 
224 		return this; 
225 	}
226 
227  
228 	/**
229 	 * Gets the value(s) for <b>code</b> (Symbol in syntax defined by the system).
230 	 * creating it if it does
231 	 * not exist. Will not return <code>null</code>.
232 	 *
233      * <p>
234      * <b>Definition:</b>
235      * 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)
236      * </p> 
237 	 */
238 	public CodeDt getCode() {  
239 		if (myCode == null) {
240 			myCode = new CodeDt();
241 		}
242 		return myCode;
243 	}
244 
245 	/**
246 	 * Sets the value(s) for <b>code</b> (Symbol in syntax defined by the system)
247 	 *
248      * <p>
249      * <b>Definition:</b>
250      * 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)
251      * </p> 
252 	 */
253 	public CodingDt setCode(CodeDt theValue) {
254 		myCode = theValue;
255 		return this;
256 	}
257 
258  	/**
259 	 * Sets the value for <b>code</b> (Symbol in syntax defined by the system)
260 	 *
261      * <p>
262      * <b>Definition:</b>
263      * 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)
264      * </p> 
265 	 */
266 	public CodingDt setCode( String theCode) {
267 		myCode = new CodeDt(theCode); 
268 		return this; 
269 	}
270 
271  
272 	/**
273 	 * Gets the value(s) for <b>display</b> (Representation defined by the system).
274 	 * creating it if it does
275 	 * not exist. Will not return <code>null</code>.
276 	 *
277      * <p>
278      * <b>Definition:</b>
279      * A representation of the meaning of the code in the system, following the rules of the system.
280      * </p> 
281 	 */
282 	public StringDt getDisplay() {  
283 		if (myDisplay == null) {
284 			myDisplay = new StringDt();
285 		}
286 		return myDisplay;
287 	}
288 
289 	/**
290 	 * Sets the value(s) for <b>display</b> (Representation defined by the system)
291 	 *
292      * <p>
293      * <b>Definition:</b>
294      * A representation of the meaning of the code in the system, following the rules of the system.
295      * </p> 
296 	 */
297 	public CodingDt setDisplay(StringDt theValue) {
298 		myDisplay = theValue;
299 		return this;
300 	}
301 
302  	/**
303 	 * Sets the value for <b>display</b> (Representation defined by the system)
304 	 *
305      * <p>
306      * <b>Definition:</b>
307      * A representation of the meaning of the code in the system, following the rules of the system.
308      * </p> 
309 	 */
310 	public CodingDt setDisplay( String theString) {
311 		myDisplay = new StringDt(theString); 
312 		return this; 
313 	}
314 
315  
316 	/**
317 	 * Gets the value(s) for <b>primary</b> (If this code was chosen directly by the user).
318 	 * creating it if it does
319 	 * not exist. Will not return <code>null</code>.
320 	 *
321      * <p>
322      * <b>Definition:</b>
323      * Indicates that this code was chosen by a user directly - i.e. off a pick list of available items (codes or displays)
324      * </p> 
325 	 */
326 	public BooleanDt getPrimary() {  
327 		if (myPrimary == null) {
328 			myPrimary = new BooleanDt();
329 		}
330 		return myPrimary;
331 	}
332 
333 	/**
334 	 * Sets the value(s) for <b>primary</b> (If this code was chosen directly by the user)
335 	 *
336      * <p>
337      * <b>Definition:</b>
338      * Indicates that this code was chosen by a user directly - i.e. off a pick list of available items (codes or displays)
339      * </p> 
340 	 */
341 	public CodingDt setPrimary(BooleanDt theValue) {
342 		myPrimary = theValue;
343 		return this;
344 	}
345 
346  	/**
347 	 * Sets the value for <b>primary</b> (If this code was chosen directly by the user)
348 	 *
349      * <p>
350      * <b>Definition:</b>
351      * Indicates that this code was chosen by a user directly - i.e. off a pick list of available items (codes or displays)
352      * </p> 
353 	 */
354 	public CodingDt setPrimary( boolean theBoolean) {
355 		myPrimary = new BooleanDt(theBoolean); 
356 		return this; 
357 	}
358 
359  
360 	/**
361 	 * Gets the value(s) for <b>valueSet</b> (Set this coding was chosen from).
362 	 * creating it if it does
363 	 * not exist. Will not return <code>null</code>.
364 	 *
365      * <p>
366      * <b>Definition:</b>
367      * The set of possible coded values this coding was chosen from or constrained by
368      * </p> 
369 	 */
370 	public ResourceReferenceDt getValueSet() {  
371 		if (myValueSet == null) {
372 			myValueSet = new ResourceReferenceDt();
373 		}
374 		return myValueSet;
375 	}
376 
377 	/**
378 	 * Sets the value(s) for <b>valueSet</b> (Set this coding was chosen from)
379 	 *
380      * <p>
381      * <b>Definition:</b>
382      * The set of possible coded values this coding was chosen from or constrained by
383      * </p> 
384 	 */
385 	public CodingDt setValueSet(ResourceReferenceDt theValue) {
386 		myValueSet = theValue;
387 		return this;
388 	}
389 
390   
391 
392 
393 }