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