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