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