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