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