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