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