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