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