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