001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017package ca.uhn.fhir.model.dstu2.composite;
018
019import java.net.URI;
020import java.math.BigDecimal;
021import org.apache.commons.lang3.StringUtils;
022import java.util.*;
023import ca.uhn.fhir.model.api.*;
024import ca.uhn.fhir.model.primitive.*;
025import ca.uhn.fhir.model.api.annotation.*;
026import ca.uhn.fhir.model.base.composite.*;
027
028import ca.uhn.fhir.model.dstu2.valueset.AddressTypeEnum;
029import ca.uhn.fhir.model.dstu2.valueset.AddressUseEnum;
030import ca.uhn.fhir.model.dstu2.valueset.AggregationModeEnum;
031import ca.uhn.fhir.model.dstu2.valueset.BindingStrengthEnum;
032import ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt;
033import ca.uhn.fhir.model.dstu2.composite.CodingDt;
034import ca.uhn.fhir.model.dstu2.valueset.ConstraintSeverityEnum;
035import ca.uhn.fhir.model.dstu2.valueset.ContactPointSystemEnum;
036import ca.uhn.fhir.model.dstu2.valueset.ContactPointUseEnum;
037import ca.uhn.fhir.model.dstu2.resource.Device;
038import ca.uhn.fhir.model.dstu2.valueset.EventTimingEnum;
039import ca.uhn.fhir.model.dstu2.valueset.IdentifierTypeCodesEnum;
040import ca.uhn.fhir.model.dstu2.valueset.IdentifierUseEnum;
041import ca.uhn.fhir.model.dstu2.valueset.NameUseEnum;
042import ca.uhn.fhir.model.dstu2.resource.Organization;
043import ca.uhn.fhir.model.dstu2.resource.Patient;
044import ca.uhn.fhir.model.dstu2.composite.PeriodDt;
045import ca.uhn.fhir.model.dstu2.resource.Practitioner;
046import ca.uhn.fhir.model.dstu2.valueset.PropertyRepresentationEnum;
047import ca.uhn.fhir.model.dstu2.valueset.QuantityComparatorEnum;
048import ca.uhn.fhir.model.dstu2.composite.QuantityDt;
049import ca.uhn.fhir.model.dstu2.composite.RangeDt;
050import ca.uhn.fhir.model.dstu2.resource.RelatedPerson;
051import ca.uhn.fhir.model.dstu2.valueset.SignatureTypeCodesEnum;
052import ca.uhn.fhir.model.dstu2.valueset.SlicingRulesEnum;
053import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
054import ca.uhn.fhir.model.dstu2.valueset.TimingAbbreviationEnum;
055import ca.uhn.fhir.model.dstu2.valueset.UnitsOfTimeEnum;
056import ca.uhn.fhir.model.dstu2.resource.ValueSet;
057import ca.uhn.fhir.model.dstu2.composite.BoundCodeableConceptDt;
058import ca.uhn.fhir.model.dstu2.composite.DurationDt;
059import ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt;
060import ca.uhn.fhir.model.dstu2.composite.SimpleQuantityDt;
061import ca.uhn.fhir.model.primitive.Base64BinaryDt;
062import ca.uhn.fhir.model.primitive.BooleanDt;
063import ca.uhn.fhir.model.primitive.BoundCodeDt;
064import ca.uhn.fhir.model.primitive.CodeDt;
065import ca.uhn.fhir.model.primitive.DateTimeDt;
066import ca.uhn.fhir.model.primitive.DecimalDt;
067import ca.uhn.fhir.model.primitive.IdDt;
068import ca.uhn.fhir.model.primitive.InstantDt;
069import ca.uhn.fhir.model.primitive.IntegerDt;
070import ca.uhn.fhir.model.primitive.MarkdownDt;
071import ca.uhn.fhir.model.primitive.PositiveIntDt;
072import ca.uhn.fhir.model.primitive.StringDt;
073import ca.uhn.fhir.model.primitive.UnsignedIntDt;
074import ca.uhn.fhir.model.primitive.UriDt;
075
076/**
077 * HAPI/FHIR <b>QuantityDt</b> Datatype
078 * ()
079 *
080 * <p>
081 * <b>Definition:</b>
082 * A measured amount (or an amount that can potentially be measured). Note that measured amounts include amounts that are not precisely quantified, including amounts involving arbitrary units and floating currencies
083 * </p> 
084 *
085 * <p>
086 * <b>Requirements:</b>
087 * Need to able to capture all sorts of measured values, even if the measured value are not precisely quantified. Values include exact measures such as 3.51g, customary units such as 3 tablets, and currencies such as $100.32USD
088 * </p> 
089 */
090@DatatypeDef(name="Quantity") 
091public class QuantityDt
092        extends  BaseQuantityDt         implements ICompositeDatatype{
093
094        /**
095         * Constructor
096         */
097        public QuantityDt() {
098                // nothing
099        }
100
101 
102        /**
103         * Constructor
104         */
105        @SimpleSetter
106        public QuantityDt(@SimpleSetter.Parameter(name="theValue") double theValue) {
107                setValue(theValue);
108        }
109
110        /**
111         * Constructor
112         */
113        @SimpleSetter
114        public QuantityDt(@SimpleSetter.Parameter(name="theValue") long theValue) {
115                setValue(theValue);
116        }
117        
118        /**
119         * Constructor
120         */
121        @SimpleSetter
122        public QuantityDt(@SimpleSetter.Parameter(name = "theComparator") QuantityComparatorEnum theComparator, @SimpleSetter.Parameter(name = "theValue") double theValue,
123                        @SimpleSetter.Parameter(name = "theUnits") String theUnits) {
124                setValue(theValue);
125                setComparator(theComparator);
126                setUnits(theUnits);
127        }
128
129        /**
130         * Constructor
131         */
132        @SimpleSetter
133        public QuantityDt(@SimpleSetter.Parameter(name = "theComparator") QuantityComparatorEnum theComparator, @SimpleSetter.Parameter(name = "theValue") long theValue,
134                        @SimpleSetter.Parameter(name = "theUnits") String theUnits) {
135                setValue(theValue);
136                setComparator(theComparator);
137                setUnits(theUnits);
138        }
139
140        /**
141         * Constructor
142         */
143        @SimpleSetter
144        public QuantityDt(@SimpleSetter.Parameter(name="theComparator") QuantityComparatorEnum theComparator, @SimpleSetter.Parameter(name="theValue") double theValue, @SimpleSetter.Parameter(name="theSystem") String theSystem, @SimpleSetter.Parameter(name="theUnits") String theUnits) {
145                setValue(theValue);
146                setComparator(theComparator);
147                setSystem(theSystem);
148                setUnits(theUnits);
149        }
150
151        /**
152         * Constructor
153         */
154        @SimpleSetter
155        public QuantityDt(@SimpleSetter.Parameter(name="theComparator") QuantityComparatorEnum theComparator, @SimpleSetter.Parameter(name="theValue") long theValue, @SimpleSetter.Parameter(name="theSystem") String theSystem, @SimpleSetter.Parameter(name="theUnits") String theUnits) {
156                setValue(theValue);
157                setComparator(theComparator);
158                setSystem(theSystem);
159                setUnits(theUnits);
160        }
161
162        /**
163         * @deprecated Use {@link #setUnit(String)} instead - Quantity.units was renamed to Quantity.unit in DSTU2
164         */
165        @Deprecated
166        @Override
167        public BaseQuantityDt setUnits(String theString) {
168                return setUnit(theString);
169        }
170
171        /**
172         * @deprecated Use {@link #getUnitElement()} - Quantity.units was renamed to Quantity.unit in DSTU2
173         */
174        @Deprecated
175        @Override
176        public StringDt getUnitsElement() {
177                return getUnitElement();
178        }
179
180        @Child(name="value", type=DecimalDt.class, order=0, min=0, max=1, summary=true, modifier=false) 
181        @Description(
182                shortDefinition="",
183                formalDefinition="The value of the measured amount. The value includes an implicit precision in the presentation of the value"
184        )
185        private DecimalDt myValue;
186        
187        @Child(name="comparator", type=CodeDt.class, order=1, min=0, max=1, summary=true, modifier=true)        
188        @Description(
189                shortDefinition="",
190                formalDefinition="How the value should be understood and represented - whether the actual value is greater or less than the stated value due to measurement issues; e.g. if the comparator is \"<\" , then the real value is < stated value"
191        )
192        @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/quantity-comparator")
193        private BoundCodeDt<QuantityComparatorEnum> myComparator;
194        
195        @Child(name="unit", type=StringDt.class, order=2, min=0, max=1, summary=true, modifier=false)   
196        @Description(
197                shortDefinition="",
198                formalDefinition="A human-readable form of the unit"
199        )
200        private StringDt myUnit;
201        
202        @Child(name="system", type=UriDt.class, order=3, min=0, max=1, summary=true, modifier=false)    
203        @Description(
204                shortDefinition="",
205                formalDefinition="The identification of the system that provides the coded form of the unit"
206        )
207        private UriDt mySystem;
208        
209        @Child(name="code", type=CodeDt.class, order=4, min=0, max=1, summary=true, modifier=false)     
210        @Description(
211                shortDefinition="",
212                formalDefinition="A computer processable form of the unit in some unit representation system"
213        )
214        private CodeDt myCode;
215        
216
217        @Override
218        public boolean isEmpty() {
219                return super.isBaseEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(  myValue,  myComparator,  myUnit,  mySystem,  myCode);
220        }
221        
222        @Override
223        public <T extends IElement> List<T> getAllPopulatedChildElementsOfType(Class<T> theType) {
224                return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(theType, myValue, myComparator, myUnit, mySystem, myCode);
225        }
226
227        /**
228         * Gets the value(s) for <b>value</b> ().
229         * creating it if it does
230         * not exist. Will not return <code>null</code>.
231         *
232     * <p>
233     * <b>Definition:</b>
234     * The value of the measured amount. The value includes an implicit precision in the presentation of the value
235     * </p> 
236         */
237        public DecimalDt getValueElement() {  
238                if (myValue == null) {
239                        myValue = new DecimalDt();
240                }
241                return myValue;
242        }
243
244        
245        /**
246         * Gets the value(s) for <b>value</b> ().
247         * creating it if it does
248         * not exist. This method may return <code>null</code>.
249         *
250     * <p>
251     * <b>Definition:</b>
252     * The value of the measured amount. The value includes an implicit precision in the presentation of the value
253     * </p> 
254         */
255        public BigDecimal getValue() {  
256                return getValueElement().getValue();
257        }
258
259        /**
260         * Sets the value(s) for <b>value</b> ()
261         *
262     * <p>
263     * <b>Definition:</b>
264     * The value of the measured amount. The value includes an implicit precision in the presentation of the value
265     * </p> 
266         */
267        public QuantityDt setValue(DecimalDt theValue) {
268                myValue = theValue;
269                return this;
270        }
271        
272        
273
274        /**
275         * Sets the value for <b>value</b> ()
276         *
277     * <p>
278     * <b>Definition:</b>
279     * The value of the measured amount. The value includes an implicit precision in the presentation of the value
280     * </p> 
281         */
282        public QuantityDt setValue( long theValue) {
283                myValue = new DecimalDt(theValue); 
284                return this; 
285        }
286
287        /**
288         * Sets the value for <b>value</b> ()
289         *
290     * <p>
291     * <b>Definition:</b>
292     * The value of the measured amount. The value includes an implicit precision in the presentation of the value
293     * </p> 
294         */
295        public QuantityDt setValue( double theValue) {
296                myValue = new DecimalDt(theValue); 
297                return this; 
298        }
299
300        /**
301         * Sets the value for <b>value</b> ()
302         *
303     * <p>
304     * <b>Definition:</b>
305     * The value of the measured amount. The value includes an implicit precision in the presentation of the value
306     * </p> 
307         */
308        public QuantityDt setValue( java.math.BigDecimal theValue) {
309                myValue = new DecimalDt(theValue); 
310                return this; 
311        }
312
313 
314        /**
315         * Gets the value(s) for <b>comparator</b> ().
316         * creating it if it does
317         * not exist. Will not return <code>null</code>.
318         *
319     * <p>
320     * <b>Definition:</b>
321     * How the value should be understood and represented - whether the actual value is greater or less than the stated value due to measurement issues; e.g. if the comparator is \&quot;&lt;\&quot; , then the real value is &lt; stated value
322     * </p> 
323         */
324        public BoundCodeDt<QuantityComparatorEnum> getComparatorElement() {  
325                if (myComparator == null) {
326                        myComparator = new BoundCodeDt<QuantityComparatorEnum>(QuantityComparatorEnum.VALUESET_BINDER);
327                }
328                return myComparator;
329        }
330
331        
332        /**
333         * Gets the value(s) for <b>comparator</b> ().
334         * creating it if it does
335         * not exist. This method may return <code>null</code>.
336         *
337     * <p>
338     * <b>Definition:</b>
339     * How the value should be understood and represented - whether the actual value is greater or less than the stated value due to measurement issues; e.g. if the comparator is \&quot;&lt;\&quot; , then the real value is &lt; stated value
340     * </p> 
341         */
342        public String getComparator() {  
343                return getComparatorElement().getValue();
344        }
345
346        /**
347         * Sets the value(s) for <b>comparator</b> ()
348         *
349     * <p>
350     * <b>Definition:</b>
351     * How the value should be understood and represented - whether the actual value is greater or less than the stated value due to measurement issues; e.g. if the comparator is \&quot;&lt;\&quot; , then the real value is &lt; stated value
352     * </p> 
353         */
354        public QuantityDt setComparator(BoundCodeDt<QuantityComparatorEnum> theValue) {
355                myComparator = theValue;
356                return this;
357        }
358        
359        
360
361        /**
362         * Sets the value(s) for <b>comparator</b> ()
363         *
364     * <p>
365     * <b>Definition:</b>
366     * How the value should be understood and represented - whether the actual value is greater or less than the stated value due to measurement issues; e.g. if the comparator is \&quot;&lt;\&quot; , then the real value is &lt; stated value
367     * </p> 
368         */
369        public QuantityDt setComparator(QuantityComparatorEnum theValue) {
370                setComparator(new BoundCodeDt<QuantityComparatorEnum>(QuantityComparatorEnum.VALUESET_BINDER, theValue));
371                
372/*
373                getComparatorElement().setValueAsEnum(theValue);
374*/
375                return this;
376        }
377
378  
379        /**
380         * Gets the value(s) for <b>unit</b> ().
381         * creating it if it does
382         * not exist. Will not return <code>null</code>.
383         *
384     * <p>
385     * <b>Definition:</b>
386     * A human-readable form of the unit
387     * </p> 
388         */
389        public StringDt getUnitElement() {  
390                if (myUnit == null) {
391                        myUnit = new StringDt();
392                }
393                return myUnit;
394        }
395
396        
397        /**
398         * Gets the value(s) for <b>unit</b> ().
399         * creating it if it does
400         * not exist. This method may return <code>null</code>.
401         *
402     * <p>
403     * <b>Definition:</b>
404     * A human-readable form of the unit
405     * </p> 
406         */
407        public String getUnit() {  
408                return getUnitElement().getValue();
409        }
410
411        /**
412         * Sets the value(s) for <b>unit</b> ()
413         *
414     * <p>
415     * <b>Definition:</b>
416     * A human-readable form of the unit
417     * </p> 
418         */
419        public QuantityDt setUnit(StringDt theValue) {
420                myUnit = theValue;
421                return this;
422        }
423        
424        
425
426        /**
427         * Sets the value for <b>unit</b> ()
428         *
429     * <p>
430     * <b>Definition:</b>
431     * A human-readable form of the unit
432     * </p> 
433         */
434        public QuantityDt setUnit( String theString) {
435                myUnit = new StringDt(theString); 
436                return this; 
437        }
438
439 
440        /**
441         * Gets the value(s) for <b>system</b> ().
442         * creating it if it does
443         * not exist. Will not return <code>null</code>.
444         *
445     * <p>
446     * <b>Definition:</b>
447     * The identification of the system that provides the coded form of the unit
448     * </p> 
449         */
450        public UriDt getSystemElement() {  
451                if (mySystem == null) {
452                        mySystem = new UriDt();
453                }
454                return mySystem;
455        }
456
457        
458        /**
459         * Gets the value(s) for <b>system</b> ().
460         * creating it if it does
461         * not exist. This method may return <code>null</code>.
462         *
463     * <p>
464     * <b>Definition:</b>
465     * The identification of the system that provides the coded form of the unit
466     * </p> 
467         */
468        public String getSystem() {  
469                return getSystemElement().getValue();
470        }
471
472        /**
473         * Sets the value(s) for <b>system</b> ()
474         *
475     * <p>
476     * <b>Definition:</b>
477     * The identification of the system that provides the coded form of the unit
478     * </p> 
479         */
480        public QuantityDt setSystem(UriDt theValue) {
481                mySystem = theValue;
482                return this;
483        }
484        
485        
486
487        /**
488         * Sets the value for <b>system</b> ()
489         *
490     * <p>
491     * <b>Definition:</b>
492     * The identification of the system that provides the coded form of the unit
493     * </p> 
494         */
495        public QuantityDt setSystem( String theUri) {
496                mySystem = new UriDt(theUri); 
497                return this; 
498        }
499
500 
501        /**
502         * Gets the value(s) for <b>code</b> ().
503         * creating it if it does
504         * not exist. Will not return <code>null</code>.
505         *
506     * <p>
507     * <b>Definition:</b>
508     * A computer processable form of the unit in some unit representation system
509     * </p> 
510         */
511        public CodeDt getCodeElement() {  
512                if (myCode == null) {
513                        myCode = new CodeDt();
514                }
515                return myCode;
516        }
517
518        
519        /**
520         * Gets the value(s) for <b>code</b> ().
521         * creating it if it does
522         * not exist. This method may return <code>null</code>.
523         *
524     * <p>
525     * <b>Definition:</b>
526     * A computer processable form of the unit in some unit representation system
527     * </p> 
528         */
529        public String getCode() {  
530                return getCodeElement().getValue();
531        }
532
533        /**
534         * Sets the value(s) for <b>code</b> ()
535         *
536     * <p>
537     * <b>Definition:</b>
538     * A computer processable form of the unit in some unit representation system
539     * </p> 
540         */
541        public QuantityDt setCode(CodeDt theValue) {
542                myCode = theValue;
543                return this;
544        }
545        
546        
547
548        /**
549         * Sets the value for <b>code</b> ()
550         *
551     * <p>
552     * <b>Definition:</b>
553     * A computer processable form of the unit in some unit representation system
554     * </p> 
555         */
556        public QuantityDt setCode( String theCode) {
557                myCode = new CodeDt(theCode); 
558                return this; 
559        }
560
561 
562
563
564}