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