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