001package org.hl7.fhir.dstu3.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 Fri, Mar 16, 2018 15:21+1100 for FHIR v3.0.1
033
034import java.util.*;
035
036import org.hl7.fhir.utilities.Utilities;
037import ca.uhn.fhir.model.api.annotation.ResourceDef;
038import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
039import ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.ChildOrder;
041import ca.uhn.fhir.model.api.annotation.Description;
042import ca.uhn.fhir.model.api.annotation.Block;
043import org.hl7.fhir.instance.model.api.*;
044import org.hl7.fhir.exceptions.FHIRException;
045import org.hl7.fhir.exceptions.FHIRFormatError;
046/**
047 * This resource identifies an instance or a type of a manufactured item that is used in the provision of healthcare without being substantially changed through that activity. The device may be a medical or non-medical device.  Medical devices include durable (reusable) medical equipment, implantable devices, as well as disposable equipment used for diagnostic, treatment, and research for healthcare and public health.  Non-medical devices may include items such as a machine, cellphone, computer, application, etc.
048 */
049@ResourceDef(name="Device", profile="http://hl7.org/fhir/StructureDefinition/Device")
050public class Device extends DomainResource {
051
052    public enum UDIEntryType {
053        /**
054         * A Barcode scanner captured the data from the device label
055         */
056        BARCODE, 
057        /**
058         * An RFID chip reader captured the data from the device label
059         */
060        RFID, 
061        /**
062         * The data was read from the label by a person and manually entered. (e.g.  via a keyboard)
063         */
064        MANUAL, 
065        /**
066         * The data originated from a patient's implant card and read by an operator.
067         */
068        CARD, 
069        /**
070         * The data originated from a patient source and not directly scanned or read from a label or card.
071         */
072        SELFREPORTED, 
073        /**
074         * The method of data capture has not been determined
075         */
076        UNKNOWN, 
077        /**
078         * added to help the parsers with the generic types
079         */
080        NULL;
081        public static UDIEntryType fromCode(String codeString) throws FHIRException {
082            if (codeString == null || "".equals(codeString))
083                return null;
084        if ("barcode".equals(codeString))
085          return BARCODE;
086        if ("rfid".equals(codeString))
087          return RFID;
088        if ("manual".equals(codeString))
089          return MANUAL;
090        if ("card".equals(codeString))
091          return CARD;
092        if ("self-reported".equals(codeString))
093          return SELFREPORTED;
094        if ("unknown".equals(codeString))
095          return UNKNOWN;
096        if (Configuration.isAcceptInvalidEnums())
097          return null;
098        else
099          throw new FHIRException("Unknown UDIEntryType code '"+codeString+"'");
100        }
101        public String toCode() {
102          switch (this) {
103            case BARCODE: return "barcode";
104            case RFID: return "rfid";
105            case MANUAL: return "manual";
106            case CARD: return "card";
107            case SELFREPORTED: return "self-reported";
108            case UNKNOWN: return "unknown";
109            default: return "?";
110          }
111        }
112        public String getSystem() {
113          switch (this) {
114            case BARCODE: return "http://hl7.org/fhir/udi-entry-type";
115            case RFID: return "http://hl7.org/fhir/udi-entry-type";
116            case MANUAL: return "http://hl7.org/fhir/udi-entry-type";
117            case CARD: return "http://hl7.org/fhir/udi-entry-type";
118            case SELFREPORTED: return "http://hl7.org/fhir/udi-entry-type";
119            case UNKNOWN: return "http://hl7.org/fhir/udi-entry-type";
120            default: return "?";
121          }
122        }
123        public String getDefinition() {
124          switch (this) {
125            case BARCODE: return "A Barcode scanner captured the data from the device label";
126            case RFID: return "An RFID chip reader captured the data from the device label";
127            case MANUAL: return "The data was read from the label by a person and manually entered. (e.g.  via a keyboard)";
128            case CARD: return "The data originated from a patient's implant card and read by an operator.";
129            case SELFREPORTED: return "The data originated from a patient source and not directly scanned or read from a label or card.";
130            case UNKNOWN: return "The method of data capture has not been determined";
131            default: return "?";
132          }
133        }
134        public String getDisplay() {
135          switch (this) {
136            case BARCODE: return "BarCode";
137            case RFID: return "RFID";
138            case MANUAL: return "Manual";
139            case CARD: return "Card";
140            case SELFREPORTED: return "Self Reported";
141            case UNKNOWN: return "Unknown";
142            default: return "?";
143          }
144        }
145    }
146
147  public static class UDIEntryTypeEnumFactory implements EnumFactory<UDIEntryType> {
148    public UDIEntryType fromCode(String codeString) throws IllegalArgumentException {
149      if (codeString == null || "".equals(codeString))
150            if (codeString == null || "".equals(codeString))
151                return null;
152        if ("barcode".equals(codeString))
153          return UDIEntryType.BARCODE;
154        if ("rfid".equals(codeString))
155          return UDIEntryType.RFID;
156        if ("manual".equals(codeString))
157          return UDIEntryType.MANUAL;
158        if ("card".equals(codeString))
159          return UDIEntryType.CARD;
160        if ("self-reported".equals(codeString))
161          return UDIEntryType.SELFREPORTED;
162        if ("unknown".equals(codeString))
163          return UDIEntryType.UNKNOWN;
164        throw new IllegalArgumentException("Unknown UDIEntryType code '"+codeString+"'");
165        }
166        public Enumeration<UDIEntryType> fromType(Base code) throws FHIRException {
167          if (code == null)
168            return null;
169          if (code.isEmpty())
170            return new Enumeration<UDIEntryType>(this);
171          String codeString = ((PrimitiveType) code).asStringValue();
172          if (codeString == null || "".equals(codeString))
173            return null;
174        if ("barcode".equals(codeString))
175          return new Enumeration<UDIEntryType>(this, UDIEntryType.BARCODE);
176        if ("rfid".equals(codeString))
177          return new Enumeration<UDIEntryType>(this, UDIEntryType.RFID);
178        if ("manual".equals(codeString))
179          return new Enumeration<UDIEntryType>(this, UDIEntryType.MANUAL);
180        if ("card".equals(codeString))
181          return new Enumeration<UDIEntryType>(this, UDIEntryType.CARD);
182        if ("self-reported".equals(codeString))
183          return new Enumeration<UDIEntryType>(this, UDIEntryType.SELFREPORTED);
184        if ("unknown".equals(codeString))
185          return new Enumeration<UDIEntryType>(this, UDIEntryType.UNKNOWN);
186        throw new FHIRException("Unknown UDIEntryType code '"+codeString+"'");
187        }
188    public String toCode(UDIEntryType code) {
189      if (code == UDIEntryType.BARCODE)
190        return "barcode";
191      if (code == UDIEntryType.RFID)
192        return "rfid";
193      if (code == UDIEntryType.MANUAL)
194        return "manual";
195      if (code == UDIEntryType.CARD)
196        return "card";
197      if (code == UDIEntryType.SELFREPORTED)
198        return "self-reported";
199      if (code == UDIEntryType.UNKNOWN)
200        return "unknown";
201      return "?";
202      }
203    public String toSystem(UDIEntryType code) {
204      return code.getSystem();
205      }
206    }
207
208    public enum FHIRDeviceStatus {
209        /**
210         * The Device is available for use.  Note: This means for *implanted devices*  the device is implanted in the patient.
211         */
212        ACTIVE, 
213        /**
214         * The Device is no longer available for use (e.g. lost, expired, damaged).  Note: This means for *implanted devices*  the device has been removed from the patient.
215         */
216        INACTIVE, 
217        /**
218         * The Device was entered in error and voided.
219         */
220        ENTEREDINERROR, 
221        /**
222         * The status of the device has not been determined.
223         */
224        UNKNOWN, 
225        /**
226         * added to help the parsers with the generic types
227         */
228        NULL;
229        public static FHIRDeviceStatus fromCode(String codeString) throws FHIRException {
230            if (codeString == null || "".equals(codeString))
231                return null;
232        if ("active".equals(codeString))
233          return ACTIVE;
234        if ("inactive".equals(codeString))
235          return INACTIVE;
236        if ("entered-in-error".equals(codeString))
237          return ENTEREDINERROR;
238        if ("unknown".equals(codeString))
239          return UNKNOWN;
240        if (Configuration.isAcceptInvalidEnums())
241          return null;
242        else
243          throw new FHIRException("Unknown FHIRDeviceStatus code '"+codeString+"'");
244        }
245        public String toCode() {
246          switch (this) {
247            case ACTIVE: return "active";
248            case INACTIVE: return "inactive";
249            case ENTEREDINERROR: return "entered-in-error";
250            case UNKNOWN: return "unknown";
251            default: return "?";
252          }
253        }
254        public String getSystem() {
255          switch (this) {
256            case ACTIVE: return "http://hl7.org/fhir/device-status";
257            case INACTIVE: return "http://hl7.org/fhir/device-status";
258            case ENTEREDINERROR: return "http://hl7.org/fhir/device-status";
259            case UNKNOWN: return "http://hl7.org/fhir/device-status";
260            default: return "?";
261          }
262        }
263        public String getDefinition() {
264          switch (this) {
265            case ACTIVE: return "The Device is available for use.  Note: This means for *implanted devices*  the device is implanted in the patient.";
266            case INACTIVE: return "The Device is no longer available for use (e.g. lost, expired, damaged).  Note: This means for *implanted devices*  the device has been removed from the patient.";
267            case ENTEREDINERROR: return "The Device was entered in error and voided.";
268            case UNKNOWN: return "The status of the device has not been determined.";
269            default: return "?";
270          }
271        }
272        public String getDisplay() {
273          switch (this) {
274            case ACTIVE: return "Active";
275            case INACTIVE: return "Inactive";
276            case ENTEREDINERROR: return "Entered in Error";
277            case UNKNOWN: return "Unknown";
278            default: return "?";
279          }
280        }
281    }
282
283  public static class FHIRDeviceStatusEnumFactory implements EnumFactory<FHIRDeviceStatus> {
284    public FHIRDeviceStatus fromCode(String codeString) throws IllegalArgumentException {
285      if (codeString == null || "".equals(codeString))
286            if (codeString == null || "".equals(codeString))
287                return null;
288        if ("active".equals(codeString))
289          return FHIRDeviceStatus.ACTIVE;
290        if ("inactive".equals(codeString))
291          return FHIRDeviceStatus.INACTIVE;
292        if ("entered-in-error".equals(codeString))
293          return FHIRDeviceStatus.ENTEREDINERROR;
294        if ("unknown".equals(codeString))
295          return FHIRDeviceStatus.UNKNOWN;
296        throw new IllegalArgumentException("Unknown FHIRDeviceStatus code '"+codeString+"'");
297        }
298        public Enumeration<FHIRDeviceStatus> fromType(Base code) throws FHIRException {
299          if (code == null)
300            return null;
301          if (code.isEmpty())
302            return new Enumeration<FHIRDeviceStatus>(this);
303          String codeString = ((PrimitiveType) code).asStringValue();
304          if (codeString == null || "".equals(codeString))
305            return null;
306        if ("active".equals(codeString))
307          return new Enumeration<FHIRDeviceStatus>(this, FHIRDeviceStatus.ACTIVE);
308        if ("inactive".equals(codeString))
309          return new Enumeration<FHIRDeviceStatus>(this, FHIRDeviceStatus.INACTIVE);
310        if ("entered-in-error".equals(codeString))
311          return new Enumeration<FHIRDeviceStatus>(this, FHIRDeviceStatus.ENTEREDINERROR);
312        if ("unknown".equals(codeString))
313          return new Enumeration<FHIRDeviceStatus>(this, FHIRDeviceStatus.UNKNOWN);
314        throw new FHIRException("Unknown FHIRDeviceStatus code '"+codeString+"'");
315        }
316    public String toCode(FHIRDeviceStatus code) {
317      if (code == FHIRDeviceStatus.ACTIVE)
318        return "active";
319      if (code == FHIRDeviceStatus.INACTIVE)
320        return "inactive";
321      if (code == FHIRDeviceStatus.ENTEREDINERROR)
322        return "entered-in-error";
323      if (code == FHIRDeviceStatus.UNKNOWN)
324        return "unknown";
325      return "?";
326      }
327    public String toSystem(FHIRDeviceStatus code) {
328      return code.getSystem();
329      }
330    }
331
332    @Block()
333    public static class DeviceUdiComponent extends BackboneElement implements IBaseBackboneElement {
334        /**
335         * The device identifier (DI) is a mandatory, fixed portion of a UDI that identifies the labeler and the specific version or model of a device.
336         */
337        @Child(name = "deviceIdentifier", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true)
338        @Description(shortDefinition="Mandatory fixed portion of UDI", formalDefinition="The device identifier (DI) is a mandatory, fixed portion of a UDI that identifies the labeler and the specific version or model of a device." )
339        protected StringType deviceIdentifier;
340
341        /**
342         * Name of device as used in labeling or catalog.
343         */
344        @Child(name = "name", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=true)
345        @Description(shortDefinition="Device Name as appears on UDI label", formalDefinition="Name of device as used in labeling or catalog." )
346        protected StringType name;
347
348        /**
349         * The identity of the authoritative source for UDI generation within a  jurisdiction.  All UDIs are globally unique within a single namespace. with the appropriate repository uri as the system.  For example,  UDIs of devices managed in the U.S. by the FDA, the value is  http://hl7.org/fhir/NamingSystem/fda-udi.
350         */
351        @Child(name = "jurisdiction", type = {UriType.class}, order=3, min=0, max=1, modifier=false, summary=false)
352        @Description(shortDefinition="Regional UDI authority", formalDefinition="The identity of the authoritative source for UDI generation within a  jurisdiction.  All UDIs are globally unique within a single namespace. with the appropriate repository uri as the system.  For example,  UDIs of devices managed in the U.S. by the FDA, the value is  http://hl7.org/fhir/NamingSystem/fda-udi." )
353        protected UriType jurisdiction;
354
355        /**
356         * The full UDI carrier as the human readable form (HRF) representation of the barcode string as printed on the packaging of the device.
357         */
358        @Child(name = "carrierHRF", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=true)
359        @Description(shortDefinition="UDI Human Readable Barcode String", formalDefinition="The full UDI carrier as the human readable form (HRF) representation of the barcode string as printed on the packaging of the device." )
360        protected StringType carrierHRF;
361
362        /**
363         * The full UDI carrier of the Automatic Identification and Data Capture (AIDC) technology representation of the barcode string as printed on the packaging of the device - E.g a barcode or RFID.   Because of limitations on character sets in XML and the need to round-trip JSON data through XML, AIDC Formats *SHALL* be base64 encoded.
364         */
365        @Child(name = "carrierAIDC", type = {Base64BinaryType.class}, order=5, min=0, max=1, modifier=false, summary=true)
366        @Description(shortDefinition="UDI Machine Readable Barcode String", formalDefinition="The full UDI carrier of the Automatic Identification and Data Capture (AIDC) technology representation of the barcode string as printed on the packaging of the device - E.g a barcode or RFID.   Because of limitations on character sets in XML and the need to round-trip JSON data through XML, AIDC Formats *SHALL* be base64 encoded." )
367        protected Base64BinaryType carrierAIDC;
368
369        /**
370         * Organization that is charged with issuing UDIs for devices.  For example, the US FDA issuers include :
3711) GS1: 
372http://hl7.org/fhir/NamingSystem/gs1-di, 
3732) HIBCC:
374http://hl7.org/fhir/NamingSystem/hibcc-dI, 
3753) ICCBBA for blood containers:
376http://hl7.org/fhir/NamingSystem/iccbba-blood-di, 
3774) ICCBA for other devices:
378http://hl7.org/fhir/NamingSystem/iccbba-other-di.
379         */
380        @Child(name = "issuer", type = {UriType.class}, order=6, min=0, max=1, modifier=false, summary=false)
381        @Description(shortDefinition="UDI Issuing Organization", formalDefinition="Organization that is charged with issuing UDIs for devices.  For example, the US FDA issuers include :\n1) GS1: \nhttp://hl7.org/fhir/NamingSystem/gs1-di, \n2) HIBCC:\nhttp://hl7.org/fhir/NamingSystem/hibcc-dI, \n3) ICCBBA for blood containers:\nhttp://hl7.org/fhir/NamingSystem/iccbba-blood-di, \n4) ICCBA for other devices:\nhttp://hl7.org/fhir/NamingSystem/iccbba-other-di." )
382        protected UriType issuer;
383
384        /**
385         * A coded entry to indicate how the data was entered.
386         */
387        @Child(name = "entryType", type = {CodeType.class}, order=7, min=0, max=1, modifier=false, summary=false)
388        @Description(shortDefinition="barcode | rfid | manual +", formalDefinition="A coded entry to indicate how the data was entered." )
389        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/udi-entry-type")
390        protected Enumeration<UDIEntryType> entryType;
391
392        private static final long serialVersionUID = -1105798343L;
393
394    /**
395     * Constructor
396     */
397      public DeviceUdiComponent() {
398        super();
399      }
400
401        /**
402         * @return {@link #deviceIdentifier} (The device identifier (DI) is a mandatory, fixed portion of a UDI that identifies the labeler and the specific version or model of a device.). This is the underlying object with id, value and extensions. The accessor "getDeviceIdentifier" gives direct access to the value
403         */
404        public StringType getDeviceIdentifierElement() { 
405          if (this.deviceIdentifier == null)
406            if (Configuration.errorOnAutoCreate())
407              throw new Error("Attempt to auto-create DeviceUdiComponent.deviceIdentifier");
408            else if (Configuration.doAutoCreate())
409              this.deviceIdentifier = new StringType(); // bb
410          return this.deviceIdentifier;
411        }
412
413        public boolean hasDeviceIdentifierElement() { 
414          return this.deviceIdentifier != null && !this.deviceIdentifier.isEmpty();
415        }
416
417        public boolean hasDeviceIdentifier() { 
418          return this.deviceIdentifier != null && !this.deviceIdentifier.isEmpty();
419        }
420
421        /**
422         * @param value {@link #deviceIdentifier} (The device identifier (DI) is a mandatory, fixed portion of a UDI that identifies the labeler and the specific version or model of a device.). This is the underlying object with id, value and extensions. The accessor "getDeviceIdentifier" gives direct access to the value
423         */
424        public DeviceUdiComponent setDeviceIdentifierElement(StringType value) { 
425          this.deviceIdentifier = value;
426          return this;
427        }
428
429        /**
430         * @return The device identifier (DI) is a mandatory, fixed portion of a UDI that identifies the labeler and the specific version or model of a device.
431         */
432        public String getDeviceIdentifier() { 
433          return this.deviceIdentifier == null ? null : this.deviceIdentifier.getValue();
434        }
435
436        /**
437         * @param value The device identifier (DI) is a mandatory, fixed portion of a UDI that identifies the labeler and the specific version or model of a device.
438         */
439        public DeviceUdiComponent setDeviceIdentifier(String value) { 
440          if (Utilities.noString(value))
441            this.deviceIdentifier = null;
442          else {
443            if (this.deviceIdentifier == null)
444              this.deviceIdentifier = new StringType();
445            this.deviceIdentifier.setValue(value);
446          }
447          return this;
448        }
449
450        /**
451         * @return {@link #name} (Name of device as used in labeling or catalog.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
452         */
453        public StringType getNameElement() { 
454          if (this.name == null)
455            if (Configuration.errorOnAutoCreate())
456              throw new Error("Attempt to auto-create DeviceUdiComponent.name");
457            else if (Configuration.doAutoCreate())
458              this.name = new StringType(); // bb
459          return this.name;
460        }
461
462        public boolean hasNameElement() { 
463          return this.name != null && !this.name.isEmpty();
464        }
465
466        public boolean hasName() { 
467          return this.name != null && !this.name.isEmpty();
468        }
469
470        /**
471         * @param value {@link #name} (Name of device as used in labeling or catalog.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
472         */
473        public DeviceUdiComponent setNameElement(StringType value) { 
474          this.name = value;
475          return this;
476        }
477
478        /**
479         * @return Name of device as used in labeling or catalog.
480         */
481        public String getName() { 
482          return this.name == null ? null : this.name.getValue();
483        }
484
485        /**
486         * @param value Name of device as used in labeling or catalog.
487         */
488        public DeviceUdiComponent setName(String value) { 
489          if (Utilities.noString(value))
490            this.name = null;
491          else {
492            if (this.name == null)
493              this.name = new StringType();
494            this.name.setValue(value);
495          }
496          return this;
497        }
498
499        /**
500         * @return {@link #jurisdiction} (The identity of the authoritative source for UDI generation within a  jurisdiction.  All UDIs are globally unique within a single namespace. with the appropriate repository uri as the system.  For example,  UDIs of devices managed in the U.S. by the FDA, the value is  http://hl7.org/fhir/NamingSystem/fda-udi.). This is the underlying object with id, value and extensions. The accessor "getJurisdiction" gives direct access to the value
501         */
502        public UriType getJurisdictionElement() { 
503          if (this.jurisdiction == null)
504            if (Configuration.errorOnAutoCreate())
505              throw new Error("Attempt to auto-create DeviceUdiComponent.jurisdiction");
506            else if (Configuration.doAutoCreate())
507              this.jurisdiction = new UriType(); // bb
508          return this.jurisdiction;
509        }
510
511        public boolean hasJurisdictionElement() { 
512          return this.jurisdiction != null && !this.jurisdiction.isEmpty();
513        }
514
515        public boolean hasJurisdiction() { 
516          return this.jurisdiction != null && !this.jurisdiction.isEmpty();
517        }
518
519        /**
520         * @param value {@link #jurisdiction} (The identity of the authoritative source for UDI generation within a  jurisdiction.  All UDIs are globally unique within a single namespace. with the appropriate repository uri as the system.  For example,  UDIs of devices managed in the U.S. by the FDA, the value is  http://hl7.org/fhir/NamingSystem/fda-udi.). This is the underlying object with id, value and extensions. The accessor "getJurisdiction" gives direct access to the value
521         */
522        public DeviceUdiComponent setJurisdictionElement(UriType value) { 
523          this.jurisdiction = value;
524          return this;
525        }
526
527        /**
528         * @return The identity of the authoritative source for UDI generation within a  jurisdiction.  All UDIs are globally unique within a single namespace. with the appropriate repository uri as the system.  For example,  UDIs of devices managed in the U.S. by the FDA, the value is  http://hl7.org/fhir/NamingSystem/fda-udi.
529         */
530        public String getJurisdiction() { 
531          return this.jurisdiction == null ? null : this.jurisdiction.getValue();
532        }
533
534        /**
535         * @param value The identity of the authoritative source for UDI generation within a  jurisdiction.  All UDIs are globally unique within a single namespace. with the appropriate repository uri as the system.  For example,  UDIs of devices managed in the U.S. by the FDA, the value is  http://hl7.org/fhir/NamingSystem/fda-udi.
536         */
537        public DeviceUdiComponent setJurisdiction(String value) { 
538          if (Utilities.noString(value))
539            this.jurisdiction = null;
540          else {
541            if (this.jurisdiction == null)
542              this.jurisdiction = new UriType();
543            this.jurisdiction.setValue(value);
544          }
545          return this;
546        }
547
548        /**
549         * @return {@link #carrierHRF} (The full UDI carrier as the human readable form (HRF) representation of the barcode string as printed on the packaging of the device.). This is the underlying object with id, value and extensions. The accessor "getCarrierHRF" gives direct access to the value
550         */
551        public StringType getCarrierHRFElement() { 
552          if (this.carrierHRF == null)
553            if (Configuration.errorOnAutoCreate())
554              throw new Error("Attempt to auto-create DeviceUdiComponent.carrierHRF");
555            else if (Configuration.doAutoCreate())
556              this.carrierHRF = new StringType(); // bb
557          return this.carrierHRF;
558        }
559
560        public boolean hasCarrierHRFElement() { 
561          return this.carrierHRF != null && !this.carrierHRF.isEmpty();
562        }
563
564        public boolean hasCarrierHRF() { 
565          return this.carrierHRF != null && !this.carrierHRF.isEmpty();
566        }
567
568        /**
569         * @param value {@link #carrierHRF} (The full UDI carrier as the human readable form (HRF) representation of the barcode string as printed on the packaging of the device.). This is the underlying object with id, value and extensions. The accessor "getCarrierHRF" gives direct access to the value
570         */
571        public DeviceUdiComponent setCarrierHRFElement(StringType value) { 
572          this.carrierHRF = value;
573          return this;
574        }
575
576        /**
577         * @return The full UDI carrier as the human readable form (HRF) representation of the barcode string as printed on the packaging of the device.
578         */
579        public String getCarrierHRF() { 
580          return this.carrierHRF == null ? null : this.carrierHRF.getValue();
581        }
582
583        /**
584         * @param value The full UDI carrier as the human readable form (HRF) representation of the barcode string as printed on the packaging of the device.
585         */
586        public DeviceUdiComponent setCarrierHRF(String value) { 
587          if (Utilities.noString(value))
588            this.carrierHRF = null;
589          else {
590            if (this.carrierHRF == null)
591              this.carrierHRF = new StringType();
592            this.carrierHRF.setValue(value);
593          }
594          return this;
595        }
596
597        /**
598         * @return {@link #carrierAIDC} (The full UDI carrier of the Automatic Identification and Data Capture (AIDC) technology representation of the barcode string as printed on the packaging of the device - E.g a barcode or RFID.   Because of limitations on character sets in XML and the need to round-trip JSON data through XML, AIDC Formats *SHALL* be base64 encoded.). This is the underlying object with id, value and extensions. The accessor "getCarrierAIDC" gives direct access to the value
599         */
600        public Base64BinaryType getCarrierAIDCElement() { 
601          if (this.carrierAIDC == null)
602            if (Configuration.errorOnAutoCreate())
603              throw new Error("Attempt to auto-create DeviceUdiComponent.carrierAIDC");
604            else if (Configuration.doAutoCreate())
605              this.carrierAIDC = new Base64BinaryType(); // bb
606          return this.carrierAIDC;
607        }
608
609        public boolean hasCarrierAIDCElement() { 
610          return this.carrierAIDC != null && !this.carrierAIDC.isEmpty();
611        }
612
613        public boolean hasCarrierAIDC() { 
614          return this.carrierAIDC != null && !this.carrierAIDC.isEmpty();
615        }
616
617        /**
618         * @param value {@link #carrierAIDC} (The full UDI carrier of the Automatic Identification and Data Capture (AIDC) technology representation of the barcode string as printed on the packaging of the device - E.g a barcode or RFID.   Because of limitations on character sets in XML and the need to round-trip JSON data through XML, AIDC Formats *SHALL* be base64 encoded.). This is the underlying object with id, value and extensions. The accessor "getCarrierAIDC" gives direct access to the value
619         */
620        public DeviceUdiComponent setCarrierAIDCElement(Base64BinaryType value) { 
621          this.carrierAIDC = value;
622          return this;
623        }
624
625        /**
626         * @return The full UDI carrier of the Automatic Identification and Data Capture (AIDC) technology representation of the barcode string as printed on the packaging of the device - E.g a barcode or RFID.   Because of limitations on character sets in XML and the need to round-trip JSON data through XML, AIDC Formats *SHALL* be base64 encoded.
627         */
628        public byte[] getCarrierAIDC() { 
629          return this.carrierAIDC == null ? null : this.carrierAIDC.getValue();
630        }
631
632        /**
633         * @param value The full UDI carrier of the Automatic Identification and Data Capture (AIDC) technology representation of the barcode string as printed on the packaging of the device - E.g a barcode or RFID.   Because of limitations on character sets in XML and the need to round-trip JSON data through XML, AIDC Formats *SHALL* be base64 encoded.
634         */
635        public DeviceUdiComponent setCarrierAIDC(byte[] value) { 
636          if (value == null)
637            this.carrierAIDC = null;
638          else {
639            if (this.carrierAIDC == null)
640              this.carrierAIDC = new Base64BinaryType();
641            this.carrierAIDC.setValue(value);
642          }
643          return this;
644        }
645
646        /**
647         * @return {@link #issuer} (Organization that is charged with issuing UDIs for devices.  For example, the US FDA issuers include :
6481) GS1: 
649http://hl7.org/fhir/NamingSystem/gs1-di, 
6502) HIBCC:
651http://hl7.org/fhir/NamingSystem/hibcc-dI, 
6523) ICCBBA for blood containers:
653http://hl7.org/fhir/NamingSystem/iccbba-blood-di, 
6544) ICCBA for other devices:
655http://hl7.org/fhir/NamingSystem/iccbba-other-di.). This is the underlying object with id, value and extensions. The accessor "getIssuer" gives direct access to the value
656         */
657        public UriType getIssuerElement() { 
658          if (this.issuer == null)
659            if (Configuration.errorOnAutoCreate())
660              throw new Error("Attempt to auto-create DeviceUdiComponent.issuer");
661            else if (Configuration.doAutoCreate())
662              this.issuer = new UriType(); // bb
663          return this.issuer;
664        }
665
666        public boolean hasIssuerElement() { 
667          return this.issuer != null && !this.issuer.isEmpty();
668        }
669
670        public boolean hasIssuer() { 
671          return this.issuer != null && !this.issuer.isEmpty();
672        }
673
674        /**
675         * @param value {@link #issuer} (Organization that is charged with issuing UDIs for devices.  For example, the US FDA issuers include :
6761) GS1: 
677http://hl7.org/fhir/NamingSystem/gs1-di, 
6782) HIBCC:
679http://hl7.org/fhir/NamingSystem/hibcc-dI, 
6803) ICCBBA for blood containers:
681http://hl7.org/fhir/NamingSystem/iccbba-blood-di, 
6824) ICCBA for other devices:
683http://hl7.org/fhir/NamingSystem/iccbba-other-di.). This is the underlying object with id, value and extensions. The accessor "getIssuer" gives direct access to the value
684         */
685        public DeviceUdiComponent setIssuerElement(UriType value) { 
686          this.issuer = value;
687          return this;
688        }
689
690        /**
691         * @return Organization that is charged with issuing UDIs for devices.  For example, the US FDA issuers include :
6921) GS1: 
693http://hl7.org/fhir/NamingSystem/gs1-di, 
6942) HIBCC:
695http://hl7.org/fhir/NamingSystem/hibcc-dI, 
6963) ICCBBA for blood containers:
697http://hl7.org/fhir/NamingSystem/iccbba-blood-di, 
6984) ICCBA for other devices:
699http://hl7.org/fhir/NamingSystem/iccbba-other-di.
700         */
701        public String getIssuer() { 
702          return this.issuer == null ? null : this.issuer.getValue();
703        }
704
705        /**
706         * @param value Organization that is charged with issuing UDIs for devices.  For example, the US FDA issuers include :
7071) GS1: 
708http://hl7.org/fhir/NamingSystem/gs1-di, 
7092) HIBCC:
710http://hl7.org/fhir/NamingSystem/hibcc-dI, 
7113) ICCBBA for blood containers:
712http://hl7.org/fhir/NamingSystem/iccbba-blood-di, 
7134) ICCBA for other devices:
714http://hl7.org/fhir/NamingSystem/iccbba-other-di.
715         */
716        public DeviceUdiComponent setIssuer(String value) { 
717          if (Utilities.noString(value))
718            this.issuer = null;
719          else {
720            if (this.issuer == null)
721              this.issuer = new UriType();
722            this.issuer.setValue(value);
723          }
724          return this;
725        }
726
727        /**
728         * @return {@link #entryType} (A coded entry to indicate how the data was entered.). This is the underlying object with id, value and extensions. The accessor "getEntryType" gives direct access to the value
729         */
730        public Enumeration<UDIEntryType> getEntryTypeElement() { 
731          if (this.entryType == null)
732            if (Configuration.errorOnAutoCreate())
733              throw new Error("Attempt to auto-create DeviceUdiComponent.entryType");
734            else if (Configuration.doAutoCreate())
735              this.entryType = new Enumeration<UDIEntryType>(new UDIEntryTypeEnumFactory()); // bb
736          return this.entryType;
737        }
738
739        public boolean hasEntryTypeElement() { 
740          return this.entryType != null && !this.entryType.isEmpty();
741        }
742
743        public boolean hasEntryType() { 
744          return this.entryType != null && !this.entryType.isEmpty();
745        }
746
747        /**
748         * @param value {@link #entryType} (A coded entry to indicate how the data was entered.). This is the underlying object with id, value and extensions. The accessor "getEntryType" gives direct access to the value
749         */
750        public DeviceUdiComponent setEntryTypeElement(Enumeration<UDIEntryType> value) { 
751          this.entryType = value;
752          return this;
753        }
754
755        /**
756         * @return A coded entry to indicate how the data was entered.
757         */
758        public UDIEntryType getEntryType() { 
759          return this.entryType == null ? null : this.entryType.getValue();
760        }
761
762        /**
763         * @param value A coded entry to indicate how the data was entered.
764         */
765        public DeviceUdiComponent setEntryType(UDIEntryType value) { 
766          if (value == null)
767            this.entryType = null;
768          else {
769            if (this.entryType == null)
770              this.entryType = new Enumeration<UDIEntryType>(new UDIEntryTypeEnumFactory());
771            this.entryType.setValue(value);
772          }
773          return this;
774        }
775
776        protected void listChildren(List<Property> children) {
777          super.listChildren(children);
778          children.add(new Property("deviceIdentifier", "string", "The device identifier (DI) is a mandatory, fixed portion of a UDI that identifies the labeler and the specific version or model of a device.", 0, 1, deviceIdentifier));
779          children.add(new Property("name", "string", "Name of device as used in labeling or catalog.", 0, 1, name));
780          children.add(new Property("jurisdiction", "uri", "The identity of the authoritative source for UDI generation within a  jurisdiction.  All UDIs are globally unique within a single namespace. with the appropriate repository uri as the system.  For example,  UDIs of devices managed in the U.S. by the FDA, the value is  http://hl7.org/fhir/NamingSystem/fda-udi.", 0, 1, jurisdiction));
781          children.add(new Property("carrierHRF", "string", "The full UDI carrier as the human readable form (HRF) representation of the barcode string as printed on the packaging of the device.", 0, 1, carrierHRF));
782          children.add(new Property("carrierAIDC", "base64Binary", "The full UDI carrier of the Automatic Identification and Data Capture (AIDC) technology representation of the barcode string as printed on the packaging of the device - E.g a barcode or RFID.   Because of limitations on character sets in XML and the need to round-trip JSON data through XML, AIDC Formats *SHALL* be base64 encoded.", 0, 1, carrierAIDC));
783          children.add(new Property("issuer", "uri", "Organization that is charged with issuing UDIs for devices.  For example, the US FDA issuers include :\n1) GS1: \nhttp://hl7.org/fhir/NamingSystem/gs1-di, \n2) HIBCC:\nhttp://hl7.org/fhir/NamingSystem/hibcc-dI, \n3) ICCBBA for blood containers:\nhttp://hl7.org/fhir/NamingSystem/iccbba-blood-di, \n4) ICCBA for other devices:\nhttp://hl7.org/fhir/NamingSystem/iccbba-other-di.", 0, 1, issuer));
784          children.add(new Property("entryType", "code", "A coded entry to indicate how the data was entered.", 0, 1, entryType));
785        }
786
787        @Override
788        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
789          switch (_hash) {
790          case 1322005407: /*deviceIdentifier*/  return new Property("deviceIdentifier", "string", "The device identifier (DI) is a mandatory, fixed portion of a UDI that identifies the labeler and the specific version or model of a device.", 0, 1, deviceIdentifier);
791          case 3373707: /*name*/  return new Property("name", "string", "Name of device as used in labeling or catalog.", 0, 1, name);
792          case -507075711: /*jurisdiction*/  return new Property("jurisdiction", "uri", "The identity of the authoritative source for UDI generation within a  jurisdiction.  All UDIs are globally unique within a single namespace. with the appropriate repository uri as the system.  For example,  UDIs of devices managed in the U.S. by the FDA, the value is  http://hl7.org/fhir/NamingSystem/fda-udi.", 0, 1, jurisdiction);
793          case 806499972: /*carrierHRF*/  return new Property("carrierHRF", "string", "The full UDI carrier as the human readable form (HRF) representation of the barcode string as printed on the packaging of the device.", 0, 1, carrierHRF);
794          case -768521825: /*carrierAIDC*/  return new Property("carrierAIDC", "base64Binary", "The full UDI carrier of the Automatic Identification and Data Capture (AIDC) technology representation of the barcode string as printed on the packaging of the device - E.g a barcode or RFID.   Because of limitations on character sets in XML and the need to round-trip JSON data through XML, AIDC Formats *SHALL* be base64 encoded.", 0, 1, carrierAIDC);
795          case -1179159879: /*issuer*/  return new Property("issuer", "uri", "Organization that is charged with issuing UDIs for devices.  For example, the US FDA issuers include :\n1) GS1: \nhttp://hl7.org/fhir/NamingSystem/gs1-di, \n2) HIBCC:\nhttp://hl7.org/fhir/NamingSystem/hibcc-dI, \n3) ICCBBA for blood containers:\nhttp://hl7.org/fhir/NamingSystem/iccbba-blood-di, \n4) ICCBA for other devices:\nhttp://hl7.org/fhir/NamingSystem/iccbba-other-di.", 0, 1, issuer);
796          case -479362356: /*entryType*/  return new Property("entryType", "code", "A coded entry to indicate how the data was entered.", 0, 1, entryType);
797          default: return super.getNamedProperty(_hash, _name, _checkValid);
798          }
799
800        }
801
802      @Override
803      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
804        switch (hash) {
805        case 1322005407: /*deviceIdentifier*/ return this.deviceIdentifier == null ? new Base[0] : new Base[] {this.deviceIdentifier}; // StringType
806        case 3373707: /*name*/ return this.name == null ? new Base[0] : new Base[] {this.name}; // StringType
807        case -507075711: /*jurisdiction*/ return this.jurisdiction == null ? new Base[0] : new Base[] {this.jurisdiction}; // UriType
808        case 806499972: /*carrierHRF*/ return this.carrierHRF == null ? new Base[0] : new Base[] {this.carrierHRF}; // StringType
809        case -768521825: /*carrierAIDC*/ return this.carrierAIDC == null ? new Base[0] : new Base[] {this.carrierAIDC}; // Base64BinaryType
810        case -1179159879: /*issuer*/ return this.issuer == null ? new Base[0] : new Base[] {this.issuer}; // UriType
811        case -479362356: /*entryType*/ return this.entryType == null ? new Base[0] : new Base[] {this.entryType}; // Enumeration<UDIEntryType>
812        default: return super.getProperty(hash, name, checkValid);
813        }
814
815      }
816
817      @Override
818      public Base setProperty(int hash, String name, Base value) throws FHIRException {
819        switch (hash) {
820        case 1322005407: // deviceIdentifier
821          this.deviceIdentifier = castToString(value); // StringType
822          return value;
823        case 3373707: // name
824          this.name = castToString(value); // StringType
825          return value;
826        case -507075711: // jurisdiction
827          this.jurisdiction = castToUri(value); // UriType
828          return value;
829        case 806499972: // carrierHRF
830          this.carrierHRF = castToString(value); // StringType
831          return value;
832        case -768521825: // carrierAIDC
833          this.carrierAIDC = castToBase64Binary(value); // Base64BinaryType
834          return value;
835        case -1179159879: // issuer
836          this.issuer = castToUri(value); // UriType
837          return value;
838        case -479362356: // entryType
839          value = new UDIEntryTypeEnumFactory().fromType(castToCode(value));
840          this.entryType = (Enumeration) value; // Enumeration<UDIEntryType>
841          return value;
842        default: return super.setProperty(hash, name, value);
843        }
844
845      }
846
847      @Override
848      public Base setProperty(String name, Base value) throws FHIRException {
849        if (name.equals("deviceIdentifier")) {
850          this.deviceIdentifier = castToString(value); // StringType
851        } else if (name.equals("name")) {
852          this.name = castToString(value); // StringType
853        } else if (name.equals("jurisdiction")) {
854          this.jurisdiction = castToUri(value); // UriType
855        } else if (name.equals("carrierHRF")) {
856          this.carrierHRF = castToString(value); // StringType
857        } else if (name.equals("carrierAIDC")) {
858          this.carrierAIDC = castToBase64Binary(value); // Base64BinaryType
859        } else if (name.equals("issuer")) {
860          this.issuer = castToUri(value); // UriType
861        } else if (name.equals("entryType")) {
862          value = new UDIEntryTypeEnumFactory().fromType(castToCode(value));
863          this.entryType = (Enumeration) value; // Enumeration<UDIEntryType>
864        } else
865          return super.setProperty(name, value);
866        return value;
867      }
868
869      @Override
870      public Base makeProperty(int hash, String name) throws FHIRException {
871        switch (hash) {
872        case 1322005407:  return getDeviceIdentifierElement();
873        case 3373707:  return getNameElement();
874        case -507075711:  return getJurisdictionElement();
875        case 806499972:  return getCarrierHRFElement();
876        case -768521825:  return getCarrierAIDCElement();
877        case -1179159879:  return getIssuerElement();
878        case -479362356:  return getEntryTypeElement();
879        default: return super.makeProperty(hash, name);
880        }
881
882      }
883
884      @Override
885      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
886        switch (hash) {
887        case 1322005407: /*deviceIdentifier*/ return new String[] {"string"};
888        case 3373707: /*name*/ return new String[] {"string"};
889        case -507075711: /*jurisdiction*/ return new String[] {"uri"};
890        case 806499972: /*carrierHRF*/ return new String[] {"string"};
891        case -768521825: /*carrierAIDC*/ return new String[] {"base64Binary"};
892        case -1179159879: /*issuer*/ return new String[] {"uri"};
893        case -479362356: /*entryType*/ return new String[] {"code"};
894        default: return super.getTypesForProperty(hash, name);
895        }
896
897      }
898
899      @Override
900      public Base addChild(String name) throws FHIRException {
901        if (name.equals("deviceIdentifier")) {
902          throw new FHIRException("Cannot call addChild on a primitive type Device.deviceIdentifier");
903        }
904        else if (name.equals("name")) {
905          throw new FHIRException("Cannot call addChild on a primitive type Device.name");
906        }
907        else if (name.equals("jurisdiction")) {
908          throw new FHIRException("Cannot call addChild on a primitive type Device.jurisdiction");
909        }
910        else if (name.equals("carrierHRF")) {
911          throw new FHIRException("Cannot call addChild on a primitive type Device.carrierHRF");
912        }
913        else if (name.equals("carrierAIDC")) {
914          throw new FHIRException("Cannot call addChild on a primitive type Device.carrierAIDC");
915        }
916        else if (name.equals("issuer")) {
917          throw new FHIRException("Cannot call addChild on a primitive type Device.issuer");
918        }
919        else if (name.equals("entryType")) {
920          throw new FHIRException("Cannot call addChild on a primitive type Device.entryType");
921        }
922        else
923          return super.addChild(name);
924      }
925
926      public DeviceUdiComponent copy() {
927        DeviceUdiComponent dst = new DeviceUdiComponent();
928        copyValues(dst);
929        dst.deviceIdentifier = deviceIdentifier == null ? null : deviceIdentifier.copy();
930        dst.name = name == null ? null : name.copy();
931        dst.jurisdiction = jurisdiction == null ? null : jurisdiction.copy();
932        dst.carrierHRF = carrierHRF == null ? null : carrierHRF.copy();
933        dst.carrierAIDC = carrierAIDC == null ? null : carrierAIDC.copy();
934        dst.issuer = issuer == null ? null : issuer.copy();
935        dst.entryType = entryType == null ? null : entryType.copy();
936        return dst;
937      }
938
939      @Override
940      public boolean equalsDeep(Base other_) {
941        if (!super.equalsDeep(other_))
942          return false;
943        if (!(other_ instanceof DeviceUdiComponent))
944          return false;
945        DeviceUdiComponent o = (DeviceUdiComponent) other_;
946        return compareDeep(deviceIdentifier, o.deviceIdentifier, true) && compareDeep(name, o.name, true)
947           && compareDeep(jurisdiction, o.jurisdiction, true) && compareDeep(carrierHRF, o.carrierHRF, true)
948           && compareDeep(carrierAIDC, o.carrierAIDC, true) && compareDeep(issuer, o.issuer, true) && compareDeep(entryType, o.entryType, true)
949          ;
950      }
951
952      @Override
953      public boolean equalsShallow(Base other_) {
954        if (!super.equalsShallow(other_))
955          return false;
956        if (!(other_ instanceof DeviceUdiComponent))
957          return false;
958        DeviceUdiComponent o = (DeviceUdiComponent) other_;
959        return compareValues(deviceIdentifier, o.deviceIdentifier, true) && compareValues(name, o.name, true)
960           && compareValues(jurisdiction, o.jurisdiction, true) && compareValues(carrierHRF, o.carrierHRF, true)
961           && compareValues(carrierAIDC, o.carrierAIDC, true) && compareValues(issuer, o.issuer, true) && compareValues(entryType, o.entryType, true)
962          ;
963      }
964
965      public boolean isEmpty() {
966        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(deviceIdentifier, name, jurisdiction
967          , carrierHRF, carrierAIDC, issuer, entryType);
968      }
969
970  public String fhirType() {
971    return "Device.udi";
972
973  }
974
975  }
976
977    /**
978     * Unique instance identifiers assigned to a device by manufacturers other organizations or owners.
979     */
980    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
981    @Description(shortDefinition="Instance identifier", formalDefinition="Unique instance identifiers assigned to a device by manufacturers other organizations or owners." )
982    protected List<Identifier> identifier;
983
984    /**
985     * [Unique device identifier (UDI)](device.html#5.11.3.2.2) assigned to device label or package.
986     */
987    @Child(name = "udi", type = {}, order=1, min=0, max=1, modifier=false, summary=true)
988    @Description(shortDefinition="Unique Device Identifier (UDI) Barcode string", formalDefinition="[Unique device identifier (UDI)](device.html#5.11.3.2.2) assigned to device label or package." )
989    protected DeviceUdiComponent udi;
990
991    /**
992     * Status of the Device availability.
993     */
994    @Child(name = "status", type = {CodeType.class}, order=2, min=0, max=1, modifier=true, summary=true)
995    @Description(shortDefinition="active | inactive | entered-in-error | unknown", formalDefinition="Status of the Device availability." )
996    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/device-status")
997    protected Enumeration<FHIRDeviceStatus> status;
998
999    /**
1000     * Code or identifier to identify a kind of device.
1001     */
1002    @Child(name = "type", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=false)
1003    @Description(shortDefinition="What kind of device this is", formalDefinition="Code or identifier to identify a kind of device." )
1004    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/device-kind")
1005    protected CodeableConcept type;
1006
1007    /**
1008     * Lot number assigned by the manufacturer.
1009     */
1010    @Child(name = "lotNumber", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=false)
1011    @Description(shortDefinition="Lot number of manufacture", formalDefinition="Lot number assigned by the manufacturer." )
1012    protected StringType lotNumber;
1013
1014    /**
1015     * A name of the manufacturer.
1016     */
1017    @Child(name = "manufacturer", type = {StringType.class}, order=5, min=0, max=1, modifier=false, summary=false)
1018    @Description(shortDefinition="Name of device manufacturer", formalDefinition="A name of the manufacturer." )
1019    protected StringType manufacturer;
1020
1021    /**
1022     * The date and time when the device was manufactured.
1023     */
1024    @Child(name = "manufactureDate", type = {DateTimeType.class}, order=6, min=0, max=1, modifier=false, summary=false)
1025    @Description(shortDefinition="Date when the device was made", formalDefinition="The date and time when the device was manufactured." )
1026    protected DateTimeType manufactureDate;
1027
1028    /**
1029     * The date and time beyond which this device is no longer valid or should not be used (if applicable).
1030     */
1031    @Child(name = "expirationDate", type = {DateTimeType.class}, order=7, min=0, max=1, modifier=false, summary=false)
1032    @Description(shortDefinition="Date and time of expiry of this device (if applicable)", formalDefinition="The date and time beyond which this device is no longer valid or should not be used (if applicable)." )
1033    protected DateTimeType expirationDate;
1034
1035    /**
1036     * The "model" is an identifier assigned by the manufacturer to identify the product by its type. This number is shared by the all devices sold as the same type.
1037     */
1038    @Child(name = "model", type = {StringType.class}, order=8, min=0, max=1, modifier=false, summary=false)
1039    @Description(shortDefinition="Model id assigned by the manufacturer", formalDefinition="The \"model\" is an identifier assigned by the manufacturer to identify the product by its type. This number is shared by the all devices sold as the same type." )
1040    protected StringType model;
1041
1042    /**
1043     * The version of the device, if the device has multiple releases under the same model, or if the device is software or carries firmware.
1044     */
1045    @Child(name = "version", type = {StringType.class}, order=9, min=0, max=1, modifier=false, summary=false)
1046    @Description(shortDefinition="Version number (i.e. software)", formalDefinition="The version of the device, if the device has multiple releases under the same model, or if the device is software or carries firmware." )
1047    protected StringType version;
1048
1049    /**
1050     * Patient information, If the device is affixed to a person.
1051     */
1052    @Child(name = "patient", type = {Patient.class}, order=10, min=0, max=1, modifier=false, summary=false)
1053    @Description(shortDefinition="Patient to whom Device is affixed", formalDefinition="Patient information, If the device is affixed to a person." )
1054    protected Reference patient;
1055
1056    /**
1057     * The actual object that is the target of the reference (Patient information, If the device is affixed to a person.)
1058     */
1059    protected Patient patientTarget;
1060
1061    /**
1062     * An organization that is responsible for the provision and ongoing maintenance of the device.
1063     */
1064    @Child(name = "owner", type = {Organization.class}, order=11, min=0, max=1, modifier=false, summary=false)
1065    @Description(shortDefinition="Organization responsible for device", formalDefinition="An organization that is responsible for the provision and ongoing maintenance of the device." )
1066    protected Reference owner;
1067
1068    /**
1069     * The actual object that is the target of the reference (An organization that is responsible for the provision and ongoing maintenance of the device.)
1070     */
1071    protected Organization ownerTarget;
1072
1073    /**
1074     * Contact details for an organization or a particular human that is responsible for the device.
1075     */
1076    @Child(name = "contact", type = {ContactPoint.class}, order=12, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1077    @Description(shortDefinition="Details for human/organization for support", formalDefinition="Contact details for an organization or a particular human that is responsible for the device." )
1078    protected List<ContactPoint> contact;
1079
1080    /**
1081     * The place where the device can be found.
1082     */
1083    @Child(name = "location", type = {Location.class}, order=13, min=0, max=1, modifier=false, summary=false)
1084    @Description(shortDefinition="Where the resource is found", formalDefinition="The place where the device can be found." )
1085    protected Reference location;
1086
1087    /**
1088     * The actual object that is the target of the reference (The place where the device can be found.)
1089     */
1090    protected Location locationTarget;
1091
1092    /**
1093     * A network address on which the device may be contacted directly.
1094     */
1095    @Child(name = "url", type = {UriType.class}, order=14, min=0, max=1, modifier=false, summary=false)
1096    @Description(shortDefinition="Network address to contact device", formalDefinition="A network address on which the device may be contacted directly." )
1097    protected UriType url;
1098
1099    /**
1100     * Descriptive information, usage information or implantation information that is not captured in an existing element.
1101     */
1102    @Child(name = "note", type = {Annotation.class}, order=15, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1103    @Description(shortDefinition="Device notes and comments", formalDefinition="Descriptive information, usage information or implantation information that is not captured in an existing element." )
1104    protected List<Annotation> note;
1105
1106    /**
1107     * Provides additional safety characteristics about a medical device.  For example devices containing latex.
1108     */
1109    @Child(name = "safety", type = {CodeableConcept.class}, order=16, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1110    @Description(shortDefinition="Safety Characteristics of Device", formalDefinition="Provides additional safety characteristics about a medical device.  For example devices containing latex." )
1111    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/device-safety")
1112    protected List<CodeableConcept> safety;
1113
1114    private static final long serialVersionUID = -1056263930L;
1115
1116  /**
1117   * Constructor
1118   */
1119    public Device() {
1120      super();
1121    }
1122
1123    /**
1124     * @return {@link #identifier} (Unique instance identifiers assigned to a device by manufacturers other organizations or owners.)
1125     */
1126    public List<Identifier> getIdentifier() { 
1127      if (this.identifier == null)
1128        this.identifier = new ArrayList<Identifier>();
1129      return this.identifier;
1130    }
1131
1132    /**
1133     * @return Returns a reference to <code>this</code> for easy method chaining
1134     */
1135    public Device setIdentifier(List<Identifier> theIdentifier) { 
1136      this.identifier = theIdentifier;
1137      return this;
1138    }
1139
1140    public boolean hasIdentifier() { 
1141      if (this.identifier == null)
1142        return false;
1143      for (Identifier item : this.identifier)
1144        if (!item.isEmpty())
1145          return true;
1146      return false;
1147    }
1148
1149    public Identifier addIdentifier() { //3
1150      Identifier t = new Identifier();
1151      if (this.identifier == null)
1152        this.identifier = new ArrayList<Identifier>();
1153      this.identifier.add(t);
1154      return t;
1155    }
1156
1157    public Device addIdentifier(Identifier t) { //3
1158      if (t == null)
1159        return this;
1160      if (this.identifier == null)
1161        this.identifier = new ArrayList<Identifier>();
1162      this.identifier.add(t);
1163      return this;
1164    }
1165
1166    /**
1167     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
1168     */
1169    public Identifier getIdentifierFirstRep() { 
1170      if (getIdentifier().isEmpty()) {
1171        addIdentifier();
1172      }
1173      return getIdentifier().get(0);
1174    }
1175
1176    /**
1177     * @return {@link #udi} ([Unique device identifier (UDI)](device.html#5.11.3.2.2) assigned to device label or package.)
1178     */
1179    public DeviceUdiComponent getUdi() { 
1180      if (this.udi == null)
1181        if (Configuration.errorOnAutoCreate())
1182          throw new Error("Attempt to auto-create Device.udi");
1183        else if (Configuration.doAutoCreate())
1184          this.udi = new DeviceUdiComponent(); // cc
1185      return this.udi;
1186    }
1187
1188    public boolean hasUdi() { 
1189      return this.udi != null && !this.udi.isEmpty();
1190    }
1191
1192    /**
1193     * @param value {@link #udi} ([Unique device identifier (UDI)](device.html#5.11.3.2.2) assigned to device label or package.)
1194     */
1195    public Device setUdi(DeviceUdiComponent value)  { 
1196      this.udi = value;
1197      return this;
1198    }
1199
1200    /**
1201     * @return {@link #status} (Status of the Device availability.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1202     */
1203    public Enumeration<FHIRDeviceStatus> getStatusElement() { 
1204      if (this.status == null)
1205        if (Configuration.errorOnAutoCreate())
1206          throw new Error("Attempt to auto-create Device.status");
1207        else if (Configuration.doAutoCreate())
1208          this.status = new Enumeration<FHIRDeviceStatus>(new FHIRDeviceStatusEnumFactory()); // bb
1209      return this.status;
1210    }
1211
1212    public boolean hasStatusElement() { 
1213      return this.status != null && !this.status.isEmpty();
1214    }
1215
1216    public boolean hasStatus() { 
1217      return this.status != null && !this.status.isEmpty();
1218    }
1219
1220    /**
1221     * @param value {@link #status} (Status of the Device availability.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1222     */
1223    public Device setStatusElement(Enumeration<FHIRDeviceStatus> value) { 
1224      this.status = value;
1225      return this;
1226    }
1227
1228    /**
1229     * @return Status of the Device availability.
1230     */
1231    public FHIRDeviceStatus getStatus() { 
1232      return this.status == null ? null : this.status.getValue();
1233    }
1234
1235    /**
1236     * @param value Status of the Device availability.
1237     */
1238    public Device setStatus(FHIRDeviceStatus value) { 
1239      if (value == null)
1240        this.status = null;
1241      else {
1242        if (this.status == null)
1243          this.status = new Enumeration<FHIRDeviceStatus>(new FHIRDeviceStatusEnumFactory());
1244        this.status.setValue(value);
1245      }
1246      return this;
1247    }
1248
1249    /**
1250     * @return {@link #type} (Code or identifier to identify a kind of device.)
1251     */
1252    public CodeableConcept getType() { 
1253      if (this.type == null)
1254        if (Configuration.errorOnAutoCreate())
1255          throw new Error("Attempt to auto-create Device.type");
1256        else if (Configuration.doAutoCreate())
1257          this.type = new CodeableConcept(); // cc
1258      return this.type;
1259    }
1260
1261    public boolean hasType() { 
1262      return this.type != null && !this.type.isEmpty();
1263    }
1264
1265    /**
1266     * @param value {@link #type} (Code or identifier to identify a kind of device.)
1267     */
1268    public Device setType(CodeableConcept value)  { 
1269      this.type = value;
1270      return this;
1271    }
1272
1273    /**
1274     * @return {@link #lotNumber} (Lot number assigned by the manufacturer.). This is the underlying object with id, value and extensions. The accessor "getLotNumber" gives direct access to the value
1275     */
1276    public StringType getLotNumberElement() { 
1277      if (this.lotNumber == null)
1278        if (Configuration.errorOnAutoCreate())
1279          throw new Error("Attempt to auto-create Device.lotNumber");
1280        else if (Configuration.doAutoCreate())
1281          this.lotNumber = new StringType(); // bb
1282      return this.lotNumber;
1283    }
1284
1285    public boolean hasLotNumberElement() { 
1286      return this.lotNumber != null && !this.lotNumber.isEmpty();
1287    }
1288
1289    public boolean hasLotNumber() { 
1290      return this.lotNumber != null && !this.lotNumber.isEmpty();
1291    }
1292
1293    /**
1294     * @param value {@link #lotNumber} (Lot number assigned by the manufacturer.). This is the underlying object with id, value and extensions. The accessor "getLotNumber" gives direct access to the value
1295     */
1296    public Device setLotNumberElement(StringType value) { 
1297      this.lotNumber = value;
1298      return this;
1299    }
1300
1301    /**
1302     * @return Lot number assigned by the manufacturer.
1303     */
1304    public String getLotNumber() { 
1305      return this.lotNumber == null ? null : this.lotNumber.getValue();
1306    }
1307
1308    /**
1309     * @param value Lot number assigned by the manufacturer.
1310     */
1311    public Device setLotNumber(String value) { 
1312      if (Utilities.noString(value))
1313        this.lotNumber = null;
1314      else {
1315        if (this.lotNumber == null)
1316          this.lotNumber = new StringType();
1317        this.lotNumber.setValue(value);
1318      }
1319      return this;
1320    }
1321
1322    /**
1323     * @return {@link #manufacturer} (A name of the manufacturer.). This is the underlying object with id, value and extensions. The accessor "getManufacturer" gives direct access to the value
1324     */
1325    public StringType getManufacturerElement() { 
1326      if (this.manufacturer == null)
1327        if (Configuration.errorOnAutoCreate())
1328          throw new Error("Attempt to auto-create Device.manufacturer");
1329        else if (Configuration.doAutoCreate())
1330          this.manufacturer = new StringType(); // bb
1331      return this.manufacturer;
1332    }
1333
1334    public boolean hasManufacturerElement() { 
1335      return this.manufacturer != null && !this.manufacturer.isEmpty();
1336    }
1337
1338    public boolean hasManufacturer() { 
1339      return this.manufacturer != null && !this.manufacturer.isEmpty();
1340    }
1341
1342    /**
1343     * @param value {@link #manufacturer} (A name of the manufacturer.). This is the underlying object with id, value and extensions. The accessor "getManufacturer" gives direct access to the value
1344     */
1345    public Device setManufacturerElement(StringType value) { 
1346      this.manufacturer = value;
1347      return this;
1348    }
1349
1350    /**
1351     * @return A name of the manufacturer.
1352     */
1353    public String getManufacturer() { 
1354      return this.manufacturer == null ? null : this.manufacturer.getValue();
1355    }
1356
1357    /**
1358     * @param value A name of the manufacturer.
1359     */
1360    public Device setManufacturer(String value) { 
1361      if (Utilities.noString(value))
1362        this.manufacturer = null;
1363      else {
1364        if (this.manufacturer == null)
1365          this.manufacturer = new StringType();
1366        this.manufacturer.setValue(value);
1367      }
1368      return this;
1369    }
1370
1371    /**
1372     * @return {@link #manufactureDate} (The date and time when the device was manufactured.). This is the underlying object with id, value and extensions. The accessor "getManufactureDate" gives direct access to the value
1373     */
1374    public DateTimeType getManufactureDateElement() { 
1375      if (this.manufactureDate == null)
1376        if (Configuration.errorOnAutoCreate())
1377          throw new Error("Attempt to auto-create Device.manufactureDate");
1378        else if (Configuration.doAutoCreate())
1379          this.manufactureDate = new DateTimeType(); // bb
1380      return this.manufactureDate;
1381    }
1382
1383    public boolean hasManufactureDateElement() { 
1384      return this.manufactureDate != null && !this.manufactureDate.isEmpty();
1385    }
1386
1387    public boolean hasManufactureDate() { 
1388      return this.manufactureDate != null && !this.manufactureDate.isEmpty();
1389    }
1390
1391    /**
1392     * @param value {@link #manufactureDate} (The date and time when the device was manufactured.). This is the underlying object with id, value and extensions. The accessor "getManufactureDate" gives direct access to the value
1393     */
1394    public Device setManufactureDateElement(DateTimeType value) { 
1395      this.manufactureDate = value;
1396      return this;
1397    }
1398
1399    /**
1400     * @return The date and time when the device was manufactured.
1401     */
1402    public Date getManufactureDate() { 
1403      return this.manufactureDate == null ? null : this.manufactureDate.getValue();
1404    }
1405
1406    /**
1407     * @param value The date and time when the device was manufactured.
1408     */
1409    public Device setManufactureDate(Date value) { 
1410      if (value == null)
1411        this.manufactureDate = null;
1412      else {
1413        if (this.manufactureDate == null)
1414          this.manufactureDate = new DateTimeType();
1415        this.manufactureDate.setValue(value);
1416      }
1417      return this;
1418    }
1419
1420    /**
1421     * @return {@link #expirationDate} (The date and time beyond which this device is no longer valid or should not be used (if applicable).). This is the underlying object with id, value and extensions. The accessor "getExpirationDate" gives direct access to the value
1422     */
1423    public DateTimeType getExpirationDateElement() { 
1424      if (this.expirationDate == null)
1425        if (Configuration.errorOnAutoCreate())
1426          throw new Error("Attempt to auto-create Device.expirationDate");
1427        else if (Configuration.doAutoCreate())
1428          this.expirationDate = new DateTimeType(); // bb
1429      return this.expirationDate;
1430    }
1431
1432    public boolean hasExpirationDateElement() { 
1433      return this.expirationDate != null && !this.expirationDate.isEmpty();
1434    }
1435
1436    public boolean hasExpirationDate() { 
1437      return this.expirationDate != null && !this.expirationDate.isEmpty();
1438    }
1439
1440    /**
1441     * @param value {@link #expirationDate} (The date and time beyond which this device is no longer valid or should not be used (if applicable).). This is the underlying object with id, value and extensions. The accessor "getExpirationDate" gives direct access to the value
1442     */
1443    public Device setExpirationDateElement(DateTimeType value) { 
1444      this.expirationDate = value;
1445      return this;
1446    }
1447
1448    /**
1449     * @return The date and time beyond which this device is no longer valid or should not be used (if applicable).
1450     */
1451    public Date getExpirationDate() { 
1452      return this.expirationDate == null ? null : this.expirationDate.getValue();
1453    }
1454
1455    /**
1456     * @param value The date and time beyond which this device is no longer valid or should not be used (if applicable).
1457     */
1458    public Device setExpirationDate(Date value) { 
1459      if (value == null)
1460        this.expirationDate = null;
1461      else {
1462        if (this.expirationDate == null)
1463          this.expirationDate = new DateTimeType();
1464        this.expirationDate.setValue(value);
1465      }
1466      return this;
1467    }
1468
1469    /**
1470     * @return {@link #model} (The "model" is an identifier assigned by the manufacturer to identify the product by its type. This number is shared by the all devices sold as the same type.). This is the underlying object with id, value and extensions. The accessor "getModel" gives direct access to the value
1471     */
1472    public StringType getModelElement() { 
1473      if (this.model == null)
1474        if (Configuration.errorOnAutoCreate())
1475          throw new Error("Attempt to auto-create Device.model");
1476        else if (Configuration.doAutoCreate())
1477          this.model = new StringType(); // bb
1478      return this.model;
1479    }
1480
1481    public boolean hasModelElement() { 
1482      return this.model != null && !this.model.isEmpty();
1483    }
1484
1485    public boolean hasModel() { 
1486      return this.model != null && !this.model.isEmpty();
1487    }
1488
1489    /**
1490     * @param value {@link #model} (The "model" is an identifier assigned by the manufacturer to identify the product by its type. This number is shared by the all devices sold as the same type.). This is the underlying object with id, value and extensions. The accessor "getModel" gives direct access to the value
1491     */
1492    public Device setModelElement(StringType value) { 
1493      this.model = value;
1494      return this;
1495    }
1496
1497    /**
1498     * @return The "model" is an identifier assigned by the manufacturer to identify the product by its type. This number is shared by the all devices sold as the same type.
1499     */
1500    public String getModel() { 
1501      return this.model == null ? null : this.model.getValue();
1502    }
1503
1504    /**
1505     * @param value The "model" is an identifier assigned by the manufacturer to identify the product by its type. This number is shared by the all devices sold as the same type.
1506     */
1507    public Device setModel(String value) { 
1508      if (Utilities.noString(value))
1509        this.model = null;
1510      else {
1511        if (this.model == null)
1512          this.model = new StringType();
1513        this.model.setValue(value);
1514      }
1515      return this;
1516    }
1517
1518    /**
1519     * @return {@link #version} (The version of the device, if the device has multiple releases under the same model, or if the device is software or carries firmware.). This is the underlying object with id, value and extensions. The accessor "getVersion" gives direct access to the value
1520     */
1521    public StringType getVersionElement() { 
1522      if (this.version == null)
1523        if (Configuration.errorOnAutoCreate())
1524          throw new Error("Attempt to auto-create Device.version");
1525        else if (Configuration.doAutoCreate())
1526          this.version = new StringType(); // bb
1527      return this.version;
1528    }
1529
1530    public boolean hasVersionElement() { 
1531      return this.version != null && !this.version.isEmpty();
1532    }
1533
1534    public boolean hasVersion() { 
1535      return this.version != null && !this.version.isEmpty();
1536    }
1537
1538    /**
1539     * @param value {@link #version} (The version of the device, if the device has multiple releases under the same model, or if the device is software or carries firmware.). This is the underlying object with id, value and extensions. The accessor "getVersion" gives direct access to the value
1540     */
1541    public Device setVersionElement(StringType value) { 
1542      this.version = value;
1543      return this;
1544    }
1545
1546    /**
1547     * @return The version of the device, if the device has multiple releases under the same model, or if the device is software or carries firmware.
1548     */
1549    public String getVersion() { 
1550      return this.version == null ? null : this.version.getValue();
1551    }
1552
1553    /**
1554     * @param value The version of the device, if the device has multiple releases under the same model, or if the device is software or carries firmware.
1555     */
1556    public Device setVersion(String value) { 
1557      if (Utilities.noString(value))
1558        this.version = null;
1559      else {
1560        if (this.version == null)
1561          this.version = new StringType();
1562        this.version.setValue(value);
1563      }
1564      return this;
1565    }
1566
1567    /**
1568     * @return {@link #patient} (Patient information, If the device is affixed to a person.)
1569     */
1570    public Reference getPatient() { 
1571      if (this.patient == null)
1572        if (Configuration.errorOnAutoCreate())
1573          throw new Error("Attempt to auto-create Device.patient");
1574        else if (Configuration.doAutoCreate())
1575          this.patient = new Reference(); // cc
1576      return this.patient;
1577    }
1578
1579    public boolean hasPatient() { 
1580      return this.patient != null && !this.patient.isEmpty();
1581    }
1582
1583    /**
1584     * @param value {@link #patient} (Patient information, If the device is affixed to a person.)
1585     */
1586    public Device setPatient(Reference value)  { 
1587      this.patient = value;
1588      return this;
1589    }
1590
1591    /**
1592     * @return {@link #patient} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Patient information, If the device is affixed to a person.)
1593     */
1594    public Patient getPatientTarget() { 
1595      if (this.patientTarget == null)
1596        if (Configuration.errorOnAutoCreate())
1597          throw new Error("Attempt to auto-create Device.patient");
1598        else if (Configuration.doAutoCreate())
1599          this.patientTarget = new Patient(); // aa
1600      return this.patientTarget;
1601    }
1602
1603    /**
1604     * @param value {@link #patient} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Patient information, If the device is affixed to a person.)
1605     */
1606    public Device setPatientTarget(Patient value) { 
1607      this.patientTarget = value;
1608      return this;
1609    }
1610
1611    /**
1612     * @return {@link #owner} (An organization that is responsible for the provision and ongoing maintenance of the device.)
1613     */
1614    public Reference getOwner() { 
1615      if (this.owner == null)
1616        if (Configuration.errorOnAutoCreate())
1617          throw new Error("Attempt to auto-create Device.owner");
1618        else if (Configuration.doAutoCreate())
1619          this.owner = new Reference(); // cc
1620      return this.owner;
1621    }
1622
1623    public boolean hasOwner() { 
1624      return this.owner != null && !this.owner.isEmpty();
1625    }
1626
1627    /**
1628     * @param value {@link #owner} (An organization that is responsible for the provision and ongoing maintenance of the device.)
1629     */
1630    public Device setOwner(Reference value)  { 
1631      this.owner = value;
1632      return this;
1633    }
1634
1635    /**
1636     * @return {@link #owner} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (An organization that is responsible for the provision and ongoing maintenance of the device.)
1637     */
1638    public Organization getOwnerTarget() { 
1639      if (this.ownerTarget == null)
1640        if (Configuration.errorOnAutoCreate())
1641          throw new Error("Attempt to auto-create Device.owner");
1642        else if (Configuration.doAutoCreate())
1643          this.ownerTarget = new Organization(); // aa
1644      return this.ownerTarget;
1645    }
1646
1647    /**
1648     * @param value {@link #owner} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (An organization that is responsible for the provision and ongoing maintenance of the device.)
1649     */
1650    public Device setOwnerTarget(Organization value) { 
1651      this.ownerTarget = value;
1652      return this;
1653    }
1654
1655    /**
1656     * @return {@link #contact} (Contact details for an organization or a particular human that is responsible for the device.)
1657     */
1658    public List<ContactPoint> getContact() { 
1659      if (this.contact == null)
1660        this.contact = new ArrayList<ContactPoint>();
1661      return this.contact;
1662    }
1663
1664    /**
1665     * @return Returns a reference to <code>this</code> for easy method chaining
1666     */
1667    public Device setContact(List<ContactPoint> theContact) { 
1668      this.contact = theContact;
1669      return this;
1670    }
1671
1672    public boolean hasContact() { 
1673      if (this.contact == null)
1674        return false;
1675      for (ContactPoint item : this.contact)
1676        if (!item.isEmpty())
1677          return true;
1678      return false;
1679    }
1680
1681    public ContactPoint addContact() { //3
1682      ContactPoint t = new ContactPoint();
1683      if (this.contact == null)
1684        this.contact = new ArrayList<ContactPoint>();
1685      this.contact.add(t);
1686      return t;
1687    }
1688
1689    public Device addContact(ContactPoint t) { //3
1690      if (t == null)
1691        return this;
1692      if (this.contact == null)
1693        this.contact = new ArrayList<ContactPoint>();
1694      this.contact.add(t);
1695      return this;
1696    }
1697
1698    /**
1699     * @return The first repetition of repeating field {@link #contact}, creating it if it does not already exist
1700     */
1701    public ContactPoint getContactFirstRep() { 
1702      if (getContact().isEmpty()) {
1703        addContact();
1704      }
1705      return getContact().get(0);
1706    }
1707
1708    /**
1709     * @return {@link #location} (The place where the device can be found.)
1710     */
1711    public Reference getLocation() { 
1712      if (this.location == null)
1713        if (Configuration.errorOnAutoCreate())
1714          throw new Error("Attempt to auto-create Device.location");
1715        else if (Configuration.doAutoCreate())
1716          this.location = new Reference(); // cc
1717      return this.location;
1718    }
1719
1720    public boolean hasLocation() { 
1721      return this.location != null && !this.location.isEmpty();
1722    }
1723
1724    /**
1725     * @param value {@link #location} (The place where the device can be found.)
1726     */
1727    public Device setLocation(Reference value)  { 
1728      this.location = value;
1729      return this;
1730    }
1731
1732    /**
1733     * @return {@link #location} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The place where the device can be found.)
1734     */
1735    public Location getLocationTarget() { 
1736      if (this.locationTarget == null)
1737        if (Configuration.errorOnAutoCreate())
1738          throw new Error("Attempt to auto-create Device.location");
1739        else if (Configuration.doAutoCreate())
1740          this.locationTarget = new Location(); // aa
1741      return this.locationTarget;
1742    }
1743
1744    /**
1745     * @param value {@link #location} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The place where the device can be found.)
1746     */
1747    public Device setLocationTarget(Location value) { 
1748      this.locationTarget = value;
1749      return this;
1750    }
1751
1752    /**
1753     * @return {@link #url} (A network address on which the device may be contacted directly.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value
1754     */
1755    public UriType getUrlElement() { 
1756      if (this.url == null)
1757        if (Configuration.errorOnAutoCreate())
1758          throw new Error("Attempt to auto-create Device.url");
1759        else if (Configuration.doAutoCreate())
1760          this.url = new UriType(); // bb
1761      return this.url;
1762    }
1763
1764    public boolean hasUrlElement() { 
1765      return this.url != null && !this.url.isEmpty();
1766    }
1767
1768    public boolean hasUrl() { 
1769      return this.url != null && !this.url.isEmpty();
1770    }
1771
1772    /**
1773     * @param value {@link #url} (A network address on which the device may be contacted directly.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value
1774     */
1775    public Device setUrlElement(UriType value) { 
1776      this.url = value;
1777      return this;
1778    }
1779
1780    /**
1781     * @return A network address on which the device may be contacted directly.
1782     */
1783    public String getUrl() { 
1784      return this.url == null ? null : this.url.getValue();
1785    }
1786
1787    /**
1788     * @param value A network address on which the device may be contacted directly.
1789     */
1790    public Device setUrl(String value) { 
1791      if (Utilities.noString(value))
1792        this.url = null;
1793      else {
1794        if (this.url == null)
1795          this.url = new UriType();
1796        this.url.setValue(value);
1797      }
1798      return this;
1799    }
1800
1801    /**
1802     * @return {@link #note} (Descriptive information, usage information or implantation information that is not captured in an existing element.)
1803     */
1804    public List<Annotation> getNote() { 
1805      if (this.note == null)
1806        this.note = new ArrayList<Annotation>();
1807      return this.note;
1808    }
1809
1810    /**
1811     * @return Returns a reference to <code>this</code> for easy method chaining
1812     */
1813    public Device setNote(List<Annotation> theNote) { 
1814      this.note = theNote;
1815      return this;
1816    }
1817
1818    public boolean hasNote() { 
1819      if (this.note == null)
1820        return false;
1821      for (Annotation item : this.note)
1822        if (!item.isEmpty())
1823          return true;
1824      return false;
1825    }
1826
1827    public Annotation addNote() { //3
1828      Annotation t = new Annotation();
1829      if (this.note == null)
1830        this.note = new ArrayList<Annotation>();
1831      this.note.add(t);
1832      return t;
1833    }
1834
1835    public Device addNote(Annotation t) { //3
1836      if (t == null)
1837        return this;
1838      if (this.note == null)
1839        this.note = new ArrayList<Annotation>();
1840      this.note.add(t);
1841      return this;
1842    }
1843
1844    /**
1845     * @return The first repetition of repeating field {@link #note}, creating it if it does not already exist
1846     */
1847    public Annotation getNoteFirstRep() { 
1848      if (getNote().isEmpty()) {
1849        addNote();
1850      }
1851      return getNote().get(0);
1852    }
1853
1854    /**
1855     * @return {@link #safety} (Provides additional safety characteristics about a medical device.  For example devices containing latex.)
1856     */
1857    public List<CodeableConcept> getSafety() { 
1858      if (this.safety == null)
1859        this.safety = new ArrayList<CodeableConcept>();
1860      return this.safety;
1861    }
1862
1863    /**
1864     * @return Returns a reference to <code>this</code> for easy method chaining
1865     */
1866    public Device setSafety(List<CodeableConcept> theSafety) { 
1867      this.safety = theSafety;
1868      return this;
1869    }
1870
1871    public boolean hasSafety() { 
1872      if (this.safety == null)
1873        return false;
1874      for (CodeableConcept item : this.safety)
1875        if (!item.isEmpty())
1876          return true;
1877      return false;
1878    }
1879
1880    public CodeableConcept addSafety() { //3
1881      CodeableConcept t = new CodeableConcept();
1882      if (this.safety == null)
1883        this.safety = new ArrayList<CodeableConcept>();
1884      this.safety.add(t);
1885      return t;
1886    }
1887
1888    public Device addSafety(CodeableConcept t) { //3
1889      if (t == null)
1890        return this;
1891      if (this.safety == null)
1892        this.safety = new ArrayList<CodeableConcept>();
1893      this.safety.add(t);
1894      return this;
1895    }
1896
1897    /**
1898     * @return The first repetition of repeating field {@link #safety}, creating it if it does not already exist
1899     */
1900    public CodeableConcept getSafetyFirstRep() { 
1901      if (getSafety().isEmpty()) {
1902        addSafety();
1903      }
1904      return getSafety().get(0);
1905    }
1906
1907      protected void listChildren(List<Property> children) {
1908        super.listChildren(children);
1909        children.add(new Property("identifier", "Identifier", "Unique instance identifiers assigned to a device by manufacturers other organizations or owners.", 0, java.lang.Integer.MAX_VALUE, identifier));
1910        children.add(new Property("udi", "", "[Unique device identifier (UDI)](device.html#5.11.3.2.2) assigned to device label or package.", 0, 1, udi));
1911        children.add(new Property("status", "code", "Status of the Device availability.", 0, 1, status));
1912        children.add(new Property("type", "CodeableConcept", "Code or identifier to identify a kind of device.", 0, 1, type));
1913        children.add(new Property("lotNumber", "string", "Lot number assigned by the manufacturer.", 0, 1, lotNumber));
1914        children.add(new Property("manufacturer", "string", "A name of the manufacturer.", 0, 1, manufacturer));
1915        children.add(new Property("manufactureDate", "dateTime", "The date and time when the device was manufactured.", 0, 1, manufactureDate));
1916        children.add(new Property("expirationDate", "dateTime", "The date and time beyond which this device is no longer valid or should not be used (if applicable).", 0, 1, expirationDate));
1917        children.add(new Property("model", "string", "The \"model\" is an identifier assigned by the manufacturer to identify the product by its type. This number is shared by the all devices sold as the same type.", 0, 1, model));
1918        children.add(new Property("version", "string", "The version of the device, if the device has multiple releases under the same model, or if the device is software or carries firmware.", 0, 1, version));
1919        children.add(new Property("patient", "Reference(Patient)", "Patient information, If the device is affixed to a person.", 0, 1, patient));
1920        children.add(new Property("owner", "Reference(Organization)", "An organization that is responsible for the provision and ongoing maintenance of the device.", 0, 1, owner));
1921        children.add(new Property("contact", "ContactPoint", "Contact details for an organization or a particular human that is responsible for the device.", 0, java.lang.Integer.MAX_VALUE, contact));
1922        children.add(new Property("location", "Reference(Location)", "The place where the device can be found.", 0, 1, location));
1923        children.add(new Property("url", "uri", "A network address on which the device may be contacted directly.", 0, 1, url));
1924        children.add(new Property("note", "Annotation", "Descriptive information, usage information or implantation information that is not captured in an existing element.", 0, java.lang.Integer.MAX_VALUE, note));
1925        children.add(new Property("safety", "CodeableConcept", "Provides additional safety characteristics about a medical device.  For example devices containing latex.", 0, java.lang.Integer.MAX_VALUE, safety));
1926      }
1927
1928      @Override
1929      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1930        switch (_hash) {
1931        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Unique instance identifiers assigned to a device by manufacturers other organizations or owners.", 0, java.lang.Integer.MAX_VALUE, identifier);
1932        case 115642: /*udi*/  return new Property("udi", "", "[Unique device identifier (UDI)](device.html#5.11.3.2.2) assigned to device label or package.", 0, 1, udi);
1933        case -892481550: /*status*/  return new Property("status", "code", "Status of the Device availability.", 0, 1, status);
1934        case 3575610: /*type*/  return new Property("type", "CodeableConcept", "Code or identifier to identify a kind of device.", 0, 1, type);
1935        case 462547450: /*lotNumber*/  return new Property("lotNumber", "string", "Lot number assigned by the manufacturer.", 0, 1, lotNumber);
1936        case -1969347631: /*manufacturer*/  return new Property("manufacturer", "string", "A name of the manufacturer.", 0, 1, manufacturer);
1937        case 416714767: /*manufactureDate*/  return new Property("manufactureDate", "dateTime", "The date and time when the device was manufactured.", 0, 1, manufactureDate);
1938        case -668811523: /*expirationDate*/  return new Property("expirationDate", "dateTime", "The date and time beyond which this device is no longer valid or should not be used (if applicable).", 0, 1, expirationDate);
1939        case 104069929: /*model*/  return new Property("model", "string", "The \"model\" is an identifier assigned by the manufacturer to identify the product by its type. This number is shared by the all devices sold as the same type.", 0, 1, model);
1940        case 351608024: /*version*/  return new Property("version", "string", "The version of the device, if the device has multiple releases under the same model, or if the device is software or carries firmware.", 0, 1, version);
1941        case -791418107: /*patient*/  return new Property("patient", "Reference(Patient)", "Patient information, If the device is affixed to a person.", 0, 1, patient);
1942        case 106164915: /*owner*/  return new Property("owner", "Reference(Organization)", "An organization that is responsible for the provision and ongoing maintenance of the device.", 0, 1, owner);
1943        case 951526432: /*contact*/  return new Property("contact", "ContactPoint", "Contact details for an organization or a particular human that is responsible for the device.", 0, java.lang.Integer.MAX_VALUE, contact);
1944        case 1901043637: /*location*/  return new Property("location", "Reference(Location)", "The place where the device can be found.", 0, 1, location);
1945        case 116079: /*url*/  return new Property("url", "uri", "A network address on which the device may be contacted directly.", 0, 1, url);
1946        case 3387378: /*note*/  return new Property("note", "Annotation", "Descriptive information, usage information or implantation information that is not captured in an existing element.", 0, java.lang.Integer.MAX_VALUE, note);
1947        case -909893934: /*safety*/  return new Property("safety", "CodeableConcept", "Provides additional safety characteristics about a medical device.  For example devices containing latex.", 0, java.lang.Integer.MAX_VALUE, safety);
1948        default: return super.getNamedProperty(_hash, _name, _checkValid);
1949        }
1950
1951      }
1952
1953      @Override
1954      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1955        switch (hash) {
1956        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1957        case 115642: /*udi*/ return this.udi == null ? new Base[0] : new Base[] {this.udi}; // DeviceUdiComponent
1958        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<FHIRDeviceStatus>
1959        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
1960        case 462547450: /*lotNumber*/ return this.lotNumber == null ? new Base[0] : new Base[] {this.lotNumber}; // StringType
1961        case -1969347631: /*manufacturer*/ return this.manufacturer == null ? new Base[0] : new Base[] {this.manufacturer}; // StringType
1962        case 416714767: /*manufactureDate*/ return this.manufactureDate == null ? new Base[0] : new Base[] {this.manufactureDate}; // DateTimeType
1963        case -668811523: /*expirationDate*/ return this.expirationDate == null ? new Base[0] : new Base[] {this.expirationDate}; // DateTimeType
1964        case 104069929: /*model*/ return this.model == null ? new Base[0] : new Base[] {this.model}; // StringType
1965        case 351608024: /*version*/ return this.version == null ? new Base[0] : new Base[] {this.version}; // StringType
1966        case -791418107: /*patient*/ return this.patient == null ? new Base[0] : new Base[] {this.patient}; // Reference
1967        case 106164915: /*owner*/ return this.owner == null ? new Base[0] : new Base[] {this.owner}; // Reference
1968        case 951526432: /*contact*/ return this.contact == null ? new Base[0] : this.contact.toArray(new Base[this.contact.size()]); // ContactPoint
1969        case 1901043637: /*location*/ return this.location == null ? new Base[0] : new Base[] {this.location}; // Reference
1970        case 116079: /*url*/ return this.url == null ? new Base[0] : new Base[] {this.url}; // UriType
1971        case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
1972        case -909893934: /*safety*/ return this.safety == null ? new Base[0] : this.safety.toArray(new Base[this.safety.size()]); // CodeableConcept
1973        default: return super.getProperty(hash, name, checkValid);
1974        }
1975
1976      }
1977
1978      @Override
1979      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1980        switch (hash) {
1981        case -1618432855: // identifier
1982          this.getIdentifier().add(castToIdentifier(value)); // Identifier
1983          return value;
1984        case 115642: // udi
1985          this.udi = (DeviceUdiComponent) value; // DeviceUdiComponent
1986          return value;
1987        case -892481550: // status
1988          value = new FHIRDeviceStatusEnumFactory().fromType(castToCode(value));
1989          this.status = (Enumeration) value; // Enumeration<FHIRDeviceStatus>
1990          return value;
1991        case 3575610: // type
1992          this.type = castToCodeableConcept(value); // CodeableConcept
1993          return value;
1994        case 462547450: // lotNumber
1995          this.lotNumber = castToString(value); // StringType
1996          return value;
1997        case -1969347631: // manufacturer
1998          this.manufacturer = castToString(value); // StringType
1999          return value;
2000        case 416714767: // manufactureDate
2001          this.manufactureDate = castToDateTime(value); // DateTimeType
2002          return value;
2003        case -668811523: // expirationDate
2004          this.expirationDate = castToDateTime(value); // DateTimeType
2005          return value;
2006        case 104069929: // model
2007          this.model = castToString(value); // StringType
2008          return value;
2009        case 351608024: // version
2010          this.version = castToString(value); // StringType
2011          return value;
2012        case -791418107: // patient
2013          this.patient = castToReference(value); // Reference
2014          return value;
2015        case 106164915: // owner
2016          this.owner = castToReference(value); // Reference
2017          return value;
2018        case 951526432: // contact
2019          this.getContact().add(castToContactPoint(value)); // ContactPoint
2020          return value;
2021        case 1901043637: // location
2022          this.location = castToReference(value); // Reference
2023          return value;
2024        case 116079: // url
2025          this.url = castToUri(value); // UriType
2026          return value;
2027        case 3387378: // note
2028          this.getNote().add(castToAnnotation(value)); // Annotation
2029          return value;
2030        case -909893934: // safety
2031          this.getSafety().add(castToCodeableConcept(value)); // CodeableConcept
2032          return value;
2033        default: return super.setProperty(hash, name, value);
2034        }
2035
2036      }
2037
2038      @Override
2039      public Base setProperty(String name, Base value) throws FHIRException {
2040        if (name.equals("identifier")) {
2041          this.getIdentifier().add(castToIdentifier(value));
2042        } else if (name.equals("udi")) {
2043          this.udi = (DeviceUdiComponent) value; // DeviceUdiComponent
2044        } else if (name.equals("status")) {
2045          value = new FHIRDeviceStatusEnumFactory().fromType(castToCode(value));
2046          this.status = (Enumeration) value; // Enumeration<FHIRDeviceStatus>
2047        } else if (name.equals("type")) {
2048          this.type = castToCodeableConcept(value); // CodeableConcept
2049        } else if (name.equals("lotNumber")) {
2050          this.lotNumber = castToString(value); // StringType
2051        } else if (name.equals("manufacturer")) {
2052          this.manufacturer = castToString(value); // StringType
2053        } else if (name.equals("manufactureDate")) {
2054          this.manufactureDate = castToDateTime(value); // DateTimeType
2055        } else if (name.equals("expirationDate")) {
2056          this.expirationDate = castToDateTime(value); // DateTimeType
2057        } else if (name.equals("model")) {
2058          this.model = castToString(value); // StringType
2059        } else if (name.equals("version")) {
2060          this.version = castToString(value); // StringType
2061        } else if (name.equals("patient")) {
2062          this.patient = castToReference(value); // Reference
2063        } else if (name.equals("owner")) {
2064          this.owner = castToReference(value); // Reference
2065        } else if (name.equals("contact")) {
2066          this.getContact().add(castToContactPoint(value));
2067        } else if (name.equals("location")) {
2068          this.location = castToReference(value); // Reference
2069        } else if (name.equals("url")) {
2070          this.url = castToUri(value); // UriType
2071        } else if (name.equals("note")) {
2072          this.getNote().add(castToAnnotation(value));
2073        } else if (name.equals("safety")) {
2074          this.getSafety().add(castToCodeableConcept(value));
2075        } else
2076          return super.setProperty(name, value);
2077        return value;
2078      }
2079
2080      @Override
2081      public Base makeProperty(int hash, String name) throws FHIRException {
2082        switch (hash) {
2083        case -1618432855:  return addIdentifier(); 
2084        case 115642:  return getUdi(); 
2085        case -892481550:  return getStatusElement();
2086        case 3575610:  return getType(); 
2087        case 462547450:  return getLotNumberElement();
2088        case -1969347631:  return getManufacturerElement();
2089        case 416714767:  return getManufactureDateElement();
2090        case -668811523:  return getExpirationDateElement();
2091        case 104069929:  return getModelElement();
2092        case 351608024:  return getVersionElement();
2093        case -791418107:  return getPatient(); 
2094        case 106164915:  return getOwner(); 
2095        case 951526432:  return addContact(); 
2096        case 1901043637:  return getLocation(); 
2097        case 116079:  return getUrlElement();
2098        case 3387378:  return addNote(); 
2099        case -909893934:  return addSafety(); 
2100        default: return super.makeProperty(hash, name);
2101        }
2102
2103      }
2104
2105      @Override
2106      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2107        switch (hash) {
2108        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
2109        case 115642: /*udi*/ return new String[] {};
2110        case -892481550: /*status*/ return new String[] {"code"};
2111        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
2112        case 462547450: /*lotNumber*/ return new String[] {"string"};
2113        case -1969347631: /*manufacturer*/ return new String[] {"string"};
2114        case 416714767: /*manufactureDate*/ return new String[] {"dateTime"};
2115        case -668811523: /*expirationDate*/ return new String[] {"dateTime"};
2116        case 104069929: /*model*/ return new String[] {"string"};
2117        case 351608024: /*version*/ return new String[] {"string"};
2118        case -791418107: /*patient*/ return new String[] {"Reference"};
2119        case 106164915: /*owner*/ return new String[] {"Reference"};
2120        case 951526432: /*contact*/ return new String[] {"ContactPoint"};
2121        case 1901043637: /*location*/ return new String[] {"Reference"};
2122        case 116079: /*url*/ return new String[] {"uri"};
2123        case 3387378: /*note*/ return new String[] {"Annotation"};
2124        case -909893934: /*safety*/ return new String[] {"CodeableConcept"};
2125        default: return super.getTypesForProperty(hash, name);
2126        }
2127
2128      }
2129
2130      @Override
2131      public Base addChild(String name) throws FHIRException {
2132        if (name.equals("identifier")) {
2133          return addIdentifier();
2134        }
2135        else if (name.equals("udi")) {
2136          this.udi = new DeviceUdiComponent();
2137          return this.udi;
2138        }
2139        else if (name.equals("status")) {
2140          throw new FHIRException("Cannot call addChild on a primitive type Device.status");
2141        }
2142        else if (name.equals("type")) {
2143          this.type = new CodeableConcept();
2144          return this.type;
2145        }
2146        else if (name.equals("lotNumber")) {
2147          throw new FHIRException("Cannot call addChild on a primitive type Device.lotNumber");
2148        }
2149        else if (name.equals("manufacturer")) {
2150          throw new FHIRException("Cannot call addChild on a primitive type Device.manufacturer");
2151        }
2152        else if (name.equals("manufactureDate")) {
2153          throw new FHIRException("Cannot call addChild on a primitive type Device.manufactureDate");
2154        }
2155        else if (name.equals("expirationDate")) {
2156          throw new FHIRException("Cannot call addChild on a primitive type Device.expirationDate");
2157        }
2158        else if (name.equals("model")) {
2159          throw new FHIRException("Cannot call addChild on a primitive type Device.model");
2160        }
2161        else if (name.equals("version")) {
2162          throw new FHIRException("Cannot call addChild on a primitive type Device.version");
2163        }
2164        else if (name.equals("patient")) {
2165          this.patient = new Reference();
2166          return this.patient;
2167        }
2168        else if (name.equals("owner")) {
2169          this.owner = new Reference();
2170          return this.owner;
2171        }
2172        else if (name.equals("contact")) {
2173          return addContact();
2174        }
2175        else if (name.equals("location")) {
2176          this.location = new Reference();
2177          return this.location;
2178        }
2179        else if (name.equals("url")) {
2180          throw new FHIRException("Cannot call addChild on a primitive type Device.url");
2181        }
2182        else if (name.equals("note")) {
2183          return addNote();
2184        }
2185        else if (name.equals("safety")) {
2186          return addSafety();
2187        }
2188        else
2189          return super.addChild(name);
2190      }
2191
2192  public String fhirType() {
2193    return "Device";
2194
2195  }
2196
2197      public Device copy() {
2198        Device dst = new Device();
2199        copyValues(dst);
2200        if (identifier != null) {
2201          dst.identifier = new ArrayList<Identifier>();
2202          for (Identifier i : identifier)
2203            dst.identifier.add(i.copy());
2204        };
2205        dst.udi = udi == null ? null : udi.copy();
2206        dst.status = status == null ? null : status.copy();
2207        dst.type = type == null ? null : type.copy();
2208        dst.lotNumber = lotNumber == null ? null : lotNumber.copy();
2209        dst.manufacturer = manufacturer == null ? null : manufacturer.copy();
2210        dst.manufactureDate = manufactureDate == null ? null : manufactureDate.copy();
2211        dst.expirationDate = expirationDate == null ? null : expirationDate.copy();
2212        dst.model = model == null ? null : model.copy();
2213        dst.version = version == null ? null : version.copy();
2214        dst.patient = patient == null ? null : patient.copy();
2215        dst.owner = owner == null ? null : owner.copy();
2216        if (contact != null) {
2217          dst.contact = new ArrayList<ContactPoint>();
2218          for (ContactPoint i : contact)
2219            dst.contact.add(i.copy());
2220        };
2221        dst.location = location == null ? null : location.copy();
2222        dst.url = url == null ? null : url.copy();
2223        if (note != null) {
2224          dst.note = new ArrayList<Annotation>();
2225          for (Annotation i : note)
2226            dst.note.add(i.copy());
2227        };
2228        if (safety != null) {
2229          dst.safety = new ArrayList<CodeableConcept>();
2230          for (CodeableConcept i : safety)
2231            dst.safety.add(i.copy());
2232        };
2233        return dst;
2234      }
2235
2236      protected Device typedCopy() {
2237        return copy();
2238      }
2239
2240      @Override
2241      public boolean equalsDeep(Base other_) {
2242        if (!super.equalsDeep(other_))
2243          return false;
2244        if (!(other_ instanceof Device))
2245          return false;
2246        Device o = (Device) other_;
2247        return compareDeep(identifier, o.identifier, true) && compareDeep(udi, o.udi, true) && compareDeep(status, o.status, true)
2248           && compareDeep(type, o.type, true) && compareDeep(lotNumber, o.lotNumber, true) && compareDeep(manufacturer, o.manufacturer, true)
2249           && compareDeep(manufactureDate, o.manufactureDate, true) && compareDeep(expirationDate, o.expirationDate, true)
2250           && compareDeep(model, o.model, true) && compareDeep(version, o.version, true) && compareDeep(patient, o.patient, true)
2251           && compareDeep(owner, o.owner, true) && compareDeep(contact, o.contact, true) && compareDeep(location, o.location, true)
2252           && compareDeep(url, o.url, true) && compareDeep(note, o.note, true) && compareDeep(safety, o.safety, true)
2253          ;
2254      }
2255
2256      @Override
2257      public boolean equalsShallow(Base other_) {
2258        if (!super.equalsShallow(other_))
2259          return false;
2260        if (!(other_ instanceof Device))
2261          return false;
2262        Device o = (Device) other_;
2263        return compareValues(status, o.status, true) && compareValues(lotNumber, o.lotNumber, true) && compareValues(manufacturer, o.manufacturer, true)
2264           && compareValues(manufactureDate, o.manufactureDate, true) && compareValues(expirationDate, o.expirationDate, true)
2265           && compareValues(model, o.model, true) && compareValues(version, o.version, true) && compareValues(url, o.url, true)
2266          ;
2267      }
2268
2269      public boolean isEmpty() {
2270        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, udi, status
2271          , type, lotNumber, manufacturer, manufactureDate, expirationDate, model, version
2272          , patient, owner, contact, location, url, note, safety);
2273      }
2274
2275  @Override
2276  public ResourceType getResourceType() {
2277    return ResourceType.Device;
2278   }
2279
2280 /**
2281   * Search parameter: <b>udi-di</b>
2282   * <p>
2283   * Description: <b>The udi Device Identifier (DI)</b><br>
2284   * Type: <b>string</b><br>
2285   * Path: <b>Device.udi.deviceIdentifier</b><br>
2286   * </p>
2287   */
2288  @SearchParamDefinition(name="udi-di", path="Device.udi.deviceIdentifier", description="The udi Device Identifier (DI)", type="string" )
2289  public static final String SP_UDI_DI = "udi-di";
2290 /**
2291   * <b>Fluent Client</b> search parameter constant for <b>udi-di</b>
2292   * <p>
2293   * Description: <b>The udi Device Identifier (DI)</b><br>
2294   * Type: <b>string</b><br>
2295   * Path: <b>Device.udi.deviceIdentifier</b><br>
2296   * </p>
2297   */
2298  public static final ca.uhn.fhir.rest.gclient.StringClientParam UDI_DI = new ca.uhn.fhir.rest.gclient.StringClientParam(SP_UDI_DI);
2299
2300 /**
2301   * Search parameter: <b>identifier</b>
2302   * <p>
2303   * Description: <b>Instance id from manufacturer, owner, and others</b><br>
2304   * Type: <b>token</b><br>
2305   * Path: <b>Device.identifier</b><br>
2306   * </p>
2307   */
2308  @SearchParamDefinition(name="identifier", path="Device.identifier", description="Instance id from manufacturer, owner, and others", type="token" )
2309  public static final String SP_IDENTIFIER = "identifier";
2310 /**
2311   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
2312   * <p>
2313   * Description: <b>Instance id from manufacturer, owner, and others</b><br>
2314   * Type: <b>token</b><br>
2315   * Path: <b>Device.identifier</b><br>
2316   * </p>
2317   */
2318  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
2319
2320 /**
2321   * Search parameter: <b>udi-carrier</b>
2322   * <p>
2323   * Description: <b>UDI Barcode (RFID or other technology) string either in HRF format or AIDC format converted to base64 string.</b><br>
2324   * Type: <b>string</b><br>
2325   * Path: <b>Device.udi.carrierHRF, Device.udi.carrierAIDC</b><br>
2326   * </p>
2327   */
2328  @SearchParamDefinition(name="udi-carrier", path="Device.udi.carrierHRF | Device.udi.carrierAIDC", description="UDI Barcode (RFID or other technology) string either in HRF format or AIDC format converted to base64 string.", type="string" )
2329  public static final String SP_UDI_CARRIER = "udi-carrier";
2330 /**
2331   * <b>Fluent Client</b> search parameter constant for <b>udi-carrier</b>
2332   * <p>
2333   * Description: <b>UDI Barcode (RFID or other technology) string either in HRF format or AIDC format converted to base64 string.</b><br>
2334   * Type: <b>string</b><br>
2335   * Path: <b>Device.udi.carrierHRF, Device.udi.carrierAIDC</b><br>
2336   * </p>
2337   */
2338  public static final ca.uhn.fhir.rest.gclient.StringClientParam UDI_CARRIER = new ca.uhn.fhir.rest.gclient.StringClientParam(SP_UDI_CARRIER);
2339
2340 /**
2341   * Search parameter: <b>device-name</b>
2342   * <p>
2343   * Description: <b>A server defined search that may match any of the string fields in the Device.udi.name  or Device.type.coding.display or  Device.type.text</b><br>
2344   * Type: <b>string</b><br>
2345   * Path: <b>Device.udi.name, Device.type.text, Device.type.coding.display</b><br>
2346   * </p>
2347   */
2348  @SearchParamDefinition(name="device-name", path="Device.udi.name | Device.type.text | Device.type.coding.display", description="A server defined search that may match any of the string fields in the Device.udi.name  or Device.type.coding.display or  Device.type.text", type="string" )
2349  public static final String SP_DEVICE_NAME = "device-name";
2350 /**
2351   * <b>Fluent Client</b> search parameter constant for <b>device-name</b>
2352   * <p>
2353   * Description: <b>A server defined search that may match any of the string fields in the Device.udi.name  or Device.type.coding.display or  Device.type.text</b><br>
2354   * Type: <b>string</b><br>
2355   * Path: <b>Device.udi.name, Device.type.text, Device.type.coding.display</b><br>
2356   * </p>
2357   */
2358  public static final ca.uhn.fhir.rest.gclient.StringClientParam DEVICE_NAME = new ca.uhn.fhir.rest.gclient.StringClientParam(SP_DEVICE_NAME);
2359
2360 /**
2361   * Search parameter: <b>patient</b>
2362   * <p>
2363   * Description: <b>Patient information, if the resource is affixed to a person</b><br>
2364   * Type: <b>reference</b><br>
2365   * Path: <b>Device.patient</b><br>
2366   * </p>
2367   */
2368  @SearchParamDefinition(name="patient", path="Device.patient", description="Patient information, if the resource is affixed to a person", type="reference", target={Patient.class } )
2369  public static final String SP_PATIENT = "patient";
2370 /**
2371   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
2372   * <p>
2373   * Description: <b>Patient information, if the resource is affixed to a person</b><br>
2374   * Type: <b>reference</b><br>
2375   * Path: <b>Device.patient</b><br>
2376   * </p>
2377   */
2378  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
2379
2380/**
2381   * Constant for fluent queries to be used to add include statements. Specifies
2382   * the path value of "<b>Device:patient</b>".
2383   */
2384  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("Device:patient").toLocked();
2385
2386 /**
2387   * Search parameter: <b>organization</b>
2388   * <p>
2389   * Description: <b>The organization responsible for the device</b><br>
2390   * Type: <b>reference</b><br>
2391   * Path: <b>Device.owner</b><br>
2392   * </p>
2393   */
2394  @SearchParamDefinition(name="organization", path="Device.owner", description="The organization responsible for the device", type="reference", target={Organization.class } )
2395  public static final String SP_ORGANIZATION = "organization";
2396 /**
2397   * <b>Fluent Client</b> search parameter constant for <b>organization</b>
2398   * <p>
2399   * Description: <b>The organization responsible for the device</b><br>
2400   * Type: <b>reference</b><br>
2401   * Path: <b>Device.owner</b><br>
2402   * </p>
2403   */
2404  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ORGANIZATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ORGANIZATION);
2405
2406/**
2407   * Constant for fluent queries to be used to add include statements. Specifies
2408   * the path value of "<b>Device:organization</b>".
2409   */
2410  public static final ca.uhn.fhir.model.api.Include INCLUDE_ORGANIZATION = new ca.uhn.fhir.model.api.Include("Device:organization").toLocked();
2411
2412 /**
2413   * Search parameter: <b>model</b>
2414   * <p>
2415   * Description: <b>The model of the device</b><br>
2416   * Type: <b>string</b><br>
2417   * Path: <b>Device.model</b><br>
2418   * </p>
2419   */
2420  @SearchParamDefinition(name="model", path="Device.model", description="The model of the device", type="string" )
2421  public static final String SP_MODEL = "model";
2422 /**
2423   * <b>Fluent Client</b> search parameter constant for <b>model</b>
2424   * <p>
2425   * Description: <b>The model of the device</b><br>
2426   * Type: <b>string</b><br>
2427   * Path: <b>Device.model</b><br>
2428   * </p>
2429   */
2430  public static final ca.uhn.fhir.rest.gclient.StringClientParam MODEL = new ca.uhn.fhir.rest.gclient.StringClientParam(SP_MODEL);
2431
2432 /**
2433   * Search parameter: <b>location</b>
2434   * <p>
2435   * Description: <b>A location, where the resource is found</b><br>
2436   * Type: <b>reference</b><br>
2437   * Path: <b>Device.location</b><br>
2438   * </p>
2439   */
2440  @SearchParamDefinition(name="location", path="Device.location", description="A location, where the resource is found", type="reference", target={Location.class } )
2441  public static final String SP_LOCATION = "location";
2442 /**
2443   * <b>Fluent Client</b> search parameter constant for <b>location</b>
2444   * <p>
2445   * Description: <b>A location, where the resource is found</b><br>
2446   * Type: <b>reference</b><br>
2447   * Path: <b>Device.location</b><br>
2448   * </p>
2449   */
2450  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam LOCATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_LOCATION);
2451
2452/**
2453   * Constant for fluent queries to be used to add include statements. Specifies
2454   * the path value of "<b>Device:location</b>".
2455   */
2456  public static final ca.uhn.fhir.model.api.Include INCLUDE_LOCATION = new ca.uhn.fhir.model.api.Include("Device:location").toLocked();
2457
2458 /**
2459   * Search parameter: <b>type</b>
2460   * <p>
2461   * Description: <b>The type of the device</b><br>
2462   * Type: <b>token</b><br>
2463   * Path: <b>Device.type</b><br>
2464   * </p>
2465   */
2466  @SearchParamDefinition(name="type", path="Device.type", description="The type of the device", type="token" )
2467  public static final String SP_TYPE = "type";
2468 /**
2469   * <b>Fluent Client</b> search parameter constant for <b>type</b>
2470   * <p>
2471   * Description: <b>The type of the device</b><br>
2472   * Type: <b>token</b><br>
2473   * Path: <b>Device.type</b><br>
2474   * </p>
2475   */
2476  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_TYPE);
2477
2478 /**
2479   * Search parameter: <b>url</b>
2480   * <p>
2481   * Description: <b>Network address to contact device</b><br>
2482   * Type: <b>uri</b><br>
2483   * Path: <b>Device.url</b><br>
2484   * </p>
2485   */
2486  @SearchParamDefinition(name="url", path="Device.url", description="Network address to contact device", type="uri" )
2487  public static final String SP_URL = "url";
2488 /**
2489   * <b>Fluent Client</b> search parameter constant for <b>url</b>
2490   * <p>
2491   * Description: <b>Network address to contact device</b><br>
2492   * Type: <b>uri</b><br>
2493   * Path: <b>Device.url</b><br>
2494   * </p>
2495   */
2496  public static final ca.uhn.fhir.rest.gclient.UriClientParam URL = new ca.uhn.fhir.rest.gclient.UriClientParam(SP_URL);
2497
2498 /**
2499   * Search parameter: <b>manufacturer</b>
2500   * <p>
2501   * Description: <b>The manufacturer of the device</b><br>
2502   * Type: <b>string</b><br>
2503   * Path: <b>Device.manufacturer</b><br>
2504   * </p>
2505   */
2506  @SearchParamDefinition(name="manufacturer", path="Device.manufacturer", description="The manufacturer of the device", type="string" )
2507  public static final String SP_MANUFACTURER = "manufacturer";
2508 /**
2509   * <b>Fluent Client</b> search parameter constant for <b>manufacturer</b>
2510   * <p>
2511   * Description: <b>The manufacturer of the device</b><br>
2512   * Type: <b>string</b><br>
2513   * Path: <b>Device.manufacturer</b><br>
2514   * </p>
2515   */
2516  public static final ca.uhn.fhir.rest.gclient.StringClientParam MANUFACTURER = new ca.uhn.fhir.rest.gclient.StringClientParam(SP_MANUFACTURER);
2517
2518 /**
2519   * Search parameter: <b>status</b>
2520   * <p>
2521   * Description: <b>active | inactive | entered-in-error | unknown</b><br>
2522   * Type: <b>token</b><br>
2523   * Path: <b>Device.status</b><br>
2524   * </p>
2525   */
2526  @SearchParamDefinition(name="status", path="Device.status", description="active | inactive | entered-in-error | unknown", type="token" )
2527  public static final String SP_STATUS = "status";
2528 /**
2529   * <b>Fluent Client</b> search parameter constant for <b>status</b>
2530   * <p>
2531   * Description: <b>active | inactive | entered-in-error | unknown</b><br>
2532   * Type: <b>token</b><br>
2533   * Path: <b>Device.status</b><br>
2534   * </p>
2535   */
2536  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
2537
2538
2539}
2540