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