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