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