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