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