001package org.hl7.fhir.dstu3.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Mon, Apr 17, 2017 17:38-0400 for FHIR v3.0.1
033
034import java.util.*;
035
036import org.hl7.fhir.utilities.Utilities;
037import ca.uhn.fhir.model.api.annotation.ResourceDef;
038import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
039import ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.ChildOrder;
041import ca.uhn.fhir.model.api.annotation.Description;
042import ca.uhn.fhir.model.api.annotation.Block;
043import org.hl7.fhir.instance.model.api.*;
044import org.hl7.fhir.exceptions.FHIRException;
045/**
046 * Describes a measurement, calculation or setting capability of a medical device.
047 */
048@ResourceDef(name="DeviceMetric", profile="http://hl7.org/fhir/Profile/DeviceMetric")
049public class DeviceMetric extends DomainResource {
050
051    public enum DeviceMetricOperationalStatus {
052        /**
053         * The DeviceMetric is operating and will generate DeviceObservations.
054         */
055        ON, 
056        /**
057         * The DeviceMetric is not operating.
058         */
059        OFF, 
060        /**
061         * The DeviceMetric is operating, but will not generate any DeviceObservations.
062         */
063        STANDBY, 
064        /**
065         * The DeviceMetric was entered in error.
066         */
067        ENTEREDINERROR, 
068        /**
069         * added to help the parsers with the generic types
070         */
071        NULL;
072        public static DeviceMetricOperationalStatus fromCode(String codeString) throws FHIRException {
073            if (codeString == null || "".equals(codeString))
074                return null;
075        if ("on".equals(codeString))
076          return ON;
077        if ("off".equals(codeString))
078          return OFF;
079        if ("standby".equals(codeString))
080          return STANDBY;
081        if ("entered-in-error".equals(codeString))
082          return ENTEREDINERROR;
083        if (Configuration.isAcceptInvalidEnums())
084          return null;
085        else
086          throw new FHIRException("Unknown DeviceMetricOperationalStatus code '"+codeString+"'");
087        }
088        public String toCode() {
089          switch (this) {
090            case ON: return "on";
091            case OFF: return "off";
092            case STANDBY: return "standby";
093            case ENTEREDINERROR: return "entered-in-error";
094            default: return "?";
095          }
096        }
097        public String getSystem() {
098          switch (this) {
099            case ON: return "http://hl7.org/fhir/metric-operational-status";
100            case OFF: return "http://hl7.org/fhir/metric-operational-status";
101            case STANDBY: return "http://hl7.org/fhir/metric-operational-status";
102            case ENTEREDINERROR: return "http://hl7.org/fhir/metric-operational-status";
103            default: return "?";
104          }
105        }
106        public String getDefinition() {
107          switch (this) {
108            case ON: return "The DeviceMetric is operating and will generate DeviceObservations.";
109            case OFF: return "The DeviceMetric is not operating.";
110            case STANDBY: return "The DeviceMetric is operating, but will not generate any DeviceObservations.";
111            case ENTEREDINERROR: return "The DeviceMetric was entered in error.";
112            default: return "?";
113          }
114        }
115        public String getDisplay() {
116          switch (this) {
117            case ON: return "On";
118            case OFF: return "Off";
119            case STANDBY: return "Standby";
120            case ENTEREDINERROR: return "Entered In Error";
121            default: return "?";
122          }
123        }
124    }
125
126  public static class DeviceMetricOperationalStatusEnumFactory implements EnumFactory<DeviceMetricOperationalStatus> {
127    public DeviceMetricOperationalStatus fromCode(String codeString) throws IllegalArgumentException {
128      if (codeString == null || "".equals(codeString))
129            if (codeString == null || "".equals(codeString))
130                return null;
131        if ("on".equals(codeString))
132          return DeviceMetricOperationalStatus.ON;
133        if ("off".equals(codeString))
134          return DeviceMetricOperationalStatus.OFF;
135        if ("standby".equals(codeString))
136          return DeviceMetricOperationalStatus.STANDBY;
137        if ("entered-in-error".equals(codeString))
138          return DeviceMetricOperationalStatus.ENTEREDINERROR;
139        throw new IllegalArgumentException("Unknown DeviceMetricOperationalStatus code '"+codeString+"'");
140        }
141        public Enumeration<DeviceMetricOperationalStatus> fromType(Base code) throws FHIRException {
142          if (code == null)
143            return null;
144          if (code.isEmpty())
145            return new Enumeration<DeviceMetricOperationalStatus>(this);
146          String codeString = ((PrimitiveType) code).asStringValue();
147          if (codeString == null || "".equals(codeString))
148            return null;
149        if ("on".equals(codeString))
150          return new Enumeration<DeviceMetricOperationalStatus>(this, DeviceMetricOperationalStatus.ON);
151        if ("off".equals(codeString))
152          return new Enumeration<DeviceMetricOperationalStatus>(this, DeviceMetricOperationalStatus.OFF);
153        if ("standby".equals(codeString))
154          return new Enumeration<DeviceMetricOperationalStatus>(this, DeviceMetricOperationalStatus.STANDBY);
155        if ("entered-in-error".equals(codeString))
156          return new Enumeration<DeviceMetricOperationalStatus>(this, DeviceMetricOperationalStatus.ENTEREDINERROR);
157        throw new FHIRException("Unknown DeviceMetricOperationalStatus code '"+codeString+"'");
158        }
159    public String toCode(DeviceMetricOperationalStatus code) {
160      if (code == DeviceMetricOperationalStatus.ON)
161        return "on";
162      if (code == DeviceMetricOperationalStatus.OFF)
163        return "off";
164      if (code == DeviceMetricOperationalStatus.STANDBY)
165        return "standby";
166      if (code == DeviceMetricOperationalStatus.ENTEREDINERROR)
167        return "entered-in-error";
168      return "?";
169      }
170    public String toSystem(DeviceMetricOperationalStatus code) {
171      return code.getSystem();
172      }
173    }
174
175    public enum DeviceMetricColor {
176        /**
177         * Color for representation - black.
178         */
179        BLACK, 
180        /**
181         * Color for representation - red.
182         */
183        RED, 
184        /**
185         * Color for representation - green.
186         */
187        GREEN, 
188        /**
189         * Color for representation - yellow.
190         */
191        YELLOW, 
192        /**
193         * Color for representation - blue.
194         */
195        BLUE, 
196        /**
197         * Color for representation - magenta.
198         */
199        MAGENTA, 
200        /**
201         * Color for representation - cyan.
202         */
203        CYAN, 
204        /**
205         * Color for representation - white.
206         */
207        WHITE, 
208        /**
209         * added to help the parsers with the generic types
210         */
211        NULL;
212        public static DeviceMetricColor fromCode(String codeString) throws FHIRException {
213            if (codeString == null || "".equals(codeString))
214                return null;
215        if ("black".equals(codeString))
216          return BLACK;
217        if ("red".equals(codeString))
218          return RED;
219        if ("green".equals(codeString))
220          return GREEN;
221        if ("yellow".equals(codeString))
222          return YELLOW;
223        if ("blue".equals(codeString))
224          return BLUE;
225        if ("magenta".equals(codeString))
226          return MAGENTA;
227        if ("cyan".equals(codeString))
228          return CYAN;
229        if ("white".equals(codeString))
230          return WHITE;
231        if (Configuration.isAcceptInvalidEnums())
232          return null;
233        else
234          throw new FHIRException("Unknown DeviceMetricColor code '"+codeString+"'");
235        }
236        public String toCode() {
237          switch (this) {
238            case BLACK: return "black";
239            case RED: return "red";
240            case GREEN: return "green";
241            case YELLOW: return "yellow";
242            case BLUE: return "blue";
243            case MAGENTA: return "magenta";
244            case CYAN: return "cyan";
245            case WHITE: return "white";
246            default: return "?";
247          }
248        }
249        public String getSystem() {
250          switch (this) {
251            case BLACK: return "http://hl7.org/fhir/metric-color";
252            case RED: return "http://hl7.org/fhir/metric-color";
253            case GREEN: return "http://hl7.org/fhir/metric-color";
254            case YELLOW: return "http://hl7.org/fhir/metric-color";
255            case BLUE: return "http://hl7.org/fhir/metric-color";
256            case MAGENTA: return "http://hl7.org/fhir/metric-color";
257            case CYAN: return "http://hl7.org/fhir/metric-color";
258            case WHITE: return "http://hl7.org/fhir/metric-color";
259            default: return "?";
260          }
261        }
262        public String getDefinition() {
263          switch (this) {
264            case BLACK: return "Color for representation - black.";
265            case RED: return "Color for representation - red.";
266            case GREEN: return "Color for representation - green.";
267            case YELLOW: return "Color for representation - yellow.";
268            case BLUE: return "Color for representation - blue.";
269            case MAGENTA: return "Color for representation - magenta.";
270            case CYAN: return "Color for representation - cyan.";
271            case WHITE: return "Color for representation - white.";
272            default: return "?";
273          }
274        }
275        public String getDisplay() {
276          switch (this) {
277            case BLACK: return "Color Black";
278            case RED: return "Color Red";
279            case GREEN: return "Color Green";
280            case YELLOW: return "Color Yellow";
281            case BLUE: return "Color Blue";
282            case MAGENTA: return "Color Magenta";
283            case CYAN: return "Color Cyan";
284            case WHITE: return "Color White";
285            default: return "?";
286          }
287        }
288    }
289
290  public static class DeviceMetricColorEnumFactory implements EnumFactory<DeviceMetricColor> {
291    public DeviceMetricColor fromCode(String codeString) throws IllegalArgumentException {
292      if (codeString == null || "".equals(codeString))
293            if (codeString == null || "".equals(codeString))
294                return null;
295        if ("black".equals(codeString))
296          return DeviceMetricColor.BLACK;
297        if ("red".equals(codeString))
298          return DeviceMetricColor.RED;
299        if ("green".equals(codeString))
300          return DeviceMetricColor.GREEN;
301        if ("yellow".equals(codeString))
302          return DeviceMetricColor.YELLOW;
303        if ("blue".equals(codeString))
304          return DeviceMetricColor.BLUE;
305        if ("magenta".equals(codeString))
306          return DeviceMetricColor.MAGENTA;
307        if ("cyan".equals(codeString))
308          return DeviceMetricColor.CYAN;
309        if ("white".equals(codeString))
310          return DeviceMetricColor.WHITE;
311        throw new IllegalArgumentException("Unknown DeviceMetricColor code '"+codeString+"'");
312        }
313        public Enumeration<DeviceMetricColor> fromType(Base code) throws FHIRException {
314          if (code == null)
315            return null;
316          if (code.isEmpty())
317            return new Enumeration<DeviceMetricColor>(this);
318          String codeString = ((PrimitiveType) code).asStringValue();
319          if (codeString == null || "".equals(codeString))
320            return null;
321        if ("black".equals(codeString))
322          return new Enumeration<DeviceMetricColor>(this, DeviceMetricColor.BLACK);
323        if ("red".equals(codeString))
324          return new Enumeration<DeviceMetricColor>(this, DeviceMetricColor.RED);
325        if ("green".equals(codeString))
326          return new Enumeration<DeviceMetricColor>(this, DeviceMetricColor.GREEN);
327        if ("yellow".equals(codeString))
328          return new Enumeration<DeviceMetricColor>(this, DeviceMetricColor.YELLOW);
329        if ("blue".equals(codeString))
330          return new Enumeration<DeviceMetricColor>(this, DeviceMetricColor.BLUE);
331        if ("magenta".equals(codeString))
332          return new Enumeration<DeviceMetricColor>(this, DeviceMetricColor.MAGENTA);
333        if ("cyan".equals(codeString))
334          return new Enumeration<DeviceMetricColor>(this, DeviceMetricColor.CYAN);
335        if ("white".equals(codeString))
336          return new Enumeration<DeviceMetricColor>(this, DeviceMetricColor.WHITE);
337        throw new FHIRException("Unknown DeviceMetricColor code '"+codeString+"'");
338        }
339    public String toCode(DeviceMetricColor code) {
340      if (code == DeviceMetricColor.BLACK)
341        return "black";
342      if (code == DeviceMetricColor.RED)
343        return "red";
344      if (code == DeviceMetricColor.GREEN)
345        return "green";
346      if (code == DeviceMetricColor.YELLOW)
347        return "yellow";
348      if (code == DeviceMetricColor.BLUE)
349        return "blue";
350      if (code == DeviceMetricColor.MAGENTA)
351        return "magenta";
352      if (code == DeviceMetricColor.CYAN)
353        return "cyan";
354      if (code == DeviceMetricColor.WHITE)
355        return "white";
356      return "?";
357      }
358    public String toSystem(DeviceMetricColor code) {
359      return code.getSystem();
360      }
361    }
362
363    public enum DeviceMetricCategory {
364        /**
365         * DeviceObservations generated for this DeviceMetric are measured.
366         */
367        MEASUREMENT, 
368        /**
369         * DeviceObservations generated for this DeviceMetric is a setting that will influence the behavior of the Device.
370         */
371        SETTING, 
372        /**
373         * DeviceObservations generated for this DeviceMetric are calculated.
374         */
375        CALCULATION, 
376        /**
377         * The category of this DeviceMetric is unspecified.
378         */
379        UNSPECIFIED, 
380        /**
381         * added to help the parsers with the generic types
382         */
383        NULL;
384        public static DeviceMetricCategory fromCode(String codeString) throws FHIRException {
385            if (codeString == null || "".equals(codeString))
386                return null;
387        if ("measurement".equals(codeString))
388          return MEASUREMENT;
389        if ("setting".equals(codeString))
390          return SETTING;
391        if ("calculation".equals(codeString))
392          return CALCULATION;
393        if ("unspecified".equals(codeString))
394          return UNSPECIFIED;
395        if (Configuration.isAcceptInvalidEnums())
396          return null;
397        else
398          throw new FHIRException("Unknown DeviceMetricCategory code '"+codeString+"'");
399        }
400        public String toCode() {
401          switch (this) {
402            case MEASUREMENT: return "measurement";
403            case SETTING: return "setting";
404            case CALCULATION: return "calculation";
405            case UNSPECIFIED: return "unspecified";
406            default: return "?";
407          }
408        }
409        public String getSystem() {
410          switch (this) {
411            case MEASUREMENT: return "http://hl7.org/fhir/metric-category";
412            case SETTING: return "http://hl7.org/fhir/metric-category";
413            case CALCULATION: return "http://hl7.org/fhir/metric-category";
414            case UNSPECIFIED: return "http://hl7.org/fhir/metric-category";
415            default: return "?";
416          }
417        }
418        public String getDefinition() {
419          switch (this) {
420            case MEASUREMENT: return "DeviceObservations generated for this DeviceMetric are measured.";
421            case SETTING: return "DeviceObservations generated for this DeviceMetric is a setting that will influence the behavior of the Device.";
422            case CALCULATION: return "DeviceObservations generated for this DeviceMetric are calculated.";
423            case UNSPECIFIED: return "The category of this DeviceMetric is unspecified.";
424            default: return "?";
425          }
426        }
427        public String getDisplay() {
428          switch (this) {
429            case MEASUREMENT: return "Measurement";
430            case SETTING: return "Setting";
431            case CALCULATION: return "Calculation";
432            case UNSPECIFIED: return "Unspecified";
433            default: return "?";
434          }
435        }
436    }
437
438  public static class DeviceMetricCategoryEnumFactory implements EnumFactory<DeviceMetricCategory> {
439    public DeviceMetricCategory fromCode(String codeString) throws IllegalArgumentException {
440      if (codeString == null || "".equals(codeString))
441            if (codeString == null || "".equals(codeString))
442                return null;
443        if ("measurement".equals(codeString))
444          return DeviceMetricCategory.MEASUREMENT;
445        if ("setting".equals(codeString))
446          return DeviceMetricCategory.SETTING;
447        if ("calculation".equals(codeString))
448          return DeviceMetricCategory.CALCULATION;
449        if ("unspecified".equals(codeString))
450          return DeviceMetricCategory.UNSPECIFIED;
451        throw new IllegalArgumentException("Unknown DeviceMetricCategory code '"+codeString+"'");
452        }
453        public Enumeration<DeviceMetricCategory> fromType(Base code) throws FHIRException {
454          if (code == null)
455            return null;
456          if (code.isEmpty())
457            return new Enumeration<DeviceMetricCategory>(this);
458          String codeString = ((PrimitiveType) code).asStringValue();
459          if (codeString == null || "".equals(codeString))
460            return null;
461        if ("measurement".equals(codeString))
462          return new Enumeration<DeviceMetricCategory>(this, DeviceMetricCategory.MEASUREMENT);
463        if ("setting".equals(codeString))
464          return new Enumeration<DeviceMetricCategory>(this, DeviceMetricCategory.SETTING);
465        if ("calculation".equals(codeString))
466          return new Enumeration<DeviceMetricCategory>(this, DeviceMetricCategory.CALCULATION);
467        if ("unspecified".equals(codeString))
468          return new Enumeration<DeviceMetricCategory>(this, DeviceMetricCategory.UNSPECIFIED);
469        throw new FHIRException("Unknown DeviceMetricCategory code '"+codeString+"'");
470        }
471    public String toCode(DeviceMetricCategory code) {
472      if (code == DeviceMetricCategory.MEASUREMENT)
473        return "measurement";
474      if (code == DeviceMetricCategory.SETTING)
475        return "setting";
476      if (code == DeviceMetricCategory.CALCULATION)
477        return "calculation";
478      if (code == DeviceMetricCategory.UNSPECIFIED)
479        return "unspecified";
480      return "?";
481      }
482    public String toSystem(DeviceMetricCategory code) {
483      return code.getSystem();
484      }
485    }
486
487    public enum DeviceMetricCalibrationType {
488        /**
489         * Metric calibration method has not been identified.
490         */
491        UNSPECIFIED, 
492        /**
493         * Offset metric calibration method
494         */
495        OFFSET, 
496        /**
497         * Gain metric calibration method
498         */
499        GAIN, 
500        /**
501         * Two-point metric calibration method
502         */
503        TWOPOINT, 
504        /**
505         * added to help the parsers with the generic types
506         */
507        NULL;
508        public static DeviceMetricCalibrationType fromCode(String codeString) throws FHIRException {
509            if (codeString == null || "".equals(codeString))
510                return null;
511        if ("unspecified".equals(codeString))
512          return UNSPECIFIED;
513        if ("offset".equals(codeString))
514          return OFFSET;
515        if ("gain".equals(codeString))
516          return GAIN;
517        if ("two-point".equals(codeString))
518          return TWOPOINT;
519        if (Configuration.isAcceptInvalidEnums())
520          return null;
521        else
522          throw new FHIRException("Unknown DeviceMetricCalibrationType code '"+codeString+"'");
523        }
524        public String toCode() {
525          switch (this) {
526            case UNSPECIFIED: return "unspecified";
527            case OFFSET: return "offset";
528            case GAIN: return "gain";
529            case TWOPOINT: return "two-point";
530            default: return "?";
531          }
532        }
533        public String getSystem() {
534          switch (this) {
535            case UNSPECIFIED: return "http://hl7.org/fhir/metric-calibration-type";
536            case OFFSET: return "http://hl7.org/fhir/metric-calibration-type";
537            case GAIN: return "http://hl7.org/fhir/metric-calibration-type";
538            case TWOPOINT: return "http://hl7.org/fhir/metric-calibration-type";
539            default: return "?";
540          }
541        }
542        public String getDefinition() {
543          switch (this) {
544            case UNSPECIFIED: return "Metric calibration method has not been identified.";
545            case OFFSET: return "Offset metric calibration method";
546            case GAIN: return "Gain metric calibration method";
547            case TWOPOINT: return "Two-point metric calibration method";
548            default: return "?";
549          }
550        }
551        public String getDisplay() {
552          switch (this) {
553            case UNSPECIFIED: return "Unspecified";
554            case OFFSET: return "Offset";
555            case GAIN: return "Gain";
556            case TWOPOINT: return "Two Point";
557            default: return "?";
558          }
559        }
560    }
561
562  public static class DeviceMetricCalibrationTypeEnumFactory implements EnumFactory<DeviceMetricCalibrationType> {
563    public DeviceMetricCalibrationType fromCode(String codeString) throws IllegalArgumentException {
564      if (codeString == null || "".equals(codeString))
565            if (codeString == null || "".equals(codeString))
566                return null;
567        if ("unspecified".equals(codeString))
568          return DeviceMetricCalibrationType.UNSPECIFIED;
569        if ("offset".equals(codeString))
570          return DeviceMetricCalibrationType.OFFSET;
571        if ("gain".equals(codeString))
572          return DeviceMetricCalibrationType.GAIN;
573        if ("two-point".equals(codeString))
574          return DeviceMetricCalibrationType.TWOPOINT;
575        throw new IllegalArgumentException("Unknown DeviceMetricCalibrationType code '"+codeString+"'");
576        }
577        public Enumeration<DeviceMetricCalibrationType> fromType(Base code) throws FHIRException {
578          if (code == null)
579            return null;
580          if (code.isEmpty())
581            return new Enumeration<DeviceMetricCalibrationType>(this);
582          String codeString = ((PrimitiveType) code).asStringValue();
583          if (codeString == null || "".equals(codeString))
584            return null;
585        if ("unspecified".equals(codeString))
586          return new Enumeration<DeviceMetricCalibrationType>(this, DeviceMetricCalibrationType.UNSPECIFIED);
587        if ("offset".equals(codeString))
588          return new Enumeration<DeviceMetricCalibrationType>(this, DeviceMetricCalibrationType.OFFSET);
589        if ("gain".equals(codeString))
590          return new Enumeration<DeviceMetricCalibrationType>(this, DeviceMetricCalibrationType.GAIN);
591        if ("two-point".equals(codeString))
592          return new Enumeration<DeviceMetricCalibrationType>(this, DeviceMetricCalibrationType.TWOPOINT);
593        throw new FHIRException("Unknown DeviceMetricCalibrationType code '"+codeString+"'");
594        }
595    public String toCode(DeviceMetricCalibrationType code) {
596      if (code == DeviceMetricCalibrationType.UNSPECIFIED)
597        return "unspecified";
598      if (code == DeviceMetricCalibrationType.OFFSET)
599        return "offset";
600      if (code == DeviceMetricCalibrationType.GAIN)
601        return "gain";
602      if (code == DeviceMetricCalibrationType.TWOPOINT)
603        return "two-point";
604      return "?";
605      }
606    public String toSystem(DeviceMetricCalibrationType code) {
607      return code.getSystem();
608      }
609    }
610
611    public enum DeviceMetricCalibrationState {
612        /**
613         * The metric has not been calibrated.
614         */
615        NOTCALIBRATED, 
616        /**
617         * The metric needs to be calibrated.
618         */
619        CALIBRATIONREQUIRED, 
620        /**
621         * The metric has been calibrated.
622         */
623        CALIBRATED, 
624        /**
625         * The state of calibration of this metric is unspecified.
626         */
627        UNSPECIFIED, 
628        /**
629         * added to help the parsers with the generic types
630         */
631        NULL;
632        public static DeviceMetricCalibrationState fromCode(String codeString) throws FHIRException {
633            if (codeString == null || "".equals(codeString))
634                return null;
635        if ("not-calibrated".equals(codeString))
636          return NOTCALIBRATED;
637        if ("calibration-required".equals(codeString))
638          return CALIBRATIONREQUIRED;
639        if ("calibrated".equals(codeString))
640          return CALIBRATED;
641        if ("unspecified".equals(codeString))
642          return UNSPECIFIED;
643        if (Configuration.isAcceptInvalidEnums())
644          return null;
645        else
646          throw new FHIRException("Unknown DeviceMetricCalibrationState code '"+codeString+"'");
647        }
648        public String toCode() {
649          switch (this) {
650            case NOTCALIBRATED: return "not-calibrated";
651            case CALIBRATIONREQUIRED: return "calibration-required";
652            case CALIBRATED: return "calibrated";
653            case UNSPECIFIED: return "unspecified";
654            default: return "?";
655          }
656        }
657        public String getSystem() {
658          switch (this) {
659            case NOTCALIBRATED: return "http://hl7.org/fhir/metric-calibration-state";
660            case CALIBRATIONREQUIRED: return "http://hl7.org/fhir/metric-calibration-state";
661            case CALIBRATED: return "http://hl7.org/fhir/metric-calibration-state";
662            case UNSPECIFIED: return "http://hl7.org/fhir/metric-calibration-state";
663            default: return "?";
664          }
665        }
666        public String getDefinition() {
667          switch (this) {
668            case NOTCALIBRATED: return "The metric has not been calibrated.";
669            case CALIBRATIONREQUIRED: return "The metric needs to be calibrated.";
670            case CALIBRATED: return "The metric has been calibrated.";
671            case UNSPECIFIED: return "The state of calibration of this metric is unspecified.";
672            default: return "?";
673          }
674        }
675        public String getDisplay() {
676          switch (this) {
677            case NOTCALIBRATED: return "Not Calibrated";
678            case CALIBRATIONREQUIRED: return "Calibration Required";
679            case CALIBRATED: return "Calibrated";
680            case UNSPECIFIED: return "Unspecified";
681            default: return "?";
682          }
683        }
684    }
685
686  public static class DeviceMetricCalibrationStateEnumFactory implements EnumFactory<DeviceMetricCalibrationState> {
687    public DeviceMetricCalibrationState fromCode(String codeString) throws IllegalArgumentException {
688      if (codeString == null || "".equals(codeString))
689            if (codeString == null || "".equals(codeString))
690                return null;
691        if ("not-calibrated".equals(codeString))
692          return DeviceMetricCalibrationState.NOTCALIBRATED;
693        if ("calibration-required".equals(codeString))
694          return DeviceMetricCalibrationState.CALIBRATIONREQUIRED;
695        if ("calibrated".equals(codeString))
696          return DeviceMetricCalibrationState.CALIBRATED;
697        if ("unspecified".equals(codeString))
698          return DeviceMetricCalibrationState.UNSPECIFIED;
699        throw new IllegalArgumentException("Unknown DeviceMetricCalibrationState code '"+codeString+"'");
700        }
701        public Enumeration<DeviceMetricCalibrationState> fromType(Base code) throws FHIRException {
702          if (code == null)
703            return null;
704          if (code.isEmpty())
705            return new Enumeration<DeviceMetricCalibrationState>(this);
706          String codeString = ((PrimitiveType) code).asStringValue();
707          if (codeString == null || "".equals(codeString))
708            return null;
709        if ("not-calibrated".equals(codeString))
710          return new Enumeration<DeviceMetricCalibrationState>(this, DeviceMetricCalibrationState.NOTCALIBRATED);
711        if ("calibration-required".equals(codeString))
712          return new Enumeration<DeviceMetricCalibrationState>(this, DeviceMetricCalibrationState.CALIBRATIONREQUIRED);
713        if ("calibrated".equals(codeString))
714          return new Enumeration<DeviceMetricCalibrationState>(this, DeviceMetricCalibrationState.CALIBRATED);
715        if ("unspecified".equals(codeString))
716          return new Enumeration<DeviceMetricCalibrationState>(this, DeviceMetricCalibrationState.UNSPECIFIED);
717        throw new FHIRException("Unknown DeviceMetricCalibrationState code '"+codeString+"'");
718        }
719    public String toCode(DeviceMetricCalibrationState code) {
720      if (code == DeviceMetricCalibrationState.NOTCALIBRATED)
721        return "not-calibrated";
722      if (code == DeviceMetricCalibrationState.CALIBRATIONREQUIRED)
723        return "calibration-required";
724      if (code == DeviceMetricCalibrationState.CALIBRATED)
725        return "calibrated";
726      if (code == DeviceMetricCalibrationState.UNSPECIFIED)
727        return "unspecified";
728      return "?";
729      }
730    public String toSystem(DeviceMetricCalibrationState code) {
731      return code.getSystem();
732      }
733    }
734
735    @Block()
736    public static class DeviceMetricCalibrationComponent extends BackboneElement implements IBaseBackboneElement {
737        /**
738         * Describes the type of the calibration method.
739         */
740        @Child(name = "type", type = {CodeType.class}, order=1, min=0, max=1, modifier=false, summary=true)
741        @Description(shortDefinition="unspecified | offset | gain | two-point", formalDefinition="Describes the type of the calibration method." )
742        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/metric-calibration-type")
743        protected Enumeration<DeviceMetricCalibrationType> type;
744
745        /**
746         * Describes the state of the calibration.
747         */
748        @Child(name = "state", type = {CodeType.class}, order=2, min=0, max=1, modifier=false, summary=true)
749        @Description(shortDefinition="not-calibrated | calibration-required | calibrated | unspecified", formalDefinition="Describes the state of the calibration." )
750        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/metric-calibration-state")
751        protected Enumeration<DeviceMetricCalibrationState> state;
752
753        /**
754         * Describes the time last calibration has been performed.
755         */
756        @Child(name = "time", type = {InstantType.class}, order=3, min=0, max=1, modifier=false, summary=true)
757        @Description(shortDefinition="Describes the time last calibration has been performed", formalDefinition="Describes the time last calibration has been performed." )
758        protected InstantType time;
759
760        private static final long serialVersionUID = 1163986578L;
761
762    /**
763     * Constructor
764     */
765      public DeviceMetricCalibrationComponent() {
766        super();
767      }
768
769        /**
770         * @return {@link #type} (Describes the type of the calibration method.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
771         */
772        public Enumeration<DeviceMetricCalibrationType> getTypeElement() { 
773          if (this.type == null)
774            if (Configuration.errorOnAutoCreate())
775              throw new Error("Attempt to auto-create DeviceMetricCalibrationComponent.type");
776            else if (Configuration.doAutoCreate())
777              this.type = new Enumeration<DeviceMetricCalibrationType>(new DeviceMetricCalibrationTypeEnumFactory()); // bb
778          return this.type;
779        }
780
781        public boolean hasTypeElement() { 
782          return this.type != null && !this.type.isEmpty();
783        }
784
785        public boolean hasType() { 
786          return this.type != null && !this.type.isEmpty();
787        }
788
789        /**
790         * @param value {@link #type} (Describes the type of the calibration method.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
791         */
792        public DeviceMetricCalibrationComponent setTypeElement(Enumeration<DeviceMetricCalibrationType> value) { 
793          this.type = value;
794          return this;
795        }
796
797        /**
798         * @return Describes the type of the calibration method.
799         */
800        public DeviceMetricCalibrationType getType() { 
801          return this.type == null ? null : this.type.getValue();
802        }
803
804        /**
805         * @param value Describes the type of the calibration method.
806         */
807        public DeviceMetricCalibrationComponent setType(DeviceMetricCalibrationType value) { 
808          if (value == null)
809            this.type = null;
810          else {
811            if (this.type == null)
812              this.type = new Enumeration<DeviceMetricCalibrationType>(new DeviceMetricCalibrationTypeEnumFactory());
813            this.type.setValue(value);
814          }
815          return this;
816        }
817
818        /**
819         * @return {@link #state} (Describes the state of the calibration.). This is the underlying object with id, value and extensions. The accessor "getState" gives direct access to the value
820         */
821        public Enumeration<DeviceMetricCalibrationState> getStateElement() { 
822          if (this.state == null)
823            if (Configuration.errorOnAutoCreate())
824              throw new Error("Attempt to auto-create DeviceMetricCalibrationComponent.state");
825            else if (Configuration.doAutoCreate())
826              this.state = new Enumeration<DeviceMetricCalibrationState>(new DeviceMetricCalibrationStateEnumFactory()); // bb
827          return this.state;
828        }
829
830        public boolean hasStateElement() { 
831          return this.state != null && !this.state.isEmpty();
832        }
833
834        public boolean hasState() { 
835          return this.state != null && !this.state.isEmpty();
836        }
837
838        /**
839         * @param value {@link #state} (Describes the state of the calibration.). This is the underlying object with id, value and extensions. The accessor "getState" gives direct access to the value
840         */
841        public DeviceMetricCalibrationComponent setStateElement(Enumeration<DeviceMetricCalibrationState> value) { 
842          this.state = value;
843          return this;
844        }
845
846        /**
847         * @return Describes the state of the calibration.
848         */
849        public DeviceMetricCalibrationState getState() { 
850          return this.state == null ? null : this.state.getValue();
851        }
852
853        /**
854         * @param value Describes the state of the calibration.
855         */
856        public DeviceMetricCalibrationComponent setState(DeviceMetricCalibrationState value) { 
857          if (value == null)
858            this.state = null;
859          else {
860            if (this.state == null)
861              this.state = new Enumeration<DeviceMetricCalibrationState>(new DeviceMetricCalibrationStateEnumFactory());
862            this.state.setValue(value);
863          }
864          return this;
865        }
866
867        /**
868         * @return {@link #time} (Describes the time last calibration has been performed.). This is the underlying object with id, value and extensions. The accessor "getTime" gives direct access to the value
869         */
870        public InstantType getTimeElement() { 
871          if (this.time == null)
872            if (Configuration.errorOnAutoCreate())
873              throw new Error("Attempt to auto-create DeviceMetricCalibrationComponent.time");
874            else if (Configuration.doAutoCreate())
875              this.time = new InstantType(); // bb
876          return this.time;
877        }
878
879        public boolean hasTimeElement() { 
880          return this.time != null && !this.time.isEmpty();
881        }
882
883        public boolean hasTime() { 
884          return this.time != null && !this.time.isEmpty();
885        }
886
887        /**
888         * @param value {@link #time} (Describes the time last calibration has been performed.). This is the underlying object with id, value and extensions. The accessor "getTime" gives direct access to the value
889         */
890        public DeviceMetricCalibrationComponent setTimeElement(InstantType value) { 
891          this.time = value;
892          return this;
893        }
894
895        /**
896         * @return Describes the time last calibration has been performed.
897         */
898        public Date getTime() { 
899          return this.time == null ? null : this.time.getValue();
900        }
901
902        /**
903         * @param value Describes the time last calibration has been performed.
904         */
905        public DeviceMetricCalibrationComponent setTime(Date value) { 
906          if (value == null)
907            this.time = null;
908          else {
909            if (this.time == null)
910              this.time = new InstantType();
911            this.time.setValue(value);
912          }
913          return this;
914        }
915
916        protected void listChildren(List<Property> childrenList) {
917          super.listChildren(childrenList);
918          childrenList.add(new Property("type", "code", "Describes the type of the calibration method.", 0, java.lang.Integer.MAX_VALUE, type));
919          childrenList.add(new Property("state", "code", "Describes the state of the calibration.", 0, java.lang.Integer.MAX_VALUE, state));
920          childrenList.add(new Property("time", "instant", "Describes the time last calibration has been performed.", 0, java.lang.Integer.MAX_VALUE, time));
921        }
922
923      @Override
924      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
925        switch (hash) {
926        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // Enumeration<DeviceMetricCalibrationType>
927        case 109757585: /*state*/ return this.state == null ? new Base[0] : new Base[] {this.state}; // Enumeration<DeviceMetricCalibrationState>
928        case 3560141: /*time*/ return this.time == null ? new Base[0] : new Base[] {this.time}; // InstantType
929        default: return super.getProperty(hash, name, checkValid);
930        }
931
932      }
933
934      @Override
935      public Base setProperty(int hash, String name, Base value) throws FHIRException {
936        switch (hash) {
937        case 3575610: // type
938          value = new DeviceMetricCalibrationTypeEnumFactory().fromType(castToCode(value));
939          this.type = (Enumeration) value; // Enumeration<DeviceMetricCalibrationType>
940          return value;
941        case 109757585: // state
942          value = new DeviceMetricCalibrationStateEnumFactory().fromType(castToCode(value));
943          this.state = (Enumeration) value; // Enumeration<DeviceMetricCalibrationState>
944          return value;
945        case 3560141: // time
946          this.time = castToInstant(value); // InstantType
947          return value;
948        default: return super.setProperty(hash, name, value);
949        }
950
951      }
952
953      @Override
954      public Base setProperty(String name, Base value) throws FHIRException {
955        if (name.equals("type")) {
956          value = new DeviceMetricCalibrationTypeEnumFactory().fromType(castToCode(value));
957          this.type = (Enumeration) value; // Enumeration<DeviceMetricCalibrationType>
958        } else if (name.equals("state")) {
959          value = new DeviceMetricCalibrationStateEnumFactory().fromType(castToCode(value));
960          this.state = (Enumeration) value; // Enumeration<DeviceMetricCalibrationState>
961        } else if (name.equals("time")) {
962          this.time = castToInstant(value); // InstantType
963        } else
964          return super.setProperty(name, value);
965        return value;
966      }
967
968      @Override
969      public Base makeProperty(int hash, String name) throws FHIRException {
970        switch (hash) {
971        case 3575610:  return getTypeElement();
972        case 109757585:  return getStateElement();
973        case 3560141:  return getTimeElement();
974        default: return super.makeProperty(hash, name);
975        }
976
977      }
978
979      @Override
980      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
981        switch (hash) {
982        case 3575610: /*type*/ return new String[] {"code"};
983        case 109757585: /*state*/ return new String[] {"code"};
984        case 3560141: /*time*/ return new String[] {"instant"};
985        default: return super.getTypesForProperty(hash, name);
986        }
987
988      }
989
990      @Override
991      public Base addChild(String name) throws FHIRException {
992        if (name.equals("type")) {
993          throw new FHIRException("Cannot call addChild on a primitive type DeviceMetric.type");
994        }
995        else if (name.equals("state")) {
996          throw new FHIRException("Cannot call addChild on a primitive type DeviceMetric.state");
997        }
998        else if (name.equals("time")) {
999          throw new FHIRException("Cannot call addChild on a primitive type DeviceMetric.time");
1000        }
1001        else
1002          return super.addChild(name);
1003      }
1004
1005      public DeviceMetricCalibrationComponent copy() {
1006        DeviceMetricCalibrationComponent dst = new DeviceMetricCalibrationComponent();
1007        copyValues(dst);
1008        dst.type = type == null ? null : type.copy();
1009        dst.state = state == null ? null : state.copy();
1010        dst.time = time == null ? null : time.copy();
1011        return dst;
1012      }
1013
1014      @Override
1015      public boolean equalsDeep(Base other) {
1016        if (!super.equalsDeep(other))
1017          return false;
1018        if (!(other instanceof DeviceMetricCalibrationComponent))
1019          return false;
1020        DeviceMetricCalibrationComponent o = (DeviceMetricCalibrationComponent) other;
1021        return compareDeep(type, o.type, true) && compareDeep(state, o.state, true) && compareDeep(time, o.time, true)
1022          ;
1023      }
1024
1025      @Override
1026      public boolean equalsShallow(Base other) {
1027        if (!super.equalsShallow(other))
1028          return false;
1029        if (!(other instanceof DeviceMetricCalibrationComponent))
1030          return false;
1031        DeviceMetricCalibrationComponent o = (DeviceMetricCalibrationComponent) other;
1032        return compareValues(type, o.type, true) && compareValues(state, o.state, true) && compareValues(time, o.time, true)
1033          ;
1034      }
1035
1036      public boolean isEmpty() {
1037        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, state, time);
1038      }
1039
1040  public String fhirType() {
1041    return "DeviceMetric.calibration";
1042
1043  }
1044
1045  }
1046
1047    /**
1048     * Describes the unique identification of this metric that has been assigned by the device or gateway software. For example: handle ID.  It should be noted that in order to make the identifier unique, the system element of the identifier should be set to the unique identifier of the device.
1049     */
1050    @Child(name = "identifier", type = {Identifier.class}, order=0, min=1, max=1, modifier=false, summary=true)
1051    @Description(shortDefinition="Unique identifier of this DeviceMetric", formalDefinition="Describes the unique identification of this metric that has been assigned by the device or gateway software. For example: handle ID.  It should be noted that in order to make the identifier unique, the system element of the identifier should be set to the unique identifier of the device." )
1052    protected Identifier identifier;
1053
1054    /**
1055     * Describes the type of the metric. For example: Heart Rate, PEEP Setting, etc.
1056     */
1057    @Child(name = "type", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=true)
1058    @Description(shortDefinition="Identity of metric, for example Heart Rate or PEEP Setting", formalDefinition="Describes the type of the metric. For example: Heart Rate, PEEP Setting, etc." )
1059    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/devicemetric-type")
1060    protected CodeableConcept type;
1061
1062    /**
1063     * Describes the unit that an observed value determined for this metric will have. For example: Percent, Seconds, etc.
1064     */
1065    @Child(name = "unit", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
1066    @Description(shortDefinition="Unit of Measure for the Metric", formalDefinition="Describes the unit that an observed value determined for this metric will have. For example: Percent, Seconds, etc." )
1067    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/devicemetric-type")
1068    protected CodeableConcept unit;
1069
1070    /**
1071     * Describes the link to the  Device that this DeviceMetric belongs to and that contains administrative device information such as manufacturer, serial number, etc.
1072     */
1073    @Child(name = "source", type = {Device.class}, order=3, min=0, max=1, modifier=false, summary=true)
1074    @Description(shortDefinition="Describes the link to the source Device", formalDefinition="Describes the link to the  Device that this DeviceMetric belongs to and that contains administrative device information such as manufacturer, serial number, etc." )
1075    protected Reference source;
1076
1077    /**
1078     * The actual object that is the target of the reference (Describes the link to the  Device that this DeviceMetric belongs to and that contains administrative device information such as manufacturer, serial number, etc.)
1079     */
1080    protected Device sourceTarget;
1081
1082    /**
1083     * Describes the link to the  DeviceComponent that this DeviceMetric belongs to and that provide information about the location of this DeviceMetric in the containment structure of the parent Device. An example would be a DeviceComponent that represents a Channel. This reference can be used by a client application to distinguish DeviceMetrics that have the same type, but should be interpreted based on their containment location.
1084     */
1085    @Child(name = "parent", type = {DeviceComponent.class}, order=4, min=0, max=1, modifier=false, summary=true)
1086    @Description(shortDefinition="Describes the link to the parent DeviceComponent", formalDefinition="Describes the link to the  DeviceComponent that this DeviceMetric belongs to and that provide information about the location of this DeviceMetric in the containment structure of the parent Device. An example would be a DeviceComponent that represents a Channel. This reference can be used by a client application to distinguish DeviceMetrics that have the same type, but should be interpreted based on their containment location." )
1087    protected Reference parent;
1088
1089    /**
1090     * The actual object that is the target of the reference (Describes the link to the  DeviceComponent that this DeviceMetric belongs to and that provide information about the location of this DeviceMetric in the containment structure of the parent Device. An example would be a DeviceComponent that represents a Channel. This reference can be used by a client application to distinguish DeviceMetrics that have the same type, but should be interpreted based on their containment location.)
1091     */
1092    protected DeviceComponent parentTarget;
1093
1094    /**
1095     * Indicates current operational state of the device. For example: On, Off, Standby, etc.
1096     */
1097    @Child(name = "operationalStatus", type = {CodeType.class}, order=5, min=0, max=1, modifier=false, summary=true)
1098    @Description(shortDefinition="on | off | standby | entered-in-error", formalDefinition="Indicates current operational state of the device. For example: On, Off, Standby, etc." )
1099    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/metric-operational-status")
1100    protected Enumeration<DeviceMetricOperationalStatus> operationalStatus;
1101
1102    /**
1103     * Describes the color representation for the metric. This is often used to aid clinicians to track and identify parameter types by color. In practice, consider a Patient Monitor that has ECG/HR and Pleth for example; the parameters are displayed in different characteristic colors, such as HR-blue, BP-green, and PR and SpO2- magenta.
1104     */
1105    @Child(name = "color", type = {CodeType.class}, order=6, min=0, max=1, modifier=false, summary=true)
1106    @Description(shortDefinition="black | red | green | yellow | blue | magenta | cyan | white", formalDefinition="Describes the color representation for the metric. This is often used to aid clinicians to track and identify parameter types by color. In practice, consider a Patient Monitor that has ECG/HR and Pleth for example; the parameters are displayed in different characteristic colors, such as HR-blue, BP-green, and PR and SpO2- magenta." )
1107    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/metric-color")
1108    protected Enumeration<DeviceMetricColor> color;
1109
1110    /**
1111     * Indicates the category of the observation generation process. A DeviceMetric can be for example a setting, measurement, or calculation.
1112     */
1113    @Child(name = "category", type = {CodeType.class}, order=7, min=1, max=1, modifier=false, summary=true)
1114    @Description(shortDefinition="measurement | setting | calculation | unspecified", formalDefinition="Indicates the category of the observation generation process. A DeviceMetric can be for example a setting, measurement, or calculation." )
1115    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/metric-category")
1116    protected Enumeration<DeviceMetricCategory> category;
1117
1118    /**
1119     * Describes the measurement repetition time. This is not necessarily the same as the update period. The measurement repetition time can range from milliseconds up to hours. An example for a measurement repetition time in the range of milliseconds is the sampling rate of an ECG. An example for a measurement repetition time in the range of hours is a NIBP that is triggered automatically every hour. The update period may be different than the measurement repetition time, if the device does not update the published observed value with the same frequency as it was measured.
1120     */
1121    @Child(name = "measurementPeriod", type = {Timing.class}, order=8, min=0, max=1, modifier=false, summary=true)
1122    @Description(shortDefinition="Describes the measurement repetition time", formalDefinition="Describes the measurement repetition time. This is not necessarily the same as the update period. The measurement repetition time can range from milliseconds up to hours. An example for a measurement repetition time in the range of milliseconds is the sampling rate of an ECG. An example for a measurement repetition time in the range of hours is a NIBP that is triggered automatically every hour. The update period may be different than the measurement repetition time, if the device does not update the published observed value with the same frequency as it was measured." )
1123    protected Timing measurementPeriod;
1124
1125    /**
1126     * Describes the calibrations that have been performed or that are required to be performed.
1127     */
1128    @Child(name = "calibration", type = {}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1129    @Description(shortDefinition="Describes the calibrations that have been performed or that are required to be performed", formalDefinition="Describes the calibrations that have been performed or that are required to be performed." )
1130    protected List<DeviceMetricCalibrationComponent> calibration;
1131
1132    private static final long serialVersionUID = -380567474L;
1133
1134  /**
1135   * Constructor
1136   */
1137    public DeviceMetric() {
1138      super();
1139    }
1140
1141  /**
1142   * Constructor
1143   */
1144    public DeviceMetric(Identifier identifier, CodeableConcept type, Enumeration<DeviceMetricCategory> category) {
1145      super();
1146      this.identifier = identifier;
1147      this.type = type;
1148      this.category = category;
1149    }
1150
1151    /**
1152     * @return {@link #identifier} (Describes the unique identification of this metric that has been assigned by the device or gateway software. For example: handle ID.  It should be noted that in order to make the identifier unique, the system element of the identifier should be set to the unique identifier of the device.)
1153     */
1154    public Identifier getIdentifier() { 
1155      if (this.identifier == null)
1156        if (Configuration.errorOnAutoCreate())
1157          throw new Error("Attempt to auto-create DeviceMetric.identifier");
1158        else if (Configuration.doAutoCreate())
1159          this.identifier = new Identifier(); // cc
1160      return this.identifier;
1161    }
1162
1163    public boolean hasIdentifier() { 
1164      return this.identifier != null && !this.identifier.isEmpty();
1165    }
1166
1167    /**
1168     * @param value {@link #identifier} (Describes the unique identification of this metric that has been assigned by the device or gateway software. For example: handle ID.  It should be noted that in order to make the identifier unique, the system element of the identifier should be set to the unique identifier of the device.)
1169     */
1170    public DeviceMetric setIdentifier(Identifier value) { 
1171      this.identifier = value;
1172      return this;
1173    }
1174
1175    /**
1176     * @return {@link #type} (Describes the type of the metric. For example: Heart Rate, PEEP Setting, etc.)
1177     */
1178    public CodeableConcept getType() { 
1179      if (this.type == null)
1180        if (Configuration.errorOnAutoCreate())
1181          throw new Error("Attempt to auto-create DeviceMetric.type");
1182        else if (Configuration.doAutoCreate())
1183          this.type = new CodeableConcept(); // cc
1184      return this.type;
1185    }
1186
1187    public boolean hasType() { 
1188      return this.type != null && !this.type.isEmpty();
1189    }
1190
1191    /**
1192     * @param value {@link #type} (Describes the type of the metric. For example: Heart Rate, PEEP Setting, etc.)
1193     */
1194    public DeviceMetric setType(CodeableConcept value) { 
1195      this.type = value;
1196      return this;
1197    }
1198
1199    /**
1200     * @return {@link #unit} (Describes the unit that an observed value determined for this metric will have. For example: Percent, Seconds, etc.)
1201     */
1202    public CodeableConcept getUnit() { 
1203      if (this.unit == null)
1204        if (Configuration.errorOnAutoCreate())
1205          throw new Error("Attempt to auto-create DeviceMetric.unit");
1206        else if (Configuration.doAutoCreate())
1207          this.unit = new CodeableConcept(); // cc
1208      return this.unit;
1209    }
1210
1211    public boolean hasUnit() { 
1212      return this.unit != null && !this.unit.isEmpty();
1213    }
1214
1215    /**
1216     * @param value {@link #unit} (Describes the unit that an observed value determined for this metric will have. For example: Percent, Seconds, etc.)
1217     */
1218    public DeviceMetric setUnit(CodeableConcept value) { 
1219      this.unit = value;
1220      return this;
1221    }
1222
1223    /**
1224     * @return {@link #source} (Describes the link to the  Device that this DeviceMetric belongs to and that contains administrative device information such as manufacturer, serial number, etc.)
1225     */
1226    public Reference getSource() { 
1227      if (this.source == null)
1228        if (Configuration.errorOnAutoCreate())
1229          throw new Error("Attempt to auto-create DeviceMetric.source");
1230        else if (Configuration.doAutoCreate())
1231          this.source = new Reference(); // cc
1232      return this.source;
1233    }
1234
1235    public boolean hasSource() { 
1236      return this.source != null && !this.source.isEmpty();
1237    }
1238
1239    /**
1240     * @param value {@link #source} (Describes the link to the  Device that this DeviceMetric belongs to and that contains administrative device information such as manufacturer, serial number, etc.)
1241     */
1242    public DeviceMetric setSource(Reference value) { 
1243      this.source = value;
1244      return this;
1245    }
1246
1247    /**
1248     * @return {@link #source} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Describes the link to the  Device that this DeviceMetric belongs to and that contains administrative device information such as manufacturer, serial number, etc.)
1249     */
1250    public Device getSourceTarget() { 
1251      if (this.sourceTarget == null)
1252        if (Configuration.errorOnAutoCreate())
1253          throw new Error("Attempt to auto-create DeviceMetric.source");
1254        else if (Configuration.doAutoCreate())
1255          this.sourceTarget = new Device(); // aa
1256      return this.sourceTarget;
1257    }
1258
1259    /**
1260     * @param value {@link #source} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Describes the link to the  Device that this DeviceMetric belongs to and that contains administrative device information such as manufacturer, serial number, etc.)
1261     */
1262    public DeviceMetric setSourceTarget(Device value) { 
1263      this.sourceTarget = value;
1264      return this;
1265    }
1266
1267    /**
1268     * @return {@link #parent} (Describes the link to the  DeviceComponent that this DeviceMetric belongs to and that provide information about the location of this DeviceMetric in the containment structure of the parent Device. An example would be a DeviceComponent that represents a Channel. This reference can be used by a client application to distinguish DeviceMetrics that have the same type, but should be interpreted based on their containment location.)
1269     */
1270    public Reference getParent() { 
1271      if (this.parent == null)
1272        if (Configuration.errorOnAutoCreate())
1273          throw new Error("Attempt to auto-create DeviceMetric.parent");
1274        else if (Configuration.doAutoCreate())
1275          this.parent = new Reference(); // cc
1276      return this.parent;
1277    }
1278
1279    public boolean hasParent() { 
1280      return this.parent != null && !this.parent.isEmpty();
1281    }
1282
1283    /**
1284     * @param value {@link #parent} (Describes the link to the  DeviceComponent that this DeviceMetric belongs to and that provide information about the location of this DeviceMetric in the containment structure of the parent Device. An example would be a DeviceComponent that represents a Channel. This reference can be used by a client application to distinguish DeviceMetrics that have the same type, but should be interpreted based on their containment location.)
1285     */
1286    public DeviceMetric setParent(Reference value) { 
1287      this.parent = value;
1288      return this;
1289    }
1290
1291    /**
1292     * @return {@link #parent} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Describes the link to the  DeviceComponent that this DeviceMetric belongs to and that provide information about the location of this DeviceMetric in the containment structure of the parent Device. An example would be a DeviceComponent that represents a Channel. This reference can be used by a client application to distinguish DeviceMetrics that have the same type, but should be interpreted based on their containment location.)
1293     */
1294    public DeviceComponent getParentTarget() { 
1295      if (this.parentTarget == null)
1296        if (Configuration.errorOnAutoCreate())
1297          throw new Error("Attempt to auto-create DeviceMetric.parent");
1298        else if (Configuration.doAutoCreate())
1299          this.parentTarget = new DeviceComponent(); // aa
1300      return this.parentTarget;
1301    }
1302
1303    /**
1304     * @param value {@link #parent} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Describes the link to the  DeviceComponent that this DeviceMetric belongs to and that provide information about the location of this DeviceMetric in the containment structure of the parent Device. An example would be a DeviceComponent that represents a Channel. This reference can be used by a client application to distinguish DeviceMetrics that have the same type, but should be interpreted based on their containment location.)
1305     */
1306    public DeviceMetric setParentTarget(DeviceComponent value) { 
1307      this.parentTarget = value;
1308      return this;
1309    }
1310
1311    /**
1312     * @return {@link #operationalStatus} (Indicates current operational state of the device. For example: On, Off, Standby, etc.). This is the underlying object with id, value and extensions. The accessor "getOperationalStatus" gives direct access to the value
1313     */
1314    public Enumeration<DeviceMetricOperationalStatus> getOperationalStatusElement() { 
1315      if (this.operationalStatus == null)
1316        if (Configuration.errorOnAutoCreate())
1317          throw new Error("Attempt to auto-create DeviceMetric.operationalStatus");
1318        else if (Configuration.doAutoCreate())
1319          this.operationalStatus = new Enumeration<DeviceMetricOperationalStatus>(new DeviceMetricOperationalStatusEnumFactory()); // bb
1320      return this.operationalStatus;
1321    }
1322
1323    public boolean hasOperationalStatusElement() { 
1324      return this.operationalStatus != null && !this.operationalStatus.isEmpty();
1325    }
1326
1327    public boolean hasOperationalStatus() { 
1328      return this.operationalStatus != null && !this.operationalStatus.isEmpty();
1329    }
1330
1331    /**
1332     * @param value {@link #operationalStatus} (Indicates current operational state of the device. For example: On, Off, Standby, etc.). This is the underlying object with id, value and extensions. The accessor "getOperationalStatus" gives direct access to the value
1333     */
1334    public DeviceMetric setOperationalStatusElement(Enumeration<DeviceMetricOperationalStatus> value) { 
1335      this.operationalStatus = value;
1336      return this;
1337    }
1338
1339    /**
1340     * @return Indicates current operational state of the device. For example: On, Off, Standby, etc.
1341     */
1342    public DeviceMetricOperationalStatus getOperationalStatus() { 
1343      return this.operationalStatus == null ? null : this.operationalStatus.getValue();
1344    }
1345
1346    /**
1347     * @param value Indicates current operational state of the device. For example: On, Off, Standby, etc.
1348     */
1349    public DeviceMetric setOperationalStatus(DeviceMetricOperationalStatus value) { 
1350      if (value == null)
1351        this.operationalStatus = null;
1352      else {
1353        if (this.operationalStatus == null)
1354          this.operationalStatus = new Enumeration<DeviceMetricOperationalStatus>(new DeviceMetricOperationalStatusEnumFactory());
1355        this.operationalStatus.setValue(value);
1356      }
1357      return this;
1358    }
1359
1360    /**
1361     * @return {@link #color} (Describes the color representation for the metric. This is often used to aid clinicians to track and identify parameter types by color. In practice, consider a Patient Monitor that has ECG/HR and Pleth for example; the parameters are displayed in different characteristic colors, such as HR-blue, BP-green, and PR and SpO2- magenta.). This is the underlying object with id, value and extensions. The accessor "getColor" gives direct access to the value
1362     */
1363    public Enumeration<DeviceMetricColor> getColorElement() { 
1364      if (this.color == null)
1365        if (Configuration.errorOnAutoCreate())
1366          throw new Error("Attempt to auto-create DeviceMetric.color");
1367        else if (Configuration.doAutoCreate())
1368          this.color = new Enumeration<DeviceMetricColor>(new DeviceMetricColorEnumFactory()); // bb
1369      return this.color;
1370    }
1371
1372    public boolean hasColorElement() { 
1373      return this.color != null && !this.color.isEmpty();
1374    }
1375
1376    public boolean hasColor() { 
1377      return this.color != null && !this.color.isEmpty();
1378    }
1379
1380    /**
1381     * @param value {@link #color} (Describes the color representation for the metric. This is often used to aid clinicians to track and identify parameter types by color. In practice, consider a Patient Monitor that has ECG/HR and Pleth for example; the parameters are displayed in different characteristic colors, such as HR-blue, BP-green, and PR and SpO2- magenta.). This is the underlying object with id, value and extensions. The accessor "getColor" gives direct access to the value
1382     */
1383    public DeviceMetric setColorElement(Enumeration<DeviceMetricColor> value) { 
1384      this.color = value;
1385      return this;
1386    }
1387
1388    /**
1389     * @return Describes the color representation for the metric. This is often used to aid clinicians to track and identify parameter types by color. In practice, consider a Patient Monitor that has ECG/HR and Pleth for example; the parameters are displayed in different characteristic colors, such as HR-blue, BP-green, and PR and SpO2- magenta.
1390     */
1391    public DeviceMetricColor getColor() { 
1392      return this.color == null ? null : this.color.getValue();
1393    }
1394
1395    /**
1396     * @param value Describes the color representation for the metric. This is often used to aid clinicians to track and identify parameter types by color. In practice, consider a Patient Monitor that has ECG/HR and Pleth for example; the parameters are displayed in different characteristic colors, such as HR-blue, BP-green, and PR and SpO2- magenta.
1397     */
1398    public DeviceMetric setColor(DeviceMetricColor value) { 
1399      if (value == null)
1400        this.color = null;
1401      else {
1402        if (this.color == null)
1403          this.color = new Enumeration<DeviceMetricColor>(new DeviceMetricColorEnumFactory());
1404        this.color.setValue(value);
1405      }
1406      return this;
1407    }
1408
1409    /**
1410     * @return {@link #category} (Indicates the category of the observation generation process. A DeviceMetric can be for example a setting, measurement, or calculation.). This is the underlying object with id, value and extensions. The accessor "getCategory" gives direct access to the value
1411     */
1412    public Enumeration<DeviceMetricCategory> getCategoryElement() { 
1413      if (this.category == null)
1414        if (Configuration.errorOnAutoCreate())
1415          throw new Error("Attempt to auto-create DeviceMetric.category");
1416        else if (Configuration.doAutoCreate())
1417          this.category = new Enumeration<DeviceMetricCategory>(new DeviceMetricCategoryEnumFactory()); // bb
1418      return this.category;
1419    }
1420
1421    public boolean hasCategoryElement() { 
1422      return this.category != null && !this.category.isEmpty();
1423    }
1424
1425    public boolean hasCategory() { 
1426      return this.category != null && !this.category.isEmpty();
1427    }
1428
1429    /**
1430     * @param value {@link #category} (Indicates the category of the observation generation process. A DeviceMetric can be for example a setting, measurement, or calculation.). This is the underlying object with id, value and extensions. The accessor "getCategory" gives direct access to the value
1431     */
1432    public DeviceMetric setCategoryElement(Enumeration<DeviceMetricCategory> value) { 
1433      this.category = value;
1434      return this;
1435    }
1436
1437    /**
1438     * @return Indicates the category of the observation generation process. A DeviceMetric can be for example a setting, measurement, or calculation.
1439     */
1440    public DeviceMetricCategory getCategory() { 
1441      return this.category == null ? null : this.category.getValue();
1442    }
1443
1444    /**
1445     * @param value Indicates the category of the observation generation process. A DeviceMetric can be for example a setting, measurement, or calculation.
1446     */
1447    public DeviceMetric setCategory(DeviceMetricCategory value) { 
1448        if (this.category == null)
1449          this.category = new Enumeration<DeviceMetricCategory>(new DeviceMetricCategoryEnumFactory());
1450        this.category.setValue(value);
1451      return this;
1452    }
1453
1454    /**
1455     * @return {@link #measurementPeriod} (Describes the measurement repetition time. This is not necessarily the same as the update period. The measurement repetition time can range from milliseconds up to hours. An example for a measurement repetition time in the range of milliseconds is the sampling rate of an ECG. An example for a measurement repetition time in the range of hours is a NIBP that is triggered automatically every hour. The update period may be different than the measurement repetition time, if the device does not update the published observed value with the same frequency as it was measured.)
1456     */
1457    public Timing getMeasurementPeriod() { 
1458      if (this.measurementPeriod == null)
1459        if (Configuration.errorOnAutoCreate())
1460          throw new Error("Attempt to auto-create DeviceMetric.measurementPeriod");
1461        else if (Configuration.doAutoCreate())
1462          this.measurementPeriod = new Timing(); // cc
1463      return this.measurementPeriod;
1464    }
1465
1466    public boolean hasMeasurementPeriod() { 
1467      return this.measurementPeriod != null && !this.measurementPeriod.isEmpty();
1468    }
1469
1470    /**
1471     * @param value {@link #measurementPeriod} (Describes the measurement repetition time. This is not necessarily the same as the update period. The measurement repetition time can range from milliseconds up to hours. An example for a measurement repetition time in the range of milliseconds is the sampling rate of an ECG. An example for a measurement repetition time in the range of hours is a NIBP that is triggered automatically every hour. The update period may be different than the measurement repetition time, if the device does not update the published observed value with the same frequency as it was measured.)
1472     */
1473    public DeviceMetric setMeasurementPeriod(Timing value) { 
1474      this.measurementPeriod = value;
1475      return this;
1476    }
1477
1478    /**
1479     * @return {@link #calibration} (Describes the calibrations that have been performed or that are required to be performed.)
1480     */
1481    public List<DeviceMetricCalibrationComponent> getCalibration() { 
1482      if (this.calibration == null)
1483        this.calibration = new ArrayList<DeviceMetricCalibrationComponent>();
1484      return this.calibration;
1485    }
1486
1487    /**
1488     * @return Returns a reference to <code>this</code> for easy method chaining
1489     */
1490    public DeviceMetric setCalibration(List<DeviceMetricCalibrationComponent> theCalibration) { 
1491      this.calibration = theCalibration;
1492      return this;
1493    }
1494
1495    public boolean hasCalibration() { 
1496      if (this.calibration == null)
1497        return false;
1498      for (DeviceMetricCalibrationComponent item : this.calibration)
1499        if (!item.isEmpty())
1500          return true;
1501      return false;
1502    }
1503
1504    public DeviceMetricCalibrationComponent addCalibration() { //3
1505      DeviceMetricCalibrationComponent t = new DeviceMetricCalibrationComponent();
1506      if (this.calibration == null)
1507        this.calibration = new ArrayList<DeviceMetricCalibrationComponent>();
1508      this.calibration.add(t);
1509      return t;
1510    }
1511
1512    public DeviceMetric addCalibration(DeviceMetricCalibrationComponent t) { //3
1513      if (t == null)
1514        return this;
1515      if (this.calibration == null)
1516        this.calibration = new ArrayList<DeviceMetricCalibrationComponent>();
1517      this.calibration.add(t);
1518      return this;
1519    }
1520
1521    /**
1522     * @return The first repetition of repeating field {@link #calibration}, creating it if it does not already exist
1523     */
1524    public DeviceMetricCalibrationComponent getCalibrationFirstRep() { 
1525      if (getCalibration().isEmpty()) {
1526        addCalibration();
1527      }
1528      return getCalibration().get(0);
1529    }
1530
1531      protected void listChildren(List<Property> childrenList) {
1532        super.listChildren(childrenList);
1533        childrenList.add(new Property("identifier", "Identifier", "Describes the unique identification of this metric that has been assigned by the device or gateway software. For example: handle ID.  It should be noted that in order to make the identifier unique, the system element of the identifier should be set to the unique identifier of the device.", 0, java.lang.Integer.MAX_VALUE, identifier));
1534        childrenList.add(new Property("type", "CodeableConcept", "Describes the type of the metric. For example: Heart Rate, PEEP Setting, etc.", 0, java.lang.Integer.MAX_VALUE, type));
1535        childrenList.add(new Property("unit", "CodeableConcept", "Describes the unit that an observed value determined for this metric will have. For example: Percent, Seconds, etc.", 0, java.lang.Integer.MAX_VALUE, unit));
1536        childrenList.add(new Property("source", "Reference(Device)", "Describes the link to the  Device that this DeviceMetric belongs to and that contains administrative device information such as manufacturer, serial number, etc.", 0, java.lang.Integer.MAX_VALUE, source));
1537        childrenList.add(new Property("parent", "Reference(DeviceComponent)", "Describes the link to the  DeviceComponent that this DeviceMetric belongs to and that provide information about the location of this DeviceMetric in the containment structure of the parent Device. An example would be a DeviceComponent that represents a Channel. This reference can be used by a client application to distinguish DeviceMetrics that have the same type, but should be interpreted based on their containment location.", 0, java.lang.Integer.MAX_VALUE, parent));
1538        childrenList.add(new Property("operationalStatus", "code", "Indicates current operational state of the device. For example: On, Off, Standby, etc.", 0, java.lang.Integer.MAX_VALUE, operationalStatus));
1539        childrenList.add(new Property("color", "code", "Describes the color representation for the metric. This is often used to aid clinicians to track and identify parameter types by color. In practice, consider a Patient Monitor that has ECG/HR and Pleth for example; the parameters are displayed in different characteristic colors, such as HR-blue, BP-green, and PR and SpO2- magenta.", 0, java.lang.Integer.MAX_VALUE, color));
1540        childrenList.add(new Property("category", "code", "Indicates the category of the observation generation process. A DeviceMetric can be for example a setting, measurement, or calculation.", 0, java.lang.Integer.MAX_VALUE, category));
1541        childrenList.add(new Property("measurementPeriod", "Timing", "Describes the measurement repetition time. This is not necessarily the same as the update period. The measurement repetition time can range from milliseconds up to hours. An example for a measurement repetition time in the range of milliseconds is the sampling rate of an ECG. An example for a measurement repetition time in the range of hours is a NIBP that is triggered automatically every hour. The update period may be different than the measurement repetition time, if the device does not update the published observed value with the same frequency as it was measured.", 0, java.lang.Integer.MAX_VALUE, measurementPeriod));
1542        childrenList.add(new Property("calibration", "", "Describes the calibrations that have been performed or that are required to be performed.", 0, java.lang.Integer.MAX_VALUE, calibration));
1543      }
1544
1545      @Override
1546      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1547        switch (hash) {
1548        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : new Base[] {this.identifier}; // Identifier
1549        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
1550        case 3594628: /*unit*/ return this.unit == null ? new Base[0] : new Base[] {this.unit}; // CodeableConcept
1551        case -896505829: /*source*/ return this.source == null ? new Base[0] : new Base[] {this.source}; // Reference
1552        case -995424086: /*parent*/ return this.parent == null ? new Base[0] : new Base[] {this.parent}; // Reference
1553        case -2103166364: /*operationalStatus*/ return this.operationalStatus == null ? new Base[0] : new Base[] {this.operationalStatus}; // Enumeration<DeviceMetricOperationalStatus>
1554        case 94842723: /*color*/ return this.color == null ? new Base[0] : new Base[] {this.color}; // Enumeration<DeviceMetricColor>
1555        case 50511102: /*category*/ return this.category == null ? new Base[0] : new Base[] {this.category}; // Enumeration<DeviceMetricCategory>
1556        case -1300332387: /*measurementPeriod*/ return this.measurementPeriod == null ? new Base[0] : new Base[] {this.measurementPeriod}; // Timing
1557        case 1421318634: /*calibration*/ return this.calibration == null ? new Base[0] : this.calibration.toArray(new Base[this.calibration.size()]); // DeviceMetricCalibrationComponent
1558        default: return super.getProperty(hash, name, checkValid);
1559        }
1560
1561      }
1562
1563      @Override
1564      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1565        switch (hash) {
1566        case -1618432855: // identifier
1567          this.identifier = castToIdentifier(value); // Identifier
1568          return value;
1569        case 3575610: // type
1570          this.type = castToCodeableConcept(value); // CodeableConcept
1571          return value;
1572        case 3594628: // unit
1573          this.unit = castToCodeableConcept(value); // CodeableConcept
1574          return value;
1575        case -896505829: // source
1576          this.source = castToReference(value); // Reference
1577          return value;
1578        case -995424086: // parent
1579          this.parent = castToReference(value); // Reference
1580          return value;
1581        case -2103166364: // operationalStatus
1582          value = new DeviceMetricOperationalStatusEnumFactory().fromType(castToCode(value));
1583          this.operationalStatus = (Enumeration) value; // Enumeration<DeviceMetricOperationalStatus>
1584          return value;
1585        case 94842723: // color
1586          value = new DeviceMetricColorEnumFactory().fromType(castToCode(value));
1587          this.color = (Enumeration) value; // Enumeration<DeviceMetricColor>
1588          return value;
1589        case 50511102: // category
1590          value = new DeviceMetricCategoryEnumFactory().fromType(castToCode(value));
1591          this.category = (Enumeration) value; // Enumeration<DeviceMetricCategory>
1592          return value;
1593        case -1300332387: // measurementPeriod
1594          this.measurementPeriod = castToTiming(value); // Timing
1595          return value;
1596        case 1421318634: // calibration
1597          this.getCalibration().add((DeviceMetricCalibrationComponent) value); // DeviceMetricCalibrationComponent
1598          return value;
1599        default: return super.setProperty(hash, name, value);
1600        }
1601
1602      }
1603
1604      @Override
1605      public Base setProperty(String name, Base value) throws FHIRException {
1606        if (name.equals("identifier")) {
1607          this.identifier = castToIdentifier(value); // Identifier
1608        } else if (name.equals("type")) {
1609          this.type = castToCodeableConcept(value); // CodeableConcept
1610        } else if (name.equals("unit")) {
1611          this.unit = castToCodeableConcept(value); // CodeableConcept
1612        } else if (name.equals("source")) {
1613          this.source = castToReference(value); // Reference
1614        } else if (name.equals("parent")) {
1615          this.parent = castToReference(value); // Reference
1616        } else if (name.equals("operationalStatus")) {
1617          value = new DeviceMetricOperationalStatusEnumFactory().fromType(castToCode(value));
1618          this.operationalStatus = (Enumeration) value; // Enumeration<DeviceMetricOperationalStatus>
1619        } else if (name.equals("color")) {
1620          value = new DeviceMetricColorEnumFactory().fromType(castToCode(value));
1621          this.color = (Enumeration) value; // Enumeration<DeviceMetricColor>
1622        } else if (name.equals("category")) {
1623          value = new DeviceMetricCategoryEnumFactory().fromType(castToCode(value));
1624          this.category = (Enumeration) value; // Enumeration<DeviceMetricCategory>
1625        } else if (name.equals("measurementPeriod")) {
1626          this.measurementPeriod = castToTiming(value); // Timing
1627        } else if (name.equals("calibration")) {
1628          this.getCalibration().add((DeviceMetricCalibrationComponent) value);
1629        } else
1630          return super.setProperty(name, value);
1631        return value;
1632      }
1633
1634      @Override
1635      public Base makeProperty(int hash, String name) throws FHIRException {
1636        switch (hash) {
1637        case -1618432855:  return getIdentifier(); 
1638        case 3575610:  return getType(); 
1639        case 3594628:  return getUnit(); 
1640        case -896505829:  return getSource(); 
1641        case -995424086:  return getParent(); 
1642        case -2103166364:  return getOperationalStatusElement();
1643        case 94842723:  return getColorElement();
1644        case 50511102:  return getCategoryElement();
1645        case -1300332387:  return getMeasurementPeriod(); 
1646        case 1421318634:  return addCalibration(); 
1647        default: return super.makeProperty(hash, name);
1648        }
1649
1650      }
1651
1652      @Override
1653      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1654        switch (hash) {
1655        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
1656        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
1657        case 3594628: /*unit*/ return new String[] {"CodeableConcept"};
1658        case -896505829: /*source*/ return new String[] {"Reference"};
1659        case -995424086: /*parent*/ return new String[] {"Reference"};
1660        case -2103166364: /*operationalStatus*/ return new String[] {"code"};
1661        case 94842723: /*color*/ return new String[] {"code"};
1662        case 50511102: /*category*/ return new String[] {"code"};
1663        case -1300332387: /*measurementPeriod*/ return new String[] {"Timing"};
1664        case 1421318634: /*calibration*/ return new String[] {};
1665        default: return super.getTypesForProperty(hash, name);
1666        }
1667
1668      }
1669
1670      @Override
1671      public Base addChild(String name) throws FHIRException {
1672        if (name.equals("identifier")) {
1673          this.identifier = new Identifier();
1674          return this.identifier;
1675        }
1676        else if (name.equals("type")) {
1677          this.type = new CodeableConcept();
1678          return this.type;
1679        }
1680        else if (name.equals("unit")) {
1681          this.unit = new CodeableConcept();
1682          return this.unit;
1683        }
1684        else if (name.equals("source")) {
1685          this.source = new Reference();
1686          return this.source;
1687        }
1688        else if (name.equals("parent")) {
1689          this.parent = new Reference();
1690          return this.parent;
1691        }
1692        else if (name.equals("operationalStatus")) {
1693          throw new FHIRException("Cannot call addChild on a primitive type DeviceMetric.operationalStatus");
1694        }
1695        else if (name.equals("color")) {
1696          throw new FHIRException("Cannot call addChild on a primitive type DeviceMetric.color");
1697        }
1698        else if (name.equals("category")) {
1699          throw new FHIRException("Cannot call addChild on a primitive type DeviceMetric.category");
1700        }
1701        else if (name.equals("measurementPeriod")) {
1702          this.measurementPeriod = new Timing();
1703          return this.measurementPeriod;
1704        }
1705        else if (name.equals("calibration")) {
1706          return addCalibration();
1707        }
1708        else
1709          return super.addChild(name);
1710      }
1711
1712  public String fhirType() {
1713    return "DeviceMetric";
1714
1715  }
1716
1717      public DeviceMetric copy() {
1718        DeviceMetric dst = new DeviceMetric();
1719        copyValues(dst);
1720        dst.identifier = identifier == null ? null : identifier.copy();
1721        dst.type = type == null ? null : type.copy();
1722        dst.unit = unit == null ? null : unit.copy();
1723        dst.source = source == null ? null : source.copy();
1724        dst.parent = parent == null ? null : parent.copy();
1725        dst.operationalStatus = operationalStatus == null ? null : operationalStatus.copy();
1726        dst.color = color == null ? null : color.copy();
1727        dst.category = category == null ? null : category.copy();
1728        dst.measurementPeriod = measurementPeriod == null ? null : measurementPeriod.copy();
1729        if (calibration != null) {
1730          dst.calibration = new ArrayList<DeviceMetricCalibrationComponent>();
1731          for (DeviceMetricCalibrationComponent i : calibration)
1732            dst.calibration.add(i.copy());
1733        };
1734        return dst;
1735      }
1736
1737      protected DeviceMetric typedCopy() {
1738        return copy();
1739      }
1740
1741      @Override
1742      public boolean equalsDeep(Base other) {
1743        if (!super.equalsDeep(other))
1744          return false;
1745        if (!(other instanceof DeviceMetric))
1746          return false;
1747        DeviceMetric o = (DeviceMetric) other;
1748        return compareDeep(identifier, o.identifier, true) && compareDeep(type, o.type, true) && compareDeep(unit, o.unit, true)
1749           && compareDeep(source, o.source, true) && compareDeep(parent, o.parent, true) && compareDeep(operationalStatus, o.operationalStatus, true)
1750           && compareDeep(color, o.color, true) && compareDeep(category, o.category, true) && compareDeep(measurementPeriod, o.measurementPeriod, true)
1751           && compareDeep(calibration, o.calibration, true);
1752      }
1753
1754      @Override
1755      public boolean equalsShallow(Base other) {
1756        if (!super.equalsShallow(other))
1757          return false;
1758        if (!(other instanceof DeviceMetric))
1759          return false;
1760        DeviceMetric o = (DeviceMetric) other;
1761        return compareValues(operationalStatus, o.operationalStatus, true) && compareValues(color, o.color, true)
1762           && compareValues(category, o.category, true);
1763      }
1764
1765      public boolean isEmpty() {
1766        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, type, unit, source
1767          , parent, operationalStatus, color, category, measurementPeriod, calibration);
1768      }
1769
1770  @Override
1771  public ResourceType getResourceType() {
1772    return ResourceType.DeviceMetric;
1773   }
1774
1775 /**
1776   * Search parameter: <b>parent</b>
1777   * <p>
1778   * Description: <b>The parent DeviceMetric resource</b><br>
1779   * Type: <b>reference</b><br>
1780   * Path: <b>DeviceMetric.parent</b><br>
1781   * </p>
1782   */
1783  @SearchParamDefinition(name="parent", path="DeviceMetric.parent", description="The parent DeviceMetric resource", type="reference", target={DeviceComponent.class } )
1784  public static final String SP_PARENT = "parent";
1785 /**
1786   * <b>Fluent Client</b> search parameter constant for <b>parent</b>
1787   * <p>
1788   * Description: <b>The parent DeviceMetric resource</b><br>
1789   * Type: <b>reference</b><br>
1790   * Path: <b>DeviceMetric.parent</b><br>
1791   * </p>
1792   */
1793  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PARENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PARENT);
1794
1795/**
1796   * Constant for fluent queries to be used to add include statements. Specifies
1797   * the path value of "<b>DeviceMetric:parent</b>".
1798   */
1799  public static final ca.uhn.fhir.model.api.Include INCLUDE_PARENT = new ca.uhn.fhir.model.api.Include("DeviceMetric:parent").toLocked();
1800
1801 /**
1802   * Search parameter: <b>identifier</b>
1803   * <p>
1804   * Description: <b>The identifier of the metric</b><br>
1805   * Type: <b>token</b><br>
1806   * Path: <b>DeviceMetric.identifier</b><br>
1807   * </p>
1808   */
1809  @SearchParamDefinition(name="identifier", path="DeviceMetric.identifier", description="The identifier of the metric", type="token" )
1810  public static final String SP_IDENTIFIER = "identifier";
1811 /**
1812   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
1813   * <p>
1814   * Description: <b>The identifier of the metric</b><br>
1815   * Type: <b>token</b><br>
1816   * Path: <b>DeviceMetric.identifier</b><br>
1817   * </p>
1818   */
1819  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
1820
1821 /**
1822   * Search parameter: <b>source</b>
1823   * <p>
1824   * Description: <b>The device resource</b><br>
1825   * Type: <b>reference</b><br>
1826   * Path: <b>DeviceMetric.source</b><br>
1827   * </p>
1828   */
1829  @SearchParamDefinition(name="source", path="DeviceMetric.source", description="The device resource", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Device") }, target={Device.class } )
1830  public static final String SP_SOURCE = "source";
1831 /**
1832   * <b>Fluent Client</b> search parameter constant for <b>source</b>
1833   * <p>
1834   * Description: <b>The device resource</b><br>
1835   * Type: <b>reference</b><br>
1836   * Path: <b>DeviceMetric.source</b><br>
1837   * </p>
1838   */
1839  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SOURCE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SOURCE);
1840
1841/**
1842   * Constant for fluent queries to be used to add include statements. Specifies
1843   * the path value of "<b>DeviceMetric:source</b>".
1844   */
1845  public static final ca.uhn.fhir.model.api.Include INCLUDE_SOURCE = new ca.uhn.fhir.model.api.Include("DeviceMetric:source").toLocked();
1846
1847 /**
1848   * Search parameter: <b>type</b>
1849   * <p>
1850   * Description: <b>The component type</b><br>
1851   * Type: <b>token</b><br>
1852   * Path: <b>DeviceMetric.type</b><br>
1853   * </p>
1854   */
1855  @SearchParamDefinition(name="type", path="DeviceMetric.type", description="The component type", type="token" )
1856  public static final String SP_TYPE = "type";
1857 /**
1858   * <b>Fluent Client</b> search parameter constant for <b>type</b>
1859   * <p>
1860   * Description: <b>The component type</b><br>
1861   * Type: <b>token</b><br>
1862   * Path: <b>DeviceMetric.type</b><br>
1863   * </p>
1864   */
1865  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_TYPE);
1866
1867 /**
1868   * Search parameter: <b>category</b>
1869   * <p>
1870   * Description: <b>The category of the metric</b><br>
1871   * Type: <b>token</b><br>
1872   * Path: <b>DeviceMetric.category</b><br>
1873   * </p>
1874   */
1875  @SearchParamDefinition(name="category", path="DeviceMetric.category", description="The category of the metric", type="token" )
1876  public static final String SP_CATEGORY = "category";
1877 /**
1878   * <b>Fluent Client</b> search parameter constant for <b>category</b>
1879   * <p>
1880   * Description: <b>The category of the metric</b><br>
1881   * Type: <b>token</b><br>
1882   * Path: <b>DeviceMetric.category</b><br>
1883   * </p>
1884   */
1885  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CATEGORY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CATEGORY);
1886
1887
1888}
1889