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