001package org.hl7.fhir.dstu3.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Fri, Mar 16, 2018 15:21+1100 for FHIR v3.0.1
033
034import java.util.*;
035
036import org.hl7.fhir.utilities.Utilities;
037import ca.uhn.fhir.model.api.annotation.ResourceDef;
038import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
039import ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.ChildOrder;
041import ca.uhn.fhir.model.api.annotation.Description;
042import ca.uhn.fhir.model.api.annotation.Block;
043import org.hl7.fhir.instance.model.api.*;
044import org.hl7.fhir.exceptions.FHIRException;
045import org.hl7.fhir.exceptions.FHIRFormatError;
046/**
047 * Represents a request for a patient to employ a medical device. The device may be an implantable device, or an external assistive device, such as a walker.
048 */
049@ResourceDef(name="DeviceRequest", profile="http://hl7.org/fhir/StructureDefinition/DeviceRequest")
050public class DeviceRequest extends DomainResource {
051
052    public enum DeviceRequestStatus {
053        /**
054         * The request has been created but is not yet complete or ready for action
055         */
056        DRAFT, 
057        /**
058         * The request is ready to be acted upon
059         */
060        ACTIVE, 
061        /**
062         * The authorization/request to act has been temporarily withdrawn but is expected to resume in the future
063         */
064        SUSPENDED, 
065        /**
066         * The authorization/request to act has been terminated prior to the full completion of the intended actions.  No further activity should occur.
067         */
068        CANCELLED, 
069        /**
070         * Activity against the request has been sufficiently completed to the satisfaction of the requester
071         */
072        COMPLETED, 
073        /**
074         * This electronic record should never have existed, though it is possible that real-world decisions were based on it.  (If real-world activity has occurred, the status should be "cancelled" rather than "entered-in-error".)
075         */
076        ENTEREDINERROR, 
077        /**
078         * The authoring system does not know which of the status values currently applies for this request.  Note: This concept is not to be used for "other" . One of the listed statuses is presumed to apply,  but the system creating the request doesn't know.
079         */
080        UNKNOWN, 
081        /**
082         * added to help the parsers with the generic types
083         */
084        NULL;
085        public static DeviceRequestStatus fromCode(String codeString) throws FHIRException {
086            if (codeString == null || "".equals(codeString))
087                return null;
088        if ("draft".equals(codeString))
089          return DRAFT;
090        if ("active".equals(codeString))
091          return ACTIVE;
092        if ("suspended".equals(codeString))
093          return SUSPENDED;
094        if ("cancelled".equals(codeString))
095          return CANCELLED;
096        if ("completed".equals(codeString))
097          return COMPLETED;
098        if ("entered-in-error".equals(codeString))
099          return ENTEREDINERROR;
100        if ("unknown".equals(codeString))
101          return UNKNOWN;
102        if (Configuration.isAcceptInvalidEnums())
103          return null;
104        else
105          throw new FHIRException("Unknown DeviceRequestStatus code '"+codeString+"'");
106        }
107        public String toCode() {
108          switch (this) {
109            case DRAFT: return "draft";
110            case ACTIVE: return "active";
111            case SUSPENDED: return "suspended";
112            case CANCELLED: return "cancelled";
113            case COMPLETED: return "completed";
114            case ENTEREDINERROR: return "entered-in-error";
115            case UNKNOWN: return "unknown";
116            default: return "?";
117          }
118        }
119        public String getSystem() {
120          switch (this) {
121            case DRAFT: return "http://hl7.org/fhir/request-status";
122            case ACTIVE: return "http://hl7.org/fhir/request-status";
123            case SUSPENDED: return "http://hl7.org/fhir/request-status";
124            case CANCELLED: return "http://hl7.org/fhir/request-status";
125            case COMPLETED: return "http://hl7.org/fhir/request-status";
126            case ENTEREDINERROR: return "http://hl7.org/fhir/request-status";
127            case UNKNOWN: return "http://hl7.org/fhir/request-status";
128            default: return "?";
129          }
130        }
131        public String getDefinition() {
132          switch (this) {
133            case DRAFT: return "The request has been created but is not yet complete or ready for action";
134            case ACTIVE: return "The request is ready to be acted upon";
135            case SUSPENDED: return "The authorization/request to act has been temporarily withdrawn but is expected to resume in the future";
136            case CANCELLED: return "The authorization/request to act has been terminated prior to the full completion of the intended actions.  No further activity should occur.";
137            case COMPLETED: return "Activity against the request has been sufficiently completed to the satisfaction of the requester";
138            case ENTEREDINERROR: return "This electronic record should never have existed, though it is possible that real-world decisions were based on it.  (If real-world activity has occurred, the status should be \"cancelled\" rather than \"entered-in-error\".)";
139            case UNKNOWN: return "The authoring system does not know which of the status values currently applies for this request.  Note: This concept is not to be used for \"other\" . One of the listed statuses is presumed to apply,  but the system creating the request doesn't know.";
140            default: return "?";
141          }
142        }
143        public String getDisplay() {
144          switch (this) {
145            case DRAFT: return "Draft";
146            case ACTIVE: return "Active";
147            case SUSPENDED: return "Suspended";
148            case CANCELLED: return "Cancelled";
149            case COMPLETED: return "Completed";
150            case ENTEREDINERROR: return "Entered in Error";
151            case UNKNOWN: return "Unknown";
152            default: return "?";
153          }
154        }
155    }
156
157  public static class DeviceRequestStatusEnumFactory implements EnumFactory<DeviceRequestStatus> {
158    public DeviceRequestStatus fromCode(String codeString) throws IllegalArgumentException {
159      if (codeString == null || "".equals(codeString))
160            if (codeString == null || "".equals(codeString))
161                return null;
162        if ("draft".equals(codeString))
163          return DeviceRequestStatus.DRAFT;
164        if ("active".equals(codeString))
165          return DeviceRequestStatus.ACTIVE;
166        if ("suspended".equals(codeString))
167          return DeviceRequestStatus.SUSPENDED;
168        if ("cancelled".equals(codeString))
169          return DeviceRequestStatus.CANCELLED;
170        if ("completed".equals(codeString))
171          return DeviceRequestStatus.COMPLETED;
172        if ("entered-in-error".equals(codeString))
173          return DeviceRequestStatus.ENTEREDINERROR;
174        if ("unknown".equals(codeString))
175          return DeviceRequestStatus.UNKNOWN;
176        throw new IllegalArgumentException("Unknown DeviceRequestStatus code '"+codeString+"'");
177        }
178        public Enumeration<DeviceRequestStatus> fromType(Base code) throws FHIRException {
179          if (code == null)
180            return null;
181          if (code.isEmpty())
182            return new Enumeration<DeviceRequestStatus>(this);
183          String codeString = ((PrimitiveType) code).asStringValue();
184          if (codeString == null || "".equals(codeString))
185            return null;
186        if ("draft".equals(codeString))
187          return new Enumeration<DeviceRequestStatus>(this, DeviceRequestStatus.DRAFT);
188        if ("active".equals(codeString))
189          return new Enumeration<DeviceRequestStatus>(this, DeviceRequestStatus.ACTIVE);
190        if ("suspended".equals(codeString))
191          return new Enumeration<DeviceRequestStatus>(this, DeviceRequestStatus.SUSPENDED);
192        if ("cancelled".equals(codeString))
193          return new Enumeration<DeviceRequestStatus>(this, DeviceRequestStatus.CANCELLED);
194        if ("completed".equals(codeString))
195          return new Enumeration<DeviceRequestStatus>(this, DeviceRequestStatus.COMPLETED);
196        if ("entered-in-error".equals(codeString))
197          return new Enumeration<DeviceRequestStatus>(this, DeviceRequestStatus.ENTEREDINERROR);
198        if ("unknown".equals(codeString))
199          return new Enumeration<DeviceRequestStatus>(this, DeviceRequestStatus.UNKNOWN);
200        throw new FHIRException("Unknown DeviceRequestStatus code '"+codeString+"'");
201        }
202    public String toCode(DeviceRequestStatus code) {
203      if (code == DeviceRequestStatus.DRAFT)
204        return "draft";
205      if (code == DeviceRequestStatus.ACTIVE)
206        return "active";
207      if (code == DeviceRequestStatus.SUSPENDED)
208        return "suspended";
209      if (code == DeviceRequestStatus.CANCELLED)
210        return "cancelled";
211      if (code == DeviceRequestStatus.COMPLETED)
212        return "completed";
213      if (code == DeviceRequestStatus.ENTEREDINERROR)
214        return "entered-in-error";
215      if (code == DeviceRequestStatus.UNKNOWN)
216        return "unknown";
217      return "?";
218      }
219    public String toSystem(DeviceRequestStatus code) {
220      return code.getSystem();
221      }
222    }
223
224    public enum RequestPriority {
225        /**
226         * The request has normal priority
227         */
228        ROUTINE, 
229        /**
230         * The request should be actioned promptly - higher priority than routine
231         */
232        URGENT, 
233        /**
234         * The request should be actioned as soon as possible - higher priority than urgent
235         */
236        ASAP, 
237        /**
238         * The request should be actioned immediately - highest possible priority.  E.g. an emergency
239         */
240        STAT, 
241        /**
242         * added to help the parsers with the generic types
243         */
244        NULL;
245        public static RequestPriority fromCode(String codeString) throws FHIRException {
246            if (codeString == null || "".equals(codeString))
247                return null;
248        if ("routine".equals(codeString))
249          return ROUTINE;
250        if ("urgent".equals(codeString))
251          return URGENT;
252        if ("asap".equals(codeString))
253          return ASAP;
254        if ("stat".equals(codeString))
255          return STAT;
256        if (Configuration.isAcceptInvalidEnums())
257          return null;
258        else
259          throw new FHIRException("Unknown RequestPriority code '"+codeString+"'");
260        }
261        public String toCode() {
262          switch (this) {
263            case ROUTINE: return "routine";
264            case URGENT: return "urgent";
265            case ASAP: return "asap";
266            case STAT: return "stat";
267            default: return "?";
268          }
269        }
270        public String getSystem() {
271          switch (this) {
272            case ROUTINE: return "http://hl7.org/fhir/request-priority";
273            case URGENT: return "http://hl7.org/fhir/request-priority";
274            case ASAP: return "http://hl7.org/fhir/request-priority";
275            case STAT: return "http://hl7.org/fhir/request-priority";
276            default: return "?";
277          }
278        }
279        public String getDefinition() {
280          switch (this) {
281            case ROUTINE: return "The request has normal priority";
282            case URGENT: return "The request should be actioned promptly - higher priority than routine";
283            case ASAP: return "The request should be actioned as soon as possible - higher priority than urgent";
284            case STAT: return "The request should be actioned immediately - highest possible priority.  E.g. an emergency";
285            default: return "?";
286          }
287        }
288        public String getDisplay() {
289          switch (this) {
290            case ROUTINE: return "Routine";
291            case URGENT: return "Urgent";
292            case ASAP: return "ASAP";
293            case STAT: return "STAT";
294            default: return "?";
295          }
296        }
297    }
298
299  public static class RequestPriorityEnumFactory implements EnumFactory<RequestPriority> {
300    public RequestPriority fromCode(String codeString) throws IllegalArgumentException {
301      if (codeString == null || "".equals(codeString))
302            if (codeString == null || "".equals(codeString))
303                return null;
304        if ("routine".equals(codeString))
305          return RequestPriority.ROUTINE;
306        if ("urgent".equals(codeString))
307          return RequestPriority.URGENT;
308        if ("asap".equals(codeString))
309          return RequestPriority.ASAP;
310        if ("stat".equals(codeString))
311          return RequestPriority.STAT;
312        throw new IllegalArgumentException("Unknown RequestPriority code '"+codeString+"'");
313        }
314        public Enumeration<RequestPriority> fromType(Base code) throws FHIRException {
315          if (code == null)
316            return null;
317          if (code.isEmpty())
318            return new Enumeration<RequestPriority>(this);
319          String codeString = ((PrimitiveType) code).asStringValue();
320          if (codeString == null || "".equals(codeString))
321            return null;
322        if ("routine".equals(codeString))
323          return new Enumeration<RequestPriority>(this, RequestPriority.ROUTINE);
324        if ("urgent".equals(codeString))
325          return new Enumeration<RequestPriority>(this, RequestPriority.URGENT);
326        if ("asap".equals(codeString))
327          return new Enumeration<RequestPriority>(this, RequestPriority.ASAP);
328        if ("stat".equals(codeString))
329          return new Enumeration<RequestPriority>(this, RequestPriority.STAT);
330        throw new FHIRException("Unknown RequestPriority code '"+codeString+"'");
331        }
332    public String toCode(RequestPriority code) {
333      if (code == RequestPriority.ROUTINE)
334        return "routine";
335      if (code == RequestPriority.URGENT)
336        return "urgent";
337      if (code == RequestPriority.ASAP)
338        return "asap";
339      if (code == RequestPriority.STAT)
340        return "stat";
341      return "?";
342      }
343    public String toSystem(RequestPriority code) {
344      return code.getSystem();
345      }
346    }
347
348    @Block()
349    public static class DeviceRequestRequesterComponent extends BackboneElement implements IBaseBackboneElement {
350        /**
351         * The device, practitioner, etc. who initiated the request.
352         */
353        @Child(name = "agent", type = {Device.class, Practitioner.class, Organization.class}, order=1, min=1, max=1, modifier=false, summary=true)
354        @Description(shortDefinition="Individual making the request", formalDefinition="The device, practitioner, etc. who initiated the request." )
355        protected Reference agent;
356
357        /**
358         * The actual object that is the target of the reference (The device, practitioner, etc. who initiated the request.)
359         */
360        protected Resource agentTarget;
361
362        /**
363         * The organization the device or practitioner was acting on behalf of.
364         */
365        @Child(name = "onBehalfOf", type = {Organization.class}, order=2, min=0, max=1, modifier=false, summary=true)
366        @Description(shortDefinition="Organization agent is acting for", formalDefinition="The organization the device or practitioner was acting on behalf of." )
367        protected Reference onBehalfOf;
368
369        /**
370         * The actual object that is the target of the reference (The organization the device or practitioner was acting on behalf of.)
371         */
372        protected Organization onBehalfOfTarget;
373
374        private static final long serialVersionUID = -71453027L;
375
376    /**
377     * Constructor
378     */
379      public DeviceRequestRequesterComponent() {
380        super();
381      }
382
383    /**
384     * Constructor
385     */
386      public DeviceRequestRequesterComponent(Reference agent) {
387        super();
388        this.agent = agent;
389      }
390
391        /**
392         * @return {@link #agent} (The device, practitioner, etc. who initiated the request.)
393         */
394        public Reference getAgent() { 
395          if (this.agent == null)
396            if (Configuration.errorOnAutoCreate())
397              throw new Error("Attempt to auto-create DeviceRequestRequesterComponent.agent");
398            else if (Configuration.doAutoCreate())
399              this.agent = new Reference(); // cc
400          return this.agent;
401        }
402
403        public boolean hasAgent() { 
404          return this.agent != null && !this.agent.isEmpty();
405        }
406
407        /**
408         * @param value {@link #agent} (The device, practitioner, etc. who initiated the request.)
409         */
410        public DeviceRequestRequesterComponent setAgent(Reference value)  { 
411          this.agent = value;
412          return this;
413        }
414
415        /**
416         * @return {@link #agent} 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 device, practitioner, etc. who initiated the request.)
417         */
418        public Resource getAgentTarget() { 
419          return this.agentTarget;
420        }
421
422        /**
423         * @param value {@link #agent} 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 device, practitioner, etc. who initiated the request.)
424         */
425        public DeviceRequestRequesterComponent setAgentTarget(Resource value) { 
426          this.agentTarget = value;
427          return this;
428        }
429
430        /**
431         * @return {@link #onBehalfOf} (The organization the device or practitioner was acting on behalf of.)
432         */
433        public Reference getOnBehalfOf() { 
434          if (this.onBehalfOf == null)
435            if (Configuration.errorOnAutoCreate())
436              throw new Error("Attempt to auto-create DeviceRequestRequesterComponent.onBehalfOf");
437            else if (Configuration.doAutoCreate())
438              this.onBehalfOf = new Reference(); // cc
439          return this.onBehalfOf;
440        }
441
442        public boolean hasOnBehalfOf() { 
443          return this.onBehalfOf != null && !this.onBehalfOf.isEmpty();
444        }
445
446        /**
447         * @param value {@link #onBehalfOf} (The organization the device or practitioner was acting on behalf of.)
448         */
449        public DeviceRequestRequesterComponent setOnBehalfOf(Reference value)  { 
450          this.onBehalfOf = value;
451          return this;
452        }
453
454        /**
455         * @return {@link #onBehalfOf} 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 organization the device or practitioner was acting on behalf of.)
456         */
457        public Organization getOnBehalfOfTarget() { 
458          if (this.onBehalfOfTarget == null)
459            if (Configuration.errorOnAutoCreate())
460              throw new Error("Attempt to auto-create DeviceRequestRequesterComponent.onBehalfOf");
461            else if (Configuration.doAutoCreate())
462              this.onBehalfOfTarget = new Organization(); // aa
463          return this.onBehalfOfTarget;
464        }
465
466        /**
467         * @param value {@link #onBehalfOf} 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 organization the device or practitioner was acting on behalf of.)
468         */
469        public DeviceRequestRequesterComponent setOnBehalfOfTarget(Organization value) { 
470          this.onBehalfOfTarget = value;
471          return this;
472        }
473
474        protected void listChildren(List<Property> children) {
475          super.listChildren(children);
476          children.add(new Property("agent", "Reference(Device|Practitioner|Organization)", "The device, practitioner, etc. who initiated the request.", 0, 1, agent));
477          children.add(new Property("onBehalfOf", "Reference(Organization)", "The organization the device or practitioner was acting on behalf of.", 0, 1, onBehalfOf));
478        }
479
480        @Override
481        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
482          switch (_hash) {
483          case 92750597: /*agent*/  return new Property("agent", "Reference(Device|Practitioner|Organization)", "The device, practitioner, etc. who initiated the request.", 0, 1, agent);
484          case -14402964: /*onBehalfOf*/  return new Property("onBehalfOf", "Reference(Organization)", "The organization the device or practitioner was acting on behalf of.", 0, 1, onBehalfOf);
485          default: return super.getNamedProperty(_hash, _name, _checkValid);
486          }
487
488        }
489
490      @Override
491      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
492        switch (hash) {
493        case 92750597: /*agent*/ return this.agent == null ? new Base[0] : new Base[] {this.agent}; // Reference
494        case -14402964: /*onBehalfOf*/ return this.onBehalfOf == null ? new Base[0] : new Base[] {this.onBehalfOf}; // Reference
495        default: return super.getProperty(hash, name, checkValid);
496        }
497
498      }
499
500      @Override
501      public Base setProperty(int hash, String name, Base value) throws FHIRException {
502        switch (hash) {
503        case 92750597: // agent
504          this.agent = castToReference(value); // Reference
505          return value;
506        case -14402964: // onBehalfOf
507          this.onBehalfOf = castToReference(value); // Reference
508          return value;
509        default: return super.setProperty(hash, name, value);
510        }
511
512      }
513
514      @Override
515      public Base setProperty(String name, Base value) throws FHIRException {
516        if (name.equals("agent")) {
517          this.agent = castToReference(value); // Reference
518        } else if (name.equals("onBehalfOf")) {
519          this.onBehalfOf = castToReference(value); // Reference
520        } else
521          return super.setProperty(name, value);
522        return value;
523      }
524
525      @Override
526      public Base makeProperty(int hash, String name) throws FHIRException {
527        switch (hash) {
528        case 92750597:  return getAgent(); 
529        case -14402964:  return getOnBehalfOf(); 
530        default: return super.makeProperty(hash, name);
531        }
532
533      }
534
535      @Override
536      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
537        switch (hash) {
538        case 92750597: /*agent*/ return new String[] {"Reference"};
539        case -14402964: /*onBehalfOf*/ return new String[] {"Reference"};
540        default: return super.getTypesForProperty(hash, name);
541        }
542
543      }
544
545      @Override
546      public Base addChild(String name) throws FHIRException {
547        if (name.equals("agent")) {
548          this.agent = new Reference();
549          return this.agent;
550        }
551        else if (name.equals("onBehalfOf")) {
552          this.onBehalfOf = new Reference();
553          return this.onBehalfOf;
554        }
555        else
556          return super.addChild(name);
557      }
558
559      public DeviceRequestRequesterComponent copy() {
560        DeviceRequestRequesterComponent dst = new DeviceRequestRequesterComponent();
561        copyValues(dst);
562        dst.agent = agent == null ? null : agent.copy();
563        dst.onBehalfOf = onBehalfOf == null ? null : onBehalfOf.copy();
564        return dst;
565      }
566
567      @Override
568      public boolean equalsDeep(Base other_) {
569        if (!super.equalsDeep(other_))
570          return false;
571        if (!(other_ instanceof DeviceRequestRequesterComponent))
572          return false;
573        DeviceRequestRequesterComponent o = (DeviceRequestRequesterComponent) other_;
574        return compareDeep(agent, o.agent, true) && compareDeep(onBehalfOf, o.onBehalfOf, true);
575      }
576
577      @Override
578      public boolean equalsShallow(Base other_) {
579        if (!super.equalsShallow(other_))
580          return false;
581        if (!(other_ instanceof DeviceRequestRequesterComponent))
582          return false;
583        DeviceRequestRequesterComponent o = (DeviceRequestRequesterComponent) other_;
584        return true;
585      }
586
587      public boolean isEmpty() {
588        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(agent, onBehalfOf);
589      }
590
591  public String fhirType() {
592    return "DeviceRequest.requester";
593
594  }
595
596  }
597
598    /**
599     * Identifiers assigned to this order by the orderer or by the receiver.
600     */
601    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
602    @Description(shortDefinition="External Request identifier", formalDefinition="Identifiers assigned to this order by the orderer or by the receiver." )
603    protected List<Identifier> identifier;
604
605    /**
606     * Protocol or definition followed by this request. For example: The proposed act must be performed if the indicated conditions occur, e.g.., shortness of breath, SpO2 less than x%.
607     */
608    @Child(name = "definition", type = {ActivityDefinition.class, PlanDefinition.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
609    @Description(shortDefinition="Protocol or definition", formalDefinition="Protocol or definition followed by this request. For example: The proposed act must be performed if the indicated conditions occur, e.g.., shortness of breath, SpO2 less than x%." )
610    protected List<Reference> definition;
611    /**
612     * The actual objects that are the target of the reference (Protocol or definition followed by this request. For example: The proposed act must be performed if the indicated conditions occur, e.g.., shortness of breath, SpO2 less than x%.)
613     */
614    protected List<Resource> definitionTarget;
615
616
617    /**
618     * Plan/proposal/order fulfilled by this request.
619     */
620    @Child(name = "basedOn", type = {Reference.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
621    @Description(shortDefinition="What request fulfills", formalDefinition="Plan/proposal/order fulfilled by this request." )
622    protected List<Reference> basedOn;
623    /**
624     * The actual objects that are the target of the reference (Plan/proposal/order fulfilled by this request.)
625     */
626    protected List<Resource> basedOnTarget;
627
628
629    /**
630     * The request takes the place of the referenced completed or terminated request(s).
631     */
632    @Child(name = "priorRequest", type = {Reference.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
633    @Description(shortDefinition="What request replaces", formalDefinition="The request takes the place of the referenced completed or terminated request(s)." )
634    protected List<Reference> priorRequest;
635    /**
636     * The actual objects that are the target of the reference (The request takes the place of the referenced completed or terminated request(s).)
637     */
638    protected List<Resource> priorRequestTarget;
639
640
641    /**
642     * Composite request this is part of.
643     */
644    @Child(name = "groupIdentifier", type = {Identifier.class}, order=4, min=0, max=1, modifier=false, summary=true)
645    @Description(shortDefinition="Identifier of composite request", formalDefinition="Composite request this is part of." )
646    protected Identifier groupIdentifier;
647
648    /**
649     * The status of the request.
650     */
651    @Child(name = "status", type = {CodeType.class}, order=5, min=0, max=1, modifier=true, summary=true)
652    @Description(shortDefinition="draft | active | suspended | completed | entered-in-error | cancelled", formalDefinition="The status of the request." )
653    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/request-status")
654    protected Enumeration<DeviceRequestStatus> status;
655
656    /**
657     * Whether the request is a proposal, plan, an original order or a reflex order.
658     */
659    @Child(name = "intent", type = {CodeableConcept.class}, order=6, min=1, max=1, modifier=true, summary=true)
660    @Description(shortDefinition="proposal | plan | original-order | encoded | reflex-order", formalDefinition="Whether the request is a proposal, plan, an original order or a reflex order." )
661    protected CodeableConcept intent;
662
663    /**
664     * Indicates how quickly the {{title}} should be addressed with respect to other requests.
665     */
666    @Child(name = "priority", type = {CodeType.class}, order=7, min=0, max=1, modifier=false, summary=true)
667    @Description(shortDefinition="Indicates how quickly the {{title}} should be addressed with respect to other requests", formalDefinition="Indicates how quickly the {{title}} should be addressed with respect to other requests." )
668    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/request-priority")
669    protected Enumeration<RequestPriority> priority;
670
671    /**
672     * The details of the device to be used.
673     */
674    @Child(name = "code", type = {Device.class, CodeableConcept.class}, order=8, min=1, max=1, modifier=false, summary=true)
675    @Description(shortDefinition="Device requested", formalDefinition="The details of the device to be used." )
676    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/device-kind")
677    protected Type code;
678
679    /**
680     * The patient who will use the device.
681     */
682    @Child(name = "subject", type = {Patient.class, Group.class, Location.class, Device.class}, order=9, min=1, max=1, modifier=false, summary=true)
683    @Description(shortDefinition="Focus of request", formalDefinition="The patient who will use the device." )
684    protected Reference subject;
685
686    /**
687     * The actual object that is the target of the reference (The patient who will use the device.)
688     */
689    protected Resource subjectTarget;
690
691    /**
692     * An encounter that provides additional context in which this request is made.
693     */
694    @Child(name = "context", type = {Encounter.class, EpisodeOfCare.class}, order=10, min=0, max=1, modifier=false, summary=true)
695    @Description(shortDefinition="Encounter or Episode motivating request", formalDefinition="An encounter that provides additional context in which this request is made." )
696    protected Reference context;
697
698    /**
699     * The actual object that is the target of the reference (An encounter that provides additional context in which this request is made.)
700     */
701    protected Resource contextTarget;
702
703    /**
704     * The timing schedule for the use of the device. The Schedule data type allows many different expressions, for example. "Every 8 hours"; "Three times a day"; "1/2 an hour before breakfast for 10 days from 23-Dec 2011:"; "15 Oct 2013, 17 Oct 2013 and 1 Nov 2013".
705     */
706    @Child(name = "occurrence", type = {DateTimeType.class, Period.class, Timing.class}, order=11, min=0, max=1, modifier=false, summary=true)
707    @Description(shortDefinition="Desired time or schedule for use", formalDefinition="The timing schedule for the use of the device. The Schedule data type allows many different expressions, for example. \"Every 8 hours\"; \"Three times a day\"; \"1/2 an hour before breakfast for 10 days from 23-Dec 2011:\"; \"15 Oct 2013, 17 Oct 2013 and 1 Nov 2013\"." )
708    protected Type occurrence;
709
710    /**
711     * When the request transitioned to being actionable.
712     */
713    @Child(name = "authoredOn", type = {DateTimeType.class}, order=12, min=0, max=1, modifier=false, summary=true)
714    @Description(shortDefinition="When recorded", formalDefinition="When the request transitioned to being actionable." )
715    protected DateTimeType authoredOn;
716
717    /**
718     * The individual who initiated the request and has responsibility for its activation.
719     */
720    @Child(name = "requester", type = {}, order=13, min=0, max=1, modifier=false, summary=true)
721    @Description(shortDefinition="Who/what is requesting diagnostics", formalDefinition="The individual who initiated the request and has responsibility for its activation." )
722    protected DeviceRequestRequesterComponent requester;
723
724    /**
725     * Desired type of performer for doing the diagnostic testing.
726     */
727    @Child(name = "performerType", type = {CodeableConcept.class}, order=14, min=0, max=1, modifier=false, summary=true)
728    @Description(shortDefinition="Fille role", formalDefinition="Desired type of performer for doing the diagnostic testing." )
729    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/participant-role")
730    protected CodeableConcept performerType;
731
732    /**
733     * The desired perfomer for doing the diagnostic testing.
734     */
735    @Child(name = "performer", type = {Practitioner.class, Organization.class, Patient.class, Device.class, RelatedPerson.class, HealthcareService.class}, order=15, min=0, max=1, modifier=false, summary=true)
736    @Description(shortDefinition="Requested Filler", formalDefinition="The desired perfomer for doing the diagnostic testing." )
737    protected Reference performer;
738
739    /**
740     * The actual object that is the target of the reference (The desired perfomer for doing the diagnostic testing.)
741     */
742    protected Resource performerTarget;
743
744    /**
745     * Reason or justification for the use of this device.
746     */
747    @Child(name = "reasonCode", type = {CodeableConcept.class}, order=16, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
748    @Description(shortDefinition="Coded Reason for request", formalDefinition="Reason or justification for the use of this device." )
749    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/condition-code")
750    protected List<CodeableConcept> reasonCode;
751
752    /**
753     * Reason or justification for the use of this device.
754     */
755    @Child(name = "reasonReference", type = {Reference.class}, order=17, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
756    @Description(shortDefinition="Linked Reason for request", formalDefinition="Reason or justification for the use of this device." )
757    protected List<Reference> reasonReference;
758    /**
759     * The actual objects that are the target of the reference (Reason or justification for the use of this device.)
760     */
761    protected List<Resource> reasonReferenceTarget;
762
763
764    /**
765     * Additional clinical information about the patient that may influence the request fulfilment.  For example, this may includes body where on the subject's the device will be used ( i.e. the target site).
766     */
767    @Child(name = "supportingInfo", type = {Reference.class}, order=18, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
768    @Description(shortDefinition="Additional clinical information", formalDefinition="Additional clinical information about the patient that may influence the request fulfilment.  For example, this may includes body where on the subject's the device will be used ( i.e. the target site)." )
769    protected List<Reference> supportingInfo;
770    /**
771     * The actual objects that are the target of the reference (Additional clinical information about the patient that may influence the request fulfilment.  For example, this may includes body where on the subject's the device will be used ( i.e. the target site).)
772     */
773    protected List<Resource> supportingInfoTarget;
774
775
776    /**
777     * Details about this request that were not represented at all or sufficiently in one of the attributes provided in a class. These may include for example a comment, an instruction, or a note associated with the statement.
778     */
779    @Child(name = "note", type = {Annotation.class}, order=19, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
780    @Description(shortDefinition="Notes or comments", formalDefinition="Details about this request that were not represented at all or sufficiently in one of the attributes provided in a class. These may include for example a comment, an instruction, or a note associated with the statement." )
781    protected List<Annotation> note;
782
783    /**
784     * Key events in the history of the request.
785     */
786    @Child(name = "relevantHistory", type = {Provenance.class}, order=20, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
787    @Description(shortDefinition="Request provenance", formalDefinition="Key events in the history of the request." )
788    protected List<Reference> relevantHistory;
789    /**
790     * The actual objects that are the target of the reference (Key events in the history of the request.)
791     */
792    protected List<Provenance> relevantHistoryTarget;
793
794
795    private static final long serialVersionUID = -2002514925L;
796
797  /**
798   * Constructor
799   */
800    public DeviceRequest() {
801      super();
802    }
803
804  /**
805   * Constructor
806   */
807    public DeviceRequest(CodeableConcept intent, Type code, Reference subject) {
808      super();
809      this.intent = intent;
810      this.code = code;
811      this.subject = subject;
812    }
813
814    /**
815     * @return {@link #identifier} (Identifiers assigned to this order by the orderer or by the receiver.)
816     */
817    public List<Identifier> getIdentifier() { 
818      if (this.identifier == null)
819        this.identifier = new ArrayList<Identifier>();
820      return this.identifier;
821    }
822
823    /**
824     * @return Returns a reference to <code>this</code> for easy method chaining
825     */
826    public DeviceRequest setIdentifier(List<Identifier> theIdentifier) { 
827      this.identifier = theIdentifier;
828      return this;
829    }
830
831    public boolean hasIdentifier() { 
832      if (this.identifier == null)
833        return false;
834      for (Identifier item : this.identifier)
835        if (!item.isEmpty())
836          return true;
837      return false;
838    }
839
840    public Identifier addIdentifier() { //3
841      Identifier t = new Identifier();
842      if (this.identifier == null)
843        this.identifier = new ArrayList<Identifier>();
844      this.identifier.add(t);
845      return t;
846    }
847
848    public DeviceRequest addIdentifier(Identifier t) { //3
849      if (t == null)
850        return this;
851      if (this.identifier == null)
852        this.identifier = new ArrayList<Identifier>();
853      this.identifier.add(t);
854      return this;
855    }
856
857    /**
858     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
859     */
860    public Identifier getIdentifierFirstRep() { 
861      if (getIdentifier().isEmpty()) {
862        addIdentifier();
863      }
864      return getIdentifier().get(0);
865    }
866
867    /**
868     * @return {@link #definition} (Protocol or definition followed by this request. For example: The proposed act must be performed if the indicated conditions occur, e.g.., shortness of breath, SpO2 less than x%.)
869     */
870    public List<Reference> getDefinition() { 
871      if (this.definition == null)
872        this.definition = new ArrayList<Reference>();
873      return this.definition;
874    }
875
876    /**
877     * @return Returns a reference to <code>this</code> for easy method chaining
878     */
879    public DeviceRequest setDefinition(List<Reference> theDefinition) { 
880      this.definition = theDefinition;
881      return this;
882    }
883
884    public boolean hasDefinition() { 
885      if (this.definition == null)
886        return false;
887      for (Reference item : this.definition)
888        if (!item.isEmpty())
889          return true;
890      return false;
891    }
892
893    public Reference addDefinition() { //3
894      Reference t = new Reference();
895      if (this.definition == null)
896        this.definition = new ArrayList<Reference>();
897      this.definition.add(t);
898      return t;
899    }
900
901    public DeviceRequest addDefinition(Reference t) { //3
902      if (t == null)
903        return this;
904      if (this.definition == null)
905        this.definition = new ArrayList<Reference>();
906      this.definition.add(t);
907      return this;
908    }
909
910    /**
911     * @return The first repetition of repeating field {@link #definition}, creating it if it does not already exist
912     */
913    public Reference getDefinitionFirstRep() { 
914      if (getDefinition().isEmpty()) {
915        addDefinition();
916      }
917      return getDefinition().get(0);
918    }
919
920    /**
921     * @deprecated Use Reference#setResource(IBaseResource) instead
922     */
923    @Deprecated
924    public List<Resource> getDefinitionTarget() { 
925      if (this.definitionTarget == null)
926        this.definitionTarget = new ArrayList<Resource>();
927      return this.definitionTarget;
928    }
929
930    /**
931     * @return {@link #basedOn} (Plan/proposal/order fulfilled by this request.)
932     */
933    public List<Reference> getBasedOn() { 
934      if (this.basedOn == null)
935        this.basedOn = new ArrayList<Reference>();
936      return this.basedOn;
937    }
938
939    /**
940     * @return Returns a reference to <code>this</code> for easy method chaining
941     */
942    public DeviceRequest setBasedOn(List<Reference> theBasedOn) { 
943      this.basedOn = theBasedOn;
944      return this;
945    }
946
947    public boolean hasBasedOn() { 
948      if (this.basedOn == null)
949        return false;
950      for (Reference item : this.basedOn)
951        if (!item.isEmpty())
952          return true;
953      return false;
954    }
955
956    public Reference addBasedOn() { //3
957      Reference t = new Reference();
958      if (this.basedOn == null)
959        this.basedOn = new ArrayList<Reference>();
960      this.basedOn.add(t);
961      return t;
962    }
963
964    public DeviceRequest addBasedOn(Reference t) { //3
965      if (t == null)
966        return this;
967      if (this.basedOn == null)
968        this.basedOn = new ArrayList<Reference>();
969      this.basedOn.add(t);
970      return this;
971    }
972
973    /**
974     * @return The first repetition of repeating field {@link #basedOn}, creating it if it does not already exist
975     */
976    public Reference getBasedOnFirstRep() { 
977      if (getBasedOn().isEmpty()) {
978        addBasedOn();
979      }
980      return getBasedOn().get(0);
981    }
982
983    /**
984     * @deprecated Use Reference#setResource(IBaseResource) instead
985     */
986    @Deprecated
987    public List<Resource> getBasedOnTarget() { 
988      if (this.basedOnTarget == null)
989        this.basedOnTarget = new ArrayList<Resource>();
990      return this.basedOnTarget;
991    }
992
993    /**
994     * @return {@link #priorRequest} (The request takes the place of the referenced completed or terminated request(s).)
995     */
996    public List<Reference> getPriorRequest() { 
997      if (this.priorRequest == null)
998        this.priorRequest = new ArrayList<Reference>();
999      return this.priorRequest;
1000    }
1001
1002    /**
1003     * @return Returns a reference to <code>this</code> for easy method chaining
1004     */
1005    public DeviceRequest setPriorRequest(List<Reference> thePriorRequest) { 
1006      this.priorRequest = thePriorRequest;
1007      return this;
1008    }
1009
1010    public boolean hasPriorRequest() { 
1011      if (this.priorRequest == null)
1012        return false;
1013      for (Reference item : this.priorRequest)
1014        if (!item.isEmpty())
1015          return true;
1016      return false;
1017    }
1018
1019    public Reference addPriorRequest() { //3
1020      Reference t = new Reference();
1021      if (this.priorRequest == null)
1022        this.priorRequest = new ArrayList<Reference>();
1023      this.priorRequest.add(t);
1024      return t;
1025    }
1026
1027    public DeviceRequest addPriorRequest(Reference t) { //3
1028      if (t == null)
1029        return this;
1030      if (this.priorRequest == null)
1031        this.priorRequest = new ArrayList<Reference>();
1032      this.priorRequest.add(t);
1033      return this;
1034    }
1035
1036    /**
1037     * @return The first repetition of repeating field {@link #priorRequest}, creating it if it does not already exist
1038     */
1039    public Reference getPriorRequestFirstRep() { 
1040      if (getPriorRequest().isEmpty()) {
1041        addPriorRequest();
1042      }
1043      return getPriorRequest().get(0);
1044    }
1045
1046    /**
1047     * @deprecated Use Reference#setResource(IBaseResource) instead
1048     */
1049    @Deprecated
1050    public List<Resource> getPriorRequestTarget() { 
1051      if (this.priorRequestTarget == null)
1052        this.priorRequestTarget = new ArrayList<Resource>();
1053      return this.priorRequestTarget;
1054    }
1055
1056    /**
1057     * @return {@link #groupIdentifier} (Composite request this is part of.)
1058     */
1059    public Identifier getGroupIdentifier() { 
1060      if (this.groupIdentifier == null)
1061        if (Configuration.errorOnAutoCreate())
1062          throw new Error("Attempt to auto-create DeviceRequest.groupIdentifier");
1063        else if (Configuration.doAutoCreate())
1064          this.groupIdentifier = new Identifier(); // cc
1065      return this.groupIdentifier;
1066    }
1067
1068    public boolean hasGroupIdentifier() { 
1069      return this.groupIdentifier != null && !this.groupIdentifier.isEmpty();
1070    }
1071
1072    /**
1073     * @param value {@link #groupIdentifier} (Composite request this is part of.)
1074     */
1075    public DeviceRequest setGroupIdentifier(Identifier value)  { 
1076      this.groupIdentifier = value;
1077      return this;
1078    }
1079
1080    /**
1081     * @return {@link #status} (The status of the request.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1082     */
1083    public Enumeration<DeviceRequestStatus> getStatusElement() { 
1084      if (this.status == null)
1085        if (Configuration.errorOnAutoCreate())
1086          throw new Error("Attempt to auto-create DeviceRequest.status");
1087        else if (Configuration.doAutoCreate())
1088          this.status = new Enumeration<DeviceRequestStatus>(new DeviceRequestStatusEnumFactory()); // bb
1089      return this.status;
1090    }
1091
1092    public boolean hasStatusElement() { 
1093      return this.status != null && !this.status.isEmpty();
1094    }
1095
1096    public boolean hasStatus() { 
1097      return this.status != null && !this.status.isEmpty();
1098    }
1099
1100    /**
1101     * @param value {@link #status} (The status of the request.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1102     */
1103    public DeviceRequest setStatusElement(Enumeration<DeviceRequestStatus> value) { 
1104      this.status = value;
1105      return this;
1106    }
1107
1108    /**
1109     * @return The status of the request.
1110     */
1111    public DeviceRequestStatus getStatus() { 
1112      return this.status == null ? null : this.status.getValue();
1113    }
1114
1115    /**
1116     * @param value The status of the request.
1117     */
1118    public DeviceRequest setStatus(DeviceRequestStatus value) { 
1119      if (value == null)
1120        this.status = null;
1121      else {
1122        if (this.status == null)
1123          this.status = new Enumeration<DeviceRequestStatus>(new DeviceRequestStatusEnumFactory());
1124        this.status.setValue(value);
1125      }
1126      return this;
1127    }
1128
1129    /**
1130     * @return {@link #intent} (Whether the request is a proposal, plan, an original order or a reflex order.)
1131     */
1132    public CodeableConcept getIntent() { 
1133      if (this.intent == null)
1134        if (Configuration.errorOnAutoCreate())
1135          throw new Error("Attempt to auto-create DeviceRequest.intent");
1136        else if (Configuration.doAutoCreate())
1137          this.intent = new CodeableConcept(); // cc
1138      return this.intent;
1139    }
1140
1141    public boolean hasIntent() { 
1142      return this.intent != null && !this.intent.isEmpty();
1143    }
1144
1145    /**
1146     * @param value {@link #intent} (Whether the request is a proposal, plan, an original order or a reflex order.)
1147     */
1148    public DeviceRequest setIntent(CodeableConcept value)  { 
1149      this.intent = value;
1150      return this;
1151    }
1152
1153    /**
1154     * @return {@link #priority} (Indicates how quickly the {{title}} should be addressed with respect to other requests.). This is the underlying object with id, value and extensions. The accessor "getPriority" gives direct access to the value
1155     */
1156    public Enumeration<RequestPriority> getPriorityElement() { 
1157      if (this.priority == null)
1158        if (Configuration.errorOnAutoCreate())
1159          throw new Error("Attempt to auto-create DeviceRequest.priority");
1160        else if (Configuration.doAutoCreate())
1161          this.priority = new Enumeration<RequestPriority>(new RequestPriorityEnumFactory()); // bb
1162      return this.priority;
1163    }
1164
1165    public boolean hasPriorityElement() { 
1166      return this.priority != null && !this.priority.isEmpty();
1167    }
1168
1169    public boolean hasPriority() { 
1170      return this.priority != null && !this.priority.isEmpty();
1171    }
1172
1173    /**
1174     * @param value {@link #priority} (Indicates how quickly the {{title}} should be addressed with respect to other requests.). This is the underlying object with id, value and extensions. The accessor "getPriority" gives direct access to the value
1175     */
1176    public DeviceRequest setPriorityElement(Enumeration<RequestPriority> value) { 
1177      this.priority = value;
1178      return this;
1179    }
1180
1181    /**
1182     * @return Indicates how quickly the {{title}} should be addressed with respect to other requests.
1183     */
1184    public RequestPriority getPriority() { 
1185      return this.priority == null ? null : this.priority.getValue();
1186    }
1187
1188    /**
1189     * @param value Indicates how quickly the {{title}} should be addressed with respect to other requests.
1190     */
1191    public DeviceRequest setPriority(RequestPriority value) { 
1192      if (value == null)
1193        this.priority = null;
1194      else {
1195        if (this.priority == null)
1196          this.priority = new Enumeration<RequestPriority>(new RequestPriorityEnumFactory());
1197        this.priority.setValue(value);
1198      }
1199      return this;
1200    }
1201
1202    /**
1203     * @return {@link #code} (The details of the device to be used.)
1204     */
1205    public Type getCode() { 
1206      return this.code;
1207    }
1208
1209    /**
1210     * @return {@link #code} (The details of the device to be used.)
1211     */
1212    public Reference getCodeReference() throws FHIRException { 
1213      if (this.code == null)
1214        return null;
1215      if (!(this.code instanceof Reference))
1216        throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.code.getClass().getName()+" was encountered");
1217      return (Reference) this.code;
1218    }
1219
1220    public boolean hasCodeReference() { 
1221      return this != null && this.code instanceof Reference;
1222    }
1223
1224    /**
1225     * @return {@link #code} (The details of the device to be used.)
1226     */
1227    public CodeableConcept getCodeCodeableConcept() throws FHIRException { 
1228      if (this.code == null)
1229        return null;
1230      if (!(this.code instanceof CodeableConcept))
1231        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.code.getClass().getName()+" was encountered");
1232      return (CodeableConcept) this.code;
1233    }
1234
1235    public boolean hasCodeCodeableConcept() { 
1236      return this != null && this.code instanceof CodeableConcept;
1237    }
1238
1239    public boolean hasCode() { 
1240      return this.code != null && !this.code.isEmpty();
1241    }
1242
1243    /**
1244     * @param value {@link #code} (The details of the device to be used.)
1245     */
1246    public DeviceRequest setCode(Type value) throws FHIRFormatError { 
1247      if (value != null && !(value instanceof Reference || value instanceof CodeableConcept))
1248        throw new FHIRFormatError("Not the right type for DeviceRequest.code[x]: "+value.fhirType());
1249      this.code = value;
1250      return this;
1251    }
1252
1253    /**
1254     * @return {@link #subject} (The patient who will use the device.)
1255     */
1256    public Reference getSubject() { 
1257      if (this.subject == null)
1258        if (Configuration.errorOnAutoCreate())
1259          throw new Error("Attempt to auto-create DeviceRequest.subject");
1260        else if (Configuration.doAutoCreate())
1261          this.subject = new Reference(); // cc
1262      return this.subject;
1263    }
1264
1265    public boolean hasSubject() { 
1266      return this.subject != null && !this.subject.isEmpty();
1267    }
1268
1269    /**
1270     * @param value {@link #subject} (The patient who will use the device.)
1271     */
1272    public DeviceRequest setSubject(Reference value)  { 
1273      this.subject = value;
1274      return this;
1275    }
1276
1277    /**
1278     * @return {@link #subject} 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 patient who will use the device.)
1279     */
1280    public Resource getSubjectTarget() { 
1281      return this.subjectTarget;
1282    }
1283
1284    /**
1285     * @param value {@link #subject} 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 patient who will use the device.)
1286     */
1287    public DeviceRequest setSubjectTarget(Resource value) { 
1288      this.subjectTarget = value;
1289      return this;
1290    }
1291
1292    /**
1293     * @return {@link #context} (An encounter that provides additional context in which this request is made.)
1294     */
1295    public Reference getContext() { 
1296      if (this.context == null)
1297        if (Configuration.errorOnAutoCreate())
1298          throw new Error("Attempt to auto-create DeviceRequest.context");
1299        else if (Configuration.doAutoCreate())
1300          this.context = new Reference(); // cc
1301      return this.context;
1302    }
1303
1304    public boolean hasContext() { 
1305      return this.context != null && !this.context.isEmpty();
1306    }
1307
1308    /**
1309     * @param value {@link #context} (An encounter that provides additional context in which this request is made.)
1310     */
1311    public DeviceRequest setContext(Reference value)  { 
1312      this.context = value;
1313      return this;
1314    }
1315
1316    /**
1317     * @return {@link #context} 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 encounter that provides additional context in which this request is made.)
1318     */
1319    public Resource getContextTarget() { 
1320      return this.contextTarget;
1321    }
1322
1323    /**
1324     * @param value {@link #context} 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 encounter that provides additional context in which this request is made.)
1325     */
1326    public DeviceRequest setContextTarget(Resource value) { 
1327      this.contextTarget = value;
1328      return this;
1329    }
1330
1331    /**
1332     * @return {@link #occurrence} (The timing schedule for the use of the device. The Schedule data type allows many different expressions, for example. "Every 8 hours"; "Three times a day"; "1/2 an hour before breakfast for 10 days from 23-Dec 2011:"; "15 Oct 2013, 17 Oct 2013 and 1 Nov 2013".)
1333     */
1334    public Type getOccurrence() { 
1335      return this.occurrence;
1336    }
1337
1338    /**
1339     * @return {@link #occurrence} (The timing schedule for the use of the device. The Schedule data type allows many different expressions, for example. "Every 8 hours"; "Three times a day"; "1/2 an hour before breakfast for 10 days from 23-Dec 2011:"; "15 Oct 2013, 17 Oct 2013 and 1 Nov 2013".)
1340     */
1341    public DateTimeType getOccurrenceDateTimeType() throws FHIRException { 
1342      if (this.occurrence == null)
1343        return null;
1344      if (!(this.occurrence instanceof DateTimeType))
1345        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.occurrence.getClass().getName()+" was encountered");
1346      return (DateTimeType) this.occurrence;
1347    }
1348
1349    public boolean hasOccurrenceDateTimeType() { 
1350      return this != null && this.occurrence instanceof DateTimeType;
1351    }
1352
1353    /**
1354     * @return {@link #occurrence} (The timing schedule for the use of the device. The Schedule data type allows many different expressions, for example. "Every 8 hours"; "Three times a day"; "1/2 an hour before breakfast for 10 days from 23-Dec 2011:"; "15 Oct 2013, 17 Oct 2013 and 1 Nov 2013".)
1355     */
1356    public Period getOccurrencePeriod() throws FHIRException { 
1357      if (this.occurrence == null)
1358        return null;
1359      if (!(this.occurrence instanceof Period))
1360        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.occurrence.getClass().getName()+" was encountered");
1361      return (Period) this.occurrence;
1362    }
1363
1364    public boolean hasOccurrencePeriod() { 
1365      return this != null && this.occurrence instanceof Period;
1366    }
1367
1368    /**
1369     * @return {@link #occurrence} (The timing schedule for the use of the device. The Schedule data type allows many different expressions, for example. "Every 8 hours"; "Three times a day"; "1/2 an hour before breakfast for 10 days from 23-Dec 2011:"; "15 Oct 2013, 17 Oct 2013 and 1 Nov 2013".)
1370     */
1371    public Timing getOccurrenceTiming() throws FHIRException { 
1372      if (this.occurrence == null)
1373        return null;
1374      if (!(this.occurrence instanceof Timing))
1375        throw new FHIRException("Type mismatch: the type Timing was expected, but "+this.occurrence.getClass().getName()+" was encountered");
1376      return (Timing) this.occurrence;
1377    }
1378
1379    public boolean hasOccurrenceTiming() { 
1380      return this != null && this.occurrence instanceof Timing;
1381    }
1382
1383    public boolean hasOccurrence() { 
1384      return this.occurrence != null && !this.occurrence.isEmpty();
1385    }
1386
1387    /**
1388     * @param value {@link #occurrence} (The timing schedule for the use of the device. The Schedule data type allows many different expressions, for example. "Every 8 hours"; "Three times a day"; "1/2 an hour before breakfast for 10 days from 23-Dec 2011:"; "15 Oct 2013, 17 Oct 2013 and 1 Nov 2013".)
1389     */
1390    public DeviceRequest setOccurrence(Type value) throws FHIRFormatError { 
1391      if (value != null && !(value instanceof DateTimeType || value instanceof Period || value instanceof Timing))
1392        throw new FHIRFormatError("Not the right type for DeviceRequest.occurrence[x]: "+value.fhirType());
1393      this.occurrence = value;
1394      return this;
1395    }
1396
1397    /**
1398     * @return {@link #authoredOn} (When the request transitioned to being actionable.). This is the underlying object with id, value and extensions. The accessor "getAuthoredOn" gives direct access to the value
1399     */
1400    public DateTimeType getAuthoredOnElement() { 
1401      if (this.authoredOn == null)
1402        if (Configuration.errorOnAutoCreate())
1403          throw new Error("Attempt to auto-create DeviceRequest.authoredOn");
1404        else if (Configuration.doAutoCreate())
1405          this.authoredOn = new DateTimeType(); // bb
1406      return this.authoredOn;
1407    }
1408
1409    public boolean hasAuthoredOnElement() { 
1410      return this.authoredOn != null && !this.authoredOn.isEmpty();
1411    }
1412
1413    public boolean hasAuthoredOn() { 
1414      return this.authoredOn != null && !this.authoredOn.isEmpty();
1415    }
1416
1417    /**
1418     * @param value {@link #authoredOn} (When the request transitioned to being actionable.). This is the underlying object with id, value and extensions. The accessor "getAuthoredOn" gives direct access to the value
1419     */
1420    public DeviceRequest setAuthoredOnElement(DateTimeType value) { 
1421      this.authoredOn = value;
1422      return this;
1423    }
1424
1425    /**
1426     * @return When the request transitioned to being actionable.
1427     */
1428    public Date getAuthoredOn() { 
1429      return this.authoredOn == null ? null : this.authoredOn.getValue();
1430    }
1431
1432    /**
1433     * @param value When the request transitioned to being actionable.
1434     */
1435    public DeviceRequest setAuthoredOn(Date value) { 
1436      if (value == null)
1437        this.authoredOn = null;
1438      else {
1439        if (this.authoredOn == null)
1440          this.authoredOn = new DateTimeType();
1441        this.authoredOn.setValue(value);
1442      }
1443      return this;
1444    }
1445
1446    /**
1447     * @return {@link #requester} (The individual who initiated the request and has responsibility for its activation.)
1448     */
1449    public DeviceRequestRequesterComponent getRequester() { 
1450      if (this.requester == null)
1451        if (Configuration.errorOnAutoCreate())
1452          throw new Error("Attempt to auto-create DeviceRequest.requester");
1453        else if (Configuration.doAutoCreate())
1454          this.requester = new DeviceRequestRequesterComponent(); // cc
1455      return this.requester;
1456    }
1457
1458    public boolean hasRequester() { 
1459      return this.requester != null && !this.requester.isEmpty();
1460    }
1461
1462    /**
1463     * @param value {@link #requester} (The individual who initiated the request and has responsibility for its activation.)
1464     */
1465    public DeviceRequest setRequester(DeviceRequestRequesterComponent value)  { 
1466      this.requester = value;
1467      return this;
1468    }
1469
1470    /**
1471     * @return {@link #performerType} (Desired type of performer for doing the diagnostic testing.)
1472     */
1473    public CodeableConcept getPerformerType() { 
1474      if (this.performerType == null)
1475        if (Configuration.errorOnAutoCreate())
1476          throw new Error("Attempt to auto-create DeviceRequest.performerType");
1477        else if (Configuration.doAutoCreate())
1478          this.performerType = new CodeableConcept(); // cc
1479      return this.performerType;
1480    }
1481
1482    public boolean hasPerformerType() { 
1483      return this.performerType != null && !this.performerType.isEmpty();
1484    }
1485
1486    /**
1487     * @param value {@link #performerType} (Desired type of performer for doing the diagnostic testing.)
1488     */
1489    public DeviceRequest setPerformerType(CodeableConcept value)  { 
1490      this.performerType = value;
1491      return this;
1492    }
1493
1494    /**
1495     * @return {@link #performer} (The desired perfomer for doing the diagnostic testing.)
1496     */
1497    public Reference getPerformer() { 
1498      if (this.performer == null)
1499        if (Configuration.errorOnAutoCreate())
1500          throw new Error("Attempt to auto-create DeviceRequest.performer");
1501        else if (Configuration.doAutoCreate())
1502          this.performer = new Reference(); // cc
1503      return this.performer;
1504    }
1505
1506    public boolean hasPerformer() { 
1507      return this.performer != null && !this.performer.isEmpty();
1508    }
1509
1510    /**
1511     * @param value {@link #performer} (The desired perfomer for doing the diagnostic testing.)
1512     */
1513    public DeviceRequest setPerformer(Reference value)  { 
1514      this.performer = value;
1515      return this;
1516    }
1517
1518    /**
1519     * @return {@link #performer} 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 desired perfomer for doing the diagnostic testing.)
1520     */
1521    public Resource getPerformerTarget() { 
1522      return this.performerTarget;
1523    }
1524
1525    /**
1526     * @param value {@link #performer} 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 desired perfomer for doing the diagnostic testing.)
1527     */
1528    public DeviceRequest setPerformerTarget(Resource value) { 
1529      this.performerTarget = value;
1530      return this;
1531    }
1532
1533    /**
1534     * @return {@link #reasonCode} (Reason or justification for the use of this device.)
1535     */
1536    public List<CodeableConcept> getReasonCode() { 
1537      if (this.reasonCode == null)
1538        this.reasonCode = new ArrayList<CodeableConcept>();
1539      return this.reasonCode;
1540    }
1541
1542    /**
1543     * @return Returns a reference to <code>this</code> for easy method chaining
1544     */
1545    public DeviceRequest setReasonCode(List<CodeableConcept> theReasonCode) { 
1546      this.reasonCode = theReasonCode;
1547      return this;
1548    }
1549
1550    public boolean hasReasonCode() { 
1551      if (this.reasonCode == null)
1552        return false;
1553      for (CodeableConcept item : this.reasonCode)
1554        if (!item.isEmpty())
1555          return true;
1556      return false;
1557    }
1558
1559    public CodeableConcept addReasonCode() { //3
1560      CodeableConcept t = new CodeableConcept();
1561      if (this.reasonCode == null)
1562        this.reasonCode = new ArrayList<CodeableConcept>();
1563      this.reasonCode.add(t);
1564      return t;
1565    }
1566
1567    public DeviceRequest addReasonCode(CodeableConcept t) { //3
1568      if (t == null)
1569        return this;
1570      if (this.reasonCode == null)
1571        this.reasonCode = new ArrayList<CodeableConcept>();
1572      this.reasonCode.add(t);
1573      return this;
1574    }
1575
1576    /**
1577     * @return The first repetition of repeating field {@link #reasonCode}, creating it if it does not already exist
1578     */
1579    public CodeableConcept getReasonCodeFirstRep() { 
1580      if (getReasonCode().isEmpty()) {
1581        addReasonCode();
1582      }
1583      return getReasonCode().get(0);
1584    }
1585
1586    /**
1587     * @return {@link #reasonReference} (Reason or justification for the use of this device.)
1588     */
1589    public List<Reference> getReasonReference() { 
1590      if (this.reasonReference == null)
1591        this.reasonReference = new ArrayList<Reference>();
1592      return this.reasonReference;
1593    }
1594
1595    /**
1596     * @return Returns a reference to <code>this</code> for easy method chaining
1597     */
1598    public DeviceRequest setReasonReference(List<Reference> theReasonReference) { 
1599      this.reasonReference = theReasonReference;
1600      return this;
1601    }
1602
1603    public boolean hasReasonReference() { 
1604      if (this.reasonReference == null)
1605        return false;
1606      for (Reference item : this.reasonReference)
1607        if (!item.isEmpty())
1608          return true;
1609      return false;
1610    }
1611
1612    public Reference addReasonReference() { //3
1613      Reference t = new Reference();
1614      if (this.reasonReference == null)
1615        this.reasonReference = new ArrayList<Reference>();
1616      this.reasonReference.add(t);
1617      return t;
1618    }
1619
1620    public DeviceRequest addReasonReference(Reference t) { //3
1621      if (t == null)
1622        return this;
1623      if (this.reasonReference == null)
1624        this.reasonReference = new ArrayList<Reference>();
1625      this.reasonReference.add(t);
1626      return this;
1627    }
1628
1629    /**
1630     * @return The first repetition of repeating field {@link #reasonReference}, creating it if it does not already exist
1631     */
1632    public Reference getReasonReferenceFirstRep() { 
1633      if (getReasonReference().isEmpty()) {
1634        addReasonReference();
1635      }
1636      return getReasonReference().get(0);
1637    }
1638
1639    /**
1640     * @deprecated Use Reference#setResource(IBaseResource) instead
1641     */
1642    @Deprecated
1643    public List<Resource> getReasonReferenceTarget() { 
1644      if (this.reasonReferenceTarget == null)
1645        this.reasonReferenceTarget = new ArrayList<Resource>();
1646      return this.reasonReferenceTarget;
1647    }
1648
1649    /**
1650     * @return {@link #supportingInfo} (Additional clinical information about the patient that may influence the request fulfilment.  For example, this may includes body where on the subject's the device will be used ( i.e. the target site).)
1651     */
1652    public List<Reference> getSupportingInfo() { 
1653      if (this.supportingInfo == null)
1654        this.supportingInfo = new ArrayList<Reference>();
1655      return this.supportingInfo;
1656    }
1657
1658    /**
1659     * @return Returns a reference to <code>this</code> for easy method chaining
1660     */
1661    public DeviceRequest setSupportingInfo(List<Reference> theSupportingInfo) { 
1662      this.supportingInfo = theSupportingInfo;
1663      return this;
1664    }
1665
1666    public boolean hasSupportingInfo() { 
1667      if (this.supportingInfo == null)
1668        return false;
1669      for (Reference item : this.supportingInfo)
1670        if (!item.isEmpty())
1671          return true;
1672      return false;
1673    }
1674
1675    public Reference addSupportingInfo() { //3
1676      Reference t = new Reference();
1677      if (this.supportingInfo == null)
1678        this.supportingInfo = new ArrayList<Reference>();
1679      this.supportingInfo.add(t);
1680      return t;
1681    }
1682
1683    public DeviceRequest addSupportingInfo(Reference t) { //3
1684      if (t == null)
1685        return this;
1686      if (this.supportingInfo == null)
1687        this.supportingInfo = new ArrayList<Reference>();
1688      this.supportingInfo.add(t);
1689      return this;
1690    }
1691
1692    /**
1693     * @return The first repetition of repeating field {@link #supportingInfo}, creating it if it does not already exist
1694     */
1695    public Reference getSupportingInfoFirstRep() { 
1696      if (getSupportingInfo().isEmpty()) {
1697        addSupportingInfo();
1698      }
1699      return getSupportingInfo().get(0);
1700    }
1701
1702    /**
1703     * @deprecated Use Reference#setResource(IBaseResource) instead
1704     */
1705    @Deprecated
1706    public List<Resource> getSupportingInfoTarget() { 
1707      if (this.supportingInfoTarget == null)
1708        this.supportingInfoTarget = new ArrayList<Resource>();
1709      return this.supportingInfoTarget;
1710    }
1711
1712    /**
1713     * @return {@link #note} (Details about this request that were not represented at all or sufficiently in one of the attributes provided in a class. These may include for example a comment, an instruction, or a note associated with the statement.)
1714     */
1715    public List<Annotation> getNote() { 
1716      if (this.note == null)
1717        this.note = new ArrayList<Annotation>();
1718      return this.note;
1719    }
1720
1721    /**
1722     * @return Returns a reference to <code>this</code> for easy method chaining
1723     */
1724    public DeviceRequest setNote(List<Annotation> theNote) { 
1725      this.note = theNote;
1726      return this;
1727    }
1728
1729    public boolean hasNote() { 
1730      if (this.note == null)
1731        return false;
1732      for (Annotation item : this.note)
1733        if (!item.isEmpty())
1734          return true;
1735      return false;
1736    }
1737
1738    public Annotation addNote() { //3
1739      Annotation t = new Annotation();
1740      if (this.note == null)
1741        this.note = new ArrayList<Annotation>();
1742      this.note.add(t);
1743      return t;
1744    }
1745
1746    public DeviceRequest addNote(Annotation t) { //3
1747      if (t == null)
1748        return this;
1749      if (this.note == null)
1750        this.note = new ArrayList<Annotation>();
1751      this.note.add(t);
1752      return this;
1753    }
1754
1755    /**
1756     * @return The first repetition of repeating field {@link #note}, creating it if it does not already exist
1757     */
1758    public Annotation getNoteFirstRep() { 
1759      if (getNote().isEmpty()) {
1760        addNote();
1761      }
1762      return getNote().get(0);
1763    }
1764
1765    /**
1766     * @return {@link #relevantHistory} (Key events in the history of the request.)
1767     */
1768    public List<Reference> getRelevantHistory() { 
1769      if (this.relevantHistory == null)
1770        this.relevantHistory = new ArrayList<Reference>();
1771      return this.relevantHistory;
1772    }
1773
1774    /**
1775     * @return Returns a reference to <code>this</code> for easy method chaining
1776     */
1777    public DeviceRequest setRelevantHistory(List<Reference> theRelevantHistory) { 
1778      this.relevantHistory = theRelevantHistory;
1779      return this;
1780    }
1781
1782    public boolean hasRelevantHistory() { 
1783      if (this.relevantHistory == null)
1784        return false;
1785      for (Reference item : this.relevantHistory)
1786        if (!item.isEmpty())
1787          return true;
1788      return false;
1789    }
1790
1791    public Reference addRelevantHistory() { //3
1792      Reference t = new Reference();
1793      if (this.relevantHistory == null)
1794        this.relevantHistory = new ArrayList<Reference>();
1795      this.relevantHistory.add(t);
1796      return t;
1797    }
1798
1799    public DeviceRequest addRelevantHistory(Reference t) { //3
1800      if (t == null)
1801        return this;
1802      if (this.relevantHistory == null)
1803        this.relevantHistory = new ArrayList<Reference>();
1804      this.relevantHistory.add(t);
1805      return this;
1806    }
1807
1808    /**
1809     * @return The first repetition of repeating field {@link #relevantHistory}, creating it if it does not already exist
1810     */
1811    public Reference getRelevantHistoryFirstRep() { 
1812      if (getRelevantHistory().isEmpty()) {
1813        addRelevantHistory();
1814      }
1815      return getRelevantHistory().get(0);
1816    }
1817
1818    /**
1819     * @deprecated Use Reference#setResource(IBaseResource) instead
1820     */
1821    @Deprecated
1822    public List<Provenance> getRelevantHistoryTarget() { 
1823      if (this.relevantHistoryTarget == null)
1824        this.relevantHistoryTarget = new ArrayList<Provenance>();
1825      return this.relevantHistoryTarget;
1826    }
1827
1828    /**
1829     * @deprecated Use Reference#setResource(IBaseResource) instead
1830     */
1831    @Deprecated
1832    public Provenance addRelevantHistoryTarget() { 
1833      Provenance r = new Provenance();
1834      if (this.relevantHistoryTarget == null)
1835        this.relevantHistoryTarget = new ArrayList<Provenance>();
1836      this.relevantHistoryTarget.add(r);
1837      return r;
1838    }
1839
1840      protected void listChildren(List<Property> children) {
1841        super.listChildren(children);
1842        children.add(new Property("identifier", "Identifier", "Identifiers assigned to this order by the orderer or by the receiver.", 0, java.lang.Integer.MAX_VALUE, identifier));
1843        children.add(new Property("definition", "Reference(ActivityDefinition|PlanDefinition)", "Protocol or definition followed by this request. For example: The proposed act must be performed if the indicated conditions occur, e.g.., shortness of breath, SpO2 less than x%.", 0, java.lang.Integer.MAX_VALUE, definition));
1844        children.add(new Property("basedOn", "Reference(Any)", "Plan/proposal/order fulfilled by this request.", 0, java.lang.Integer.MAX_VALUE, basedOn));
1845        children.add(new Property("priorRequest", "Reference(Any)", "The request takes the place of the referenced completed or terminated request(s).", 0, java.lang.Integer.MAX_VALUE, priorRequest));
1846        children.add(new Property("groupIdentifier", "Identifier", "Composite request this is part of.", 0, 1, groupIdentifier));
1847        children.add(new Property("status", "code", "The status of the request.", 0, 1, status));
1848        children.add(new Property("intent", "CodeableConcept", "Whether the request is a proposal, plan, an original order or a reflex order.", 0, 1, intent));
1849        children.add(new Property("priority", "code", "Indicates how quickly the {{title}} should be addressed with respect to other requests.", 0, 1, priority));
1850        children.add(new Property("code[x]", "Reference(Device)|CodeableConcept", "The details of the device to be used.", 0, 1, code));
1851        children.add(new Property("subject", "Reference(Patient|Group|Location|Device)", "The patient who will use the device.", 0, 1, subject));
1852        children.add(new Property("context", "Reference(Encounter|EpisodeOfCare)", "An encounter that provides additional context in which this request is made.", 0, 1, context));
1853        children.add(new Property("occurrence[x]", "dateTime|Period|Timing", "The timing schedule for the use of the device. The Schedule data type allows many different expressions, for example. \"Every 8 hours\"; \"Three times a day\"; \"1/2 an hour before breakfast for 10 days from 23-Dec 2011:\"; \"15 Oct 2013, 17 Oct 2013 and 1 Nov 2013\".", 0, 1, occurrence));
1854        children.add(new Property("authoredOn", "dateTime", "When the request transitioned to being actionable.", 0, 1, authoredOn));
1855        children.add(new Property("requester", "", "The individual who initiated the request and has responsibility for its activation.", 0, 1, requester));
1856        children.add(new Property("performerType", "CodeableConcept", "Desired type of performer for doing the diagnostic testing.", 0, 1, performerType));
1857        children.add(new Property("performer", "Reference(Practitioner|Organization|Patient|Device|RelatedPerson|HealthcareService)", "The desired perfomer for doing the diagnostic testing.", 0, 1, performer));
1858        children.add(new Property("reasonCode", "CodeableConcept", "Reason or justification for the use of this device.", 0, java.lang.Integer.MAX_VALUE, reasonCode));
1859        children.add(new Property("reasonReference", "Reference(Any)", "Reason or justification for the use of this device.", 0, java.lang.Integer.MAX_VALUE, reasonReference));
1860        children.add(new Property("supportingInfo", "Reference(Any)", "Additional clinical information about the patient that may influence the request fulfilment.  For example, this may includes body where on the subject's the device will be used ( i.e. the target site).", 0, java.lang.Integer.MAX_VALUE, supportingInfo));
1861        children.add(new Property("note", "Annotation", "Details about this request that were not represented at all or sufficiently in one of the attributes provided in a class. These may include for example a comment, an instruction, or a note associated with the statement.", 0, java.lang.Integer.MAX_VALUE, note));
1862        children.add(new Property("relevantHistory", "Reference(Provenance)", "Key events in the history of the request.", 0, java.lang.Integer.MAX_VALUE, relevantHistory));
1863      }
1864
1865      @Override
1866      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1867        switch (_hash) {
1868        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Identifiers assigned to this order by the orderer or by the receiver.", 0, java.lang.Integer.MAX_VALUE, identifier);
1869        case -1014418093: /*definition*/  return new Property("definition", "Reference(ActivityDefinition|PlanDefinition)", "Protocol or definition followed by this request. For example: The proposed act must be performed if the indicated conditions occur, e.g.., shortness of breath, SpO2 less than x%.", 0, java.lang.Integer.MAX_VALUE, definition);
1870        case -332612366: /*basedOn*/  return new Property("basedOn", "Reference(Any)", "Plan/proposal/order fulfilled by this request.", 0, java.lang.Integer.MAX_VALUE, basedOn);
1871        case 237568101: /*priorRequest*/  return new Property("priorRequest", "Reference(Any)", "The request takes the place of the referenced completed or terminated request(s).", 0, java.lang.Integer.MAX_VALUE, priorRequest);
1872        case -445338488: /*groupIdentifier*/  return new Property("groupIdentifier", "Identifier", "Composite request this is part of.", 0, 1, groupIdentifier);
1873        case -892481550: /*status*/  return new Property("status", "code", "The status of the request.", 0, 1, status);
1874        case -1183762788: /*intent*/  return new Property("intent", "CodeableConcept", "Whether the request is a proposal, plan, an original order or a reflex order.", 0, 1, intent);
1875        case -1165461084: /*priority*/  return new Property("priority", "code", "Indicates how quickly the {{title}} should be addressed with respect to other requests.", 0, 1, priority);
1876        case 941839219: /*code[x]*/  return new Property("code[x]", "Reference(Device)|CodeableConcept", "The details of the device to be used.", 0, 1, code);
1877        case 3059181: /*code*/  return new Property("code[x]", "Reference(Device)|CodeableConcept", "The details of the device to be used.", 0, 1, code);
1878        case 1565461470: /*codeReference*/  return new Property("code[x]", "Reference(Device)|CodeableConcept", "The details of the device to be used.", 0, 1, code);
1879        case 4899316: /*codeCodeableConcept*/  return new Property("code[x]", "Reference(Device)|CodeableConcept", "The details of the device to be used.", 0, 1, code);
1880        case -1867885268: /*subject*/  return new Property("subject", "Reference(Patient|Group|Location|Device)", "The patient who will use the device.", 0, 1, subject);
1881        case 951530927: /*context*/  return new Property("context", "Reference(Encounter|EpisodeOfCare)", "An encounter that provides additional context in which this request is made.", 0, 1, context);
1882        case -2022646513: /*occurrence[x]*/  return new Property("occurrence[x]", "dateTime|Period|Timing", "The timing schedule for the use of the device. The Schedule data type allows many different expressions, for example. \"Every 8 hours\"; \"Three times a day\"; \"1/2 an hour before breakfast for 10 days from 23-Dec 2011:\"; \"15 Oct 2013, 17 Oct 2013 and 1 Nov 2013\".", 0, 1, occurrence);
1883        case 1687874001: /*occurrence*/  return new Property("occurrence[x]", "dateTime|Period|Timing", "The timing schedule for the use of the device. The Schedule data type allows many different expressions, for example. \"Every 8 hours\"; \"Three times a day\"; \"1/2 an hour before breakfast for 10 days from 23-Dec 2011:\"; \"15 Oct 2013, 17 Oct 2013 and 1 Nov 2013\".", 0, 1, occurrence);
1884        case -298443636: /*occurrenceDateTime*/  return new Property("occurrence[x]", "dateTime|Period|Timing", "The timing schedule for the use of the device. The Schedule data type allows many different expressions, for example. \"Every 8 hours\"; \"Three times a day\"; \"1/2 an hour before breakfast for 10 days from 23-Dec 2011:\"; \"15 Oct 2013, 17 Oct 2013 and 1 Nov 2013\".", 0, 1, occurrence);
1885        case 1397156594: /*occurrencePeriod*/  return new Property("occurrence[x]", "dateTime|Period|Timing", "The timing schedule for the use of the device. The Schedule data type allows many different expressions, for example. \"Every 8 hours\"; \"Three times a day\"; \"1/2 an hour before breakfast for 10 days from 23-Dec 2011:\"; \"15 Oct 2013, 17 Oct 2013 and 1 Nov 2013\".", 0, 1, occurrence);
1886        case 1515218299: /*occurrenceTiming*/  return new Property("occurrence[x]", "dateTime|Period|Timing", "The timing schedule for the use of the device. The Schedule data type allows many different expressions, for example. \"Every 8 hours\"; \"Three times a day\"; \"1/2 an hour before breakfast for 10 days from 23-Dec 2011:\"; \"15 Oct 2013, 17 Oct 2013 and 1 Nov 2013\".", 0, 1, occurrence);
1887        case -1500852503: /*authoredOn*/  return new Property("authoredOn", "dateTime", "When the request transitioned to being actionable.", 0, 1, authoredOn);
1888        case 693933948: /*requester*/  return new Property("requester", "", "The individual who initiated the request and has responsibility for its activation.", 0, 1, requester);
1889        case -901444568: /*performerType*/  return new Property("performerType", "CodeableConcept", "Desired type of performer for doing the diagnostic testing.", 0, 1, performerType);
1890        case 481140686: /*performer*/  return new Property("performer", "Reference(Practitioner|Organization|Patient|Device|RelatedPerson|HealthcareService)", "The desired perfomer for doing the diagnostic testing.", 0, 1, performer);
1891        case 722137681: /*reasonCode*/  return new Property("reasonCode", "CodeableConcept", "Reason or justification for the use of this device.", 0, java.lang.Integer.MAX_VALUE, reasonCode);
1892        case -1146218137: /*reasonReference*/  return new Property("reasonReference", "Reference(Any)", "Reason or justification for the use of this device.", 0, java.lang.Integer.MAX_VALUE, reasonReference);
1893        case 1922406657: /*supportingInfo*/  return new Property("supportingInfo", "Reference(Any)", "Additional clinical information about the patient that may influence the request fulfilment.  For example, this may includes body where on the subject's the device will be used ( i.e. the target site).", 0, java.lang.Integer.MAX_VALUE, supportingInfo);
1894        case 3387378: /*note*/  return new Property("note", "Annotation", "Details about this request that were not represented at all or sufficiently in one of the attributes provided in a class. These may include for example a comment, an instruction, or a note associated with the statement.", 0, java.lang.Integer.MAX_VALUE, note);
1895        case 1538891575: /*relevantHistory*/  return new Property("relevantHistory", "Reference(Provenance)", "Key events in the history of the request.", 0, java.lang.Integer.MAX_VALUE, relevantHistory);
1896        default: return super.getNamedProperty(_hash, _name, _checkValid);
1897        }
1898
1899      }
1900
1901      @Override
1902      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1903        switch (hash) {
1904        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1905        case -1014418093: /*definition*/ return this.definition == null ? new Base[0] : this.definition.toArray(new Base[this.definition.size()]); // Reference
1906        case -332612366: /*basedOn*/ return this.basedOn == null ? new Base[0] : this.basedOn.toArray(new Base[this.basedOn.size()]); // Reference
1907        case 237568101: /*priorRequest*/ return this.priorRequest == null ? new Base[0] : this.priorRequest.toArray(new Base[this.priorRequest.size()]); // Reference
1908        case -445338488: /*groupIdentifier*/ return this.groupIdentifier == null ? new Base[0] : new Base[] {this.groupIdentifier}; // Identifier
1909        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<DeviceRequestStatus>
1910        case -1183762788: /*intent*/ return this.intent == null ? new Base[0] : new Base[] {this.intent}; // CodeableConcept
1911        case -1165461084: /*priority*/ return this.priority == null ? new Base[0] : new Base[] {this.priority}; // Enumeration<RequestPriority>
1912        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // Type
1913        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
1914        case 951530927: /*context*/ return this.context == null ? new Base[0] : new Base[] {this.context}; // Reference
1915        case 1687874001: /*occurrence*/ return this.occurrence == null ? new Base[0] : new Base[] {this.occurrence}; // Type
1916        case -1500852503: /*authoredOn*/ return this.authoredOn == null ? new Base[0] : new Base[] {this.authoredOn}; // DateTimeType
1917        case 693933948: /*requester*/ return this.requester == null ? new Base[0] : new Base[] {this.requester}; // DeviceRequestRequesterComponent
1918        case -901444568: /*performerType*/ return this.performerType == null ? new Base[0] : new Base[] {this.performerType}; // CodeableConcept
1919        case 481140686: /*performer*/ return this.performer == null ? new Base[0] : new Base[] {this.performer}; // Reference
1920        case 722137681: /*reasonCode*/ return this.reasonCode == null ? new Base[0] : this.reasonCode.toArray(new Base[this.reasonCode.size()]); // CodeableConcept
1921        case -1146218137: /*reasonReference*/ return this.reasonReference == null ? new Base[0] : this.reasonReference.toArray(new Base[this.reasonReference.size()]); // Reference
1922        case 1922406657: /*supportingInfo*/ return this.supportingInfo == null ? new Base[0] : this.supportingInfo.toArray(new Base[this.supportingInfo.size()]); // Reference
1923        case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
1924        case 1538891575: /*relevantHistory*/ return this.relevantHistory == null ? new Base[0] : this.relevantHistory.toArray(new Base[this.relevantHistory.size()]); // Reference
1925        default: return super.getProperty(hash, name, checkValid);
1926        }
1927
1928      }
1929
1930      @Override
1931      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1932        switch (hash) {
1933        case -1618432855: // identifier
1934          this.getIdentifier().add(castToIdentifier(value)); // Identifier
1935          return value;
1936        case -1014418093: // definition
1937          this.getDefinition().add(castToReference(value)); // Reference
1938          return value;
1939        case -332612366: // basedOn
1940          this.getBasedOn().add(castToReference(value)); // Reference
1941          return value;
1942        case 237568101: // priorRequest
1943          this.getPriorRequest().add(castToReference(value)); // Reference
1944          return value;
1945        case -445338488: // groupIdentifier
1946          this.groupIdentifier = castToIdentifier(value); // Identifier
1947          return value;
1948        case -892481550: // status
1949          value = new DeviceRequestStatusEnumFactory().fromType(castToCode(value));
1950          this.status = (Enumeration) value; // Enumeration<DeviceRequestStatus>
1951          return value;
1952        case -1183762788: // intent
1953          this.intent = castToCodeableConcept(value); // CodeableConcept
1954          return value;
1955        case -1165461084: // priority
1956          value = new RequestPriorityEnumFactory().fromType(castToCode(value));
1957          this.priority = (Enumeration) value; // Enumeration<RequestPriority>
1958          return value;
1959        case 3059181: // code
1960          this.code = castToType(value); // Type
1961          return value;
1962        case -1867885268: // subject
1963          this.subject = castToReference(value); // Reference
1964          return value;
1965        case 951530927: // context
1966          this.context = castToReference(value); // Reference
1967          return value;
1968        case 1687874001: // occurrence
1969          this.occurrence = castToType(value); // Type
1970          return value;
1971        case -1500852503: // authoredOn
1972          this.authoredOn = castToDateTime(value); // DateTimeType
1973          return value;
1974        case 693933948: // requester
1975          this.requester = (DeviceRequestRequesterComponent) value; // DeviceRequestRequesterComponent
1976          return value;
1977        case -901444568: // performerType
1978          this.performerType = castToCodeableConcept(value); // CodeableConcept
1979          return value;
1980        case 481140686: // performer
1981          this.performer = castToReference(value); // Reference
1982          return value;
1983        case 722137681: // reasonCode
1984          this.getReasonCode().add(castToCodeableConcept(value)); // CodeableConcept
1985          return value;
1986        case -1146218137: // reasonReference
1987          this.getReasonReference().add(castToReference(value)); // Reference
1988          return value;
1989        case 1922406657: // supportingInfo
1990          this.getSupportingInfo().add(castToReference(value)); // Reference
1991          return value;
1992        case 3387378: // note
1993          this.getNote().add(castToAnnotation(value)); // Annotation
1994          return value;
1995        case 1538891575: // relevantHistory
1996          this.getRelevantHistory().add(castToReference(value)); // Reference
1997          return value;
1998        default: return super.setProperty(hash, name, value);
1999        }
2000
2001      }
2002
2003      @Override
2004      public Base setProperty(String name, Base value) throws FHIRException {
2005        if (name.equals("identifier")) {
2006          this.getIdentifier().add(castToIdentifier(value));
2007        } else if (name.equals("definition")) {
2008          this.getDefinition().add(castToReference(value));
2009        } else if (name.equals("basedOn")) {
2010          this.getBasedOn().add(castToReference(value));
2011        } else if (name.equals("priorRequest")) {
2012          this.getPriorRequest().add(castToReference(value));
2013        } else if (name.equals("groupIdentifier")) {
2014          this.groupIdentifier = castToIdentifier(value); // Identifier
2015        } else if (name.equals("status")) {
2016          value = new DeviceRequestStatusEnumFactory().fromType(castToCode(value));
2017          this.status = (Enumeration) value; // Enumeration<DeviceRequestStatus>
2018        } else if (name.equals("intent")) {
2019          this.intent = castToCodeableConcept(value); // CodeableConcept
2020        } else if (name.equals("priority")) {
2021          value = new RequestPriorityEnumFactory().fromType(castToCode(value));
2022          this.priority = (Enumeration) value; // Enumeration<RequestPriority>
2023        } else if (name.equals("code[x]")) {
2024          this.code = castToType(value); // Type
2025        } else if (name.equals("subject")) {
2026          this.subject = castToReference(value); // Reference
2027        } else if (name.equals("context")) {
2028          this.context = castToReference(value); // Reference
2029        } else if (name.equals("occurrence[x]")) {
2030          this.occurrence = castToType(value); // Type
2031        } else if (name.equals("authoredOn")) {
2032          this.authoredOn = castToDateTime(value); // DateTimeType
2033        } else if (name.equals("requester")) {
2034          this.requester = (DeviceRequestRequesterComponent) value; // DeviceRequestRequesterComponent
2035        } else if (name.equals("performerType")) {
2036          this.performerType = castToCodeableConcept(value); // CodeableConcept
2037        } else if (name.equals("performer")) {
2038          this.performer = castToReference(value); // Reference
2039        } else if (name.equals("reasonCode")) {
2040          this.getReasonCode().add(castToCodeableConcept(value));
2041        } else if (name.equals("reasonReference")) {
2042          this.getReasonReference().add(castToReference(value));
2043        } else if (name.equals("supportingInfo")) {
2044          this.getSupportingInfo().add(castToReference(value));
2045        } else if (name.equals("note")) {
2046          this.getNote().add(castToAnnotation(value));
2047        } else if (name.equals("relevantHistory")) {
2048          this.getRelevantHistory().add(castToReference(value));
2049        } else
2050          return super.setProperty(name, value);
2051        return value;
2052      }
2053
2054      @Override
2055      public Base makeProperty(int hash, String name) throws FHIRException {
2056        switch (hash) {
2057        case -1618432855:  return addIdentifier(); 
2058        case -1014418093:  return addDefinition(); 
2059        case -332612366:  return addBasedOn(); 
2060        case 237568101:  return addPriorRequest(); 
2061        case -445338488:  return getGroupIdentifier(); 
2062        case -892481550:  return getStatusElement();
2063        case -1183762788:  return getIntent(); 
2064        case -1165461084:  return getPriorityElement();
2065        case 941839219:  return getCode(); 
2066        case 3059181:  return getCode(); 
2067        case -1867885268:  return getSubject(); 
2068        case 951530927:  return getContext(); 
2069        case -2022646513:  return getOccurrence(); 
2070        case 1687874001:  return getOccurrence(); 
2071        case -1500852503:  return getAuthoredOnElement();
2072        case 693933948:  return getRequester(); 
2073        case -901444568:  return getPerformerType(); 
2074        case 481140686:  return getPerformer(); 
2075        case 722137681:  return addReasonCode(); 
2076        case -1146218137:  return addReasonReference(); 
2077        case 1922406657:  return addSupportingInfo(); 
2078        case 3387378:  return addNote(); 
2079        case 1538891575:  return addRelevantHistory(); 
2080        default: return super.makeProperty(hash, name);
2081        }
2082
2083      }
2084
2085      @Override
2086      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2087        switch (hash) {
2088        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
2089        case -1014418093: /*definition*/ return new String[] {"Reference"};
2090        case -332612366: /*basedOn*/ return new String[] {"Reference"};
2091        case 237568101: /*priorRequest*/ return new String[] {"Reference"};
2092        case -445338488: /*groupIdentifier*/ return new String[] {"Identifier"};
2093        case -892481550: /*status*/ return new String[] {"code"};
2094        case -1183762788: /*intent*/ return new String[] {"CodeableConcept"};
2095        case -1165461084: /*priority*/ return new String[] {"code"};
2096        case 3059181: /*code*/ return new String[] {"Reference", "CodeableConcept"};
2097        case -1867885268: /*subject*/ return new String[] {"Reference"};
2098        case 951530927: /*context*/ return new String[] {"Reference"};
2099        case 1687874001: /*occurrence*/ return new String[] {"dateTime", "Period", "Timing"};
2100        case -1500852503: /*authoredOn*/ return new String[] {"dateTime"};
2101        case 693933948: /*requester*/ return new String[] {};
2102        case -901444568: /*performerType*/ return new String[] {"CodeableConcept"};
2103        case 481140686: /*performer*/ return new String[] {"Reference"};
2104        case 722137681: /*reasonCode*/ return new String[] {"CodeableConcept"};
2105        case -1146218137: /*reasonReference*/ return new String[] {"Reference"};
2106        case 1922406657: /*supportingInfo*/ return new String[] {"Reference"};
2107        case 3387378: /*note*/ return new String[] {"Annotation"};
2108        case 1538891575: /*relevantHistory*/ return new String[] {"Reference"};
2109        default: return super.getTypesForProperty(hash, name);
2110        }
2111
2112      }
2113
2114      @Override
2115      public Base addChild(String name) throws FHIRException {
2116        if (name.equals("identifier")) {
2117          return addIdentifier();
2118        }
2119        else if (name.equals("definition")) {
2120          return addDefinition();
2121        }
2122        else if (name.equals("basedOn")) {
2123          return addBasedOn();
2124        }
2125        else if (name.equals("priorRequest")) {
2126          return addPriorRequest();
2127        }
2128        else if (name.equals("groupIdentifier")) {
2129          this.groupIdentifier = new Identifier();
2130          return this.groupIdentifier;
2131        }
2132        else if (name.equals("status")) {
2133          throw new FHIRException("Cannot call addChild on a primitive type DeviceRequest.status");
2134        }
2135        else if (name.equals("intent")) {
2136          this.intent = new CodeableConcept();
2137          return this.intent;
2138        }
2139        else if (name.equals("priority")) {
2140          throw new FHIRException("Cannot call addChild on a primitive type DeviceRequest.priority");
2141        }
2142        else if (name.equals("codeReference")) {
2143          this.code = new Reference();
2144          return this.code;
2145        }
2146        else if (name.equals("codeCodeableConcept")) {
2147          this.code = new CodeableConcept();
2148          return this.code;
2149        }
2150        else if (name.equals("subject")) {
2151          this.subject = new Reference();
2152          return this.subject;
2153        }
2154        else if (name.equals("context")) {
2155          this.context = new Reference();
2156          return this.context;
2157        }
2158        else if (name.equals("occurrenceDateTime")) {
2159          this.occurrence = new DateTimeType();
2160          return this.occurrence;
2161        }
2162        else if (name.equals("occurrencePeriod")) {
2163          this.occurrence = new Period();
2164          return this.occurrence;
2165        }
2166        else if (name.equals("occurrenceTiming")) {
2167          this.occurrence = new Timing();
2168          return this.occurrence;
2169        }
2170        else if (name.equals("authoredOn")) {
2171          throw new FHIRException("Cannot call addChild on a primitive type DeviceRequest.authoredOn");
2172        }
2173        else if (name.equals("requester")) {
2174          this.requester = new DeviceRequestRequesterComponent();
2175          return this.requester;
2176        }
2177        else if (name.equals("performerType")) {
2178          this.performerType = new CodeableConcept();
2179          return this.performerType;
2180        }
2181        else if (name.equals("performer")) {
2182          this.performer = new Reference();
2183          return this.performer;
2184        }
2185        else if (name.equals("reasonCode")) {
2186          return addReasonCode();
2187        }
2188        else if (name.equals("reasonReference")) {
2189          return addReasonReference();
2190        }
2191        else if (name.equals("supportingInfo")) {
2192          return addSupportingInfo();
2193        }
2194        else if (name.equals("note")) {
2195          return addNote();
2196        }
2197        else if (name.equals("relevantHistory")) {
2198          return addRelevantHistory();
2199        }
2200        else
2201          return super.addChild(name);
2202      }
2203
2204  public String fhirType() {
2205    return "DeviceRequest";
2206
2207  }
2208
2209      public DeviceRequest copy() {
2210        DeviceRequest dst = new DeviceRequest();
2211        copyValues(dst);
2212        if (identifier != null) {
2213          dst.identifier = new ArrayList<Identifier>();
2214          for (Identifier i : identifier)
2215            dst.identifier.add(i.copy());
2216        };
2217        if (definition != null) {
2218          dst.definition = new ArrayList<Reference>();
2219          for (Reference i : definition)
2220            dst.definition.add(i.copy());
2221        };
2222        if (basedOn != null) {
2223          dst.basedOn = new ArrayList<Reference>();
2224          for (Reference i : basedOn)
2225            dst.basedOn.add(i.copy());
2226        };
2227        if (priorRequest != null) {
2228          dst.priorRequest = new ArrayList<Reference>();
2229          for (Reference i : priorRequest)
2230            dst.priorRequest.add(i.copy());
2231        };
2232        dst.groupIdentifier = groupIdentifier == null ? null : groupIdentifier.copy();
2233        dst.status = status == null ? null : status.copy();
2234        dst.intent = intent == null ? null : intent.copy();
2235        dst.priority = priority == null ? null : priority.copy();
2236        dst.code = code == null ? null : code.copy();
2237        dst.subject = subject == null ? null : subject.copy();
2238        dst.context = context == null ? null : context.copy();
2239        dst.occurrence = occurrence == null ? null : occurrence.copy();
2240        dst.authoredOn = authoredOn == null ? null : authoredOn.copy();
2241        dst.requester = requester == null ? null : requester.copy();
2242        dst.performerType = performerType == null ? null : performerType.copy();
2243        dst.performer = performer == null ? null : performer.copy();
2244        if (reasonCode != null) {
2245          dst.reasonCode = new ArrayList<CodeableConcept>();
2246          for (CodeableConcept i : reasonCode)
2247            dst.reasonCode.add(i.copy());
2248        };
2249        if (reasonReference != null) {
2250          dst.reasonReference = new ArrayList<Reference>();
2251          for (Reference i : reasonReference)
2252            dst.reasonReference.add(i.copy());
2253        };
2254        if (supportingInfo != null) {
2255          dst.supportingInfo = new ArrayList<Reference>();
2256          for (Reference i : supportingInfo)
2257            dst.supportingInfo.add(i.copy());
2258        };
2259        if (note != null) {
2260          dst.note = new ArrayList<Annotation>();
2261          for (Annotation i : note)
2262            dst.note.add(i.copy());
2263        };
2264        if (relevantHistory != null) {
2265          dst.relevantHistory = new ArrayList<Reference>();
2266          for (Reference i : relevantHistory)
2267            dst.relevantHistory.add(i.copy());
2268        };
2269        return dst;
2270      }
2271
2272      protected DeviceRequest typedCopy() {
2273        return copy();
2274      }
2275
2276      @Override
2277      public boolean equalsDeep(Base other_) {
2278        if (!super.equalsDeep(other_))
2279          return false;
2280        if (!(other_ instanceof DeviceRequest))
2281          return false;
2282        DeviceRequest o = (DeviceRequest) other_;
2283        return compareDeep(identifier, o.identifier, true) && compareDeep(definition, o.definition, true)
2284           && compareDeep(basedOn, o.basedOn, true) && compareDeep(priorRequest, o.priorRequest, true) && compareDeep(groupIdentifier, o.groupIdentifier, true)
2285           && compareDeep(status, o.status, true) && compareDeep(intent, o.intent, true) && compareDeep(priority, o.priority, true)
2286           && compareDeep(code, o.code, true) && compareDeep(subject, o.subject, true) && compareDeep(context, o.context, true)
2287           && compareDeep(occurrence, o.occurrence, true) && compareDeep(authoredOn, o.authoredOn, true) && compareDeep(requester, o.requester, true)
2288           && compareDeep(performerType, o.performerType, true) && compareDeep(performer, o.performer, true)
2289           && compareDeep(reasonCode, o.reasonCode, true) && compareDeep(reasonReference, o.reasonReference, true)
2290           && compareDeep(supportingInfo, o.supportingInfo, true) && compareDeep(note, o.note, true) && compareDeep(relevantHistory, o.relevantHistory, true)
2291          ;
2292      }
2293
2294      @Override
2295      public boolean equalsShallow(Base other_) {
2296        if (!super.equalsShallow(other_))
2297          return false;
2298        if (!(other_ instanceof DeviceRequest))
2299          return false;
2300        DeviceRequest o = (DeviceRequest) other_;
2301        return compareValues(status, o.status, true) && compareValues(priority, o.priority, true) && compareValues(authoredOn, o.authoredOn, true)
2302          ;
2303      }
2304
2305      public boolean isEmpty() {
2306        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, definition, basedOn
2307          , priorRequest, groupIdentifier, status, intent, priority, code, subject, context
2308          , occurrence, authoredOn, requester, performerType, performer, reasonCode, reasonReference
2309          , supportingInfo, note, relevantHistory);
2310      }
2311
2312  @Override
2313  public ResourceType getResourceType() {
2314    return ResourceType.DeviceRequest;
2315   }
2316
2317 /**
2318   * Search parameter: <b>requester</b>
2319   * <p>
2320   * Description: <b>Who/what is requesting service </b><br>
2321   * Type: <b>reference</b><br>
2322   * Path: <b>DeviceRequest.requester.agent</b><br>
2323   * </p>
2324   */
2325  @SearchParamDefinition(name="requester", path="DeviceRequest.requester.agent", description="Who/what is requesting service ", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Device"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner") }, target={Device.class, Organization.class, Practitioner.class } )
2326  public static final String SP_REQUESTER = "requester";
2327 /**
2328   * <b>Fluent Client</b> search parameter constant for <b>requester</b>
2329   * <p>
2330   * Description: <b>Who/what is requesting service </b><br>
2331   * Type: <b>reference</b><br>
2332   * Path: <b>DeviceRequest.requester.agent</b><br>
2333   * </p>
2334   */
2335  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam REQUESTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_REQUESTER);
2336
2337/**
2338   * Constant for fluent queries to be used to add include statements. Specifies
2339   * the path value of "<b>DeviceRequest:requester</b>".
2340   */
2341  public static final ca.uhn.fhir.model.api.Include INCLUDE_REQUESTER = new ca.uhn.fhir.model.api.Include("DeviceRequest:requester").toLocked();
2342
2343 /**
2344   * Search parameter: <b>identifier</b>
2345   * <p>
2346   * Description: <b>Business identifier for request/order</b><br>
2347   * Type: <b>token</b><br>
2348   * Path: <b>DeviceRequest.identifier</b><br>
2349   * </p>
2350   */
2351  @SearchParamDefinition(name="identifier", path="DeviceRequest.identifier", description="Business identifier for request/order", type="token" )
2352  public static final String SP_IDENTIFIER = "identifier";
2353 /**
2354   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
2355   * <p>
2356   * Description: <b>Business identifier for request/order</b><br>
2357   * Type: <b>token</b><br>
2358   * Path: <b>DeviceRequest.identifier</b><br>
2359   * </p>
2360   */
2361  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
2362
2363 /**
2364   * Search parameter: <b>code</b>
2365   * <p>
2366   * Description: <b>Code for what is being requested/ordered</b><br>
2367   * Type: <b>token</b><br>
2368   * Path: <b>DeviceRequest.codeCodeableConcept</b><br>
2369   * </p>
2370   */
2371  @SearchParamDefinition(name="code", path="DeviceRequest.code.as(CodeableConcept)", description="Code for what is being requested/ordered", type="token" )
2372  public static final String SP_CODE = "code";
2373 /**
2374   * <b>Fluent Client</b> search parameter constant for <b>code</b>
2375   * <p>
2376   * Description: <b>Code for what is being requested/ordered</b><br>
2377   * Type: <b>token</b><br>
2378   * Path: <b>DeviceRequest.codeCodeableConcept</b><br>
2379   * </p>
2380   */
2381  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CODE);
2382
2383 /**
2384   * Search parameter: <b>performer</b>
2385   * <p>
2386   * Description: <b>Desired performer for service</b><br>
2387   * Type: <b>reference</b><br>
2388   * Path: <b>DeviceRequest.performer</b><br>
2389   * </p>
2390   */
2391  @SearchParamDefinition(name="performer", path="DeviceRequest.performer", description="Desired performer for service", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Device"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner") }, target={Device.class, HealthcareService.class, Organization.class, Patient.class, Practitioner.class, RelatedPerson.class } )
2392  public static final String SP_PERFORMER = "performer";
2393 /**
2394   * <b>Fluent Client</b> search parameter constant for <b>performer</b>
2395   * <p>
2396   * Description: <b>Desired performer for service</b><br>
2397   * Type: <b>reference</b><br>
2398   * Path: <b>DeviceRequest.performer</b><br>
2399   * </p>
2400   */
2401  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PERFORMER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PERFORMER);
2402
2403/**
2404   * Constant for fluent queries to be used to add include statements. Specifies
2405   * the path value of "<b>DeviceRequest:performer</b>".
2406   */
2407  public static final ca.uhn.fhir.model.api.Include INCLUDE_PERFORMER = new ca.uhn.fhir.model.api.Include("DeviceRequest:performer").toLocked();
2408
2409 /**
2410   * Search parameter: <b>event-date</b>
2411   * <p>
2412   * Description: <b>When service should occur</b><br>
2413   * Type: <b>date</b><br>
2414   * Path: <b>DeviceRequest.occurrenceDateTime, DeviceRequest.occurrencePeriod</b><br>
2415   * </p>
2416   */
2417  @SearchParamDefinition(name="event-date", path="DeviceRequest.occurrence.as(DateTime) | DeviceRequest.occurrence.as(Period)", description="When service should occur", type="date" )
2418  public static final String SP_EVENT_DATE = "event-date";
2419 /**
2420   * <b>Fluent Client</b> search parameter constant for <b>event-date</b>
2421   * <p>
2422   * Description: <b>When service should occur</b><br>
2423   * Type: <b>date</b><br>
2424   * Path: <b>DeviceRequest.occurrenceDateTime, DeviceRequest.occurrencePeriod</b><br>
2425   * </p>
2426   */
2427  public static final ca.uhn.fhir.rest.gclient.DateClientParam EVENT_DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_EVENT_DATE);
2428
2429 /**
2430   * Search parameter: <b>subject</b>
2431   * <p>
2432   * Description: <b>Individual the service is ordered for</b><br>
2433   * Type: <b>reference</b><br>
2434   * Path: <b>DeviceRequest.subject</b><br>
2435   * </p>
2436   */
2437  @SearchParamDefinition(name="subject", path="DeviceRequest.subject", description="Individual the service is ordered for", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Device"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Device.class, Group.class, Location.class, Patient.class } )
2438  public static final String SP_SUBJECT = "subject";
2439 /**
2440   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
2441   * <p>
2442   * Description: <b>Individual the service is ordered for</b><br>
2443   * Type: <b>reference</b><br>
2444   * Path: <b>DeviceRequest.subject</b><br>
2445   * </p>
2446   */
2447  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
2448
2449/**
2450   * Constant for fluent queries to be used to add include statements. Specifies
2451   * the path value of "<b>DeviceRequest:subject</b>".
2452   */
2453  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("DeviceRequest:subject").toLocked();
2454
2455 /**
2456   * Search parameter: <b>encounter</b>
2457   * <p>
2458   * Description: <b>Encounter or Episode during which request was created</b><br>
2459   * Type: <b>reference</b><br>
2460   * Path: <b>DeviceRequest.context</b><br>
2461   * </p>
2462   */
2463  @SearchParamDefinition(name="encounter", path="DeviceRequest.context", description="Encounter or Episode during which request was created", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Encounter") }, target={Encounter.class, EpisodeOfCare.class } )
2464  public static final String SP_ENCOUNTER = "encounter";
2465 /**
2466   * <b>Fluent Client</b> search parameter constant for <b>encounter</b>
2467   * <p>
2468   * Description: <b>Encounter or Episode during which request was created</b><br>
2469   * Type: <b>reference</b><br>
2470   * Path: <b>DeviceRequest.context</b><br>
2471   * </p>
2472   */
2473  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENCOUNTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENCOUNTER);
2474
2475/**
2476   * Constant for fluent queries to be used to add include statements. Specifies
2477   * the path value of "<b>DeviceRequest:encounter</b>".
2478   */
2479  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENCOUNTER = new ca.uhn.fhir.model.api.Include("DeviceRequest:encounter").toLocked();
2480
2481 /**
2482   * Search parameter: <b>authored-on</b>
2483   * <p>
2484   * Description: <b>When the request transitioned to being actionable</b><br>
2485   * Type: <b>date</b><br>
2486   * Path: <b>DeviceRequest.authoredOn</b><br>
2487   * </p>
2488   */
2489  @SearchParamDefinition(name="authored-on", path="DeviceRequest.authoredOn", description="When the request transitioned to being actionable", type="date" )
2490  public static final String SP_AUTHORED_ON = "authored-on";
2491 /**
2492   * <b>Fluent Client</b> search parameter constant for <b>authored-on</b>
2493   * <p>
2494   * Description: <b>When the request transitioned to being actionable</b><br>
2495   * Type: <b>date</b><br>
2496   * Path: <b>DeviceRequest.authoredOn</b><br>
2497   * </p>
2498   */
2499  public static final ca.uhn.fhir.rest.gclient.DateClientParam AUTHORED_ON = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_AUTHORED_ON);
2500
2501 /**
2502   * Search parameter: <b>intent</b>
2503   * <p>
2504   * Description: <b>proposal | plan | original-order |reflex-order</b><br>
2505   * Type: <b>token</b><br>
2506   * Path: <b>DeviceRequest.intent</b><br>
2507   * </p>
2508   */
2509  @SearchParamDefinition(name="intent", path="DeviceRequest.intent", description="proposal | plan | original-order |reflex-order", type="token" )
2510  public static final String SP_INTENT = "intent";
2511 /**
2512   * <b>Fluent Client</b> search parameter constant for <b>intent</b>
2513   * <p>
2514   * Description: <b>proposal | plan | original-order |reflex-order</b><br>
2515   * Type: <b>token</b><br>
2516   * Path: <b>DeviceRequest.intent</b><br>
2517   * </p>
2518   */
2519  public static final ca.uhn.fhir.rest.gclient.TokenClientParam INTENT = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_INTENT);
2520
2521 /**
2522   * Search parameter: <b>group-identifier</b>
2523   * <p>
2524   * Description: <b>Composite request this is part of</b><br>
2525   * Type: <b>token</b><br>
2526   * Path: <b>DeviceRequest.groupIdentifier</b><br>
2527   * </p>
2528   */
2529  @SearchParamDefinition(name="group-identifier", path="DeviceRequest.groupIdentifier", description="Composite request this is part of", type="token" )
2530  public static final String SP_GROUP_IDENTIFIER = "group-identifier";
2531 /**
2532   * <b>Fluent Client</b> search parameter constant for <b>group-identifier</b>
2533   * <p>
2534   * Description: <b>Composite request this is part of</b><br>
2535   * Type: <b>token</b><br>
2536   * Path: <b>DeviceRequest.groupIdentifier</b><br>
2537   * </p>
2538   */
2539  public static final ca.uhn.fhir.rest.gclient.TokenClientParam GROUP_IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_GROUP_IDENTIFIER);
2540
2541 /**
2542   * Search parameter: <b>based-on</b>
2543   * <p>
2544   * Description: <b>Plan/proposal/order fulfilled by this request</b><br>
2545   * Type: <b>reference</b><br>
2546   * Path: <b>DeviceRequest.basedOn</b><br>
2547   * </p>
2548   */
2549  @SearchParamDefinition(name="based-on", path="DeviceRequest.basedOn", description="Plan/proposal/order fulfilled by this request", type="reference" )
2550  public static final String SP_BASED_ON = "based-on";
2551 /**
2552   * <b>Fluent Client</b> search parameter constant for <b>based-on</b>
2553   * <p>
2554   * Description: <b>Plan/proposal/order fulfilled by this request</b><br>
2555   * Type: <b>reference</b><br>
2556   * Path: <b>DeviceRequest.basedOn</b><br>
2557   * </p>
2558   */
2559  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam BASED_ON = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_BASED_ON);
2560
2561/**
2562   * Constant for fluent queries to be used to add include statements. Specifies
2563   * the path value of "<b>DeviceRequest:based-on</b>".
2564   */
2565  public static final ca.uhn.fhir.model.api.Include INCLUDE_BASED_ON = new ca.uhn.fhir.model.api.Include("DeviceRequest:based-on").toLocked();
2566
2567 /**
2568   * Search parameter: <b>priorrequest</b>
2569   * <p>
2570   * Description: <b>Request takes the place of referenced completed or terminated requests</b><br>
2571   * Type: <b>reference</b><br>
2572   * Path: <b>DeviceRequest.priorRequest</b><br>
2573   * </p>
2574   */
2575  @SearchParamDefinition(name="priorrequest", path="DeviceRequest.priorRequest", description="Request takes the place of referenced completed or terminated requests", type="reference" )
2576  public static final String SP_PRIORREQUEST = "priorrequest";
2577 /**
2578   * <b>Fluent Client</b> search parameter constant for <b>priorrequest</b>
2579   * <p>
2580   * Description: <b>Request takes the place of referenced completed or terminated requests</b><br>
2581   * Type: <b>reference</b><br>
2582   * Path: <b>DeviceRequest.priorRequest</b><br>
2583   * </p>
2584   */
2585  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PRIORREQUEST = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PRIORREQUEST);
2586
2587/**
2588   * Constant for fluent queries to be used to add include statements. Specifies
2589   * the path value of "<b>DeviceRequest:priorrequest</b>".
2590   */
2591  public static final ca.uhn.fhir.model.api.Include INCLUDE_PRIORREQUEST = new ca.uhn.fhir.model.api.Include("DeviceRequest:priorrequest").toLocked();
2592
2593 /**
2594   * Search parameter: <b>patient</b>
2595   * <p>
2596   * Description: <b>Individual the service is ordered for</b><br>
2597   * Type: <b>reference</b><br>
2598   * Path: <b>DeviceRequest.subject</b><br>
2599   * </p>
2600   */
2601  @SearchParamDefinition(name="patient", path="DeviceRequest.subject", description="Individual the service is ordered for", type="reference", target={Patient.class } )
2602  public static final String SP_PATIENT = "patient";
2603 /**
2604   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
2605   * <p>
2606   * Description: <b>Individual the service is ordered for</b><br>
2607   * Type: <b>reference</b><br>
2608   * Path: <b>DeviceRequest.subject</b><br>
2609   * </p>
2610   */
2611  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
2612
2613/**
2614   * Constant for fluent queries to be used to add include statements. Specifies
2615   * the path value of "<b>DeviceRequest:patient</b>".
2616   */
2617  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("DeviceRequest:patient").toLocked();
2618
2619 /**
2620   * Search parameter: <b>definition</b>
2621   * <p>
2622   * Description: <b>Protocol or definition followed by this request</b><br>
2623   * Type: <b>reference</b><br>
2624   * Path: <b>DeviceRequest.definition</b><br>
2625   * </p>
2626   */
2627  @SearchParamDefinition(name="definition", path="DeviceRequest.definition", description="Protocol or definition followed by this request", type="reference", target={ActivityDefinition.class, PlanDefinition.class } )
2628  public static final String SP_DEFINITION = "definition";
2629 /**
2630   * <b>Fluent Client</b> search parameter constant for <b>definition</b>
2631   * <p>
2632   * Description: <b>Protocol or definition followed by this request</b><br>
2633   * Type: <b>reference</b><br>
2634   * Path: <b>DeviceRequest.definition</b><br>
2635   * </p>
2636   */
2637  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam DEFINITION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_DEFINITION);
2638
2639/**
2640   * Constant for fluent queries to be used to add include statements. Specifies
2641   * the path value of "<b>DeviceRequest:definition</b>".
2642   */
2643  public static final ca.uhn.fhir.model.api.Include INCLUDE_DEFINITION = new ca.uhn.fhir.model.api.Include("DeviceRequest:definition").toLocked();
2644
2645 /**
2646   * Search parameter: <b>device</b>
2647   * <p>
2648   * Description: <b>Reference to resource that is being requested/ordered</b><br>
2649   * Type: <b>reference</b><br>
2650   * Path: <b>DeviceRequest.codeReference</b><br>
2651   * </p>
2652   */
2653  @SearchParamDefinition(name="device", path="DeviceRequest.code.as(Reference)", description="Reference to resource that is being requested/ordered", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Device") }, target={Device.class } )
2654  public static final String SP_DEVICE = "device";
2655 /**
2656   * <b>Fluent Client</b> search parameter constant for <b>device</b>
2657   * <p>
2658   * Description: <b>Reference to resource that is being requested/ordered</b><br>
2659   * Type: <b>reference</b><br>
2660   * Path: <b>DeviceRequest.codeReference</b><br>
2661   * </p>
2662   */
2663  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam DEVICE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_DEVICE);
2664
2665/**
2666   * Constant for fluent queries to be used to add include statements. Specifies
2667   * the path value of "<b>DeviceRequest:device</b>".
2668   */
2669  public static final ca.uhn.fhir.model.api.Include INCLUDE_DEVICE = new ca.uhn.fhir.model.api.Include("DeviceRequest:device").toLocked();
2670
2671 /**
2672   * Search parameter: <b>status</b>
2673   * <p>
2674   * Description: <b>entered-in-error | draft | active |suspended | completed </b><br>
2675   * Type: <b>token</b><br>
2676   * Path: <b>DeviceRequest.status</b><br>
2677   * </p>
2678   */
2679  @SearchParamDefinition(name="status", path="DeviceRequest.status", description="entered-in-error | draft | active |suspended | completed ", type="token" )
2680  public static final String SP_STATUS = "status";
2681 /**
2682   * <b>Fluent Client</b> search parameter constant for <b>status</b>
2683   * <p>
2684   * Description: <b>entered-in-error | draft | active |suspended | completed </b><br>
2685   * Type: <b>token</b><br>
2686   * Path: <b>DeviceRequest.status</b><br>
2687   * </p>
2688   */
2689  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
2690
2691
2692}
2693