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