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