001package org.hl7.fhir.dstu3.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Mon, Apr 17, 2017 17:38-0400 for FHIR v3.0.1
033
034import java.util.*;
035
036import org.hl7.fhir.utilities.Utilities;
037import ca.uhn.fhir.model.api.annotation.ResourceDef;
038import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
039import ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.ChildOrder;
041import ca.uhn.fhir.model.api.annotation.Description;
042import ca.uhn.fhir.model.api.annotation.Block;
043import org.hl7.fhir.instance.model.api.*;
044import org.hl7.fhir.exceptions.FHIRException;
045/**
046 * An order or request for both supply of the medication and the instructions for administration of the medication to a patient. The resource is called "MedicationRequest" rather than "MedicationPrescription" or "MedicationOrder" to generalize the use across inpatient and outpatient settings, including care plans, etc., and to harmonize with workflow patterns.
047 */
048@ResourceDef(name="MedicationRequest", profile="http://hl7.org/fhir/Profile/MedicationRequest")
049public class MedicationRequest extends DomainResource {
050
051    public enum MedicationRequestStatus {
052        /**
053         * The prescription is 'actionable', but not all actions that are implied by it have occurred yet.
054         */
055        ACTIVE, 
056        /**
057         * Actions implied by the prescription are to be temporarily halted, but are expected to continue later.  May also be called "suspended".
058         */
059        ONHOLD, 
060        /**
061         * The prescription has been withdrawn.
062         */
063        CANCELLED, 
064        /**
065         * All actions that are implied by the prescription have occurred.
066         */
067        COMPLETED, 
068        /**
069         * The prescription was entered in error.
070         */
071        ENTEREDINERROR, 
072        /**
073         * Actions implied by the prescription are to be permanently halted, before all of them occurred.
074         */
075        STOPPED, 
076        /**
077         * The prescription is not yet 'actionable', i.e. it is a work in progress, requires sign-off or verification, and needs to be run through decision support process.
078         */
079        DRAFT, 
080        /**
081         * The authoring system does not know which of the status values currently applies for this request
082         */
083        UNKNOWN, 
084        /**
085         * added to help the parsers with the generic types
086         */
087        NULL;
088        public static MedicationRequestStatus fromCode(String codeString) throws FHIRException {
089            if (codeString == null || "".equals(codeString))
090                return null;
091        if ("active".equals(codeString))
092          return ACTIVE;
093        if ("on-hold".equals(codeString))
094          return ONHOLD;
095        if ("cancelled".equals(codeString))
096          return CANCELLED;
097        if ("completed".equals(codeString))
098          return COMPLETED;
099        if ("entered-in-error".equals(codeString))
100          return ENTEREDINERROR;
101        if ("stopped".equals(codeString))
102          return STOPPED;
103        if ("draft".equals(codeString))
104          return DRAFT;
105        if ("unknown".equals(codeString))
106          return UNKNOWN;
107        if (Configuration.isAcceptInvalidEnums())
108          return null;
109        else
110          throw new FHIRException("Unknown MedicationRequestStatus code '"+codeString+"'");
111        }
112        public String toCode() {
113          switch (this) {
114            case ACTIVE: return "active";
115            case ONHOLD: return "on-hold";
116            case CANCELLED: return "cancelled";
117            case COMPLETED: return "completed";
118            case ENTEREDINERROR: return "entered-in-error";
119            case STOPPED: return "stopped";
120            case DRAFT: return "draft";
121            case UNKNOWN: return "unknown";
122            default: return "?";
123          }
124        }
125        public String getSystem() {
126          switch (this) {
127            case ACTIVE: return "http://hl7.org/fhir/medication-request-status";
128            case ONHOLD: return "http://hl7.org/fhir/medication-request-status";
129            case CANCELLED: return "http://hl7.org/fhir/medication-request-status";
130            case COMPLETED: return "http://hl7.org/fhir/medication-request-status";
131            case ENTEREDINERROR: return "http://hl7.org/fhir/medication-request-status";
132            case STOPPED: return "http://hl7.org/fhir/medication-request-status";
133            case DRAFT: return "http://hl7.org/fhir/medication-request-status";
134            case UNKNOWN: return "http://hl7.org/fhir/medication-request-status";
135            default: return "?";
136          }
137        }
138        public String getDefinition() {
139          switch (this) {
140            case ACTIVE: return "The prescription is 'actionable', but not all actions that are implied by it have occurred yet.";
141            case ONHOLD: return "Actions implied by the prescription are to be temporarily halted, but are expected to continue later.  May also be called \"suspended\".";
142            case CANCELLED: return "The prescription has been withdrawn.";
143            case COMPLETED: return "All actions that are implied by the prescription have occurred.";
144            case ENTEREDINERROR: return "The prescription was entered in error.";
145            case STOPPED: return "Actions implied by the prescription are to be permanently halted, before all of them occurred.";
146            case DRAFT: return "The prescription is not yet 'actionable', i.e. it is a work in progress, requires sign-off or verification, and needs to be run through decision support process.";
147            case UNKNOWN: return "The authoring system does not know which of the status values currently applies for this request";
148            default: return "?";
149          }
150        }
151        public String getDisplay() {
152          switch (this) {
153            case ACTIVE: return "Active";
154            case ONHOLD: return "On Hold";
155            case CANCELLED: return "Cancelled";
156            case COMPLETED: return "Completed";
157            case ENTEREDINERROR: return "Entered In Error";
158            case STOPPED: return "Stopped";
159            case DRAFT: return "Draft";
160            case UNKNOWN: return "Unknown";
161            default: return "?";
162          }
163        }
164    }
165
166  public static class MedicationRequestStatusEnumFactory implements EnumFactory<MedicationRequestStatus> {
167    public MedicationRequestStatus fromCode(String codeString) throws IllegalArgumentException {
168      if (codeString == null || "".equals(codeString))
169            if (codeString == null || "".equals(codeString))
170                return null;
171        if ("active".equals(codeString))
172          return MedicationRequestStatus.ACTIVE;
173        if ("on-hold".equals(codeString))
174          return MedicationRequestStatus.ONHOLD;
175        if ("cancelled".equals(codeString))
176          return MedicationRequestStatus.CANCELLED;
177        if ("completed".equals(codeString))
178          return MedicationRequestStatus.COMPLETED;
179        if ("entered-in-error".equals(codeString))
180          return MedicationRequestStatus.ENTEREDINERROR;
181        if ("stopped".equals(codeString))
182          return MedicationRequestStatus.STOPPED;
183        if ("draft".equals(codeString))
184          return MedicationRequestStatus.DRAFT;
185        if ("unknown".equals(codeString))
186          return MedicationRequestStatus.UNKNOWN;
187        throw new IllegalArgumentException("Unknown MedicationRequestStatus code '"+codeString+"'");
188        }
189        public Enumeration<MedicationRequestStatus> fromType(Base code) throws FHIRException {
190          if (code == null)
191            return null;
192          if (code.isEmpty())
193            return new Enumeration<MedicationRequestStatus>(this);
194          String codeString = ((PrimitiveType) code).asStringValue();
195          if (codeString == null || "".equals(codeString))
196            return null;
197        if ("active".equals(codeString))
198          return new Enumeration<MedicationRequestStatus>(this, MedicationRequestStatus.ACTIVE);
199        if ("on-hold".equals(codeString))
200          return new Enumeration<MedicationRequestStatus>(this, MedicationRequestStatus.ONHOLD);
201        if ("cancelled".equals(codeString))
202          return new Enumeration<MedicationRequestStatus>(this, MedicationRequestStatus.CANCELLED);
203        if ("completed".equals(codeString))
204          return new Enumeration<MedicationRequestStatus>(this, MedicationRequestStatus.COMPLETED);
205        if ("entered-in-error".equals(codeString))
206          return new Enumeration<MedicationRequestStatus>(this, MedicationRequestStatus.ENTEREDINERROR);
207        if ("stopped".equals(codeString))
208          return new Enumeration<MedicationRequestStatus>(this, MedicationRequestStatus.STOPPED);
209        if ("draft".equals(codeString))
210          return new Enumeration<MedicationRequestStatus>(this, MedicationRequestStatus.DRAFT);
211        if ("unknown".equals(codeString))
212          return new Enumeration<MedicationRequestStatus>(this, MedicationRequestStatus.UNKNOWN);
213        throw new FHIRException("Unknown MedicationRequestStatus code '"+codeString+"'");
214        }
215    public String toCode(MedicationRequestStatus code) {
216      if (code == MedicationRequestStatus.ACTIVE)
217        return "active";
218      if (code == MedicationRequestStatus.ONHOLD)
219        return "on-hold";
220      if (code == MedicationRequestStatus.CANCELLED)
221        return "cancelled";
222      if (code == MedicationRequestStatus.COMPLETED)
223        return "completed";
224      if (code == MedicationRequestStatus.ENTEREDINERROR)
225        return "entered-in-error";
226      if (code == MedicationRequestStatus.STOPPED)
227        return "stopped";
228      if (code == MedicationRequestStatus.DRAFT)
229        return "draft";
230      if (code == MedicationRequestStatus.UNKNOWN)
231        return "unknown";
232      return "?";
233      }
234    public String toSystem(MedicationRequestStatus code) {
235      return code.getSystem();
236      }
237    }
238
239    public enum MedicationRequestIntent {
240        /**
241         * The request is a suggestion made by someone/something that doesn't have an intention to ensure it occurs and without providing an authorization to act
242         */
243        PROPOSAL, 
244        /**
245         * The request represents an intension to ensure something occurs without providing an authorization for others to act
246         */
247        PLAN, 
248        /**
249         * The request represents a request/demand and authorization for action
250         */
251        ORDER, 
252        /**
253         * The request represents an instance for the particular order, for example a medication administration record.
254         */
255        INSTANCEORDER, 
256        /**
257         * added to help the parsers with the generic types
258         */
259        NULL;
260        public static MedicationRequestIntent fromCode(String codeString) throws FHIRException {
261            if (codeString == null || "".equals(codeString))
262                return null;
263        if ("proposal".equals(codeString))
264          return PROPOSAL;
265        if ("plan".equals(codeString))
266          return PLAN;
267        if ("order".equals(codeString))
268          return ORDER;
269        if ("instance-order".equals(codeString))
270          return INSTANCEORDER;
271        if (Configuration.isAcceptInvalidEnums())
272          return null;
273        else
274          throw new FHIRException("Unknown MedicationRequestIntent code '"+codeString+"'");
275        }
276        public String toCode() {
277          switch (this) {
278            case PROPOSAL: return "proposal";
279            case PLAN: return "plan";
280            case ORDER: return "order";
281            case INSTANCEORDER: return "instance-order";
282            default: return "?";
283          }
284        }
285        public String getSystem() {
286          switch (this) {
287            case PROPOSAL: return "http://hl7.org/fhir/medication-request-intent";
288            case PLAN: return "http://hl7.org/fhir/medication-request-intent";
289            case ORDER: return "http://hl7.org/fhir/medication-request-intent";
290            case INSTANCEORDER: return "http://hl7.org/fhir/medication-request-intent";
291            default: return "?";
292          }
293        }
294        public String getDefinition() {
295          switch (this) {
296            case PROPOSAL: return "The request is a suggestion made by someone/something that doesn't have an intention to ensure it occurs and without providing an authorization to act";
297            case PLAN: return "The request represents an intension to ensure something occurs without providing an authorization for others to act";
298            case ORDER: return "The request represents a request/demand and authorization for action";
299            case INSTANCEORDER: return "The request represents an instance for the particular order, for example a medication administration record.";
300            default: return "?";
301          }
302        }
303        public String getDisplay() {
304          switch (this) {
305            case PROPOSAL: return "Proposal";
306            case PLAN: return "Plan";
307            case ORDER: return "Order";
308            case INSTANCEORDER: return "Instance Order";
309            default: return "?";
310          }
311        }
312    }
313
314  public static class MedicationRequestIntentEnumFactory implements EnumFactory<MedicationRequestIntent> {
315    public MedicationRequestIntent fromCode(String codeString) throws IllegalArgumentException {
316      if (codeString == null || "".equals(codeString))
317            if (codeString == null || "".equals(codeString))
318                return null;
319        if ("proposal".equals(codeString))
320          return MedicationRequestIntent.PROPOSAL;
321        if ("plan".equals(codeString))
322          return MedicationRequestIntent.PLAN;
323        if ("order".equals(codeString))
324          return MedicationRequestIntent.ORDER;
325        if ("instance-order".equals(codeString))
326          return MedicationRequestIntent.INSTANCEORDER;
327        throw new IllegalArgumentException("Unknown MedicationRequestIntent code '"+codeString+"'");
328        }
329        public Enumeration<MedicationRequestIntent> fromType(Base code) throws FHIRException {
330          if (code == null)
331            return null;
332          if (code.isEmpty())
333            return new Enumeration<MedicationRequestIntent>(this);
334          String codeString = ((PrimitiveType) code).asStringValue();
335          if (codeString == null || "".equals(codeString))
336            return null;
337        if ("proposal".equals(codeString))
338          return new Enumeration<MedicationRequestIntent>(this, MedicationRequestIntent.PROPOSAL);
339        if ("plan".equals(codeString))
340          return new Enumeration<MedicationRequestIntent>(this, MedicationRequestIntent.PLAN);
341        if ("order".equals(codeString))
342          return new Enumeration<MedicationRequestIntent>(this, MedicationRequestIntent.ORDER);
343        if ("instance-order".equals(codeString))
344          return new Enumeration<MedicationRequestIntent>(this, MedicationRequestIntent.INSTANCEORDER);
345        throw new FHIRException("Unknown MedicationRequestIntent code '"+codeString+"'");
346        }
347    public String toCode(MedicationRequestIntent code) {
348      if (code == MedicationRequestIntent.PROPOSAL)
349        return "proposal";
350      if (code == MedicationRequestIntent.PLAN)
351        return "plan";
352      if (code == MedicationRequestIntent.ORDER)
353        return "order";
354      if (code == MedicationRequestIntent.INSTANCEORDER)
355        return "instance-order";
356      return "?";
357      }
358    public String toSystem(MedicationRequestIntent code) {
359      return code.getSystem();
360      }
361    }
362
363    public enum MedicationRequestPriority {
364        /**
365         * The order has a normal priority .
366         */
367        ROUTINE, 
368        /**
369         * The order should be urgently.
370         */
371        URGENT, 
372        /**
373         * The order is time-critical.
374         */
375        STAT, 
376        /**
377         * The order should be acted on as soon as possible.
378         */
379        ASAP, 
380        /**
381         * added to help the parsers with the generic types
382         */
383        NULL;
384        public static MedicationRequestPriority fromCode(String codeString) throws FHIRException {
385            if (codeString == null || "".equals(codeString))
386                return null;
387        if ("routine".equals(codeString))
388          return ROUTINE;
389        if ("urgent".equals(codeString))
390          return URGENT;
391        if ("stat".equals(codeString))
392          return STAT;
393        if ("asap".equals(codeString))
394          return ASAP;
395        if (Configuration.isAcceptInvalidEnums())
396          return null;
397        else
398          throw new FHIRException("Unknown MedicationRequestPriority code '"+codeString+"'");
399        }
400        public String toCode() {
401          switch (this) {
402            case ROUTINE: return "routine";
403            case URGENT: return "urgent";
404            case STAT: return "stat";
405            case ASAP: return "asap";
406            default: return "?";
407          }
408        }
409        public String getSystem() {
410          switch (this) {
411            case ROUTINE: return "http://hl7.org/fhir/medication-request-priority";
412            case URGENT: return "http://hl7.org/fhir/medication-request-priority";
413            case STAT: return "http://hl7.org/fhir/medication-request-priority";
414            case ASAP: return "http://hl7.org/fhir/medication-request-priority";
415            default: return "?";
416          }
417        }
418        public String getDefinition() {
419          switch (this) {
420            case ROUTINE: return "The order has a normal priority .";
421            case URGENT: return "The order should be urgently.";
422            case STAT: return "The order is time-critical.";
423            case ASAP: return "The order should be acted on as soon as possible.";
424            default: return "?";
425          }
426        }
427        public String getDisplay() {
428          switch (this) {
429            case ROUTINE: return "Routine";
430            case URGENT: return "Urgent";
431            case STAT: return "Stat";
432            case ASAP: return "ASAP";
433            default: return "?";
434          }
435        }
436    }
437
438  public static class MedicationRequestPriorityEnumFactory implements EnumFactory<MedicationRequestPriority> {
439    public MedicationRequestPriority fromCode(String codeString) throws IllegalArgumentException {
440      if (codeString == null || "".equals(codeString))
441            if (codeString == null || "".equals(codeString))
442                return null;
443        if ("routine".equals(codeString))
444          return MedicationRequestPriority.ROUTINE;
445        if ("urgent".equals(codeString))
446          return MedicationRequestPriority.URGENT;
447        if ("stat".equals(codeString))
448          return MedicationRequestPriority.STAT;
449        if ("asap".equals(codeString))
450          return MedicationRequestPriority.ASAP;
451        throw new IllegalArgumentException("Unknown MedicationRequestPriority code '"+codeString+"'");
452        }
453        public Enumeration<MedicationRequestPriority> fromType(Base code) throws FHIRException {
454          if (code == null)
455            return null;
456          if (code.isEmpty())
457            return new Enumeration<MedicationRequestPriority>(this);
458          String codeString = ((PrimitiveType) code).asStringValue();
459          if (codeString == null || "".equals(codeString))
460            return null;
461        if ("routine".equals(codeString))
462          return new Enumeration<MedicationRequestPriority>(this, MedicationRequestPriority.ROUTINE);
463        if ("urgent".equals(codeString))
464          return new Enumeration<MedicationRequestPriority>(this, MedicationRequestPriority.URGENT);
465        if ("stat".equals(codeString))
466          return new Enumeration<MedicationRequestPriority>(this, MedicationRequestPriority.STAT);
467        if ("asap".equals(codeString))
468          return new Enumeration<MedicationRequestPriority>(this, MedicationRequestPriority.ASAP);
469        throw new FHIRException("Unknown MedicationRequestPriority code '"+codeString+"'");
470        }
471    public String toCode(MedicationRequestPriority code) {
472      if (code == MedicationRequestPriority.ROUTINE)
473        return "routine";
474      if (code == MedicationRequestPriority.URGENT)
475        return "urgent";
476      if (code == MedicationRequestPriority.STAT)
477        return "stat";
478      if (code == MedicationRequestPriority.ASAP)
479        return "asap";
480      return "?";
481      }
482    public String toSystem(MedicationRequestPriority code) {
483      return code.getSystem();
484      }
485    }
486
487    @Block()
488    public static class MedicationRequestRequesterComponent extends BackboneElement implements IBaseBackboneElement {
489        /**
490         * The healthcare professional responsible for authorizing the initial prescription.
491         */
492        @Child(name = "agent", type = {Practitioner.class, Organization.class, Patient.class, RelatedPerson.class, Device.class}, order=1, min=1, max=1, modifier=false, summary=true)
493        @Description(shortDefinition="Who ordered the initial medication(s)", formalDefinition="The healthcare professional responsible for authorizing the initial prescription." )
494        protected Reference agent;
495
496        /**
497         * The actual object that is the target of the reference (The healthcare professional responsible for authorizing the initial prescription.)
498         */
499        protected Resource agentTarget;
500
501        /**
502         * The organization the device or practitioner was acting on behalf of.
503         */
504        @Child(name = "onBehalfOf", type = {Organization.class}, order=2, min=0, max=1, modifier=false, summary=true)
505        @Description(shortDefinition="Organization agent is acting for", formalDefinition="The organization the device or practitioner was acting on behalf of." )
506        protected Reference onBehalfOf;
507
508        /**
509         * The actual object that is the target of the reference (The organization the device or practitioner was acting on behalf of.)
510         */
511        protected Organization onBehalfOfTarget;
512
513        private static final long serialVersionUID = -71453027L;
514
515    /**
516     * Constructor
517     */
518      public MedicationRequestRequesterComponent() {
519        super();
520      }
521
522    /**
523     * Constructor
524     */
525      public MedicationRequestRequesterComponent(Reference agent) {
526        super();
527        this.agent = agent;
528      }
529
530        /**
531         * @return {@link #agent} (The healthcare professional responsible for authorizing the initial prescription.)
532         */
533        public Reference getAgent() { 
534          if (this.agent == null)
535            if (Configuration.errorOnAutoCreate())
536              throw new Error("Attempt to auto-create MedicationRequestRequesterComponent.agent");
537            else if (Configuration.doAutoCreate())
538              this.agent = new Reference(); // cc
539          return this.agent;
540        }
541
542        public boolean hasAgent() { 
543          return this.agent != null && !this.agent.isEmpty();
544        }
545
546        /**
547         * @param value {@link #agent} (The healthcare professional responsible for authorizing the initial prescription.)
548         */
549        public MedicationRequestRequesterComponent setAgent(Reference value) { 
550          this.agent = value;
551          return this;
552        }
553
554        /**
555         * @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 healthcare professional responsible for authorizing the initial prescription.)
556         */
557        public Resource getAgentTarget() { 
558          return this.agentTarget;
559        }
560
561        /**
562         * @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 healthcare professional responsible for authorizing the initial prescription.)
563         */
564        public MedicationRequestRequesterComponent setAgentTarget(Resource value) { 
565          this.agentTarget = value;
566          return this;
567        }
568
569        /**
570         * @return {@link #onBehalfOf} (The organization the device or practitioner was acting on behalf of.)
571         */
572        public Reference getOnBehalfOf() { 
573          if (this.onBehalfOf == null)
574            if (Configuration.errorOnAutoCreate())
575              throw new Error("Attempt to auto-create MedicationRequestRequesterComponent.onBehalfOf");
576            else if (Configuration.doAutoCreate())
577              this.onBehalfOf = new Reference(); // cc
578          return this.onBehalfOf;
579        }
580
581        public boolean hasOnBehalfOf() { 
582          return this.onBehalfOf != null && !this.onBehalfOf.isEmpty();
583        }
584
585        /**
586         * @param value {@link #onBehalfOf} (The organization the device or practitioner was acting on behalf of.)
587         */
588        public MedicationRequestRequesterComponent setOnBehalfOf(Reference value) { 
589          this.onBehalfOf = value;
590          return this;
591        }
592
593        /**
594         * @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.)
595         */
596        public Organization getOnBehalfOfTarget() { 
597          if (this.onBehalfOfTarget == null)
598            if (Configuration.errorOnAutoCreate())
599              throw new Error("Attempt to auto-create MedicationRequestRequesterComponent.onBehalfOf");
600            else if (Configuration.doAutoCreate())
601              this.onBehalfOfTarget = new Organization(); // aa
602          return this.onBehalfOfTarget;
603        }
604
605        /**
606         * @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.)
607         */
608        public MedicationRequestRequesterComponent setOnBehalfOfTarget(Organization value) { 
609          this.onBehalfOfTarget = value;
610          return this;
611        }
612
613        protected void listChildren(List<Property> childrenList) {
614          super.listChildren(childrenList);
615          childrenList.add(new Property("agent", "Reference(Practitioner|Organization|Patient|RelatedPerson|Device)", "The healthcare professional responsible for authorizing the initial prescription.", 0, java.lang.Integer.MAX_VALUE, agent));
616          childrenList.add(new Property("onBehalfOf", "Reference(Organization)", "The organization the device or practitioner was acting on behalf of.", 0, java.lang.Integer.MAX_VALUE, onBehalfOf));
617        }
618
619      @Override
620      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
621        switch (hash) {
622        case 92750597: /*agent*/ return this.agent == null ? new Base[0] : new Base[] {this.agent}; // Reference
623        case -14402964: /*onBehalfOf*/ return this.onBehalfOf == null ? new Base[0] : new Base[] {this.onBehalfOf}; // Reference
624        default: return super.getProperty(hash, name, checkValid);
625        }
626
627      }
628
629      @Override
630      public Base setProperty(int hash, String name, Base value) throws FHIRException {
631        switch (hash) {
632        case 92750597: // agent
633          this.agent = castToReference(value); // Reference
634          return value;
635        case -14402964: // onBehalfOf
636          this.onBehalfOf = castToReference(value); // Reference
637          return value;
638        default: return super.setProperty(hash, name, value);
639        }
640
641      }
642
643      @Override
644      public Base setProperty(String name, Base value) throws FHIRException {
645        if (name.equals("agent")) {
646          this.agent = castToReference(value); // Reference
647        } else if (name.equals("onBehalfOf")) {
648          this.onBehalfOf = castToReference(value); // Reference
649        } else
650          return super.setProperty(name, value);
651        return value;
652      }
653
654      @Override
655      public Base makeProperty(int hash, String name) throws FHIRException {
656        switch (hash) {
657        case 92750597:  return getAgent(); 
658        case -14402964:  return getOnBehalfOf(); 
659        default: return super.makeProperty(hash, name);
660        }
661
662      }
663
664      @Override
665      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
666        switch (hash) {
667        case 92750597: /*agent*/ return new String[] {"Reference"};
668        case -14402964: /*onBehalfOf*/ return new String[] {"Reference"};
669        default: return super.getTypesForProperty(hash, name);
670        }
671
672      }
673
674      @Override
675      public Base addChild(String name) throws FHIRException {
676        if (name.equals("agent")) {
677          this.agent = new Reference();
678          return this.agent;
679        }
680        else if (name.equals("onBehalfOf")) {
681          this.onBehalfOf = new Reference();
682          return this.onBehalfOf;
683        }
684        else
685          return super.addChild(name);
686      }
687
688      public MedicationRequestRequesterComponent copy() {
689        MedicationRequestRequesterComponent dst = new MedicationRequestRequesterComponent();
690        copyValues(dst);
691        dst.agent = agent == null ? null : agent.copy();
692        dst.onBehalfOf = onBehalfOf == null ? null : onBehalfOf.copy();
693        return dst;
694      }
695
696      @Override
697      public boolean equalsDeep(Base other) {
698        if (!super.equalsDeep(other))
699          return false;
700        if (!(other instanceof MedicationRequestRequesterComponent))
701          return false;
702        MedicationRequestRequesterComponent o = (MedicationRequestRequesterComponent) other;
703        return compareDeep(agent, o.agent, true) && compareDeep(onBehalfOf, o.onBehalfOf, true);
704      }
705
706      @Override
707      public boolean equalsShallow(Base other) {
708        if (!super.equalsShallow(other))
709          return false;
710        if (!(other instanceof MedicationRequestRequesterComponent))
711          return false;
712        MedicationRequestRequesterComponent o = (MedicationRequestRequesterComponent) other;
713        return true;
714      }
715
716      public boolean isEmpty() {
717        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(agent, onBehalfOf);
718      }
719
720  public String fhirType() {
721    return "MedicationRequest.requester";
722
723  }
724
725  }
726
727    @Block()
728    public static class MedicationRequestDispenseRequestComponent extends BackboneElement implements IBaseBackboneElement {
729        /**
730         * This indicates the validity period of a prescription (stale dating the Prescription).
731         */
732        @Child(name = "validityPeriod", type = {Period.class}, order=1, min=0, max=1, modifier=false, summary=false)
733        @Description(shortDefinition="Time period supply is authorized for", formalDefinition="This indicates the validity period of a prescription (stale dating the Prescription)." )
734        protected Period validityPeriod;
735
736        /**
737         * An integer indicating the number of times, in addition to the original dispense, (aka refills or repeats) that the patient can receive the prescribed medication. Usage Notes: This integer does not include the original order dispense. This means that if an order indicates dispense 30 tablets plus "3 repeats", then the order can be dispensed a total of 4 times and the patient can receive a total of 120 tablets.
738         */
739        @Child(name = "numberOfRepeatsAllowed", type = {PositiveIntType.class}, order=2, min=0, max=1, modifier=false, summary=false)
740        @Description(shortDefinition="Number of refills authorized", formalDefinition="An integer indicating the number of times, in addition to the original dispense, (aka refills or repeats) that the patient can receive the prescribed medication. Usage Notes: This integer does not include the original order dispense. This means that if an order indicates dispense 30 tablets plus \"3 repeats\", then the order can be dispensed a total of 4 times and the patient can receive a total of 120 tablets." )
741        protected PositiveIntType numberOfRepeatsAllowed;
742
743        /**
744         * The amount that is to be dispensed for one fill.
745         */
746        @Child(name = "quantity", type = {SimpleQuantity.class}, order=3, min=0, max=1, modifier=false, summary=false)
747        @Description(shortDefinition="Amount of medication to supply per dispense", formalDefinition="The amount that is to be dispensed for one fill." )
748        protected SimpleQuantity quantity;
749
750        /**
751         * Identifies the period time over which the supplied product is expected to be used, or the length of time the dispense is expected to last.
752         */
753        @Child(name = "expectedSupplyDuration", type = {Duration.class}, order=4, min=0, max=1, modifier=false, summary=false)
754        @Description(shortDefinition="Number of days supply per dispense", formalDefinition="Identifies the period time over which the supplied product is expected to be used, or the length of time the dispense is expected to last." )
755        protected Duration expectedSupplyDuration;
756
757        /**
758         * Indicates the intended dispensing Organization specified by the prescriber.
759         */
760        @Child(name = "performer", type = {Organization.class}, order=5, min=0, max=1, modifier=false, summary=false)
761        @Description(shortDefinition="Intended dispenser", formalDefinition="Indicates the intended dispensing Organization specified by the prescriber." )
762        protected Reference performer;
763
764        /**
765         * The actual object that is the target of the reference (Indicates the intended dispensing Organization specified by the prescriber.)
766         */
767        protected Organization performerTarget;
768
769        private static final long serialVersionUID = 280197622L;
770
771    /**
772     * Constructor
773     */
774      public MedicationRequestDispenseRequestComponent() {
775        super();
776      }
777
778        /**
779         * @return {@link #validityPeriod} (This indicates the validity period of a prescription (stale dating the Prescription).)
780         */
781        public Period getValidityPeriod() { 
782          if (this.validityPeriod == null)
783            if (Configuration.errorOnAutoCreate())
784              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.validityPeriod");
785            else if (Configuration.doAutoCreate())
786              this.validityPeriod = new Period(); // cc
787          return this.validityPeriod;
788        }
789
790        public boolean hasValidityPeriod() { 
791          return this.validityPeriod != null && !this.validityPeriod.isEmpty();
792        }
793
794        /**
795         * @param value {@link #validityPeriod} (This indicates the validity period of a prescription (stale dating the Prescription).)
796         */
797        public MedicationRequestDispenseRequestComponent setValidityPeriod(Period value) { 
798          this.validityPeriod = value;
799          return this;
800        }
801
802        /**
803         * @return {@link #numberOfRepeatsAllowed} (An integer indicating the number of times, in addition to the original dispense, (aka refills or repeats) that the patient can receive the prescribed medication. Usage Notes: This integer does not include the original order dispense. This means that if an order indicates dispense 30 tablets plus "3 repeats", then the order can be dispensed a total of 4 times and the patient can receive a total of 120 tablets.). This is the underlying object with id, value and extensions. The accessor "getNumberOfRepeatsAllowed" gives direct access to the value
804         */
805        public PositiveIntType getNumberOfRepeatsAllowedElement() { 
806          if (this.numberOfRepeatsAllowed == null)
807            if (Configuration.errorOnAutoCreate())
808              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.numberOfRepeatsAllowed");
809            else if (Configuration.doAutoCreate())
810              this.numberOfRepeatsAllowed = new PositiveIntType(); // bb
811          return this.numberOfRepeatsAllowed;
812        }
813
814        public boolean hasNumberOfRepeatsAllowedElement() { 
815          return this.numberOfRepeatsAllowed != null && !this.numberOfRepeatsAllowed.isEmpty();
816        }
817
818        public boolean hasNumberOfRepeatsAllowed() { 
819          return this.numberOfRepeatsAllowed != null && !this.numberOfRepeatsAllowed.isEmpty();
820        }
821
822        /**
823         * @param value {@link #numberOfRepeatsAllowed} (An integer indicating the number of times, in addition to the original dispense, (aka refills or repeats) that the patient can receive the prescribed medication. Usage Notes: This integer does not include the original order dispense. This means that if an order indicates dispense 30 tablets plus "3 repeats", then the order can be dispensed a total of 4 times and the patient can receive a total of 120 tablets.). This is the underlying object with id, value and extensions. The accessor "getNumberOfRepeatsAllowed" gives direct access to the value
824         */
825        public MedicationRequestDispenseRequestComponent setNumberOfRepeatsAllowedElement(PositiveIntType value) { 
826          this.numberOfRepeatsAllowed = value;
827          return this;
828        }
829
830        /**
831         * @return An integer indicating the number of times, in addition to the original dispense, (aka refills or repeats) that the patient can receive the prescribed medication. Usage Notes: This integer does not include the original order dispense. This means that if an order indicates dispense 30 tablets plus "3 repeats", then the order can be dispensed a total of 4 times and the patient can receive a total of 120 tablets.
832         */
833        public int getNumberOfRepeatsAllowed() { 
834          return this.numberOfRepeatsAllowed == null || this.numberOfRepeatsAllowed.isEmpty() ? 0 : this.numberOfRepeatsAllowed.getValue();
835        }
836
837        /**
838         * @param value An integer indicating the number of times, in addition to the original dispense, (aka refills or repeats) that the patient can receive the prescribed medication. Usage Notes: This integer does not include the original order dispense. This means that if an order indicates dispense 30 tablets plus "3 repeats", then the order can be dispensed a total of 4 times and the patient can receive a total of 120 tablets.
839         */
840        public MedicationRequestDispenseRequestComponent setNumberOfRepeatsAllowed(int value) { 
841            if (this.numberOfRepeatsAllowed == null)
842              this.numberOfRepeatsAllowed = new PositiveIntType();
843            this.numberOfRepeatsAllowed.setValue(value);
844          return this;
845        }
846
847        /**
848         * @return {@link #quantity} (The amount that is to be dispensed for one fill.)
849         */
850        public SimpleQuantity getQuantity() { 
851          if (this.quantity == null)
852            if (Configuration.errorOnAutoCreate())
853              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.quantity");
854            else if (Configuration.doAutoCreate())
855              this.quantity = new SimpleQuantity(); // cc
856          return this.quantity;
857        }
858
859        public boolean hasQuantity() { 
860          return this.quantity != null && !this.quantity.isEmpty();
861        }
862
863        /**
864         * @param value {@link #quantity} (The amount that is to be dispensed for one fill.)
865         */
866        public MedicationRequestDispenseRequestComponent setQuantity(SimpleQuantity value) { 
867          this.quantity = value;
868          return this;
869        }
870
871        /**
872         * @return {@link #expectedSupplyDuration} (Identifies the period time over which the supplied product is expected to be used, or the length of time the dispense is expected to last.)
873         */
874        public Duration getExpectedSupplyDuration() { 
875          if (this.expectedSupplyDuration == null)
876            if (Configuration.errorOnAutoCreate())
877              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.expectedSupplyDuration");
878            else if (Configuration.doAutoCreate())
879              this.expectedSupplyDuration = new Duration(); // cc
880          return this.expectedSupplyDuration;
881        }
882
883        public boolean hasExpectedSupplyDuration() { 
884          return this.expectedSupplyDuration != null && !this.expectedSupplyDuration.isEmpty();
885        }
886
887        /**
888         * @param value {@link #expectedSupplyDuration} (Identifies the period time over which the supplied product is expected to be used, or the length of time the dispense is expected to last.)
889         */
890        public MedicationRequestDispenseRequestComponent setExpectedSupplyDuration(Duration value) { 
891          this.expectedSupplyDuration = value;
892          return this;
893        }
894
895        /**
896         * @return {@link #performer} (Indicates the intended dispensing Organization specified by the prescriber.)
897         */
898        public Reference getPerformer() { 
899          if (this.performer == null)
900            if (Configuration.errorOnAutoCreate())
901              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.performer");
902            else if (Configuration.doAutoCreate())
903              this.performer = new Reference(); // cc
904          return this.performer;
905        }
906
907        public boolean hasPerformer() { 
908          return this.performer != null && !this.performer.isEmpty();
909        }
910
911        /**
912         * @param value {@link #performer} (Indicates the intended dispensing Organization specified by the prescriber.)
913         */
914        public MedicationRequestDispenseRequestComponent setPerformer(Reference value) { 
915          this.performer = value;
916          return this;
917        }
918
919        /**
920         * @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. (Indicates the intended dispensing Organization specified by the prescriber.)
921         */
922        public Organization getPerformerTarget() { 
923          if (this.performerTarget == null)
924            if (Configuration.errorOnAutoCreate())
925              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.performer");
926            else if (Configuration.doAutoCreate())
927              this.performerTarget = new Organization(); // aa
928          return this.performerTarget;
929        }
930
931        /**
932         * @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. (Indicates the intended dispensing Organization specified by the prescriber.)
933         */
934        public MedicationRequestDispenseRequestComponent setPerformerTarget(Organization value) { 
935          this.performerTarget = value;
936          return this;
937        }
938
939        protected void listChildren(List<Property> childrenList) {
940          super.listChildren(childrenList);
941          childrenList.add(new Property("validityPeriod", "Period", "This indicates the validity period of a prescription (stale dating the Prescription).", 0, java.lang.Integer.MAX_VALUE, validityPeriod));
942          childrenList.add(new Property("numberOfRepeatsAllowed", "positiveInt", "An integer indicating the number of times, in addition to the original dispense, (aka refills or repeats) that the patient can receive the prescribed medication. Usage Notes: This integer does not include the original order dispense. This means that if an order indicates dispense 30 tablets plus \"3 repeats\", then the order can be dispensed a total of 4 times and the patient can receive a total of 120 tablets.", 0, java.lang.Integer.MAX_VALUE, numberOfRepeatsAllowed));
943          childrenList.add(new Property("quantity", "SimpleQuantity", "The amount that is to be dispensed for one fill.", 0, java.lang.Integer.MAX_VALUE, quantity));
944          childrenList.add(new Property("expectedSupplyDuration", "Duration", "Identifies the period time over which the supplied product is expected to be used, or the length of time the dispense is expected to last.", 0, java.lang.Integer.MAX_VALUE, expectedSupplyDuration));
945          childrenList.add(new Property("performer", "Reference(Organization)", "Indicates the intended dispensing Organization specified by the prescriber.", 0, java.lang.Integer.MAX_VALUE, performer));
946        }
947
948      @Override
949      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
950        switch (hash) {
951        case -1434195053: /*validityPeriod*/ return this.validityPeriod == null ? new Base[0] : new Base[] {this.validityPeriod}; // Period
952        case -239736976: /*numberOfRepeatsAllowed*/ return this.numberOfRepeatsAllowed == null ? new Base[0] : new Base[] {this.numberOfRepeatsAllowed}; // PositiveIntType
953        case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // SimpleQuantity
954        case -1910182789: /*expectedSupplyDuration*/ return this.expectedSupplyDuration == null ? new Base[0] : new Base[] {this.expectedSupplyDuration}; // Duration
955        case 481140686: /*performer*/ return this.performer == null ? new Base[0] : new Base[] {this.performer}; // Reference
956        default: return super.getProperty(hash, name, checkValid);
957        }
958
959      }
960
961      @Override
962      public Base setProperty(int hash, String name, Base value) throws FHIRException {
963        switch (hash) {
964        case -1434195053: // validityPeriod
965          this.validityPeriod = castToPeriod(value); // Period
966          return value;
967        case -239736976: // numberOfRepeatsAllowed
968          this.numberOfRepeatsAllowed = castToPositiveInt(value); // PositiveIntType
969          return value;
970        case -1285004149: // quantity
971          this.quantity = castToSimpleQuantity(value); // SimpleQuantity
972          return value;
973        case -1910182789: // expectedSupplyDuration
974          this.expectedSupplyDuration = castToDuration(value); // Duration
975          return value;
976        case 481140686: // performer
977          this.performer = castToReference(value); // Reference
978          return value;
979        default: return super.setProperty(hash, name, value);
980        }
981
982      }
983
984      @Override
985      public Base setProperty(String name, Base value) throws FHIRException {
986        if (name.equals("validityPeriod")) {
987          this.validityPeriod = castToPeriod(value); // Period
988        } else if (name.equals("numberOfRepeatsAllowed")) {
989          this.numberOfRepeatsAllowed = castToPositiveInt(value); // PositiveIntType
990        } else if (name.equals("quantity")) {
991          this.quantity = castToSimpleQuantity(value); // SimpleQuantity
992        } else if (name.equals("expectedSupplyDuration")) {
993          this.expectedSupplyDuration = castToDuration(value); // Duration
994        } else if (name.equals("performer")) {
995          this.performer = castToReference(value); // Reference
996        } else
997          return super.setProperty(name, value);
998        return value;
999      }
1000
1001      @Override
1002      public Base makeProperty(int hash, String name) throws FHIRException {
1003        switch (hash) {
1004        case -1434195053:  return getValidityPeriod(); 
1005        case -239736976:  return getNumberOfRepeatsAllowedElement();
1006        case -1285004149:  return getQuantity(); 
1007        case -1910182789:  return getExpectedSupplyDuration(); 
1008        case 481140686:  return getPerformer(); 
1009        default: return super.makeProperty(hash, name);
1010        }
1011
1012      }
1013
1014      @Override
1015      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1016        switch (hash) {
1017        case -1434195053: /*validityPeriod*/ return new String[] {"Period"};
1018        case -239736976: /*numberOfRepeatsAllowed*/ return new String[] {"positiveInt"};
1019        case -1285004149: /*quantity*/ return new String[] {"SimpleQuantity"};
1020        case -1910182789: /*expectedSupplyDuration*/ return new String[] {"Duration"};
1021        case 481140686: /*performer*/ return new String[] {"Reference"};
1022        default: return super.getTypesForProperty(hash, name);
1023        }
1024
1025      }
1026
1027      @Override
1028      public Base addChild(String name) throws FHIRException {
1029        if (name.equals("validityPeriod")) {
1030          this.validityPeriod = new Period();
1031          return this.validityPeriod;
1032        }
1033        else if (name.equals("numberOfRepeatsAllowed")) {
1034          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.numberOfRepeatsAllowed");
1035        }
1036        else if (name.equals("quantity")) {
1037          this.quantity = new SimpleQuantity();
1038          return this.quantity;
1039        }
1040        else if (name.equals("expectedSupplyDuration")) {
1041          this.expectedSupplyDuration = new Duration();
1042          return this.expectedSupplyDuration;
1043        }
1044        else if (name.equals("performer")) {
1045          this.performer = new Reference();
1046          return this.performer;
1047        }
1048        else
1049          return super.addChild(name);
1050      }
1051
1052      public MedicationRequestDispenseRequestComponent copy() {
1053        MedicationRequestDispenseRequestComponent dst = new MedicationRequestDispenseRequestComponent();
1054        copyValues(dst);
1055        dst.validityPeriod = validityPeriod == null ? null : validityPeriod.copy();
1056        dst.numberOfRepeatsAllowed = numberOfRepeatsAllowed == null ? null : numberOfRepeatsAllowed.copy();
1057        dst.quantity = quantity == null ? null : quantity.copy();
1058        dst.expectedSupplyDuration = expectedSupplyDuration == null ? null : expectedSupplyDuration.copy();
1059        dst.performer = performer == null ? null : performer.copy();
1060        return dst;
1061      }
1062
1063      @Override
1064      public boolean equalsDeep(Base other) {
1065        if (!super.equalsDeep(other))
1066          return false;
1067        if (!(other instanceof MedicationRequestDispenseRequestComponent))
1068          return false;
1069        MedicationRequestDispenseRequestComponent o = (MedicationRequestDispenseRequestComponent) other;
1070        return compareDeep(validityPeriod, o.validityPeriod, true) && compareDeep(numberOfRepeatsAllowed, o.numberOfRepeatsAllowed, true)
1071           && compareDeep(quantity, o.quantity, true) && compareDeep(expectedSupplyDuration, o.expectedSupplyDuration, true)
1072           && compareDeep(performer, o.performer, true);
1073      }
1074
1075      @Override
1076      public boolean equalsShallow(Base other) {
1077        if (!super.equalsShallow(other))
1078          return false;
1079        if (!(other instanceof MedicationRequestDispenseRequestComponent))
1080          return false;
1081        MedicationRequestDispenseRequestComponent o = (MedicationRequestDispenseRequestComponent) other;
1082        return compareValues(numberOfRepeatsAllowed, o.numberOfRepeatsAllowed, true);
1083      }
1084
1085      public boolean isEmpty() {
1086        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(validityPeriod, numberOfRepeatsAllowed
1087          , quantity, expectedSupplyDuration, performer);
1088      }
1089
1090  public String fhirType() {
1091    return "MedicationRequest.dispenseRequest";
1092
1093  }
1094
1095  }
1096
1097    @Block()
1098    public static class MedicationRequestSubstitutionComponent extends BackboneElement implements IBaseBackboneElement {
1099        /**
1100         * True if the prescriber allows a different drug to be dispensed from what was prescribed.
1101         */
1102        @Child(name = "allowed", type = {BooleanType.class}, order=1, min=1, max=1, modifier=true, summary=false)
1103        @Description(shortDefinition="Whether substitution is allowed or not", formalDefinition="True if the prescriber allows a different drug to be dispensed from what was prescribed." )
1104        protected BooleanType allowed;
1105
1106        /**
1107         * Indicates the reason for the substitution, or why substitution must or must not be performed.
1108         */
1109        @Child(name = "reason", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
1110        @Description(shortDefinition="Why should (not) substitution be made", formalDefinition="Indicates the reason for the substitution, or why substitution must or must not be performed." )
1111        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/v3-SubstanceAdminSubstitutionReason")
1112        protected CodeableConcept reason;
1113
1114        private static final long serialVersionUID = -141547037L;
1115
1116    /**
1117     * Constructor
1118     */
1119      public MedicationRequestSubstitutionComponent() {
1120        super();
1121      }
1122
1123    /**
1124     * Constructor
1125     */
1126      public MedicationRequestSubstitutionComponent(BooleanType allowed) {
1127        super();
1128        this.allowed = allowed;
1129      }
1130
1131        /**
1132         * @return {@link #allowed} (True if the prescriber allows a different drug to be dispensed from what was prescribed.). This is the underlying object with id, value and extensions. The accessor "getAllowed" gives direct access to the value
1133         */
1134        public BooleanType getAllowedElement() { 
1135          if (this.allowed == null)
1136            if (Configuration.errorOnAutoCreate())
1137              throw new Error("Attempt to auto-create MedicationRequestSubstitutionComponent.allowed");
1138            else if (Configuration.doAutoCreate())
1139              this.allowed = new BooleanType(); // bb
1140          return this.allowed;
1141        }
1142
1143        public boolean hasAllowedElement() { 
1144          return this.allowed != null && !this.allowed.isEmpty();
1145        }
1146
1147        public boolean hasAllowed() { 
1148          return this.allowed != null && !this.allowed.isEmpty();
1149        }
1150
1151        /**
1152         * @param value {@link #allowed} (True if the prescriber allows a different drug to be dispensed from what was prescribed.). This is the underlying object with id, value and extensions. The accessor "getAllowed" gives direct access to the value
1153         */
1154        public MedicationRequestSubstitutionComponent setAllowedElement(BooleanType value) { 
1155          this.allowed = value;
1156          return this;
1157        }
1158
1159        /**
1160         * @return True if the prescriber allows a different drug to be dispensed from what was prescribed.
1161         */
1162        public boolean getAllowed() { 
1163          return this.allowed == null || this.allowed.isEmpty() ? false : this.allowed.getValue();
1164        }
1165
1166        /**
1167         * @param value True if the prescriber allows a different drug to be dispensed from what was prescribed.
1168         */
1169        public MedicationRequestSubstitutionComponent setAllowed(boolean value) { 
1170            if (this.allowed == null)
1171              this.allowed = new BooleanType();
1172            this.allowed.setValue(value);
1173          return this;
1174        }
1175
1176        /**
1177         * @return {@link #reason} (Indicates the reason for the substitution, or why substitution must or must not be performed.)
1178         */
1179        public CodeableConcept getReason() { 
1180          if (this.reason == null)
1181            if (Configuration.errorOnAutoCreate())
1182              throw new Error("Attempt to auto-create MedicationRequestSubstitutionComponent.reason");
1183            else if (Configuration.doAutoCreate())
1184              this.reason = new CodeableConcept(); // cc
1185          return this.reason;
1186        }
1187
1188        public boolean hasReason() { 
1189          return this.reason != null && !this.reason.isEmpty();
1190        }
1191
1192        /**
1193         * @param value {@link #reason} (Indicates the reason for the substitution, or why substitution must or must not be performed.)
1194         */
1195        public MedicationRequestSubstitutionComponent setReason(CodeableConcept value) { 
1196          this.reason = value;
1197          return this;
1198        }
1199
1200        protected void listChildren(List<Property> childrenList) {
1201          super.listChildren(childrenList);
1202          childrenList.add(new Property("allowed", "boolean", "True if the prescriber allows a different drug to be dispensed from what was prescribed.", 0, java.lang.Integer.MAX_VALUE, allowed));
1203          childrenList.add(new Property("reason", "CodeableConcept", "Indicates the reason for the substitution, or why substitution must or must not be performed.", 0, java.lang.Integer.MAX_VALUE, reason));
1204        }
1205
1206      @Override
1207      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1208        switch (hash) {
1209        case -911343192: /*allowed*/ return this.allowed == null ? new Base[0] : new Base[] {this.allowed}; // BooleanType
1210        case -934964668: /*reason*/ return this.reason == null ? new Base[0] : new Base[] {this.reason}; // CodeableConcept
1211        default: return super.getProperty(hash, name, checkValid);
1212        }
1213
1214      }
1215
1216      @Override
1217      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1218        switch (hash) {
1219        case -911343192: // allowed
1220          this.allowed = castToBoolean(value); // BooleanType
1221          return value;
1222        case -934964668: // reason
1223          this.reason = castToCodeableConcept(value); // CodeableConcept
1224          return value;
1225        default: return super.setProperty(hash, name, value);
1226        }
1227
1228      }
1229
1230      @Override
1231      public Base setProperty(String name, Base value) throws FHIRException {
1232        if (name.equals("allowed")) {
1233          this.allowed = castToBoolean(value); // BooleanType
1234        } else if (name.equals("reason")) {
1235          this.reason = castToCodeableConcept(value); // CodeableConcept
1236        } else
1237          return super.setProperty(name, value);
1238        return value;
1239      }
1240
1241      @Override
1242      public Base makeProperty(int hash, String name) throws FHIRException {
1243        switch (hash) {
1244        case -911343192:  return getAllowedElement();
1245        case -934964668:  return getReason(); 
1246        default: return super.makeProperty(hash, name);
1247        }
1248
1249      }
1250
1251      @Override
1252      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1253        switch (hash) {
1254        case -911343192: /*allowed*/ return new String[] {"boolean"};
1255        case -934964668: /*reason*/ return new String[] {"CodeableConcept"};
1256        default: return super.getTypesForProperty(hash, name);
1257        }
1258
1259      }
1260
1261      @Override
1262      public Base addChild(String name) throws FHIRException {
1263        if (name.equals("allowed")) {
1264          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.allowed");
1265        }
1266        else if (name.equals("reason")) {
1267          this.reason = new CodeableConcept();
1268          return this.reason;
1269        }
1270        else
1271          return super.addChild(name);
1272      }
1273
1274      public MedicationRequestSubstitutionComponent copy() {
1275        MedicationRequestSubstitutionComponent dst = new MedicationRequestSubstitutionComponent();
1276        copyValues(dst);
1277        dst.allowed = allowed == null ? null : allowed.copy();
1278        dst.reason = reason == null ? null : reason.copy();
1279        return dst;
1280      }
1281
1282      @Override
1283      public boolean equalsDeep(Base other) {
1284        if (!super.equalsDeep(other))
1285          return false;
1286        if (!(other instanceof MedicationRequestSubstitutionComponent))
1287          return false;
1288        MedicationRequestSubstitutionComponent o = (MedicationRequestSubstitutionComponent) other;
1289        return compareDeep(allowed, o.allowed, true) && compareDeep(reason, o.reason, true);
1290      }
1291
1292      @Override
1293      public boolean equalsShallow(Base other) {
1294        if (!super.equalsShallow(other))
1295          return false;
1296        if (!(other instanceof MedicationRequestSubstitutionComponent))
1297          return false;
1298        MedicationRequestSubstitutionComponent o = (MedicationRequestSubstitutionComponent) other;
1299        return compareValues(allowed, o.allowed, true);
1300      }
1301
1302      public boolean isEmpty() {
1303        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(allowed, reason);
1304      }
1305
1306  public String fhirType() {
1307    return "MedicationRequest.substitution";
1308
1309  }
1310
1311  }
1312
1313    /**
1314     * This records identifiers associated with this medication request that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate. For example a re-imbursement system might issue its own id for each prescription that is created.  This is particularly important where FHIR only provides part of an entire workflow process where records must be tracked through an entire system.
1315     */
1316    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1317    @Description(shortDefinition="External ids for this request", formalDefinition="This records identifiers associated with this medication request that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate. For example a re-imbursement system might issue its own id for each prescription that is created.  This is particularly important where FHIR only provides part of an entire workflow process where records must be tracked through an entire system." )
1318    protected List<Identifier> identifier;
1319
1320    /**
1321     * Protocol or definition followed by this request.
1322     */
1323    @Child(name = "definition", type = {ActivityDefinition.class, PlanDefinition.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1324    @Description(shortDefinition="Protocol or definition", formalDefinition="Protocol or definition followed by this request." )
1325    protected List<Reference> definition;
1326    /**
1327     * The actual objects that are the target of the reference (Protocol or definition followed by this request.)
1328     */
1329    protected List<Resource> definitionTarget;
1330
1331
1332    /**
1333     * A plan or request that is fulfilled in whole or in part by this medication request.
1334     */
1335    @Child(name = "basedOn", type = {CarePlan.class, MedicationRequest.class, ProcedureRequest.class, ReferralRequest.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1336    @Description(shortDefinition="What request fulfills", formalDefinition="A plan or request that is fulfilled in whole or in part by this medication request." )
1337    protected List<Reference> basedOn;
1338    /**
1339     * The actual objects that are the target of the reference (A plan or request that is fulfilled in whole or in part by this medication request.)
1340     */
1341    protected List<Resource> basedOnTarget;
1342
1343
1344    /**
1345     * A shared identifier common to all requests that were authorized more or less simultaneously by a single author, representing the identifier of the requisition or prescription.
1346     */
1347    @Child(name = "groupIdentifier", type = {Identifier.class}, order=3, min=0, max=1, modifier=false, summary=true)
1348    @Description(shortDefinition="Composite request this is part of", formalDefinition="A shared identifier common to all requests that were authorized more or less simultaneously by a single author, representing the identifier of the requisition or prescription." )
1349    protected Identifier groupIdentifier;
1350
1351    /**
1352     * A code specifying the current state of the order.  Generally this will be active or completed state.
1353     */
1354    @Child(name = "status", type = {CodeType.class}, order=4, min=0, max=1, modifier=true, summary=true)
1355    @Description(shortDefinition="active | on-hold | cancelled | completed | entered-in-error | stopped | draft | unknown", formalDefinition="A code specifying the current state of the order.  Generally this will be active or completed state." )
1356    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-request-status")
1357    protected Enumeration<MedicationRequestStatus> status;
1358
1359    /**
1360     * Whether the request is a proposal, plan, or an original order.
1361     */
1362    @Child(name = "intent", type = {CodeType.class}, order=5, min=1, max=1, modifier=true, summary=true)
1363    @Description(shortDefinition="proposal | plan | order | instance-order", formalDefinition="Whether the request is a proposal, plan, or an original order." )
1364    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-request-intent")
1365    protected Enumeration<MedicationRequestIntent> intent;
1366
1367    /**
1368     * Indicates the type of medication order and where the medication is expected to be consumed or administered.
1369     */
1370    @Child(name = "category", type = {CodeableConcept.class}, order=6, min=0, max=1, modifier=false, summary=false)
1371    @Description(shortDefinition="Type of medication usage", formalDefinition="Indicates the type of medication order and where the medication is expected to be consumed or administered." )
1372    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-request-category")
1373    protected CodeableConcept category;
1374
1375    /**
1376     * Indicates how quickly the Medication Request should be addressed with respect to other requests.
1377     */
1378    @Child(name = "priority", type = {CodeType.class}, order=7, min=0, max=1, modifier=false, summary=true)
1379    @Description(shortDefinition="routine | urgent | stat | asap", formalDefinition="Indicates how quickly the Medication Request should be addressed with respect to other requests." )
1380    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-request-priority")
1381    protected Enumeration<MedicationRequestPriority> priority;
1382
1383    /**
1384     * Identifies the medication being requested. This is a link to a resource that represents the medication which may be the details of the medication or simply an attribute carrying a code that identifies the medication from a known list of medications.
1385     */
1386    @Child(name = "medication", type = {CodeableConcept.class, Medication.class}, order=8, min=1, max=1, modifier=false, summary=true)
1387    @Description(shortDefinition="Medication to be taken", formalDefinition="Identifies the medication being requested. This is a link to a resource that represents the medication which may be the details of the medication or simply an attribute carrying a code that identifies the medication from a known list of medications." )
1388    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-codes")
1389    protected Type medication;
1390
1391    /**
1392     * A link to a resource representing the person or set of individuals to whom the medication will be given.
1393     */
1394    @Child(name = "subject", type = {Patient.class, Group.class}, order=9, min=1, max=1, modifier=false, summary=true)
1395    @Description(shortDefinition="Who or group medication request is for", formalDefinition="A link to a resource representing the person or set of individuals to whom the medication will be given." )
1396    protected Reference subject;
1397
1398    /**
1399     * The actual object that is the target of the reference (A link to a resource representing the person or set of individuals to whom the medication will be given.)
1400     */
1401    protected Resource subjectTarget;
1402
1403    /**
1404     * A link to an encounter, or episode of care, that identifies the particular occurrence or set occurrences of contact between patient and health care provider.
1405     */
1406    @Child(name = "context", type = {Encounter.class, EpisodeOfCare.class}, order=10, min=0, max=1, modifier=false, summary=false)
1407    @Description(shortDefinition="Created during encounter/admission/stay", formalDefinition="A link to an encounter, or episode of care, that identifies the particular occurrence or set occurrences of contact between patient and health care provider." )
1408    protected Reference context;
1409
1410    /**
1411     * The actual object that is the target of the reference (A link to an encounter, or episode of care, that identifies the particular occurrence or set occurrences of contact between patient and health care provider.)
1412     */
1413    protected Resource contextTarget;
1414
1415    /**
1416     * Include additional information (for example, patient height and weight) that supports the ordering of the medication.
1417     */
1418    @Child(name = "supportingInformation", type = {Reference.class}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1419    @Description(shortDefinition="Information to support ordering of the medication", formalDefinition="Include additional information (for example, patient height and weight) that supports the ordering of the medication." )
1420    protected List<Reference> supportingInformation;
1421    /**
1422     * The actual objects that are the target of the reference (Include additional information (for example, patient height and weight) that supports the ordering of the medication.)
1423     */
1424    protected List<Resource> supportingInformationTarget;
1425
1426
1427    /**
1428     * The date (and perhaps time) when the prescription was initially written or authored on.
1429     */
1430    @Child(name = "authoredOn", type = {DateTimeType.class}, order=12, min=0, max=1, modifier=false, summary=true)
1431    @Description(shortDefinition="When request was initially authored", formalDefinition="The date (and perhaps time) when the prescription was initially written or authored on." )
1432    protected DateTimeType authoredOn;
1433
1434    /**
1435     * The individual, organization or device that initiated the request and has responsibility for its activation.
1436     */
1437    @Child(name = "requester", type = {}, order=13, min=0, max=1, modifier=false, summary=true)
1438    @Description(shortDefinition="Who/What requested the Request", formalDefinition="The individual, organization or device that initiated the request and has responsibility for its activation." )
1439    protected MedicationRequestRequesterComponent requester;
1440
1441    /**
1442     * The person who entered the order on behalf of another individual for example in the case of a verbal or a telephone order.
1443     */
1444    @Child(name = "recorder", type = {Practitioner.class}, order=14, min=0, max=1, modifier=false, summary=false)
1445    @Description(shortDefinition="Person who entered the request", formalDefinition="The person who entered the order on behalf of another individual for example in the case of a verbal or a telephone order." )
1446    protected Reference recorder;
1447
1448    /**
1449     * The actual object that is the target of the reference (The person who entered the order on behalf of another individual for example in the case of a verbal or a telephone order.)
1450     */
1451    protected Practitioner recorderTarget;
1452
1453    /**
1454     * The reason or the indication for ordering the medication.
1455     */
1456    @Child(name = "reasonCode", type = {CodeableConcept.class}, order=15, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1457    @Description(shortDefinition="Reason or indication for writing the prescription", formalDefinition="The reason or the indication for ordering the medication." )
1458    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/condition-code")
1459    protected List<CodeableConcept> reasonCode;
1460
1461    /**
1462     * Condition or observation that supports why the medication was ordered.
1463     */
1464    @Child(name = "reasonReference", type = {Condition.class, Observation.class}, order=16, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1465    @Description(shortDefinition="Condition or Observation that supports why the prescription is being written", formalDefinition="Condition or observation that supports why the medication was ordered." )
1466    protected List<Reference> reasonReference;
1467    /**
1468     * The actual objects that are the target of the reference (Condition or observation that supports why the medication was ordered.)
1469     */
1470    protected List<Resource> reasonReferenceTarget;
1471
1472
1473    /**
1474     * Extra information about the prescription that could not be conveyed by the other attributes.
1475     */
1476    @Child(name = "note", type = {Annotation.class}, order=17, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1477    @Description(shortDefinition="Information about the prescription", formalDefinition="Extra information about the prescription that could not be conveyed by the other attributes." )
1478    protected List<Annotation> note;
1479
1480    /**
1481     * Indicates how the medication is to be used by the patient.
1482     */
1483    @Child(name = "dosageInstruction", type = {Dosage.class}, order=18, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1484    @Description(shortDefinition="How the medication should be taken", formalDefinition="Indicates how the medication is to be used by the patient." )
1485    protected List<Dosage> dosageInstruction;
1486
1487    /**
1488     * Indicates the specific details for the dispense or medication supply part of a medication request (also known as a Medication Prescription or Medication Order).  Note that this information is not always sent with the order.  There may be in some settings (e.g. hospitals) institutional or system support for completing the dispense details in the pharmacy department.
1489     */
1490    @Child(name = "dispenseRequest", type = {}, order=19, min=0, max=1, modifier=false, summary=false)
1491    @Description(shortDefinition="Medication supply authorization", formalDefinition="Indicates the specific details for the dispense or medication supply part of a medication request (also known as a Medication Prescription or Medication Order).  Note that this information is not always sent with the order.  There may be in some settings (e.g. hospitals) institutional or system support for completing the dispense details in the pharmacy department." )
1492    protected MedicationRequestDispenseRequestComponent dispenseRequest;
1493
1494    /**
1495     * Indicates whether or not substitution can or should be part of the dispense. In some cases substitution must happen, in other cases substitution must not happen. This block explains the prescriber's intent. If nothing is specified substitution may be done.
1496     */
1497    @Child(name = "substitution", type = {}, order=20, min=0, max=1, modifier=false, summary=false)
1498    @Description(shortDefinition="Any restrictions on medication substitution", formalDefinition="Indicates whether or not substitution can or should be part of the dispense. In some cases substitution must happen, in other cases substitution must not happen. This block explains the prescriber's intent. If nothing is specified substitution may be done." )
1499    protected MedicationRequestSubstitutionComponent substitution;
1500
1501    /**
1502     * A link to a resource representing an earlier order related order or prescription.
1503     */
1504    @Child(name = "priorPrescription", type = {MedicationRequest.class}, order=21, min=0, max=1, modifier=false, summary=false)
1505    @Description(shortDefinition="An order/prescription that is being replaced", formalDefinition="A link to a resource representing an earlier order related order or prescription." )
1506    protected Reference priorPrescription;
1507
1508    /**
1509     * The actual object that is the target of the reference (A link to a resource representing an earlier order related order or prescription.)
1510     */
1511    protected MedicationRequest priorPrescriptionTarget;
1512
1513    /**
1514     * Indicates an actual or potential clinical issue with or between one or more active or proposed clinical actions for a patient; e.g. Drug-drug interaction, duplicate therapy, dosage alert etc.
1515     */
1516    @Child(name = "detectedIssue", type = {DetectedIssue.class}, order=22, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1517    @Description(shortDefinition="Clinical Issue with action", formalDefinition="Indicates an actual or potential clinical issue with or between one or more active or proposed clinical actions for a patient; e.g. Drug-drug interaction, duplicate therapy, dosage alert etc." )
1518    protected List<Reference> detectedIssue;
1519    /**
1520     * The actual objects that are the target of the reference (Indicates an actual or potential clinical issue with or between one or more active or proposed clinical actions for a patient; e.g. Drug-drug interaction, duplicate therapy, dosage alert etc.)
1521     */
1522    protected List<DetectedIssue> detectedIssueTarget;
1523
1524
1525    /**
1526     * Links to Provenance records for past versions of this resource or fulfilling request or event resources that identify key state transitions or updates that are likely to be relevant to a user looking at the current version of the resource.
1527     */
1528    @Child(name = "eventHistory", type = {Provenance.class}, order=23, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1529    @Description(shortDefinition="A list of events of interest in the lifecycle", formalDefinition="Links to Provenance records for past versions of this resource or fulfilling request or event resources that identify key state transitions or updates that are likely to be relevant to a user looking at the current version of the resource." )
1530    protected List<Reference> eventHistory;
1531    /**
1532     * The actual objects that are the target of the reference (Links to Provenance records for past versions of this resource or fulfilling request or event resources that identify key state transitions or updates that are likely to be relevant to a user looking at the current version of the resource.)
1533     */
1534    protected List<Provenance> eventHistoryTarget;
1535
1536
1537    private static final long serialVersionUID = 299392400L;
1538
1539  /**
1540   * Constructor
1541   */
1542    public MedicationRequest() {
1543      super();
1544    }
1545
1546  /**
1547   * Constructor
1548   */
1549    public MedicationRequest(Enumeration<MedicationRequestIntent> intent, Type medication, Reference subject) {
1550      super();
1551      this.intent = intent;
1552      this.medication = medication;
1553      this.subject = subject;
1554    }
1555
1556    /**
1557     * @return {@link #identifier} (This records identifiers associated with this medication request that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate. For example a re-imbursement system might issue its own id for each prescription that is created.  This is particularly important where FHIR only provides part of an entire workflow process where records must be tracked through an entire system.)
1558     */
1559    public List<Identifier> getIdentifier() { 
1560      if (this.identifier == null)
1561        this.identifier = new ArrayList<Identifier>();
1562      return this.identifier;
1563    }
1564
1565    /**
1566     * @return Returns a reference to <code>this</code> for easy method chaining
1567     */
1568    public MedicationRequest setIdentifier(List<Identifier> theIdentifier) { 
1569      this.identifier = theIdentifier;
1570      return this;
1571    }
1572
1573    public boolean hasIdentifier() { 
1574      if (this.identifier == null)
1575        return false;
1576      for (Identifier item : this.identifier)
1577        if (!item.isEmpty())
1578          return true;
1579      return false;
1580    }
1581
1582    public Identifier addIdentifier() { //3
1583      Identifier t = new Identifier();
1584      if (this.identifier == null)
1585        this.identifier = new ArrayList<Identifier>();
1586      this.identifier.add(t);
1587      return t;
1588    }
1589
1590    public MedicationRequest addIdentifier(Identifier t) { //3
1591      if (t == null)
1592        return this;
1593      if (this.identifier == null)
1594        this.identifier = new ArrayList<Identifier>();
1595      this.identifier.add(t);
1596      return this;
1597    }
1598
1599    /**
1600     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
1601     */
1602    public Identifier getIdentifierFirstRep() { 
1603      if (getIdentifier().isEmpty()) {
1604        addIdentifier();
1605      }
1606      return getIdentifier().get(0);
1607    }
1608
1609    /**
1610     * @return {@link #definition} (Protocol or definition followed by this request.)
1611     */
1612    public List<Reference> getDefinition() { 
1613      if (this.definition == null)
1614        this.definition = new ArrayList<Reference>();
1615      return this.definition;
1616    }
1617
1618    /**
1619     * @return Returns a reference to <code>this</code> for easy method chaining
1620     */
1621    public MedicationRequest setDefinition(List<Reference> theDefinition) { 
1622      this.definition = theDefinition;
1623      return this;
1624    }
1625
1626    public boolean hasDefinition() { 
1627      if (this.definition == null)
1628        return false;
1629      for (Reference item : this.definition)
1630        if (!item.isEmpty())
1631          return true;
1632      return false;
1633    }
1634
1635    public Reference addDefinition() { //3
1636      Reference t = new Reference();
1637      if (this.definition == null)
1638        this.definition = new ArrayList<Reference>();
1639      this.definition.add(t);
1640      return t;
1641    }
1642
1643    public MedicationRequest addDefinition(Reference t) { //3
1644      if (t == null)
1645        return this;
1646      if (this.definition == null)
1647        this.definition = new ArrayList<Reference>();
1648      this.definition.add(t);
1649      return this;
1650    }
1651
1652    /**
1653     * @return The first repetition of repeating field {@link #definition}, creating it if it does not already exist
1654     */
1655    public Reference getDefinitionFirstRep() { 
1656      if (getDefinition().isEmpty()) {
1657        addDefinition();
1658      }
1659      return getDefinition().get(0);
1660    }
1661
1662    /**
1663     * @deprecated Use Reference#setResource(IBaseResource) instead
1664     */
1665    @Deprecated
1666    public List<Resource> getDefinitionTarget() { 
1667      if (this.definitionTarget == null)
1668        this.definitionTarget = new ArrayList<Resource>();
1669      return this.definitionTarget;
1670    }
1671
1672    /**
1673     * @return {@link #basedOn} (A plan or request that is fulfilled in whole or in part by this medication request.)
1674     */
1675    public List<Reference> getBasedOn() { 
1676      if (this.basedOn == null)
1677        this.basedOn = new ArrayList<Reference>();
1678      return this.basedOn;
1679    }
1680
1681    /**
1682     * @return Returns a reference to <code>this</code> for easy method chaining
1683     */
1684    public MedicationRequest setBasedOn(List<Reference> theBasedOn) { 
1685      this.basedOn = theBasedOn;
1686      return this;
1687    }
1688
1689    public boolean hasBasedOn() { 
1690      if (this.basedOn == null)
1691        return false;
1692      for (Reference item : this.basedOn)
1693        if (!item.isEmpty())
1694          return true;
1695      return false;
1696    }
1697
1698    public Reference addBasedOn() { //3
1699      Reference t = new Reference();
1700      if (this.basedOn == null)
1701        this.basedOn = new ArrayList<Reference>();
1702      this.basedOn.add(t);
1703      return t;
1704    }
1705
1706    public MedicationRequest addBasedOn(Reference t) { //3
1707      if (t == null)
1708        return this;
1709      if (this.basedOn == null)
1710        this.basedOn = new ArrayList<Reference>();
1711      this.basedOn.add(t);
1712      return this;
1713    }
1714
1715    /**
1716     * @return The first repetition of repeating field {@link #basedOn}, creating it if it does not already exist
1717     */
1718    public Reference getBasedOnFirstRep() { 
1719      if (getBasedOn().isEmpty()) {
1720        addBasedOn();
1721      }
1722      return getBasedOn().get(0);
1723    }
1724
1725    /**
1726     * @deprecated Use Reference#setResource(IBaseResource) instead
1727     */
1728    @Deprecated
1729    public List<Resource> getBasedOnTarget() { 
1730      if (this.basedOnTarget == null)
1731        this.basedOnTarget = new ArrayList<Resource>();
1732      return this.basedOnTarget;
1733    }
1734
1735    /**
1736     * @return {@link #groupIdentifier} (A shared identifier common to all requests that were authorized more or less simultaneously by a single author, representing the identifier of the requisition or prescription.)
1737     */
1738    public Identifier getGroupIdentifier() { 
1739      if (this.groupIdentifier == null)
1740        if (Configuration.errorOnAutoCreate())
1741          throw new Error("Attempt to auto-create MedicationRequest.groupIdentifier");
1742        else if (Configuration.doAutoCreate())
1743          this.groupIdentifier = new Identifier(); // cc
1744      return this.groupIdentifier;
1745    }
1746
1747    public boolean hasGroupIdentifier() { 
1748      return this.groupIdentifier != null && !this.groupIdentifier.isEmpty();
1749    }
1750
1751    /**
1752     * @param value {@link #groupIdentifier} (A shared identifier common to all requests that were authorized more or less simultaneously by a single author, representing the identifier of the requisition or prescription.)
1753     */
1754    public MedicationRequest setGroupIdentifier(Identifier value) { 
1755      this.groupIdentifier = value;
1756      return this;
1757    }
1758
1759    /**
1760     * @return {@link #status} (A code specifying the current state of the order.  Generally this will be active or completed state.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1761     */
1762    public Enumeration<MedicationRequestStatus> getStatusElement() { 
1763      if (this.status == null)
1764        if (Configuration.errorOnAutoCreate())
1765          throw new Error("Attempt to auto-create MedicationRequest.status");
1766        else if (Configuration.doAutoCreate())
1767          this.status = new Enumeration<MedicationRequestStatus>(new MedicationRequestStatusEnumFactory()); // bb
1768      return this.status;
1769    }
1770
1771    public boolean hasStatusElement() { 
1772      return this.status != null && !this.status.isEmpty();
1773    }
1774
1775    public boolean hasStatus() { 
1776      return this.status != null && !this.status.isEmpty();
1777    }
1778
1779    /**
1780     * @param value {@link #status} (A code specifying the current state of the order.  Generally this will be active or completed state.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1781     */
1782    public MedicationRequest setStatusElement(Enumeration<MedicationRequestStatus> value) { 
1783      this.status = value;
1784      return this;
1785    }
1786
1787    /**
1788     * @return A code specifying the current state of the order.  Generally this will be active or completed state.
1789     */
1790    public MedicationRequestStatus getStatus() { 
1791      return this.status == null ? null : this.status.getValue();
1792    }
1793
1794    /**
1795     * @param value A code specifying the current state of the order.  Generally this will be active or completed state.
1796     */
1797    public MedicationRequest setStatus(MedicationRequestStatus value) { 
1798      if (value == null)
1799        this.status = null;
1800      else {
1801        if (this.status == null)
1802          this.status = new Enumeration<MedicationRequestStatus>(new MedicationRequestStatusEnumFactory());
1803        this.status.setValue(value);
1804      }
1805      return this;
1806    }
1807
1808    /**
1809     * @return {@link #intent} (Whether the request is a proposal, plan, or an original order.). This is the underlying object with id, value and extensions. The accessor "getIntent" gives direct access to the value
1810     */
1811    public Enumeration<MedicationRequestIntent> getIntentElement() { 
1812      if (this.intent == null)
1813        if (Configuration.errorOnAutoCreate())
1814          throw new Error("Attempt to auto-create MedicationRequest.intent");
1815        else if (Configuration.doAutoCreate())
1816          this.intent = new Enumeration<MedicationRequestIntent>(new MedicationRequestIntentEnumFactory()); // bb
1817      return this.intent;
1818    }
1819
1820    public boolean hasIntentElement() { 
1821      return this.intent != null && !this.intent.isEmpty();
1822    }
1823
1824    public boolean hasIntent() { 
1825      return this.intent != null && !this.intent.isEmpty();
1826    }
1827
1828    /**
1829     * @param value {@link #intent} (Whether the request is a proposal, plan, or an original order.). This is the underlying object with id, value and extensions. The accessor "getIntent" gives direct access to the value
1830     */
1831    public MedicationRequest setIntentElement(Enumeration<MedicationRequestIntent> value) { 
1832      this.intent = value;
1833      return this;
1834    }
1835
1836    /**
1837     * @return Whether the request is a proposal, plan, or an original order.
1838     */
1839    public MedicationRequestIntent getIntent() { 
1840      return this.intent == null ? null : this.intent.getValue();
1841    }
1842
1843    /**
1844     * @param value Whether the request is a proposal, plan, or an original order.
1845     */
1846    public MedicationRequest setIntent(MedicationRequestIntent value) { 
1847        if (this.intent == null)
1848          this.intent = new Enumeration<MedicationRequestIntent>(new MedicationRequestIntentEnumFactory());
1849        this.intent.setValue(value);
1850      return this;
1851    }
1852
1853    /**
1854     * @return {@link #category} (Indicates the type of medication order and where the medication is expected to be consumed or administered.)
1855     */
1856    public CodeableConcept getCategory() { 
1857      if (this.category == null)
1858        if (Configuration.errorOnAutoCreate())
1859          throw new Error("Attempt to auto-create MedicationRequest.category");
1860        else if (Configuration.doAutoCreate())
1861          this.category = new CodeableConcept(); // cc
1862      return this.category;
1863    }
1864
1865    public boolean hasCategory() { 
1866      return this.category != null && !this.category.isEmpty();
1867    }
1868
1869    /**
1870     * @param value {@link #category} (Indicates the type of medication order and where the medication is expected to be consumed or administered.)
1871     */
1872    public MedicationRequest setCategory(CodeableConcept value) { 
1873      this.category = value;
1874      return this;
1875    }
1876
1877    /**
1878     * @return {@link #priority} (Indicates how quickly the Medication Request 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
1879     */
1880    public Enumeration<MedicationRequestPriority> getPriorityElement() { 
1881      if (this.priority == null)
1882        if (Configuration.errorOnAutoCreate())
1883          throw new Error("Attempt to auto-create MedicationRequest.priority");
1884        else if (Configuration.doAutoCreate())
1885          this.priority = new Enumeration<MedicationRequestPriority>(new MedicationRequestPriorityEnumFactory()); // bb
1886      return this.priority;
1887    }
1888
1889    public boolean hasPriorityElement() { 
1890      return this.priority != null && !this.priority.isEmpty();
1891    }
1892
1893    public boolean hasPriority() { 
1894      return this.priority != null && !this.priority.isEmpty();
1895    }
1896
1897    /**
1898     * @param value {@link #priority} (Indicates how quickly the Medication Request 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
1899     */
1900    public MedicationRequest setPriorityElement(Enumeration<MedicationRequestPriority> value) { 
1901      this.priority = value;
1902      return this;
1903    }
1904
1905    /**
1906     * @return Indicates how quickly the Medication Request should be addressed with respect to other requests.
1907     */
1908    public MedicationRequestPriority getPriority() { 
1909      return this.priority == null ? null : this.priority.getValue();
1910    }
1911
1912    /**
1913     * @param value Indicates how quickly the Medication Request should be addressed with respect to other requests.
1914     */
1915    public MedicationRequest setPriority(MedicationRequestPriority value) { 
1916      if (value == null)
1917        this.priority = null;
1918      else {
1919        if (this.priority == null)
1920          this.priority = new Enumeration<MedicationRequestPriority>(new MedicationRequestPriorityEnumFactory());
1921        this.priority.setValue(value);
1922      }
1923      return this;
1924    }
1925
1926    /**
1927     * @return {@link #medication} (Identifies the medication being requested. This is a link to a resource that represents the medication which may be the details of the medication or simply an attribute carrying a code that identifies the medication from a known list of medications.)
1928     */
1929    public Type getMedication() { 
1930      return this.medication;
1931    }
1932
1933    /**
1934     * @return {@link #medication} (Identifies the medication being requested. This is a link to a resource that represents the medication which may be the details of the medication or simply an attribute carrying a code that identifies the medication from a known list of medications.)
1935     */
1936    public CodeableConcept getMedicationCodeableConcept() throws FHIRException { 
1937      if (!(this.medication instanceof CodeableConcept))
1938        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.medication.getClass().getName()+" was encountered");
1939      return (CodeableConcept) this.medication;
1940    }
1941
1942    public boolean hasMedicationCodeableConcept() { 
1943      return this.medication instanceof CodeableConcept;
1944    }
1945
1946    /**
1947     * @return {@link #medication} (Identifies the medication being requested. This is a link to a resource that represents the medication which may be the details of the medication or simply an attribute carrying a code that identifies the medication from a known list of medications.)
1948     */
1949    public Reference getMedicationReference() throws FHIRException { 
1950      if (!(this.medication instanceof Reference))
1951        throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.medication.getClass().getName()+" was encountered");
1952      return (Reference) this.medication;
1953    }
1954
1955    public boolean hasMedicationReference() { 
1956      return this.medication instanceof Reference;
1957    }
1958
1959    public boolean hasMedication() { 
1960      return this.medication != null && !this.medication.isEmpty();
1961    }
1962
1963    /**
1964     * @param value {@link #medication} (Identifies the medication being requested. This is a link to a resource that represents the medication which may be the details of the medication or simply an attribute carrying a code that identifies the medication from a known list of medications.)
1965     */
1966    public MedicationRequest setMedication(Type value) { 
1967      this.medication = value;
1968      return this;
1969    }
1970
1971    /**
1972     * @return {@link #subject} (A link to a resource representing the person or set of individuals to whom the medication will be given.)
1973     */
1974    public Reference getSubject() { 
1975      if (this.subject == null)
1976        if (Configuration.errorOnAutoCreate())
1977          throw new Error("Attempt to auto-create MedicationRequest.subject");
1978        else if (Configuration.doAutoCreate())
1979          this.subject = new Reference(); // cc
1980      return this.subject;
1981    }
1982
1983    public boolean hasSubject() { 
1984      return this.subject != null && !this.subject.isEmpty();
1985    }
1986
1987    /**
1988     * @param value {@link #subject} (A link to a resource representing the person or set of individuals to whom the medication will be given.)
1989     */
1990    public MedicationRequest setSubject(Reference value) { 
1991      this.subject = value;
1992      return this;
1993    }
1994
1995    /**
1996     * @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. (A link to a resource representing the person or set of individuals to whom the medication will be given.)
1997     */
1998    public Resource getSubjectTarget() { 
1999      return this.subjectTarget;
2000    }
2001
2002    /**
2003     * @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. (A link to a resource representing the person or set of individuals to whom the medication will be given.)
2004     */
2005    public MedicationRequest setSubjectTarget(Resource value) { 
2006      this.subjectTarget = value;
2007      return this;
2008    }
2009
2010    /**
2011     * @return {@link #context} (A link to an encounter, or episode of care, that identifies the particular occurrence or set occurrences of contact between patient and health care provider.)
2012     */
2013    public Reference getContext() { 
2014      if (this.context == null)
2015        if (Configuration.errorOnAutoCreate())
2016          throw new Error("Attempt to auto-create MedicationRequest.context");
2017        else if (Configuration.doAutoCreate())
2018          this.context = new Reference(); // cc
2019      return this.context;
2020    }
2021
2022    public boolean hasContext() { 
2023      return this.context != null && !this.context.isEmpty();
2024    }
2025
2026    /**
2027     * @param value {@link #context} (A link to an encounter, or episode of care, that identifies the particular occurrence or set occurrences of contact between patient and health care provider.)
2028     */
2029    public MedicationRequest setContext(Reference value) { 
2030      this.context = value;
2031      return this;
2032    }
2033
2034    /**
2035     * @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. (A link to an encounter, or episode of care, that identifies the particular occurrence or set occurrences of contact between patient and health care provider.)
2036     */
2037    public Resource getContextTarget() { 
2038      return this.contextTarget;
2039    }
2040
2041    /**
2042     * @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. (A link to an encounter, or episode of care, that identifies the particular occurrence or set occurrences of contact between patient and health care provider.)
2043     */
2044    public MedicationRequest setContextTarget(Resource value) { 
2045      this.contextTarget = value;
2046      return this;
2047    }
2048
2049    /**
2050     * @return {@link #supportingInformation} (Include additional information (for example, patient height and weight) that supports the ordering of the medication.)
2051     */
2052    public List<Reference> getSupportingInformation() { 
2053      if (this.supportingInformation == null)
2054        this.supportingInformation = new ArrayList<Reference>();
2055      return this.supportingInformation;
2056    }
2057
2058    /**
2059     * @return Returns a reference to <code>this</code> for easy method chaining
2060     */
2061    public MedicationRequest setSupportingInformation(List<Reference> theSupportingInformation) { 
2062      this.supportingInformation = theSupportingInformation;
2063      return this;
2064    }
2065
2066    public boolean hasSupportingInformation() { 
2067      if (this.supportingInformation == null)
2068        return false;
2069      for (Reference item : this.supportingInformation)
2070        if (!item.isEmpty())
2071          return true;
2072      return false;
2073    }
2074
2075    public Reference addSupportingInformation() { //3
2076      Reference t = new Reference();
2077      if (this.supportingInformation == null)
2078        this.supportingInformation = new ArrayList<Reference>();
2079      this.supportingInformation.add(t);
2080      return t;
2081    }
2082
2083    public MedicationRequest addSupportingInformation(Reference t) { //3
2084      if (t == null)
2085        return this;
2086      if (this.supportingInformation == null)
2087        this.supportingInformation = new ArrayList<Reference>();
2088      this.supportingInformation.add(t);
2089      return this;
2090    }
2091
2092    /**
2093     * @return The first repetition of repeating field {@link #supportingInformation}, creating it if it does not already exist
2094     */
2095    public Reference getSupportingInformationFirstRep() { 
2096      if (getSupportingInformation().isEmpty()) {
2097        addSupportingInformation();
2098      }
2099      return getSupportingInformation().get(0);
2100    }
2101
2102    /**
2103     * @deprecated Use Reference#setResource(IBaseResource) instead
2104     */
2105    @Deprecated
2106    public List<Resource> getSupportingInformationTarget() { 
2107      if (this.supportingInformationTarget == null)
2108        this.supportingInformationTarget = new ArrayList<Resource>();
2109      return this.supportingInformationTarget;
2110    }
2111
2112    /**
2113     * @return {@link #authoredOn} (The date (and perhaps time) when the prescription was initially written or authored on.). This is the underlying object with id, value and extensions. The accessor "getAuthoredOn" gives direct access to the value
2114     */
2115    public DateTimeType getAuthoredOnElement() { 
2116      if (this.authoredOn == null)
2117        if (Configuration.errorOnAutoCreate())
2118          throw new Error("Attempt to auto-create MedicationRequest.authoredOn");
2119        else if (Configuration.doAutoCreate())
2120          this.authoredOn = new DateTimeType(); // bb
2121      return this.authoredOn;
2122    }
2123
2124    public boolean hasAuthoredOnElement() { 
2125      return this.authoredOn != null && !this.authoredOn.isEmpty();
2126    }
2127
2128    public boolean hasAuthoredOn() { 
2129      return this.authoredOn != null && !this.authoredOn.isEmpty();
2130    }
2131
2132    /**
2133     * @param value {@link #authoredOn} (The date (and perhaps time) when the prescription was initially written or authored on.). This is the underlying object with id, value and extensions. The accessor "getAuthoredOn" gives direct access to the value
2134     */
2135    public MedicationRequest setAuthoredOnElement(DateTimeType value) { 
2136      this.authoredOn = value;
2137      return this;
2138    }
2139
2140    /**
2141     * @return The date (and perhaps time) when the prescription was initially written or authored on.
2142     */
2143    public Date getAuthoredOn() { 
2144      return this.authoredOn == null ? null : this.authoredOn.getValue();
2145    }
2146
2147    /**
2148     * @param value The date (and perhaps time) when the prescription was initially written or authored on.
2149     */
2150    public MedicationRequest setAuthoredOn(Date value) { 
2151      if (value == null)
2152        this.authoredOn = null;
2153      else {
2154        if (this.authoredOn == null)
2155          this.authoredOn = new DateTimeType();
2156        this.authoredOn.setValue(value);
2157      }
2158      return this;
2159    }
2160
2161    /**
2162     * @return {@link #requester} (The individual, organization or device that initiated the request and has responsibility for its activation.)
2163     */
2164    public MedicationRequestRequesterComponent getRequester() { 
2165      if (this.requester == null)
2166        if (Configuration.errorOnAutoCreate())
2167          throw new Error("Attempt to auto-create MedicationRequest.requester");
2168        else if (Configuration.doAutoCreate())
2169          this.requester = new MedicationRequestRequesterComponent(); // cc
2170      return this.requester;
2171    }
2172
2173    public boolean hasRequester() { 
2174      return this.requester != null && !this.requester.isEmpty();
2175    }
2176
2177    /**
2178     * @param value {@link #requester} (The individual, organization or device that initiated the request and has responsibility for its activation.)
2179     */
2180    public MedicationRequest setRequester(MedicationRequestRequesterComponent value) { 
2181      this.requester = value;
2182      return this;
2183    }
2184
2185    /**
2186     * @return {@link #recorder} (The person who entered the order on behalf of another individual for example in the case of a verbal or a telephone order.)
2187     */
2188    public Reference getRecorder() { 
2189      if (this.recorder == null)
2190        if (Configuration.errorOnAutoCreate())
2191          throw new Error("Attempt to auto-create MedicationRequest.recorder");
2192        else if (Configuration.doAutoCreate())
2193          this.recorder = new Reference(); // cc
2194      return this.recorder;
2195    }
2196
2197    public boolean hasRecorder() { 
2198      return this.recorder != null && !this.recorder.isEmpty();
2199    }
2200
2201    /**
2202     * @param value {@link #recorder} (The person who entered the order on behalf of another individual for example in the case of a verbal or a telephone order.)
2203     */
2204    public MedicationRequest setRecorder(Reference value) { 
2205      this.recorder = value;
2206      return this;
2207    }
2208
2209    /**
2210     * @return {@link #recorder} 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 person who entered the order on behalf of another individual for example in the case of a verbal or a telephone order.)
2211     */
2212    public Practitioner getRecorderTarget() { 
2213      if (this.recorderTarget == null)
2214        if (Configuration.errorOnAutoCreate())
2215          throw new Error("Attempt to auto-create MedicationRequest.recorder");
2216        else if (Configuration.doAutoCreate())
2217          this.recorderTarget = new Practitioner(); // aa
2218      return this.recorderTarget;
2219    }
2220
2221    /**
2222     * @param value {@link #recorder} 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 person who entered the order on behalf of another individual for example in the case of a verbal or a telephone order.)
2223     */
2224    public MedicationRequest setRecorderTarget(Practitioner value) { 
2225      this.recorderTarget = value;
2226      return this;
2227    }
2228
2229    /**
2230     * @return {@link #reasonCode} (The reason or the indication for ordering the medication.)
2231     */
2232    public List<CodeableConcept> getReasonCode() { 
2233      if (this.reasonCode == null)
2234        this.reasonCode = new ArrayList<CodeableConcept>();
2235      return this.reasonCode;
2236    }
2237
2238    /**
2239     * @return Returns a reference to <code>this</code> for easy method chaining
2240     */
2241    public MedicationRequest setReasonCode(List<CodeableConcept> theReasonCode) { 
2242      this.reasonCode = theReasonCode;
2243      return this;
2244    }
2245
2246    public boolean hasReasonCode() { 
2247      if (this.reasonCode == null)
2248        return false;
2249      for (CodeableConcept item : this.reasonCode)
2250        if (!item.isEmpty())
2251          return true;
2252      return false;
2253    }
2254
2255    public CodeableConcept addReasonCode() { //3
2256      CodeableConcept t = new CodeableConcept();
2257      if (this.reasonCode == null)
2258        this.reasonCode = new ArrayList<CodeableConcept>();
2259      this.reasonCode.add(t);
2260      return t;
2261    }
2262
2263    public MedicationRequest addReasonCode(CodeableConcept t) { //3
2264      if (t == null)
2265        return this;
2266      if (this.reasonCode == null)
2267        this.reasonCode = new ArrayList<CodeableConcept>();
2268      this.reasonCode.add(t);
2269      return this;
2270    }
2271
2272    /**
2273     * @return The first repetition of repeating field {@link #reasonCode}, creating it if it does not already exist
2274     */
2275    public CodeableConcept getReasonCodeFirstRep() { 
2276      if (getReasonCode().isEmpty()) {
2277        addReasonCode();
2278      }
2279      return getReasonCode().get(0);
2280    }
2281
2282    /**
2283     * @return {@link #reasonReference} (Condition or observation that supports why the medication was ordered.)
2284     */
2285    public List<Reference> getReasonReference() { 
2286      if (this.reasonReference == null)
2287        this.reasonReference = new ArrayList<Reference>();
2288      return this.reasonReference;
2289    }
2290
2291    /**
2292     * @return Returns a reference to <code>this</code> for easy method chaining
2293     */
2294    public MedicationRequest setReasonReference(List<Reference> theReasonReference) { 
2295      this.reasonReference = theReasonReference;
2296      return this;
2297    }
2298
2299    public boolean hasReasonReference() { 
2300      if (this.reasonReference == null)
2301        return false;
2302      for (Reference item : this.reasonReference)
2303        if (!item.isEmpty())
2304          return true;
2305      return false;
2306    }
2307
2308    public Reference addReasonReference() { //3
2309      Reference t = new Reference();
2310      if (this.reasonReference == null)
2311        this.reasonReference = new ArrayList<Reference>();
2312      this.reasonReference.add(t);
2313      return t;
2314    }
2315
2316    public MedicationRequest addReasonReference(Reference t) { //3
2317      if (t == null)
2318        return this;
2319      if (this.reasonReference == null)
2320        this.reasonReference = new ArrayList<Reference>();
2321      this.reasonReference.add(t);
2322      return this;
2323    }
2324
2325    /**
2326     * @return The first repetition of repeating field {@link #reasonReference}, creating it if it does not already exist
2327     */
2328    public Reference getReasonReferenceFirstRep() { 
2329      if (getReasonReference().isEmpty()) {
2330        addReasonReference();
2331      }
2332      return getReasonReference().get(0);
2333    }
2334
2335    /**
2336     * @deprecated Use Reference#setResource(IBaseResource) instead
2337     */
2338    @Deprecated
2339    public List<Resource> getReasonReferenceTarget() { 
2340      if (this.reasonReferenceTarget == null)
2341        this.reasonReferenceTarget = new ArrayList<Resource>();
2342      return this.reasonReferenceTarget;
2343    }
2344
2345    /**
2346     * @return {@link #note} (Extra information about the prescription that could not be conveyed by the other attributes.)
2347     */
2348    public List<Annotation> getNote() { 
2349      if (this.note == null)
2350        this.note = new ArrayList<Annotation>();
2351      return this.note;
2352    }
2353
2354    /**
2355     * @return Returns a reference to <code>this</code> for easy method chaining
2356     */
2357    public MedicationRequest setNote(List<Annotation> theNote) { 
2358      this.note = theNote;
2359      return this;
2360    }
2361
2362    public boolean hasNote() { 
2363      if (this.note == null)
2364        return false;
2365      for (Annotation item : this.note)
2366        if (!item.isEmpty())
2367          return true;
2368      return false;
2369    }
2370
2371    public Annotation addNote() { //3
2372      Annotation t = new Annotation();
2373      if (this.note == null)
2374        this.note = new ArrayList<Annotation>();
2375      this.note.add(t);
2376      return t;
2377    }
2378
2379    public MedicationRequest addNote(Annotation t) { //3
2380      if (t == null)
2381        return this;
2382      if (this.note == null)
2383        this.note = new ArrayList<Annotation>();
2384      this.note.add(t);
2385      return this;
2386    }
2387
2388    /**
2389     * @return The first repetition of repeating field {@link #note}, creating it if it does not already exist
2390     */
2391    public Annotation getNoteFirstRep() { 
2392      if (getNote().isEmpty()) {
2393        addNote();
2394      }
2395      return getNote().get(0);
2396    }
2397
2398    /**
2399     * @return {@link #dosageInstruction} (Indicates how the medication is to be used by the patient.)
2400     */
2401    public List<Dosage> getDosageInstruction() { 
2402      if (this.dosageInstruction == null)
2403        this.dosageInstruction = new ArrayList<Dosage>();
2404      return this.dosageInstruction;
2405    }
2406
2407    /**
2408     * @return Returns a reference to <code>this</code> for easy method chaining
2409     */
2410    public MedicationRequest setDosageInstruction(List<Dosage> theDosageInstruction) { 
2411      this.dosageInstruction = theDosageInstruction;
2412      return this;
2413    }
2414
2415    public boolean hasDosageInstruction() { 
2416      if (this.dosageInstruction == null)
2417        return false;
2418      for (Dosage item : this.dosageInstruction)
2419        if (!item.isEmpty())
2420          return true;
2421      return false;
2422    }
2423
2424    public Dosage addDosageInstruction() { //3
2425      Dosage t = new Dosage();
2426      if (this.dosageInstruction == null)
2427        this.dosageInstruction = new ArrayList<Dosage>();
2428      this.dosageInstruction.add(t);
2429      return t;
2430    }
2431
2432    public MedicationRequest addDosageInstruction(Dosage t) { //3
2433      if (t == null)
2434        return this;
2435      if (this.dosageInstruction == null)
2436        this.dosageInstruction = new ArrayList<Dosage>();
2437      this.dosageInstruction.add(t);
2438      return this;
2439    }
2440
2441    /**
2442     * @return The first repetition of repeating field {@link #dosageInstruction}, creating it if it does not already exist
2443     */
2444    public Dosage getDosageInstructionFirstRep() { 
2445      if (getDosageInstruction().isEmpty()) {
2446        addDosageInstruction();
2447      }
2448      return getDosageInstruction().get(0);
2449    }
2450
2451    /**
2452     * @return {@link #dispenseRequest} (Indicates the specific details for the dispense or medication supply part of a medication request (also known as a Medication Prescription or Medication Order).  Note that this information is not always sent with the order.  There may be in some settings (e.g. hospitals) institutional or system support for completing the dispense details in the pharmacy department.)
2453     */
2454    public MedicationRequestDispenseRequestComponent getDispenseRequest() { 
2455      if (this.dispenseRequest == null)
2456        if (Configuration.errorOnAutoCreate())
2457          throw new Error("Attempt to auto-create MedicationRequest.dispenseRequest");
2458        else if (Configuration.doAutoCreate())
2459          this.dispenseRequest = new MedicationRequestDispenseRequestComponent(); // cc
2460      return this.dispenseRequest;
2461    }
2462
2463    public boolean hasDispenseRequest() { 
2464      return this.dispenseRequest != null && !this.dispenseRequest.isEmpty();
2465    }
2466
2467    /**
2468     * @param value {@link #dispenseRequest} (Indicates the specific details for the dispense or medication supply part of a medication request (also known as a Medication Prescription or Medication Order).  Note that this information is not always sent with the order.  There may be in some settings (e.g. hospitals) institutional or system support for completing the dispense details in the pharmacy department.)
2469     */
2470    public MedicationRequest setDispenseRequest(MedicationRequestDispenseRequestComponent value) { 
2471      this.dispenseRequest = value;
2472      return this;
2473    }
2474
2475    /**
2476     * @return {@link #substitution} (Indicates whether or not substitution can or should be part of the dispense. In some cases substitution must happen, in other cases substitution must not happen. This block explains the prescriber's intent. If nothing is specified substitution may be done.)
2477     */
2478    public MedicationRequestSubstitutionComponent getSubstitution() { 
2479      if (this.substitution == null)
2480        if (Configuration.errorOnAutoCreate())
2481          throw new Error("Attempt to auto-create MedicationRequest.substitution");
2482        else if (Configuration.doAutoCreate())
2483          this.substitution = new MedicationRequestSubstitutionComponent(); // cc
2484      return this.substitution;
2485    }
2486
2487    public boolean hasSubstitution() { 
2488      return this.substitution != null && !this.substitution.isEmpty();
2489    }
2490
2491    /**
2492     * @param value {@link #substitution} (Indicates whether or not substitution can or should be part of the dispense. In some cases substitution must happen, in other cases substitution must not happen. This block explains the prescriber's intent. If nothing is specified substitution may be done.)
2493     */
2494    public MedicationRequest setSubstitution(MedicationRequestSubstitutionComponent value) { 
2495      this.substitution = value;
2496      return this;
2497    }
2498
2499    /**
2500     * @return {@link #priorPrescription} (A link to a resource representing an earlier order related order or prescription.)
2501     */
2502    public Reference getPriorPrescription() { 
2503      if (this.priorPrescription == null)
2504        if (Configuration.errorOnAutoCreate())
2505          throw new Error("Attempt to auto-create MedicationRequest.priorPrescription");
2506        else if (Configuration.doAutoCreate())
2507          this.priorPrescription = new Reference(); // cc
2508      return this.priorPrescription;
2509    }
2510
2511    public boolean hasPriorPrescription() { 
2512      return this.priorPrescription != null && !this.priorPrescription.isEmpty();
2513    }
2514
2515    /**
2516     * @param value {@link #priorPrescription} (A link to a resource representing an earlier order related order or prescription.)
2517     */
2518    public MedicationRequest setPriorPrescription(Reference value) { 
2519      this.priorPrescription = value;
2520      return this;
2521    }
2522
2523    /**
2524     * @return {@link #priorPrescription} 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. (A link to a resource representing an earlier order related order or prescription.)
2525     */
2526    public MedicationRequest getPriorPrescriptionTarget() { 
2527      if (this.priorPrescriptionTarget == null)
2528        if (Configuration.errorOnAutoCreate())
2529          throw new Error("Attempt to auto-create MedicationRequest.priorPrescription");
2530        else if (Configuration.doAutoCreate())
2531          this.priorPrescriptionTarget = new MedicationRequest(); // aa
2532      return this.priorPrescriptionTarget;
2533    }
2534
2535    /**
2536     * @param value {@link #priorPrescription} 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. (A link to a resource representing an earlier order related order or prescription.)
2537     */
2538    public MedicationRequest setPriorPrescriptionTarget(MedicationRequest value) { 
2539      this.priorPrescriptionTarget = value;
2540      return this;
2541    }
2542
2543    /**
2544     * @return {@link #detectedIssue} (Indicates an actual or potential clinical issue with or between one or more active or proposed clinical actions for a patient; e.g. Drug-drug interaction, duplicate therapy, dosage alert etc.)
2545     */
2546    public List<Reference> getDetectedIssue() { 
2547      if (this.detectedIssue == null)
2548        this.detectedIssue = new ArrayList<Reference>();
2549      return this.detectedIssue;
2550    }
2551
2552    /**
2553     * @return Returns a reference to <code>this</code> for easy method chaining
2554     */
2555    public MedicationRequest setDetectedIssue(List<Reference> theDetectedIssue) { 
2556      this.detectedIssue = theDetectedIssue;
2557      return this;
2558    }
2559
2560    public boolean hasDetectedIssue() { 
2561      if (this.detectedIssue == null)
2562        return false;
2563      for (Reference item : this.detectedIssue)
2564        if (!item.isEmpty())
2565          return true;
2566      return false;
2567    }
2568
2569    public Reference addDetectedIssue() { //3
2570      Reference t = new Reference();
2571      if (this.detectedIssue == null)
2572        this.detectedIssue = new ArrayList<Reference>();
2573      this.detectedIssue.add(t);
2574      return t;
2575    }
2576
2577    public MedicationRequest addDetectedIssue(Reference t) { //3
2578      if (t == null)
2579        return this;
2580      if (this.detectedIssue == null)
2581        this.detectedIssue = new ArrayList<Reference>();
2582      this.detectedIssue.add(t);
2583      return this;
2584    }
2585
2586    /**
2587     * @return The first repetition of repeating field {@link #detectedIssue}, creating it if it does not already exist
2588     */
2589    public Reference getDetectedIssueFirstRep() { 
2590      if (getDetectedIssue().isEmpty()) {
2591        addDetectedIssue();
2592      }
2593      return getDetectedIssue().get(0);
2594    }
2595
2596    /**
2597     * @deprecated Use Reference#setResource(IBaseResource) instead
2598     */
2599    @Deprecated
2600    public List<DetectedIssue> getDetectedIssueTarget() { 
2601      if (this.detectedIssueTarget == null)
2602        this.detectedIssueTarget = new ArrayList<DetectedIssue>();
2603      return this.detectedIssueTarget;
2604    }
2605
2606    /**
2607     * @deprecated Use Reference#setResource(IBaseResource) instead
2608     */
2609    @Deprecated
2610    public DetectedIssue addDetectedIssueTarget() { 
2611      DetectedIssue r = new DetectedIssue();
2612      if (this.detectedIssueTarget == null)
2613        this.detectedIssueTarget = new ArrayList<DetectedIssue>();
2614      this.detectedIssueTarget.add(r);
2615      return r;
2616    }
2617
2618    /**
2619     * @return {@link #eventHistory} (Links to Provenance records for past versions of this resource or fulfilling request or event resources that identify key state transitions or updates that are likely to be relevant to a user looking at the current version of the resource.)
2620     */
2621    public List<Reference> getEventHistory() { 
2622      if (this.eventHistory == null)
2623        this.eventHistory = new ArrayList<Reference>();
2624      return this.eventHistory;
2625    }
2626
2627    /**
2628     * @return Returns a reference to <code>this</code> for easy method chaining
2629     */
2630    public MedicationRequest setEventHistory(List<Reference> theEventHistory) { 
2631      this.eventHistory = theEventHistory;
2632      return this;
2633    }
2634
2635    public boolean hasEventHistory() { 
2636      if (this.eventHistory == null)
2637        return false;
2638      for (Reference item : this.eventHistory)
2639        if (!item.isEmpty())
2640          return true;
2641      return false;
2642    }
2643
2644    public Reference addEventHistory() { //3
2645      Reference t = new Reference();
2646      if (this.eventHistory == null)
2647        this.eventHistory = new ArrayList<Reference>();
2648      this.eventHistory.add(t);
2649      return t;
2650    }
2651
2652    public MedicationRequest addEventHistory(Reference t) { //3
2653      if (t == null)
2654        return this;
2655      if (this.eventHistory == null)
2656        this.eventHistory = new ArrayList<Reference>();
2657      this.eventHistory.add(t);
2658      return this;
2659    }
2660
2661    /**
2662     * @return The first repetition of repeating field {@link #eventHistory}, creating it if it does not already exist
2663     */
2664    public Reference getEventHistoryFirstRep() { 
2665      if (getEventHistory().isEmpty()) {
2666        addEventHistory();
2667      }
2668      return getEventHistory().get(0);
2669    }
2670
2671    /**
2672     * @deprecated Use Reference#setResource(IBaseResource) instead
2673     */
2674    @Deprecated
2675    public List<Provenance> getEventHistoryTarget() { 
2676      if (this.eventHistoryTarget == null)
2677        this.eventHistoryTarget = new ArrayList<Provenance>();
2678      return this.eventHistoryTarget;
2679    }
2680
2681    /**
2682     * @deprecated Use Reference#setResource(IBaseResource) instead
2683     */
2684    @Deprecated
2685    public Provenance addEventHistoryTarget() { 
2686      Provenance r = new Provenance();
2687      if (this.eventHistoryTarget == null)
2688        this.eventHistoryTarget = new ArrayList<Provenance>();
2689      this.eventHistoryTarget.add(r);
2690      return r;
2691    }
2692
2693      protected void listChildren(List<Property> childrenList) {
2694        super.listChildren(childrenList);
2695        childrenList.add(new Property("identifier", "Identifier", "This records identifiers associated with this medication request that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate. For example a re-imbursement system might issue its own id for each prescription that is created.  This is particularly important where FHIR only provides part of an entire workflow process where records must be tracked through an entire system.", 0, java.lang.Integer.MAX_VALUE, identifier));
2696        childrenList.add(new Property("definition", "Reference(ActivityDefinition|PlanDefinition)", "Protocol or definition followed by this request.", 0, java.lang.Integer.MAX_VALUE, definition));
2697        childrenList.add(new Property("basedOn", "Reference(CarePlan|MedicationRequest|ProcedureRequest|ReferralRequest)", "A plan or request that is fulfilled in whole or in part by this medication request.", 0, java.lang.Integer.MAX_VALUE, basedOn));
2698        childrenList.add(new Property("groupIdentifier", "Identifier", "A shared identifier common to all requests that were authorized more or less simultaneously by a single author, representing the identifier of the requisition or prescription.", 0, java.lang.Integer.MAX_VALUE, groupIdentifier));
2699        childrenList.add(new Property("status", "code", "A code specifying the current state of the order.  Generally this will be active or completed state.", 0, java.lang.Integer.MAX_VALUE, status));
2700        childrenList.add(new Property("intent", "code", "Whether the request is a proposal, plan, or an original order.", 0, java.lang.Integer.MAX_VALUE, intent));
2701        childrenList.add(new Property("category", "CodeableConcept", "Indicates the type of medication order and where the medication is expected to be consumed or administered.", 0, java.lang.Integer.MAX_VALUE, category));
2702        childrenList.add(new Property("priority", "code", "Indicates how quickly the Medication Request should be addressed with respect to other requests.", 0, java.lang.Integer.MAX_VALUE, priority));
2703        childrenList.add(new Property("medication[x]", "CodeableConcept|Reference(Medication)", "Identifies the medication being requested. This is a link to a resource that represents the medication which may be the details of the medication or simply an attribute carrying a code that identifies the medication from a known list of medications.", 0, java.lang.Integer.MAX_VALUE, medication));
2704        childrenList.add(new Property("subject", "Reference(Patient|Group)", "A link to a resource representing the person or set of individuals to whom the medication will be given.", 0, java.lang.Integer.MAX_VALUE, subject));
2705        childrenList.add(new Property("context", "Reference(Encounter|EpisodeOfCare)", "A link to an encounter, or episode of care, that identifies the particular occurrence or set occurrences of contact between patient and health care provider.", 0, java.lang.Integer.MAX_VALUE, context));
2706        childrenList.add(new Property("supportingInformation", "Reference(Any)", "Include additional information (for example, patient height and weight) that supports the ordering of the medication.", 0, java.lang.Integer.MAX_VALUE, supportingInformation));
2707        childrenList.add(new Property("authoredOn", "dateTime", "The date (and perhaps time) when the prescription was initially written or authored on.", 0, java.lang.Integer.MAX_VALUE, authoredOn));
2708        childrenList.add(new Property("requester", "", "The individual, organization or device that initiated the request and has responsibility for its activation.", 0, java.lang.Integer.MAX_VALUE, requester));
2709        childrenList.add(new Property("recorder", "Reference(Practitioner)", "The person who entered the order on behalf of another individual for example in the case of a verbal or a telephone order.", 0, java.lang.Integer.MAX_VALUE, recorder));
2710        childrenList.add(new Property("reasonCode", "CodeableConcept", "The reason or the indication for ordering the medication.", 0, java.lang.Integer.MAX_VALUE, reasonCode));
2711        childrenList.add(new Property("reasonReference", "Reference(Condition|Observation)", "Condition or observation that supports why the medication was ordered.", 0, java.lang.Integer.MAX_VALUE, reasonReference));
2712        childrenList.add(new Property("note", "Annotation", "Extra information about the prescription that could not be conveyed by the other attributes.", 0, java.lang.Integer.MAX_VALUE, note));
2713        childrenList.add(new Property("dosageInstruction", "Dosage", "Indicates how the medication is to be used by the patient.", 0, java.lang.Integer.MAX_VALUE, dosageInstruction));
2714        childrenList.add(new Property("dispenseRequest", "", "Indicates the specific details for the dispense or medication supply part of a medication request (also known as a Medication Prescription or Medication Order).  Note that this information is not always sent with the order.  There may be in some settings (e.g. hospitals) institutional or system support for completing the dispense details in the pharmacy department.", 0, java.lang.Integer.MAX_VALUE, dispenseRequest));
2715        childrenList.add(new Property("substitution", "", "Indicates whether or not substitution can or should be part of the dispense. In some cases substitution must happen, in other cases substitution must not happen. This block explains the prescriber's intent. If nothing is specified substitution may be done.", 0, java.lang.Integer.MAX_VALUE, substitution));
2716        childrenList.add(new Property("priorPrescription", "Reference(MedicationRequest)", "A link to a resource representing an earlier order related order or prescription.", 0, java.lang.Integer.MAX_VALUE, priorPrescription));
2717        childrenList.add(new Property("detectedIssue", "Reference(DetectedIssue)", "Indicates an actual or potential clinical issue with or between one or more active or proposed clinical actions for a patient; e.g. Drug-drug interaction, duplicate therapy, dosage alert etc.", 0, java.lang.Integer.MAX_VALUE, detectedIssue));
2718        childrenList.add(new Property("eventHistory", "Reference(Provenance)", "Links to Provenance records for past versions of this resource or fulfilling request or event resources that identify key state transitions or updates that are likely to be relevant to a user looking at the current version of the resource.", 0, java.lang.Integer.MAX_VALUE, eventHistory));
2719      }
2720
2721      @Override
2722      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2723        switch (hash) {
2724        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
2725        case -1014418093: /*definition*/ return this.definition == null ? new Base[0] : this.definition.toArray(new Base[this.definition.size()]); // Reference
2726        case -332612366: /*basedOn*/ return this.basedOn == null ? new Base[0] : this.basedOn.toArray(new Base[this.basedOn.size()]); // Reference
2727        case -445338488: /*groupIdentifier*/ return this.groupIdentifier == null ? new Base[0] : new Base[] {this.groupIdentifier}; // Identifier
2728        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<MedicationRequestStatus>
2729        case -1183762788: /*intent*/ return this.intent == null ? new Base[0] : new Base[] {this.intent}; // Enumeration<MedicationRequestIntent>
2730        case 50511102: /*category*/ return this.category == null ? new Base[0] : new Base[] {this.category}; // CodeableConcept
2731        case -1165461084: /*priority*/ return this.priority == null ? new Base[0] : new Base[] {this.priority}; // Enumeration<MedicationRequestPriority>
2732        case 1998965455: /*medication*/ return this.medication == null ? new Base[0] : new Base[] {this.medication}; // Type
2733        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
2734        case 951530927: /*context*/ return this.context == null ? new Base[0] : new Base[] {this.context}; // Reference
2735        case -1248768647: /*supportingInformation*/ return this.supportingInformation == null ? new Base[0] : this.supportingInformation.toArray(new Base[this.supportingInformation.size()]); // Reference
2736        case -1500852503: /*authoredOn*/ return this.authoredOn == null ? new Base[0] : new Base[] {this.authoredOn}; // DateTimeType
2737        case 693933948: /*requester*/ return this.requester == null ? new Base[0] : new Base[] {this.requester}; // MedicationRequestRequesterComponent
2738        case -799233858: /*recorder*/ return this.recorder == null ? new Base[0] : new Base[] {this.recorder}; // Reference
2739        case 722137681: /*reasonCode*/ return this.reasonCode == null ? new Base[0] : this.reasonCode.toArray(new Base[this.reasonCode.size()]); // CodeableConcept
2740        case -1146218137: /*reasonReference*/ return this.reasonReference == null ? new Base[0] : this.reasonReference.toArray(new Base[this.reasonReference.size()]); // Reference
2741        case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
2742        case -1201373865: /*dosageInstruction*/ return this.dosageInstruction == null ? new Base[0] : this.dosageInstruction.toArray(new Base[this.dosageInstruction.size()]); // Dosage
2743        case 824620658: /*dispenseRequest*/ return this.dispenseRequest == null ? new Base[0] : new Base[] {this.dispenseRequest}; // MedicationRequestDispenseRequestComponent
2744        case 826147581: /*substitution*/ return this.substitution == null ? new Base[0] : new Base[] {this.substitution}; // MedicationRequestSubstitutionComponent
2745        case -486355964: /*priorPrescription*/ return this.priorPrescription == null ? new Base[0] : new Base[] {this.priorPrescription}; // Reference
2746        case 51602295: /*detectedIssue*/ return this.detectedIssue == null ? new Base[0] : this.detectedIssue.toArray(new Base[this.detectedIssue.size()]); // Reference
2747        case 1835190426: /*eventHistory*/ return this.eventHistory == null ? new Base[0] : this.eventHistory.toArray(new Base[this.eventHistory.size()]); // Reference
2748        default: return super.getProperty(hash, name, checkValid);
2749        }
2750
2751      }
2752
2753      @Override
2754      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2755        switch (hash) {
2756        case -1618432855: // identifier
2757          this.getIdentifier().add(castToIdentifier(value)); // Identifier
2758          return value;
2759        case -1014418093: // definition
2760          this.getDefinition().add(castToReference(value)); // Reference
2761          return value;
2762        case -332612366: // basedOn
2763          this.getBasedOn().add(castToReference(value)); // Reference
2764          return value;
2765        case -445338488: // groupIdentifier
2766          this.groupIdentifier = castToIdentifier(value); // Identifier
2767          return value;
2768        case -892481550: // status
2769          value = new MedicationRequestStatusEnumFactory().fromType(castToCode(value));
2770          this.status = (Enumeration) value; // Enumeration<MedicationRequestStatus>
2771          return value;
2772        case -1183762788: // intent
2773          value = new MedicationRequestIntentEnumFactory().fromType(castToCode(value));
2774          this.intent = (Enumeration) value; // Enumeration<MedicationRequestIntent>
2775          return value;
2776        case 50511102: // category
2777          this.category = castToCodeableConcept(value); // CodeableConcept
2778          return value;
2779        case -1165461084: // priority
2780          value = new MedicationRequestPriorityEnumFactory().fromType(castToCode(value));
2781          this.priority = (Enumeration) value; // Enumeration<MedicationRequestPriority>
2782          return value;
2783        case 1998965455: // medication
2784          this.medication = castToType(value); // Type
2785          return value;
2786        case -1867885268: // subject
2787          this.subject = castToReference(value); // Reference
2788          return value;
2789        case 951530927: // context
2790          this.context = castToReference(value); // Reference
2791          return value;
2792        case -1248768647: // supportingInformation
2793          this.getSupportingInformation().add(castToReference(value)); // Reference
2794          return value;
2795        case -1500852503: // authoredOn
2796          this.authoredOn = castToDateTime(value); // DateTimeType
2797          return value;
2798        case 693933948: // requester
2799          this.requester = (MedicationRequestRequesterComponent) value; // MedicationRequestRequesterComponent
2800          return value;
2801        case -799233858: // recorder
2802          this.recorder = castToReference(value); // Reference
2803          return value;
2804        case 722137681: // reasonCode
2805          this.getReasonCode().add(castToCodeableConcept(value)); // CodeableConcept
2806          return value;
2807        case -1146218137: // reasonReference
2808          this.getReasonReference().add(castToReference(value)); // Reference
2809          return value;
2810        case 3387378: // note
2811          this.getNote().add(castToAnnotation(value)); // Annotation
2812          return value;
2813        case -1201373865: // dosageInstruction
2814          this.getDosageInstruction().add(castToDosage(value)); // Dosage
2815          return value;
2816        case 824620658: // dispenseRequest
2817          this.dispenseRequest = (MedicationRequestDispenseRequestComponent) value; // MedicationRequestDispenseRequestComponent
2818          return value;
2819        case 826147581: // substitution
2820          this.substitution = (MedicationRequestSubstitutionComponent) value; // MedicationRequestSubstitutionComponent
2821          return value;
2822        case -486355964: // priorPrescription
2823          this.priorPrescription = castToReference(value); // Reference
2824          return value;
2825        case 51602295: // detectedIssue
2826          this.getDetectedIssue().add(castToReference(value)); // Reference
2827          return value;
2828        case 1835190426: // eventHistory
2829          this.getEventHistory().add(castToReference(value)); // Reference
2830          return value;
2831        default: return super.setProperty(hash, name, value);
2832        }
2833
2834      }
2835
2836      @Override
2837      public Base setProperty(String name, Base value) throws FHIRException {
2838        if (name.equals("identifier")) {
2839          this.getIdentifier().add(castToIdentifier(value));
2840        } else if (name.equals("definition")) {
2841          this.getDefinition().add(castToReference(value));
2842        } else if (name.equals("basedOn")) {
2843          this.getBasedOn().add(castToReference(value));
2844        } else if (name.equals("groupIdentifier")) {
2845          this.groupIdentifier = castToIdentifier(value); // Identifier
2846        } else if (name.equals("status")) {
2847          value = new MedicationRequestStatusEnumFactory().fromType(castToCode(value));
2848          this.status = (Enumeration) value; // Enumeration<MedicationRequestStatus>
2849        } else if (name.equals("intent")) {
2850          value = new MedicationRequestIntentEnumFactory().fromType(castToCode(value));
2851          this.intent = (Enumeration) value; // Enumeration<MedicationRequestIntent>
2852        } else if (name.equals("category")) {
2853          this.category = castToCodeableConcept(value); // CodeableConcept
2854        } else if (name.equals("priority")) {
2855          value = new MedicationRequestPriorityEnumFactory().fromType(castToCode(value));
2856          this.priority = (Enumeration) value; // Enumeration<MedicationRequestPriority>
2857        } else if (name.equals("medication[x]")) {
2858          this.medication = castToType(value); // Type
2859        } else if (name.equals("subject")) {
2860          this.subject = castToReference(value); // Reference
2861        } else if (name.equals("context")) {
2862          this.context = castToReference(value); // Reference
2863        } else if (name.equals("supportingInformation")) {
2864          this.getSupportingInformation().add(castToReference(value));
2865        } else if (name.equals("authoredOn")) {
2866          this.authoredOn = castToDateTime(value); // DateTimeType
2867        } else if (name.equals("requester")) {
2868          this.requester = (MedicationRequestRequesterComponent) value; // MedicationRequestRequesterComponent
2869        } else if (name.equals("recorder")) {
2870          this.recorder = castToReference(value); // Reference
2871        } else if (name.equals("reasonCode")) {
2872          this.getReasonCode().add(castToCodeableConcept(value));
2873        } else if (name.equals("reasonReference")) {
2874          this.getReasonReference().add(castToReference(value));
2875        } else if (name.equals("note")) {
2876          this.getNote().add(castToAnnotation(value));
2877        } else if (name.equals("dosageInstruction")) {
2878          this.getDosageInstruction().add(castToDosage(value));
2879        } else if (name.equals("dispenseRequest")) {
2880          this.dispenseRequest = (MedicationRequestDispenseRequestComponent) value; // MedicationRequestDispenseRequestComponent
2881        } else if (name.equals("substitution")) {
2882          this.substitution = (MedicationRequestSubstitutionComponent) value; // MedicationRequestSubstitutionComponent
2883        } else if (name.equals("priorPrescription")) {
2884          this.priorPrescription = castToReference(value); // Reference
2885        } else if (name.equals("detectedIssue")) {
2886          this.getDetectedIssue().add(castToReference(value));
2887        } else if (name.equals("eventHistory")) {
2888          this.getEventHistory().add(castToReference(value));
2889        } else
2890          return super.setProperty(name, value);
2891        return value;
2892      }
2893
2894      @Override
2895      public Base makeProperty(int hash, String name) throws FHIRException {
2896        switch (hash) {
2897        case -1618432855:  return addIdentifier(); 
2898        case -1014418093:  return addDefinition(); 
2899        case -332612366:  return addBasedOn(); 
2900        case -445338488:  return getGroupIdentifier(); 
2901        case -892481550:  return getStatusElement();
2902        case -1183762788:  return getIntentElement();
2903        case 50511102:  return getCategory(); 
2904        case -1165461084:  return getPriorityElement();
2905        case 1458402129:  return getMedication(); 
2906        case 1998965455:  return getMedication(); 
2907        case -1867885268:  return getSubject(); 
2908        case 951530927:  return getContext(); 
2909        case -1248768647:  return addSupportingInformation(); 
2910        case -1500852503:  return getAuthoredOnElement();
2911        case 693933948:  return getRequester(); 
2912        case -799233858:  return getRecorder(); 
2913        case 722137681:  return addReasonCode(); 
2914        case -1146218137:  return addReasonReference(); 
2915        case 3387378:  return addNote(); 
2916        case -1201373865:  return addDosageInstruction(); 
2917        case 824620658:  return getDispenseRequest(); 
2918        case 826147581:  return getSubstitution(); 
2919        case -486355964:  return getPriorPrescription(); 
2920        case 51602295:  return addDetectedIssue(); 
2921        case 1835190426:  return addEventHistory(); 
2922        default: return super.makeProperty(hash, name);
2923        }
2924
2925      }
2926
2927      @Override
2928      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2929        switch (hash) {
2930        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
2931        case -1014418093: /*definition*/ return new String[] {"Reference"};
2932        case -332612366: /*basedOn*/ return new String[] {"Reference"};
2933        case -445338488: /*groupIdentifier*/ return new String[] {"Identifier"};
2934        case -892481550: /*status*/ return new String[] {"code"};
2935        case -1183762788: /*intent*/ return new String[] {"code"};
2936        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
2937        case -1165461084: /*priority*/ return new String[] {"code"};
2938        case 1998965455: /*medication*/ return new String[] {"CodeableConcept", "Reference"};
2939        case -1867885268: /*subject*/ return new String[] {"Reference"};
2940        case 951530927: /*context*/ return new String[] {"Reference"};
2941        case -1248768647: /*supportingInformation*/ return new String[] {"Reference"};
2942        case -1500852503: /*authoredOn*/ return new String[] {"dateTime"};
2943        case 693933948: /*requester*/ return new String[] {};
2944        case -799233858: /*recorder*/ return new String[] {"Reference"};
2945        case 722137681: /*reasonCode*/ return new String[] {"CodeableConcept"};
2946        case -1146218137: /*reasonReference*/ return new String[] {"Reference"};
2947        case 3387378: /*note*/ return new String[] {"Annotation"};
2948        case -1201373865: /*dosageInstruction*/ return new String[] {"Dosage"};
2949        case 824620658: /*dispenseRequest*/ return new String[] {};
2950        case 826147581: /*substitution*/ return new String[] {};
2951        case -486355964: /*priorPrescription*/ return new String[] {"Reference"};
2952        case 51602295: /*detectedIssue*/ return new String[] {"Reference"};
2953        case 1835190426: /*eventHistory*/ return new String[] {"Reference"};
2954        default: return super.getTypesForProperty(hash, name);
2955        }
2956
2957      }
2958
2959      @Override
2960      public Base addChild(String name) throws FHIRException {
2961        if (name.equals("identifier")) {
2962          return addIdentifier();
2963        }
2964        else if (name.equals("definition")) {
2965          return addDefinition();
2966        }
2967        else if (name.equals("basedOn")) {
2968          return addBasedOn();
2969        }
2970        else if (name.equals("groupIdentifier")) {
2971          this.groupIdentifier = new Identifier();
2972          return this.groupIdentifier;
2973        }
2974        else if (name.equals("status")) {
2975          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.status");
2976        }
2977        else if (name.equals("intent")) {
2978          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.intent");
2979        }
2980        else if (name.equals("category")) {
2981          this.category = new CodeableConcept();
2982          return this.category;
2983        }
2984        else if (name.equals("priority")) {
2985          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.priority");
2986        }
2987        else if (name.equals("medicationCodeableConcept")) {
2988          this.medication = new CodeableConcept();
2989          return this.medication;
2990        }
2991        else if (name.equals("medicationReference")) {
2992          this.medication = new Reference();
2993          return this.medication;
2994        }
2995        else if (name.equals("subject")) {
2996          this.subject = new Reference();
2997          return this.subject;
2998        }
2999        else if (name.equals("context")) {
3000          this.context = new Reference();
3001          return this.context;
3002        }
3003        else if (name.equals("supportingInformation")) {
3004          return addSupportingInformation();
3005        }
3006        else if (name.equals("authoredOn")) {
3007          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.authoredOn");
3008        }
3009        else if (name.equals("requester")) {
3010          this.requester = new MedicationRequestRequesterComponent();
3011          return this.requester;
3012        }
3013        else if (name.equals("recorder")) {
3014          this.recorder = new Reference();
3015          return this.recorder;
3016        }
3017        else if (name.equals("reasonCode")) {
3018          return addReasonCode();
3019        }
3020        else if (name.equals("reasonReference")) {
3021          return addReasonReference();
3022        }
3023        else if (name.equals("note")) {
3024          return addNote();
3025        }
3026        else if (name.equals("dosageInstruction")) {
3027          return addDosageInstruction();
3028        }
3029        else if (name.equals("dispenseRequest")) {
3030          this.dispenseRequest = new MedicationRequestDispenseRequestComponent();
3031          return this.dispenseRequest;
3032        }
3033        else if (name.equals("substitution")) {
3034          this.substitution = new MedicationRequestSubstitutionComponent();
3035          return this.substitution;
3036        }
3037        else if (name.equals("priorPrescription")) {
3038          this.priorPrescription = new Reference();
3039          return this.priorPrescription;
3040        }
3041        else if (name.equals("detectedIssue")) {
3042          return addDetectedIssue();
3043        }
3044        else if (name.equals("eventHistory")) {
3045          return addEventHistory();
3046        }
3047        else
3048          return super.addChild(name);
3049      }
3050
3051  public String fhirType() {
3052    return "MedicationRequest";
3053
3054  }
3055
3056      public MedicationRequest copy() {
3057        MedicationRequest dst = new MedicationRequest();
3058        copyValues(dst);
3059        if (identifier != null) {
3060          dst.identifier = new ArrayList<Identifier>();
3061          for (Identifier i : identifier)
3062            dst.identifier.add(i.copy());
3063        };
3064        if (definition != null) {
3065          dst.definition = new ArrayList<Reference>();
3066          for (Reference i : definition)
3067            dst.definition.add(i.copy());
3068        };
3069        if (basedOn != null) {
3070          dst.basedOn = new ArrayList<Reference>();
3071          for (Reference i : basedOn)
3072            dst.basedOn.add(i.copy());
3073        };
3074        dst.groupIdentifier = groupIdentifier == null ? null : groupIdentifier.copy();
3075        dst.status = status == null ? null : status.copy();
3076        dst.intent = intent == null ? null : intent.copy();
3077        dst.category = category == null ? null : category.copy();
3078        dst.priority = priority == null ? null : priority.copy();
3079        dst.medication = medication == null ? null : medication.copy();
3080        dst.subject = subject == null ? null : subject.copy();
3081        dst.context = context == null ? null : context.copy();
3082        if (supportingInformation != null) {
3083          dst.supportingInformation = new ArrayList<Reference>();
3084          for (Reference i : supportingInformation)
3085            dst.supportingInformation.add(i.copy());
3086        };
3087        dst.authoredOn = authoredOn == null ? null : authoredOn.copy();
3088        dst.requester = requester == null ? null : requester.copy();
3089        dst.recorder = recorder == null ? null : recorder.copy();
3090        if (reasonCode != null) {
3091          dst.reasonCode = new ArrayList<CodeableConcept>();
3092          for (CodeableConcept i : reasonCode)
3093            dst.reasonCode.add(i.copy());
3094        };
3095        if (reasonReference != null) {
3096          dst.reasonReference = new ArrayList<Reference>();
3097          for (Reference i : reasonReference)
3098            dst.reasonReference.add(i.copy());
3099        };
3100        if (note != null) {
3101          dst.note = new ArrayList<Annotation>();
3102          for (Annotation i : note)
3103            dst.note.add(i.copy());
3104        };
3105        if (dosageInstruction != null) {
3106          dst.dosageInstruction = new ArrayList<Dosage>();
3107          for (Dosage i : dosageInstruction)
3108            dst.dosageInstruction.add(i.copy());
3109        };
3110        dst.dispenseRequest = dispenseRequest == null ? null : dispenseRequest.copy();
3111        dst.substitution = substitution == null ? null : substitution.copy();
3112        dst.priorPrescription = priorPrescription == null ? null : priorPrescription.copy();
3113        if (detectedIssue != null) {
3114          dst.detectedIssue = new ArrayList<Reference>();
3115          for (Reference i : detectedIssue)
3116            dst.detectedIssue.add(i.copy());
3117        };
3118        if (eventHistory != null) {
3119          dst.eventHistory = new ArrayList<Reference>();
3120          for (Reference i : eventHistory)
3121            dst.eventHistory.add(i.copy());
3122        };
3123        return dst;
3124      }
3125
3126      protected MedicationRequest typedCopy() {
3127        return copy();
3128      }
3129
3130      @Override
3131      public boolean equalsDeep(Base other) {
3132        if (!super.equalsDeep(other))
3133          return false;
3134        if (!(other instanceof MedicationRequest))
3135          return false;
3136        MedicationRequest o = (MedicationRequest) other;
3137        return compareDeep(identifier, o.identifier, true) && compareDeep(definition, o.definition, true)
3138           && compareDeep(basedOn, o.basedOn, true) && compareDeep(groupIdentifier, o.groupIdentifier, true)
3139           && compareDeep(status, o.status, true) && compareDeep(intent, o.intent, true) && compareDeep(category, o.category, true)
3140           && compareDeep(priority, o.priority, true) && compareDeep(medication, o.medication, true) && compareDeep(subject, o.subject, true)
3141           && compareDeep(context, o.context, true) && compareDeep(supportingInformation, o.supportingInformation, true)
3142           && compareDeep(authoredOn, o.authoredOn, true) && compareDeep(requester, o.requester, true) && compareDeep(recorder, o.recorder, true)
3143           && compareDeep(reasonCode, o.reasonCode, true) && compareDeep(reasonReference, o.reasonReference, true)
3144           && compareDeep(note, o.note, true) && compareDeep(dosageInstruction, o.dosageInstruction, true)
3145           && compareDeep(dispenseRequest, o.dispenseRequest, true) && compareDeep(substitution, o.substitution, true)
3146           && compareDeep(priorPrescription, o.priorPrescription, true) && compareDeep(detectedIssue, o.detectedIssue, true)
3147           && compareDeep(eventHistory, o.eventHistory, true);
3148      }
3149
3150      @Override
3151      public boolean equalsShallow(Base other) {
3152        if (!super.equalsShallow(other))
3153          return false;
3154        if (!(other instanceof MedicationRequest))
3155          return false;
3156        MedicationRequest o = (MedicationRequest) other;
3157        return compareValues(status, o.status, true) && compareValues(intent, o.intent, true) && compareValues(priority, o.priority, true)
3158           && compareValues(authoredOn, o.authoredOn, true);
3159      }
3160
3161      public boolean isEmpty() {
3162        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, definition, basedOn
3163          , groupIdentifier, status, intent, category, priority, medication, subject, context
3164          , supportingInformation, authoredOn, requester, recorder, reasonCode, reasonReference
3165          , note, dosageInstruction, dispenseRequest, substitution, priorPrescription, detectedIssue
3166          , eventHistory);
3167      }
3168
3169  @Override
3170  public ResourceType getResourceType() {
3171    return ResourceType.MedicationRequest;
3172   }
3173
3174 /**
3175   * Search parameter: <b>requester</b>
3176   * <p>
3177   * Description: <b>Returns prescriptions prescribed by this prescriber</b><br>
3178   * Type: <b>reference</b><br>
3179   * Path: <b>MedicationRequest.requester.agent</b><br>
3180   * </p>
3181   */
3182  @SearchParamDefinition(name="requester", path="MedicationRequest.requester.agent", description="Returns prescriptions prescribed by this prescriber", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner") }, target={Device.class, Organization.class, Patient.class, Practitioner.class, RelatedPerson.class } )
3183  public static final String SP_REQUESTER = "requester";
3184 /**
3185   * <b>Fluent Client</b> search parameter constant for <b>requester</b>
3186   * <p>
3187   * Description: <b>Returns prescriptions prescribed by this prescriber</b><br>
3188   * Type: <b>reference</b><br>
3189   * Path: <b>MedicationRequest.requester.agent</b><br>
3190   * </p>
3191   */
3192  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam REQUESTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_REQUESTER);
3193
3194/**
3195   * Constant for fluent queries to be used to add include statements. Specifies
3196   * the path value of "<b>MedicationRequest:requester</b>".
3197   */
3198  public static final ca.uhn.fhir.model.api.Include INCLUDE_REQUESTER = new ca.uhn.fhir.model.api.Include("MedicationRequest:requester").toLocked();
3199
3200 /**
3201   * Search parameter: <b>date</b>
3202   * <p>
3203   * Description: <b>Returns medication request to be administered on a specific date</b><br>
3204   * Type: <b>date</b><br>
3205   * Path: <b>MedicationRequest.dosageInstruction.timing.event</b><br>
3206   * </p>
3207   */
3208  @SearchParamDefinition(name="date", path="MedicationRequest.dosageInstruction.timing.event", description="Returns medication request to be administered on a specific date", type="date" )
3209  public static final String SP_DATE = "date";
3210 /**
3211   * <b>Fluent Client</b> search parameter constant for <b>date</b>
3212   * <p>
3213   * Description: <b>Returns medication request to be administered on a specific date</b><br>
3214   * Type: <b>date</b><br>
3215   * Path: <b>MedicationRequest.dosageInstruction.timing.event</b><br>
3216   * </p>
3217   */
3218  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATE);
3219
3220 /**
3221   * Search parameter: <b>identifier</b>
3222   * <p>
3223   * Description: <b>Return prescriptions with this external identifier</b><br>
3224   * Type: <b>token</b><br>
3225   * Path: <b>MedicationRequest.identifier</b><br>
3226   * </p>
3227   */
3228  @SearchParamDefinition(name="identifier", path="MedicationRequest.identifier", description="Return prescriptions with this external identifier", type="token" )
3229  public static final String SP_IDENTIFIER = "identifier";
3230 /**
3231   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
3232   * <p>
3233   * Description: <b>Return prescriptions with this external identifier</b><br>
3234   * Type: <b>token</b><br>
3235   * Path: <b>MedicationRequest.identifier</b><br>
3236   * </p>
3237   */
3238  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
3239
3240 /**
3241   * Search parameter: <b>intended-dispenser</b>
3242   * <p>
3243   * Description: <b>Returns prescriptions intended to be dispensed by this Organization</b><br>
3244   * Type: <b>reference</b><br>
3245   * Path: <b>MedicationRequest.dispenseRequest.performer</b><br>
3246   * </p>
3247   */
3248  @SearchParamDefinition(name="intended-dispenser", path="MedicationRequest.dispenseRequest.performer", description="Returns prescriptions intended to be dispensed by this Organization", type="reference", target={Organization.class } )
3249  public static final String SP_INTENDED_DISPENSER = "intended-dispenser";
3250 /**
3251   * <b>Fluent Client</b> search parameter constant for <b>intended-dispenser</b>
3252   * <p>
3253   * Description: <b>Returns prescriptions intended to be dispensed by this Organization</b><br>
3254   * Type: <b>reference</b><br>
3255   * Path: <b>MedicationRequest.dispenseRequest.performer</b><br>
3256   * </p>
3257   */
3258  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam INTENDED_DISPENSER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_INTENDED_DISPENSER);
3259
3260/**
3261   * Constant for fluent queries to be used to add include statements. Specifies
3262   * the path value of "<b>MedicationRequest:intended-dispenser</b>".
3263   */
3264  public static final ca.uhn.fhir.model.api.Include INCLUDE_INTENDED_DISPENSER = new ca.uhn.fhir.model.api.Include("MedicationRequest:intended-dispenser").toLocked();
3265
3266 /**
3267   * Search parameter: <b>authoredon</b>
3268   * <p>
3269   * Description: <b>Return prescriptions written on this date</b><br>
3270   * Type: <b>date</b><br>
3271   * Path: <b>MedicationRequest.authoredOn</b><br>
3272   * </p>
3273   */
3274  @SearchParamDefinition(name="authoredon", path="MedicationRequest.authoredOn", description="Return prescriptions written on this date", type="date" )
3275  public static final String SP_AUTHOREDON = "authoredon";
3276 /**
3277   * <b>Fluent Client</b> search parameter constant for <b>authoredon</b>
3278   * <p>
3279   * Description: <b>Return prescriptions written on this date</b><br>
3280   * Type: <b>date</b><br>
3281   * Path: <b>MedicationRequest.authoredOn</b><br>
3282   * </p>
3283   */
3284  public static final ca.uhn.fhir.rest.gclient.DateClientParam AUTHOREDON = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_AUTHOREDON);
3285
3286 /**
3287   * Search parameter: <b>code</b>
3288   * <p>
3289   * Description: <b>Return prescriptions of this medication code</b><br>
3290   * Type: <b>token</b><br>
3291   * Path: <b>MedicationRequest.medicationCodeableConcept</b><br>
3292   * </p>
3293   */
3294  @SearchParamDefinition(name="code", path="MedicationRequest.medication.as(CodeableConcept)", description="Return prescriptions of this medication code", type="token" )
3295  public static final String SP_CODE = "code";
3296 /**
3297   * <b>Fluent Client</b> search parameter constant for <b>code</b>
3298   * <p>
3299   * Description: <b>Return prescriptions of this medication code</b><br>
3300   * Type: <b>token</b><br>
3301   * Path: <b>MedicationRequest.medicationCodeableConcept</b><br>
3302   * </p>
3303   */
3304  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CODE);
3305
3306 /**
3307   * Search parameter: <b>subject</b>
3308   * <p>
3309   * Description: <b>The identity of a patient to list orders  for</b><br>
3310   * Type: <b>reference</b><br>
3311   * Path: <b>MedicationRequest.subject</b><br>
3312   * </p>
3313   */
3314  @SearchParamDefinition(name="subject", path="MedicationRequest.subject", description="The identity of a patient to list orders  for", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Group.class, Patient.class } )
3315  public static final String SP_SUBJECT = "subject";
3316 /**
3317   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
3318   * <p>
3319   * Description: <b>The identity of a patient to list orders  for</b><br>
3320   * Type: <b>reference</b><br>
3321   * Path: <b>MedicationRequest.subject</b><br>
3322   * </p>
3323   */
3324  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
3325
3326/**
3327   * Constant for fluent queries to be used to add include statements. Specifies
3328   * the path value of "<b>MedicationRequest:subject</b>".
3329   */
3330  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("MedicationRequest:subject").toLocked();
3331
3332 /**
3333   * Search parameter: <b>medication</b>
3334   * <p>
3335   * Description: <b>Return prescriptions of this medication reference</b><br>
3336   * Type: <b>reference</b><br>
3337   * Path: <b>MedicationRequest.medicationReference</b><br>
3338   * </p>
3339   */
3340  @SearchParamDefinition(name="medication", path="MedicationRequest.medication.as(Reference)", description="Return prescriptions of this medication reference", type="reference", target={Medication.class } )
3341  public static final String SP_MEDICATION = "medication";
3342 /**
3343   * <b>Fluent Client</b> search parameter constant for <b>medication</b>
3344   * <p>
3345   * Description: <b>Return prescriptions of this medication reference</b><br>
3346   * Type: <b>reference</b><br>
3347   * Path: <b>MedicationRequest.medicationReference</b><br>
3348   * </p>
3349   */
3350  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam MEDICATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_MEDICATION);
3351
3352/**
3353   * Constant for fluent queries to be used to add include statements. Specifies
3354   * the path value of "<b>MedicationRequest:medication</b>".
3355   */
3356  public static final ca.uhn.fhir.model.api.Include INCLUDE_MEDICATION = new ca.uhn.fhir.model.api.Include("MedicationRequest:medication").toLocked();
3357
3358 /**
3359   * Search parameter: <b>priority</b>
3360   * <p>
3361   * Description: <b>Returns prescriptions with different priorities</b><br>
3362   * Type: <b>token</b><br>
3363   * Path: <b>MedicationRequest.priority</b><br>
3364   * </p>
3365   */
3366  @SearchParamDefinition(name="priority", path="MedicationRequest.priority", description="Returns prescriptions with different priorities", type="token" )
3367  public static final String SP_PRIORITY = "priority";
3368 /**
3369   * <b>Fluent Client</b> search parameter constant for <b>priority</b>
3370   * <p>
3371   * Description: <b>Returns prescriptions with different priorities</b><br>
3372   * Type: <b>token</b><br>
3373   * Path: <b>MedicationRequest.priority</b><br>
3374   * </p>
3375   */
3376  public static final ca.uhn.fhir.rest.gclient.TokenClientParam PRIORITY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_PRIORITY);
3377
3378 /**
3379   * Search parameter: <b>intent</b>
3380   * <p>
3381   * Description: <b>Returns prescriptions with different intents</b><br>
3382   * Type: <b>token</b><br>
3383   * Path: <b>MedicationRequest.intent</b><br>
3384   * </p>
3385   */
3386  @SearchParamDefinition(name="intent", path="MedicationRequest.intent", description="Returns prescriptions with different intents", type="token" )
3387  public static final String SP_INTENT = "intent";
3388 /**
3389   * <b>Fluent Client</b> search parameter constant for <b>intent</b>
3390   * <p>
3391   * Description: <b>Returns prescriptions with different intents</b><br>
3392   * Type: <b>token</b><br>
3393   * Path: <b>MedicationRequest.intent</b><br>
3394   * </p>
3395   */
3396  public static final ca.uhn.fhir.rest.gclient.TokenClientParam INTENT = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_INTENT);
3397
3398 /**
3399   * Search parameter: <b>patient</b>
3400   * <p>
3401   * Description: <b>Returns prescriptions for a specific patient</b><br>
3402   * Type: <b>reference</b><br>
3403   * Path: <b>MedicationRequest.subject</b><br>
3404   * </p>
3405   */
3406  @SearchParamDefinition(name="patient", path="MedicationRequest.subject", description="Returns prescriptions for a specific patient", type="reference", target={Patient.class } )
3407  public static final String SP_PATIENT = "patient";
3408 /**
3409   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
3410   * <p>
3411   * Description: <b>Returns prescriptions for a specific patient</b><br>
3412   * Type: <b>reference</b><br>
3413   * Path: <b>MedicationRequest.subject</b><br>
3414   * </p>
3415   */
3416  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
3417
3418/**
3419   * Constant for fluent queries to be used to add include statements. Specifies
3420   * the path value of "<b>MedicationRequest:patient</b>".
3421   */
3422  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("MedicationRequest:patient").toLocked();
3423
3424 /**
3425   * Search parameter: <b>context</b>
3426   * <p>
3427   * Description: <b>Return prescriptions with this encounter or episode of care identifier</b><br>
3428   * Type: <b>reference</b><br>
3429   * Path: <b>MedicationRequest.context</b><br>
3430   * </p>
3431   */
3432  @SearchParamDefinition(name="context", path="MedicationRequest.context", description="Return prescriptions with this encounter or episode of care identifier", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Encounter") }, target={Encounter.class, EpisodeOfCare.class } )
3433  public static final String SP_CONTEXT = "context";
3434 /**
3435   * <b>Fluent Client</b> search parameter constant for <b>context</b>
3436   * <p>
3437   * Description: <b>Return prescriptions with this encounter or episode of care identifier</b><br>
3438   * Type: <b>reference</b><br>
3439   * Path: <b>MedicationRequest.context</b><br>
3440   * </p>
3441   */
3442  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam CONTEXT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_CONTEXT);
3443
3444/**
3445   * Constant for fluent queries to be used to add include statements. Specifies
3446   * the path value of "<b>MedicationRequest:context</b>".
3447   */
3448  public static final ca.uhn.fhir.model.api.Include INCLUDE_CONTEXT = new ca.uhn.fhir.model.api.Include("MedicationRequest:context").toLocked();
3449
3450 /**
3451   * Search parameter: <b>category</b>
3452   * <p>
3453   * Description: <b>Returns prescriptions with different categories</b><br>
3454   * Type: <b>token</b><br>
3455   * Path: <b>MedicationRequest.category</b><br>
3456   * </p>
3457   */
3458  @SearchParamDefinition(name="category", path="MedicationRequest.category", description="Returns prescriptions with different categories", type="token" )
3459  public static final String SP_CATEGORY = "category";
3460 /**
3461   * <b>Fluent Client</b> search parameter constant for <b>category</b>
3462   * <p>
3463   * Description: <b>Returns prescriptions with different categories</b><br>
3464   * Type: <b>token</b><br>
3465   * Path: <b>MedicationRequest.category</b><br>
3466   * </p>
3467   */
3468  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CATEGORY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CATEGORY);
3469
3470 /**
3471   * Search parameter: <b>status</b>
3472   * <p>
3473   * Description: <b>Status of the prescription</b><br>
3474   * Type: <b>token</b><br>
3475   * Path: <b>MedicationRequest.status</b><br>
3476   * </p>
3477   */
3478  @SearchParamDefinition(name="status", path="MedicationRequest.status", description="Status of the prescription", type="token" )
3479  public static final String SP_STATUS = "status";
3480 /**
3481   * <b>Fluent Client</b> search parameter constant for <b>status</b>
3482   * <p>
3483   * Description: <b>Status of the prescription</b><br>
3484   * Type: <b>token</b><br>
3485   * Path: <b>MedicationRequest.status</b><br>
3486   * </p>
3487   */
3488  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
3489
3490
3491}
3492