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