001package org.hl7.fhir.r5.model;
002
003
004/*
005 * #%L
006 * org.hl7.fhir.r5
007 * %%
008 * Copyright (C) 2014 - 2019 Health Level 7
009 * %%
010 * Licensed under the Apache License, Version 2.0 (the \"License\");
011 * you may not use this file except in compliance with the License.
012 * You may obtain a copy of the License at
013 * 
014 *      http://www.apache.org/licenses/LICENSE-2.0
015 * 
016 * Unless required by applicable law or agreed to in writing, software
017 * distributed under the License is distributed on an \"AS IS\" BASIS,
018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
019 * See the License for the specific language governing permissions and
020 * limitations under the License.
021 * #L%
022 */
023
024/*
025  Copyright (c) 2011+, HL7, Inc.
026  All rights reserved.
027  
028  Redistribution and use in source and binary forms, with or without modification, \
029  are permitted provided that the following conditions are met:
030  
031   * Redistributions of source code must retain the above copyright notice, this \
032     list of conditions and the following disclaimer.
033   * Redistributions in binary form must reproduce the above copyright notice, \
034     this list of conditions and the following disclaimer in the documentation \
035     and/or other materials provided with the distribution.
036   * Neither the name of HL7 nor the names of its contributors may be used to 
037     endorse or promote products derived from this software without specific 
038     prior written permission.
039  
040  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \
041  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \
042  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \
043  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \
044  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \
045  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \
046  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \
047  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \
048  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \
049  POSSIBILITY OF SUCH DAMAGE.
050  */
051
052// Generated on Tue, Dec 31, 2019 12:12+1100 for FHIR vcurrent
053
054import java.util.ArrayList;
055import java.util.Date;
056import java.util.List;
057import org.hl7.fhir.utilities.Utilities;
058import org.hl7.fhir.r5.model.Enumerations.*;
059import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
060import org.hl7.fhir.exceptions.FHIRException;
061import org.hl7.fhir.instance.model.api.ICompositeType;
062import ca.uhn.fhir.model.api.annotation.ResourceDef;
063import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
064import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
065import ca.uhn.fhir.model.api.annotation.Child;
066import ca.uhn.fhir.model.api.annotation.ChildOrder;
067import ca.uhn.fhir.model.api.annotation.Description;
068import ca.uhn.fhir.model.api.annotation.Block;
069
070/**
071 * 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.
072 */
073@ResourceDef(name="MedicationRequest", profile="http://hl7.org/fhir/StructureDefinition/MedicationRequest")
074public class MedicationRequest extends DomainResource {
075
076    public enum MedicationRequestIntent {
077        /**
078         * 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
079         */
080        PROPOSAL, 
081        /**
082         * The request represents an intention to ensure something occurs without providing an authorization for others to act.
083         */
084        PLAN, 
085        /**
086         * The request represents a request/demand and authorization for action
087         */
088        ORDER, 
089        /**
090         * The request represents the original authorization for the medication request.
091         */
092        ORIGINALORDER, 
093        /**
094         * The request represents an automatically generated supplemental authorization for action based on a parent authorization together with initial results of the action taken against that parent authorization..
095         */
096        REFLEXORDER, 
097        /**
098         * The request represents the view of an authorization instantiated by a fulfilling system representing the details of the fulfiller's intention to act upon a submitted order.
099         */
100        FILLERORDER, 
101        /**
102         * The request represents an instance for the particular order, for example a medication administration record.
103         */
104        INSTANCEORDER, 
105        /**
106         * The request represents a component or option for a RequestGroup that establishes timing, conditionality and/or  other constraints among a set of requests.
107         */
108        OPTION, 
109        /**
110         * added to help the parsers with the generic types
111         */
112        NULL;
113        public static MedicationRequestIntent fromCode(String codeString) throws FHIRException {
114            if (codeString == null || "".equals(codeString))
115                return null;
116        if ("proposal".equals(codeString))
117          return PROPOSAL;
118        if ("plan".equals(codeString))
119          return PLAN;
120        if ("order".equals(codeString))
121          return ORDER;
122        if ("original-order".equals(codeString))
123          return ORIGINALORDER;
124        if ("reflex-order".equals(codeString))
125          return REFLEXORDER;
126        if ("filler-order".equals(codeString))
127          return FILLERORDER;
128        if ("instance-order".equals(codeString))
129          return INSTANCEORDER;
130        if ("option".equals(codeString))
131          return OPTION;
132        if (Configuration.isAcceptInvalidEnums())
133          return null;
134        else
135          throw new FHIRException("Unknown MedicationRequestIntent code '"+codeString+"'");
136        }
137        public String toCode() {
138          switch (this) {
139            case PROPOSAL: return "proposal";
140            case PLAN: return "plan";
141            case ORDER: return "order";
142            case ORIGINALORDER: return "original-order";
143            case REFLEXORDER: return "reflex-order";
144            case FILLERORDER: return "filler-order";
145            case INSTANCEORDER: return "instance-order";
146            case OPTION: return "option";
147            default: return "?";
148          }
149        }
150        public String getSystem() {
151          switch (this) {
152            case PROPOSAL: return "http://hl7.org/fhir/CodeSystem/medicationrequest-intent";
153            case PLAN: return "http://hl7.org/fhir/CodeSystem/medicationrequest-intent";
154            case ORDER: return "http://hl7.org/fhir/CodeSystem/medicationrequest-intent";
155            case ORIGINALORDER: return "http://hl7.org/fhir/CodeSystem/medicationrequest-intent";
156            case REFLEXORDER: return "http://hl7.org/fhir/CodeSystem/medicationrequest-intent";
157            case FILLERORDER: return "http://hl7.org/fhir/CodeSystem/medicationrequest-intent";
158            case INSTANCEORDER: return "http://hl7.org/fhir/CodeSystem/medicationrequest-intent";
159            case OPTION: return "http://hl7.org/fhir/CodeSystem/medicationrequest-intent";
160            default: return "?";
161          }
162        }
163        public String getDefinition() {
164          switch (this) {
165            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";
166            case PLAN: return "The request represents an intention to ensure something occurs without providing an authorization for others to act.";
167            case ORDER: return "The request represents a request/demand and authorization for action";
168            case ORIGINALORDER: return "The request represents the original authorization for the medication request.";
169            case REFLEXORDER: return "The request represents an automatically generated supplemental authorization for action based on a parent authorization together with initial results of the action taken against that parent authorization..";
170            case FILLERORDER: return "The request represents the view of an authorization instantiated by a fulfilling system representing the details of the fulfiller's intention to act upon a submitted order.";
171            case INSTANCEORDER: return "The request represents an instance for the particular order, for example a medication administration record.";
172            case OPTION: return "The request represents a component or option for a RequestGroup that establishes timing, conditionality and/or  other constraints among a set of requests.";
173            default: return "?";
174          }
175        }
176        public String getDisplay() {
177          switch (this) {
178            case PROPOSAL: return "Proposal";
179            case PLAN: return "Plan";
180            case ORDER: return "Order";
181            case ORIGINALORDER: return "Original Order";
182            case REFLEXORDER: return "Reflex Order";
183            case FILLERORDER: return "Filler Order";
184            case INSTANCEORDER: return "Instance Order";
185            case OPTION: return "Option";
186            default: return "?";
187          }
188        }
189    }
190
191  public static class MedicationRequestIntentEnumFactory implements EnumFactory<MedicationRequestIntent> {
192    public MedicationRequestIntent fromCode(String codeString) throws IllegalArgumentException {
193      if (codeString == null || "".equals(codeString))
194            if (codeString == null || "".equals(codeString))
195                return null;
196        if ("proposal".equals(codeString))
197          return MedicationRequestIntent.PROPOSAL;
198        if ("plan".equals(codeString))
199          return MedicationRequestIntent.PLAN;
200        if ("order".equals(codeString))
201          return MedicationRequestIntent.ORDER;
202        if ("original-order".equals(codeString))
203          return MedicationRequestIntent.ORIGINALORDER;
204        if ("reflex-order".equals(codeString))
205          return MedicationRequestIntent.REFLEXORDER;
206        if ("filler-order".equals(codeString))
207          return MedicationRequestIntent.FILLERORDER;
208        if ("instance-order".equals(codeString))
209          return MedicationRequestIntent.INSTANCEORDER;
210        if ("option".equals(codeString))
211          return MedicationRequestIntent.OPTION;
212        throw new IllegalArgumentException("Unknown MedicationRequestIntent code '"+codeString+"'");
213        }
214        public Enumeration<MedicationRequestIntent> fromType(Base code) throws FHIRException {
215          if (code == null)
216            return null;
217          if (code.isEmpty())
218            return new Enumeration<MedicationRequestIntent>(this);
219          String codeString = ((PrimitiveType) code).asStringValue();
220          if (codeString == null || "".equals(codeString))
221            return null;
222        if ("proposal".equals(codeString))
223          return new Enumeration<MedicationRequestIntent>(this, MedicationRequestIntent.PROPOSAL);
224        if ("plan".equals(codeString))
225          return new Enumeration<MedicationRequestIntent>(this, MedicationRequestIntent.PLAN);
226        if ("order".equals(codeString))
227          return new Enumeration<MedicationRequestIntent>(this, MedicationRequestIntent.ORDER);
228        if ("original-order".equals(codeString))
229          return new Enumeration<MedicationRequestIntent>(this, MedicationRequestIntent.ORIGINALORDER);
230        if ("reflex-order".equals(codeString))
231          return new Enumeration<MedicationRequestIntent>(this, MedicationRequestIntent.REFLEXORDER);
232        if ("filler-order".equals(codeString))
233          return new Enumeration<MedicationRequestIntent>(this, MedicationRequestIntent.FILLERORDER);
234        if ("instance-order".equals(codeString))
235          return new Enumeration<MedicationRequestIntent>(this, MedicationRequestIntent.INSTANCEORDER);
236        if ("option".equals(codeString))
237          return new Enumeration<MedicationRequestIntent>(this, MedicationRequestIntent.OPTION);
238        throw new FHIRException("Unknown MedicationRequestIntent code '"+codeString+"'");
239        }
240    public String toCode(MedicationRequestIntent code) {
241      if (code == MedicationRequestIntent.PROPOSAL)
242        return "proposal";
243      if (code == MedicationRequestIntent.PLAN)
244        return "plan";
245      if (code == MedicationRequestIntent.ORDER)
246        return "order";
247      if (code == MedicationRequestIntent.ORIGINALORDER)
248        return "original-order";
249      if (code == MedicationRequestIntent.REFLEXORDER)
250        return "reflex-order";
251      if (code == MedicationRequestIntent.FILLERORDER)
252        return "filler-order";
253      if (code == MedicationRequestIntent.INSTANCEORDER)
254        return "instance-order";
255      if (code == MedicationRequestIntent.OPTION)
256        return "option";
257      return "?";
258      }
259    public String toSystem(MedicationRequestIntent code) {
260      return code.getSystem();
261      }
262    }
263
264    public enum MedicationrequestStatus {
265        /**
266         * The prescription is 'actionable', but not all actions that are implied by it have occurred yet.
267         */
268        ACTIVE, 
269        /**
270         * Actions implied by the prescription are to be temporarily halted. The prescription might or might not be resumed. May also be called 'suspended'.
271         */
272        ONHOLD, 
273        /**
274         * The prescription has been withdrawn before any administrations have occurred
275         */
276        CANCELLED, 
277        /**
278         * All actions that are implied by the prescription have occurred.
279         */
280        COMPLETED, 
281        /**
282         * Some of the actions that are implied by the medication request may have occurred.  For example, the medication may have been dispensed and the patient may have taken some of the medication.  Clinical decision support systems should take this status into account
283         */
284        ENTEREDINERROR, 
285        /**
286         * Actions implied by the prescription are to be permanently halted, before all of the administrations occurred. This should not be used if the original order was entered in error
287         */
288        STOPPED, 
289        /**
290         * The prescription is not yet 'actionable', e.g. it is a work in progress, requires sign-off, verification or needs to be run through decision support process.
291         */
292        DRAFT, 
293        /**
294         * The authoring/source system does not know which of the status values currently applies for this observation. Note: This concept is not to be used for 'other' - one of the listed statuses is presumed to apply, but the authoring/source system does not know which.
295         */
296        UNKNOWN, 
297        /**
298         * added to help the parsers with the generic types
299         */
300        NULL;
301        public static MedicationrequestStatus fromCode(String codeString) throws FHIRException {
302            if (codeString == null || "".equals(codeString))
303                return null;
304        if ("active".equals(codeString))
305          return ACTIVE;
306        if ("on-hold".equals(codeString))
307          return ONHOLD;
308        if ("cancelled".equals(codeString))
309          return CANCELLED;
310        if ("completed".equals(codeString))
311          return COMPLETED;
312        if ("entered-in-error".equals(codeString))
313          return ENTEREDINERROR;
314        if ("stopped".equals(codeString))
315          return STOPPED;
316        if ("draft".equals(codeString))
317          return DRAFT;
318        if ("unknown".equals(codeString))
319          return UNKNOWN;
320        if (Configuration.isAcceptInvalidEnums())
321          return null;
322        else
323          throw new FHIRException("Unknown MedicationrequestStatus code '"+codeString+"'");
324        }
325        public String toCode() {
326          switch (this) {
327            case ACTIVE: return "active";
328            case ONHOLD: return "on-hold";
329            case CANCELLED: return "cancelled";
330            case COMPLETED: return "completed";
331            case ENTEREDINERROR: return "entered-in-error";
332            case STOPPED: return "stopped";
333            case DRAFT: return "draft";
334            case UNKNOWN: return "unknown";
335            default: return "?";
336          }
337        }
338        public String getSystem() {
339          switch (this) {
340            case ACTIVE: return "http://hl7.org/fhir/CodeSystem/medicationrequest-status";
341            case ONHOLD: return "http://hl7.org/fhir/CodeSystem/medicationrequest-status";
342            case CANCELLED: return "http://hl7.org/fhir/CodeSystem/medicationrequest-status";
343            case COMPLETED: return "http://hl7.org/fhir/CodeSystem/medicationrequest-status";
344            case ENTEREDINERROR: return "http://hl7.org/fhir/CodeSystem/medicationrequest-status";
345            case STOPPED: return "http://hl7.org/fhir/CodeSystem/medicationrequest-status";
346            case DRAFT: return "http://hl7.org/fhir/CodeSystem/medicationrequest-status";
347            case UNKNOWN: return "http://hl7.org/fhir/CodeSystem/medicationrequest-status";
348            default: return "?";
349          }
350        }
351        public String getDefinition() {
352          switch (this) {
353            case ACTIVE: return "The prescription is 'actionable', but not all actions that are implied by it have occurred yet.";
354            case ONHOLD: return "Actions implied by the prescription are to be temporarily halted. The prescription might or might not be resumed. May also be called 'suspended'.";
355            case CANCELLED: return "The prescription has been withdrawn before any administrations have occurred";
356            case COMPLETED: return "All actions that are implied by the prescription have occurred.";
357            case ENTEREDINERROR: return "Some of the actions that are implied by the medication request may have occurred.  For example, the medication may have been dispensed and the patient may have taken some of the medication.  Clinical decision support systems should take this status into account";
358            case STOPPED: return "Actions implied by the prescription are to be permanently halted, before all of the administrations occurred. This should not be used if the original order was entered in error";
359            case DRAFT: return "The prescription is not yet 'actionable', e.g. it is a work in progress, requires sign-off, verification or needs to be run through decision support process.";
360            case UNKNOWN: return "The authoring/source system does not know which of the status values currently applies for this observation. Note: This concept is not to be used for 'other' - one of the listed statuses is presumed to apply, but the authoring/source system does not know which.";
361            default: return "?";
362          }
363        }
364        public String getDisplay() {
365          switch (this) {
366            case ACTIVE: return "Active";
367            case ONHOLD: return "On Hold";
368            case CANCELLED: return "Cancelled";
369            case COMPLETED: return "Completed";
370            case ENTEREDINERROR: return "Entered in Error";
371            case STOPPED: return "Stopped";
372            case DRAFT: return "Draft";
373            case UNKNOWN: return "Unknown";
374            default: return "?";
375          }
376        }
377    }
378
379  public static class MedicationrequestStatusEnumFactory implements EnumFactory<MedicationrequestStatus> {
380    public MedicationrequestStatus fromCode(String codeString) throws IllegalArgumentException {
381      if (codeString == null || "".equals(codeString))
382            if (codeString == null || "".equals(codeString))
383                return null;
384        if ("active".equals(codeString))
385          return MedicationrequestStatus.ACTIVE;
386        if ("on-hold".equals(codeString))
387          return MedicationrequestStatus.ONHOLD;
388        if ("cancelled".equals(codeString))
389          return MedicationrequestStatus.CANCELLED;
390        if ("completed".equals(codeString))
391          return MedicationrequestStatus.COMPLETED;
392        if ("entered-in-error".equals(codeString))
393          return MedicationrequestStatus.ENTEREDINERROR;
394        if ("stopped".equals(codeString))
395          return MedicationrequestStatus.STOPPED;
396        if ("draft".equals(codeString))
397          return MedicationrequestStatus.DRAFT;
398        if ("unknown".equals(codeString))
399          return MedicationrequestStatus.UNKNOWN;
400        throw new IllegalArgumentException("Unknown MedicationrequestStatus code '"+codeString+"'");
401        }
402        public Enumeration<MedicationrequestStatus> fromType(Base code) throws FHIRException {
403          if (code == null)
404            return null;
405          if (code.isEmpty())
406            return new Enumeration<MedicationrequestStatus>(this);
407          String codeString = ((PrimitiveType) code).asStringValue();
408          if (codeString == null || "".equals(codeString))
409            return null;
410        if ("active".equals(codeString))
411          return new Enumeration<MedicationrequestStatus>(this, MedicationrequestStatus.ACTIVE);
412        if ("on-hold".equals(codeString))
413          return new Enumeration<MedicationrequestStatus>(this, MedicationrequestStatus.ONHOLD);
414        if ("cancelled".equals(codeString))
415          return new Enumeration<MedicationrequestStatus>(this, MedicationrequestStatus.CANCELLED);
416        if ("completed".equals(codeString))
417          return new Enumeration<MedicationrequestStatus>(this, MedicationrequestStatus.COMPLETED);
418        if ("entered-in-error".equals(codeString))
419          return new Enumeration<MedicationrequestStatus>(this, MedicationrequestStatus.ENTEREDINERROR);
420        if ("stopped".equals(codeString))
421          return new Enumeration<MedicationrequestStatus>(this, MedicationrequestStatus.STOPPED);
422        if ("draft".equals(codeString))
423          return new Enumeration<MedicationrequestStatus>(this, MedicationrequestStatus.DRAFT);
424        if ("unknown".equals(codeString))
425          return new Enumeration<MedicationrequestStatus>(this, MedicationrequestStatus.UNKNOWN);
426        throw new FHIRException("Unknown MedicationrequestStatus code '"+codeString+"'");
427        }
428    public String toCode(MedicationrequestStatus code) {
429      if (code == MedicationrequestStatus.ACTIVE)
430        return "active";
431      if (code == MedicationrequestStatus.ONHOLD)
432        return "on-hold";
433      if (code == MedicationrequestStatus.CANCELLED)
434        return "cancelled";
435      if (code == MedicationrequestStatus.COMPLETED)
436        return "completed";
437      if (code == MedicationrequestStatus.ENTEREDINERROR)
438        return "entered-in-error";
439      if (code == MedicationrequestStatus.STOPPED)
440        return "stopped";
441      if (code == MedicationrequestStatus.DRAFT)
442        return "draft";
443      if (code == MedicationrequestStatus.UNKNOWN)
444        return "unknown";
445      return "?";
446      }
447    public String toSystem(MedicationrequestStatus code) {
448      return code.getSystem();
449      }
450    }
451
452    @Block()
453    public static class MedicationRequestDispenseRequestComponent extends BackboneElement implements IBaseBackboneElement {
454        /**
455         * Indicates the quantity or duration for the first dispense of the medication.
456         */
457        @Child(name = "initialFill", type = {}, order=1, min=0, max=1, modifier=false, summary=false)
458        @Description(shortDefinition="First fill details", formalDefinition="Indicates the quantity or duration for the first dispense of the medication." )
459        protected MedicationRequestDispenseRequestInitialFillComponent initialFill;
460
461        /**
462         * The minimum period of time that must occur between dispenses of the medication.
463         */
464        @Child(name = "dispenseInterval", type = {Duration.class}, order=2, min=0, max=1, modifier=false, summary=false)
465        @Description(shortDefinition="Minimum period of time between dispenses", formalDefinition="The minimum period of time that must occur between dispenses of the medication." )
466        protected Duration dispenseInterval;
467
468        /**
469         * This indicates the validity period of a prescription (stale dating the Prescription).
470         */
471        @Child(name = "validityPeriod", type = {Period.class}, order=3, min=0, max=1, modifier=false, summary=false)
472        @Description(shortDefinition="Time period supply is authorized for", formalDefinition="This indicates the validity period of a prescription (stale dating the Prescription)." )
473        protected Period validityPeriod;
474
475        /**
476         * 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.  A prescriber may explicitly say that zero refills are permitted after the initial dispense.
477         */
478        @Child(name = "numberOfRepeatsAllowed", type = {UnsignedIntType.class}, order=4, min=0, max=1, modifier=false, summary=false)
479        @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.  A prescriber may explicitly say that zero refills are permitted after the initial dispense." )
480        protected UnsignedIntType numberOfRepeatsAllowed;
481
482        /**
483         * The amount that is to be dispensed for one fill.
484         */
485        @Child(name = "quantity", type = {Quantity.class}, order=5, min=0, max=1, modifier=false, summary=false)
486        @Description(shortDefinition="Amount of medication to supply per dispense", formalDefinition="The amount that is to be dispensed for one fill." )
487        protected Quantity quantity;
488
489        /**
490         * 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.
491         */
492        @Child(name = "expectedSupplyDuration", type = {Duration.class}, order=6, min=0, max=1, modifier=false, summary=false)
493        @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." )
494        protected Duration expectedSupplyDuration;
495
496        /**
497         * Indicates the intended performing Organization that will dispense the medication as specified by the prescriber.
498         */
499        @Child(name = "dispenser", type = {Organization.class}, order=7, min=0, max=1, modifier=false, summary=false)
500        @Description(shortDefinition="Intended performer of dispense", formalDefinition="Indicates the intended performing Organization that will dispense the medication as specified by the prescriber." )
501        protected Reference dispenser;
502
503        private static final long serialVersionUID = 1118791702L;
504
505    /**
506     * Constructor
507     */
508      public MedicationRequestDispenseRequestComponent() {
509        super();
510      }
511
512        /**
513         * @return {@link #initialFill} (Indicates the quantity or duration for the first dispense of the medication.)
514         */
515        public MedicationRequestDispenseRequestInitialFillComponent getInitialFill() { 
516          if (this.initialFill == null)
517            if (Configuration.errorOnAutoCreate())
518              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.initialFill");
519            else if (Configuration.doAutoCreate())
520              this.initialFill = new MedicationRequestDispenseRequestInitialFillComponent(); // cc
521          return this.initialFill;
522        }
523
524        public boolean hasInitialFill() { 
525          return this.initialFill != null && !this.initialFill.isEmpty();
526        }
527
528        /**
529         * @param value {@link #initialFill} (Indicates the quantity or duration for the first dispense of the medication.)
530         */
531        public MedicationRequestDispenseRequestComponent setInitialFill(MedicationRequestDispenseRequestInitialFillComponent value) { 
532          this.initialFill = value;
533          return this;
534        }
535
536        /**
537         * @return {@link #dispenseInterval} (The minimum period of time that must occur between dispenses of the medication.)
538         */
539        public Duration getDispenseInterval() { 
540          if (this.dispenseInterval == null)
541            if (Configuration.errorOnAutoCreate())
542              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.dispenseInterval");
543            else if (Configuration.doAutoCreate())
544              this.dispenseInterval = new Duration(); // cc
545          return this.dispenseInterval;
546        }
547
548        public boolean hasDispenseInterval() { 
549          return this.dispenseInterval != null && !this.dispenseInterval.isEmpty();
550        }
551
552        /**
553         * @param value {@link #dispenseInterval} (The minimum period of time that must occur between dispenses of the medication.)
554         */
555        public MedicationRequestDispenseRequestComponent setDispenseInterval(Duration value) { 
556          this.dispenseInterval = value;
557          return this;
558        }
559
560        /**
561         * @return {@link #validityPeriod} (This indicates the validity period of a prescription (stale dating the Prescription).)
562         */
563        public Period getValidityPeriod() { 
564          if (this.validityPeriod == null)
565            if (Configuration.errorOnAutoCreate())
566              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.validityPeriod");
567            else if (Configuration.doAutoCreate())
568              this.validityPeriod = new Period(); // cc
569          return this.validityPeriod;
570        }
571
572        public boolean hasValidityPeriod() { 
573          return this.validityPeriod != null && !this.validityPeriod.isEmpty();
574        }
575
576        /**
577         * @param value {@link #validityPeriod} (This indicates the validity period of a prescription (stale dating the Prescription).)
578         */
579        public MedicationRequestDispenseRequestComponent setValidityPeriod(Period value) { 
580          this.validityPeriod = value;
581          return this;
582        }
583
584        /**
585         * @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.  A prescriber may explicitly say that zero refills are permitted after the initial dispense.). This is the underlying object with id, value and extensions. The accessor "getNumberOfRepeatsAllowed" gives direct access to the value
586         */
587        public UnsignedIntType getNumberOfRepeatsAllowedElement() { 
588          if (this.numberOfRepeatsAllowed == null)
589            if (Configuration.errorOnAutoCreate())
590              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.numberOfRepeatsAllowed");
591            else if (Configuration.doAutoCreate())
592              this.numberOfRepeatsAllowed = new UnsignedIntType(); // bb
593          return this.numberOfRepeatsAllowed;
594        }
595
596        public boolean hasNumberOfRepeatsAllowedElement() { 
597          return this.numberOfRepeatsAllowed != null && !this.numberOfRepeatsAllowed.isEmpty();
598        }
599
600        public boolean hasNumberOfRepeatsAllowed() { 
601          return this.numberOfRepeatsAllowed != null && !this.numberOfRepeatsAllowed.isEmpty();
602        }
603
604        /**
605         * @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.  A prescriber may explicitly say that zero refills are permitted after the initial dispense.). This is the underlying object with id, value and extensions. The accessor "getNumberOfRepeatsAllowed" gives direct access to the value
606         */
607        public MedicationRequestDispenseRequestComponent setNumberOfRepeatsAllowedElement(UnsignedIntType value) { 
608          this.numberOfRepeatsAllowed = value;
609          return this;
610        }
611
612        /**
613         * @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.  A prescriber may explicitly say that zero refills are permitted after the initial dispense.
614         */
615        public int getNumberOfRepeatsAllowed() { 
616          return this.numberOfRepeatsAllowed == null || this.numberOfRepeatsAllowed.isEmpty() ? 0 : this.numberOfRepeatsAllowed.getValue();
617        }
618
619        /**
620         * @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.  A prescriber may explicitly say that zero refills are permitted after the initial dispense.
621         */
622        public MedicationRequestDispenseRequestComponent setNumberOfRepeatsAllowed(int value) { 
623            if (this.numberOfRepeatsAllowed == null)
624              this.numberOfRepeatsAllowed = new UnsignedIntType();
625            this.numberOfRepeatsAllowed.setValue(value);
626          return this;
627        }
628
629        /**
630         * @return {@link #quantity} (The amount that is to be dispensed for one fill.)
631         */
632        public Quantity getQuantity() { 
633          if (this.quantity == null)
634            if (Configuration.errorOnAutoCreate())
635              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.quantity");
636            else if (Configuration.doAutoCreate())
637              this.quantity = new Quantity(); // cc
638          return this.quantity;
639        }
640
641        public boolean hasQuantity() { 
642          return this.quantity != null && !this.quantity.isEmpty();
643        }
644
645        /**
646         * @param value {@link #quantity} (The amount that is to be dispensed for one fill.)
647         */
648        public MedicationRequestDispenseRequestComponent setQuantity(Quantity value) { 
649          this.quantity = value;
650          return this;
651        }
652
653        /**
654         * @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.)
655         */
656        public Duration getExpectedSupplyDuration() { 
657          if (this.expectedSupplyDuration == null)
658            if (Configuration.errorOnAutoCreate())
659              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.expectedSupplyDuration");
660            else if (Configuration.doAutoCreate())
661              this.expectedSupplyDuration = new Duration(); // cc
662          return this.expectedSupplyDuration;
663        }
664
665        public boolean hasExpectedSupplyDuration() { 
666          return this.expectedSupplyDuration != null && !this.expectedSupplyDuration.isEmpty();
667        }
668
669        /**
670         * @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.)
671         */
672        public MedicationRequestDispenseRequestComponent setExpectedSupplyDuration(Duration value) { 
673          this.expectedSupplyDuration = value;
674          return this;
675        }
676
677        /**
678         * @return {@link #dispenser} (Indicates the intended performing Organization that will dispense the medication as specified by the prescriber.)
679         */
680        public Reference getDispenser() { 
681          if (this.dispenser == null)
682            if (Configuration.errorOnAutoCreate())
683              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.dispenser");
684            else if (Configuration.doAutoCreate())
685              this.dispenser = new Reference(); // cc
686          return this.dispenser;
687        }
688
689        public boolean hasDispenser() { 
690          return this.dispenser != null && !this.dispenser.isEmpty();
691        }
692
693        /**
694         * @param value {@link #dispenser} (Indicates the intended performing Organization that will dispense the medication as specified by the prescriber.)
695         */
696        public MedicationRequestDispenseRequestComponent setDispenser(Reference value) { 
697          this.dispenser = value;
698          return this;
699        }
700
701        protected void listChildren(List<Property> children) {
702          super.listChildren(children);
703          children.add(new Property("initialFill", "", "Indicates the quantity or duration for the first dispense of the medication.", 0, 1, initialFill));
704          children.add(new Property("dispenseInterval", "Duration", "The minimum period of time that must occur between dispenses of the medication.", 0, 1, dispenseInterval));
705          children.add(new Property("validityPeriod", "Period", "This indicates the validity period of a prescription (stale dating the Prescription).", 0, 1, validityPeriod));
706          children.add(new Property("numberOfRepeatsAllowed", "unsignedInt", "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.  A prescriber may explicitly say that zero refills are permitted after the initial dispense.", 0, 1, numberOfRepeatsAllowed));
707          children.add(new Property("quantity", "Quantity", "The amount that is to be dispensed for one fill.", 0, 1, quantity));
708          children.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, 1, expectedSupplyDuration));
709          children.add(new Property("dispenser", "Reference(Organization)", "Indicates the intended performing Organization that will dispense the medication as specified by the prescriber.", 0, 1, dispenser));
710        }
711
712        @Override
713        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
714          switch (_hash) {
715          case 1232961255: /*initialFill*/  return new Property("initialFill", "", "Indicates the quantity or duration for the first dispense of the medication.", 0, 1, initialFill);
716          case 757112130: /*dispenseInterval*/  return new Property("dispenseInterval", "Duration", "The minimum period of time that must occur between dispenses of the medication.", 0, 1, dispenseInterval);
717          case -1434195053: /*validityPeriod*/  return new Property("validityPeriod", "Period", "This indicates the validity period of a prescription (stale dating the Prescription).", 0, 1, validityPeriod);
718          case -239736976: /*numberOfRepeatsAllowed*/  return new Property("numberOfRepeatsAllowed", "unsignedInt", "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.  A prescriber may explicitly say that zero refills are permitted after the initial dispense.", 0, 1, numberOfRepeatsAllowed);
719          case -1285004149: /*quantity*/  return new Property("quantity", "Quantity", "The amount that is to be dispensed for one fill.", 0, 1, quantity);
720          case -1910182789: /*expectedSupplyDuration*/  return 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, 1, expectedSupplyDuration);
721          case 241511093: /*dispenser*/  return new Property("dispenser", "Reference(Organization)", "Indicates the intended performing Organization that will dispense the medication as specified by the prescriber.", 0, 1, dispenser);
722          default: return super.getNamedProperty(_hash, _name, _checkValid);
723          }
724
725        }
726
727      @Override
728      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
729        switch (hash) {
730        case 1232961255: /*initialFill*/ return this.initialFill == null ? new Base[0] : new Base[] {this.initialFill}; // MedicationRequestDispenseRequestInitialFillComponent
731        case 757112130: /*dispenseInterval*/ return this.dispenseInterval == null ? new Base[0] : new Base[] {this.dispenseInterval}; // Duration
732        case -1434195053: /*validityPeriod*/ return this.validityPeriod == null ? new Base[0] : new Base[] {this.validityPeriod}; // Period
733        case -239736976: /*numberOfRepeatsAllowed*/ return this.numberOfRepeatsAllowed == null ? new Base[0] : new Base[] {this.numberOfRepeatsAllowed}; // UnsignedIntType
734        case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // Quantity
735        case -1910182789: /*expectedSupplyDuration*/ return this.expectedSupplyDuration == null ? new Base[0] : new Base[] {this.expectedSupplyDuration}; // Duration
736        case 241511093: /*dispenser*/ return this.dispenser == null ? new Base[0] : new Base[] {this.dispenser}; // Reference
737        default: return super.getProperty(hash, name, checkValid);
738        }
739
740      }
741
742      @Override
743      public Base setProperty(int hash, String name, Base value) throws FHIRException {
744        switch (hash) {
745        case 1232961255: // initialFill
746          this.initialFill = (MedicationRequestDispenseRequestInitialFillComponent) value; // MedicationRequestDispenseRequestInitialFillComponent
747          return value;
748        case 757112130: // dispenseInterval
749          this.dispenseInterval = TypeConvertor.castToDuration(value); // Duration
750          return value;
751        case -1434195053: // validityPeriod
752          this.validityPeriod = TypeConvertor.castToPeriod(value); // Period
753          return value;
754        case -239736976: // numberOfRepeatsAllowed
755          this.numberOfRepeatsAllowed = TypeConvertor.castToUnsignedInt(value); // UnsignedIntType
756          return value;
757        case -1285004149: // quantity
758          this.quantity = TypeConvertor.castToQuantity(value); // Quantity
759          return value;
760        case -1910182789: // expectedSupplyDuration
761          this.expectedSupplyDuration = TypeConvertor.castToDuration(value); // Duration
762          return value;
763        case 241511093: // dispenser
764          this.dispenser = TypeConvertor.castToReference(value); // Reference
765          return value;
766        default: return super.setProperty(hash, name, value);
767        }
768
769      }
770
771      @Override
772      public Base setProperty(String name, Base value) throws FHIRException {
773        if (name.equals("initialFill")) {
774          this.initialFill = (MedicationRequestDispenseRequestInitialFillComponent) value; // MedicationRequestDispenseRequestInitialFillComponent
775        } else if (name.equals("dispenseInterval")) {
776          this.dispenseInterval = TypeConvertor.castToDuration(value); // Duration
777        } else if (name.equals("validityPeriod")) {
778          this.validityPeriod = TypeConvertor.castToPeriod(value); // Period
779        } else if (name.equals("numberOfRepeatsAllowed")) {
780          this.numberOfRepeatsAllowed = TypeConvertor.castToUnsignedInt(value); // UnsignedIntType
781        } else if (name.equals("quantity")) {
782          this.quantity = TypeConvertor.castToQuantity(value); // Quantity
783        } else if (name.equals("expectedSupplyDuration")) {
784          this.expectedSupplyDuration = TypeConvertor.castToDuration(value); // Duration
785        } else if (name.equals("dispenser")) {
786          this.dispenser = TypeConvertor.castToReference(value); // Reference
787        } else
788          return super.setProperty(name, value);
789        return value;
790      }
791
792      @Override
793      public Base makeProperty(int hash, String name) throws FHIRException {
794        switch (hash) {
795        case 1232961255:  return getInitialFill();
796        case 757112130:  return getDispenseInterval();
797        case -1434195053:  return getValidityPeriod();
798        case -239736976:  return getNumberOfRepeatsAllowedElement();
799        case -1285004149:  return getQuantity();
800        case -1910182789:  return getExpectedSupplyDuration();
801        case 241511093:  return getDispenser();
802        default: return super.makeProperty(hash, name);
803        }
804
805      }
806
807      @Override
808      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
809        switch (hash) {
810        case 1232961255: /*initialFill*/ return new String[] {};
811        case 757112130: /*dispenseInterval*/ return new String[] {"Duration"};
812        case -1434195053: /*validityPeriod*/ return new String[] {"Period"};
813        case -239736976: /*numberOfRepeatsAllowed*/ return new String[] {"unsignedInt"};
814        case -1285004149: /*quantity*/ return new String[] {"Quantity"};
815        case -1910182789: /*expectedSupplyDuration*/ return new String[] {"Duration"};
816        case 241511093: /*dispenser*/ return new String[] {"Reference"};
817        default: return super.getTypesForProperty(hash, name);
818        }
819
820      }
821
822      @Override
823      public Base addChild(String name) throws FHIRException {
824        if (name.equals("initialFill")) {
825          this.initialFill = new MedicationRequestDispenseRequestInitialFillComponent();
826          return this.initialFill;
827        }
828        else if (name.equals("dispenseInterval")) {
829          this.dispenseInterval = new Duration();
830          return this.dispenseInterval;
831        }
832        else if (name.equals("validityPeriod")) {
833          this.validityPeriod = new Period();
834          return this.validityPeriod;
835        }
836        else if (name.equals("numberOfRepeatsAllowed")) {
837          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.dispenseRequest.numberOfRepeatsAllowed");
838        }
839        else if (name.equals("quantity")) {
840          this.quantity = new Quantity();
841          return this.quantity;
842        }
843        else if (name.equals("expectedSupplyDuration")) {
844          this.expectedSupplyDuration = new Duration();
845          return this.expectedSupplyDuration;
846        }
847        else if (name.equals("dispenser")) {
848          this.dispenser = new Reference();
849          return this.dispenser;
850        }
851        else
852          return super.addChild(name);
853      }
854
855      public MedicationRequestDispenseRequestComponent copy() {
856        MedicationRequestDispenseRequestComponent dst = new MedicationRequestDispenseRequestComponent();
857        copyValues(dst);
858        return dst;
859      }
860
861      public void copyValues(MedicationRequestDispenseRequestComponent dst) {
862        super.copyValues(dst);
863        dst.initialFill = initialFill == null ? null : initialFill.copy();
864        dst.dispenseInterval = dispenseInterval == null ? null : dispenseInterval.copy();
865        dst.validityPeriod = validityPeriod == null ? null : validityPeriod.copy();
866        dst.numberOfRepeatsAllowed = numberOfRepeatsAllowed == null ? null : numberOfRepeatsAllowed.copy();
867        dst.quantity = quantity == null ? null : quantity.copy();
868        dst.expectedSupplyDuration = expectedSupplyDuration == null ? null : expectedSupplyDuration.copy();
869        dst.dispenser = dispenser == null ? null : dispenser.copy();
870      }
871
872      @Override
873      public boolean equalsDeep(Base other_) {
874        if (!super.equalsDeep(other_))
875          return false;
876        if (!(other_ instanceof MedicationRequestDispenseRequestComponent))
877          return false;
878        MedicationRequestDispenseRequestComponent o = (MedicationRequestDispenseRequestComponent) other_;
879        return compareDeep(initialFill, o.initialFill, true) && compareDeep(dispenseInterval, o.dispenseInterval, true)
880           && compareDeep(validityPeriod, o.validityPeriod, true) && compareDeep(numberOfRepeatsAllowed, o.numberOfRepeatsAllowed, true)
881           && compareDeep(quantity, o.quantity, true) && compareDeep(expectedSupplyDuration, o.expectedSupplyDuration, true)
882           && compareDeep(dispenser, o.dispenser, true);
883      }
884
885      @Override
886      public boolean equalsShallow(Base other_) {
887        if (!super.equalsShallow(other_))
888          return false;
889        if (!(other_ instanceof MedicationRequestDispenseRequestComponent))
890          return false;
891        MedicationRequestDispenseRequestComponent o = (MedicationRequestDispenseRequestComponent) other_;
892        return compareValues(numberOfRepeatsAllowed, o.numberOfRepeatsAllowed, true);
893      }
894
895      public boolean isEmpty() {
896        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(initialFill, dispenseInterval
897          , validityPeriod, numberOfRepeatsAllowed, quantity, expectedSupplyDuration, dispenser
898          );
899      }
900
901  public String fhirType() {
902    return "MedicationRequest.dispenseRequest";
903
904  }
905
906  }
907
908    @Block()
909    public static class MedicationRequestDispenseRequestInitialFillComponent extends BackboneElement implements IBaseBackboneElement {
910        /**
911         * The amount or quantity to provide as part of the first dispense.
912         */
913        @Child(name = "quantity", type = {Quantity.class}, order=1, min=0, max=1, modifier=false, summary=false)
914        @Description(shortDefinition="First fill quantity", formalDefinition="The amount or quantity to provide as part of the first dispense." )
915        protected Quantity quantity;
916
917        /**
918         * The length of time that the first dispense is expected to last.
919         */
920        @Child(name = "duration", type = {Duration.class}, order=2, min=0, max=1, modifier=false, summary=false)
921        @Description(shortDefinition="First fill duration", formalDefinition="The length of time that the first dispense is expected to last." )
922        protected Duration duration;
923
924        private static final long serialVersionUID = 1223227956L;
925
926    /**
927     * Constructor
928     */
929      public MedicationRequestDispenseRequestInitialFillComponent() {
930        super();
931      }
932
933        /**
934         * @return {@link #quantity} (The amount or quantity to provide as part of the first dispense.)
935         */
936        public Quantity getQuantity() { 
937          if (this.quantity == null)
938            if (Configuration.errorOnAutoCreate())
939              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestInitialFillComponent.quantity");
940            else if (Configuration.doAutoCreate())
941              this.quantity = new Quantity(); // cc
942          return this.quantity;
943        }
944
945        public boolean hasQuantity() { 
946          return this.quantity != null && !this.quantity.isEmpty();
947        }
948
949        /**
950         * @param value {@link #quantity} (The amount or quantity to provide as part of the first dispense.)
951         */
952        public MedicationRequestDispenseRequestInitialFillComponent setQuantity(Quantity value) { 
953          this.quantity = value;
954          return this;
955        }
956
957        /**
958         * @return {@link #duration} (The length of time that the first dispense is expected to last.)
959         */
960        public Duration getDuration() { 
961          if (this.duration == null)
962            if (Configuration.errorOnAutoCreate())
963              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestInitialFillComponent.duration");
964            else if (Configuration.doAutoCreate())
965              this.duration = new Duration(); // cc
966          return this.duration;
967        }
968
969        public boolean hasDuration() { 
970          return this.duration != null && !this.duration.isEmpty();
971        }
972
973        /**
974         * @param value {@link #duration} (The length of time that the first dispense is expected to last.)
975         */
976        public MedicationRequestDispenseRequestInitialFillComponent setDuration(Duration value) { 
977          this.duration = value;
978          return this;
979        }
980
981        protected void listChildren(List<Property> children) {
982          super.listChildren(children);
983          children.add(new Property("quantity", "Quantity", "The amount or quantity to provide as part of the first dispense.", 0, 1, quantity));
984          children.add(new Property("duration", "Duration", "The length of time that the first dispense is expected to last.", 0, 1, duration));
985        }
986
987        @Override
988        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
989          switch (_hash) {
990          case -1285004149: /*quantity*/  return new Property("quantity", "Quantity", "The amount or quantity to provide as part of the first dispense.", 0, 1, quantity);
991          case -1992012396: /*duration*/  return new Property("duration", "Duration", "The length of time that the first dispense is expected to last.", 0, 1, duration);
992          default: return super.getNamedProperty(_hash, _name, _checkValid);
993          }
994
995        }
996
997      @Override
998      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
999        switch (hash) {
1000        case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // Quantity
1001        case -1992012396: /*duration*/ return this.duration == null ? new Base[0] : new Base[] {this.duration}; // Duration
1002        default: return super.getProperty(hash, name, checkValid);
1003        }
1004
1005      }
1006
1007      @Override
1008      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1009        switch (hash) {
1010        case -1285004149: // quantity
1011          this.quantity = TypeConvertor.castToQuantity(value); // Quantity
1012          return value;
1013        case -1992012396: // duration
1014          this.duration = TypeConvertor.castToDuration(value); // Duration
1015          return value;
1016        default: return super.setProperty(hash, name, value);
1017        }
1018
1019      }
1020
1021      @Override
1022      public Base setProperty(String name, Base value) throws FHIRException {
1023        if (name.equals("quantity")) {
1024          this.quantity = TypeConvertor.castToQuantity(value); // Quantity
1025        } else if (name.equals("duration")) {
1026          this.duration = TypeConvertor.castToDuration(value); // Duration
1027        } else
1028          return super.setProperty(name, value);
1029        return value;
1030      }
1031
1032      @Override
1033      public Base makeProperty(int hash, String name) throws FHIRException {
1034        switch (hash) {
1035        case -1285004149:  return getQuantity();
1036        case -1992012396:  return getDuration();
1037        default: return super.makeProperty(hash, name);
1038        }
1039
1040      }
1041
1042      @Override
1043      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1044        switch (hash) {
1045        case -1285004149: /*quantity*/ return new String[] {"Quantity"};
1046        case -1992012396: /*duration*/ return new String[] {"Duration"};
1047        default: return super.getTypesForProperty(hash, name);
1048        }
1049
1050      }
1051
1052      @Override
1053      public Base addChild(String name) throws FHIRException {
1054        if (name.equals("quantity")) {
1055          this.quantity = new Quantity();
1056          return this.quantity;
1057        }
1058        else if (name.equals("duration")) {
1059          this.duration = new Duration();
1060          return this.duration;
1061        }
1062        else
1063          return super.addChild(name);
1064      }
1065
1066      public MedicationRequestDispenseRequestInitialFillComponent copy() {
1067        MedicationRequestDispenseRequestInitialFillComponent dst = new MedicationRequestDispenseRequestInitialFillComponent();
1068        copyValues(dst);
1069        return dst;
1070      }
1071
1072      public void copyValues(MedicationRequestDispenseRequestInitialFillComponent dst) {
1073        super.copyValues(dst);
1074        dst.quantity = quantity == null ? null : quantity.copy();
1075        dst.duration = duration == null ? null : duration.copy();
1076      }
1077
1078      @Override
1079      public boolean equalsDeep(Base other_) {
1080        if (!super.equalsDeep(other_))
1081          return false;
1082        if (!(other_ instanceof MedicationRequestDispenseRequestInitialFillComponent))
1083          return false;
1084        MedicationRequestDispenseRequestInitialFillComponent o = (MedicationRequestDispenseRequestInitialFillComponent) other_;
1085        return compareDeep(quantity, o.quantity, true) && compareDeep(duration, o.duration, true);
1086      }
1087
1088      @Override
1089      public boolean equalsShallow(Base other_) {
1090        if (!super.equalsShallow(other_))
1091          return false;
1092        if (!(other_ instanceof MedicationRequestDispenseRequestInitialFillComponent))
1093          return false;
1094        MedicationRequestDispenseRequestInitialFillComponent o = (MedicationRequestDispenseRequestInitialFillComponent) other_;
1095        return true;
1096      }
1097
1098      public boolean isEmpty() {
1099        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(quantity, duration);
1100      }
1101
1102  public String fhirType() {
1103    return "MedicationRequest.dispenseRequest.initialFill";
1104
1105  }
1106
1107  }
1108
1109    @Block()
1110    public static class MedicationRequestSubstitutionComponent extends BackboneElement implements IBaseBackboneElement {
1111        /**
1112         * True if the prescriber allows a different drug to be dispensed from what was prescribed.
1113         */
1114        @Child(name = "allowed", type = {BooleanType.class, CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=false)
1115        @Description(shortDefinition="Whether substitution is allowed or not", formalDefinition="True if the prescriber allows a different drug to be dispensed from what was prescribed." )
1116        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://terminology.hl7.org/ValueSet/v3-ActSubstanceAdminSubstitutionCode")
1117        protected DataType allowed;
1118
1119        /**
1120         * Indicates the reason for the substitution, or why substitution must or must not be performed.
1121         */
1122        @Child(name = "reason", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
1123        @Description(shortDefinition="Why should (not) substitution be made", formalDefinition="Indicates the reason for the substitution, or why substitution must or must not be performed." )
1124        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://terminology.hl7.org/ValueSet/v3-SubstanceAdminSubstitutionReason")
1125        protected CodeableConcept reason;
1126
1127        private static final long serialVersionUID = -855005751L;
1128
1129    /**
1130     * Constructor
1131     */
1132      public MedicationRequestSubstitutionComponent() {
1133        super();
1134      }
1135
1136    /**
1137     * Constructor
1138     */
1139      public MedicationRequestSubstitutionComponent(DataType allowed) {
1140        super();
1141        this.setAllowed(allowed);
1142      }
1143
1144        /**
1145         * @return {@link #allowed} (True if the prescriber allows a different drug to be dispensed from what was prescribed.)
1146         */
1147        public DataType getAllowed() { 
1148          return this.allowed;
1149        }
1150
1151        /**
1152         * @return {@link #allowed} (True if the prescriber allows a different drug to be dispensed from what was prescribed.)
1153         */
1154        public BooleanType getAllowedBooleanType() throws FHIRException { 
1155          if (this.allowed == null)
1156            this.allowed = new BooleanType();
1157          if (!(this.allowed instanceof BooleanType))
1158            throw new FHIRException("Type mismatch: the type BooleanType was expected, but "+this.allowed.getClass().getName()+" was encountered");
1159          return (BooleanType) this.allowed;
1160        }
1161
1162        public boolean hasAllowedBooleanType() { 
1163          return this != null && this.allowed instanceof BooleanType;
1164        }
1165
1166        /**
1167         * @return {@link #allowed} (True if the prescriber allows a different drug to be dispensed from what was prescribed.)
1168         */
1169        public CodeableConcept getAllowedCodeableConcept() throws FHIRException { 
1170          if (this.allowed == null)
1171            this.allowed = new CodeableConcept();
1172          if (!(this.allowed instanceof CodeableConcept))
1173            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.allowed.getClass().getName()+" was encountered");
1174          return (CodeableConcept) this.allowed;
1175        }
1176
1177        public boolean hasAllowedCodeableConcept() { 
1178          return this != null && this.allowed instanceof CodeableConcept;
1179        }
1180
1181        public boolean hasAllowed() { 
1182          return this.allowed != null && !this.allowed.isEmpty();
1183        }
1184
1185        /**
1186         * @param value {@link #allowed} (True if the prescriber allows a different drug to be dispensed from what was prescribed.)
1187         */
1188        public MedicationRequestSubstitutionComponent setAllowed(DataType value) { 
1189          if (value != null && !(value instanceof BooleanType || value instanceof CodeableConcept))
1190            throw new Error("Not the right type for MedicationRequest.substitution.allowed[x]: "+value.fhirType());
1191          this.allowed = value;
1192          return this;
1193        }
1194
1195        /**
1196         * @return {@link #reason} (Indicates the reason for the substitution, or why substitution must or must not be performed.)
1197         */
1198        public CodeableConcept getReason() { 
1199          if (this.reason == null)
1200            if (Configuration.errorOnAutoCreate())
1201              throw new Error("Attempt to auto-create MedicationRequestSubstitutionComponent.reason");
1202            else if (Configuration.doAutoCreate())
1203              this.reason = new CodeableConcept(); // cc
1204          return this.reason;
1205        }
1206
1207        public boolean hasReason() { 
1208          return this.reason != null && !this.reason.isEmpty();
1209        }
1210
1211        /**
1212         * @param value {@link #reason} (Indicates the reason for the substitution, or why substitution must or must not be performed.)
1213         */
1214        public MedicationRequestSubstitutionComponent setReason(CodeableConcept value) { 
1215          this.reason = value;
1216          return this;
1217        }
1218
1219        protected void listChildren(List<Property> children) {
1220          super.listChildren(children);
1221          children.add(new Property("allowed[x]", "boolean|CodeableConcept", "True if the prescriber allows a different drug to be dispensed from what was prescribed.", 0, 1, allowed));
1222          children.add(new Property("reason", "CodeableConcept", "Indicates the reason for the substitution, or why substitution must or must not be performed.", 0, 1, reason));
1223        }
1224
1225        @Override
1226        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1227          switch (_hash) {
1228          case -1336663592: /*allowed[x]*/  return new Property("allowed[x]", "boolean|CodeableConcept", "True if the prescriber allows a different drug to be dispensed from what was prescribed.", 0, 1, allowed);
1229          case -911343192: /*allowed*/  return new Property("allowed[x]", "boolean|CodeableConcept", "True if the prescriber allows a different drug to be dispensed from what was prescribed.", 0, 1, allowed);
1230          case 177755488: /*allowedBoolean*/  return new Property("allowed[x]", "boolean", "True if the prescriber allows a different drug to be dispensed from what was prescribed.", 0, 1, allowed);
1231          case 963125465: /*allowedCodeableConcept*/  return new Property("allowed[x]", "CodeableConcept", "True if the prescriber allows a different drug to be dispensed from what was prescribed.", 0, 1, allowed);
1232          case -934964668: /*reason*/  return new Property("reason", "CodeableConcept", "Indicates the reason for the substitution, or why substitution must or must not be performed.", 0, 1, reason);
1233          default: return super.getNamedProperty(_hash, _name, _checkValid);
1234          }
1235
1236        }
1237
1238      @Override
1239      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1240        switch (hash) {
1241        case -911343192: /*allowed*/ return this.allowed == null ? new Base[0] : new Base[] {this.allowed}; // DataType
1242        case -934964668: /*reason*/ return this.reason == null ? new Base[0] : new Base[] {this.reason}; // CodeableConcept
1243        default: return super.getProperty(hash, name, checkValid);
1244        }
1245
1246      }
1247
1248      @Override
1249      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1250        switch (hash) {
1251        case -911343192: // allowed
1252          this.allowed = TypeConvertor.castToType(value); // DataType
1253          return value;
1254        case -934964668: // reason
1255          this.reason = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1256          return value;
1257        default: return super.setProperty(hash, name, value);
1258        }
1259
1260      }
1261
1262      @Override
1263      public Base setProperty(String name, Base value) throws FHIRException {
1264        if (name.equals("allowed[x]")) {
1265          this.allowed = TypeConvertor.castToType(value); // DataType
1266        } else if (name.equals("reason")) {
1267          this.reason = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1268        } else
1269          return super.setProperty(name, value);
1270        return value;
1271      }
1272
1273      @Override
1274      public Base makeProperty(int hash, String name) throws FHIRException {
1275        switch (hash) {
1276        case -1336663592:  return getAllowed();
1277        case -911343192:  return getAllowed();
1278        case -934964668:  return getReason();
1279        default: return super.makeProperty(hash, name);
1280        }
1281
1282      }
1283
1284      @Override
1285      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1286        switch (hash) {
1287        case -911343192: /*allowed*/ return new String[] {"boolean", "CodeableConcept"};
1288        case -934964668: /*reason*/ return new String[] {"CodeableConcept"};
1289        default: return super.getTypesForProperty(hash, name);
1290        }
1291
1292      }
1293
1294      @Override
1295      public Base addChild(String name) throws FHIRException {
1296        if (name.equals("allowedBoolean")) {
1297          this.allowed = new BooleanType();
1298          return this.allowed;
1299        }
1300        else if (name.equals("allowedCodeableConcept")) {
1301          this.allowed = new CodeableConcept();
1302          return this.allowed;
1303        }
1304        else if (name.equals("reason")) {
1305          this.reason = new CodeableConcept();
1306          return this.reason;
1307        }
1308        else
1309          return super.addChild(name);
1310      }
1311
1312      public MedicationRequestSubstitutionComponent copy() {
1313        MedicationRequestSubstitutionComponent dst = new MedicationRequestSubstitutionComponent();
1314        copyValues(dst);
1315        return dst;
1316      }
1317
1318      public void copyValues(MedicationRequestSubstitutionComponent dst) {
1319        super.copyValues(dst);
1320        dst.allowed = allowed == null ? null : allowed.copy();
1321        dst.reason = reason == null ? null : reason.copy();
1322      }
1323
1324      @Override
1325      public boolean equalsDeep(Base other_) {
1326        if (!super.equalsDeep(other_))
1327          return false;
1328        if (!(other_ instanceof MedicationRequestSubstitutionComponent))
1329          return false;
1330        MedicationRequestSubstitutionComponent o = (MedicationRequestSubstitutionComponent) other_;
1331        return compareDeep(allowed, o.allowed, true) && compareDeep(reason, o.reason, true);
1332      }
1333
1334      @Override
1335      public boolean equalsShallow(Base other_) {
1336        if (!super.equalsShallow(other_))
1337          return false;
1338        if (!(other_ instanceof MedicationRequestSubstitutionComponent))
1339          return false;
1340        MedicationRequestSubstitutionComponent o = (MedicationRequestSubstitutionComponent) other_;
1341        return true;
1342      }
1343
1344      public boolean isEmpty() {
1345        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(allowed, reason);
1346      }
1347
1348  public String fhirType() {
1349    return "MedicationRequest.substitution";
1350
1351  }
1352
1353  }
1354
1355    /**
1356     * 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. They are business identifiers assigned to this resource by the performer or other systems and remain constant as the resource is updated and propagates from server to server.
1357     */
1358    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1359    @Description(shortDefinition="External ids for this request", formalDefinition="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. They are business identifiers assigned to this resource by the performer or other systems and remain constant as the resource is updated and propagates from server to server." )
1360    protected List<Identifier> identifier;
1361
1362    /**
1363     * A code specifying the current state of the order.  Generally, this will be active or completed state.
1364     */
1365    @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true)
1366    @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." )
1367    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medicationrequest-status")
1368    protected Enumeration<MedicationrequestStatus> status;
1369
1370    /**
1371     * Captures the reason for the current state of the MedicationRequest.
1372     */
1373    @Child(name = "statusReason", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
1374    @Description(shortDefinition="Reason for current status", formalDefinition="Captures the reason for the current state of the MedicationRequest." )
1375    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medicationrequest-status-reason")
1376    protected CodeableConcept statusReason;
1377
1378    /**
1379     * Whether the request is a proposal, plan, or an original order.
1380     */
1381    @Child(name = "intent", type = {CodeType.class}, order=3, min=1, max=1, modifier=true, summary=true)
1382    @Description(shortDefinition="proposal | plan | order | original-order | reflex-order | filler-order | instance-order | option", formalDefinition="Whether the request is a proposal, plan, or an original order." )
1383    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medicationrequest-intent")
1384    protected Enumeration<MedicationRequestIntent> intent;
1385
1386    /**
1387     * Indicates the grouping or category of medication request (for example, where the medication is expected to be consumed or administered (i.e. inpatient or outpatient)).
1388     */
1389    @Child(name = "category", type = {CodeableConcept.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1390    @Description(shortDefinition="Grouping or category of medication request", formalDefinition="Indicates the grouping or category of medication request (for example, where the medication is expected to be consumed or administered (i.e. inpatient or outpatient))." )
1391    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medicationrequest-category")
1392    protected List<CodeableConcept> category;
1393
1394    /**
1395     * Indicates how quickly the Medication Request should be addressed with respect to other requests.
1396     */
1397    @Child(name = "priority", type = {CodeType.class}, order=5, min=0, max=1, modifier=false, summary=true)
1398    @Description(shortDefinition="routine | urgent | asap | stat", formalDefinition="Indicates how quickly the Medication Request should be addressed with respect to other requests." )
1399    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/request-priority")
1400    protected Enumeration<RequestPriority> priority;
1401
1402    /**
1403     * If true indicates that the provider is asking for the medication request not to occur.
1404     */
1405    @Child(name = "doNotPerform", type = {BooleanType.class}, order=6, min=0, max=1, modifier=true, summary=true)
1406    @Description(shortDefinition="True if request is prohibiting action", formalDefinition="If true indicates that the provider is asking for the medication request not to occur." )
1407    protected BooleanType doNotPerform;
1408
1409    /**
1410     * Indicates if this record was captured as a secondary 'reported' record rather than as an original primary source-of-truth record.  It may also indicate the source of the report.
1411     */
1412    @Child(name = "reported", type = {BooleanType.class}, order=7, min=0, max=1, modifier=false, summary=true)
1413    @Description(shortDefinition="Reported rather than primary record", formalDefinition="Indicates if this record was captured as a secondary 'reported' record rather than as an original primary source-of-truth record.  It may also indicate the source of the report." )
1414    protected BooleanType reported;
1415
1416    /**
1417     * The person or organization who provided the information about this request, if the source is someone other than the requestor.  This is often used when the MedicationRequest is reported by another person.
1418     */
1419    @Child(name = "informationSource", type = {Patient.class, Practitioner.class, PractitionerRole.class, RelatedPerson.class, Organization.class}, order=8, min=0, max=1, modifier=false, summary=false)
1420    @Description(shortDefinition="The person or organization who provided the information about this request, if the source is someone other than the requestor", formalDefinition="The person or organization who provided the information about this request, if the source is someone other than the requestor.  This is often used when the MedicationRequest is reported by another person." )
1421    protected Reference informationSource;
1422
1423    /**
1424     * 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.
1425     */
1426    @Child(name = "medication", type = {CodeableConcept.class, Medication.class}, order=9, min=1, max=1, modifier=false, summary=true)
1427    @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." )
1428    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-codes")
1429    protected DataType medication;
1430
1431    /**
1432     * A link to a resource representing the person or set of individuals to whom the medication will be given.
1433     */
1434    @Child(name = "subject", type = {Patient.class, Group.class}, order=10, min=1, max=1, modifier=false, summary=true)
1435    @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." )
1436    protected Reference subject;
1437
1438    /**
1439     * The Encounter during which this [x] was created or to which the creation of this record is tightly associated.
1440     */
1441    @Child(name = "encounter", type = {Encounter.class}, order=11, min=0, max=1, modifier=false, summary=false)
1442    @Description(shortDefinition="Encounter created as part of encounter/admission/stay", formalDefinition="The Encounter during which this [x] was created or to which the creation of this record is tightly associated." )
1443    protected Reference encounter;
1444
1445    /**
1446     * Include additional information (for example, patient height and weight, a MedicationUsage for the patient) that supports the ordering of the medication.
1447     */
1448    @Child(name = "supportingInformation", type = {Reference.class}, order=12, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1449    @Description(shortDefinition="Information to support ordering of the medication", formalDefinition="Include additional information (for example, patient height and weight, a MedicationUsage for the patient) that supports the ordering of the medication." )
1450    protected List<Reference> supportingInformation;
1451
1452    /**
1453     * The date (and perhaps time) when the prescription was initially written or authored on.
1454     */
1455    @Child(name = "authoredOn", type = {DateTimeType.class}, order=13, min=0, max=1, modifier=false, summary=true)
1456    @Description(shortDefinition="When request was initially authored", formalDefinition="The date (and perhaps time) when the prescription was initially written or authored on." )
1457    protected DateTimeType authoredOn;
1458
1459    /**
1460     * The individual, organization, or device that initiated the request and has responsibility for its activation.
1461     */
1462    @Child(name = "requester", type = {Practitioner.class, PractitionerRole.class, Organization.class, Patient.class, RelatedPerson.class, Device.class}, order=14, min=0, max=1, modifier=false, summary=true)
1463    @Description(shortDefinition="Who/What requested the Request", formalDefinition="The individual, organization, or device that initiated the request and has responsibility for its activation." )
1464    protected Reference requester;
1465
1466    /**
1467     * The specified desired performer of the medication treatment (e.g. the performer of the medication administration).
1468     */
1469    @Child(name = "performer", type = {Practitioner.class, PractitionerRole.class, Organization.class, Patient.class, Device.class, RelatedPerson.class, CareTeam.class, HealthcareService.class}, order=15, min=0, max=1, modifier=false, summary=false)
1470    @Description(shortDefinition="Intended performer of administration", formalDefinition="The specified desired performer of the medication treatment (e.g. the performer of the medication administration)." )
1471    protected Reference performer;
1472
1473    /**
1474     * Indicates the type of performer of the administration of the medication.
1475     */
1476    @Child(name = "performerType", type = {CodeableConcept.class}, order=16, min=0, max=1, modifier=false, summary=true)
1477    @Description(shortDefinition="Desired kind of performer of the medication administration", formalDefinition="Indicates the type of performer of the administration of the medication." )
1478    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/performer-role")
1479    protected CodeableConcept performerType;
1480
1481    /**
1482     * The person who entered the order on behalf of another individual for example in the case of a verbal or a telephone order.
1483     */
1484    @Child(name = "recorder", type = {Practitioner.class, PractitionerRole.class}, order=17, min=0, max=1, modifier=false, summary=false)
1485    @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." )
1486    protected Reference recorder;
1487
1488    /**
1489     * The reason or the indication for ordering or not ordering the medication.
1490     */
1491    @Child(name = "reason", type = {CodeableReference.class}, order=18, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1492    @Description(shortDefinition="Reason or indication for ordering or not ordering the medication", formalDefinition="The reason or the indication for ordering or not ordering the medication." )
1493    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/condition-code")
1494    protected List<CodeableReference> reason;
1495
1496    /**
1497     * The URL pointing to a protocol, guideline, orderset, or other definition that is adhered to in whole or in part by this MedicationRequest.
1498     */
1499    @Child(name = "instantiatesCanonical", type = {CanonicalType.class}, order=19, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1500    @Description(shortDefinition="Instantiates FHIR protocol or definition", formalDefinition="The URL pointing to a protocol, guideline, orderset, or other definition that is adhered to in whole or in part by this MedicationRequest." )
1501    protected List<CanonicalType> instantiatesCanonical;
1502
1503    /**
1504     * The URL pointing to an externally maintained protocol, guideline, orderset or other definition that is adhered to in whole or in part by this MedicationRequest.
1505     */
1506    @Child(name = "instantiatesUri", type = {UriType.class}, order=20, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1507    @Description(shortDefinition="Instantiates external protocol or definition", formalDefinition="The URL pointing to an externally maintained protocol, guideline, orderset or other definition that is adhered to in whole or in part by this MedicationRequest." )
1508    protected List<UriType> instantiatesUri;
1509
1510    /**
1511     * A plan or request that is fulfilled in whole or in part by this medication request.
1512     */
1513    @Child(name = "basedOn", type = {CarePlan.class, MedicationRequest.class, ServiceRequest.class, ImmunizationRecommendation.class}, order=21, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1514    @Description(shortDefinition="What request fulfills", formalDefinition="A plan or request that is fulfilled in whole or in part by this medication request." )
1515    protected List<Reference> basedOn;
1516
1517    /**
1518     * 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.
1519     */
1520    @Child(name = "groupIdentifier", type = {Identifier.class}, order=22, min=0, max=1, modifier=false, summary=true)
1521    @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." )
1522    protected Identifier groupIdentifier;
1523
1524    /**
1525     * The description of the overall pattern of the administration of the medication to the patient.
1526     */
1527    @Child(name = "courseOfTherapyType", type = {CodeableConcept.class}, order=23, min=0, max=1, modifier=false, summary=false)
1528    @Description(shortDefinition="Overall pattern of medication administration", formalDefinition="The description of the overall pattern of the administration of the medication to the patient." )
1529    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medicationrequest-course-of-therapy")
1530    protected CodeableConcept courseOfTherapyType;
1531
1532    /**
1533     * Insurance plans, coverage extensions, pre-authorizations and/or pre-determinations that may be required for delivering the requested service.
1534     */
1535    @Child(name = "insurance", type = {Coverage.class, ClaimResponse.class}, order=24, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1536    @Description(shortDefinition="Associated insurance coverage", formalDefinition="Insurance plans, coverage extensions, pre-authorizations and/or pre-determinations that may be required for delivering the requested service." )
1537    protected List<Reference> insurance;
1538
1539    /**
1540     * Extra information about the prescription that could not be conveyed by the other attributes.
1541     */
1542    @Child(name = "note", type = {Annotation.class}, order=25, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1543    @Description(shortDefinition="Information about the prescription", formalDefinition="Extra information about the prescription that could not be conveyed by the other attributes." )
1544    protected List<Annotation> note;
1545
1546    /**
1547     * The full representation of the dose of the medication included in all dosage instructions.  To be used when multiple dosage instructions are included to represent complex dosing such as increasing or tapering doses.
1548     */
1549    @Child(name = "renderedDosageInstruction", type = {StringType.class}, order=26, min=0, max=1, modifier=false, summary=false)
1550    @Description(shortDefinition="Full representation of the dosage instructions", formalDefinition="The full representation of the dose of the medication included in all dosage instructions.  To be used when multiple dosage instructions are included to represent complex dosing such as increasing or tapering doses." )
1551    protected StringType renderedDosageInstruction;
1552
1553    /**
1554     * Indicates how the medication is to be used by the patient.
1555     */
1556    @Child(name = "dosageInstruction", type = {Dosage.class}, order=27, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1557    @Description(shortDefinition="How the medication should be taken", formalDefinition="Indicates how the medication is to be used by the patient." )
1558    protected List<Dosage> dosageInstruction;
1559
1560    /**
1561     * 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.
1562     */
1563    @Child(name = "dispenseRequest", type = {}, order=28, min=0, max=1, modifier=false, summary=false)
1564    @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." )
1565    protected MedicationRequestDispenseRequestComponent dispenseRequest;
1566
1567    /**
1568     * 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.
1569     */
1570    @Child(name = "substitution", type = {}, order=29, min=0, max=1, modifier=false, summary=false)
1571    @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." )
1572    protected MedicationRequestSubstitutionComponent substitution;
1573
1574    /**
1575     * A link to a resource representing an earlier order related order or prescription.
1576     */
1577    @Child(name = "priorPrescription", type = {MedicationRequest.class}, order=30, min=0, max=1, modifier=false, summary=false)
1578    @Description(shortDefinition="An order/prescription that is being replaced", formalDefinition="A link to a resource representing an earlier order related order or prescription." )
1579    protected Reference priorPrescription;
1580
1581    /**
1582     * 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.
1583     */
1584    @Child(name = "detectedIssue", type = {DetectedIssue.class}, order=31, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1585    @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." )
1586    protected List<Reference> detectedIssue;
1587
1588    /**
1589     * 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.
1590     */
1591    @Child(name = "eventHistory", type = {Provenance.class}, order=32, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1592    @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." )
1593    protected List<Reference> eventHistory;
1594
1595    private static final long serialVersionUID = 1089528447L;
1596
1597  /**
1598   * Constructor
1599   */
1600    public MedicationRequest() {
1601      super();
1602    }
1603
1604  /**
1605   * Constructor
1606   */
1607    public MedicationRequest(MedicationrequestStatus status, MedicationRequestIntent intent, DataType medication, Reference subject) {
1608      super();
1609      this.setStatus(status);
1610      this.setIntent(intent);
1611      this.setMedication(medication);
1612      this.setSubject(subject);
1613    }
1614
1615    /**
1616     * @return {@link #identifier} (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. They are business identifiers assigned to this resource by the performer or other systems and remain constant as the resource is updated and propagates from server to server.)
1617     */
1618    public List<Identifier> getIdentifier() { 
1619      if (this.identifier == null)
1620        this.identifier = new ArrayList<Identifier>();
1621      return this.identifier;
1622    }
1623
1624    /**
1625     * @return Returns a reference to <code>this</code> for easy method chaining
1626     */
1627    public MedicationRequest setIdentifier(List<Identifier> theIdentifier) { 
1628      this.identifier = theIdentifier;
1629      return this;
1630    }
1631
1632    public boolean hasIdentifier() { 
1633      if (this.identifier == null)
1634        return false;
1635      for (Identifier item : this.identifier)
1636        if (!item.isEmpty())
1637          return true;
1638      return false;
1639    }
1640
1641    public Identifier addIdentifier() { //3
1642      Identifier t = new Identifier();
1643      if (this.identifier == null)
1644        this.identifier = new ArrayList<Identifier>();
1645      this.identifier.add(t);
1646      return t;
1647    }
1648
1649    public MedicationRequest addIdentifier(Identifier t) { //3
1650      if (t == null)
1651        return this;
1652      if (this.identifier == null)
1653        this.identifier = new ArrayList<Identifier>();
1654      this.identifier.add(t);
1655      return this;
1656    }
1657
1658    /**
1659     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist {3}
1660     */
1661    public Identifier getIdentifierFirstRep() { 
1662      if (getIdentifier().isEmpty()) {
1663        addIdentifier();
1664      }
1665      return getIdentifier().get(0);
1666    }
1667
1668    /**
1669     * @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
1670     */
1671    public Enumeration<MedicationrequestStatus> getStatusElement() { 
1672      if (this.status == null)
1673        if (Configuration.errorOnAutoCreate())
1674          throw new Error("Attempt to auto-create MedicationRequest.status");
1675        else if (Configuration.doAutoCreate())
1676          this.status = new Enumeration<MedicationrequestStatus>(new MedicationrequestStatusEnumFactory()); // bb
1677      return this.status;
1678    }
1679
1680    public boolean hasStatusElement() { 
1681      return this.status != null && !this.status.isEmpty();
1682    }
1683
1684    public boolean hasStatus() { 
1685      return this.status != null && !this.status.isEmpty();
1686    }
1687
1688    /**
1689     * @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
1690     */
1691    public MedicationRequest setStatusElement(Enumeration<MedicationrequestStatus> value) { 
1692      this.status = value;
1693      return this;
1694    }
1695
1696    /**
1697     * @return A code specifying the current state of the order.  Generally, this will be active or completed state.
1698     */
1699    public MedicationrequestStatus getStatus() { 
1700      return this.status == null ? null : this.status.getValue();
1701    }
1702
1703    /**
1704     * @param value A code specifying the current state of the order.  Generally, this will be active or completed state.
1705     */
1706    public MedicationRequest setStatus(MedicationrequestStatus value) { 
1707        if (this.status == null)
1708          this.status = new Enumeration<MedicationrequestStatus>(new MedicationrequestStatusEnumFactory());
1709        this.status.setValue(value);
1710      return this;
1711    }
1712
1713    /**
1714     * @return {@link #statusReason} (Captures the reason for the current state of the MedicationRequest.)
1715     */
1716    public CodeableConcept getStatusReason() { 
1717      if (this.statusReason == null)
1718        if (Configuration.errorOnAutoCreate())
1719          throw new Error("Attempt to auto-create MedicationRequest.statusReason");
1720        else if (Configuration.doAutoCreate())
1721          this.statusReason = new CodeableConcept(); // cc
1722      return this.statusReason;
1723    }
1724
1725    public boolean hasStatusReason() { 
1726      return this.statusReason != null && !this.statusReason.isEmpty();
1727    }
1728
1729    /**
1730     * @param value {@link #statusReason} (Captures the reason for the current state of the MedicationRequest.)
1731     */
1732    public MedicationRequest setStatusReason(CodeableConcept value) { 
1733      this.statusReason = value;
1734      return this;
1735    }
1736
1737    /**
1738     * @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
1739     */
1740    public Enumeration<MedicationRequestIntent> getIntentElement() { 
1741      if (this.intent == null)
1742        if (Configuration.errorOnAutoCreate())
1743          throw new Error("Attempt to auto-create MedicationRequest.intent");
1744        else if (Configuration.doAutoCreate())
1745          this.intent = new Enumeration<MedicationRequestIntent>(new MedicationRequestIntentEnumFactory()); // bb
1746      return this.intent;
1747    }
1748
1749    public boolean hasIntentElement() { 
1750      return this.intent != null && !this.intent.isEmpty();
1751    }
1752
1753    public boolean hasIntent() { 
1754      return this.intent != null && !this.intent.isEmpty();
1755    }
1756
1757    /**
1758     * @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
1759     */
1760    public MedicationRequest setIntentElement(Enumeration<MedicationRequestIntent> value) { 
1761      this.intent = value;
1762      return this;
1763    }
1764
1765    /**
1766     * @return Whether the request is a proposal, plan, or an original order.
1767     */
1768    public MedicationRequestIntent getIntent() { 
1769      return this.intent == null ? null : this.intent.getValue();
1770    }
1771
1772    /**
1773     * @param value Whether the request is a proposal, plan, or an original order.
1774     */
1775    public MedicationRequest setIntent(MedicationRequestIntent value) { 
1776        if (this.intent == null)
1777          this.intent = new Enumeration<MedicationRequestIntent>(new MedicationRequestIntentEnumFactory());
1778        this.intent.setValue(value);
1779      return this;
1780    }
1781
1782    /**
1783     * @return {@link #category} (Indicates the grouping or category of medication request (for example, where the medication is expected to be consumed or administered (i.e. inpatient or outpatient)).)
1784     */
1785    public List<CodeableConcept> getCategory() { 
1786      if (this.category == null)
1787        this.category = new ArrayList<CodeableConcept>();
1788      return this.category;
1789    }
1790
1791    /**
1792     * @return Returns a reference to <code>this</code> for easy method chaining
1793     */
1794    public MedicationRequest setCategory(List<CodeableConcept> theCategory) { 
1795      this.category = theCategory;
1796      return this;
1797    }
1798
1799    public boolean hasCategory() { 
1800      if (this.category == null)
1801        return false;
1802      for (CodeableConcept item : this.category)
1803        if (!item.isEmpty())
1804          return true;
1805      return false;
1806    }
1807
1808    public CodeableConcept addCategory() { //3
1809      CodeableConcept t = new CodeableConcept();
1810      if (this.category == null)
1811        this.category = new ArrayList<CodeableConcept>();
1812      this.category.add(t);
1813      return t;
1814    }
1815
1816    public MedicationRequest addCategory(CodeableConcept t) { //3
1817      if (t == null)
1818        return this;
1819      if (this.category == null)
1820        this.category = new ArrayList<CodeableConcept>();
1821      this.category.add(t);
1822      return this;
1823    }
1824
1825    /**
1826     * @return The first repetition of repeating field {@link #category}, creating it if it does not already exist {3}
1827     */
1828    public CodeableConcept getCategoryFirstRep() { 
1829      if (getCategory().isEmpty()) {
1830        addCategory();
1831      }
1832      return getCategory().get(0);
1833    }
1834
1835    /**
1836     * @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
1837     */
1838    public Enumeration<RequestPriority> getPriorityElement() { 
1839      if (this.priority == null)
1840        if (Configuration.errorOnAutoCreate())
1841          throw new Error("Attempt to auto-create MedicationRequest.priority");
1842        else if (Configuration.doAutoCreate())
1843          this.priority = new Enumeration<RequestPriority>(new RequestPriorityEnumFactory()); // bb
1844      return this.priority;
1845    }
1846
1847    public boolean hasPriorityElement() { 
1848      return this.priority != null && !this.priority.isEmpty();
1849    }
1850
1851    public boolean hasPriority() { 
1852      return this.priority != null && !this.priority.isEmpty();
1853    }
1854
1855    /**
1856     * @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
1857     */
1858    public MedicationRequest setPriorityElement(Enumeration<RequestPriority> value) { 
1859      this.priority = value;
1860      return this;
1861    }
1862
1863    /**
1864     * @return Indicates how quickly the Medication Request should be addressed with respect to other requests.
1865     */
1866    public RequestPriority getPriority() { 
1867      return this.priority == null ? null : this.priority.getValue();
1868    }
1869
1870    /**
1871     * @param value Indicates how quickly the Medication Request should be addressed with respect to other requests.
1872     */
1873    public MedicationRequest setPriority(RequestPriority value) { 
1874      if (value == null)
1875        this.priority = null;
1876      else {
1877        if (this.priority == null)
1878          this.priority = new Enumeration<RequestPriority>(new RequestPriorityEnumFactory());
1879        this.priority.setValue(value);
1880      }
1881      return this;
1882    }
1883
1884    /**
1885     * @return {@link #doNotPerform} (If true indicates that the provider is asking for the medication request not to occur.). This is the underlying object with id, value and extensions. The accessor "getDoNotPerform" gives direct access to the value
1886     */
1887    public BooleanType getDoNotPerformElement() { 
1888      if (this.doNotPerform == null)
1889        if (Configuration.errorOnAutoCreate())
1890          throw new Error("Attempt to auto-create MedicationRequest.doNotPerform");
1891        else if (Configuration.doAutoCreate())
1892          this.doNotPerform = new BooleanType(); // bb
1893      return this.doNotPerform;
1894    }
1895
1896    public boolean hasDoNotPerformElement() { 
1897      return this.doNotPerform != null && !this.doNotPerform.isEmpty();
1898    }
1899
1900    public boolean hasDoNotPerform() { 
1901      return this.doNotPerform != null && !this.doNotPerform.isEmpty();
1902    }
1903
1904    /**
1905     * @param value {@link #doNotPerform} (If true indicates that the provider is asking for the medication request not to occur.). This is the underlying object with id, value and extensions. The accessor "getDoNotPerform" gives direct access to the value
1906     */
1907    public MedicationRequest setDoNotPerformElement(BooleanType value) { 
1908      this.doNotPerform = value;
1909      return this;
1910    }
1911
1912    /**
1913     * @return If true indicates that the provider is asking for the medication request not to occur.
1914     */
1915    public boolean getDoNotPerform() { 
1916      return this.doNotPerform == null || this.doNotPerform.isEmpty() ? false : this.doNotPerform.getValue();
1917    }
1918
1919    /**
1920     * @param value If true indicates that the provider is asking for the medication request not to occur.
1921     */
1922    public MedicationRequest setDoNotPerform(boolean value) { 
1923        if (this.doNotPerform == null)
1924          this.doNotPerform = new BooleanType();
1925        this.doNotPerform.setValue(value);
1926      return this;
1927    }
1928
1929    /**
1930     * @return {@link #reported} (Indicates if this record was captured as a secondary 'reported' record rather than as an original primary source-of-truth record.  It may also indicate the source of the report.). This is the underlying object with id, value and extensions. The accessor "getReported" gives direct access to the value
1931     */
1932    public BooleanType getReportedElement() { 
1933      if (this.reported == null)
1934        if (Configuration.errorOnAutoCreate())
1935          throw new Error("Attempt to auto-create MedicationRequest.reported");
1936        else if (Configuration.doAutoCreate())
1937          this.reported = new BooleanType(); // bb
1938      return this.reported;
1939    }
1940
1941    public boolean hasReportedElement() { 
1942      return this.reported != null && !this.reported.isEmpty();
1943    }
1944
1945    public boolean hasReported() { 
1946      return this.reported != null && !this.reported.isEmpty();
1947    }
1948
1949    /**
1950     * @param value {@link #reported} (Indicates if this record was captured as a secondary 'reported' record rather than as an original primary source-of-truth record.  It may also indicate the source of the report.). This is the underlying object with id, value and extensions. The accessor "getReported" gives direct access to the value
1951     */
1952    public MedicationRequest setReportedElement(BooleanType value) { 
1953      this.reported = value;
1954      return this;
1955    }
1956
1957    /**
1958     * @return Indicates if this record was captured as a secondary 'reported' record rather than as an original primary source-of-truth record.  It may also indicate the source of the report.
1959     */
1960    public boolean getReported() { 
1961      return this.reported == null || this.reported.isEmpty() ? false : this.reported.getValue();
1962    }
1963
1964    /**
1965     * @param value Indicates if this record was captured as a secondary 'reported' record rather than as an original primary source-of-truth record.  It may also indicate the source of the report.
1966     */
1967    public MedicationRequest setReported(boolean value) { 
1968        if (this.reported == null)
1969          this.reported = new BooleanType();
1970        this.reported.setValue(value);
1971      return this;
1972    }
1973
1974    /**
1975     * @return {@link #informationSource} (The person or organization who provided the information about this request, if the source is someone other than the requestor.  This is often used when the MedicationRequest is reported by another person.)
1976     */
1977    public Reference getInformationSource() { 
1978      if (this.informationSource == null)
1979        if (Configuration.errorOnAutoCreate())
1980          throw new Error("Attempt to auto-create MedicationRequest.informationSource");
1981        else if (Configuration.doAutoCreate())
1982          this.informationSource = new Reference(); // cc
1983      return this.informationSource;
1984    }
1985
1986    public boolean hasInformationSource() { 
1987      return this.informationSource != null && !this.informationSource.isEmpty();
1988    }
1989
1990    /**
1991     * @param value {@link #informationSource} (The person or organization who provided the information about this request, if the source is someone other than the requestor.  This is often used when the MedicationRequest is reported by another person.)
1992     */
1993    public MedicationRequest setInformationSource(Reference value) { 
1994      this.informationSource = value;
1995      return this;
1996    }
1997
1998    /**
1999     * @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.)
2000     */
2001    public DataType getMedication() { 
2002      return this.medication;
2003    }
2004
2005    /**
2006     * @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.)
2007     */
2008    public CodeableConcept getMedicationCodeableConcept() throws FHIRException { 
2009      if (this.medication == null)
2010        this.medication = new CodeableConcept();
2011      if (!(this.medication instanceof CodeableConcept))
2012        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.medication.getClass().getName()+" was encountered");
2013      return (CodeableConcept) this.medication;
2014    }
2015
2016    public boolean hasMedicationCodeableConcept() { 
2017      return this != null && this.medication instanceof CodeableConcept;
2018    }
2019
2020    /**
2021     * @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.)
2022     */
2023    public Reference getMedicationReference() throws FHIRException { 
2024      if (this.medication == null)
2025        this.medication = new Reference();
2026      if (!(this.medication instanceof Reference))
2027        throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.medication.getClass().getName()+" was encountered");
2028      return (Reference) this.medication;
2029    }
2030
2031    public boolean hasMedicationReference() { 
2032      return this != null && this.medication instanceof Reference;
2033    }
2034
2035    public boolean hasMedication() { 
2036      return this.medication != null && !this.medication.isEmpty();
2037    }
2038
2039    /**
2040     * @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.)
2041     */
2042    public MedicationRequest setMedication(DataType value) { 
2043      if (value != null && !(value instanceof CodeableConcept || value instanceof Reference))
2044        throw new Error("Not the right type for MedicationRequest.medication[x]: "+value.fhirType());
2045      this.medication = value;
2046      return this;
2047    }
2048
2049    /**
2050     * @return {@link #subject} (A link to a resource representing the person or set of individuals to whom the medication will be given.)
2051     */
2052    public Reference getSubject() { 
2053      if (this.subject == null)
2054        if (Configuration.errorOnAutoCreate())
2055          throw new Error("Attempt to auto-create MedicationRequest.subject");
2056        else if (Configuration.doAutoCreate())
2057          this.subject = new Reference(); // cc
2058      return this.subject;
2059    }
2060
2061    public boolean hasSubject() { 
2062      return this.subject != null && !this.subject.isEmpty();
2063    }
2064
2065    /**
2066     * @param value {@link #subject} (A link to a resource representing the person or set of individuals to whom the medication will be given.)
2067     */
2068    public MedicationRequest setSubject(Reference value) { 
2069      this.subject = value;
2070      return this;
2071    }
2072
2073    /**
2074     * @return {@link #encounter} (The Encounter during which this [x] was created or to which the creation of this record is tightly associated.)
2075     */
2076    public Reference getEncounter() { 
2077      if (this.encounter == null)
2078        if (Configuration.errorOnAutoCreate())
2079          throw new Error("Attempt to auto-create MedicationRequest.encounter");
2080        else if (Configuration.doAutoCreate())
2081          this.encounter = new Reference(); // cc
2082      return this.encounter;
2083    }
2084
2085    public boolean hasEncounter() { 
2086      return this.encounter != null && !this.encounter.isEmpty();
2087    }
2088
2089    /**
2090     * @param value {@link #encounter} (The Encounter during which this [x] was created or to which the creation of this record is tightly associated.)
2091     */
2092    public MedicationRequest setEncounter(Reference value) { 
2093      this.encounter = value;
2094      return this;
2095    }
2096
2097    /**
2098     * @return {@link #supportingInformation} (Include additional information (for example, patient height and weight, a MedicationUsage for the patient) that supports the ordering of the medication.)
2099     */
2100    public List<Reference> getSupportingInformation() { 
2101      if (this.supportingInformation == null)
2102        this.supportingInformation = new ArrayList<Reference>();
2103      return this.supportingInformation;
2104    }
2105
2106    /**
2107     * @return Returns a reference to <code>this</code> for easy method chaining
2108     */
2109    public MedicationRequest setSupportingInformation(List<Reference> theSupportingInformation) { 
2110      this.supportingInformation = theSupportingInformation;
2111      return this;
2112    }
2113
2114    public boolean hasSupportingInformation() { 
2115      if (this.supportingInformation == null)
2116        return false;
2117      for (Reference item : this.supportingInformation)
2118        if (!item.isEmpty())
2119          return true;
2120      return false;
2121    }
2122
2123    public Reference addSupportingInformation() { //3
2124      Reference t = new Reference();
2125      if (this.supportingInformation == null)
2126        this.supportingInformation = new ArrayList<Reference>();
2127      this.supportingInformation.add(t);
2128      return t;
2129    }
2130
2131    public MedicationRequest addSupportingInformation(Reference t) { //3
2132      if (t == null)
2133        return this;
2134      if (this.supportingInformation == null)
2135        this.supportingInformation = new ArrayList<Reference>();
2136      this.supportingInformation.add(t);
2137      return this;
2138    }
2139
2140    /**
2141     * @return The first repetition of repeating field {@link #supportingInformation}, creating it if it does not already exist {3}
2142     */
2143    public Reference getSupportingInformationFirstRep() { 
2144      if (getSupportingInformation().isEmpty()) {
2145        addSupportingInformation();
2146      }
2147      return getSupportingInformation().get(0);
2148    }
2149
2150    /**
2151     * @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
2152     */
2153    public DateTimeType getAuthoredOnElement() { 
2154      if (this.authoredOn == null)
2155        if (Configuration.errorOnAutoCreate())
2156          throw new Error("Attempt to auto-create MedicationRequest.authoredOn");
2157        else if (Configuration.doAutoCreate())
2158          this.authoredOn = new DateTimeType(); // bb
2159      return this.authoredOn;
2160    }
2161
2162    public boolean hasAuthoredOnElement() { 
2163      return this.authoredOn != null && !this.authoredOn.isEmpty();
2164    }
2165
2166    public boolean hasAuthoredOn() { 
2167      return this.authoredOn != null && !this.authoredOn.isEmpty();
2168    }
2169
2170    /**
2171     * @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
2172     */
2173    public MedicationRequest setAuthoredOnElement(DateTimeType value) { 
2174      this.authoredOn = value;
2175      return this;
2176    }
2177
2178    /**
2179     * @return The date (and perhaps time) when the prescription was initially written or authored on.
2180     */
2181    public Date getAuthoredOn() { 
2182      return this.authoredOn == null ? null : this.authoredOn.getValue();
2183    }
2184
2185    /**
2186     * @param value The date (and perhaps time) when the prescription was initially written or authored on.
2187     */
2188    public MedicationRequest setAuthoredOn(Date value) { 
2189      if (value == null)
2190        this.authoredOn = null;
2191      else {
2192        if (this.authoredOn == null)
2193          this.authoredOn = new DateTimeType();
2194        this.authoredOn.setValue(value);
2195      }
2196      return this;
2197    }
2198
2199    /**
2200     * @return {@link #requester} (The individual, organization, or device that initiated the request and has responsibility for its activation.)
2201     */
2202    public Reference getRequester() { 
2203      if (this.requester == null)
2204        if (Configuration.errorOnAutoCreate())
2205          throw new Error("Attempt to auto-create MedicationRequest.requester");
2206        else if (Configuration.doAutoCreate())
2207          this.requester = new Reference(); // cc
2208      return this.requester;
2209    }
2210
2211    public boolean hasRequester() { 
2212      return this.requester != null && !this.requester.isEmpty();
2213    }
2214
2215    /**
2216     * @param value {@link #requester} (The individual, organization, or device that initiated the request and has responsibility for its activation.)
2217     */
2218    public MedicationRequest setRequester(Reference value) { 
2219      this.requester = value;
2220      return this;
2221    }
2222
2223    /**
2224     * @return {@link #performer} (The specified desired performer of the medication treatment (e.g. the performer of the medication administration).)
2225     */
2226    public Reference getPerformer() { 
2227      if (this.performer == null)
2228        if (Configuration.errorOnAutoCreate())
2229          throw new Error("Attempt to auto-create MedicationRequest.performer");
2230        else if (Configuration.doAutoCreate())
2231          this.performer = new Reference(); // cc
2232      return this.performer;
2233    }
2234
2235    public boolean hasPerformer() { 
2236      return this.performer != null && !this.performer.isEmpty();
2237    }
2238
2239    /**
2240     * @param value {@link #performer} (The specified desired performer of the medication treatment (e.g. the performer of the medication administration).)
2241     */
2242    public MedicationRequest setPerformer(Reference value) { 
2243      this.performer = value;
2244      return this;
2245    }
2246
2247    /**
2248     * @return {@link #performerType} (Indicates the type of performer of the administration of the medication.)
2249     */
2250    public CodeableConcept getPerformerType() { 
2251      if (this.performerType == null)
2252        if (Configuration.errorOnAutoCreate())
2253          throw new Error("Attempt to auto-create MedicationRequest.performerType");
2254        else if (Configuration.doAutoCreate())
2255          this.performerType = new CodeableConcept(); // cc
2256      return this.performerType;
2257    }
2258
2259    public boolean hasPerformerType() { 
2260      return this.performerType != null && !this.performerType.isEmpty();
2261    }
2262
2263    /**
2264     * @param value {@link #performerType} (Indicates the type of performer of the administration of the medication.)
2265     */
2266    public MedicationRequest setPerformerType(CodeableConcept value) { 
2267      this.performerType = value;
2268      return this;
2269    }
2270
2271    /**
2272     * @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.)
2273     */
2274    public Reference getRecorder() { 
2275      if (this.recorder == null)
2276        if (Configuration.errorOnAutoCreate())
2277          throw new Error("Attempt to auto-create MedicationRequest.recorder");
2278        else if (Configuration.doAutoCreate())
2279          this.recorder = new Reference(); // cc
2280      return this.recorder;
2281    }
2282
2283    public boolean hasRecorder() { 
2284      return this.recorder != null && !this.recorder.isEmpty();
2285    }
2286
2287    /**
2288     * @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.)
2289     */
2290    public MedicationRequest setRecorder(Reference value) { 
2291      this.recorder = value;
2292      return this;
2293    }
2294
2295    /**
2296     * @return {@link #reason} (The reason or the indication for ordering or not ordering the medication.)
2297     */
2298    public List<CodeableReference> getReason() { 
2299      if (this.reason == null)
2300        this.reason = new ArrayList<CodeableReference>();
2301      return this.reason;
2302    }
2303
2304    /**
2305     * @return Returns a reference to <code>this</code> for easy method chaining
2306     */
2307    public MedicationRequest setReason(List<CodeableReference> theReason) { 
2308      this.reason = theReason;
2309      return this;
2310    }
2311
2312    public boolean hasReason() { 
2313      if (this.reason == null)
2314        return false;
2315      for (CodeableReference item : this.reason)
2316        if (!item.isEmpty())
2317          return true;
2318      return false;
2319    }
2320
2321    public CodeableReference addReason() { //3
2322      CodeableReference t = new CodeableReference();
2323      if (this.reason == null)
2324        this.reason = new ArrayList<CodeableReference>();
2325      this.reason.add(t);
2326      return t;
2327    }
2328
2329    public MedicationRequest addReason(CodeableReference t) { //3
2330      if (t == null)
2331        return this;
2332      if (this.reason == null)
2333        this.reason = new ArrayList<CodeableReference>();
2334      this.reason.add(t);
2335      return this;
2336    }
2337
2338    /**
2339     * @return The first repetition of repeating field {@link #reason}, creating it if it does not already exist {3}
2340     */
2341    public CodeableReference getReasonFirstRep() { 
2342      if (getReason().isEmpty()) {
2343        addReason();
2344      }
2345      return getReason().get(0);
2346    }
2347
2348    /**
2349     * @return {@link #instantiatesCanonical} (The URL pointing to a protocol, guideline, orderset, or other definition that is adhered to in whole or in part by this MedicationRequest.)
2350     */
2351    public List<CanonicalType> getInstantiatesCanonical() { 
2352      if (this.instantiatesCanonical == null)
2353        this.instantiatesCanonical = new ArrayList<CanonicalType>();
2354      return this.instantiatesCanonical;
2355    }
2356
2357    /**
2358     * @return Returns a reference to <code>this</code> for easy method chaining
2359     */
2360    public MedicationRequest setInstantiatesCanonical(List<CanonicalType> theInstantiatesCanonical) { 
2361      this.instantiatesCanonical = theInstantiatesCanonical;
2362      return this;
2363    }
2364
2365    public boolean hasInstantiatesCanonical() { 
2366      if (this.instantiatesCanonical == null)
2367        return false;
2368      for (CanonicalType item : this.instantiatesCanonical)
2369        if (!item.isEmpty())
2370          return true;
2371      return false;
2372    }
2373
2374    /**
2375     * @return {@link #instantiatesCanonical} (The URL pointing to a protocol, guideline, orderset, or other definition that is adhered to in whole or in part by this MedicationRequest.)
2376     */
2377    public CanonicalType addInstantiatesCanonicalElement() {//2 
2378      CanonicalType t = new CanonicalType();
2379      if (this.instantiatesCanonical == null)
2380        this.instantiatesCanonical = new ArrayList<CanonicalType>();
2381      this.instantiatesCanonical.add(t);
2382      return t;
2383    }
2384
2385    /**
2386     * @param value {@link #instantiatesCanonical} (The URL pointing to a protocol, guideline, orderset, or other definition that is adhered to in whole or in part by this MedicationRequest.)
2387     */
2388    public MedicationRequest addInstantiatesCanonical(String value) { //1
2389      CanonicalType t = new CanonicalType();
2390      t.setValue(value);
2391      if (this.instantiatesCanonical == null)
2392        this.instantiatesCanonical = new ArrayList<CanonicalType>();
2393      this.instantiatesCanonical.add(t);
2394      return this;
2395    }
2396
2397    /**
2398     * @param value {@link #instantiatesCanonical} (The URL pointing to a protocol, guideline, orderset, or other definition that is adhered to in whole or in part by this MedicationRequest.)
2399     */
2400    public boolean hasInstantiatesCanonical(String value) { 
2401      if (this.instantiatesCanonical == null)
2402        return false;
2403      for (CanonicalType v : this.instantiatesCanonical)
2404        if (v.getValue().equals(value)) // canonical
2405          return true;
2406      return false;
2407    }
2408
2409    /**
2410     * @return {@link #instantiatesUri} (The URL pointing to an externally maintained protocol, guideline, orderset or other definition that is adhered to in whole or in part by this MedicationRequest.)
2411     */
2412    public List<UriType> getInstantiatesUri() { 
2413      if (this.instantiatesUri == null)
2414        this.instantiatesUri = new ArrayList<UriType>();
2415      return this.instantiatesUri;
2416    }
2417
2418    /**
2419     * @return Returns a reference to <code>this</code> for easy method chaining
2420     */
2421    public MedicationRequest setInstantiatesUri(List<UriType> theInstantiatesUri) { 
2422      this.instantiatesUri = theInstantiatesUri;
2423      return this;
2424    }
2425
2426    public boolean hasInstantiatesUri() { 
2427      if (this.instantiatesUri == null)
2428        return false;
2429      for (UriType item : this.instantiatesUri)
2430        if (!item.isEmpty())
2431          return true;
2432      return false;
2433    }
2434
2435    /**
2436     * @return {@link #instantiatesUri} (The URL pointing to an externally maintained protocol, guideline, orderset or other definition that is adhered to in whole or in part by this MedicationRequest.)
2437     */
2438    public UriType addInstantiatesUriElement() {//2 
2439      UriType t = new UriType();
2440      if (this.instantiatesUri == null)
2441        this.instantiatesUri = new ArrayList<UriType>();
2442      this.instantiatesUri.add(t);
2443      return t;
2444    }
2445
2446    /**
2447     * @param value {@link #instantiatesUri} (The URL pointing to an externally maintained protocol, guideline, orderset or other definition that is adhered to in whole or in part by this MedicationRequest.)
2448     */
2449    public MedicationRequest addInstantiatesUri(String value) { //1
2450      UriType t = new UriType();
2451      t.setValue(value);
2452      if (this.instantiatesUri == null)
2453        this.instantiatesUri = new ArrayList<UriType>();
2454      this.instantiatesUri.add(t);
2455      return this;
2456    }
2457
2458    /**
2459     * @param value {@link #instantiatesUri} (The URL pointing to an externally maintained protocol, guideline, orderset or other definition that is adhered to in whole or in part by this MedicationRequest.)
2460     */
2461    public boolean hasInstantiatesUri(String value) { 
2462      if (this.instantiatesUri == null)
2463        return false;
2464      for (UriType v : this.instantiatesUri)
2465        if (v.getValue().equals(value)) // uri
2466          return true;
2467      return false;
2468    }
2469
2470    /**
2471     * @return {@link #basedOn} (A plan or request that is fulfilled in whole or in part by this medication request.)
2472     */
2473    public List<Reference> getBasedOn() { 
2474      if (this.basedOn == null)
2475        this.basedOn = new ArrayList<Reference>();
2476      return this.basedOn;
2477    }
2478
2479    /**
2480     * @return Returns a reference to <code>this</code> for easy method chaining
2481     */
2482    public MedicationRequest setBasedOn(List<Reference> theBasedOn) { 
2483      this.basedOn = theBasedOn;
2484      return this;
2485    }
2486
2487    public boolean hasBasedOn() { 
2488      if (this.basedOn == null)
2489        return false;
2490      for (Reference item : this.basedOn)
2491        if (!item.isEmpty())
2492          return true;
2493      return false;
2494    }
2495
2496    public Reference addBasedOn() { //3
2497      Reference t = new Reference();
2498      if (this.basedOn == null)
2499        this.basedOn = new ArrayList<Reference>();
2500      this.basedOn.add(t);
2501      return t;
2502    }
2503
2504    public MedicationRequest addBasedOn(Reference t) { //3
2505      if (t == null)
2506        return this;
2507      if (this.basedOn == null)
2508        this.basedOn = new ArrayList<Reference>();
2509      this.basedOn.add(t);
2510      return this;
2511    }
2512
2513    /**
2514     * @return The first repetition of repeating field {@link #basedOn}, creating it if it does not already exist {3}
2515     */
2516    public Reference getBasedOnFirstRep() { 
2517      if (getBasedOn().isEmpty()) {
2518        addBasedOn();
2519      }
2520      return getBasedOn().get(0);
2521    }
2522
2523    /**
2524     * @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.)
2525     */
2526    public Identifier getGroupIdentifier() { 
2527      if (this.groupIdentifier == null)
2528        if (Configuration.errorOnAutoCreate())
2529          throw new Error("Attempt to auto-create MedicationRequest.groupIdentifier");
2530        else if (Configuration.doAutoCreate())
2531          this.groupIdentifier = new Identifier(); // cc
2532      return this.groupIdentifier;
2533    }
2534
2535    public boolean hasGroupIdentifier() { 
2536      return this.groupIdentifier != null && !this.groupIdentifier.isEmpty();
2537    }
2538
2539    /**
2540     * @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.)
2541     */
2542    public MedicationRequest setGroupIdentifier(Identifier value) { 
2543      this.groupIdentifier = value;
2544      return this;
2545    }
2546
2547    /**
2548     * @return {@link #courseOfTherapyType} (The description of the overall pattern of the administration of the medication to the patient.)
2549     */
2550    public CodeableConcept getCourseOfTherapyType() { 
2551      if (this.courseOfTherapyType == null)
2552        if (Configuration.errorOnAutoCreate())
2553          throw new Error("Attempt to auto-create MedicationRequest.courseOfTherapyType");
2554        else if (Configuration.doAutoCreate())
2555          this.courseOfTherapyType = new CodeableConcept(); // cc
2556      return this.courseOfTherapyType;
2557    }
2558
2559    public boolean hasCourseOfTherapyType() { 
2560      return this.courseOfTherapyType != null && !this.courseOfTherapyType.isEmpty();
2561    }
2562
2563    /**
2564     * @param value {@link #courseOfTherapyType} (The description of the overall pattern of the administration of the medication to the patient.)
2565     */
2566    public MedicationRequest setCourseOfTherapyType(CodeableConcept value) { 
2567      this.courseOfTherapyType = value;
2568      return this;
2569    }
2570
2571    /**
2572     * @return {@link #insurance} (Insurance plans, coverage extensions, pre-authorizations and/or pre-determinations that may be required for delivering the requested service.)
2573     */
2574    public List<Reference> getInsurance() { 
2575      if (this.insurance == null)
2576        this.insurance = new ArrayList<Reference>();
2577      return this.insurance;
2578    }
2579
2580    /**
2581     * @return Returns a reference to <code>this</code> for easy method chaining
2582     */
2583    public MedicationRequest setInsurance(List<Reference> theInsurance) { 
2584      this.insurance = theInsurance;
2585      return this;
2586    }
2587
2588    public boolean hasInsurance() { 
2589      if (this.insurance == null)
2590        return false;
2591      for (Reference item : this.insurance)
2592        if (!item.isEmpty())
2593          return true;
2594      return false;
2595    }
2596
2597    public Reference addInsurance() { //3
2598      Reference t = new Reference();
2599      if (this.insurance == null)
2600        this.insurance = new ArrayList<Reference>();
2601      this.insurance.add(t);
2602      return t;
2603    }
2604
2605    public MedicationRequest addInsurance(Reference t) { //3
2606      if (t == null)
2607        return this;
2608      if (this.insurance == null)
2609        this.insurance = new ArrayList<Reference>();
2610      this.insurance.add(t);
2611      return this;
2612    }
2613
2614    /**
2615     * @return The first repetition of repeating field {@link #insurance}, creating it if it does not already exist {3}
2616     */
2617    public Reference getInsuranceFirstRep() { 
2618      if (getInsurance().isEmpty()) {
2619        addInsurance();
2620      }
2621      return getInsurance().get(0);
2622    }
2623
2624    /**
2625     * @return {@link #note} (Extra information about the prescription that could not be conveyed by the other attributes.)
2626     */
2627    public List<Annotation> getNote() { 
2628      if (this.note == null)
2629        this.note = new ArrayList<Annotation>();
2630      return this.note;
2631    }
2632
2633    /**
2634     * @return Returns a reference to <code>this</code> for easy method chaining
2635     */
2636    public MedicationRequest setNote(List<Annotation> theNote) { 
2637      this.note = theNote;
2638      return this;
2639    }
2640
2641    public boolean hasNote() { 
2642      if (this.note == null)
2643        return false;
2644      for (Annotation item : this.note)
2645        if (!item.isEmpty())
2646          return true;
2647      return false;
2648    }
2649
2650    public Annotation addNote() { //3
2651      Annotation t = new Annotation();
2652      if (this.note == null)
2653        this.note = new ArrayList<Annotation>();
2654      this.note.add(t);
2655      return t;
2656    }
2657
2658    public MedicationRequest addNote(Annotation t) { //3
2659      if (t == null)
2660        return this;
2661      if (this.note == null)
2662        this.note = new ArrayList<Annotation>();
2663      this.note.add(t);
2664      return this;
2665    }
2666
2667    /**
2668     * @return The first repetition of repeating field {@link #note}, creating it if it does not already exist {3}
2669     */
2670    public Annotation getNoteFirstRep() { 
2671      if (getNote().isEmpty()) {
2672        addNote();
2673      }
2674      return getNote().get(0);
2675    }
2676
2677    /**
2678     * @return {@link #renderedDosageInstruction} (The full representation of the dose of the medication included in all dosage instructions.  To be used when multiple dosage instructions are included to represent complex dosing such as increasing or tapering doses.). This is the underlying object with id, value and extensions. The accessor "getRenderedDosageInstruction" gives direct access to the value
2679     */
2680    public StringType getRenderedDosageInstructionElement() { 
2681      if (this.renderedDosageInstruction == null)
2682        if (Configuration.errorOnAutoCreate())
2683          throw new Error("Attempt to auto-create MedicationRequest.renderedDosageInstruction");
2684        else if (Configuration.doAutoCreate())
2685          this.renderedDosageInstruction = new StringType(); // bb
2686      return this.renderedDosageInstruction;
2687    }
2688
2689    public boolean hasRenderedDosageInstructionElement() { 
2690      return this.renderedDosageInstruction != null && !this.renderedDosageInstruction.isEmpty();
2691    }
2692
2693    public boolean hasRenderedDosageInstruction() { 
2694      return this.renderedDosageInstruction != null && !this.renderedDosageInstruction.isEmpty();
2695    }
2696
2697    /**
2698     * @param value {@link #renderedDosageInstruction} (The full representation of the dose of the medication included in all dosage instructions.  To be used when multiple dosage instructions are included to represent complex dosing such as increasing or tapering doses.). This is the underlying object with id, value and extensions. The accessor "getRenderedDosageInstruction" gives direct access to the value
2699     */
2700    public MedicationRequest setRenderedDosageInstructionElement(StringType value) { 
2701      this.renderedDosageInstruction = value;
2702      return this;
2703    }
2704
2705    /**
2706     * @return The full representation of the dose of the medication included in all dosage instructions.  To be used when multiple dosage instructions are included to represent complex dosing such as increasing or tapering doses.
2707     */
2708    public String getRenderedDosageInstruction() { 
2709      return this.renderedDosageInstruction == null ? null : this.renderedDosageInstruction.getValue();
2710    }
2711
2712    /**
2713     * @param value The full representation of the dose of the medication included in all dosage instructions.  To be used when multiple dosage instructions are included to represent complex dosing such as increasing or tapering doses.
2714     */
2715    public MedicationRequest setRenderedDosageInstruction(String value) { 
2716      if (Utilities.noString(value))
2717        this.renderedDosageInstruction = null;
2718      else {
2719        if (this.renderedDosageInstruction == null)
2720          this.renderedDosageInstruction = new StringType();
2721        this.renderedDosageInstruction.setValue(value);
2722      }
2723      return this;
2724    }
2725
2726    /**
2727     * @return {@link #dosageInstruction} (Indicates how the medication is to be used by the patient.)
2728     */
2729    public List<Dosage> getDosageInstruction() { 
2730      if (this.dosageInstruction == null)
2731        this.dosageInstruction = new ArrayList<Dosage>();
2732      return this.dosageInstruction;
2733    }
2734
2735    /**
2736     * @return Returns a reference to <code>this</code> for easy method chaining
2737     */
2738    public MedicationRequest setDosageInstruction(List<Dosage> theDosageInstruction) { 
2739      this.dosageInstruction = theDosageInstruction;
2740      return this;
2741    }
2742
2743    public boolean hasDosageInstruction() { 
2744      if (this.dosageInstruction == null)
2745        return false;
2746      for (Dosage item : this.dosageInstruction)
2747        if (!item.isEmpty())
2748          return true;
2749      return false;
2750    }
2751
2752    public Dosage addDosageInstruction() { //3
2753      Dosage t = new Dosage();
2754      if (this.dosageInstruction == null)
2755        this.dosageInstruction = new ArrayList<Dosage>();
2756      this.dosageInstruction.add(t);
2757      return t;
2758    }
2759
2760    public MedicationRequest addDosageInstruction(Dosage t) { //3
2761      if (t == null)
2762        return this;
2763      if (this.dosageInstruction == null)
2764        this.dosageInstruction = new ArrayList<Dosage>();
2765      this.dosageInstruction.add(t);
2766      return this;
2767    }
2768
2769    /**
2770     * @return The first repetition of repeating field {@link #dosageInstruction}, creating it if it does not already exist {3}
2771     */
2772    public Dosage getDosageInstructionFirstRep() { 
2773      if (getDosageInstruction().isEmpty()) {
2774        addDosageInstruction();
2775      }
2776      return getDosageInstruction().get(0);
2777    }
2778
2779    /**
2780     * @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.)
2781     */
2782    public MedicationRequestDispenseRequestComponent getDispenseRequest() { 
2783      if (this.dispenseRequest == null)
2784        if (Configuration.errorOnAutoCreate())
2785          throw new Error("Attempt to auto-create MedicationRequest.dispenseRequest");
2786        else if (Configuration.doAutoCreate())
2787          this.dispenseRequest = new MedicationRequestDispenseRequestComponent(); // cc
2788      return this.dispenseRequest;
2789    }
2790
2791    public boolean hasDispenseRequest() { 
2792      return this.dispenseRequest != null && !this.dispenseRequest.isEmpty();
2793    }
2794
2795    /**
2796     * @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.)
2797     */
2798    public MedicationRequest setDispenseRequest(MedicationRequestDispenseRequestComponent value) { 
2799      this.dispenseRequest = value;
2800      return this;
2801    }
2802
2803    /**
2804     * @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.)
2805     */
2806    public MedicationRequestSubstitutionComponent getSubstitution() { 
2807      if (this.substitution == null)
2808        if (Configuration.errorOnAutoCreate())
2809          throw new Error("Attempt to auto-create MedicationRequest.substitution");
2810        else if (Configuration.doAutoCreate())
2811          this.substitution = new MedicationRequestSubstitutionComponent(); // cc
2812      return this.substitution;
2813    }
2814
2815    public boolean hasSubstitution() { 
2816      return this.substitution != null && !this.substitution.isEmpty();
2817    }
2818
2819    /**
2820     * @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.)
2821     */
2822    public MedicationRequest setSubstitution(MedicationRequestSubstitutionComponent value) { 
2823      this.substitution = value;
2824      return this;
2825    }
2826
2827    /**
2828     * @return {@link #priorPrescription} (A link to a resource representing an earlier order related order or prescription.)
2829     */
2830    public Reference getPriorPrescription() { 
2831      if (this.priorPrescription == null)
2832        if (Configuration.errorOnAutoCreate())
2833          throw new Error("Attempt to auto-create MedicationRequest.priorPrescription");
2834        else if (Configuration.doAutoCreate())
2835          this.priorPrescription = new Reference(); // cc
2836      return this.priorPrescription;
2837    }
2838
2839    public boolean hasPriorPrescription() { 
2840      return this.priorPrescription != null && !this.priorPrescription.isEmpty();
2841    }
2842
2843    /**
2844     * @param value {@link #priorPrescription} (A link to a resource representing an earlier order related order or prescription.)
2845     */
2846    public MedicationRequest setPriorPrescription(Reference value) { 
2847      this.priorPrescription = value;
2848      return this;
2849    }
2850
2851    /**
2852     * @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.)
2853     */
2854    public List<Reference> getDetectedIssue() { 
2855      if (this.detectedIssue == null)
2856        this.detectedIssue = new ArrayList<Reference>();
2857      return this.detectedIssue;
2858    }
2859
2860    /**
2861     * @return Returns a reference to <code>this</code> for easy method chaining
2862     */
2863    public MedicationRequest setDetectedIssue(List<Reference> theDetectedIssue) { 
2864      this.detectedIssue = theDetectedIssue;
2865      return this;
2866    }
2867
2868    public boolean hasDetectedIssue() { 
2869      if (this.detectedIssue == null)
2870        return false;
2871      for (Reference item : this.detectedIssue)
2872        if (!item.isEmpty())
2873          return true;
2874      return false;
2875    }
2876
2877    public Reference addDetectedIssue() { //3
2878      Reference t = new Reference();
2879      if (this.detectedIssue == null)
2880        this.detectedIssue = new ArrayList<Reference>();
2881      this.detectedIssue.add(t);
2882      return t;
2883    }
2884
2885    public MedicationRequest addDetectedIssue(Reference t) { //3
2886      if (t == null)
2887        return this;
2888      if (this.detectedIssue == null)
2889        this.detectedIssue = new ArrayList<Reference>();
2890      this.detectedIssue.add(t);
2891      return this;
2892    }
2893
2894    /**
2895     * @return The first repetition of repeating field {@link #detectedIssue}, creating it if it does not already exist {3}
2896     */
2897    public Reference getDetectedIssueFirstRep() { 
2898      if (getDetectedIssue().isEmpty()) {
2899        addDetectedIssue();
2900      }
2901      return getDetectedIssue().get(0);
2902    }
2903
2904    /**
2905     * @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.)
2906     */
2907    public List<Reference> getEventHistory() { 
2908      if (this.eventHistory == null)
2909        this.eventHistory = new ArrayList<Reference>();
2910      return this.eventHistory;
2911    }
2912
2913    /**
2914     * @return Returns a reference to <code>this</code> for easy method chaining
2915     */
2916    public MedicationRequest setEventHistory(List<Reference> theEventHistory) { 
2917      this.eventHistory = theEventHistory;
2918      return this;
2919    }
2920
2921    public boolean hasEventHistory() { 
2922      if (this.eventHistory == null)
2923        return false;
2924      for (Reference item : this.eventHistory)
2925        if (!item.isEmpty())
2926          return true;
2927      return false;
2928    }
2929
2930    public Reference addEventHistory() { //3
2931      Reference t = new Reference();
2932      if (this.eventHistory == null)
2933        this.eventHistory = new ArrayList<Reference>();
2934      this.eventHistory.add(t);
2935      return t;
2936    }
2937
2938    public MedicationRequest addEventHistory(Reference t) { //3
2939      if (t == null)
2940        return this;
2941      if (this.eventHistory == null)
2942        this.eventHistory = new ArrayList<Reference>();
2943      this.eventHistory.add(t);
2944      return this;
2945    }
2946
2947    /**
2948     * @return The first repetition of repeating field {@link #eventHistory}, creating it if it does not already exist {3}
2949     */
2950    public Reference getEventHistoryFirstRep() { 
2951      if (getEventHistory().isEmpty()) {
2952        addEventHistory();
2953      }
2954      return getEventHistory().get(0);
2955    }
2956
2957      protected void listChildren(List<Property> children) {
2958        super.listChildren(children);
2959        children.add(new Property("identifier", "Identifier", "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. They are business identifiers assigned to this resource by the performer or other systems and remain constant as the resource is updated and propagates from server to server.", 0, java.lang.Integer.MAX_VALUE, identifier));
2960        children.add(new Property("status", "code", "A code specifying the current state of the order.  Generally, this will be active or completed state.", 0, 1, status));
2961        children.add(new Property("statusReason", "CodeableConcept", "Captures the reason for the current state of the MedicationRequest.", 0, 1, statusReason));
2962        children.add(new Property("intent", "code", "Whether the request is a proposal, plan, or an original order.", 0, 1, intent));
2963        children.add(new Property("category", "CodeableConcept", "Indicates the grouping or category of medication request (for example, where the medication is expected to be consumed or administered (i.e. inpatient or outpatient)).", 0, java.lang.Integer.MAX_VALUE, category));
2964        children.add(new Property("priority", "code", "Indicates how quickly the Medication Request should be addressed with respect to other requests.", 0, 1, priority));
2965        children.add(new Property("doNotPerform", "boolean", "If true indicates that the provider is asking for the medication request not to occur.", 0, 1, doNotPerform));
2966        children.add(new Property("reported", "boolean", "Indicates if this record was captured as a secondary 'reported' record rather than as an original primary source-of-truth record.  It may also indicate the source of the report.", 0, 1, reported));
2967        children.add(new Property("informationSource", "Reference(Patient|Practitioner|PractitionerRole|RelatedPerson|Organization)", "The person or organization who provided the information about this request, if the source is someone other than the requestor.  This is often used when the MedicationRequest is reported by another person.", 0, 1, informationSource));
2968        children.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, 1, medication));
2969        children.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, 1, subject));
2970        children.add(new Property("encounter", "Reference(Encounter)", "The Encounter during which this [x] was created or to which the creation of this record is tightly associated.", 0, 1, encounter));
2971        children.add(new Property("supportingInformation", "Reference(Any)", "Include additional information (for example, patient height and weight, a MedicationUsage for the patient) that supports the ordering of the medication.", 0, java.lang.Integer.MAX_VALUE, supportingInformation));
2972        children.add(new Property("authoredOn", "dateTime", "The date (and perhaps time) when the prescription was initially written or authored on.", 0, 1, authoredOn));
2973        children.add(new Property("requester", "Reference(Practitioner|PractitionerRole|Organization|Patient|RelatedPerson|Device)", "The individual, organization, or device that initiated the request and has responsibility for its activation.", 0, 1, requester));
2974        children.add(new Property("performer", "Reference(Practitioner|PractitionerRole|Organization|Patient|Device|RelatedPerson|CareTeam|HealthcareService)", "The specified desired performer of the medication treatment (e.g. the performer of the medication administration).", 0, 1, performer));
2975        children.add(new Property("performerType", "CodeableConcept", "Indicates the type of performer of the administration of the medication.", 0, 1, performerType));
2976        children.add(new Property("recorder", "Reference(Practitioner|PractitionerRole)", "The person who entered the order on behalf of another individual for example in the case of a verbal or a telephone order.", 0, 1, recorder));
2977        children.add(new Property("reason", "CodeableReference(Condition|Observation)", "The reason or the indication for ordering or not ordering the medication.", 0, java.lang.Integer.MAX_VALUE, reason));
2978        children.add(new Property("instantiatesCanonical", "canonical(PlanDefinition|ActivityDefinition)", "The URL pointing to a protocol, guideline, orderset, or other definition that is adhered to in whole or in part by this MedicationRequest.", 0, java.lang.Integer.MAX_VALUE, instantiatesCanonical));
2979        children.add(new Property("instantiatesUri", "uri", "The URL pointing to an externally maintained protocol, guideline, orderset or other definition that is adhered to in whole or in part by this MedicationRequest.", 0, java.lang.Integer.MAX_VALUE, instantiatesUri));
2980        children.add(new Property("basedOn", "Reference(CarePlan|MedicationRequest|ServiceRequest|ImmunizationRecommendation)", "A plan or request that is fulfilled in whole or in part by this medication request.", 0, java.lang.Integer.MAX_VALUE, basedOn));
2981        children.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, 1, groupIdentifier));
2982        children.add(new Property("courseOfTherapyType", "CodeableConcept", "The description of the overall pattern of the administration of the medication to the patient.", 0, 1, courseOfTherapyType));
2983        children.add(new Property("insurance", "Reference(Coverage|ClaimResponse)", "Insurance plans, coverage extensions, pre-authorizations and/or pre-determinations that may be required for delivering the requested service.", 0, java.lang.Integer.MAX_VALUE, insurance));
2984        children.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));
2985        children.add(new Property("renderedDosageInstruction", "string", "The full representation of the dose of the medication included in all dosage instructions.  To be used when multiple dosage instructions are included to represent complex dosing such as increasing or tapering doses.", 0, 1, renderedDosageInstruction));
2986        children.add(new Property("dosageInstruction", "Dosage", "Indicates how the medication is to be used by the patient.", 0, java.lang.Integer.MAX_VALUE, dosageInstruction));
2987        children.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, 1, dispenseRequest));
2988        children.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, 1, substitution));
2989        children.add(new Property("priorPrescription", "Reference(MedicationRequest)", "A link to a resource representing an earlier order related order or prescription.", 0, 1, priorPrescription));
2990        children.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));
2991        children.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));
2992      }
2993
2994      @Override
2995      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2996        switch (_hash) {
2997        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "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. They are business identifiers assigned to this resource by the performer or other systems and remain constant as the resource is updated and propagates from server to server.", 0, java.lang.Integer.MAX_VALUE, identifier);
2998        case -892481550: /*status*/  return new Property("status", "code", "A code specifying the current state of the order.  Generally, this will be active or completed state.", 0, 1, status);
2999        case 2051346646: /*statusReason*/  return new Property("statusReason", "CodeableConcept", "Captures the reason for the current state of the MedicationRequest.", 0, 1, statusReason);
3000        case -1183762788: /*intent*/  return new Property("intent", "code", "Whether the request is a proposal, plan, or an original order.", 0, 1, intent);
3001        case 50511102: /*category*/  return new Property("category", "CodeableConcept", "Indicates the grouping or category of medication request (for example, where the medication is expected to be consumed or administered (i.e. inpatient or outpatient)).", 0, java.lang.Integer.MAX_VALUE, category);
3002        case -1165461084: /*priority*/  return new Property("priority", "code", "Indicates how quickly the Medication Request should be addressed with respect to other requests.", 0, 1, priority);
3003        case -1788508167: /*doNotPerform*/  return new Property("doNotPerform", "boolean", "If true indicates that the provider is asking for the medication request not to occur.", 0, 1, doNotPerform);
3004        case -427039533: /*reported*/  return new Property("reported", "boolean", "Indicates if this record was captured as a secondary 'reported' record rather than as an original primary source-of-truth record.  It may also indicate the source of the report.", 0, 1, reported);
3005        case -2123220889: /*informationSource*/  return new Property("informationSource", "Reference(Patient|Practitioner|PractitionerRole|RelatedPerson|Organization)", "The person or organization who provided the information about this request, if the source is someone other than the requestor.  This is often used when the MedicationRequest is reported by another person.", 0, 1, informationSource);
3006        case 1458402129: /*medication[x]*/  return 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, 1, medication);
3007        case 1998965455: /*medication*/  return 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, 1, medication);
3008        case -209845038: /*medicationCodeableConcept*/  return new Property("medication[x]", "CodeableConcept", "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, 1, medication);
3009        case 2104315196: /*medicationReference*/  return new Property("medication[x]", "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, 1, medication);
3010        case -1867885268: /*subject*/  return 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, 1, subject);
3011        case 1524132147: /*encounter*/  return new Property("encounter", "Reference(Encounter)", "The Encounter during which this [x] was created or to which the creation of this record is tightly associated.", 0, 1, encounter);
3012        case -1248768647: /*supportingInformation*/  return new Property("supportingInformation", "Reference(Any)", "Include additional information (for example, patient height and weight, a MedicationUsage for the patient) that supports the ordering of the medication.", 0, java.lang.Integer.MAX_VALUE, supportingInformation);
3013        case -1500852503: /*authoredOn*/  return new Property("authoredOn", "dateTime", "The date (and perhaps time) when the prescription was initially written or authored on.", 0, 1, authoredOn);
3014        case 693933948: /*requester*/  return new Property("requester", "Reference(Practitioner|PractitionerRole|Organization|Patient|RelatedPerson|Device)", "The individual, organization, or device that initiated the request and has responsibility for its activation.", 0, 1, requester);
3015        case 481140686: /*performer*/  return new Property("performer", "Reference(Practitioner|PractitionerRole|Organization|Patient|Device|RelatedPerson|CareTeam|HealthcareService)", "The specified desired performer of the medication treatment (e.g. the performer of the medication administration).", 0, 1, performer);
3016        case -901444568: /*performerType*/  return new Property("performerType", "CodeableConcept", "Indicates the type of performer of the administration of the medication.", 0, 1, performerType);
3017        case -799233858: /*recorder*/  return new Property("recorder", "Reference(Practitioner|PractitionerRole)", "The person who entered the order on behalf of another individual for example in the case of a verbal or a telephone order.", 0, 1, recorder);
3018        case -934964668: /*reason*/  return new Property("reason", "CodeableReference(Condition|Observation)", "The reason or the indication for ordering or not ordering the medication.", 0, java.lang.Integer.MAX_VALUE, reason);
3019        case 8911915: /*instantiatesCanonical*/  return new Property("instantiatesCanonical", "canonical(PlanDefinition|ActivityDefinition)", "The URL pointing to a protocol, guideline, orderset, or other definition that is adhered to in whole or in part by this MedicationRequest.", 0, java.lang.Integer.MAX_VALUE, instantiatesCanonical);
3020        case -1926393373: /*instantiatesUri*/  return new Property("instantiatesUri", "uri", "The URL pointing to an externally maintained protocol, guideline, orderset or other definition that is adhered to in whole or in part by this MedicationRequest.", 0, java.lang.Integer.MAX_VALUE, instantiatesUri);
3021        case -332612366: /*basedOn*/  return new Property("basedOn", "Reference(CarePlan|MedicationRequest|ServiceRequest|ImmunizationRecommendation)", "A plan or request that is fulfilled in whole or in part by this medication request.", 0, java.lang.Integer.MAX_VALUE, basedOn);
3022        case -445338488: /*groupIdentifier*/  return 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, 1, groupIdentifier);
3023        case -447282031: /*courseOfTherapyType*/  return new Property("courseOfTherapyType", "CodeableConcept", "The description of the overall pattern of the administration of the medication to the patient.", 0, 1, courseOfTherapyType);
3024        case 73049818: /*insurance*/  return new Property("insurance", "Reference(Coverage|ClaimResponse)", "Insurance plans, coverage extensions, pre-authorizations and/or pre-determinations that may be required for delivering the requested service.", 0, java.lang.Integer.MAX_VALUE, insurance);
3025        case 3387378: /*note*/  return 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);
3026        case 1718902050: /*renderedDosageInstruction*/  return new Property("renderedDosageInstruction", "string", "The full representation of the dose of the medication included in all dosage instructions.  To be used when multiple dosage instructions are included to represent complex dosing such as increasing or tapering doses.", 0, 1, renderedDosageInstruction);
3027        case -1201373865: /*dosageInstruction*/  return new Property("dosageInstruction", "Dosage", "Indicates how the medication is to be used by the patient.", 0, java.lang.Integer.MAX_VALUE, dosageInstruction);
3028        case 824620658: /*dispenseRequest*/  return 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, 1, dispenseRequest);
3029        case 826147581: /*substitution*/  return 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, 1, substitution);
3030        case -486355964: /*priorPrescription*/  return new Property("priorPrescription", "Reference(MedicationRequest)", "A link to a resource representing an earlier order related order or prescription.", 0, 1, priorPrescription);
3031        case 51602295: /*detectedIssue*/  return 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);
3032        case 1835190426: /*eventHistory*/  return 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);
3033        default: return super.getNamedProperty(_hash, _name, _checkValid);
3034        }
3035
3036      }
3037
3038      @Override
3039      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
3040        switch (hash) {
3041        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
3042        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<MedicationrequestStatus>
3043        case 2051346646: /*statusReason*/ return this.statusReason == null ? new Base[0] : new Base[] {this.statusReason}; // CodeableConcept
3044        case -1183762788: /*intent*/ return this.intent == null ? new Base[0] : new Base[] {this.intent}; // Enumeration<MedicationRequestIntent>
3045        case 50511102: /*category*/ return this.category == null ? new Base[0] : this.category.toArray(new Base[this.category.size()]); // CodeableConcept
3046        case -1165461084: /*priority*/ return this.priority == null ? new Base[0] : new Base[] {this.priority}; // Enumeration<RequestPriority>
3047        case -1788508167: /*doNotPerform*/ return this.doNotPerform == null ? new Base[0] : new Base[] {this.doNotPerform}; // BooleanType
3048        case -427039533: /*reported*/ return this.reported == null ? new Base[0] : new Base[] {this.reported}; // BooleanType
3049        case -2123220889: /*informationSource*/ return this.informationSource == null ? new Base[0] : new Base[] {this.informationSource}; // Reference
3050        case 1998965455: /*medication*/ return this.medication == null ? new Base[0] : new Base[] {this.medication}; // DataType
3051        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
3052        case 1524132147: /*encounter*/ return this.encounter == null ? new Base[0] : new Base[] {this.encounter}; // Reference
3053        case -1248768647: /*supportingInformation*/ return this.supportingInformation == null ? new Base[0] : this.supportingInformation.toArray(new Base[this.supportingInformation.size()]); // Reference
3054        case -1500852503: /*authoredOn*/ return this.authoredOn == null ? new Base[0] : new Base[] {this.authoredOn}; // DateTimeType
3055        case 693933948: /*requester*/ return this.requester == null ? new Base[0] : new Base[] {this.requester}; // Reference
3056        case 481140686: /*performer*/ return this.performer == null ? new Base[0] : new Base[] {this.performer}; // Reference
3057        case -901444568: /*performerType*/ return this.performerType == null ? new Base[0] : new Base[] {this.performerType}; // CodeableConcept
3058        case -799233858: /*recorder*/ return this.recorder == null ? new Base[0] : new Base[] {this.recorder}; // Reference
3059        case -934964668: /*reason*/ return this.reason == null ? new Base[0] : this.reason.toArray(new Base[this.reason.size()]); // CodeableReference
3060        case 8911915: /*instantiatesCanonical*/ return this.instantiatesCanonical == null ? new Base[0] : this.instantiatesCanonical.toArray(new Base[this.instantiatesCanonical.size()]); // CanonicalType
3061        case -1926393373: /*instantiatesUri*/ return this.instantiatesUri == null ? new Base[0] : this.instantiatesUri.toArray(new Base[this.instantiatesUri.size()]); // UriType
3062        case -332612366: /*basedOn*/ return this.basedOn == null ? new Base[0] : this.basedOn.toArray(new Base[this.basedOn.size()]); // Reference
3063        case -445338488: /*groupIdentifier*/ return this.groupIdentifier == null ? new Base[0] : new Base[] {this.groupIdentifier}; // Identifier
3064        case -447282031: /*courseOfTherapyType*/ return this.courseOfTherapyType == null ? new Base[0] : new Base[] {this.courseOfTherapyType}; // CodeableConcept
3065        case 73049818: /*insurance*/ return this.insurance == null ? new Base[0] : this.insurance.toArray(new Base[this.insurance.size()]); // Reference
3066        case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
3067        case 1718902050: /*renderedDosageInstruction*/ return this.renderedDosageInstruction == null ? new Base[0] : new Base[] {this.renderedDosageInstruction}; // StringType
3068        case -1201373865: /*dosageInstruction*/ return this.dosageInstruction == null ? new Base[0] : this.dosageInstruction.toArray(new Base[this.dosageInstruction.size()]); // Dosage
3069        case 824620658: /*dispenseRequest*/ return this.dispenseRequest == null ? new Base[0] : new Base[] {this.dispenseRequest}; // MedicationRequestDispenseRequestComponent
3070        case 826147581: /*substitution*/ return this.substitution == null ? new Base[0] : new Base[] {this.substitution}; // MedicationRequestSubstitutionComponent
3071        case -486355964: /*priorPrescription*/ return this.priorPrescription == null ? new Base[0] : new Base[] {this.priorPrescription}; // Reference
3072        case 51602295: /*detectedIssue*/ return this.detectedIssue == null ? new Base[0] : this.detectedIssue.toArray(new Base[this.detectedIssue.size()]); // Reference
3073        case 1835190426: /*eventHistory*/ return this.eventHistory == null ? new Base[0] : this.eventHistory.toArray(new Base[this.eventHistory.size()]); // Reference
3074        default: return super.getProperty(hash, name, checkValid);
3075        }
3076
3077      }
3078
3079      @Override
3080      public Base setProperty(int hash, String name, Base value) throws FHIRException {
3081        switch (hash) {
3082        case -1618432855: // identifier
3083          this.getIdentifier().add(TypeConvertor.castToIdentifier(value)); // Identifier
3084          return value;
3085        case -892481550: // status
3086          value = new MedicationrequestStatusEnumFactory().fromType(TypeConvertor.castToCode(value));
3087          this.status = (Enumeration) value; // Enumeration<MedicationrequestStatus>
3088          return value;
3089        case 2051346646: // statusReason
3090          this.statusReason = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
3091          return value;
3092        case -1183762788: // intent
3093          value = new MedicationRequestIntentEnumFactory().fromType(TypeConvertor.castToCode(value));
3094          this.intent = (Enumeration) value; // Enumeration<MedicationRequestIntent>
3095          return value;
3096        case 50511102: // category
3097          this.getCategory().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
3098          return value;
3099        case -1165461084: // priority
3100          value = new RequestPriorityEnumFactory().fromType(TypeConvertor.castToCode(value));
3101          this.priority = (Enumeration) value; // Enumeration<RequestPriority>
3102          return value;
3103        case -1788508167: // doNotPerform
3104          this.doNotPerform = TypeConvertor.castToBoolean(value); // BooleanType
3105          return value;
3106        case -427039533: // reported
3107          this.reported = TypeConvertor.castToBoolean(value); // BooleanType
3108          return value;
3109        case -2123220889: // informationSource
3110          this.informationSource = TypeConvertor.castToReference(value); // Reference
3111          return value;
3112        case 1998965455: // medication
3113          this.medication = TypeConvertor.castToType(value); // DataType
3114          return value;
3115        case -1867885268: // subject
3116          this.subject = TypeConvertor.castToReference(value); // Reference
3117          return value;
3118        case 1524132147: // encounter
3119          this.encounter = TypeConvertor.castToReference(value); // Reference
3120          return value;
3121        case -1248768647: // supportingInformation
3122          this.getSupportingInformation().add(TypeConvertor.castToReference(value)); // Reference
3123          return value;
3124        case -1500852503: // authoredOn
3125          this.authoredOn = TypeConvertor.castToDateTime(value); // DateTimeType
3126          return value;
3127        case 693933948: // requester
3128          this.requester = TypeConvertor.castToReference(value); // Reference
3129          return value;
3130        case 481140686: // performer
3131          this.performer = TypeConvertor.castToReference(value); // Reference
3132          return value;
3133        case -901444568: // performerType
3134          this.performerType = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
3135          return value;
3136        case -799233858: // recorder
3137          this.recorder = TypeConvertor.castToReference(value); // Reference
3138          return value;
3139        case -934964668: // reason
3140          this.getReason().add(TypeConvertor.castToCodeableReference(value)); // CodeableReference
3141          return value;
3142        case 8911915: // instantiatesCanonical
3143          this.getInstantiatesCanonical().add(TypeConvertor.castToCanonical(value)); // CanonicalType
3144          return value;
3145        case -1926393373: // instantiatesUri
3146          this.getInstantiatesUri().add(TypeConvertor.castToUri(value)); // UriType
3147          return value;
3148        case -332612366: // basedOn
3149          this.getBasedOn().add(TypeConvertor.castToReference(value)); // Reference
3150          return value;
3151        case -445338488: // groupIdentifier
3152          this.groupIdentifier = TypeConvertor.castToIdentifier(value); // Identifier
3153          return value;
3154        case -447282031: // courseOfTherapyType
3155          this.courseOfTherapyType = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
3156          return value;
3157        case 73049818: // insurance
3158          this.getInsurance().add(TypeConvertor.castToReference(value)); // Reference
3159          return value;
3160        case 3387378: // note
3161          this.getNote().add(TypeConvertor.castToAnnotation(value)); // Annotation
3162          return value;
3163        case 1718902050: // renderedDosageInstruction
3164          this.renderedDosageInstruction = TypeConvertor.castToString(value); // StringType
3165          return value;
3166        case -1201373865: // dosageInstruction
3167          this.getDosageInstruction().add(TypeConvertor.castToDosage(value)); // Dosage
3168          return value;
3169        case 824620658: // dispenseRequest
3170          this.dispenseRequest = (MedicationRequestDispenseRequestComponent) value; // MedicationRequestDispenseRequestComponent
3171          return value;
3172        case 826147581: // substitution
3173          this.substitution = (MedicationRequestSubstitutionComponent) value; // MedicationRequestSubstitutionComponent
3174          return value;
3175        case -486355964: // priorPrescription
3176          this.priorPrescription = TypeConvertor.castToReference(value); // Reference
3177          return value;
3178        case 51602295: // detectedIssue
3179          this.getDetectedIssue().add(TypeConvertor.castToReference(value)); // Reference
3180          return value;
3181        case 1835190426: // eventHistory
3182          this.getEventHistory().add(TypeConvertor.castToReference(value)); // Reference
3183          return value;
3184        default: return super.setProperty(hash, name, value);
3185        }
3186
3187      }
3188
3189      @Override
3190      public Base setProperty(String name, Base value) throws FHIRException {
3191        if (name.equals("identifier")) {
3192          this.getIdentifier().add(TypeConvertor.castToIdentifier(value));
3193        } else if (name.equals("status")) {
3194          value = new MedicationrequestStatusEnumFactory().fromType(TypeConvertor.castToCode(value));
3195          this.status = (Enumeration) value; // Enumeration<MedicationrequestStatus>
3196        } else if (name.equals("statusReason")) {
3197          this.statusReason = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
3198        } else if (name.equals("intent")) {
3199          value = new MedicationRequestIntentEnumFactory().fromType(TypeConvertor.castToCode(value));
3200          this.intent = (Enumeration) value; // Enumeration<MedicationRequestIntent>
3201        } else if (name.equals("category")) {
3202          this.getCategory().add(TypeConvertor.castToCodeableConcept(value));
3203        } else if (name.equals("priority")) {
3204          value = new RequestPriorityEnumFactory().fromType(TypeConvertor.castToCode(value));
3205          this.priority = (Enumeration) value; // Enumeration<RequestPriority>
3206        } else if (name.equals("doNotPerform")) {
3207          this.doNotPerform = TypeConvertor.castToBoolean(value); // BooleanType
3208        } else if (name.equals("reported")) {
3209          this.reported = TypeConvertor.castToBoolean(value); // BooleanType
3210        } else if (name.equals("informationSource")) {
3211          this.informationSource = TypeConvertor.castToReference(value); // Reference
3212        } else if (name.equals("medication[x]")) {
3213          this.medication = TypeConvertor.castToType(value); // DataType
3214        } else if (name.equals("subject")) {
3215          this.subject = TypeConvertor.castToReference(value); // Reference
3216        } else if (name.equals("encounter")) {
3217          this.encounter = TypeConvertor.castToReference(value); // Reference
3218        } else if (name.equals("supportingInformation")) {
3219          this.getSupportingInformation().add(TypeConvertor.castToReference(value));
3220        } else if (name.equals("authoredOn")) {
3221          this.authoredOn = TypeConvertor.castToDateTime(value); // DateTimeType
3222        } else if (name.equals("requester")) {
3223          this.requester = TypeConvertor.castToReference(value); // Reference
3224        } else if (name.equals("performer")) {
3225          this.performer = TypeConvertor.castToReference(value); // Reference
3226        } else if (name.equals("performerType")) {
3227          this.performerType = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
3228        } else if (name.equals("recorder")) {
3229          this.recorder = TypeConvertor.castToReference(value); // Reference
3230        } else if (name.equals("reason")) {
3231          this.getReason().add(TypeConvertor.castToCodeableReference(value));
3232        } else if (name.equals("instantiatesCanonical")) {
3233          this.getInstantiatesCanonical().add(TypeConvertor.castToCanonical(value));
3234        } else if (name.equals("instantiatesUri")) {
3235          this.getInstantiatesUri().add(TypeConvertor.castToUri(value));
3236        } else if (name.equals("basedOn")) {
3237          this.getBasedOn().add(TypeConvertor.castToReference(value));
3238        } else if (name.equals("groupIdentifier")) {
3239          this.groupIdentifier = TypeConvertor.castToIdentifier(value); // Identifier
3240        } else if (name.equals("courseOfTherapyType")) {
3241          this.courseOfTherapyType = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
3242        } else if (name.equals("insurance")) {
3243          this.getInsurance().add(TypeConvertor.castToReference(value));
3244        } else if (name.equals("note")) {
3245          this.getNote().add(TypeConvertor.castToAnnotation(value));
3246        } else if (name.equals("renderedDosageInstruction")) {
3247          this.renderedDosageInstruction = TypeConvertor.castToString(value); // StringType
3248        } else if (name.equals("dosageInstruction")) {
3249          this.getDosageInstruction().add(TypeConvertor.castToDosage(value));
3250        } else if (name.equals("dispenseRequest")) {
3251          this.dispenseRequest = (MedicationRequestDispenseRequestComponent) value; // MedicationRequestDispenseRequestComponent
3252        } else if (name.equals("substitution")) {
3253          this.substitution = (MedicationRequestSubstitutionComponent) value; // MedicationRequestSubstitutionComponent
3254        } else if (name.equals("priorPrescription")) {
3255          this.priorPrescription = TypeConvertor.castToReference(value); // Reference
3256        } else if (name.equals("detectedIssue")) {
3257          this.getDetectedIssue().add(TypeConvertor.castToReference(value));
3258        } else if (name.equals("eventHistory")) {
3259          this.getEventHistory().add(TypeConvertor.castToReference(value));
3260        } else
3261          return super.setProperty(name, value);
3262        return value;
3263      }
3264
3265      @Override
3266      public Base makeProperty(int hash, String name) throws FHIRException {
3267        switch (hash) {
3268        case -1618432855:  return addIdentifier(); 
3269        case -892481550:  return getStatusElement();
3270        case 2051346646:  return getStatusReason();
3271        case -1183762788:  return getIntentElement();
3272        case 50511102:  return addCategory(); 
3273        case -1165461084:  return getPriorityElement();
3274        case -1788508167:  return getDoNotPerformElement();
3275        case -427039533:  return getReportedElement();
3276        case -2123220889:  return getInformationSource();
3277        case 1458402129:  return getMedication();
3278        case 1998965455:  return getMedication();
3279        case -1867885268:  return getSubject();
3280        case 1524132147:  return getEncounter();
3281        case -1248768647:  return addSupportingInformation(); 
3282        case -1500852503:  return getAuthoredOnElement();
3283        case 693933948:  return getRequester();
3284        case 481140686:  return getPerformer();
3285        case -901444568:  return getPerformerType();
3286        case -799233858:  return getRecorder();
3287        case -934964668:  return addReason(); 
3288        case 8911915:  return addInstantiatesCanonicalElement();
3289        case -1926393373:  return addInstantiatesUriElement();
3290        case -332612366:  return addBasedOn(); 
3291        case -445338488:  return getGroupIdentifier();
3292        case -447282031:  return getCourseOfTherapyType();
3293        case 73049818:  return addInsurance(); 
3294        case 3387378:  return addNote(); 
3295        case 1718902050:  return getRenderedDosageInstructionElement();
3296        case -1201373865:  return addDosageInstruction(); 
3297        case 824620658:  return getDispenseRequest();
3298        case 826147581:  return getSubstitution();
3299        case -486355964:  return getPriorPrescription();
3300        case 51602295:  return addDetectedIssue(); 
3301        case 1835190426:  return addEventHistory(); 
3302        default: return super.makeProperty(hash, name);
3303        }
3304
3305      }
3306
3307      @Override
3308      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
3309        switch (hash) {
3310        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
3311        case -892481550: /*status*/ return new String[] {"code"};
3312        case 2051346646: /*statusReason*/ return new String[] {"CodeableConcept"};
3313        case -1183762788: /*intent*/ return new String[] {"code"};
3314        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
3315        case -1165461084: /*priority*/ return new String[] {"code"};
3316        case -1788508167: /*doNotPerform*/ return new String[] {"boolean"};
3317        case -427039533: /*reported*/ return new String[] {"boolean"};
3318        case -2123220889: /*informationSource*/ return new String[] {"Reference"};
3319        case 1998965455: /*medication*/ return new String[] {"CodeableConcept", "Reference"};
3320        case -1867885268: /*subject*/ return new String[] {"Reference"};
3321        case 1524132147: /*encounter*/ return new String[] {"Reference"};
3322        case -1248768647: /*supportingInformation*/ return new String[] {"Reference"};
3323        case -1500852503: /*authoredOn*/ return new String[] {"dateTime"};
3324        case 693933948: /*requester*/ return new String[] {"Reference"};
3325        case 481140686: /*performer*/ return new String[] {"Reference"};
3326        case -901444568: /*performerType*/ return new String[] {"CodeableConcept"};
3327        case -799233858: /*recorder*/ return new String[] {"Reference"};
3328        case -934964668: /*reason*/ return new String[] {"CodeableReference"};
3329        case 8911915: /*instantiatesCanonical*/ return new String[] {"canonical"};
3330        case -1926393373: /*instantiatesUri*/ return new String[] {"uri"};
3331        case -332612366: /*basedOn*/ return new String[] {"Reference"};
3332        case -445338488: /*groupIdentifier*/ return new String[] {"Identifier"};
3333        case -447282031: /*courseOfTherapyType*/ return new String[] {"CodeableConcept"};
3334        case 73049818: /*insurance*/ return new String[] {"Reference"};
3335        case 3387378: /*note*/ return new String[] {"Annotation"};
3336        case 1718902050: /*renderedDosageInstruction*/ return new String[] {"string"};
3337        case -1201373865: /*dosageInstruction*/ return new String[] {"Dosage"};
3338        case 824620658: /*dispenseRequest*/ return new String[] {};
3339        case 826147581: /*substitution*/ return new String[] {};
3340        case -486355964: /*priorPrescription*/ return new String[] {"Reference"};
3341        case 51602295: /*detectedIssue*/ return new String[] {"Reference"};
3342        case 1835190426: /*eventHistory*/ return new String[] {"Reference"};
3343        default: return super.getTypesForProperty(hash, name);
3344        }
3345
3346      }
3347
3348      @Override
3349      public Base addChild(String name) throws FHIRException {
3350        if (name.equals("identifier")) {
3351          return addIdentifier();
3352        }
3353        else if (name.equals("status")) {
3354          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.status");
3355        }
3356        else if (name.equals("statusReason")) {
3357          this.statusReason = new CodeableConcept();
3358          return this.statusReason;
3359        }
3360        else if (name.equals("intent")) {
3361          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.intent");
3362        }
3363        else if (name.equals("category")) {
3364          return addCategory();
3365        }
3366        else if (name.equals("priority")) {
3367          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.priority");
3368        }
3369        else if (name.equals("doNotPerform")) {
3370          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.doNotPerform");
3371        }
3372        else if (name.equals("reported")) {
3373          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.reported");
3374        }
3375        else if (name.equals("informationSource")) {
3376          this.informationSource = new Reference();
3377          return this.informationSource;
3378        }
3379        else if (name.equals("medicationCodeableConcept")) {
3380          this.medication = new CodeableConcept();
3381          return this.medication;
3382        }
3383        else if (name.equals("medicationReference")) {
3384          this.medication = new Reference();
3385          return this.medication;
3386        }
3387        else if (name.equals("subject")) {
3388          this.subject = new Reference();
3389          return this.subject;
3390        }
3391        else if (name.equals("encounter")) {
3392          this.encounter = new Reference();
3393          return this.encounter;
3394        }
3395        else if (name.equals("supportingInformation")) {
3396          return addSupportingInformation();
3397        }
3398        else if (name.equals("authoredOn")) {
3399          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.authoredOn");
3400        }
3401        else if (name.equals("requester")) {
3402          this.requester = new Reference();
3403          return this.requester;
3404        }
3405        else if (name.equals("performer")) {
3406          this.performer = new Reference();
3407          return this.performer;
3408        }
3409        else if (name.equals("performerType")) {
3410          this.performerType = new CodeableConcept();
3411          return this.performerType;
3412        }
3413        else if (name.equals("recorder")) {
3414          this.recorder = new Reference();
3415          return this.recorder;
3416        }
3417        else if (name.equals("reason")) {
3418          return addReason();
3419        }
3420        else if (name.equals("instantiatesCanonical")) {
3421          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.instantiatesCanonical");
3422        }
3423        else if (name.equals("instantiatesUri")) {
3424          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.instantiatesUri");
3425        }
3426        else if (name.equals("basedOn")) {
3427          return addBasedOn();
3428        }
3429        else if (name.equals("groupIdentifier")) {
3430          this.groupIdentifier = new Identifier();
3431          return this.groupIdentifier;
3432        }
3433        else if (name.equals("courseOfTherapyType")) {
3434          this.courseOfTherapyType = new CodeableConcept();
3435          return this.courseOfTherapyType;
3436        }
3437        else if (name.equals("insurance")) {
3438          return addInsurance();
3439        }
3440        else if (name.equals("note")) {
3441          return addNote();
3442        }
3443        else if (name.equals("renderedDosageInstruction")) {
3444          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.renderedDosageInstruction");
3445        }
3446        else if (name.equals("dosageInstruction")) {
3447          return addDosageInstruction();
3448        }
3449        else if (name.equals("dispenseRequest")) {
3450          this.dispenseRequest = new MedicationRequestDispenseRequestComponent();
3451          return this.dispenseRequest;
3452        }
3453        else if (name.equals("substitution")) {
3454          this.substitution = new MedicationRequestSubstitutionComponent();
3455          return this.substitution;
3456        }
3457        else if (name.equals("priorPrescription")) {
3458          this.priorPrescription = new Reference();
3459          return this.priorPrescription;
3460        }
3461        else if (name.equals("detectedIssue")) {
3462          return addDetectedIssue();
3463        }
3464        else if (name.equals("eventHistory")) {
3465          return addEventHistory();
3466        }
3467        else
3468          return super.addChild(name);
3469      }
3470
3471  public String fhirType() {
3472    return "MedicationRequest";
3473
3474  }
3475
3476      public MedicationRequest copy() {
3477        MedicationRequest dst = new MedicationRequest();
3478        copyValues(dst);
3479        return dst;
3480      }
3481
3482      public void copyValues(MedicationRequest dst) {
3483        super.copyValues(dst);
3484        if (identifier != null) {
3485          dst.identifier = new ArrayList<Identifier>();
3486          for (Identifier i : identifier)
3487            dst.identifier.add(i.copy());
3488        };
3489        dst.status = status == null ? null : status.copy();
3490        dst.statusReason = statusReason == null ? null : statusReason.copy();
3491        dst.intent = intent == null ? null : intent.copy();
3492        if (category != null) {
3493          dst.category = new ArrayList<CodeableConcept>();
3494          for (CodeableConcept i : category)
3495            dst.category.add(i.copy());
3496        };
3497        dst.priority = priority == null ? null : priority.copy();
3498        dst.doNotPerform = doNotPerform == null ? null : doNotPerform.copy();
3499        dst.reported = reported == null ? null : reported.copy();
3500        dst.informationSource = informationSource == null ? null : informationSource.copy();
3501        dst.medication = medication == null ? null : medication.copy();
3502        dst.subject = subject == null ? null : subject.copy();
3503        dst.encounter = encounter == null ? null : encounter.copy();
3504        if (supportingInformation != null) {
3505          dst.supportingInformation = new ArrayList<Reference>();
3506          for (Reference i : supportingInformation)
3507            dst.supportingInformation.add(i.copy());
3508        };
3509        dst.authoredOn = authoredOn == null ? null : authoredOn.copy();
3510        dst.requester = requester == null ? null : requester.copy();
3511        dst.performer = performer == null ? null : performer.copy();
3512        dst.performerType = performerType == null ? null : performerType.copy();
3513        dst.recorder = recorder == null ? null : recorder.copy();
3514        if (reason != null) {
3515          dst.reason = new ArrayList<CodeableReference>();
3516          for (CodeableReference i : reason)
3517            dst.reason.add(i.copy());
3518        };
3519        if (instantiatesCanonical != null) {
3520          dst.instantiatesCanonical = new ArrayList<CanonicalType>();
3521          for (CanonicalType i : instantiatesCanonical)
3522            dst.instantiatesCanonical.add(i.copy());
3523        };
3524        if (instantiatesUri != null) {
3525          dst.instantiatesUri = new ArrayList<UriType>();
3526          for (UriType i : instantiatesUri)
3527            dst.instantiatesUri.add(i.copy());
3528        };
3529        if (basedOn != null) {
3530          dst.basedOn = new ArrayList<Reference>();
3531          for (Reference i : basedOn)
3532            dst.basedOn.add(i.copy());
3533        };
3534        dst.groupIdentifier = groupIdentifier == null ? null : groupIdentifier.copy();
3535        dst.courseOfTherapyType = courseOfTherapyType == null ? null : courseOfTherapyType.copy();
3536        if (insurance != null) {
3537          dst.insurance = new ArrayList<Reference>();
3538          for (Reference i : insurance)
3539            dst.insurance.add(i.copy());
3540        };
3541        if (note != null) {
3542          dst.note = new ArrayList<Annotation>();
3543          for (Annotation i : note)
3544            dst.note.add(i.copy());
3545        };
3546        dst.renderedDosageInstruction = renderedDosageInstruction == null ? null : renderedDosageInstruction.copy();
3547        if (dosageInstruction != null) {
3548          dst.dosageInstruction = new ArrayList<Dosage>();
3549          for (Dosage i : dosageInstruction)
3550            dst.dosageInstruction.add(i.copy());
3551        };
3552        dst.dispenseRequest = dispenseRequest == null ? null : dispenseRequest.copy();
3553        dst.substitution = substitution == null ? null : substitution.copy();
3554        dst.priorPrescription = priorPrescription == null ? null : priorPrescription.copy();
3555        if (detectedIssue != null) {
3556          dst.detectedIssue = new ArrayList<Reference>();
3557          for (Reference i : detectedIssue)
3558            dst.detectedIssue.add(i.copy());
3559        };
3560        if (eventHistory != null) {
3561          dst.eventHistory = new ArrayList<Reference>();
3562          for (Reference i : eventHistory)
3563            dst.eventHistory.add(i.copy());
3564        };
3565      }
3566
3567      protected MedicationRequest typedCopy() {
3568        return copy();
3569      }
3570
3571      @Override
3572      public boolean equalsDeep(Base other_) {
3573        if (!super.equalsDeep(other_))
3574          return false;
3575        if (!(other_ instanceof MedicationRequest))
3576          return false;
3577        MedicationRequest o = (MedicationRequest) other_;
3578        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(statusReason, o.statusReason, true)
3579           && compareDeep(intent, o.intent, true) && compareDeep(category, o.category, true) && compareDeep(priority, o.priority, true)
3580           && compareDeep(doNotPerform, o.doNotPerform, true) && compareDeep(reported, o.reported, true) && compareDeep(informationSource, o.informationSource, true)
3581           && compareDeep(medication, o.medication, true) && compareDeep(subject, o.subject, true) && compareDeep(encounter, o.encounter, true)
3582           && compareDeep(supportingInformation, o.supportingInformation, true) && compareDeep(authoredOn, o.authoredOn, true)
3583           && compareDeep(requester, o.requester, true) && compareDeep(performer, o.performer, true) && compareDeep(performerType, o.performerType, true)
3584           && compareDeep(recorder, o.recorder, true) && compareDeep(reason, o.reason, true) && compareDeep(instantiatesCanonical, o.instantiatesCanonical, true)
3585           && compareDeep(instantiatesUri, o.instantiatesUri, true) && compareDeep(basedOn, o.basedOn, true)
3586           && compareDeep(groupIdentifier, o.groupIdentifier, true) && compareDeep(courseOfTherapyType, o.courseOfTherapyType, true)
3587           && compareDeep(insurance, o.insurance, true) && compareDeep(note, o.note, true) && compareDeep(renderedDosageInstruction, o.renderedDosageInstruction, true)
3588           && compareDeep(dosageInstruction, o.dosageInstruction, true) && compareDeep(dispenseRequest, o.dispenseRequest, true)
3589           && compareDeep(substitution, o.substitution, true) && compareDeep(priorPrescription, o.priorPrescription, true)
3590           && compareDeep(detectedIssue, o.detectedIssue, true) && compareDeep(eventHistory, o.eventHistory, true)
3591          ;
3592      }
3593
3594      @Override
3595      public boolean equalsShallow(Base other_) {
3596        if (!super.equalsShallow(other_))
3597          return false;
3598        if (!(other_ instanceof MedicationRequest))
3599          return false;
3600        MedicationRequest o = (MedicationRequest) other_;
3601        return compareValues(status, o.status, true) && compareValues(intent, o.intent, true) && compareValues(priority, o.priority, true)
3602           && compareValues(doNotPerform, o.doNotPerform, true) && compareValues(reported, o.reported, true) && compareValues(authoredOn, o.authoredOn, true)
3603           && compareValues(instantiatesCanonical, o.instantiatesCanonical, true) && compareValues(instantiatesUri, o.instantiatesUri, true)
3604           && compareValues(renderedDosageInstruction, o.renderedDosageInstruction, true);
3605      }
3606
3607      public boolean isEmpty() {
3608        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, statusReason
3609          , intent, category, priority, doNotPerform, reported, informationSource, medication
3610          , subject, encounter, supportingInformation, authoredOn, requester, performer, performerType
3611          , recorder, reason, instantiatesCanonical, instantiatesUri, basedOn, groupIdentifier
3612          , courseOfTherapyType, insurance, note, renderedDosageInstruction, dosageInstruction
3613          , dispenseRequest, substitution, priorPrescription, detectedIssue, eventHistory);
3614      }
3615
3616  @Override
3617  public ResourceType getResourceType() {
3618    return ResourceType.MedicationRequest;
3619   }
3620
3621 /**
3622   * Search parameter: <b>authoredon</b>
3623   * <p>
3624   * Description: <b>Return prescriptions written on this date</b><br>
3625   * Type: <b>date</b><br>
3626   * Path: <b>MedicationRequest.authoredOn</b><br>
3627   * </p>
3628   */
3629  @SearchParamDefinition(name="authoredon", path="MedicationRequest.authoredOn", description="Return prescriptions written on this date", type="date" )
3630  public static final String SP_AUTHOREDON = "authoredon";
3631 /**
3632   * <b>Fluent Client</b> search parameter constant for <b>authoredon</b>
3633   * <p>
3634   * Description: <b>Return prescriptions written on this date</b><br>
3635   * Type: <b>date</b><br>
3636   * Path: <b>MedicationRequest.authoredOn</b><br>
3637   * </p>
3638   */
3639  public static final ca.uhn.fhir.rest.gclient.DateClientParam AUTHOREDON = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_AUTHOREDON);
3640
3641 /**
3642   * Search parameter: <b>category</b>
3643   * <p>
3644   * Description: <b>Returns prescriptions with different categories</b><br>
3645   * Type: <b>token</b><br>
3646   * Path: <b>MedicationRequest.category</b><br>
3647   * </p>
3648   */
3649  @SearchParamDefinition(name="category", path="MedicationRequest.category", description="Returns prescriptions with different categories", type="token" )
3650  public static final String SP_CATEGORY = "category";
3651 /**
3652   * <b>Fluent Client</b> search parameter constant for <b>category</b>
3653   * <p>
3654   * Description: <b>Returns prescriptions with different categories</b><br>
3655   * Type: <b>token</b><br>
3656   * Path: <b>MedicationRequest.category</b><br>
3657   * </p>
3658   */
3659  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CATEGORY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CATEGORY);
3660
3661 /**
3662   * Search parameter: <b>intended-dispenser</b>
3663   * <p>
3664   * Description: <b>Returns prescriptions intended to be dispensed by this Organization</b><br>
3665   * Type: <b>reference</b><br>
3666   * Path: <b>MedicationRequest.dispenseRequest.dispenser</b><br>
3667   * </p>
3668   */
3669  @SearchParamDefinition(name="intended-dispenser", path="MedicationRequest.dispenseRequest.dispenser", description="Returns prescriptions intended to be dispensed by this Organization", type="reference", target={Organization.class } )
3670  public static final String SP_INTENDED_DISPENSER = "intended-dispenser";
3671 /**
3672   * <b>Fluent Client</b> search parameter constant for <b>intended-dispenser</b>
3673   * <p>
3674   * Description: <b>Returns prescriptions intended to be dispensed by this Organization</b><br>
3675   * Type: <b>reference</b><br>
3676   * Path: <b>MedicationRequest.dispenseRequest.dispenser</b><br>
3677   * </p>
3678   */
3679  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam INTENDED_DISPENSER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_INTENDED_DISPENSER);
3680
3681/**
3682   * Constant for fluent queries to be used to add include statements. Specifies
3683   * the path value of "<b>MedicationRequest:intended-dispenser</b>".
3684   */
3685  public static final ca.uhn.fhir.model.api.Include INCLUDE_INTENDED_DISPENSER = new ca.uhn.fhir.model.api.Include("MedicationRequest:intended-dispenser").toLocked();
3686
3687 /**
3688   * Search parameter: <b>intended-performer</b>
3689   * <p>
3690   * Description: <b>Returns the intended performer of the administration of the medication request</b><br>
3691   * Type: <b>reference</b><br>
3692   * Path: <b>MedicationRequest.performer</b><br>
3693   * </p>
3694   */
3695  @SearchParamDefinition(name="intended-performer", path="MedicationRequest.performer", description="Returns the intended performer of the administration of the medication request", type="reference", target={CareTeam.class, Device.class, HealthcareService.class, Organization.class, Patient.class, Practitioner.class, PractitionerRole.class, RelatedPerson.class } )
3696  public static final String SP_INTENDED_PERFORMER = "intended-performer";
3697 /**
3698   * <b>Fluent Client</b> search parameter constant for <b>intended-performer</b>
3699   * <p>
3700   * Description: <b>Returns the intended performer of the administration of the medication request</b><br>
3701   * Type: <b>reference</b><br>
3702   * Path: <b>MedicationRequest.performer</b><br>
3703   * </p>
3704   */
3705  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam INTENDED_PERFORMER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_INTENDED_PERFORMER);
3706
3707/**
3708   * Constant for fluent queries to be used to add include statements. Specifies
3709   * the path value of "<b>MedicationRequest:intended-performer</b>".
3710   */
3711  public static final ca.uhn.fhir.model.api.Include INCLUDE_INTENDED_PERFORMER = new ca.uhn.fhir.model.api.Include("MedicationRequest:intended-performer").toLocked();
3712
3713 /**
3714   * Search parameter: <b>intended-performertype</b>
3715   * <p>
3716   * Description: <b>Returns requests for a specific type of performer</b><br>
3717   * Type: <b>token</b><br>
3718   * Path: <b>MedicationRequest.performerType</b><br>
3719   * </p>
3720   */
3721  @SearchParamDefinition(name="intended-performertype", path="MedicationRequest.performerType", description="Returns requests for a specific type of performer", type="token" )
3722  public static final String SP_INTENDED_PERFORMERTYPE = "intended-performertype";
3723 /**
3724   * <b>Fluent Client</b> search parameter constant for <b>intended-performertype</b>
3725   * <p>
3726   * Description: <b>Returns requests for a specific type of performer</b><br>
3727   * Type: <b>token</b><br>
3728   * Path: <b>MedicationRequest.performerType</b><br>
3729   * </p>
3730   */
3731  public static final ca.uhn.fhir.rest.gclient.TokenClientParam INTENDED_PERFORMERTYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_INTENDED_PERFORMERTYPE);
3732
3733 /**
3734   * Search parameter: <b>intent</b>
3735   * <p>
3736   * Description: <b>Returns prescriptions with different intents</b><br>
3737   * Type: <b>token</b><br>
3738   * Path: <b>MedicationRequest.intent</b><br>
3739   * </p>
3740   */
3741  @SearchParamDefinition(name="intent", path="MedicationRequest.intent", description="Returns prescriptions with different intents", type="token" )
3742  public static final String SP_INTENT = "intent";
3743 /**
3744   * <b>Fluent Client</b> search parameter constant for <b>intent</b>
3745   * <p>
3746   * Description: <b>Returns prescriptions with different intents</b><br>
3747   * Type: <b>token</b><br>
3748   * Path: <b>MedicationRequest.intent</b><br>
3749   * </p>
3750   */
3751  public static final ca.uhn.fhir.rest.gclient.TokenClientParam INTENT = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_INTENT);
3752
3753 /**
3754   * Search parameter: <b>priority</b>
3755   * <p>
3756   * Description: <b>Returns prescriptions with different priorities</b><br>
3757   * Type: <b>token</b><br>
3758   * Path: <b>MedicationRequest.priority</b><br>
3759   * </p>
3760   */
3761  @SearchParamDefinition(name="priority", path="MedicationRequest.priority", description="Returns prescriptions with different priorities", type="token" )
3762  public static final String SP_PRIORITY = "priority";
3763 /**
3764   * <b>Fluent Client</b> search parameter constant for <b>priority</b>
3765   * <p>
3766   * Description: <b>Returns prescriptions with different priorities</b><br>
3767   * Type: <b>token</b><br>
3768   * Path: <b>MedicationRequest.priority</b><br>
3769   * </p>
3770   */
3771  public static final ca.uhn.fhir.rest.gclient.TokenClientParam PRIORITY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_PRIORITY);
3772
3773 /**
3774   * Search parameter: <b>requester</b>
3775   * <p>
3776   * Description: <b>Returns prescriptions prescribed by this prescriber</b><br>
3777   * Type: <b>reference</b><br>
3778   * Path: <b>MedicationRequest.requester</b><br>
3779   * </p>
3780   */
3781  @SearchParamDefinition(name="requester", path="MedicationRequest.requester", description="Returns prescriptions prescribed by this prescriber", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Base FHIR compartment definition for Practitioner") }, target={Device.class, Organization.class, Patient.class, Practitioner.class, PractitionerRole.class, RelatedPerson.class } )
3782  public static final String SP_REQUESTER = "requester";
3783 /**
3784   * <b>Fluent Client</b> search parameter constant for <b>requester</b>
3785   * <p>
3786   * Description: <b>Returns prescriptions prescribed by this prescriber</b><br>
3787   * Type: <b>reference</b><br>
3788   * Path: <b>MedicationRequest.requester</b><br>
3789   * </p>
3790   */
3791  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam REQUESTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_REQUESTER);
3792
3793/**
3794   * Constant for fluent queries to be used to add include statements. Specifies
3795   * the path value of "<b>MedicationRequest:requester</b>".
3796   */
3797  public static final ca.uhn.fhir.model.api.Include INCLUDE_REQUESTER = new ca.uhn.fhir.model.api.Include("MedicationRequest:requester").toLocked();
3798
3799 /**
3800   * Search parameter: <b>subject</b>
3801   * <p>
3802   * Description: <b>The identity of a patient to list orders  for</b><br>
3803   * Type: <b>reference</b><br>
3804   * Path: <b>MedicationRequest.subject</b><br>
3805   * </p>
3806   */
3807  @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="Base FHIR compartment definition for Patient") }, target={Group.class, Patient.class } )
3808  public static final String SP_SUBJECT = "subject";
3809 /**
3810   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
3811   * <p>
3812   * Description: <b>The identity of a patient to list orders  for</b><br>
3813   * Type: <b>reference</b><br>
3814   * Path: <b>MedicationRequest.subject</b><br>
3815   * </p>
3816   */
3817  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
3818
3819/**
3820   * Constant for fluent queries to be used to add include statements. Specifies
3821   * the path value of "<b>MedicationRequest:subject</b>".
3822   */
3823  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("MedicationRequest:subject").toLocked();
3824
3825 /**
3826   * Search parameter: <b>code</b>
3827   * <p>
3828   * Description: <b>Multiple Resources: 
3829
3830* [AllergyIntolerance](allergyintolerance.html): Code that identifies the allergy or intolerance
3831* [Condition](condition.html): Code for the condition
3832* [DeviceRequest](devicerequest.html): Code for what is being requested/ordered
3833* [DiagnosticReport](diagnosticreport.html): The code for the report, as opposed to codes for the atomic results, which are the names on the observation resource referred to from the result
3834* [FamilyMemberHistory](familymemberhistory.html): A search by a condition code
3835* [List](list.html): What the purpose of this list is
3836* [Medication](medication.html): Returns medications for a specific code
3837* [MedicationAdministration](medicationadministration.html): Return administrations of this medication code
3838* [MedicationDispense](medicationdispense.html): Returns dispenses of this medicine code
3839* [MedicationRequest](medicationrequest.html): Return prescriptions of this medication code
3840* [MedicationUsage](medicationusage.html): Return statements of this medication code
3841* [Observation](observation.html): The code of the observation type
3842* [Procedure](procedure.html): A code to identify a  procedure
3843* [ServiceRequest](servicerequest.html): What is being requested/ordered
3844</b><br>
3845   * Type: <b>token</b><br>
3846   * Path: <b>AllergyIntolerance.code | AllergyIntolerance.reaction.substance | Condition.code | (DeviceRequest.code as CodeableConcept) | DiagnosticReport.code | FamilyMemberHistory.condition.code | List.code | Medication.code | (MedicationAdministration.medication as CodeableConcept) | (MedicationDispense.medication as CodeableConcept) | (MedicationRequest.medication as CodeableConcept) | (MedicationUsage.medication as CodeableConcept) | Observation.code | Procedure.code | ServiceRequest.code</b><br>
3847   * </p>
3848   */
3849  @SearchParamDefinition(name="code", path="AllergyIntolerance.code | AllergyIntolerance.reaction.substance | Condition.code | (DeviceRequest.code as CodeableConcept) | DiagnosticReport.code | FamilyMemberHistory.condition.code | List.code | Medication.code | (MedicationAdministration.medication as CodeableConcept) | (MedicationDispense.medication as CodeableConcept) | (MedicationRequest.medication as CodeableConcept) | (MedicationUsage.medication as CodeableConcept) | Observation.code | Procedure.code | ServiceRequest.code", description="Multiple Resources: \r\n\r\n* [AllergyIntolerance](allergyintolerance.html): Code that identifies the allergy or intolerance\r\n* [Condition](condition.html): Code for the condition\r\n* [DeviceRequest](devicerequest.html): Code for what is being requested/ordered\r\n* [DiagnosticReport](diagnosticreport.html): The code for the report, as opposed to codes for the atomic results, which are the names on the observation resource referred to from the result\r\n* [FamilyMemberHistory](familymemberhistory.html): A search by a condition code\r\n* [List](list.html): What the purpose of this list is\r\n* [Medication](medication.html): Returns medications for a specific code\r\n* [MedicationAdministration](medicationadministration.html): Return administrations of this medication code\r\n* [MedicationDispense](medicationdispense.html): Returns dispenses of this medicine code\r\n* [MedicationRequest](medicationrequest.html): Return prescriptions of this medication code\r\n* [MedicationUsage](medicationusage.html): Return statements of this medication code\r\n* [Observation](observation.html): The code of the observation type\r\n* [Procedure](procedure.html): A code to identify a  procedure\r\n* [ServiceRequest](servicerequest.html): What is being requested/ordered\r\n", type="token" )
3850  public static final String SP_CODE = "code";
3851 /**
3852   * <b>Fluent Client</b> search parameter constant for <b>code</b>
3853   * <p>
3854   * Description: <b>Multiple Resources: 
3855
3856* [AllergyIntolerance](allergyintolerance.html): Code that identifies the allergy or intolerance
3857* [Condition](condition.html): Code for the condition
3858* [DeviceRequest](devicerequest.html): Code for what is being requested/ordered
3859* [DiagnosticReport](diagnosticreport.html): The code for the report, as opposed to codes for the atomic results, which are the names on the observation resource referred to from the result
3860* [FamilyMemberHistory](familymemberhistory.html): A search by a condition code
3861* [List](list.html): What the purpose of this list is
3862* [Medication](medication.html): Returns medications for a specific code
3863* [MedicationAdministration](medicationadministration.html): Return administrations of this medication code
3864* [MedicationDispense](medicationdispense.html): Returns dispenses of this medicine code
3865* [MedicationRequest](medicationrequest.html): Return prescriptions of this medication code
3866* [MedicationUsage](medicationusage.html): Return statements of this medication code
3867* [Observation](observation.html): The code of the observation type
3868* [Procedure](procedure.html): A code to identify a  procedure
3869* [ServiceRequest](servicerequest.html): What is being requested/ordered
3870</b><br>
3871   * Type: <b>token</b><br>
3872   * Path: <b>AllergyIntolerance.code | AllergyIntolerance.reaction.substance | Condition.code | (DeviceRequest.code as CodeableConcept) | DiagnosticReport.code | FamilyMemberHistory.condition.code | List.code | Medication.code | (MedicationAdministration.medication as CodeableConcept) | (MedicationDispense.medication as CodeableConcept) | (MedicationRequest.medication as CodeableConcept) | (MedicationUsage.medication as CodeableConcept) | Observation.code | Procedure.code | ServiceRequest.code</b><br>
3873   * </p>
3874   */
3875  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CODE);
3876
3877 /**
3878   * Search parameter: <b>identifier</b>
3879   * <p>
3880   * Description: <b>Multiple Resources: 
3881
3882* [AllergyIntolerance](allergyintolerance.html): External ids for this item
3883* [CarePlan](careplan.html): External Ids for this plan
3884* [CareTeam](careteam.html): External Ids for this team
3885* [Composition](composition.html): Version-independent identifier for the Composition
3886* [Condition](condition.html): A unique identifier of the condition record
3887* [Consent](consent.html): Identifier for this record (external references)
3888* [DetectedIssue](detectedissue.html): Unique id for the detected issue
3889* [DeviceRequest](devicerequest.html): Business identifier for request/order
3890* [DiagnosticReport](diagnosticreport.html): An identifier for the report
3891* [DocumentManifest](documentmanifest.html): Unique Identifier for the set of documents
3892* [DocumentReference](documentreference.html): Master Version Specific Identifier
3893* [Encounter](encounter.html): Identifier(s) by which this encounter is known
3894* [EpisodeOfCare](episodeofcare.html): Business Identifier(s) relevant for this EpisodeOfCare
3895* [FamilyMemberHistory](familymemberhistory.html): A search by a record identifier
3896* [Goal](goal.html): External Ids for this goal
3897* [ImagingStudy](imagingstudy.html): Identifiers for the Study, such as DICOM Study Instance UID and Accession number
3898* [Immunization](immunization.html): Business identifier
3899* [List](list.html): Business identifier
3900* [MedicationAdministration](medicationadministration.html): Return administrations with this external identifier
3901* [MedicationDispense](medicationdispense.html): Returns dispenses with this external identifier
3902* [MedicationRequest](medicationrequest.html): Return prescriptions with this external identifier
3903* [MedicationUsage](medicationusage.html): Return statements with this external identifier
3904* [NutritionOrder](nutritionorder.html): Return nutrition orders with this external identifier
3905* [Observation](observation.html): The unique id for a particular observation
3906* [Procedure](procedure.html): A unique identifier for a procedure
3907* [RiskAssessment](riskassessment.html): Unique identifier for the assessment
3908* [ServiceRequest](servicerequest.html): Identifiers assigned to this order
3909* [SupplyDelivery](supplydelivery.html): External identifier
3910* [SupplyRequest](supplyrequest.html): Business Identifier for SupplyRequest
3911* [VisionPrescription](visionprescription.html): Return prescriptions with this external identifier
3912</b><br>
3913   * Type: <b>token</b><br>
3914   * Path: <b>AllergyIntolerance.identifier | CarePlan.identifier | CareTeam.identifier | Composition.identifier | Condition.identifier | Consent.identifier | DetectedIssue.identifier | DeviceRequest.identifier | DiagnosticReport.identifier | DocumentManifest.masterIdentifier | DocumentManifest.identifier | DocumentReference.masterIdentifier | DocumentReference.identifier | Encounter.identifier | EpisodeOfCare.identifier | FamilyMemberHistory.identifier | Goal.identifier | ImagingStudy.identifier | Immunization.identifier | List.identifier | MedicationAdministration.identifier | MedicationDispense.identifier | MedicationRequest.identifier | MedicationUsage.identifier | NutritionOrder.identifier | Observation.identifier | Procedure.identifier | RiskAssessment.identifier | ServiceRequest.identifier | SupplyDelivery.identifier | SupplyRequest.identifier | VisionPrescription.identifier</b><br>
3915   * </p>
3916   */
3917  @SearchParamDefinition(name="identifier", path="AllergyIntolerance.identifier | CarePlan.identifier | CareTeam.identifier | Composition.identifier | Condition.identifier | Consent.identifier | DetectedIssue.identifier | DeviceRequest.identifier | DiagnosticReport.identifier | DocumentManifest.masterIdentifier | DocumentManifest.identifier | DocumentReference.masterIdentifier | DocumentReference.identifier | Encounter.identifier | EpisodeOfCare.identifier | FamilyMemberHistory.identifier | Goal.identifier | ImagingStudy.identifier | Immunization.identifier | List.identifier | MedicationAdministration.identifier | MedicationDispense.identifier | MedicationRequest.identifier | MedicationUsage.identifier | NutritionOrder.identifier | Observation.identifier | Procedure.identifier | RiskAssessment.identifier | ServiceRequest.identifier | SupplyDelivery.identifier | SupplyRequest.identifier | VisionPrescription.identifier", description="Multiple Resources: \r\n\r\n* [AllergyIntolerance](allergyintolerance.html): External ids for this item\r\n* [CarePlan](careplan.html): External Ids for this plan\r\n* [CareTeam](careteam.html): External Ids for this team\r\n* [Composition](composition.html): Version-independent identifier for the Composition\r\n* [Condition](condition.html): A unique identifier of the condition record\r\n* [Consent](consent.html): Identifier for this record (external references)\r\n* [DetectedIssue](detectedissue.html): Unique id for the detected issue\r\n* [DeviceRequest](devicerequest.html): Business identifier for request/order\r\n* [DiagnosticReport](diagnosticreport.html): An identifier for the report\r\n* [DocumentManifest](documentmanifest.html): Unique Identifier for the set of documents\r\n* [DocumentReference](documentreference.html): Master Version Specific Identifier\r\n* [Encounter](encounter.html): Identifier(s) by which this encounter is known\r\n* [EpisodeOfCare](episodeofcare.html): Business Identifier(s) relevant for this EpisodeOfCare\r\n* [FamilyMemberHistory](familymemberhistory.html): A search by a record identifier\r\n* [Goal](goal.html): External Ids for this goal\r\n* [ImagingStudy](imagingstudy.html): Identifiers for the Study, such as DICOM Study Instance UID and Accession number\r\n* [Immunization](immunization.html): Business identifier\r\n* [List](list.html): Business identifier\r\n* [MedicationAdministration](medicationadministration.html): Return administrations with this external identifier\r\n* [MedicationDispense](medicationdispense.html): Returns dispenses with this external identifier\r\n* [MedicationRequest](medicationrequest.html): Return prescriptions with this external identifier\r\n* [MedicationUsage](medicationusage.html): Return statements with this external identifier\r\n* [NutritionOrder](nutritionorder.html): Return nutrition orders with this external identifier\r\n* [Observation](observation.html): The unique id for a particular observation\r\n* [Procedure](procedure.html): A unique identifier for a procedure\r\n* [RiskAssessment](riskassessment.html): Unique identifier for the assessment\r\n* [ServiceRequest](servicerequest.html): Identifiers assigned to this order\r\n* [SupplyDelivery](supplydelivery.html): External identifier\r\n* [SupplyRequest](supplyrequest.html): Business Identifier for SupplyRequest\r\n* [VisionPrescription](visionprescription.html): Return prescriptions with this external identifier\r\n", type="token" )
3918  public static final String SP_IDENTIFIER = "identifier";
3919 /**
3920   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
3921   * <p>
3922   * Description: <b>Multiple Resources: 
3923
3924* [AllergyIntolerance](allergyintolerance.html): External ids for this item
3925* [CarePlan](careplan.html): External Ids for this plan
3926* [CareTeam](careteam.html): External Ids for this team
3927* [Composition](composition.html): Version-independent identifier for the Composition
3928* [Condition](condition.html): A unique identifier of the condition record
3929* [Consent](consent.html): Identifier for this record (external references)
3930* [DetectedIssue](detectedissue.html): Unique id for the detected issue
3931* [DeviceRequest](devicerequest.html): Business identifier for request/order
3932* [DiagnosticReport](diagnosticreport.html): An identifier for the report
3933* [DocumentManifest](documentmanifest.html): Unique Identifier for the set of documents
3934* [DocumentReference](documentreference.html): Master Version Specific Identifier
3935* [Encounter](encounter.html): Identifier(s) by which this encounter is known
3936* [EpisodeOfCare](episodeofcare.html): Business Identifier(s) relevant for this EpisodeOfCare
3937* [FamilyMemberHistory](familymemberhistory.html): A search by a record identifier
3938* [Goal](goal.html): External Ids for this goal
3939* [ImagingStudy](imagingstudy.html): Identifiers for the Study, such as DICOM Study Instance UID and Accession number
3940* [Immunization](immunization.html): Business identifier
3941* [List](list.html): Business identifier
3942* [MedicationAdministration](medicationadministration.html): Return administrations with this external identifier
3943* [MedicationDispense](medicationdispense.html): Returns dispenses with this external identifier
3944* [MedicationRequest](medicationrequest.html): Return prescriptions with this external identifier
3945* [MedicationUsage](medicationusage.html): Return statements with this external identifier
3946* [NutritionOrder](nutritionorder.html): Return nutrition orders with this external identifier
3947* [Observation](observation.html): The unique id for a particular observation
3948* [Procedure](procedure.html): A unique identifier for a procedure
3949* [RiskAssessment](riskassessment.html): Unique identifier for the assessment
3950* [ServiceRequest](servicerequest.html): Identifiers assigned to this order
3951* [SupplyDelivery](supplydelivery.html): External identifier
3952* [SupplyRequest](supplyrequest.html): Business Identifier for SupplyRequest
3953* [VisionPrescription](visionprescription.html): Return prescriptions with this external identifier
3954</b><br>
3955   * Type: <b>token</b><br>
3956   * Path: <b>AllergyIntolerance.identifier | CarePlan.identifier | CareTeam.identifier | Composition.identifier | Condition.identifier | Consent.identifier | DetectedIssue.identifier | DeviceRequest.identifier | DiagnosticReport.identifier | DocumentManifest.masterIdentifier | DocumentManifest.identifier | DocumentReference.masterIdentifier | DocumentReference.identifier | Encounter.identifier | EpisodeOfCare.identifier | FamilyMemberHistory.identifier | Goal.identifier | ImagingStudy.identifier | Immunization.identifier | List.identifier | MedicationAdministration.identifier | MedicationDispense.identifier | MedicationRequest.identifier | MedicationUsage.identifier | NutritionOrder.identifier | Observation.identifier | Procedure.identifier | RiskAssessment.identifier | ServiceRequest.identifier | SupplyDelivery.identifier | SupplyRequest.identifier | VisionPrescription.identifier</b><br>
3957   * </p>
3958   */
3959  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
3960
3961 /**
3962   * Search parameter: <b>patient</b>
3963   * <p>
3964   * Description: <b>Multiple Resources: 
3965
3966* [AllergyIntolerance](allergyintolerance.html): Who the sensitivity is for
3967* [CarePlan](careplan.html): Who the care plan is for
3968* [CareTeam](careteam.html): Who care team is for
3969* [ClinicalImpression](clinicalimpression.html): Patient or group assessed
3970* [Composition](composition.html): Who and/or what the composition is about
3971* [Condition](condition.html): Who has the condition?
3972* [Consent](consent.html): Who the consent applies to
3973* [DetectedIssue](detectedissue.html): Associated patient
3974* [DeviceRequest](devicerequest.html): Individual the service is ordered for
3975* [DeviceUseStatement](deviceusestatement.html): Search by subject - a patient
3976* [DiagnosticReport](diagnosticreport.html): The subject of the report if a patient
3977* [DocumentManifest](documentmanifest.html): The subject of the set of documents
3978* [DocumentReference](documentreference.html): Who/what is the subject of the document
3979* [Encounter](encounter.html): The patient or group present at the encounter
3980* [EpisodeOfCare](episodeofcare.html): The patient who is the focus of this episode of care
3981* [FamilyMemberHistory](familymemberhistory.html): The identity of a subject to list family member history items for
3982* [Flag](flag.html): The identity of a subject to list flags for
3983* [Goal](goal.html): Who this goal is intended for
3984* [ImagingStudy](imagingstudy.html): Who the study is about
3985* [Immunization](immunization.html): The patient for the vaccination record
3986* [List](list.html): If all resources have the same subject
3987* [MedicationAdministration](medicationadministration.html): The identity of a patient to list administrations  for
3988* [MedicationDispense](medicationdispense.html): The identity of a patient to list dispenses  for
3989* [MedicationRequest](medicationrequest.html): Returns prescriptions for a specific patient
3990* [MedicationUsage](medicationusage.html): Returns statements for a specific patient.
3991* [NutritionOrder](nutritionorder.html): The identity of the person who requires the diet, formula or nutritional supplement
3992* [Observation](observation.html): The subject that the observation is about (if patient)
3993* [Procedure](procedure.html): Search by subject - a patient
3994* [RiskAssessment](riskassessment.html): Who/what does assessment apply to?
3995* [ServiceRequest](servicerequest.html): Search by subject - a patient
3996* [SupplyDelivery](supplydelivery.html): Patient for whom the item is supplied
3997* [VisionPrescription](visionprescription.html): The identity of a patient to list dispenses for
3998</b><br>
3999   * Type: <b>reference</b><br>
4000   * Path: <b>AllergyIntolerance.patient | CarePlan.subject.where(resolve() is Patient) | CareTeam.subject.where(resolve() is Patient) | ClinicalImpression.subject.where(resolve() is Patient) | Composition.subject.where(resolve() is Patient) | Condition.subject.where(resolve() is Patient) | Consent.patient | DetectedIssue.patient | DeviceRequest.subject.where(resolve() is Patient) | DeviceUseStatement.subject | DiagnosticReport.subject.where(resolve() is Patient) | DocumentManifest.subject.where(resolve() is Patient) | DocumentReference.subject.where(resolve() is Patient) | Encounter.subject.where(resolve() is Patient) | EpisodeOfCare.patient | FamilyMemberHistory.patient | Flag.subject.where(resolve() is Patient) | Goal.subject.where(resolve() is Patient) | ImagingStudy.subject.where(resolve() is Patient) | Immunization.patient | List.subject.where(resolve() is Patient) | MedicationAdministration.subject.where(resolve() is Patient) | MedicationDispense.subject.where(resolve() is Patient) | MedicationRequest.subject.where(resolve() is Patient) | MedicationUsage.subject.where(resolve() is Patient) | NutritionOrder.patient | Observation.subject.where(resolve() is Patient) | Procedure.subject.where(resolve() is Patient) | RiskAssessment.subject.where(resolve() is Patient) | ServiceRequest.subject.where(resolve() is Patient) | SupplyDelivery.patient | VisionPrescription.patient</b><br>
4001   * </p>
4002   */
4003  @SearchParamDefinition(name="patient", path="AllergyIntolerance.patient | CarePlan.subject.where(resolve() is Patient) | CareTeam.subject.where(resolve() is Patient) | ClinicalImpression.subject.where(resolve() is Patient) | Composition.subject.where(resolve() is Patient) | Condition.subject.where(resolve() is Patient) | Consent.patient | DetectedIssue.patient | DeviceRequest.subject.where(resolve() is Patient) | DeviceUseStatement.subject | DiagnosticReport.subject.where(resolve() is Patient) | DocumentManifest.subject.where(resolve() is Patient) | DocumentReference.subject.where(resolve() is Patient) | Encounter.subject.where(resolve() is Patient) | EpisodeOfCare.patient | FamilyMemberHistory.patient | Flag.subject.where(resolve() is Patient) | Goal.subject.where(resolve() is Patient) | ImagingStudy.subject.where(resolve() is Patient) | Immunization.patient | List.subject.where(resolve() is Patient) | MedicationAdministration.subject.where(resolve() is Patient) | MedicationDispense.subject.where(resolve() is Patient) | MedicationRequest.subject.where(resolve() is Patient) | MedicationUsage.subject.where(resolve() is Patient) | NutritionOrder.patient | Observation.subject.where(resolve() is Patient) | Procedure.subject.where(resolve() is Patient) | RiskAssessment.subject.where(resolve() is Patient) | ServiceRequest.subject.where(resolve() is Patient) | SupplyDelivery.patient | VisionPrescription.patient", description="Multiple Resources: \r\n\r\n* [AllergyIntolerance](allergyintolerance.html): Who the sensitivity is for\r\n* [CarePlan](careplan.html): Who the care plan is for\r\n* [CareTeam](careteam.html): Who care team is for\r\n* [ClinicalImpression](clinicalimpression.html): Patient or group assessed\r\n* [Composition](composition.html): Who and/or what the composition is about\r\n* [Condition](condition.html): Who has the condition?\r\n* [Consent](consent.html): Who the consent applies to\r\n* [DetectedIssue](detectedissue.html): Associated patient\r\n* [DeviceRequest](devicerequest.html): Individual the service is ordered for\r\n* [DeviceUseStatement](deviceusestatement.html): Search by subject - a patient\r\n* [DiagnosticReport](diagnosticreport.html): The subject of the report if a patient\r\n* [DocumentManifest](documentmanifest.html): The subject of the set of documents\r\n* [DocumentReference](documentreference.html): Who/what is the subject of the document\r\n* [Encounter](encounter.html): The patient or group present at the encounter\r\n* [EpisodeOfCare](episodeofcare.html): The patient who is the focus of this episode of care\r\n* [FamilyMemberHistory](familymemberhistory.html): The identity of a subject to list family member history items for\r\n* [Flag](flag.html): The identity of a subject to list flags for\r\n* [Goal](goal.html): Who this goal is intended for\r\n* [ImagingStudy](imagingstudy.html): Who the study is about\r\n* [Immunization](immunization.html): The patient for the vaccination record\r\n* [List](list.html): If all resources have the same subject\r\n* [MedicationAdministration](medicationadministration.html): The identity of a patient to list administrations  for\r\n* [MedicationDispense](medicationdispense.html): The identity of a patient to list dispenses  for\r\n* [MedicationRequest](medicationrequest.html): Returns prescriptions for a specific patient\r\n* [MedicationUsage](medicationusage.html): Returns statements for a specific patient.\r\n* [NutritionOrder](nutritionorder.html): The identity of the person who requires the diet, formula or nutritional supplement\r\n* [Observation](observation.html): The subject that the observation is about (if patient)\r\n* [Procedure](procedure.html): Search by subject - a patient\r\n* [RiskAssessment](riskassessment.html): Who/what does assessment apply to?\r\n* [ServiceRequest](servicerequest.html): Search by subject - a patient\r\n* [SupplyDelivery](supplydelivery.html): Patient for whom the item is supplied\r\n* [VisionPrescription](visionprescription.html): The identity of a patient to list dispenses for\r\n", type="reference", target={Group.class, Patient.class } )
4004  public static final String SP_PATIENT = "patient";
4005 /**
4006   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
4007   * <p>
4008   * Description: <b>Multiple Resources: 
4009
4010* [AllergyIntolerance](allergyintolerance.html): Who the sensitivity is for
4011* [CarePlan](careplan.html): Who the care plan is for
4012* [CareTeam](careteam.html): Who care team is for
4013* [ClinicalImpression](clinicalimpression.html): Patient or group assessed
4014* [Composition](composition.html): Who and/or what the composition is about
4015* [Condition](condition.html): Who has the condition?
4016* [Consent](consent.html): Who the consent applies to
4017* [DetectedIssue](detectedissue.html): Associated patient
4018* [DeviceRequest](devicerequest.html): Individual the service is ordered for
4019* [DeviceUseStatement](deviceusestatement.html): Search by subject - a patient
4020* [DiagnosticReport](diagnosticreport.html): The subject of the report if a patient
4021* [DocumentManifest](documentmanifest.html): The subject of the set of documents
4022* [DocumentReference](documentreference.html): Who/what is the subject of the document
4023* [Encounter](encounter.html): The patient or group present at the encounter
4024* [EpisodeOfCare](episodeofcare.html): The patient who is the focus of this episode of care
4025* [FamilyMemberHistory](familymemberhistory.html): The identity of a subject to list family member history items for
4026* [Flag](flag.html): The identity of a subject to list flags for
4027* [Goal](goal.html): Who this goal is intended for
4028* [ImagingStudy](imagingstudy.html): Who the study is about
4029* [Immunization](immunization.html): The patient for the vaccination record
4030* [List](list.html): If all resources have the same subject
4031* [MedicationAdministration](medicationadministration.html): The identity of a patient to list administrations  for
4032* [MedicationDispense](medicationdispense.html): The identity of a patient to list dispenses  for
4033* [MedicationRequest](medicationrequest.html): Returns prescriptions for a specific patient
4034* [MedicationUsage](medicationusage.html): Returns statements for a specific patient.
4035* [NutritionOrder](nutritionorder.html): The identity of the person who requires the diet, formula or nutritional supplement
4036* [Observation](observation.html): The subject that the observation is about (if patient)
4037* [Procedure](procedure.html): Search by subject - a patient
4038* [RiskAssessment](riskassessment.html): Who/what does assessment apply to?
4039* [ServiceRequest](servicerequest.html): Search by subject - a patient
4040* [SupplyDelivery](supplydelivery.html): Patient for whom the item is supplied
4041* [VisionPrescription](visionprescription.html): The identity of a patient to list dispenses for
4042</b><br>
4043   * Type: <b>reference</b><br>
4044   * Path: <b>AllergyIntolerance.patient | CarePlan.subject.where(resolve() is Patient) | CareTeam.subject.where(resolve() is Patient) | ClinicalImpression.subject.where(resolve() is Patient) | Composition.subject.where(resolve() is Patient) | Condition.subject.where(resolve() is Patient) | Consent.patient | DetectedIssue.patient | DeviceRequest.subject.where(resolve() is Patient) | DeviceUseStatement.subject | DiagnosticReport.subject.where(resolve() is Patient) | DocumentManifest.subject.where(resolve() is Patient) | DocumentReference.subject.where(resolve() is Patient) | Encounter.subject.where(resolve() is Patient) | EpisodeOfCare.patient | FamilyMemberHistory.patient | Flag.subject.where(resolve() is Patient) | Goal.subject.where(resolve() is Patient) | ImagingStudy.subject.where(resolve() is Patient) | Immunization.patient | List.subject.where(resolve() is Patient) | MedicationAdministration.subject.where(resolve() is Patient) | MedicationDispense.subject.where(resolve() is Patient) | MedicationRequest.subject.where(resolve() is Patient) | MedicationUsage.subject.where(resolve() is Patient) | NutritionOrder.patient | Observation.subject.where(resolve() is Patient) | Procedure.subject.where(resolve() is Patient) | RiskAssessment.subject.where(resolve() is Patient) | ServiceRequest.subject.where(resolve() is Patient) | SupplyDelivery.patient | VisionPrescription.patient</b><br>
4045   * </p>
4046   */
4047  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
4048
4049/**
4050   * Constant for fluent queries to be used to add include statements. Specifies
4051   * the path value of "<b>MedicationRequest:patient</b>".
4052   */
4053  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("MedicationRequest:patient").toLocked();
4054
4055 /**
4056   * Search parameter: <b>date</b>
4057   * <p>
4058   * Description: <b>Multiple Resources: 
4059
4060* [MedicationAdministration](medicationadministration.html): Date administration happened (or did not happen)
4061* [MedicationRequest](medicationrequest.html): Returns medication request to be administered on a specific date
4062</b><br>
4063   * Type: <b>date</b><br>
4064   * Path: <b>MedicationAdministration.occurence | MedicationRequest.dosageInstruction.timing.event</b><br>
4065   * </p>
4066   */
4067  @SearchParamDefinition(name="date", path="MedicationAdministration.occurence | MedicationRequest.dosageInstruction.timing.event", description="Multiple Resources: \r\n\r\n* [MedicationAdministration](medicationadministration.html): Date administration happened (or did not happen)\r\n* [MedicationRequest](medicationrequest.html): Returns medication request to be administered on a specific date\r\n", type="date" )
4068  public static final String SP_DATE = "date";
4069 /**
4070   * <b>Fluent Client</b> search parameter constant for <b>date</b>
4071   * <p>
4072   * Description: <b>Multiple Resources: 
4073
4074* [MedicationAdministration](medicationadministration.html): Date administration happened (or did not happen)
4075* [MedicationRequest](medicationrequest.html): Returns medication request to be administered on a specific date
4076</b><br>
4077   * Type: <b>date</b><br>
4078   * Path: <b>MedicationAdministration.occurence | MedicationRequest.dosageInstruction.timing.event</b><br>
4079   * </p>
4080   */
4081  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATE);
4082
4083 /**
4084   * Search parameter: <b>encounter</b>
4085   * <p>
4086   * Description: <b>Multiple Resources: 
4087
4088* [MedicationAdministration](medicationadministration.html): Return administrations that share this encounter
4089* [MedicationRequest](medicationrequest.html): Return prescriptions with this encounter identifier
4090</b><br>
4091   * Type: <b>reference</b><br>
4092   * Path: <b>MedicationAdministration.encounter | MedicationRequest.encounter</b><br>
4093   * </p>
4094   */
4095  @SearchParamDefinition(name="encounter", path="MedicationAdministration.encounter | MedicationRequest.encounter", description="Multiple Resources: \r\n\r\n* [MedicationAdministration](medicationadministration.html): Return administrations that share this encounter\r\n* [MedicationRequest](medicationrequest.html): Return prescriptions with this encounter identifier\r\n", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Base FHIR compartment definition for Encounter") }, target={Encounter.class } )
4096  public static final String SP_ENCOUNTER = "encounter";
4097 /**
4098   * <b>Fluent Client</b> search parameter constant for <b>encounter</b>
4099   * <p>
4100   * Description: <b>Multiple Resources: 
4101
4102* [MedicationAdministration](medicationadministration.html): Return administrations that share this encounter
4103* [MedicationRequest](medicationrequest.html): Return prescriptions with this encounter identifier
4104</b><br>
4105   * Type: <b>reference</b><br>
4106   * Path: <b>MedicationAdministration.encounter | MedicationRequest.encounter</b><br>
4107   * </p>
4108   */
4109  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENCOUNTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENCOUNTER);
4110
4111/**
4112   * Constant for fluent queries to be used to add include statements. Specifies
4113   * the path value of "<b>MedicationRequest:encounter</b>".
4114   */
4115  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENCOUNTER = new ca.uhn.fhir.model.api.Include("MedicationRequest:encounter").toLocked();
4116
4117 /**
4118   * Search parameter: <b>medication</b>
4119   * <p>
4120   * Description: <b>Multiple Resources: 
4121
4122* [MedicationAdministration](medicationadministration.html): Return administrations of this medication resource
4123* [MedicationDispense](medicationdispense.html): Returns dispenses of this medicine resource
4124* [MedicationRequest](medicationrequest.html): Return prescriptions for this medication reference
4125* [MedicationUsage](medicationusage.html): Return statements of this medication reference
4126</b><br>
4127   * Type: <b>reference</b><br>
4128   * Path: <b>(MedicationAdministration.medication as Reference) | (MedicationDispense.medication as Reference) | (MedicationRequest.medication as Reference) | (MedicationUsage.medication as Reference)</b><br>
4129   * </p>
4130   */
4131  @SearchParamDefinition(name="medication", path="(MedicationAdministration.medication as Reference) | (MedicationDispense.medication as Reference) | (MedicationRequest.medication as Reference) | (MedicationUsage.medication as Reference)", description="Multiple Resources: \r\n\r\n* [MedicationAdministration](medicationadministration.html): Return administrations of this medication resource\r\n* [MedicationDispense](medicationdispense.html): Returns dispenses of this medicine resource\r\n* [MedicationRequest](medicationrequest.html): Return prescriptions for this medication reference\r\n* [MedicationUsage](medicationusage.html): Return statements of this medication reference\r\n", type="reference", target={Medication.class } )
4132  public static final String SP_MEDICATION = "medication";
4133 /**
4134   * <b>Fluent Client</b> search parameter constant for <b>medication</b>
4135   * <p>
4136   * Description: <b>Multiple Resources: 
4137
4138* [MedicationAdministration](medicationadministration.html): Return administrations of this medication resource
4139* [MedicationDispense](medicationdispense.html): Returns dispenses of this medicine resource
4140* [MedicationRequest](medicationrequest.html): Return prescriptions for this medication reference
4141* [MedicationUsage](medicationusage.html): Return statements of this medication reference
4142</b><br>
4143   * Type: <b>reference</b><br>
4144   * Path: <b>(MedicationAdministration.medication as Reference) | (MedicationDispense.medication as Reference) | (MedicationRequest.medication as Reference) | (MedicationUsage.medication as Reference)</b><br>
4145   * </p>
4146   */
4147  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam MEDICATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_MEDICATION);
4148
4149/**
4150   * Constant for fluent queries to be used to add include statements. Specifies
4151   * the path value of "<b>MedicationRequest:medication</b>".
4152   */
4153  public static final ca.uhn.fhir.model.api.Include INCLUDE_MEDICATION = new ca.uhn.fhir.model.api.Include("MedicationRequest:medication").toLocked();
4154
4155 /**
4156   * Search parameter: <b>status</b>
4157   * <p>
4158   * Description: <b>Multiple Resources: 
4159
4160* [MedicationAdministration](medicationadministration.html): MedicationAdministration event status (for example one of active/paused/completed/nullified)
4161* [MedicationDispense](medicationdispense.html): Returns dispenses with a specified dispense status
4162* [MedicationRequest](medicationrequest.html): Status of the prescription
4163* [MedicationUsage](medicationusage.html): Return statements that match the given status
4164</b><br>
4165   * Type: <b>token</b><br>
4166   * Path: <b>MedicationAdministration.status | MedicationDispense.status | MedicationRequest.status | MedicationUsage.status</b><br>
4167   * </p>
4168   */
4169  @SearchParamDefinition(name="status", path="MedicationAdministration.status | MedicationDispense.status | MedicationRequest.status | MedicationUsage.status", description="Multiple Resources: \r\n\r\n* [MedicationAdministration](medicationadministration.html): MedicationAdministration event status (for example one of active/paused/completed/nullified)\r\n* [MedicationDispense](medicationdispense.html): Returns dispenses with a specified dispense status\r\n* [MedicationRequest](medicationrequest.html): Status of the prescription\r\n* [MedicationUsage](medicationusage.html): Return statements that match the given status\r\n", type="token" )
4170  public static final String SP_STATUS = "status";
4171 /**
4172   * <b>Fluent Client</b> search parameter constant for <b>status</b>
4173   * <p>
4174   * Description: <b>Multiple Resources: 
4175
4176* [MedicationAdministration](medicationadministration.html): MedicationAdministration event status (for example one of active/paused/completed/nullified)
4177* [MedicationDispense](medicationdispense.html): Returns dispenses with a specified dispense status
4178* [MedicationRequest](medicationrequest.html): Status of the prescription
4179* [MedicationUsage](medicationusage.html): Return statements that match the given status
4180</b><br>
4181   * Type: <b>token</b><br>
4182   * Path: <b>MedicationAdministration.status | MedicationDispense.status | MedicationRequest.status | MedicationUsage.status</b><br>
4183   * </p>
4184   */
4185  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
4186
4187
4188}
4189