001package org.hl7.fhir.instance.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
033import java.util.*;
034
035import org.hl7.fhir.exceptions.FHIRException;
036import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
037
038import ca.uhn.fhir.model.api.annotation.*;
039/**
040 * Describes a measurement, calculation or setting capability of a medical device.
041 */
042@ResourceDef(name="DeviceMetric", profile="http://hl7.org/fhir/Profile/DeviceMetric")
043public class DeviceMetric extends DomainResource {
044
045    public enum DeviceMetricOperationalStatus {
046        /**
047         * The DeviceMetric is operating and will generate DeviceObservations.
048         */
049        ON, 
050        /**
051         * The DeviceMetric is not operating.
052         */
053        OFF, 
054        /**
055         * The DeviceMetric is operating, but will not generate any DeviceObservations.
056         */
057        STANDBY, 
058        /**
059         * added to help the parsers
060         */
061        NULL;
062        public static DeviceMetricOperationalStatus fromCode(String codeString) throws FHIRException {
063            if (codeString == null || "".equals(codeString))
064                return null;
065        if ("on".equals(codeString))
066          return ON;
067        if ("off".equals(codeString))
068          return OFF;
069        if ("standby".equals(codeString))
070          return STANDBY;
071        throw new FHIRException("Unknown DeviceMetricOperationalStatus code '"+codeString+"'");
072        }
073        public String toCode() {
074          switch (this) {
075            case ON: return "on";
076            case OFF: return "off";
077            case STANDBY: return "standby";
078            default: return "?";
079          }
080        }
081        public String getSystem() {
082          switch (this) {
083            case ON: return "http://hl7.org/fhir/metric-operational-status";
084            case OFF: return "http://hl7.org/fhir/metric-operational-status";
085            case STANDBY: return "http://hl7.org/fhir/metric-operational-status";
086            default: return "?";
087          }
088        }
089        public String getDefinition() {
090          switch (this) {
091            case ON: return "The DeviceMetric is operating and will generate DeviceObservations.";
092            case OFF: return "The DeviceMetric is not operating.";
093            case STANDBY: return "The DeviceMetric is operating, but will not generate any DeviceObservations.";
094            default: return "?";
095          }
096        }
097        public String getDisplay() {
098          switch (this) {
099            case ON: return "On";
100            case OFF: return "Off";
101            case STANDBY: return "Standby";
102            default: return "?";
103          }
104        }
105    }
106
107  public static class DeviceMetricOperationalStatusEnumFactory implements EnumFactory<DeviceMetricOperationalStatus> {
108    public DeviceMetricOperationalStatus fromCode(String codeString) throws IllegalArgumentException {
109      if (codeString == null || "".equals(codeString))
110            if (codeString == null || "".equals(codeString))
111                return null;
112        if ("on".equals(codeString))
113          return DeviceMetricOperationalStatus.ON;
114        if ("off".equals(codeString))
115          return DeviceMetricOperationalStatus.OFF;
116        if ("standby".equals(codeString))
117          return DeviceMetricOperationalStatus.STANDBY;
118        throw new IllegalArgumentException("Unknown DeviceMetricOperationalStatus code '"+codeString+"'");
119        }
120        public Enumeration<DeviceMetricOperationalStatus> fromType(Base code) throws FHIRException {
121          if (code == null || code.isEmpty())
122            return null;
123          String codeString = ((PrimitiveType) code).asStringValue();
124          if (codeString == null || "".equals(codeString))
125            return null;
126        if ("on".equals(codeString))
127          return new Enumeration<DeviceMetricOperationalStatus>(this, DeviceMetricOperationalStatus.ON);
128        if ("off".equals(codeString))
129          return new Enumeration<DeviceMetricOperationalStatus>(this, DeviceMetricOperationalStatus.OFF);
130        if ("standby".equals(codeString))
131          return new Enumeration<DeviceMetricOperationalStatus>(this, DeviceMetricOperationalStatus.STANDBY);
132        throw new FHIRException("Unknown DeviceMetricOperationalStatus code '"+codeString+"'");
133        }
134    public String toCode(DeviceMetricOperationalStatus code) {
135      if (code == DeviceMetricOperationalStatus.ON)
136        return "on";
137      if (code == DeviceMetricOperationalStatus.OFF)
138        return "off";
139      if (code == DeviceMetricOperationalStatus.STANDBY)
140        return "standby";
141      return "?";
142      }
143    }
144
145    public enum DeviceMetricColor {
146        /**
147         * Color for representation - black.
148         */
149        BLACK, 
150        /**
151         * Color for representation - red.
152         */
153        RED, 
154        /**
155         * Color for representation - green.
156         */
157        GREEN, 
158        /**
159         * Color for representation - yellow.
160         */
161        YELLOW, 
162        /**
163         * Color for representation - blue.
164         */
165        BLUE, 
166        /**
167         * Color for representation - magenta.
168         */
169        MAGENTA, 
170        /**
171         * Color for representation - cyan.
172         */
173        CYAN, 
174        /**
175         * Color for representation - white.
176         */
177        WHITE, 
178        /**
179         * added to help the parsers
180         */
181        NULL;
182        public static DeviceMetricColor fromCode(String codeString) throws FHIRException {
183            if (codeString == null || "".equals(codeString))
184                return null;
185        if ("black".equals(codeString))
186          return BLACK;
187        if ("red".equals(codeString))
188          return RED;
189        if ("green".equals(codeString))
190          return GREEN;
191        if ("yellow".equals(codeString))
192          return YELLOW;
193        if ("blue".equals(codeString))
194          return BLUE;
195        if ("magenta".equals(codeString))
196          return MAGENTA;
197        if ("cyan".equals(codeString))
198          return CYAN;
199        if ("white".equals(codeString))
200          return WHITE;
201        throw new FHIRException("Unknown DeviceMetricColor code '"+codeString+"'");
202        }
203        public String toCode() {
204          switch (this) {
205            case BLACK: return "black";
206            case RED: return "red";
207            case GREEN: return "green";
208            case YELLOW: return "yellow";
209            case BLUE: return "blue";
210            case MAGENTA: return "magenta";
211            case CYAN: return "cyan";
212            case WHITE: return "white";
213            default: return "?";
214          }
215        }
216        public String getSystem() {
217          switch (this) {
218            case BLACK: return "http://hl7.org/fhir/metric-color";
219            case RED: return "http://hl7.org/fhir/metric-color";
220            case GREEN: return "http://hl7.org/fhir/metric-color";
221            case YELLOW: return "http://hl7.org/fhir/metric-color";
222            case BLUE: return "http://hl7.org/fhir/metric-color";
223            case MAGENTA: return "http://hl7.org/fhir/metric-color";
224            case CYAN: return "http://hl7.org/fhir/metric-color";
225            case WHITE: return "http://hl7.org/fhir/metric-color";
226            default: return "?";
227          }
228        }
229        public String getDefinition() {
230          switch (this) {
231            case BLACK: return "Color for representation - black.";
232            case RED: return "Color for representation - red.";
233            case GREEN: return "Color for representation - green.";
234            case YELLOW: return "Color for representation - yellow.";
235            case BLUE: return "Color for representation - blue.";
236            case MAGENTA: return "Color for representation - magenta.";
237            case CYAN: return "Color for representation - cyan.";
238            case WHITE: return "Color for representation - white.";
239            default: return "?";
240          }
241        }
242        public String getDisplay() {
243          switch (this) {
244            case BLACK: return "Color Black";
245            case RED: return "Color Red";
246            case GREEN: return "Color Green";
247            case YELLOW: return "Color Yellow";
248            case BLUE: return "Color Blue";
249            case MAGENTA: return "Color Magenta";
250            case CYAN: return "Color Cyan";
251            case WHITE: return "Color White";
252            default: return "?";
253          }
254        }
255    }
256
257  public static class DeviceMetricColorEnumFactory implements EnumFactory<DeviceMetricColor> {
258    public DeviceMetricColor fromCode(String codeString) throws IllegalArgumentException {
259      if (codeString == null || "".equals(codeString))
260            if (codeString == null || "".equals(codeString))
261                return null;
262        if ("black".equals(codeString))
263          return DeviceMetricColor.BLACK;
264        if ("red".equals(codeString))
265          return DeviceMetricColor.RED;
266        if ("green".equals(codeString))
267          return DeviceMetricColor.GREEN;
268        if ("yellow".equals(codeString))
269          return DeviceMetricColor.YELLOW;
270        if ("blue".equals(codeString))
271          return DeviceMetricColor.BLUE;
272        if ("magenta".equals(codeString))
273          return DeviceMetricColor.MAGENTA;
274        if ("cyan".equals(codeString))
275          return DeviceMetricColor.CYAN;
276        if ("white".equals(codeString))
277          return DeviceMetricColor.WHITE;
278        throw new IllegalArgumentException("Unknown DeviceMetricColor code '"+codeString+"'");
279        }
280        public Enumeration<DeviceMetricColor> fromType(Base code) throws FHIRException {
281          if (code == null || code.isEmpty())
282            return null;
283          String codeString = ((PrimitiveType) code).asStringValue();
284          if (codeString == null || "".equals(codeString))
285            return null;
286        if ("black".equals(codeString))
287          return new Enumeration<DeviceMetricColor>(this, DeviceMetricColor.BLACK);
288        if ("red".equals(codeString))
289          return new Enumeration<DeviceMetricColor>(this, DeviceMetricColor.RED);
290        if ("green".equals(codeString))
291          return new Enumeration<DeviceMetricColor>(this, DeviceMetricColor.GREEN);
292        if ("yellow".equals(codeString))
293          return new Enumeration<DeviceMetricColor>(this, DeviceMetricColor.YELLOW);
294        if ("blue".equals(codeString))
295          return new Enumeration<DeviceMetricColor>(this, DeviceMetricColor.BLUE);
296        if ("magenta".equals(codeString))
297          return new Enumeration<DeviceMetricColor>(this, DeviceMetricColor.MAGENTA);
298        if ("cyan".equals(codeString))
299          return new Enumeration<DeviceMetricColor>(this, DeviceMetricColor.CYAN);
300        if ("white".equals(codeString))
301          return new Enumeration<DeviceMetricColor>(this, DeviceMetricColor.WHITE);
302        throw new FHIRException("Unknown DeviceMetricColor code '"+codeString+"'");
303        }
304    public String toCode(DeviceMetricColor code) {
305      if (code == DeviceMetricColor.BLACK)
306        return "black";
307      if (code == DeviceMetricColor.RED)
308        return "red";
309      if (code == DeviceMetricColor.GREEN)
310        return "green";
311      if (code == DeviceMetricColor.YELLOW)
312        return "yellow";
313      if (code == DeviceMetricColor.BLUE)
314        return "blue";
315      if (code == DeviceMetricColor.MAGENTA)
316        return "magenta";
317      if (code == DeviceMetricColor.CYAN)
318        return "cyan";
319      if (code == DeviceMetricColor.WHITE)
320        return "white";
321      return "?";
322      }
323    }
324
325    public enum DeviceMetricCategory {
326        /**
327         * DeviceObservations generated for this DeviceMetric are measured.
328         */
329        MEASUREMENT, 
330        /**
331         * DeviceObservations generated for this DeviceMetric is a setting that will influence the behavior of the Device.
332         */
333        SETTING, 
334        /**
335         * DeviceObservations generated for this DeviceMetric are calculated.
336         */
337        CALCULATION, 
338        /**
339         * The category of this DeviceMetric is unspecified.
340         */
341        UNSPECIFIED, 
342        /**
343         * added to help the parsers
344         */
345        NULL;
346        public static DeviceMetricCategory fromCode(String codeString) throws FHIRException {
347            if (codeString == null || "".equals(codeString))
348                return null;
349        if ("measurement".equals(codeString))
350          return MEASUREMENT;
351        if ("setting".equals(codeString))
352          return SETTING;
353        if ("calculation".equals(codeString))
354          return CALCULATION;
355        if ("unspecified".equals(codeString))
356          return UNSPECIFIED;
357        throw new FHIRException("Unknown DeviceMetricCategory code '"+codeString+"'");
358        }
359        public String toCode() {
360          switch (this) {
361            case MEASUREMENT: return "measurement";
362            case SETTING: return "setting";
363            case CALCULATION: return "calculation";
364            case UNSPECIFIED: return "unspecified";
365            default: return "?";
366          }
367        }
368        public String getSystem() {
369          switch (this) {
370            case MEASUREMENT: return "http://hl7.org/fhir/metric-category";
371            case SETTING: return "http://hl7.org/fhir/metric-category";
372            case CALCULATION: return "http://hl7.org/fhir/metric-category";
373            case UNSPECIFIED: return "http://hl7.org/fhir/metric-category";
374            default: return "?";
375          }
376        }
377        public String getDefinition() {
378          switch (this) {
379            case MEASUREMENT: return "DeviceObservations generated for this DeviceMetric are measured.";
380            case SETTING: return "DeviceObservations generated for this DeviceMetric is a setting that will influence the behavior of the Device.";
381            case CALCULATION: return "DeviceObservations generated for this DeviceMetric are calculated.";
382            case UNSPECIFIED: return "The category of this DeviceMetric is unspecified.";
383            default: return "?";
384          }
385        }
386        public String getDisplay() {
387          switch (this) {
388            case MEASUREMENT: return "Measurement";
389            case SETTING: return "Setting";
390            case CALCULATION: return "Calculation";
391            case UNSPECIFIED: return "Unspecified";
392            default: return "?";
393          }
394        }
395    }
396
397  public static class DeviceMetricCategoryEnumFactory implements EnumFactory<DeviceMetricCategory> {
398    public DeviceMetricCategory fromCode(String codeString) throws IllegalArgumentException {
399      if (codeString == null || "".equals(codeString))
400            if (codeString == null || "".equals(codeString))
401                return null;
402        if ("measurement".equals(codeString))
403          return DeviceMetricCategory.MEASUREMENT;
404        if ("setting".equals(codeString))
405          return DeviceMetricCategory.SETTING;
406        if ("calculation".equals(codeString))
407          return DeviceMetricCategory.CALCULATION;
408        if ("unspecified".equals(codeString))
409          return DeviceMetricCategory.UNSPECIFIED;
410        throw new IllegalArgumentException("Unknown DeviceMetricCategory code '"+codeString+"'");
411        }
412        public Enumeration<DeviceMetricCategory> fromType(Base code) throws FHIRException {
413          if (code == null || code.isEmpty())
414            return null;
415          String codeString = ((PrimitiveType) code).asStringValue();
416          if (codeString == null || "".equals(codeString))
417            return null;
418        if ("measurement".equals(codeString))
419          return new Enumeration<DeviceMetricCategory>(this, DeviceMetricCategory.MEASUREMENT);
420        if ("setting".equals(codeString))
421          return new Enumeration<DeviceMetricCategory>(this, DeviceMetricCategory.SETTING);
422        if ("calculation".equals(codeString))
423          return new Enumeration<DeviceMetricCategory>(this, DeviceMetricCategory.CALCULATION);
424        if ("unspecified".equals(codeString))
425          return new Enumeration<DeviceMetricCategory>(this, DeviceMetricCategory.UNSPECIFIED);
426        throw new FHIRException("Unknown DeviceMetricCategory code '"+codeString+"'");
427        }
428    public String toCode(DeviceMetricCategory code) {
429      if (code == DeviceMetricCategory.MEASUREMENT)
430        return "measurement";
431      if (code == DeviceMetricCategory.SETTING)
432        return "setting";
433      if (code == DeviceMetricCategory.CALCULATION)
434        return "calculation";
435      if (code == DeviceMetricCategory.UNSPECIFIED)
436        return "unspecified";
437      return "?";
438      }
439    }
440
441    public enum DeviceMetricCalibrationType {
442        /**
443         * TODO
444         */
445        UNSPECIFIED, 
446        /**
447         * TODO
448         */
449        OFFSET, 
450        /**
451         * TODO
452         */
453        GAIN, 
454        /**
455         * TODO
456         */
457        TWOPOINT, 
458        /**
459         * added to help the parsers
460         */
461        NULL;
462        public static DeviceMetricCalibrationType fromCode(String codeString) throws FHIRException {
463            if (codeString == null || "".equals(codeString))
464                return null;
465        if ("unspecified".equals(codeString))
466          return UNSPECIFIED;
467        if ("offset".equals(codeString))
468          return OFFSET;
469        if ("gain".equals(codeString))
470          return GAIN;
471        if ("two-point".equals(codeString))
472          return TWOPOINT;
473        throw new FHIRException("Unknown DeviceMetricCalibrationType code '"+codeString+"'");
474        }
475        public String toCode() {
476          switch (this) {
477            case UNSPECIFIED: return "unspecified";
478            case OFFSET: return "offset";
479            case GAIN: return "gain";
480            case TWOPOINT: return "two-point";
481            default: return "?";
482          }
483        }
484        public String getSystem() {
485          switch (this) {
486            case UNSPECIFIED: return "http://hl7.org/fhir/metric-calibration-type";
487            case OFFSET: return "http://hl7.org/fhir/metric-calibration-type";
488            case GAIN: return "http://hl7.org/fhir/metric-calibration-type";
489            case TWOPOINT: return "http://hl7.org/fhir/metric-calibration-type";
490            default: return "?";
491          }
492        }
493        public String getDefinition() {
494          switch (this) {
495            case UNSPECIFIED: return "TODO";
496            case OFFSET: return "TODO";
497            case GAIN: return "TODO";
498            case TWOPOINT: return "TODO";
499            default: return "?";
500          }
501        }
502        public String getDisplay() {
503          switch (this) {
504            case UNSPECIFIED: return "Unspecified";
505            case OFFSET: return "Offset";
506            case GAIN: return "Gain";
507            case TWOPOINT: return "Two Point";
508            default: return "?";
509          }
510        }
511    }
512
513  public static class DeviceMetricCalibrationTypeEnumFactory implements EnumFactory<DeviceMetricCalibrationType> {
514    public DeviceMetricCalibrationType fromCode(String codeString) throws IllegalArgumentException {
515      if (codeString == null || "".equals(codeString))
516            if (codeString == null || "".equals(codeString))
517                return null;
518        if ("unspecified".equals(codeString))
519          return DeviceMetricCalibrationType.UNSPECIFIED;
520        if ("offset".equals(codeString))
521          return DeviceMetricCalibrationType.OFFSET;
522        if ("gain".equals(codeString))
523          return DeviceMetricCalibrationType.GAIN;
524        if ("two-point".equals(codeString))
525          return DeviceMetricCalibrationType.TWOPOINT;
526        throw new IllegalArgumentException("Unknown DeviceMetricCalibrationType code '"+codeString+"'");
527        }
528        public Enumeration<DeviceMetricCalibrationType> fromType(Base code) throws FHIRException {
529          if (code == null || code.isEmpty())
530            return null;
531          String codeString = ((PrimitiveType) code).asStringValue();
532          if (codeString == null || "".equals(codeString))
533            return null;
534        if ("unspecified".equals(codeString))
535          return new Enumeration<DeviceMetricCalibrationType>(this, DeviceMetricCalibrationType.UNSPECIFIED);
536        if ("offset".equals(codeString))
537          return new Enumeration<DeviceMetricCalibrationType>(this, DeviceMetricCalibrationType.OFFSET);
538        if ("gain".equals(codeString))
539          return new Enumeration<DeviceMetricCalibrationType>(this, DeviceMetricCalibrationType.GAIN);
540        if ("two-point".equals(codeString))
541          return new Enumeration<DeviceMetricCalibrationType>(this, DeviceMetricCalibrationType.TWOPOINT);
542        throw new FHIRException("Unknown DeviceMetricCalibrationType code '"+codeString+"'");
543        }
544    public String toCode(DeviceMetricCalibrationType code) {
545      if (code == DeviceMetricCalibrationType.UNSPECIFIED)
546        return "unspecified";
547      if (code == DeviceMetricCalibrationType.OFFSET)
548        return "offset";
549      if (code == DeviceMetricCalibrationType.GAIN)
550        return "gain";
551      if (code == DeviceMetricCalibrationType.TWOPOINT)
552        return "two-point";
553      return "?";
554      }
555    }
556
557    public enum DeviceMetricCalibrationState {
558        /**
559         * The metric has not been calibrated.
560         */
561        NOTCALIBRATED, 
562        /**
563         * The metric needs to be calibrated.
564         */
565        CALIBRATIONREQUIRED, 
566        /**
567         * The metric has been calibrated.
568         */
569        CALIBRATED, 
570        /**
571         * The state of calibration of this metric is unspecified.
572         */
573        UNSPECIFIED, 
574        /**
575         * added to help the parsers
576         */
577        NULL;
578        public static DeviceMetricCalibrationState fromCode(String codeString) throws FHIRException {
579            if (codeString == null || "".equals(codeString))
580                return null;
581        if ("not-calibrated".equals(codeString))
582          return NOTCALIBRATED;
583        if ("calibration-required".equals(codeString))
584          return CALIBRATIONREQUIRED;
585        if ("calibrated".equals(codeString))
586          return CALIBRATED;
587        if ("unspecified".equals(codeString))
588          return UNSPECIFIED;
589        throw new FHIRException("Unknown DeviceMetricCalibrationState code '"+codeString+"'");
590        }
591        public String toCode() {
592          switch (this) {
593            case NOTCALIBRATED: return "not-calibrated";
594            case CALIBRATIONREQUIRED: return "calibration-required";
595            case CALIBRATED: return "calibrated";
596            case UNSPECIFIED: return "unspecified";
597            default: return "?";
598          }
599        }
600        public String getSystem() {
601          switch (this) {
602            case NOTCALIBRATED: return "http://hl7.org/fhir/metric-calibration-state";
603            case CALIBRATIONREQUIRED: return "http://hl7.org/fhir/metric-calibration-state";
604            case CALIBRATED: return "http://hl7.org/fhir/metric-calibration-state";
605            case UNSPECIFIED: return "http://hl7.org/fhir/metric-calibration-state";
606            default: return "?";
607          }
608        }
609        public String getDefinition() {
610          switch (this) {
611            case NOTCALIBRATED: return "The metric has not been calibrated.";
612            case CALIBRATIONREQUIRED: return "The metric needs to be calibrated.";
613            case CALIBRATED: return "The metric has been calibrated.";
614            case UNSPECIFIED: return "The state of calibration of this metric is unspecified.";
615            default: return "?";
616          }
617        }
618        public String getDisplay() {
619          switch (this) {
620            case NOTCALIBRATED: return "Not Calibrated";
621            case CALIBRATIONREQUIRED: return "Calibration Required";
622            case CALIBRATED: return "Calibrated";
623            case UNSPECIFIED: return "Unspecified";
624            default: return "?";
625          }
626        }
627    }
628
629  public static class DeviceMetricCalibrationStateEnumFactory implements EnumFactory<DeviceMetricCalibrationState> {
630    public DeviceMetricCalibrationState fromCode(String codeString) throws IllegalArgumentException {
631      if (codeString == null || "".equals(codeString))
632            if (codeString == null || "".equals(codeString))
633                return null;
634        if ("not-calibrated".equals(codeString))
635          return DeviceMetricCalibrationState.NOTCALIBRATED;
636        if ("calibration-required".equals(codeString))
637          return DeviceMetricCalibrationState.CALIBRATIONREQUIRED;
638        if ("calibrated".equals(codeString))
639          return DeviceMetricCalibrationState.CALIBRATED;
640        if ("unspecified".equals(codeString))
641          return DeviceMetricCalibrationState.UNSPECIFIED;
642        throw new IllegalArgumentException("Unknown DeviceMetricCalibrationState code '"+codeString+"'");
643        }
644        public Enumeration<DeviceMetricCalibrationState> fromType(Base code) throws FHIRException {
645          if (code == null || code.isEmpty())
646            return null;
647          String codeString = ((PrimitiveType) code).asStringValue();
648          if (codeString == null || "".equals(codeString))
649            return null;
650        if ("not-calibrated".equals(codeString))
651          return new Enumeration<DeviceMetricCalibrationState>(this, DeviceMetricCalibrationState.NOTCALIBRATED);
652        if ("calibration-required".equals(codeString))
653          return new Enumeration<DeviceMetricCalibrationState>(this, DeviceMetricCalibrationState.CALIBRATIONREQUIRED);
654        if ("calibrated".equals(codeString))
655          return new Enumeration<DeviceMetricCalibrationState>(this, DeviceMetricCalibrationState.CALIBRATED);
656        if ("unspecified".equals(codeString))
657          return new Enumeration<DeviceMetricCalibrationState>(this, DeviceMetricCalibrationState.UNSPECIFIED);
658        throw new FHIRException("Unknown DeviceMetricCalibrationState code '"+codeString+"'");
659        }
660    public String toCode(DeviceMetricCalibrationState code) {
661      if (code == DeviceMetricCalibrationState.NOTCALIBRATED)
662        return "not-calibrated";
663      if (code == DeviceMetricCalibrationState.CALIBRATIONREQUIRED)
664        return "calibration-required";
665      if (code == DeviceMetricCalibrationState.CALIBRATED)
666        return "calibrated";
667      if (code == DeviceMetricCalibrationState.UNSPECIFIED)
668        return "unspecified";
669      return "?";
670      }
671    }
672
673    @Block()
674    public static class DeviceMetricCalibrationComponent extends BackboneElement implements IBaseBackboneElement {
675        /**
676         * Describes the type of the calibration method.
677         */
678        @Child(name = "type", type = {CodeType.class}, order=1, min=0, max=1, modifier=false, summary=true)
679        @Description(shortDefinition="unspecified | offset | gain | two-point", formalDefinition="Describes the type of the calibration method." )
680        protected Enumeration<DeviceMetricCalibrationType> type;
681
682        /**
683         * Describes the state of the calibration.
684         */
685        @Child(name = "state", type = {CodeType.class}, order=2, min=0, max=1, modifier=false, summary=true)
686        @Description(shortDefinition="not-calibrated | calibration-required | calibrated | unspecified", formalDefinition="Describes the state of the calibration." )
687        protected Enumeration<DeviceMetricCalibrationState> state;
688
689        /**
690         * Describes the time last calibration has been performed.
691         */
692        @Child(name = "time", type = {InstantType.class}, order=3, min=0, max=1, modifier=false, summary=true)
693        @Description(shortDefinition="Describes the time last calibration has been performed", formalDefinition="Describes the time last calibration has been performed." )
694        protected InstantType time;
695
696        private static final long serialVersionUID = 1163986578L;
697
698    /*
699     * Constructor
700     */
701      public DeviceMetricCalibrationComponent() {
702        super();
703      }
704
705        /**
706         * @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
707         */
708        public Enumeration<DeviceMetricCalibrationType> getTypeElement() { 
709          if (this.type == null)
710            if (Configuration.errorOnAutoCreate())
711              throw new Error("Attempt to auto-create DeviceMetricCalibrationComponent.type");
712            else if (Configuration.doAutoCreate())
713              this.type = new Enumeration<DeviceMetricCalibrationType>(new DeviceMetricCalibrationTypeEnumFactory()); // bb
714          return this.type;
715        }
716
717        public boolean hasTypeElement() { 
718          return this.type != null && !this.type.isEmpty();
719        }
720
721        public boolean hasType() { 
722          return this.type != null && !this.type.isEmpty();
723        }
724
725        /**
726         * @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
727         */
728        public DeviceMetricCalibrationComponent setTypeElement(Enumeration<DeviceMetricCalibrationType> value) { 
729          this.type = value;
730          return this;
731        }
732
733        /**
734         * @return Describes the type of the calibration method.
735         */
736        public DeviceMetricCalibrationType getType() { 
737          return this.type == null ? null : this.type.getValue();
738        }
739
740        /**
741         * @param value Describes the type of the calibration method.
742         */
743        public DeviceMetricCalibrationComponent setType(DeviceMetricCalibrationType value) { 
744          if (value == null)
745            this.type = null;
746          else {
747            if (this.type == null)
748              this.type = new Enumeration<DeviceMetricCalibrationType>(new DeviceMetricCalibrationTypeEnumFactory());
749            this.type.setValue(value);
750          }
751          return this;
752        }
753
754        /**
755         * @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
756         */
757        public Enumeration<DeviceMetricCalibrationState> getStateElement() { 
758          if (this.state == null)
759            if (Configuration.errorOnAutoCreate())
760              throw new Error("Attempt to auto-create DeviceMetricCalibrationComponent.state");
761            else if (Configuration.doAutoCreate())
762              this.state = new Enumeration<DeviceMetricCalibrationState>(new DeviceMetricCalibrationStateEnumFactory()); // bb
763          return this.state;
764        }
765
766        public boolean hasStateElement() { 
767          return this.state != null && !this.state.isEmpty();
768        }
769
770        public boolean hasState() { 
771          return this.state != null && !this.state.isEmpty();
772        }
773
774        /**
775         * @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
776         */
777        public DeviceMetricCalibrationComponent setStateElement(Enumeration<DeviceMetricCalibrationState> value) { 
778          this.state = value;
779          return this;
780        }
781
782        /**
783         * @return Describes the state of the calibration.
784         */
785        public DeviceMetricCalibrationState getState() { 
786          return this.state == null ? null : this.state.getValue();
787        }
788
789        /**
790         * @param value Describes the state of the calibration.
791         */
792        public DeviceMetricCalibrationComponent setState(DeviceMetricCalibrationState value) { 
793          if (value == null)
794            this.state = null;
795          else {
796            if (this.state == null)
797              this.state = new Enumeration<DeviceMetricCalibrationState>(new DeviceMetricCalibrationStateEnumFactory());
798            this.state.setValue(value);
799          }
800          return this;
801        }
802
803        /**
804         * @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
805         */
806        public InstantType getTimeElement() { 
807          if (this.time == null)
808            if (Configuration.errorOnAutoCreate())
809              throw new Error("Attempt to auto-create DeviceMetricCalibrationComponent.time");
810            else if (Configuration.doAutoCreate())
811              this.time = new InstantType(); // bb
812          return this.time;
813        }
814
815        public boolean hasTimeElement() { 
816          return this.time != null && !this.time.isEmpty();
817        }
818
819        public boolean hasTime() { 
820          return this.time != null && !this.time.isEmpty();
821        }
822
823        /**
824         * @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
825         */
826        public DeviceMetricCalibrationComponent setTimeElement(InstantType value) { 
827          this.time = value;
828          return this;
829        }
830
831        /**
832         * @return Describes the time last calibration has been performed.
833         */
834        public Date getTime() { 
835          return this.time == null ? null : this.time.getValue();
836        }
837
838        /**
839         * @param value Describes the time last calibration has been performed.
840         */
841        public DeviceMetricCalibrationComponent setTime(Date value) { 
842          if (value == null)
843            this.time = null;
844          else {
845            if (this.time == null)
846              this.time = new InstantType();
847            this.time.setValue(value);
848          }
849          return this;
850        }
851
852        protected void listChildren(List<Property> childrenList) {
853          super.listChildren(childrenList);
854          childrenList.add(new Property("type", "code", "Describes the type of the calibration method.", 0, java.lang.Integer.MAX_VALUE, type));
855          childrenList.add(new Property("state", "code", "Describes the state of the calibration.", 0, java.lang.Integer.MAX_VALUE, state));
856          childrenList.add(new Property("time", "instant", "Describes the time last calibration has been performed.", 0, java.lang.Integer.MAX_VALUE, time));
857        }
858
859      @Override
860      public void setProperty(String name, Base value) throws FHIRException {
861        if (name.equals("type"))
862          this.type = new DeviceMetricCalibrationTypeEnumFactory().fromType(value); // Enumeration<DeviceMetricCalibrationType>
863        else if (name.equals("state"))
864          this.state = new DeviceMetricCalibrationStateEnumFactory().fromType(value); // Enumeration<DeviceMetricCalibrationState>
865        else if (name.equals("time"))
866          this.time = castToInstant(value); // InstantType
867        else
868          super.setProperty(name, value);
869      }
870
871      @Override
872      public Base addChild(String name) throws FHIRException {
873        if (name.equals("type")) {
874          throw new FHIRException("Cannot call addChild on a primitive type DeviceMetric.type");
875        }
876        else if (name.equals("state")) {
877          throw new FHIRException("Cannot call addChild on a primitive type DeviceMetric.state");
878        }
879        else if (name.equals("time")) {
880          throw new FHIRException("Cannot call addChild on a primitive type DeviceMetric.time");
881        }
882        else
883          return super.addChild(name);
884      }
885
886      public DeviceMetricCalibrationComponent copy() {
887        DeviceMetricCalibrationComponent dst = new DeviceMetricCalibrationComponent();
888        copyValues(dst);
889        dst.type = type == null ? null : type.copy();
890        dst.state = state == null ? null : state.copy();
891        dst.time = time == null ? null : time.copy();
892        return dst;
893      }
894
895      @Override
896      public boolean equalsDeep(Base other) {
897        if (!super.equalsDeep(other))
898          return false;
899        if (!(other instanceof DeviceMetricCalibrationComponent))
900          return false;
901        DeviceMetricCalibrationComponent o = (DeviceMetricCalibrationComponent) other;
902        return compareDeep(type, o.type, true) && compareDeep(state, o.state, true) && compareDeep(time, o.time, true)
903          ;
904      }
905
906      @Override
907      public boolean equalsShallow(Base other) {
908        if (!super.equalsShallow(other))
909          return false;
910        if (!(other instanceof DeviceMetricCalibrationComponent))
911          return false;
912        DeviceMetricCalibrationComponent o = (DeviceMetricCalibrationComponent) other;
913        return compareValues(type, o.type, true) && compareValues(state, o.state, true) && compareValues(time, o.time, true)
914          ;
915      }
916
917      public boolean isEmpty() {
918        return super.isEmpty() && (type == null || type.isEmpty()) && (state == null || state.isEmpty())
919           && (time == null || time.isEmpty());
920      }
921
922  public String fhirType() {
923    return "DeviceMetric.calibration";
924
925  }
926
927  }
928
929    /**
930     * Describes the type of the metric. For example: Heart Rate, PEEP Setting, etc.
931     */
932    @Child(name = "type", type = {CodeableConcept.class}, order=0, min=1, max=1, modifier=false, summary=true)
933    @Description(shortDefinition="Type of metric", formalDefinition="Describes the type of the metric. For example: Heart Rate, PEEP Setting, etc." )
934    protected CodeableConcept type;
935
936    /**
937     * 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.
938     */
939    @Child(name = "identifier", type = {Identifier.class}, order=1, min=1, max=1, modifier=false, summary=true)
940    @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." )
941    protected Identifier identifier;
942
943    /**
944     * Describes the unit that an observed value determined for this metric will have. For example: Percent, Seconds, etc.
945     */
946    @Child(name = "unit", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
947    @Description(shortDefinition="Unit of metric", formalDefinition="Describes the unit that an observed value determined for this metric will have. For example: Percent, Seconds, etc." )
948    protected CodeableConcept unit;
949
950    /**
951     * Describes the link to the  Device that this DeviceMetric belongs to and that contains administrative device information such as manufacture, serial number, etc.
952     */
953    @Child(name = "source", type = {Device.class}, order=3, min=0, max=1, modifier=false, summary=true)
954    @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 manufacture, serial number, etc." )
955    protected Reference source;
956
957    /**
958     * 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 manufacture, serial number, etc.)
959     */
960    protected Device sourceTarget;
961
962    /**
963     * 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.
964     */
965    @Child(name = "parent", type = {DeviceComponent.class}, order=4, min=0, max=1, modifier=false, summary=true)
966    @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." )
967    protected Reference parent;
968
969    /**
970     * 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.)
971     */
972    protected DeviceComponent parentTarget;
973
974    /**
975     * Indicates current operational state of the device. For example: On, Off, Standby, etc.
976     */
977    @Child(name = "operationalStatus", type = {CodeType.class}, order=5, min=0, max=1, modifier=false, summary=true)
978    @Description(shortDefinition="on | off | standby", formalDefinition="Indicates current operational state of the device. For example: On, Off, Standby, etc." )
979    protected Enumeration<DeviceMetricOperationalStatus> operationalStatus;
980
981    /**
982     * 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.
983     */
984    @Child(name = "color", type = {CodeType.class}, order=6, min=0, max=1, modifier=false, summary=true)
985    @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." )
986    protected Enumeration<DeviceMetricColor> color;
987
988    /**
989     * Indicates the category of the observation generation process. A DeviceMetric can be for example a setting, measurement, or calculation.
990     */
991    @Child(name = "category", type = {CodeType.class}, order=7, min=1, max=1, modifier=false, summary=true)
992    @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." )
993    protected Enumeration<DeviceMetricCategory> category;
994
995    /**
996     * 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.
997     */
998    @Child(name = "measurementPeriod", type = {Timing.class}, order=8, min=0, max=1, modifier=false, summary=true)
999    @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." )
1000    protected Timing measurementPeriod;
1001
1002    /**
1003     * Describes the calibrations that have been performed or that are required to be performed.
1004     */
1005    @Child(name = "calibration", type = {}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1006    @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." )
1007    protected List<DeviceMetricCalibrationComponent> calibration;
1008
1009    private static final long serialVersionUID = 1786401018L;
1010
1011  /*
1012   * Constructor
1013   */
1014    public DeviceMetric() {
1015      super();
1016    }
1017
1018  /*
1019   * Constructor
1020   */
1021    public DeviceMetric(CodeableConcept type, Identifier identifier, Enumeration<DeviceMetricCategory> category) {
1022      super();
1023      this.type = type;
1024      this.identifier = identifier;
1025      this.category = category;
1026    }
1027
1028    /**
1029     * @return {@link #type} (Describes the type of the metric. For example: Heart Rate, PEEP Setting, etc.)
1030     */
1031    public CodeableConcept getType() { 
1032      if (this.type == null)
1033        if (Configuration.errorOnAutoCreate())
1034          throw new Error("Attempt to auto-create DeviceMetric.type");
1035        else if (Configuration.doAutoCreate())
1036          this.type = new CodeableConcept(); // cc
1037      return this.type;
1038    }
1039
1040    public boolean hasType() { 
1041      return this.type != null && !this.type.isEmpty();
1042    }
1043
1044    /**
1045     * @param value {@link #type} (Describes the type of the metric. For example: Heart Rate, PEEP Setting, etc.)
1046     */
1047    public DeviceMetric setType(CodeableConcept value) { 
1048      this.type = value;
1049      return this;
1050    }
1051
1052    /**
1053     * @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.)
1054     */
1055    public Identifier getIdentifier() { 
1056      if (this.identifier == null)
1057        if (Configuration.errorOnAutoCreate())
1058          throw new Error("Attempt to auto-create DeviceMetric.identifier");
1059        else if (Configuration.doAutoCreate())
1060          this.identifier = new Identifier(); // cc
1061      return this.identifier;
1062    }
1063
1064    public boolean hasIdentifier() { 
1065      return this.identifier != null && !this.identifier.isEmpty();
1066    }
1067
1068    /**
1069     * @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.)
1070     */
1071    public DeviceMetric setIdentifier(Identifier value) { 
1072      this.identifier = value;
1073      return this;
1074    }
1075
1076    /**
1077     * @return {@link #unit} (Describes the unit that an observed value determined for this metric will have. For example: Percent, Seconds, etc.)
1078     */
1079    public CodeableConcept getUnit() { 
1080      if (this.unit == null)
1081        if (Configuration.errorOnAutoCreate())
1082          throw new Error("Attempt to auto-create DeviceMetric.unit");
1083        else if (Configuration.doAutoCreate())
1084          this.unit = new CodeableConcept(); // cc
1085      return this.unit;
1086    }
1087
1088    public boolean hasUnit() { 
1089      return this.unit != null && !this.unit.isEmpty();
1090    }
1091
1092    /**
1093     * @param value {@link #unit} (Describes the unit that an observed value determined for this metric will have. For example: Percent, Seconds, etc.)
1094     */
1095    public DeviceMetric setUnit(CodeableConcept value) { 
1096      this.unit = value;
1097      return this;
1098    }
1099
1100    /**
1101     * @return {@link #source} (Describes the link to the  Device that this DeviceMetric belongs to and that contains administrative device information such as manufacture, serial number, etc.)
1102     */
1103    public Reference getSource() { 
1104      if (this.source == null)
1105        if (Configuration.errorOnAutoCreate())
1106          throw new Error("Attempt to auto-create DeviceMetric.source");
1107        else if (Configuration.doAutoCreate())
1108          this.source = new Reference(); // cc
1109      return this.source;
1110    }
1111
1112    public boolean hasSource() { 
1113      return this.source != null && !this.source.isEmpty();
1114    }
1115
1116    /**
1117     * @param value {@link #source} (Describes the link to the  Device that this DeviceMetric belongs to and that contains administrative device information such as manufacture, serial number, etc.)
1118     */
1119    public DeviceMetric setSource(Reference value) { 
1120      this.source = value;
1121      return this;
1122    }
1123
1124    /**
1125     * @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 manufacture, serial number, etc.)
1126     */
1127    public Device getSourceTarget() { 
1128      if (this.sourceTarget == null)
1129        if (Configuration.errorOnAutoCreate())
1130          throw new Error("Attempt to auto-create DeviceMetric.source");
1131        else if (Configuration.doAutoCreate())
1132          this.sourceTarget = new Device(); // aa
1133      return this.sourceTarget;
1134    }
1135
1136    /**
1137     * @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 manufacture, serial number, etc.)
1138     */
1139    public DeviceMetric setSourceTarget(Device value) { 
1140      this.sourceTarget = value;
1141      return this;
1142    }
1143
1144    /**
1145     * @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.)
1146     */
1147    public Reference getParent() { 
1148      if (this.parent == null)
1149        if (Configuration.errorOnAutoCreate())
1150          throw new Error("Attempt to auto-create DeviceMetric.parent");
1151        else if (Configuration.doAutoCreate())
1152          this.parent = new Reference(); // cc
1153      return this.parent;
1154    }
1155
1156    public boolean hasParent() { 
1157      return this.parent != null && !this.parent.isEmpty();
1158    }
1159
1160    /**
1161     * @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.)
1162     */
1163    public DeviceMetric setParent(Reference value) { 
1164      this.parent = value;
1165      return this;
1166    }
1167
1168    /**
1169     * @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.)
1170     */
1171    public DeviceComponent getParentTarget() { 
1172      if (this.parentTarget == null)
1173        if (Configuration.errorOnAutoCreate())
1174          throw new Error("Attempt to auto-create DeviceMetric.parent");
1175        else if (Configuration.doAutoCreate())
1176          this.parentTarget = new DeviceComponent(); // aa
1177      return this.parentTarget;
1178    }
1179
1180    /**
1181     * @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.)
1182     */
1183    public DeviceMetric setParentTarget(DeviceComponent value) { 
1184      this.parentTarget = value;
1185      return this;
1186    }
1187
1188    /**
1189     * @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
1190     */
1191    public Enumeration<DeviceMetricOperationalStatus> getOperationalStatusElement() { 
1192      if (this.operationalStatus == null)
1193        if (Configuration.errorOnAutoCreate())
1194          throw new Error("Attempt to auto-create DeviceMetric.operationalStatus");
1195        else if (Configuration.doAutoCreate())
1196          this.operationalStatus = new Enumeration<DeviceMetricOperationalStatus>(new DeviceMetricOperationalStatusEnumFactory()); // bb
1197      return this.operationalStatus;
1198    }
1199
1200    public boolean hasOperationalStatusElement() { 
1201      return this.operationalStatus != null && !this.operationalStatus.isEmpty();
1202    }
1203
1204    public boolean hasOperationalStatus() { 
1205      return this.operationalStatus != null && !this.operationalStatus.isEmpty();
1206    }
1207
1208    /**
1209     * @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
1210     */
1211    public DeviceMetric setOperationalStatusElement(Enumeration<DeviceMetricOperationalStatus> value) { 
1212      this.operationalStatus = value;
1213      return this;
1214    }
1215
1216    /**
1217     * @return Indicates current operational state of the device. For example: On, Off, Standby, etc.
1218     */
1219    public DeviceMetricOperationalStatus getOperationalStatus() { 
1220      return this.operationalStatus == null ? null : this.operationalStatus.getValue();
1221    }
1222
1223    /**
1224     * @param value Indicates current operational state of the device. For example: On, Off, Standby, etc.
1225     */
1226    public DeviceMetric setOperationalStatus(DeviceMetricOperationalStatus value) { 
1227      if (value == null)
1228        this.operationalStatus = null;
1229      else {
1230        if (this.operationalStatus == null)
1231          this.operationalStatus = new Enumeration<DeviceMetricOperationalStatus>(new DeviceMetricOperationalStatusEnumFactory());
1232        this.operationalStatus.setValue(value);
1233      }
1234      return this;
1235    }
1236
1237    /**
1238     * @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
1239     */
1240    public Enumeration<DeviceMetricColor> getColorElement() { 
1241      if (this.color == null)
1242        if (Configuration.errorOnAutoCreate())
1243          throw new Error("Attempt to auto-create DeviceMetric.color");
1244        else if (Configuration.doAutoCreate())
1245          this.color = new Enumeration<DeviceMetricColor>(new DeviceMetricColorEnumFactory()); // bb
1246      return this.color;
1247    }
1248
1249    public boolean hasColorElement() { 
1250      return this.color != null && !this.color.isEmpty();
1251    }
1252
1253    public boolean hasColor() { 
1254      return this.color != null && !this.color.isEmpty();
1255    }
1256
1257    /**
1258     * @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
1259     */
1260    public DeviceMetric setColorElement(Enumeration<DeviceMetricColor> value) { 
1261      this.color = value;
1262      return this;
1263    }
1264
1265    /**
1266     * @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.
1267     */
1268    public DeviceMetricColor getColor() { 
1269      return this.color == null ? null : this.color.getValue();
1270    }
1271
1272    /**
1273     * @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.
1274     */
1275    public DeviceMetric setColor(DeviceMetricColor value) { 
1276      if (value == null)
1277        this.color = null;
1278      else {
1279        if (this.color == null)
1280          this.color = new Enumeration<DeviceMetricColor>(new DeviceMetricColorEnumFactory());
1281        this.color.setValue(value);
1282      }
1283      return this;
1284    }
1285
1286    /**
1287     * @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
1288     */
1289    public Enumeration<DeviceMetricCategory> getCategoryElement() { 
1290      if (this.category == null)
1291        if (Configuration.errorOnAutoCreate())
1292          throw new Error("Attempt to auto-create DeviceMetric.category");
1293        else if (Configuration.doAutoCreate())
1294          this.category = new Enumeration<DeviceMetricCategory>(new DeviceMetricCategoryEnumFactory()); // bb
1295      return this.category;
1296    }
1297
1298    public boolean hasCategoryElement() { 
1299      return this.category != null && !this.category.isEmpty();
1300    }
1301
1302    public boolean hasCategory() { 
1303      return this.category != null && !this.category.isEmpty();
1304    }
1305
1306    /**
1307     * @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
1308     */
1309    public DeviceMetric setCategoryElement(Enumeration<DeviceMetricCategory> value) { 
1310      this.category = value;
1311      return this;
1312    }
1313
1314    /**
1315     * @return Indicates the category of the observation generation process. A DeviceMetric can be for example a setting, measurement, or calculation.
1316     */
1317    public DeviceMetricCategory getCategory() { 
1318      return this.category == null ? null : this.category.getValue();
1319    }
1320
1321    /**
1322     * @param value Indicates the category of the observation generation process. A DeviceMetric can be for example a setting, measurement, or calculation.
1323     */
1324    public DeviceMetric setCategory(DeviceMetricCategory value) { 
1325        if (this.category == null)
1326          this.category = new Enumeration<DeviceMetricCategory>(new DeviceMetricCategoryEnumFactory());
1327        this.category.setValue(value);
1328      return this;
1329    }
1330
1331    /**
1332     * @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.)
1333     */
1334    public Timing getMeasurementPeriod() { 
1335      if (this.measurementPeriod == null)
1336        if (Configuration.errorOnAutoCreate())
1337          throw new Error("Attempt to auto-create DeviceMetric.measurementPeriod");
1338        else if (Configuration.doAutoCreate())
1339          this.measurementPeriod = new Timing(); // cc
1340      return this.measurementPeriod;
1341    }
1342
1343    public boolean hasMeasurementPeriod() { 
1344      return this.measurementPeriod != null && !this.measurementPeriod.isEmpty();
1345    }
1346
1347    /**
1348     * @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.)
1349     */
1350    public DeviceMetric setMeasurementPeriod(Timing value) { 
1351      this.measurementPeriod = value;
1352      return this;
1353    }
1354
1355    /**
1356     * @return {@link #calibration} (Describes the calibrations that have been performed or that are required to be performed.)
1357     */
1358    public List<DeviceMetricCalibrationComponent> getCalibration() { 
1359      if (this.calibration == null)
1360        this.calibration = new ArrayList<DeviceMetricCalibrationComponent>();
1361      return this.calibration;
1362    }
1363
1364    public boolean hasCalibration() { 
1365      if (this.calibration == null)
1366        return false;
1367      for (DeviceMetricCalibrationComponent item : this.calibration)
1368        if (!item.isEmpty())
1369          return true;
1370      return false;
1371    }
1372
1373    /**
1374     * @return {@link #calibration} (Describes the calibrations that have been performed or that are required to be performed.)
1375     */
1376    // syntactic sugar
1377    public DeviceMetricCalibrationComponent addCalibration() { //3
1378      DeviceMetricCalibrationComponent t = new DeviceMetricCalibrationComponent();
1379      if (this.calibration == null)
1380        this.calibration = new ArrayList<DeviceMetricCalibrationComponent>();
1381      this.calibration.add(t);
1382      return t;
1383    }
1384
1385    // syntactic sugar
1386    public DeviceMetric addCalibration(DeviceMetricCalibrationComponent t) { //3
1387      if (t == null)
1388        return this;
1389      if (this.calibration == null)
1390        this.calibration = new ArrayList<DeviceMetricCalibrationComponent>();
1391      this.calibration.add(t);
1392      return this;
1393    }
1394
1395      protected void listChildren(List<Property> childrenList) {
1396        super.listChildren(childrenList);
1397        childrenList.add(new Property("type", "CodeableConcept", "Describes the type of the metric. For example: Heart Rate, PEEP Setting, etc.", 0, java.lang.Integer.MAX_VALUE, type));
1398        childrenList.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, java.lang.Integer.MAX_VALUE, identifier));
1399        childrenList.add(new Property("unit", "CodeableConcept", "Describes the unit that an observed value determined for this metric will have. For example: Percent, Seconds, etc.", 0, java.lang.Integer.MAX_VALUE, unit));
1400        childrenList.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 manufacture, serial number, etc.", 0, java.lang.Integer.MAX_VALUE, source));
1401        childrenList.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, java.lang.Integer.MAX_VALUE, parent));
1402        childrenList.add(new Property("operationalStatus", "code", "Indicates current operational state of the device. For example: On, Off, Standby, etc.", 0, java.lang.Integer.MAX_VALUE, operationalStatus));
1403        childrenList.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, java.lang.Integer.MAX_VALUE, color));
1404        childrenList.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, java.lang.Integer.MAX_VALUE, category));
1405        childrenList.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, java.lang.Integer.MAX_VALUE, measurementPeriod));
1406        childrenList.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));
1407      }
1408
1409      @Override
1410      public void setProperty(String name, Base value) throws FHIRException {
1411        if (name.equals("type"))
1412          this.type = castToCodeableConcept(value); // CodeableConcept
1413        else if (name.equals("identifier"))
1414          this.identifier = castToIdentifier(value); // Identifier
1415        else if (name.equals("unit"))
1416          this.unit = castToCodeableConcept(value); // CodeableConcept
1417        else if (name.equals("source"))
1418          this.source = castToReference(value); // Reference
1419        else if (name.equals("parent"))
1420          this.parent = castToReference(value); // Reference
1421        else if (name.equals("operationalStatus"))
1422          this.operationalStatus = new DeviceMetricOperationalStatusEnumFactory().fromType(value); // Enumeration<DeviceMetricOperationalStatus>
1423        else if (name.equals("color"))
1424          this.color = new DeviceMetricColorEnumFactory().fromType(value); // Enumeration<DeviceMetricColor>
1425        else if (name.equals("category"))
1426          this.category = new DeviceMetricCategoryEnumFactory().fromType(value); // Enumeration<DeviceMetricCategory>
1427        else if (name.equals("measurementPeriod"))
1428          this.measurementPeriod = castToTiming(value); // Timing
1429        else if (name.equals("calibration"))
1430          this.getCalibration().add((DeviceMetricCalibrationComponent) value);
1431        else
1432          super.setProperty(name, value);
1433      }
1434
1435      @Override
1436      public Base addChild(String name) throws FHIRException {
1437        if (name.equals("type")) {
1438          this.type = new CodeableConcept();
1439          return this.type;
1440        }
1441        else if (name.equals("identifier")) {
1442          this.identifier = new Identifier();
1443          return this.identifier;
1444        }
1445        else if (name.equals("unit")) {
1446          this.unit = new CodeableConcept();
1447          return this.unit;
1448        }
1449        else if (name.equals("source")) {
1450          this.source = new Reference();
1451          return this.source;
1452        }
1453        else if (name.equals("parent")) {
1454          this.parent = new Reference();
1455          return this.parent;
1456        }
1457        else if (name.equals("operationalStatus")) {
1458          throw new FHIRException("Cannot call addChild on a primitive type DeviceMetric.operationalStatus");
1459        }
1460        else if (name.equals("color")) {
1461          throw new FHIRException("Cannot call addChild on a primitive type DeviceMetric.color");
1462        }
1463        else if (name.equals("category")) {
1464          throw new FHIRException("Cannot call addChild on a primitive type DeviceMetric.category");
1465        }
1466        else if (name.equals("measurementPeriod")) {
1467          this.measurementPeriod = new Timing();
1468          return this.measurementPeriod;
1469        }
1470        else if (name.equals("calibration")) {
1471          return addCalibration();
1472        }
1473        else
1474          return super.addChild(name);
1475      }
1476
1477  public String fhirType() {
1478    return "DeviceMetric";
1479
1480  }
1481
1482      public DeviceMetric copy() {
1483        DeviceMetric dst = new DeviceMetric();
1484        copyValues(dst);
1485        dst.type = type == null ? null : type.copy();
1486        dst.identifier = identifier == null ? null : identifier.copy();
1487        dst.unit = unit == null ? null : unit.copy();
1488        dst.source = source == null ? null : source.copy();
1489        dst.parent = parent == null ? null : parent.copy();
1490        dst.operationalStatus = operationalStatus == null ? null : operationalStatus.copy();
1491        dst.color = color == null ? null : color.copy();
1492        dst.category = category == null ? null : category.copy();
1493        dst.measurementPeriod = measurementPeriod == null ? null : measurementPeriod.copy();
1494        if (calibration != null) {
1495          dst.calibration = new ArrayList<DeviceMetricCalibrationComponent>();
1496          for (DeviceMetricCalibrationComponent i : calibration)
1497            dst.calibration.add(i.copy());
1498        };
1499        return dst;
1500      }
1501
1502      protected DeviceMetric typedCopy() {
1503        return copy();
1504      }
1505
1506      @Override
1507      public boolean equalsDeep(Base other) {
1508        if (!super.equalsDeep(other))
1509          return false;
1510        if (!(other instanceof DeviceMetric))
1511          return false;
1512        DeviceMetric o = (DeviceMetric) other;
1513        return compareDeep(type, o.type, true) && compareDeep(identifier, o.identifier, true) && compareDeep(unit, o.unit, true)
1514           && compareDeep(source, o.source, true) && compareDeep(parent, o.parent, true) && compareDeep(operationalStatus, o.operationalStatus, true)
1515           && compareDeep(color, o.color, true) && compareDeep(category, o.category, true) && compareDeep(measurementPeriod, o.measurementPeriod, true)
1516           && compareDeep(calibration, o.calibration, true);
1517      }
1518
1519      @Override
1520      public boolean equalsShallow(Base other) {
1521        if (!super.equalsShallow(other))
1522          return false;
1523        if (!(other instanceof DeviceMetric))
1524          return false;
1525        DeviceMetric o = (DeviceMetric) other;
1526        return compareValues(operationalStatus, o.operationalStatus, true) && compareValues(color, o.color, true)
1527           && compareValues(category, o.category, true);
1528      }
1529
1530      public boolean isEmpty() {
1531        return super.isEmpty() && (type == null || type.isEmpty()) && (identifier == null || identifier.isEmpty())
1532           && (unit == null || unit.isEmpty()) && (source == null || source.isEmpty()) && (parent == null || parent.isEmpty())
1533           && (operationalStatus == null || operationalStatus.isEmpty()) && (color == null || color.isEmpty())
1534           && (category == null || category.isEmpty()) && (measurementPeriod == null || measurementPeriod.isEmpty())
1535           && (calibration == null || calibration.isEmpty());
1536      }
1537
1538  @Override
1539  public ResourceType getResourceType() {
1540    return ResourceType.DeviceMetric;
1541   }
1542
1543  @SearchParamDefinition(name="parent", path="DeviceMetric.parent", description="The parent DeviceMetric resource", type="reference" )
1544  public static final String SP_PARENT = "parent";
1545  @SearchParamDefinition(name="identifier", path="DeviceMetric.identifier", description="The identifier of the metric", type="token" )
1546  public static final String SP_IDENTIFIER = "identifier";
1547  @SearchParamDefinition(name="source", path="DeviceMetric.source", description="The device resource", type="reference" )
1548  public static final String SP_SOURCE = "source";
1549  @SearchParamDefinition(name="type", path="DeviceMetric.type", description="The component type", type="token" )
1550  public static final String SP_TYPE = "type";
1551  @SearchParamDefinition(name="category", path="DeviceMetric.category", description="The category of the metric", type="token" )
1552  public static final String SP_CATEGORY = "category";
1553
1554}
1555