001package org.hl7.fhir.r4.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1
033import java.util.ArrayList;
034import java.util.Date;
035import java.util.List;
036
037import org.hl7.fhir.exceptions.FHIRException;
038import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
039
040import ca.uhn.fhir.model.api.annotation.Block;
041import ca.uhn.fhir.model.api.annotation.Child;
042import ca.uhn.fhir.model.api.annotation.Description;
043import ca.uhn.fhir.model.api.annotation.ResourceDef;
044import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
045
046/**
047 * Describes a measurement, calculation or setting capability of a medical
048 * device.
049 */
050@ResourceDef(name = "DeviceMetric", profile = "http://hl7.org/fhir/StructureDefinition/DeviceMetric")
051public class DeviceMetric extends DomainResource {
052
053  public enum DeviceMetricOperationalStatus {
054    /**
055     * The DeviceMetric is operating and will generate DeviceObservations.
056     */
057    ON,
058    /**
059     * The DeviceMetric is not operating.
060     */
061    OFF,
062    /**
063     * The DeviceMetric is operating, but will not generate any DeviceObservations.
064     */
065    STANDBY,
066    /**
067     * The DeviceMetric was entered in error.
068     */
069    ENTEREDINERROR,
070    /**
071     * added to help the parsers with the generic types
072     */
073    NULL;
074
075    public static DeviceMetricOperationalStatus fromCode(String codeString) throws FHIRException {
076      if (codeString == null || "".equals(codeString))
077        return null;
078      if ("on".equals(codeString))
079        return ON;
080      if ("off".equals(codeString))
081        return OFF;
082      if ("standby".equals(codeString))
083        return STANDBY;
084      if ("entered-in-error".equals(codeString))
085        return ENTEREDINERROR;
086      if (Configuration.isAcceptInvalidEnums())
087        return null;
088      else
089        throw new FHIRException("Unknown DeviceMetricOperationalStatus code '" + codeString + "'");
090    }
091
092    public String toCode() {
093      switch (this) {
094      case ON:
095        return "on";
096      case OFF:
097        return "off";
098      case STANDBY:
099        return "standby";
100      case ENTEREDINERROR:
101        return "entered-in-error";
102      case NULL:
103        return null;
104      default:
105        return "?";
106      }
107    }
108
109    public String getSystem() {
110      switch (this) {
111      case ON:
112        return "http://hl7.org/fhir/metric-operational-status";
113      case OFF:
114        return "http://hl7.org/fhir/metric-operational-status";
115      case STANDBY:
116        return "http://hl7.org/fhir/metric-operational-status";
117      case ENTEREDINERROR:
118        return "http://hl7.org/fhir/metric-operational-status";
119      case NULL:
120        return null;
121      default:
122        return "?";
123      }
124    }
125
126    public String getDefinition() {
127      switch (this) {
128      case ON:
129        return "The DeviceMetric is operating and will generate DeviceObservations.";
130      case OFF:
131        return "The DeviceMetric is not operating.";
132      case STANDBY:
133        return "The DeviceMetric is operating, but will not generate any DeviceObservations.";
134      case ENTEREDINERROR:
135        return "The DeviceMetric was entered in error.";
136      case NULL:
137        return null;
138      default:
139        return "?";
140      }
141    }
142
143    public String getDisplay() {
144      switch (this) {
145      case ON:
146        return "On";
147      case OFF:
148        return "Off";
149      case STANDBY:
150        return "Standby";
151      case ENTEREDINERROR:
152        return "Entered In Error";
153      case NULL:
154        return null;
155      default:
156        return "?";
157      }
158    }
159  }
160
161  public static class DeviceMetricOperationalStatusEnumFactory implements EnumFactory<DeviceMetricOperationalStatus> {
162    public DeviceMetricOperationalStatus fromCode(String codeString) throws IllegalArgumentException {
163      if (codeString == null || "".equals(codeString))
164        if (codeString == null || "".equals(codeString))
165          return null;
166      if ("on".equals(codeString))
167        return DeviceMetricOperationalStatus.ON;
168      if ("off".equals(codeString))
169        return DeviceMetricOperationalStatus.OFF;
170      if ("standby".equals(codeString))
171        return DeviceMetricOperationalStatus.STANDBY;
172      if ("entered-in-error".equals(codeString))
173        return DeviceMetricOperationalStatus.ENTEREDINERROR;
174      throw new IllegalArgumentException("Unknown DeviceMetricOperationalStatus code '" + codeString + "'");
175    }
176
177    public Enumeration<DeviceMetricOperationalStatus> fromType(PrimitiveType<?> code) throws FHIRException {
178      if (code == null)
179        return null;
180      if (code.isEmpty())
181        return new Enumeration<DeviceMetricOperationalStatus>(this, DeviceMetricOperationalStatus.NULL, code);
182      String codeString = code.asStringValue();
183      if (codeString == null || "".equals(codeString))
184        return new Enumeration<DeviceMetricOperationalStatus>(this, DeviceMetricOperationalStatus.NULL, code);
185      if ("on".equals(codeString))
186        return new Enumeration<DeviceMetricOperationalStatus>(this, DeviceMetricOperationalStatus.ON, code);
187      if ("off".equals(codeString))
188        return new Enumeration<DeviceMetricOperationalStatus>(this, DeviceMetricOperationalStatus.OFF, code);
189      if ("standby".equals(codeString))
190        return new Enumeration<DeviceMetricOperationalStatus>(this, DeviceMetricOperationalStatus.STANDBY, code);
191      if ("entered-in-error".equals(codeString))
192        return new Enumeration<DeviceMetricOperationalStatus>(this, DeviceMetricOperationalStatus.ENTEREDINERROR, code);
193      throw new FHIRException("Unknown DeviceMetricOperationalStatus code '" + codeString + "'");
194    }
195
196    public String toCode(DeviceMetricOperationalStatus code) {
197      if (code == DeviceMetricOperationalStatus.ON)
198        return "on";
199      if (code == DeviceMetricOperationalStatus.OFF)
200        return "off";
201      if (code == DeviceMetricOperationalStatus.STANDBY)
202        return "standby";
203      if (code == DeviceMetricOperationalStatus.ENTEREDINERROR)
204        return "entered-in-error";
205      return "?";
206    }
207
208    public String toSystem(DeviceMetricOperationalStatus code) {
209      return code.getSystem();
210    }
211  }
212
213  public enum DeviceMetricColor {
214    /**
215     * Color for representation - black.
216     */
217    BLACK,
218    /**
219     * Color for representation - red.
220     */
221    RED,
222    /**
223     * Color for representation - green.
224     */
225    GREEN,
226    /**
227     * Color for representation - yellow.
228     */
229    YELLOW,
230    /**
231     * Color for representation - blue.
232     */
233    BLUE,
234    /**
235     * Color for representation - magenta.
236     */
237    MAGENTA,
238    /**
239     * Color for representation - cyan.
240     */
241    CYAN,
242    /**
243     * Color for representation - white.
244     */
245    WHITE,
246    /**
247     * added to help the parsers with the generic types
248     */
249    NULL;
250
251    public static DeviceMetricColor fromCode(String codeString) throws FHIRException {
252      if (codeString == null || "".equals(codeString))
253        return null;
254      if ("black".equals(codeString))
255        return BLACK;
256      if ("red".equals(codeString))
257        return RED;
258      if ("green".equals(codeString))
259        return GREEN;
260      if ("yellow".equals(codeString))
261        return YELLOW;
262      if ("blue".equals(codeString))
263        return BLUE;
264      if ("magenta".equals(codeString))
265        return MAGENTA;
266      if ("cyan".equals(codeString))
267        return CYAN;
268      if ("white".equals(codeString))
269        return WHITE;
270      if (Configuration.isAcceptInvalidEnums())
271        return null;
272      else
273        throw new FHIRException("Unknown DeviceMetricColor code '" + codeString + "'");
274    }
275
276    public String toCode() {
277      switch (this) {
278      case BLACK:
279        return "black";
280      case RED:
281        return "red";
282      case GREEN:
283        return "green";
284      case YELLOW:
285        return "yellow";
286      case BLUE:
287        return "blue";
288      case MAGENTA:
289        return "magenta";
290      case CYAN:
291        return "cyan";
292      case WHITE:
293        return "white";
294      case NULL:
295        return null;
296      default:
297        return "?";
298      }
299    }
300
301    public String getSystem() {
302      switch (this) {
303      case BLACK:
304        return "http://hl7.org/fhir/metric-color";
305      case RED:
306        return "http://hl7.org/fhir/metric-color";
307      case GREEN:
308        return "http://hl7.org/fhir/metric-color";
309      case YELLOW:
310        return "http://hl7.org/fhir/metric-color";
311      case BLUE:
312        return "http://hl7.org/fhir/metric-color";
313      case MAGENTA:
314        return "http://hl7.org/fhir/metric-color";
315      case CYAN:
316        return "http://hl7.org/fhir/metric-color";
317      case WHITE:
318        return "http://hl7.org/fhir/metric-color";
319      case NULL:
320        return null;
321      default:
322        return "?";
323      }
324    }
325
326    public String getDefinition() {
327      switch (this) {
328      case BLACK:
329        return "Color for representation - black.";
330      case RED:
331        return "Color for representation - red.";
332      case GREEN:
333        return "Color for representation - green.";
334      case YELLOW:
335        return "Color for representation - yellow.";
336      case BLUE:
337        return "Color for representation - blue.";
338      case MAGENTA:
339        return "Color for representation - magenta.";
340      case CYAN:
341        return "Color for representation - cyan.";
342      case WHITE:
343        return "Color for representation - white.";
344      case NULL:
345        return null;
346      default:
347        return "?";
348      }
349    }
350
351    public String getDisplay() {
352      switch (this) {
353      case BLACK:
354        return "Color Black";
355      case RED:
356        return "Color Red";
357      case GREEN:
358        return "Color Green";
359      case YELLOW:
360        return "Color Yellow";
361      case BLUE:
362        return "Color Blue";
363      case MAGENTA:
364        return "Color Magenta";
365      case CYAN:
366        return "Color Cyan";
367      case WHITE:
368        return "Color White";
369      case NULL:
370        return null;
371      default:
372        return "?";
373      }
374    }
375  }
376
377  public static class DeviceMetricColorEnumFactory implements EnumFactory<DeviceMetricColor> {
378    public DeviceMetricColor fromCode(String codeString) throws IllegalArgumentException {
379      if (codeString == null || "".equals(codeString))
380        if (codeString == null || "".equals(codeString))
381          return null;
382      if ("black".equals(codeString))
383        return DeviceMetricColor.BLACK;
384      if ("red".equals(codeString))
385        return DeviceMetricColor.RED;
386      if ("green".equals(codeString))
387        return DeviceMetricColor.GREEN;
388      if ("yellow".equals(codeString))
389        return DeviceMetricColor.YELLOW;
390      if ("blue".equals(codeString))
391        return DeviceMetricColor.BLUE;
392      if ("magenta".equals(codeString))
393        return DeviceMetricColor.MAGENTA;
394      if ("cyan".equals(codeString))
395        return DeviceMetricColor.CYAN;
396      if ("white".equals(codeString))
397        return DeviceMetricColor.WHITE;
398      throw new IllegalArgumentException("Unknown DeviceMetricColor code '" + codeString + "'");
399    }
400
401    public Enumeration<DeviceMetricColor> fromType(PrimitiveType<?> code) throws FHIRException {
402      if (code == null)
403        return null;
404      if (code.isEmpty())
405        return new Enumeration<DeviceMetricColor>(this, DeviceMetricColor.NULL, code);
406      String codeString = code.asStringValue();
407      if (codeString == null || "".equals(codeString))
408        return new Enumeration<DeviceMetricColor>(this, DeviceMetricColor.NULL, code);
409      if ("black".equals(codeString))
410        return new Enumeration<DeviceMetricColor>(this, DeviceMetricColor.BLACK, code);
411      if ("red".equals(codeString))
412        return new Enumeration<DeviceMetricColor>(this, DeviceMetricColor.RED, code);
413      if ("green".equals(codeString))
414        return new Enumeration<DeviceMetricColor>(this, DeviceMetricColor.GREEN, code);
415      if ("yellow".equals(codeString))
416        return new Enumeration<DeviceMetricColor>(this, DeviceMetricColor.YELLOW, code);
417      if ("blue".equals(codeString))
418        return new Enumeration<DeviceMetricColor>(this, DeviceMetricColor.BLUE, code);
419      if ("magenta".equals(codeString))
420        return new Enumeration<DeviceMetricColor>(this, DeviceMetricColor.MAGENTA, code);
421      if ("cyan".equals(codeString))
422        return new Enumeration<DeviceMetricColor>(this, DeviceMetricColor.CYAN, code);
423      if ("white".equals(codeString))
424        return new Enumeration<DeviceMetricColor>(this, DeviceMetricColor.WHITE, code);
425      throw new FHIRException("Unknown DeviceMetricColor code '" + codeString + "'");
426    }
427
428    public String toCode(DeviceMetricColor code) {
429      if (code == DeviceMetricColor.BLACK)
430        return "black";
431      if (code == DeviceMetricColor.RED)
432        return "red";
433      if (code == DeviceMetricColor.GREEN)
434        return "green";
435      if (code == DeviceMetricColor.YELLOW)
436        return "yellow";
437      if (code == DeviceMetricColor.BLUE)
438        return "blue";
439      if (code == DeviceMetricColor.MAGENTA)
440        return "magenta";
441      if (code == DeviceMetricColor.CYAN)
442        return "cyan";
443      if (code == DeviceMetricColor.WHITE)
444        return "white";
445      return "?";
446    }
447
448    public String toSystem(DeviceMetricColor code) {
449      return code.getSystem();
450    }
451  }
452
453  public enum DeviceMetricCategory {
454    /**
455     * DeviceObservations generated for this DeviceMetric are measured.
456     */
457    MEASUREMENT,
458    /**
459     * DeviceObservations generated for this DeviceMetric is a setting that will
460     * influence the behavior of the Device.
461     */
462    SETTING,
463    /**
464     * DeviceObservations generated for this DeviceMetric are calculated.
465     */
466    CALCULATION,
467    /**
468     * The category of this DeviceMetric is unspecified.
469     */
470    UNSPECIFIED,
471    /**
472     * added to help the parsers with the generic types
473     */
474    NULL;
475
476    public static DeviceMetricCategory fromCode(String codeString) throws FHIRException {
477      if (codeString == null || "".equals(codeString))
478        return null;
479      if ("measurement".equals(codeString))
480        return MEASUREMENT;
481      if ("setting".equals(codeString))
482        return SETTING;
483      if ("calculation".equals(codeString))
484        return CALCULATION;
485      if ("unspecified".equals(codeString))
486        return UNSPECIFIED;
487      if (Configuration.isAcceptInvalidEnums())
488        return null;
489      else
490        throw new FHIRException("Unknown DeviceMetricCategory code '" + codeString + "'");
491    }
492
493    public String toCode() {
494      switch (this) {
495      case MEASUREMENT:
496        return "measurement";
497      case SETTING:
498        return "setting";
499      case CALCULATION:
500        return "calculation";
501      case UNSPECIFIED:
502        return "unspecified";
503      case NULL:
504        return null;
505      default:
506        return "?";
507      }
508    }
509
510    public String getSystem() {
511      switch (this) {
512      case MEASUREMENT:
513        return "http://hl7.org/fhir/metric-category";
514      case SETTING:
515        return "http://hl7.org/fhir/metric-category";
516      case CALCULATION:
517        return "http://hl7.org/fhir/metric-category";
518      case UNSPECIFIED:
519        return "http://hl7.org/fhir/metric-category";
520      case NULL:
521        return null;
522      default:
523        return "?";
524      }
525    }
526
527    public String getDefinition() {
528      switch (this) {
529      case MEASUREMENT:
530        return "DeviceObservations generated for this DeviceMetric are measured.";
531      case SETTING:
532        return "DeviceObservations generated for this DeviceMetric is a setting that will influence the behavior of the Device.";
533      case CALCULATION:
534        return "DeviceObservations generated for this DeviceMetric are calculated.";
535      case UNSPECIFIED:
536        return "The category of this DeviceMetric is unspecified.";
537      case NULL:
538        return null;
539      default:
540        return "?";
541      }
542    }
543
544    public String getDisplay() {
545      switch (this) {
546      case MEASUREMENT:
547        return "Measurement";
548      case SETTING:
549        return "Setting";
550      case CALCULATION:
551        return "Calculation";
552      case UNSPECIFIED:
553        return "Unspecified";
554      case NULL:
555        return null;
556      default:
557        return "?";
558      }
559    }
560  }
561
562  public static class DeviceMetricCategoryEnumFactory implements EnumFactory<DeviceMetricCategory> {
563    public DeviceMetricCategory fromCode(String codeString) throws IllegalArgumentException {
564      if (codeString == null || "".equals(codeString))
565        if (codeString == null || "".equals(codeString))
566          return null;
567      if ("measurement".equals(codeString))
568        return DeviceMetricCategory.MEASUREMENT;
569      if ("setting".equals(codeString))
570        return DeviceMetricCategory.SETTING;
571      if ("calculation".equals(codeString))
572        return DeviceMetricCategory.CALCULATION;
573      if ("unspecified".equals(codeString))
574        return DeviceMetricCategory.UNSPECIFIED;
575      throw new IllegalArgumentException("Unknown DeviceMetricCategory code '" + codeString + "'");
576    }
577
578    public Enumeration<DeviceMetricCategory> fromType(PrimitiveType<?> code) throws FHIRException {
579      if (code == null)
580        return null;
581      if (code.isEmpty())
582        return new Enumeration<DeviceMetricCategory>(this, DeviceMetricCategory.NULL, code);
583      String codeString = code.asStringValue();
584      if (codeString == null || "".equals(codeString))
585        return new Enumeration<DeviceMetricCategory>(this, DeviceMetricCategory.NULL, code);
586      if ("measurement".equals(codeString))
587        return new Enumeration<DeviceMetricCategory>(this, DeviceMetricCategory.MEASUREMENT, code);
588      if ("setting".equals(codeString))
589        return new Enumeration<DeviceMetricCategory>(this, DeviceMetricCategory.SETTING, code);
590      if ("calculation".equals(codeString))
591        return new Enumeration<DeviceMetricCategory>(this, DeviceMetricCategory.CALCULATION, code);
592      if ("unspecified".equals(codeString))
593        return new Enumeration<DeviceMetricCategory>(this, DeviceMetricCategory.UNSPECIFIED, code);
594      throw new FHIRException("Unknown DeviceMetricCategory code '" + codeString + "'");
595    }
596
597    public String toCode(DeviceMetricCategory code) {
598      if (code == DeviceMetricCategory.MEASUREMENT)
599        return "measurement";
600      if (code == DeviceMetricCategory.SETTING)
601        return "setting";
602      if (code == DeviceMetricCategory.CALCULATION)
603        return "calculation";
604      if (code == DeviceMetricCategory.UNSPECIFIED)
605        return "unspecified";
606      return "?";
607    }
608
609    public String toSystem(DeviceMetricCategory code) {
610      return code.getSystem();
611    }
612  }
613
614  public enum DeviceMetricCalibrationType {
615    /**
616     * Metric calibration method has not been identified.
617     */
618    UNSPECIFIED,
619    /**
620     * Offset metric calibration method.
621     */
622    OFFSET,
623    /**
624     * Gain metric calibration method.
625     */
626    GAIN,
627    /**
628     * Two-point metric calibration method.
629     */
630    TWOPOINT,
631    /**
632     * added to help the parsers with the generic types
633     */
634    NULL;
635
636    public static DeviceMetricCalibrationType fromCode(String codeString) throws FHIRException {
637      if (codeString == null || "".equals(codeString))
638        return null;
639      if ("unspecified".equals(codeString))
640        return UNSPECIFIED;
641      if ("offset".equals(codeString))
642        return OFFSET;
643      if ("gain".equals(codeString))
644        return GAIN;
645      if ("two-point".equals(codeString))
646        return TWOPOINT;
647      if (Configuration.isAcceptInvalidEnums())
648        return null;
649      else
650        throw new FHIRException("Unknown DeviceMetricCalibrationType code '" + codeString + "'");
651    }
652
653    public String toCode() {
654      switch (this) {
655      case UNSPECIFIED:
656        return "unspecified";
657      case OFFSET:
658        return "offset";
659      case GAIN:
660        return "gain";
661      case TWOPOINT:
662        return "two-point";
663      case NULL:
664        return null;
665      default:
666        return "?";
667      }
668    }
669
670    public String getSystem() {
671      switch (this) {
672      case UNSPECIFIED:
673        return "http://hl7.org/fhir/metric-calibration-type";
674      case OFFSET:
675        return "http://hl7.org/fhir/metric-calibration-type";
676      case GAIN:
677        return "http://hl7.org/fhir/metric-calibration-type";
678      case TWOPOINT:
679        return "http://hl7.org/fhir/metric-calibration-type";
680      case NULL:
681        return null;
682      default:
683        return "?";
684      }
685    }
686
687    public String getDefinition() {
688      switch (this) {
689      case UNSPECIFIED:
690        return "Metric calibration method has not been identified.";
691      case OFFSET:
692        return "Offset metric calibration method.";
693      case GAIN:
694        return "Gain metric calibration method.";
695      case TWOPOINT:
696        return "Two-point metric calibration method.";
697      case NULL:
698        return null;
699      default:
700        return "?";
701      }
702    }
703
704    public String getDisplay() {
705      switch (this) {
706      case UNSPECIFIED:
707        return "Unspecified";
708      case OFFSET:
709        return "Offset";
710      case GAIN:
711        return "Gain";
712      case TWOPOINT:
713        return "Two Point";
714      case NULL:
715        return null;
716      default:
717        return "?";
718      }
719    }
720  }
721
722  public static class DeviceMetricCalibrationTypeEnumFactory implements EnumFactory<DeviceMetricCalibrationType> {
723    public DeviceMetricCalibrationType fromCode(String codeString) throws IllegalArgumentException {
724      if (codeString == null || "".equals(codeString))
725        if (codeString == null || "".equals(codeString))
726          return null;
727      if ("unspecified".equals(codeString))
728        return DeviceMetricCalibrationType.UNSPECIFIED;
729      if ("offset".equals(codeString))
730        return DeviceMetricCalibrationType.OFFSET;
731      if ("gain".equals(codeString))
732        return DeviceMetricCalibrationType.GAIN;
733      if ("two-point".equals(codeString))
734        return DeviceMetricCalibrationType.TWOPOINT;
735      throw new IllegalArgumentException("Unknown DeviceMetricCalibrationType code '" + codeString + "'");
736    }
737
738    public Enumeration<DeviceMetricCalibrationType> fromType(PrimitiveType<?> code) throws FHIRException {
739      if (code == null)
740        return null;
741      if (code.isEmpty())
742        return new Enumeration<DeviceMetricCalibrationType>(this, DeviceMetricCalibrationType.NULL, code);
743      String codeString = code.asStringValue();
744      if (codeString == null || "".equals(codeString))
745        return new Enumeration<DeviceMetricCalibrationType>(this, DeviceMetricCalibrationType.NULL, code);
746      if ("unspecified".equals(codeString))
747        return new Enumeration<DeviceMetricCalibrationType>(this, DeviceMetricCalibrationType.UNSPECIFIED, code);
748      if ("offset".equals(codeString))
749        return new Enumeration<DeviceMetricCalibrationType>(this, DeviceMetricCalibrationType.OFFSET, code);
750      if ("gain".equals(codeString))
751        return new Enumeration<DeviceMetricCalibrationType>(this, DeviceMetricCalibrationType.GAIN, code);
752      if ("two-point".equals(codeString))
753        return new Enumeration<DeviceMetricCalibrationType>(this, DeviceMetricCalibrationType.TWOPOINT, code);
754      throw new FHIRException("Unknown DeviceMetricCalibrationType code '" + codeString + "'");
755    }
756
757    public String toCode(DeviceMetricCalibrationType code) {
758      if (code == DeviceMetricCalibrationType.UNSPECIFIED)
759        return "unspecified";
760      if (code == DeviceMetricCalibrationType.OFFSET)
761        return "offset";
762      if (code == DeviceMetricCalibrationType.GAIN)
763        return "gain";
764      if (code == DeviceMetricCalibrationType.TWOPOINT)
765        return "two-point";
766      return "?";
767    }
768
769    public String toSystem(DeviceMetricCalibrationType code) {
770      return code.getSystem();
771    }
772  }
773
774  public enum DeviceMetricCalibrationState {
775    /**
776     * The metric has not been calibrated.
777     */
778    NOTCALIBRATED,
779    /**
780     * The metric needs to be calibrated.
781     */
782    CALIBRATIONREQUIRED,
783    /**
784     * The metric has been calibrated.
785     */
786    CALIBRATED,
787    /**
788     * The state of calibration of this metric is unspecified.
789     */
790    UNSPECIFIED,
791    /**
792     * added to help the parsers with the generic types
793     */
794    NULL;
795
796    public static DeviceMetricCalibrationState fromCode(String codeString) throws FHIRException {
797      if (codeString == null || "".equals(codeString))
798        return null;
799      if ("not-calibrated".equals(codeString))
800        return NOTCALIBRATED;
801      if ("calibration-required".equals(codeString))
802        return CALIBRATIONREQUIRED;
803      if ("calibrated".equals(codeString))
804        return CALIBRATED;
805      if ("unspecified".equals(codeString))
806        return UNSPECIFIED;
807      if (Configuration.isAcceptInvalidEnums())
808        return null;
809      else
810        throw new FHIRException("Unknown DeviceMetricCalibrationState code '" + codeString + "'");
811    }
812
813    public String toCode() {
814      switch (this) {
815      case NOTCALIBRATED:
816        return "not-calibrated";
817      case CALIBRATIONREQUIRED:
818        return "calibration-required";
819      case CALIBRATED:
820        return "calibrated";
821      case UNSPECIFIED:
822        return "unspecified";
823      case NULL:
824        return null;
825      default:
826        return "?";
827      }
828    }
829
830    public String getSystem() {
831      switch (this) {
832      case NOTCALIBRATED:
833        return "http://hl7.org/fhir/metric-calibration-state";
834      case CALIBRATIONREQUIRED:
835        return "http://hl7.org/fhir/metric-calibration-state";
836      case CALIBRATED:
837        return "http://hl7.org/fhir/metric-calibration-state";
838      case UNSPECIFIED:
839        return "http://hl7.org/fhir/metric-calibration-state";
840      case NULL:
841        return null;
842      default:
843        return "?";
844      }
845    }
846
847    public String getDefinition() {
848      switch (this) {
849      case NOTCALIBRATED:
850        return "The metric has not been calibrated.";
851      case CALIBRATIONREQUIRED:
852        return "The metric needs to be calibrated.";
853      case CALIBRATED:
854        return "The metric has been calibrated.";
855      case UNSPECIFIED:
856        return "The state of calibration of this metric is unspecified.";
857      case NULL:
858        return null;
859      default:
860        return "?";
861      }
862    }
863
864    public String getDisplay() {
865      switch (this) {
866      case NOTCALIBRATED:
867        return "Not Calibrated";
868      case CALIBRATIONREQUIRED:
869        return "Calibration Required";
870      case CALIBRATED:
871        return "Calibrated";
872      case UNSPECIFIED:
873        return "Unspecified";
874      case NULL:
875        return null;
876      default:
877        return "?";
878      }
879    }
880  }
881
882  public static class DeviceMetricCalibrationStateEnumFactory implements EnumFactory<DeviceMetricCalibrationState> {
883    public DeviceMetricCalibrationState fromCode(String codeString) throws IllegalArgumentException {
884      if (codeString == null || "".equals(codeString))
885        if (codeString == null || "".equals(codeString))
886          return null;
887      if ("not-calibrated".equals(codeString))
888        return DeviceMetricCalibrationState.NOTCALIBRATED;
889      if ("calibration-required".equals(codeString))
890        return DeviceMetricCalibrationState.CALIBRATIONREQUIRED;
891      if ("calibrated".equals(codeString))
892        return DeviceMetricCalibrationState.CALIBRATED;
893      if ("unspecified".equals(codeString))
894        return DeviceMetricCalibrationState.UNSPECIFIED;
895      throw new IllegalArgumentException("Unknown DeviceMetricCalibrationState code '" + codeString + "'");
896    }
897
898    public Enumeration<DeviceMetricCalibrationState> fromType(PrimitiveType<?> code) throws FHIRException {
899      if (code == null)
900        return null;
901      if (code.isEmpty())
902        return new Enumeration<DeviceMetricCalibrationState>(this, DeviceMetricCalibrationState.NULL, code);
903      String codeString = code.asStringValue();
904      if (codeString == null || "".equals(codeString))
905        return new Enumeration<DeviceMetricCalibrationState>(this, DeviceMetricCalibrationState.NULL, code);
906      if ("not-calibrated".equals(codeString))
907        return new Enumeration<DeviceMetricCalibrationState>(this, DeviceMetricCalibrationState.NOTCALIBRATED, code);
908      if ("calibration-required".equals(codeString))
909        return new Enumeration<DeviceMetricCalibrationState>(this, DeviceMetricCalibrationState.CALIBRATIONREQUIRED,
910            code);
911      if ("calibrated".equals(codeString))
912        return new Enumeration<DeviceMetricCalibrationState>(this, DeviceMetricCalibrationState.CALIBRATED, code);
913      if ("unspecified".equals(codeString))
914        return new Enumeration<DeviceMetricCalibrationState>(this, DeviceMetricCalibrationState.UNSPECIFIED, code);
915      throw new FHIRException("Unknown DeviceMetricCalibrationState code '" + codeString + "'");
916    }
917
918    public String toCode(DeviceMetricCalibrationState code) {
919      if (code == DeviceMetricCalibrationState.NOTCALIBRATED)
920        return "not-calibrated";
921      if (code == DeviceMetricCalibrationState.CALIBRATIONREQUIRED)
922        return "calibration-required";
923      if (code == DeviceMetricCalibrationState.CALIBRATED)
924        return "calibrated";
925      if (code == DeviceMetricCalibrationState.UNSPECIFIED)
926        return "unspecified";
927      return "?";
928    }
929
930    public String toSystem(DeviceMetricCalibrationState code) {
931      return code.getSystem();
932    }
933  }
934
935  @Block()
936  public static class DeviceMetricCalibrationComponent extends BackboneElement implements IBaseBackboneElement {
937    /**
938     * Describes the type of the calibration method.
939     */
940    @Child(name = "type", type = { CodeType.class }, order = 1, min = 0, max = 1, modifier = false, summary = true)
941    @Description(shortDefinition = "unspecified | offset | gain | two-point", formalDefinition = "Describes the type of the calibration method.")
942    @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/metric-calibration-type")
943    protected Enumeration<DeviceMetricCalibrationType> type;
944
945    /**
946     * Describes the state of the calibration.
947     */
948    @Child(name = "state", type = { CodeType.class }, order = 2, min = 0, max = 1, modifier = false, summary = true)
949    @Description(shortDefinition = "not-calibrated | calibration-required | calibrated | unspecified", formalDefinition = "Describes the state of the calibration.")
950    @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/metric-calibration-state")
951    protected Enumeration<DeviceMetricCalibrationState> state;
952
953    /**
954     * Describes the time last calibration has been performed.
955     */
956    @Child(name = "time", type = { InstantType.class }, order = 3, min = 0, max = 1, modifier = false, summary = true)
957    @Description(shortDefinition = "Describes the time last calibration has been performed", formalDefinition = "Describes the time last calibration has been performed.")
958    protected InstantType time;
959
960    private static final long serialVersionUID = 1163986578L;
961
962    /**
963     * Constructor
964     */
965    public DeviceMetricCalibrationComponent() {
966      super();
967    }
968
969    /**
970     * @return {@link #type} (Describes the type of the calibration method.). This
971     *         is the underlying object with id, value and extensions. The accessor
972     *         "getType" gives direct access to the value
973     */
974    public Enumeration<DeviceMetricCalibrationType> getTypeElement() {
975      if (this.type == null)
976        if (Configuration.errorOnAutoCreate())
977          throw new Error("Attempt to auto-create DeviceMetricCalibrationComponent.type");
978        else if (Configuration.doAutoCreate())
979          this.type = new Enumeration<DeviceMetricCalibrationType>(new DeviceMetricCalibrationTypeEnumFactory()); // bb
980      return this.type;
981    }
982
983    public boolean hasTypeElement() {
984      return this.type != null && !this.type.isEmpty();
985    }
986
987    public boolean hasType() {
988      return this.type != null && !this.type.isEmpty();
989    }
990
991    /**
992     * @param value {@link #type} (Describes the type of the calibration method.).
993     *              This is the underlying object with id, value and extensions. The
994     *              accessor "getType" gives direct access to the value
995     */
996    public DeviceMetricCalibrationComponent setTypeElement(Enumeration<DeviceMetricCalibrationType> value) {
997      this.type = value;
998      return this;
999    }
1000
1001    /**
1002     * @return Describes the type of the calibration method.
1003     */
1004    public DeviceMetricCalibrationType getType() {
1005      return this.type == null ? null : this.type.getValue();
1006    }
1007
1008    /**
1009     * @param value Describes the type of the calibration method.
1010     */
1011    public DeviceMetricCalibrationComponent setType(DeviceMetricCalibrationType value) {
1012      if (value == null)
1013        this.type = null;
1014      else {
1015        if (this.type == null)
1016          this.type = new Enumeration<DeviceMetricCalibrationType>(new DeviceMetricCalibrationTypeEnumFactory());
1017        this.type.setValue(value);
1018      }
1019      return this;
1020    }
1021
1022    /**
1023     * @return {@link #state} (Describes the state of the calibration.). This is the
1024     *         underlying object with id, value and extensions. The accessor
1025     *         "getState" gives direct access to the value
1026     */
1027    public Enumeration<DeviceMetricCalibrationState> getStateElement() {
1028      if (this.state == null)
1029        if (Configuration.errorOnAutoCreate())
1030          throw new Error("Attempt to auto-create DeviceMetricCalibrationComponent.state");
1031        else if (Configuration.doAutoCreate())
1032          this.state = new Enumeration<DeviceMetricCalibrationState>(new DeviceMetricCalibrationStateEnumFactory()); // bb
1033      return this.state;
1034    }
1035
1036    public boolean hasStateElement() {
1037      return this.state != null && !this.state.isEmpty();
1038    }
1039
1040    public boolean hasState() {
1041      return this.state != null && !this.state.isEmpty();
1042    }
1043
1044    /**
1045     * @param value {@link #state} (Describes the state of the calibration.). This
1046     *              is the underlying object with id, value and extensions. The
1047     *              accessor "getState" gives direct access to the value
1048     */
1049    public DeviceMetricCalibrationComponent setStateElement(Enumeration<DeviceMetricCalibrationState> value) {
1050      this.state = value;
1051      return this;
1052    }
1053
1054    /**
1055     * @return Describes the state of the calibration.
1056     */
1057    public DeviceMetricCalibrationState getState() {
1058      return this.state == null ? null : this.state.getValue();
1059    }
1060
1061    /**
1062     * @param value Describes the state of the calibration.
1063     */
1064    public DeviceMetricCalibrationComponent setState(DeviceMetricCalibrationState value) {
1065      if (value == null)
1066        this.state = null;
1067      else {
1068        if (this.state == null)
1069          this.state = new Enumeration<DeviceMetricCalibrationState>(new DeviceMetricCalibrationStateEnumFactory());
1070        this.state.setValue(value);
1071      }
1072      return this;
1073    }
1074
1075    /**
1076     * @return {@link #time} (Describes the time last calibration has been
1077     *         performed.). This is the underlying object with id, value and
1078     *         extensions. The accessor "getTime" gives direct access to the value
1079     */
1080    public InstantType getTimeElement() {
1081      if (this.time == null)
1082        if (Configuration.errorOnAutoCreate())
1083          throw new Error("Attempt to auto-create DeviceMetricCalibrationComponent.time");
1084        else if (Configuration.doAutoCreate())
1085          this.time = new InstantType(); // bb
1086      return this.time;
1087    }
1088
1089    public boolean hasTimeElement() {
1090      return this.time != null && !this.time.isEmpty();
1091    }
1092
1093    public boolean hasTime() {
1094      return this.time != null && !this.time.isEmpty();
1095    }
1096
1097    /**
1098     * @param value {@link #time} (Describes the time last calibration has been
1099     *              performed.). This is the underlying object with id, value and
1100     *              extensions. The accessor "getTime" gives direct access to the
1101     *              value
1102     */
1103    public DeviceMetricCalibrationComponent setTimeElement(InstantType value) {
1104      this.time = value;
1105      return this;
1106    }
1107
1108    /**
1109     * @return Describes the time last calibration has been performed.
1110     */
1111    public Date getTime() {
1112      return this.time == null ? null : this.time.getValue();
1113    }
1114
1115    /**
1116     * @param value Describes the time last calibration has been performed.
1117     */
1118    public DeviceMetricCalibrationComponent setTime(Date value) {
1119      if (value == null)
1120        this.time = null;
1121      else {
1122        if (this.time == null)
1123          this.time = new InstantType();
1124        this.time.setValue(value);
1125      }
1126      return this;
1127    }
1128
1129    protected void listChildren(List<Property> children) {
1130      super.listChildren(children);
1131      children.add(new Property("type", "code", "Describes the type of the calibration method.", 0, 1, type));
1132      children.add(new Property("state", "code", "Describes the state of the calibration.", 0, 1, state));
1133      children
1134          .add(new Property("time", "instant", "Describes the time last calibration has been performed.", 0, 1, time));
1135    }
1136
1137    @Override
1138    public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1139      switch (_hash) {
1140      case 3575610:
1141        /* type */ return new Property("type", "code", "Describes the type of the calibration method.", 0, 1, type);
1142      case 109757585:
1143        /* state */ return new Property("state", "code", "Describes the state of the calibration.", 0, 1, state);
1144      case 3560141:
1145        /* time */ return new Property("time", "instant", "Describes the time last calibration has been performed.", 0,
1146            1, time);
1147      default:
1148        return super.getNamedProperty(_hash, _name, _checkValid);
1149      }
1150
1151    }
1152
1153    @Override
1154    public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1155      switch (hash) {
1156      case 3575610:
1157        /* type */ return this.type == null ? new Base[0] : new Base[] { this.type }; // Enumeration<DeviceMetricCalibrationType>
1158      case 109757585:
1159        /* state */ return this.state == null ? new Base[0] : new Base[] { this.state }; // Enumeration<DeviceMetricCalibrationState>
1160      case 3560141:
1161        /* time */ return this.time == null ? new Base[0] : new Base[] { this.time }; // InstantType
1162      default:
1163        return super.getProperty(hash, name, checkValid);
1164      }
1165
1166    }
1167
1168    @Override
1169    public Base setProperty(int hash, String name, Base value) throws FHIRException {
1170      switch (hash) {
1171      case 3575610: // type
1172        value = new DeviceMetricCalibrationTypeEnumFactory().fromType(castToCode(value));
1173        this.type = (Enumeration) value; // Enumeration<DeviceMetricCalibrationType>
1174        return value;
1175      case 109757585: // state
1176        value = new DeviceMetricCalibrationStateEnumFactory().fromType(castToCode(value));
1177        this.state = (Enumeration) value; // Enumeration<DeviceMetricCalibrationState>
1178        return value;
1179      case 3560141: // time
1180        this.time = castToInstant(value); // InstantType
1181        return value;
1182      default:
1183        return super.setProperty(hash, name, value);
1184      }
1185
1186    }
1187
1188    @Override
1189    public Base setProperty(String name, Base value) throws FHIRException {
1190      if (name.equals("type")) {
1191        value = new DeviceMetricCalibrationTypeEnumFactory().fromType(castToCode(value));
1192        this.type = (Enumeration) value; // Enumeration<DeviceMetricCalibrationType>
1193      } else if (name.equals("state")) {
1194        value = new DeviceMetricCalibrationStateEnumFactory().fromType(castToCode(value));
1195        this.state = (Enumeration) value; // Enumeration<DeviceMetricCalibrationState>
1196      } else if (name.equals("time")) {
1197        this.time = castToInstant(value); // InstantType
1198      } else
1199        return super.setProperty(name, value);
1200      return value;
1201    }
1202
1203    @Override
1204    public Base makeProperty(int hash, String name) throws FHIRException {
1205      switch (hash) {
1206      case 3575610:
1207        return getTypeElement();
1208      case 109757585:
1209        return getStateElement();
1210      case 3560141:
1211        return getTimeElement();
1212      default:
1213        return super.makeProperty(hash, name);
1214      }
1215
1216    }
1217
1218    @Override
1219    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1220      switch (hash) {
1221      case 3575610:
1222        /* type */ return new String[] { "code" };
1223      case 109757585:
1224        /* state */ return new String[] { "code" };
1225      case 3560141:
1226        /* time */ return new String[] { "instant" };
1227      default:
1228        return super.getTypesForProperty(hash, name);
1229      }
1230
1231    }
1232
1233    @Override
1234    public Base addChild(String name) throws FHIRException {
1235      if (name.equals("type")) {
1236        throw new FHIRException("Cannot call addChild on a singleton property DeviceMetric.type");
1237      } else if (name.equals("state")) {
1238        throw new FHIRException("Cannot call addChild on a singleton property DeviceMetric.state");
1239      } else if (name.equals("time")) {
1240        throw new FHIRException("Cannot call addChild on a singleton property DeviceMetric.time");
1241      } else
1242        return super.addChild(name);
1243    }
1244
1245    public DeviceMetricCalibrationComponent copy() {
1246      DeviceMetricCalibrationComponent dst = new DeviceMetricCalibrationComponent();
1247      copyValues(dst);
1248      return dst;
1249    }
1250
1251    public void copyValues(DeviceMetricCalibrationComponent dst) {
1252      super.copyValues(dst);
1253      dst.type = type == null ? null : type.copy();
1254      dst.state = state == null ? null : state.copy();
1255      dst.time = time == null ? null : time.copy();
1256    }
1257
1258    @Override
1259    public boolean equalsDeep(Base other_) {
1260      if (!super.equalsDeep(other_))
1261        return false;
1262      if (!(other_ instanceof DeviceMetricCalibrationComponent))
1263        return false;
1264      DeviceMetricCalibrationComponent o = (DeviceMetricCalibrationComponent) other_;
1265      return compareDeep(type, o.type, true) && compareDeep(state, o.state, true) && compareDeep(time, o.time, true);
1266    }
1267
1268    @Override
1269    public boolean equalsShallow(Base other_) {
1270      if (!super.equalsShallow(other_))
1271        return false;
1272      if (!(other_ instanceof DeviceMetricCalibrationComponent))
1273        return false;
1274      DeviceMetricCalibrationComponent o = (DeviceMetricCalibrationComponent) other_;
1275      return compareValues(type, o.type, true) && compareValues(state, o.state, true)
1276          && compareValues(time, o.time, true);
1277    }
1278
1279    public boolean isEmpty() {
1280      return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, state, time);
1281    }
1282
1283    public String fhirType() {
1284      return "DeviceMetric.calibration";
1285
1286    }
1287
1288  }
1289
1290  /**
1291   * Unique instance identifiers assigned to a device by the device or gateway
1292   * software, manufacturers, other organizations or owners. For example: handle
1293   * ID.
1294   */
1295  @Child(name = "identifier", type = {
1296      Identifier.class }, order = 0, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
1297  @Description(shortDefinition = "Instance identifier", formalDefinition = "Unique instance identifiers assigned to a device by the device or gateway software, manufacturers, other organizations or owners. For example: handle ID.")
1298  protected List<Identifier> identifier;
1299
1300  /**
1301   * Describes the type of the metric. For example: Heart Rate, PEEP Setting, etc.
1302   */
1303  @Child(name = "type", type = { CodeableConcept.class }, order = 1, min = 1, max = 1, modifier = false, summary = true)
1304  @Description(shortDefinition = "Identity of metric, for example Heart Rate or PEEP Setting", formalDefinition = "Describes the type of the metric. For example: Heart Rate, PEEP Setting, etc.")
1305  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/devicemetric-type")
1306  protected CodeableConcept type;
1307
1308  /**
1309   * Describes the unit that an observed value determined for this metric will
1310   * have. For example: Percent, Seconds, etc.
1311   */
1312  @Child(name = "unit", type = { CodeableConcept.class }, order = 2, min = 0, max = 1, modifier = false, summary = true)
1313  @Description(shortDefinition = "Unit of Measure for the Metric", formalDefinition = "Describes the unit that an observed value determined for this metric will have. For example: Percent, Seconds, etc.")
1314  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/devicemetric-type")
1315  protected CodeableConcept unit;
1316
1317  /**
1318   * Describes the link to the Device that this DeviceMetric belongs to and that
1319   * contains administrative device information such as manufacturer, serial
1320   * number, etc.
1321   */
1322  @Child(name = "source", type = { Device.class }, order = 3, min = 0, max = 1, modifier = false, summary = true)
1323  @Description(shortDefinition = "Describes the link to the source Device", formalDefinition = "Describes the link to the  Device that this DeviceMetric belongs to and that contains administrative device information such as manufacturer, serial number, etc.")
1324  protected Reference source;
1325
1326  /**
1327   * The actual object that is the target of the reference (Describes the link to
1328   * the Device that this DeviceMetric belongs to and that contains administrative
1329   * device information such as manufacturer, serial number, etc.)
1330   */
1331  protected Device sourceTarget;
1332
1333  /**
1334   * Describes the link to the Device that this DeviceMetric belongs to and that
1335   * provide information about the location of this DeviceMetric in the
1336   * containment structure of the parent Device. An example would be a Device that
1337   * represents a Channel. This reference can be used by a client application to
1338   * distinguish DeviceMetrics that have the same type, but should be interpreted
1339   * based on their containment location.
1340   */
1341  @Child(name = "parent", type = { Device.class }, order = 4, min = 0, max = 1, modifier = false, summary = true)
1342  @Description(shortDefinition = "Describes the link to the parent Device", formalDefinition = "Describes the link to the  Device 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 Device 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.")
1343  protected Reference parent;
1344
1345  /**
1346   * The actual object that is the target of the reference (Describes the link to
1347   * the Device that this DeviceMetric belongs to and that provide information
1348   * about the location of this DeviceMetric in the containment structure of the
1349   * parent Device. An example would be a Device that represents a Channel. This
1350   * reference can be used by a client application to distinguish DeviceMetrics
1351   * that have the same type, but should be interpreted based on their containment
1352   * location.)
1353   */
1354  protected Device parentTarget;
1355
1356  /**
1357   * Indicates current operational state of the device. For example: On, Off,
1358   * Standby, etc.
1359   */
1360  @Child(name = "operationalStatus", type = {
1361      CodeType.class }, order = 5, min = 0, max = 1, modifier = false, summary = true)
1362  @Description(shortDefinition = "on | off | standby | entered-in-error", formalDefinition = "Indicates current operational state of the device. For example: On, Off, Standby, etc.")
1363  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/metric-operational-status")
1364  protected Enumeration<DeviceMetricOperationalStatus> operationalStatus;
1365
1366  /**
1367   * Describes the color representation for the metric. This is often used to aid
1368   * clinicians to track and identify parameter types by color. In practice,
1369   * consider a Patient Monitor that has ECG/HR and Pleth for example; the
1370   * parameters are displayed in different characteristic colors, such as HR-blue,
1371   * BP-green, and PR and SpO2- magenta.
1372   */
1373  @Child(name = "color", type = { CodeType.class }, order = 6, min = 0, max = 1, modifier = false, summary = true)
1374  @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.")
1375  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/metric-color")
1376  protected Enumeration<DeviceMetricColor> color;
1377
1378  /**
1379   * Indicates the category of the observation generation process. A DeviceMetric
1380   * can be for example a setting, measurement, or calculation.
1381   */
1382  @Child(name = "category", type = { CodeType.class }, order = 7, min = 1, max = 1, modifier = false, summary = true)
1383  @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.")
1384  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/metric-category")
1385  protected Enumeration<DeviceMetricCategory> category;
1386
1387  /**
1388   * Describes the measurement repetition time. This is not necessarily the same
1389   * as the update period. The measurement repetition time can range from
1390   * milliseconds up to hours. An example for a measurement repetition time in the
1391   * range of milliseconds is the sampling rate of an ECG. An example for a
1392   * measurement repetition time in the range of hours is a NIBP that is triggered
1393   * automatically every hour. The update period may be different than the
1394   * measurement repetition time, if the device does not update the published
1395   * observed value with the same frequency as it was measured.
1396   */
1397  @Child(name = "measurementPeriod", type = {
1398      Timing.class }, order = 8, min = 0, max = 1, modifier = false, summary = true)
1399  @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.")
1400  protected Timing measurementPeriod;
1401
1402  /**
1403   * Describes the calibrations that have been performed or that are required to
1404   * be performed.
1405   */
1406  @Child(name = "calibration", type = {}, order = 9, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
1407  @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.")
1408  protected List<DeviceMetricCalibrationComponent> calibration;
1409
1410  private static final long serialVersionUID = 1309955219L;
1411
1412  /**
1413   * Constructor
1414   */
1415  public DeviceMetric() {
1416    super();
1417  }
1418
1419  /**
1420   * Constructor
1421   */
1422  public DeviceMetric(CodeableConcept type, Enumeration<DeviceMetricCategory> category) {
1423    super();
1424    this.type = type;
1425    this.category = category;
1426  }
1427
1428  /**
1429   * @return {@link #identifier} (Unique instance identifiers assigned to a device
1430   *         by the device or gateway software, manufacturers, other organizations
1431   *         or owners. For example: handle ID.)
1432   */
1433  public List<Identifier> getIdentifier() {
1434    if (this.identifier == null)
1435      this.identifier = new ArrayList<Identifier>();
1436    return this.identifier;
1437  }
1438
1439  /**
1440   * @return Returns a reference to <code>this</code> for easy method chaining
1441   */
1442  public DeviceMetric setIdentifier(List<Identifier> theIdentifier) {
1443    this.identifier = theIdentifier;
1444    return this;
1445  }
1446
1447  public boolean hasIdentifier() {
1448    if (this.identifier == null)
1449      return false;
1450    for (Identifier item : this.identifier)
1451      if (!item.isEmpty())
1452        return true;
1453    return false;
1454  }
1455
1456  public Identifier addIdentifier() { // 3
1457    Identifier t = new Identifier();
1458    if (this.identifier == null)
1459      this.identifier = new ArrayList<Identifier>();
1460    this.identifier.add(t);
1461    return t;
1462  }
1463
1464  public DeviceMetric addIdentifier(Identifier t) { // 3
1465    if (t == null)
1466      return this;
1467    if (this.identifier == null)
1468      this.identifier = new ArrayList<Identifier>();
1469    this.identifier.add(t);
1470    return this;
1471  }
1472
1473  /**
1474   * @return The first repetition of repeating field {@link #identifier}, creating
1475   *         it if it does not already exist
1476   */
1477  public Identifier getIdentifierFirstRep() {
1478    if (getIdentifier().isEmpty()) {
1479      addIdentifier();
1480    }
1481    return getIdentifier().get(0);
1482  }
1483
1484  /**
1485   * @return {@link #type} (Describes the type of the metric. For example: Heart
1486   *         Rate, PEEP Setting, etc.)
1487   */
1488  public CodeableConcept getType() {
1489    if (this.type == null)
1490      if (Configuration.errorOnAutoCreate())
1491        throw new Error("Attempt to auto-create DeviceMetric.type");
1492      else if (Configuration.doAutoCreate())
1493        this.type = new CodeableConcept(); // cc
1494    return this.type;
1495  }
1496
1497  public boolean hasType() {
1498    return this.type != null && !this.type.isEmpty();
1499  }
1500
1501  /**
1502   * @param value {@link #type} (Describes the type of the metric. For example:
1503   *              Heart Rate, PEEP Setting, etc.)
1504   */
1505  public DeviceMetric setType(CodeableConcept value) {
1506    this.type = value;
1507    return this;
1508  }
1509
1510  /**
1511   * @return {@link #unit} (Describes the unit that an observed value determined
1512   *         for this metric will have. For example: Percent, Seconds, etc.)
1513   */
1514  public CodeableConcept getUnit() {
1515    if (this.unit == null)
1516      if (Configuration.errorOnAutoCreate())
1517        throw new Error("Attempt to auto-create DeviceMetric.unit");
1518      else if (Configuration.doAutoCreate())
1519        this.unit = new CodeableConcept(); // cc
1520    return this.unit;
1521  }
1522
1523  public boolean hasUnit() {
1524    return this.unit != null && !this.unit.isEmpty();
1525  }
1526
1527  /**
1528   * @param value {@link #unit} (Describes the unit that an observed value
1529   *              determined for this metric will have. For example: Percent,
1530   *              Seconds, etc.)
1531   */
1532  public DeviceMetric setUnit(CodeableConcept value) {
1533    this.unit = value;
1534    return this;
1535  }
1536
1537  /**
1538   * @return {@link #source} (Describes the link to the Device that this
1539   *         DeviceMetric belongs to and that contains administrative device
1540   *         information such as manufacturer, serial number, etc.)
1541   */
1542  public Reference getSource() {
1543    if (this.source == null)
1544      if (Configuration.errorOnAutoCreate())
1545        throw new Error("Attempt to auto-create DeviceMetric.source");
1546      else if (Configuration.doAutoCreate())
1547        this.source = new Reference(); // cc
1548    return this.source;
1549  }
1550
1551  public boolean hasSource() {
1552    return this.source != null && !this.source.isEmpty();
1553  }
1554
1555  /**
1556   * @param value {@link #source} (Describes the link to the Device that this
1557   *              DeviceMetric belongs to and that contains administrative device
1558   *              information such as manufacturer, serial number, etc.)
1559   */
1560  public DeviceMetric setSource(Reference value) {
1561    this.source = value;
1562    return this;
1563  }
1564
1565  /**
1566   * @return {@link #source} The actual object that is the target of the
1567   *         reference. The reference library doesn't populate this, but you can
1568   *         use it to hold the resource if you resolve it. (Describes the link to
1569   *         the Device that this DeviceMetric belongs to and that contains
1570   *         administrative device information such as manufacturer, serial
1571   *         number, etc.)
1572   */
1573  public Device getSourceTarget() {
1574    if (this.sourceTarget == null)
1575      if (Configuration.errorOnAutoCreate())
1576        throw new Error("Attempt to auto-create DeviceMetric.source");
1577      else if (Configuration.doAutoCreate())
1578        this.sourceTarget = new Device(); // aa
1579    return this.sourceTarget;
1580  }
1581
1582  /**
1583   * @param value {@link #source} The actual object that is the target of the
1584   *              reference. The reference library doesn't use these, but you can
1585   *              use it to hold the resource if you resolve it. (Describes the
1586   *              link to the Device that this DeviceMetric belongs to and that
1587   *              contains administrative device information such as manufacturer,
1588   *              serial number, etc.)
1589   */
1590  public DeviceMetric setSourceTarget(Device value) {
1591    this.sourceTarget = value;
1592    return this;
1593  }
1594
1595  /**
1596   * @return {@link #parent} (Describes the link to the Device that this
1597   *         DeviceMetric belongs to and that provide information about the
1598   *         location of this DeviceMetric in the containment structure of the
1599   *         parent Device. An example would be a Device that represents a
1600   *         Channel. This reference can be used by a client application to
1601   *         distinguish DeviceMetrics that have the same type, but should be
1602   *         interpreted based on their containment location.)
1603   */
1604  public Reference getParent() {
1605    if (this.parent == null)
1606      if (Configuration.errorOnAutoCreate())
1607        throw new Error("Attempt to auto-create DeviceMetric.parent");
1608      else if (Configuration.doAutoCreate())
1609        this.parent = new Reference(); // cc
1610    return this.parent;
1611  }
1612
1613  public boolean hasParent() {
1614    return this.parent != null && !this.parent.isEmpty();
1615  }
1616
1617  /**
1618   * @param value {@link #parent} (Describes the link to the Device that this
1619   *              DeviceMetric belongs to and that provide information about the
1620   *              location of this DeviceMetric in the containment structure of
1621   *              the parent Device. An example would be a Device that represents
1622   *              a Channel. This reference can be used by a client application to
1623   *              distinguish DeviceMetrics that have the same type, but should be
1624   *              interpreted based on their containment location.)
1625   */
1626  public DeviceMetric setParent(Reference value) {
1627    this.parent = value;
1628    return this;
1629  }
1630
1631  /**
1632   * @return {@link #parent} The actual object that is the target of the
1633   *         reference. The reference library doesn't populate this, but you can
1634   *         use it to hold the resource if you resolve it. (Describes the link to
1635   *         the Device that this DeviceMetric belongs to and that provide
1636   *         information about the location of this DeviceMetric in the
1637   *         containment structure of the parent Device. An example would be a
1638   *         Device that represents a Channel. This reference can be used by a
1639   *         client application to distinguish DeviceMetrics that have the same
1640   *         type, but should be interpreted based on their containment location.)
1641   */
1642  public Device getParentTarget() {
1643    if (this.parentTarget == null)
1644      if (Configuration.errorOnAutoCreate())
1645        throw new Error("Attempt to auto-create DeviceMetric.parent");
1646      else if (Configuration.doAutoCreate())
1647        this.parentTarget = new Device(); // aa
1648    return this.parentTarget;
1649  }
1650
1651  /**
1652   * @param value {@link #parent} The actual object that is the target of the
1653   *              reference. The reference library doesn't use these, but you can
1654   *              use it to hold the resource if you resolve it. (Describes the
1655   *              link to the Device that this DeviceMetric belongs to and that
1656   *              provide information about the location of this DeviceMetric in
1657   *              the containment structure of the parent Device. An example would
1658   *              be a Device that represents a Channel. This reference can be
1659   *              used by a client application to distinguish DeviceMetrics that
1660   *              have the same type, but should be interpreted based on their
1661   *              containment location.)
1662   */
1663  public DeviceMetric setParentTarget(Device value) {
1664    this.parentTarget = value;
1665    return this;
1666  }
1667
1668  /**
1669   * @return {@link #operationalStatus} (Indicates current operational state of
1670   *         the device. For example: On, Off, Standby, etc.). This is the
1671   *         underlying object with id, value and extensions. The accessor
1672   *         "getOperationalStatus" gives direct access to the value
1673   */
1674  public Enumeration<DeviceMetricOperationalStatus> getOperationalStatusElement() {
1675    if (this.operationalStatus == null)
1676      if (Configuration.errorOnAutoCreate())
1677        throw new Error("Attempt to auto-create DeviceMetric.operationalStatus");
1678      else if (Configuration.doAutoCreate())
1679        this.operationalStatus = new Enumeration<DeviceMetricOperationalStatus>(
1680            new DeviceMetricOperationalStatusEnumFactory()); // bb
1681    return this.operationalStatus;
1682  }
1683
1684  public boolean hasOperationalStatusElement() {
1685    return this.operationalStatus != null && !this.operationalStatus.isEmpty();
1686  }
1687
1688  public boolean hasOperationalStatus() {
1689    return this.operationalStatus != null && !this.operationalStatus.isEmpty();
1690  }
1691
1692  /**
1693   * @param value {@link #operationalStatus} (Indicates current operational state
1694   *              of the device. For example: On, Off, Standby, etc.). This is the
1695   *              underlying object with id, value and extensions. The accessor
1696   *              "getOperationalStatus" gives direct access to the value
1697   */
1698  public DeviceMetric setOperationalStatusElement(Enumeration<DeviceMetricOperationalStatus> value) {
1699    this.operationalStatus = value;
1700    return this;
1701  }
1702
1703  /**
1704   * @return Indicates current operational state of the device. For example: On,
1705   *         Off, Standby, etc.
1706   */
1707  public DeviceMetricOperationalStatus getOperationalStatus() {
1708    return this.operationalStatus == null ? null : this.operationalStatus.getValue();
1709  }
1710
1711  /**
1712   * @param value Indicates current operational state of the device. For example:
1713   *              On, Off, Standby, etc.
1714   */
1715  public DeviceMetric setOperationalStatus(DeviceMetricOperationalStatus value) {
1716    if (value == null)
1717      this.operationalStatus = null;
1718    else {
1719      if (this.operationalStatus == null)
1720        this.operationalStatus = new Enumeration<DeviceMetricOperationalStatus>(
1721            new DeviceMetricOperationalStatusEnumFactory());
1722      this.operationalStatus.setValue(value);
1723    }
1724    return this;
1725  }
1726
1727  /**
1728   * @return {@link #color} (Describes the color representation for the metric.
1729   *         This is often used to aid clinicians to track and identify parameter
1730   *         types by color. In practice, consider a Patient Monitor that has
1731   *         ECG/HR and Pleth for example; the parameters are displayed in
1732   *         different characteristic colors, such as HR-blue, BP-green, and PR
1733   *         and SpO2- magenta.). This is the underlying object with id, value and
1734   *         extensions. The accessor "getColor" gives direct access to the value
1735   */
1736  public Enumeration<DeviceMetricColor> getColorElement() {
1737    if (this.color == null)
1738      if (Configuration.errorOnAutoCreate())
1739        throw new Error("Attempt to auto-create DeviceMetric.color");
1740      else if (Configuration.doAutoCreate())
1741        this.color = new Enumeration<DeviceMetricColor>(new DeviceMetricColorEnumFactory()); // bb
1742    return this.color;
1743  }
1744
1745  public boolean hasColorElement() {
1746    return this.color != null && !this.color.isEmpty();
1747  }
1748
1749  public boolean hasColor() {
1750    return this.color != null && !this.color.isEmpty();
1751  }
1752
1753  /**
1754   * @param value {@link #color} (Describes the color representation for the
1755   *              metric. This is often used to aid clinicians to track and
1756   *              identify parameter types by color. In practice, consider a
1757   *              Patient Monitor that has ECG/HR and Pleth for example; the
1758   *              parameters are displayed in different characteristic colors,
1759   *              such as HR-blue, BP-green, and PR and SpO2- magenta.). This is
1760   *              the underlying object with id, value and extensions. The
1761   *              accessor "getColor" gives direct access to the value
1762   */
1763  public DeviceMetric setColorElement(Enumeration<DeviceMetricColor> value) {
1764    this.color = value;
1765    return this;
1766  }
1767
1768  /**
1769   * @return Describes the color representation for the metric. This is often used
1770   *         to aid clinicians to track and identify parameter types by color. In
1771   *         practice, consider a Patient Monitor that has ECG/HR and Pleth for
1772   *         example; the parameters are displayed in different characteristic
1773   *         colors, such as HR-blue, BP-green, and PR and SpO2- magenta.
1774   */
1775  public DeviceMetricColor getColor() {
1776    return this.color == null ? null : this.color.getValue();
1777  }
1778
1779  /**
1780   * @param value Describes the color representation for the metric. This is often
1781   *              used to aid clinicians to track and identify parameter types by
1782   *              color. In practice, consider a Patient Monitor that has ECG/HR
1783   *              and Pleth for example; the parameters are displayed in different
1784   *              characteristic colors, such as HR-blue, BP-green, and PR and
1785   *              SpO2- magenta.
1786   */
1787  public DeviceMetric setColor(DeviceMetricColor value) {
1788    if (value == null)
1789      this.color = null;
1790    else {
1791      if (this.color == null)
1792        this.color = new Enumeration<DeviceMetricColor>(new DeviceMetricColorEnumFactory());
1793      this.color.setValue(value);
1794    }
1795    return this;
1796  }
1797
1798  /**
1799   * @return {@link #category} (Indicates the category of the observation
1800   *         generation process. A DeviceMetric can be for example a setting,
1801   *         measurement, or calculation.). This is the underlying object with id,
1802   *         value and extensions. The accessor "getCategory" gives direct access
1803   *         to the value
1804   */
1805  public Enumeration<DeviceMetricCategory> getCategoryElement() {
1806    if (this.category == null)
1807      if (Configuration.errorOnAutoCreate())
1808        throw new Error("Attempt to auto-create DeviceMetric.category");
1809      else if (Configuration.doAutoCreate())
1810        this.category = new Enumeration<DeviceMetricCategory>(new DeviceMetricCategoryEnumFactory()); // bb
1811    return this.category;
1812  }
1813
1814  public boolean hasCategoryElement() {
1815    return this.category != null && !this.category.isEmpty();
1816  }
1817
1818  public boolean hasCategory() {
1819    return this.category != null && !this.category.isEmpty();
1820  }
1821
1822  /**
1823   * @param value {@link #category} (Indicates the category of the observation
1824   *              generation process. A DeviceMetric can be for example a setting,
1825   *              measurement, or calculation.). This is the underlying object
1826   *              with id, value and extensions. The accessor "getCategory" gives
1827   *              direct access to the value
1828   */
1829  public DeviceMetric setCategoryElement(Enumeration<DeviceMetricCategory> value) {
1830    this.category = value;
1831    return this;
1832  }
1833
1834  /**
1835   * @return Indicates the category of the observation generation process. A
1836   *         DeviceMetric can be for example a setting, measurement, or
1837   *         calculation.
1838   */
1839  public DeviceMetricCategory getCategory() {
1840    return this.category == null ? null : this.category.getValue();
1841  }
1842
1843  /**
1844   * @param value Indicates the category of the observation generation process. A
1845   *              DeviceMetric can be for example a setting, measurement, or
1846   *              calculation.
1847   */
1848  public DeviceMetric setCategory(DeviceMetricCategory value) {
1849    if (this.category == null)
1850      this.category = new Enumeration<DeviceMetricCategory>(new DeviceMetricCategoryEnumFactory());
1851    this.category.setValue(value);
1852    return this;
1853  }
1854
1855  /**
1856   * @return {@link #measurementPeriod} (Describes the measurement repetition
1857   *         time. This is not necessarily the same as the update period. The
1858   *         measurement repetition time can range from milliseconds up to hours.
1859   *         An example for a measurement repetition time in the range of
1860   *         milliseconds is the sampling rate of an ECG. An example for a
1861   *         measurement repetition time in the range of hours is a NIBP that is
1862   *         triggered automatically every hour. The update period may be
1863   *         different than the measurement repetition time, if the device does
1864   *         not update the published observed value with the same frequency as it
1865   *         was measured.)
1866   */
1867  public Timing getMeasurementPeriod() {
1868    if (this.measurementPeriod == null)
1869      if (Configuration.errorOnAutoCreate())
1870        throw new Error("Attempt to auto-create DeviceMetric.measurementPeriod");
1871      else if (Configuration.doAutoCreate())
1872        this.measurementPeriod = new Timing(); // cc
1873    return this.measurementPeriod;
1874  }
1875
1876  public boolean hasMeasurementPeriod() {
1877    return this.measurementPeriod != null && !this.measurementPeriod.isEmpty();
1878  }
1879
1880  /**
1881   * @param value {@link #measurementPeriod} (Describes the measurement repetition
1882   *              time. This is not necessarily the same as the update period. The
1883   *              measurement repetition time can range from milliseconds up to
1884   *              hours. An example for a measurement repetition time in the range
1885   *              of milliseconds is the sampling rate of an ECG. An example for a
1886   *              measurement repetition time in the range of hours is a NIBP that
1887   *              is triggered automatically every hour. The update period may be
1888   *              different than the measurement repetition time, if the device
1889   *              does not update the published observed value with the same
1890   *              frequency as it was measured.)
1891   */
1892  public DeviceMetric setMeasurementPeriod(Timing value) {
1893    this.measurementPeriod = value;
1894    return this;
1895  }
1896
1897  /**
1898   * @return {@link #calibration} (Describes the calibrations that have been
1899   *         performed or that are required to be performed.)
1900   */
1901  public List<DeviceMetricCalibrationComponent> getCalibration() {
1902    if (this.calibration == null)
1903      this.calibration = new ArrayList<DeviceMetricCalibrationComponent>();
1904    return this.calibration;
1905  }
1906
1907  /**
1908   * @return Returns a reference to <code>this</code> for easy method chaining
1909   */
1910  public DeviceMetric setCalibration(List<DeviceMetricCalibrationComponent> theCalibration) {
1911    this.calibration = theCalibration;
1912    return this;
1913  }
1914
1915  public boolean hasCalibration() {
1916    if (this.calibration == null)
1917      return false;
1918    for (DeviceMetricCalibrationComponent item : this.calibration)
1919      if (!item.isEmpty())
1920        return true;
1921    return false;
1922  }
1923
1924  public DeviceMetricCalibrationComponent addCalibration() { // 3
1925    DeviceMetricCalibrationComponent t = new DeviceMetricCalibrationComponent();
1926    if (this.calibration == null)
1927      this.calibration = new ArrayList<DeviceMetricCalibrationComponent>();
1928    this.calibration.add(t);
1929    return t;
1930  }
1931
1932  public DeviceMetric addCalibration(DeviceMetricCalibrationComponent t) { // 3
1933    if (t == null)
1934      return this;
1935    if (this.calibration == null)
1936      this.calibration = new ArrayList<DeviceMetricCalibrationComponent>();
1937    this.calibration.add(t);
1938    return this;
1939  }
1940
1941  /**
1942   * @return The first repetition of repeating field {@link #calibration},
1943   *         creating it if it does not already exist
1944   */
1945  public DeviceMetricCalibrationComponent getCalibrationFirstRep() {
1946    if (getCalibration().isEmpty()) {
1947      addCalibration();
1948    }
1949    return getCalibration().get(0);
1950  }
1951
1952  protected void listChildren(List<Property> children) {
1953    super.listChildren(children);
1954    children.add(new Property("identifier", "Identifier",
1955        "Unique instance identifiers assigned to a device by the device or gateway software, manufacturers, other organizations or owners. For example: handle ID.",
1956        0, java.lang.Integer.MAX_VALUE, identifier));
1957    children.add(new Property("type", "CodeableConcept",
1958        "Describes the type of the metric. For example: Heart Rate, PEEP Setting, etc.", 0, 1, type));
1959    children.add(new Property("unit", "CodeableConcept",
1960        "Describes the unit that an observed value determined for this metric will have. For example: Percent, Seconds, etc.",
1961        0, 1, unit));
1962    children.add(new Property("source", "Reference(Device)",
1963        "Describes the link to the  Device that this DeviceMetric belongs to and that contains administrative device information such as manufacturer, serial number, etc.",
1964        0, 1, source));
1965    children.add(new Property("parent", "Reference(Device)",
1966        "Describes the link to the  Device 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 Device 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.",
1967        0, 1, parent));
1968    children.add(new Property("operationalStatus", "code",
1969        "Indicates current operational state of the device. For example: On, Off, Standby, etc.", 0, 1,
1970        operationalStatus));
1971    children.add(new Property("color", "code",
1972        "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.",
1973        0, 1, color));
1974    children.add(new Property("category", "code",
1975        "Indicates the category of the observation generation process. A DeviceMetric can be for example a setting, measurement, or calculation.",
1976        0, 1, category));
1977    children.add(new Property("measurementPeriod", "Timing",
1978        "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.",
1979        0, 1, measurementPeriod));
1980    children.add(new Property("calibration", "",
1981        "Describes the calibrations that have been performed or that are required to be performed.", 0,
1982        java.lang.Integer.MAX_VALUE, calibration));
1983  }
1984
1985  @Override
1986  public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1987    switch (_hash) {
1988    case -1618432855:
1989      /* identifier */ return new Property("identifier", "Identifier",
1990          "Unique instance identifiers assigned to a device by the device or gateway software, manufacturers, other organizations or owners. For example: handle ID.",
1991          0, java.lang.Integer.MAX_VALUE, identifier);
1992    case 3575610:
1993      /* type */ return new Property("type", "CodeableConcept",
1994          "Describes the type of the metric. For example: Heart Rate, PEEP Setting, etc.", 0, 1, type);
1995    case 3594628:
1996      /* unit */ return new Property("unit", "CodeableConcept",
1997          "Describes the unit that an observed value determined for this metric will have. For example: Percent, Seconds, etc.",
1998          0, 1, unit);
1999    case -896505829:
2000      /* source */ return new Property("source", "Reference(Device)",
2001          "Describes the link to the  Device that this DeviceMetric belongs to and that contains administrative device information such as manufacturer, serial number, etc.",
2002          0, 1, source);
2003    case -995424086:
2004      /* parent */ return new Property("parent", "Reference(Device)",
2005          "Describes the link to the  Device 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 Device 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.",
2006          0, 1, parent);
2007    case -2103166364:
2008      /* operationalStatus */ return new Property("operationalStatus", "code",
2009          "Indicates current operational state of the device. For example: On, Off, Standby, etc.", 0, 1,
2010          operationalStatus);
2011    case 94842723:
2012      /* color */ return new Property("color", "code",
2013          "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.",
2014          0, 1, color);
2015    case 50511102:
2016      /* category */ return new Property("category", "code",
2017          "Indicates the category of the observation generation process. A DeviceMetric can be for example a setting, measurement, or calculation.",
2018          0, 1, category);
2019    case -1300332387:
2020      /* measurementPeriod */ return new Property("measurementPeriod", "Timing",
2021          "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.",
2022          0, 1, measurementPeriod);
2023    case 1421318634:
2024      /* calibration */ return new Property("calibration", "",
2025          "Describes the calibrations that have been performed or that are required to be performed.", 0,
2026          java.lang.Integer.MAX_VALUE, calibration);
2027    default:
2028      return super.getNamedProperty(_hash, _name, _checkValid);
2029    }
2030
2031  }
2032
2033  @Override
2034  public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2035    switch (hash) {
2036    case -1618432855:
2037      /* identifier */ return this.identifier == null ? new Base[0]
2038          : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
2039    case 3575610:
2040      /* type */ return this.type == null ? new Base[0] : new Base[] { this.type }; // CodeableConcept
2041    case 3594628:
2042      /* unit */ return this.unit == null ? new Base[0] : new Base[] { this.unit }; // CodeableConcept
2043    case -896505829:
2044      /* source */ return this.source == null ? new Base[0] : new Base[] { this.source }; // Reference
2045    case -995424086:
2046      /* parent */ return this.parent == null ? new Base[0] : new Base[] { this.parent }; // Reference
2047    case -2103166364:
2048      /* operationalStatus */ return this.operationalStatus == null ? new Base[0]
2049          : new Base[] { this.operationalStatus }; // Enumeration<DeviceMetricOperationalStatus>
2050    case 94842723:
2051      /* color */ return this.color == null ? new Base[0] : new Base[] { this.color }; // Enumeration<DeviceMetricColor>
2052    case 50511102:
2053      /* category */ return this.category == null ? new Base[0] : new Base[] { this.category }; // Enumeration<DeviceMetricCategory>
2054    case -1300332387:
2055      /* measurementPeriod */ return this.measurementPeriod == null ? new Base[0]
2056          : new Base[] { this.measurementPeriod }; // Timing
2057    case 1421318634:
2058      /* calibration */ return this.calibration == null ? new Base[0]
2059          : this.calibration.toArray(new Base[this.calibration.size()]); // DeviceMetricCalibrationComponent
2060    default:
2061      return super.getProperty(hash, name, checkValid);
2062    }
2063
2064  }
2065
2066  @Override
2067  public Base setProperty(int hash, String name, Base value) throws FHIRException {
2068    switch (hash) {
2069    case -1618432855: // identifier
2070      this.getIdentifier().add(castToIdentifier(value)); // Identifier
2071      return value;
2072    case 3575610: // type
2073      this.type = castToCodeableConcept(value); // CodeableConcept
2074      return value;
2075    case 3594628: // unit
2076      this.unit = castToCodeableConcept(value); // CodeableConcept
2077      return value;
2078    case -896505829: // source
2079      this.source = castToReference(value); // Reference
2080      return value;
2081    case -995424086: // parent
2082      this.parent = castToReference(value); // Reference
2083      return value;
2084    case -2103166364: // operationalStatus
2085      value = new DeviceMetricOperationalStatusEnumFactory().fromType(castToCode(value));
2086      this.operationalStatus = (Enumeration) value; // Enumeration<DeviceMetricOperationalStatus>
2087      return value;
2088    case 94842723: // color
2089      value = new DeviceMetricColorEnumFactory().fromType(castToCode(value));
2090      this.color = (Enumeration) value; // Enumeration<DeviceMetricColor>
2091      return value;
2092    case 50511102: // category
2093      value = new DeviceMetricCategoryEnumFactory().fromType(castToCode(value));
2094      this.category = (Enumeration) value; // Enumeration<DeviceMetricCategory>
2095      return value;
2096    case -1300332387: // measurementPeriod
2097      this.measurementPeriod = castToTiming(value); // Timing
2098      return value;
2099    case 1421318634: // calibration
2100      this.getCalibration().add((DeviceMetricCalibrationComponent) value); // DeviceMetricCalibrationComponent
2101      return value;
2102    default:
2103      return super.setProperty(hash, name, value);
2104    }
2105
2106  }
2107
2108  @Override
2109  public Base setProperty(String name, Base value) throws FHIRException {
2110    if (name.equals("identifier")) {
2111      this.getIdentifier().add(castToIdentifier(value));
2112    } else if (name.equals("type")) {
2113      this.type = castToCodeableConcept(value); // CodeableConcept
2114    } else if (name.equals("unit")) {
2115      this.unit = castToCodeableConcept(value); // CodeableConcept
2116    } else if (name.equals("source")) {
2117      this.source = castToReference(value); // Reference
2118    } else if (name.equals("parent")) {
2119      this.parent = castToReference(value); // Reference
2120    } else if (name.equals("operationalStatus")) {
2121      value = new DeviceMetricOperationalStatusEnumFactory().fromType(castToCode(value));
2122      this.operationalStatus = (Enumeration) value; // Enumeration<DeviceMetricOperationalStatus>
2123    } else if (name.equals("color")) {
2124      value = new DeviceMetricColorEnumFactory().fromType(castToCode(value));
2125      this.color = (Enumeration) value; // Enumeration<DeviceMetricColor>
2126    } else if (name.equals("category")) {
2127      value = new DeviceMetricCategoryEnumFactory().fromType(castToCode(value));
2128      this.category = (Enumeration) value; // Enumeration<DeviceMetricCategory>
2129    } else if (name.equals("measurementPeriod")) {
2130      this.measurementPeriod = castToTiming(value); // Timing
2131    } else if (name.equals("calibration")) {
2132      this.getCalibration().add((DeviceMetricCalibrationComponent) value);
2133    } else
2134      return super.setProperty(name, value);
2135    return value;
2136  }
2137
2138  @Override
2139  public Base makeProperty(int hash, String name) throws FHIRException {
2140    switch (hash) {
2141    case -1618432855:
2142      return addIdentifier();
2143    case 3575610:
2144      return getType();
2145    case 3594628:
2146      return getUnit();
2147    case -896505829:
2148      return getSource();
2149    case -995424086:
2150      return getParent();
2151    case -2103166364:
2152      return getOperationalStatusElement();
2153    case 94842723:
2154      return getColorElement();
2155    case 50511102:
2156      return getCategoryElement();
2157    case -1300332387:
2158      return getMeasurementPeriod();
2159    case 1421318634:
2160      return addCalibration();
2161    default:
2162      return super.makeProperty(hash, name);
2163    }
2164
2165  }
2166
2167  @Override
2168  public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2169    switch (hash) {
2170    case -1618432855:
2171      /* identifier */ return new String[] { "Identifier" };
2172    case 3575610:
2173      /* type */ return new String[] { "CodeableConcept" };
2174    case 3594628:
2175      /* unit */ return new String[] { "CodeableConcept" };
2176    case -896505829:
2177      /* source */ return new String[] { "Reference" };
2178    case -995424086:
2179      /* parent */ return new String[] { "Reference" };
2180    case -2103166364:
2181      /* operationalStatus */ return new String[] { "code" };
2182    case 94842723:
2183      /* color */ return new String[] { "code" };
2184    case 50511102:
2185      /* category */ return new String[] { "code" };
2186    case -1300332387:
2187      /* measurementPeriod */ return new String[] { "Timing" };
2188    case 1421318634:
2189      /* calibration */ return new String[] {};
2190    default:
2191      return super.getTypesForProperty(hash, name);
2192    }
2193
2194  }
2195
2196  @Override
2197  public Base addChild(String name) throws FHIRException {
2198    if (name.equals("identifier")) {
2199      return addIdentifier();
2200    } else if (name.equals("type")) {
2201      this.type = new CodeableConcept();
2202      return this.type;
2203    } else if (name.equals("unit")) {
2204      this.unit = new CodeableConcept();
2205      return this.unit;
2206    } else if (name.equals("source")) {
2207      this.source = new Reference();
2208      return this.source;
2209    } else if (name.equals("parent")) {
2210      this.parent = new Reference();
2211      return this.parent;
2212    } else if (name.equals("operationalStatus")) {
2213      throw new FHIRException("Cannot call addChild on a singleton property DeviceMetric.operationalStatus");
2214    } else if (name.equals("color")) {
2215      throw new FHIRException("Cannot call addChild on a singleton property DeviceMetric.color");
2216    } else if (name.equals("category")) {
2217      throw new FHIRException("Cannot call addChild on a singleton property DeviceMetric.category");
2218    } else if (name.equals("measurementPeriod")) {
2219      this.measurementPeriod = new Timing();
2220      return this.measurementPeriod;
2221    } else if (name.equals("calibration")) {
2222      return addCalibration();
2223    } else
2224      return super.addChild(name);
2225  }
2226
2227  public String fhirType() {
2228    return "DeviceMetric";
2229
2230  }
2231
2232  public DeviceMetric copy() {
2233    DeviceMetric dst = new DeviceMetric();
2234    copyValues(dst);
2235    return dst;
2236  }
2237
2238  public void copyValues(DeviceMetric dst) {
2239    super.copyValues(dst);
2240    if (identifier != null) {
2241      dst.identifier = new ArrayList<Identifier>();
2242      for (Identifier i : identifier)
2243        dst.identifier.add(i.copy());
2244    }
2245    ;
2246    dst.type = type == null ? null : type.copy();
2247    dst.unit = unit == null ? null : unit.copy();
2248    dst.source = source == null ? null : source.copy();
2249    dst.parent = parent == null ? null : parent.copy();
2250    dst.operationalStatus = operationalStatus == null ? null : operationalStatus.copy();
2251    dst.color = color == null ? null : color.copy();
2252    dst.category = category == null ? null : category.copy();
2253    dst.measurementPeriod = measurementPeriod == null ? null : measurementPeriod.copy();
2254    if (calibration != null) {
2255      dst.calibration = new ArrayList<DeviceMetricCalibrationComponent>();
2256      for (DeviceMetricCalibrationComponent i : calibration)
2257        dst.calibration.add(i.copy());
2258    }
2259    ;
2260  }
2261
2262  protected DeviceMetric typedCopy() {
2263    return copy();
2264  }
2265
2266  @Override
2267  public boolean equalsDeep(Base other_) {
2268    if (!super.equalsDeep(other_))
2269      return false;
2270    if (!(other_ instanceof DeviceMetric))
2271      return false;
2272    DeviceMetric o = (DeviceMetric) other_;
2273    return compareDeep(identifier, o.identifier, true) && compareDeep(type, o.type, true)
2274        && compareDeep(unit, o.unit, true) && compareDeep(source, o.source, true) && compareDeep(parent, o.parent, true)
2275        && compareDeep(operationalStatus, o.operationalStatus, true) && compareDeep(color, o.color, true)
2276        && compareDeep(category, o.category, true) && compareDeep(measurementPeriod, o.measurementPeriod, true)
2277        && compareDeep(calibration, o.calibration, true);
2278  }
2279
2280  @Override
2281  public boolean equalsShallow(Base other_) {
2282    if (!super.equalsShallow(other_))
2283      return false;
2284    if (!(other_ instanceof DeviceMetric))
2285      return false;
2286    DeviceMetric o = (DeviceMetric) other_;
2287    return compareValues(operationalStatus, o.operationalStatus, true) && compareValues(color, o.color, true)
2288        && compareValues(category, o.category, true);
2289  }
2290
2291  public boolean isEmpty() {
2292    return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, type, unit, source, parent,
2293        operationalStatus, color, category, measurementPeriod, calibration);
2294  }
2295
2296  @Override
2297  public ResourceType getResourceType() {
2298    return ResourceType.DeviceMetric;
2299  }
2300
2301  /**
2302   * Search parameter: <b>parent</b>
2303   * <p>
2304   * Description: <b>The parent DeviceMetric resource</b><br>
2305   * Type: <b>reference</b><br>
2306   * Path: <b>DeviceMetric.parent</b><br>
2307   * </p>
2308   */
2309  @SearchParamDefinition(name = "parent", path = "DeviceMetric.parent", description = "The parent DeviceMetric resource", type = "reference", target = {
2310      Device.class })
2311  public static final String SP_PARENT = "parent";
2312  /**
2313   * <b>Fluent Client</b> search parameter constant for <b>parent</b>
2314   * <p>
2315   * Description: <b>The parent DeviceMetric resource</b><br>
2316   * Type: <b>reference</b><br>
2317   * Path: <b>DeviceMetric.parent</b><br>
2318   * </p>
2319   */
2320  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PARENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
2321      SP_PARENT);
2322
2323  /**
2324   * Constant for fluent queries to be used to add include statements. Specifies
2325   * the path value of "<b>DeviceMetric:parent</b>".
2326   */
2327  public static final ca.uhn.fhir.model.api.Include INCLUDE_PARENT = new ca.uhn.fhir.model.api.Include(
2328      "DeviceMetric:parent").toLocked();
2329
2330  /**
2331   * Search parameter: <b>identifier</b>
2332   * <p>
2333   * Description: <b>The identifier of the metric</b><br>
2334   * Type: <b>token</b><br>
2335   * Path: <b>DeviceMetric.identifier</b><br>
2336   * </p>
2337   */
2338  @SearchParamDefinition(name = "identifier", path = "DeviceMetric.identifier", description = "The identifier of the metric", type = "token")
2339  public static final String SP_IDENTIFIER = "identifier";
2340  /**
2341   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
2342   * <p>
2343   * Description: <b>The identifier of the metric</b><br>
2344   * Type: <b>token</b><br>
2345   * Path: <b>DeviceMetric.identifier</b><br>
2346   * </p>
2347   */
2348  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(
2349      SP_IDENTIFIER);
2350
2351  /**
2352   * Search parameter: <b>source</b>
2353   * <p>
2354   * Description: <b>The device resource</b><br>
2355   * Type: <b>reference</b><br>
2356   * Path: <b>DeviceMetric.source</b><br>
2357   * </p>
2358   */
2359  @SearchParamDefinition(name = "source", path = "DeviceMetric.source", description = "The device resource", type = "reference", target = {
2360      Device.class })
2361  public static final String SP_SOURCE = "source";
2362  /**
2363   * <b>Fluent Client</b> search parameter constant for <b>source</b>
2364   * <p>
2365   * Description: <b>The device resource</b><br>
2366   * Type: <b>reference</b><br>
2367   * Path: <b>DeviceMetric.source</b><br>
2368   * </p>
2369   */
2370  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SOURCE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
2371      SP_SOURCE);
2372
2373  /**
2374   * Constant for fluent queries to be used to add include statements. Specifies
2375   * the path value of "<b>DeviceMetric:source</b>".
2376   */
2377  public static final ca.uhn.fhir.model.api.Include INCLUDE_SOURCE = new ca.uhn.fhir.model.api.Include(
2378      "DeviceMetric:source").toLocked();
2379
2380  /**
2381   * Search parameter: <b>type</b>
2382   * <p>
2383   * Description: <b>The component type</b><br>
2384   * Type: <b>token</b><br>
2385   * Path: <b>DeviceMetric.type</b><br>
2386   * </p>
2387   */
2388  @SearchParamDefinition(name = "type", path = "DeviceMetric.type", description = "The component type", type = "token")
2389  public static final String SP_TYPE = "type";
2390  /**
2391   * <b>Fluent Client</b> search parameter constant for <b>type</b>
2392   * <p>
2393   * Description: <b>The component type</b><br>
2394   * Type: <b>token</b><br>
2395   * Path: <b>DeviceMetric.type</b><br>
2396   * </p>
2397   */
2398  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(
2399      SP_TYPE);
2400
2401  /**
2402   * Search parameter: <b>category</b>
2403   * <p>
2404   * Description: <b>The category of the metric</b><br>
2405   * Type: <b>token</b><br>
2406   * Path: <b>DeviceMetric.category</b><br>
2407   * </p>
2408   */
2409  @SearchParamDefinition(name = "category", path = "DeviceMetric.category", description = "The category of the metric", type = "token")
2410  public static final String SP_CATEGORY = "category";
2411  /**
2412   * <b>Fluent Client</b> search parameter constant for <b>category</b>
2413   * <p>
2414   * Description: <b>The category of the metric</b><br>
2415   * Type: <b>token</b><br>
2416   * Path: <b>DeviceMetric.category</b><br>
2417   * </p>
2418   */
2419  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CATEGORY = new ca.uhn.fhir.rest.gclient.TokenClientParam(
2420      SP_CATEGORY);
2421
2422}