001package org.hl7.fhir.dstu2016may.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
033import java.util.ArrayList;
034import java.util.Date;
035import java.util.List;
036
037import org.hl7.fhir.exceptions.FHIRException;
038
039import ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.Description;
041import ca.uhn.fhir.model.api.annotation.ResourceDef;
042import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
043/**
044 * A request for a procedure to be performed. May be a proposal or an order.
045 */
046@ResourceDef(name="ProcedureRequest", profile="http://hl7.org/fhir/Profile/ProcedureRequest")
047public class ProcedureRequest extends DomainResource {
048
049    public enum ProcedureRequestStatus {
050        /**
051         * The request has been proposed.
052         */
053        PROPOSED, 
054        /**
055         * The request is in preliminary form, prior to being requested.
056         */
057        DRAFT, 
058        /**
059         * The request has been placed.
060         */
061        REQUESTED, 
062        /**
063         * The receiving system has received the request but not yet decided whether it will be performed.
064         */
065        RECEIVED, 
066        /**
067         * The receiving system has accepted the request, but work has not yet commenced.
068         */
069        ACCEPTED, 
070        /**
071         * The work to fulfill the request is happening.
072         */
073        INPROGRESS, 
074        /**
075         * The work has been completed, the report(s) released, and no further work is planned.
076         */
077        COMPLETED, 
078        /**
079         * The request has been held by originating system/user request.
080         */
081        SUSPENDED, 
082        /**
083         * The receiving system has declined to fulfill the request.
084         */
085        REJECTED, 
086        /**
087         * The request was attempted, but due to some procedural error, it could not be completed.
088         */
089        ABORTED, 
090        /**
091         * added to help the parsers
092         */
093        NULL;
094        public static ProcedureRequestStatus fromCode(String codeString) throws FHIRException {
095            if (codeString == null || "".equals(codeString))
096                return null;
097        if ("proposed".equals(codeString))
098          return PROPOSED;
099        if ("draft".equals(codeString))
100          return DRAFT;
101        if ("requested".equals(codeString))
102          return REQUESTED;
103        if ("received".equals(codeString))
104          return RECEIVED;
105        if ("accepted".equals(codeString))
106          return ACCEPTED;
107        if ("in-progress".equals(codeString))
108          return INPROGRESS;
109        if ("completed".equals(codeString))
110          return COMPLETED;
111        if ("suspended".equals(codeString))
112          return SUSPENDED;
113        if ("rejected".equals(codeString))
114          return REJECTED;
115        if ("aborted".equals(codeString))
116          return ABORTED;
117        throw new FHIRException("Unknown ProcedureRequestStatus code '"+codeString+"'");
118        }
119        public String toCode() {
120          switch (this) {
121            case PROPOSED: return "proposed";
122            case DRAFT: return "draft";
123            case REQUESTED: return "requested";
124            case RECEIVED: return "received";
125            case ACCEPTED: return "accepted";
126            case INPROGRESS: return "in-progress";
127            case COMPLETED: return "completed";
128            case SUSPENDED: return "suspended";
129            case REJECTED: return "rejected";
130            case ABORTED: return "aborted";
131            default: return "?";
132          }
133        }
134        public String getSystem() {
135          switch (this) {
136            case PROPOSED: return "http://hl7.org/fhir/procedure-request-status";
137            case DRAFT: return "http://hl7.org/fhir/procedure-request-status";
138            case REQUESTED: return "http://hl7.org/fhir/procedure-request-status";
139            case RECEIVED: return "http://hl7.org/fhir/procedure-request-status";
140            case ACCEPTED: return "http://hl7.org/fhir/procedure-request-status";
141            case INPROGRESS: return "http://hl7.org/fhir/procedure-request-status";
142            case COMPLETED: return "http://hl7.org/fhir/procedure-request-status";
143            case SUSPENDED: return "http://hl7.org/fhir/procedure-request-status";
144            case REJECTED: return "http://hl7.org/fhir/procedure-request-status";
145            case ABORTED: return "http://hl7.org/fhir/procedure-request-status";
146            default: return "?";
147          }
148        }
149        public String getDefinition() {
150          switch (this) {
151            case PROPOSED: return "The request has been proposed.";
152            case DRAFT: return "The request is in preliminary form, prior to being requested.";
153            case REQUESTED: return "The request has been placed.";
154            case RECEIVED: return "The receiving system has received the request but not yet decided whether it will be performed.";
155            case ACCEPTED: return "The receiving system has accepted the request, but work has not yet commenced.";
156            case INPROGRESS: return "The work to fulfill the request is happening.";
157            case COMPLETED: return "The work has been completed, the report(s) released, and no further work is planned.";
158            case SUSPENDED: return "The request has been held by originating system/user request.";
159            case REJECTED: return "The receiving system has declined to fulfill the request.";
160            case ABORTED: return "The request was attempted, but due to some procedural error, it could not be completed.";
161            default: return "?";
162          }
163        }
164        public String getDisplay() {
165          switch (this) {
166            case PROPOSED: return "Proposed";
167            case DRAFT: return "Draft";
168            case REQUESTED: return "Requested";
169            case RECEIVED: return "Received";
170            case ACCEPTED: return "Accepted";
171            case INPROGRESS: return "In Progress";
172            case COMPLETED: return "Completed";
173            case SUSPENDED: return "Suspended";
174            case REJECTED: return "Rejected";
175            case ABORTED: return "Aborted";
176            default: return "?";
177          }
178        }
179    }
180
181  public static class ProcedureRequestStatusEnumFactory implements EnumFactory<ProcedureRequestStatus> {
182    public ProcedureRequestStatus fromCode(String codeString) throws IllegalArgumentException {
183      if (codeString == null || "".equals(codeString))
184            if (codeString == null || "".equals(codeString))
185                return null;
186        if ("proposed".equals(codeString))
187          return ProcedureRequestStatus.PROPOSED;
188        if ("draft".equals(codeString))
189          return ProcedureRequestStatus.DRAFT;
190        if ("requested".equals(codeString))
191          return ProcedureRequestStatus.REQUESTED;
192        if ("received".equals(codeString))
193          return ProcedureRequestStatus.RECEIVED;
194        if ("accepted".equals(codeString))
195          return ProcedureRequestStatus.ACCEPTED;
196        if ("in-progress".equals(codeString))
197          return ProcedureRequestStatus.INPROGRESS;
198        if ("completed".equals(codeString))
199          return ProcedureRequestStatus.COMPLETED;
200        if ("suspended".equals(codeString))
201          return ProcedureRequestStatus.SUSPENDED;
202        if ("rejected".equals(codeString))
203          return ProcedureRequestStatus.REJECTED;
204        if ("aborted".equals(codeString))
205          return ProcedureRequestStatus.ABORTED;
206        throw new IllegalArgumentException("Unknown ProcedureRequestStatus code '"+codeString+"'");
207        }
208        public Enumeration<ProcedureRequestStatus> fromType(Base code) throws FHIRException {
209          if (code == null || code.isEmpty())
210            return null;
211          String codeString = ((PrimitiveType) code).asStringValue();
212          if (codeString == null || "".equals(codeString))
213            return null;
214        if ("proposed".equals(codeString))
215          return new Enumeration<ProcedureRequestStatus>(this, ProcedureRequestStatus.PROPOSED);
216        if ("draft".equals(codeString))
217          return new Enumeration<ProcedureRequestStatus>(this, ProcedureRequestStatus.DRAFT);
218        if ("requested".equals(codeString))
219          return new Enumeration<ProcedureRequestStatus>(this, ProcedureRequestStatus.REQUESTED);
220        if ("received".equals(codeString))
221          return new Enumeration<ProcedureRequestStatus>(this, ProcedureRequestStatus.RECEIVED);
222        if ("accepted".equals(codeString))
223          return new Enumeration<ProcedureRequestStatus>(this, ProcedureRequestStatus.ACCEPTED);
224        if ("in-progress".equals(codeString))
225          return new Enumeration<ProcedureRequestStatus>(this, ProcedureRequestStatus.INPROGRESS);
226        if ("completed".equals(codeString))
227          return new Enumeration<ProcedureRequestStatus>(this, ProcedureRequestStatus.COMPLETED);
228        if ("suspended".equals(codeString))
229          return new Enumeration<ProcedureRequestStatus>(this, ProcedureRequestStatus.SUSPENDED);
230        if ("rejected".equals(codeString))
231          return new Enumeration<ProcedureRequestStatus>(this, ProcedureRequestStatus.REJECTED);
232        if ("aborted".equals(codeString))
233          return new Enumeration<ProcedureRequestStatus>(this, ProcedureRequestStatus.ABORTED);
234        throw new FHIRException("Unknown ProcedureRequestStatus code '"+codeString+"'");
235        }
236    public String toCode(ProcedureRequestStatus code) {
237      if (code == ProcedureRequestStatus.PROPOSED)
238        return "proposed";
239      if (code == ProcedureRequestStatus.DRAFT)
240        return "draft";
241      if (code == ProcedureRequestStatus.REQUESTED)
242        return "requested";
243      if (code == ProcedureRequestStatus.RECEIVED)
244        return "received";
245      if (code == ProcedureRequestStatus.ACCEPTED)
246        return "accepted";
247      if (code == ProcedureRequestStatus.INPROGRESS)
248        return "in-progress";
249      if (code == ProcedureRequestStatus.COMPLETED)
250        return "completed";
251      if (code == ProcedureRequestStatus.SUSPENDED)
252        return "suspended";
253      if (code == ProcedureRequestStatus.REJECTED)
254        return "rejected";
255      if (code == ProcedureRequestStatus.ABORTED)
256        return "aborted";
257      return "?";
258      }
259    public String toSystem(ProcedureRequestStatus code) {
260      return code.getSystem();
261      }
262    }
263
264    public enum ProcedureRequestPriority {
265        /**
266         * The request has a normal priority.
267         */
268        ROUTINE, 
269        /**
270         * The request should be done urgently.
271         */
272        URGENT, 
273        /**
274         * The request is time-critical.
275         */
276        STAT, 
277        /**
278         * The request should be acted on as soon as possible.
279         */
280        ASAP, 
281        /**
282         * added to help the parsers
283         */
284        NULL;
285        public static ProcedureRequestPriority fromCode(String codeString) throws FHIRException {
286            if (codeString == null || "".equals(codeString))
287                return null;
288        if ("routine".equals(codeString))
289          return ROUTINE;
290        if ("urgent".equals(codeString))
291          return URGENT;
292        if ("stat".equals(codeString))
293          return STAT;
294        if ("asap".equals(codeString))
295          return ASAP;
296        throw new FHIRException("Unknown ProcedureRequestPriority code '"+codeString+"'");
297        }
298        public String toCode() {
299          switch (this) {
300            case ROUTINE: return "routine";
301            case URGENT: return "urgent";
302            case STAT: return "stat";
303            case ASAP: return "asap";
304            default: return "?";
305          }
306        }
307        public String getSystem() {
308          switch (this) {
309            case ROUTINE: return "http://hl7.org/fhir/procedure-request-priority";
310            case URGENT: return "http://hl7.org/fhir/procedure-request-priority";
311            case STAT: return "http://hl7.org/fhir/procedure-request-priority";
312            case ASAP: return "http://hl7.org/fhir/procedure-request-priority";
313            default: return "?";
314          }
315        }
316        public String getDefinition() {
317          switch (this) {
318            case ROUTINE: return "The request has a normal priority.";
319            case URGENT: return "The request should be done urgently.";
320            case STAT: return "The request is time-critical.";
321            case ASAP: return "The request should be acted on as soon as possible.";
322            default: return "?";
323          }
324        }
325        public String getDisplay() {
326          switch (this) {
327            case ROUTINE: return "Routine";
328            case URGENT: return "Urgent";
329            case STAT: return "Stat";
330            case ASAP: return "ASAP";
331            default: return "?";
332          }
333        }
334    }
335
336  public static class ProcedureRequestPriorityEnumFactory implements EnumFactory<ProcedureRequestPriority> {
337    public ProcedureRequestPriority fromCode(String codeString) throws IllegalArgumentException {
338      if (codeString == null || "".equals(codeString))
339            if (codeString == null || "".equals(codeString))
340                return null;
341        if ("routine".equals(codeString))
342          return ProcedureRequestPriority.ROUTINE;
343        if ("urgent".equals(codeString))
344          return ProcedureRequestPriority.URGENT;
345        if ("stat".equals(codeString))
346          return ProcedureRequestPriority.STAT;
347        if ("asap".equals(codeString))
348          return ProcedureRequestPriority.ASAP;
349        throw new IllegalArgumentException("Unknown ProcedureRequestPriority code '"+codeString+"'");
350        }
351        public Enumeration<ProcedureRequestPriority> fromType(Base code) throws FHIRException {
352          if (code == null || code.isEmpty())
353            return null;
354          String codeString = ((PrimitiveType) code).asStringValue();
355          if (codeString == null || "".equals(codeString))
356            return null;
357        if ("routine".equals(codeString))
358          return new Enumeration<ProcedureRequestPriority>(this, ProcedureRequestPriority.ROUTINE);
359        if ("urgent".equals(codeString))
360          return new Enumeration<ProcedureRequestPriority>(this, ProcedureRequestPriority.URGENT);
361        if ("stat".equals(codeString))
362          return new Enumeration<ProcedureRequestPriority>(this, ProcedureRequestPriority.STAT);
363        if ("asap".equals(codeString))
364          return new Enumeration<ProcedureRequestPriority>(this, ProcedureRequestPriority.ASAP);
365        throw new FHIRException("Unknown ProcedureRequestPriority code '"+codeString+"'");
366        }
367    public String toCode(ProcedureRequestPriority code) {
368      if (code == ProcedureRequestPriority.ROUTINE)
369        return "routine";
370      if (code == ProcedureRequestPriority.URGENT)
371        return "urgent";
372      if (code == ProcedureRequestPriority.STAT)
373        return "stat";
374      if (code == ProcedureRequestPriority.ASAP)
375        return "asap";
376      return "?";
377      }
378    public String toSystem(ProcedureRequestPriority code) {
379      return code.getSystem();
380      }
381    }
382
383    /**
384     * Identifiers assigned to this order by the order or by the receiver.
385     */
386    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
387    @Description(shortDefinition="Unique identifier for the request", formalDefinition="Identifiers assigned to this order by the order or by the receiver." )
388    protected List<Identifier> identifier;
389
390    /**
391     * The person, animal or group that should receive the procedure.
392     */
393    @Child(name = "subject", type = {Patient.class, Group.class}, order=1, min=1, max=1, modifier=false, summary=true)
394    @Description(shortDefinition="Who the procedure should be done to", formalDefinition="The person, animal or group that should receive the procedure." )
395    protected Reference subject;
396
397    /**
398     * The actual object that is the target of the reference (The person, animal or group that should receive the procedure.)
399     */
400    protected Resource subjectTarget;
401
402    /**
403     * The specific procedure that is ordered. Use text if the exact nature of the procedure cannot be coded.
404     */
405    @Child(name = "code", type = {CodeableConcept.class}, order=2, min=1, max=1, modifier=false, summary=true)
406    @Description(shortDefinition="What procedure to perform", formalDefinition="The specific procedure that is ordered. Use text if the exact nature of the procedure cannot be coded." )
407    protected CodeableConcept code;
408
409    /**
410     * Indicates the sites on the subject's body where the procedure should be performed (I.e. the target sites).
411     */
412    @Child(name = "bodySite", type = {CodeableConcept.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
413    @Description(shortDefinition="What part of body to perform on", formalDefinition="Indicates the sites on the subject's body where the procedure should be performed (I.e. the target sites)." )
414    protected List<CodeableConcept> bodySite;
415
416    /**
417     * The reason why the procedure is being proposed or ordered. This procedure request may be motivated by a Condition for instance.
418     */
419    @Child(name = "reason", type = {CodeableConcept.class, Condition.class}, order=4, min=0, max=1, modifier=false, summary=true)
420    @Description(shortDefinition="Why procedure should occur", formalDefinition="The reason why the procedure is being proposed or ordered. This procedure request may be motivated by a Condition for instance." )
421    protected Type reason;
422
423    /**
424     * The timing schedule for the proposed or ordered procedure. The Schedule data type allows many different expressions.  E.g. "Every 8 hours"; "Three times a day"; "1/2 an hour before breakfast for 10 days from 23-Dec 2011:"; "15 Oct 2013, 17 Oct 2013 and 1 Nov 2013".
425     */
426    @Child(name = "scheduled", type = {DateTimeType.class, Period.class, Timing.class}, order=5, min=0, max=1, modifier=false, summary=true)
427    @Description(shortDefinition="When procedure should occur", formalDefinition="The timing schedule for the proposed or ordered procedure. The Schedule data type allows many different expressions.  E.g. \"Every 8 hours\"; \"Three times a day\"; \"1/2 an hour before breakfast for 10 days from 23-Dec 2011:\"; \"15 Oct 2013, 17 Oct 2013 and 1 Nov 2013\"." )
428    protected Type scheduled;
429
430    /**
431     * The encounter within which the procedure proposal or request was created.
432     */
433    @Child(name = "encounter", type = {Encounter.class}, order=6, min=0, max=1, modifier=false, summary=true)
434    @Description(shortDefinition="Encounter request created during", formalDefinition="The encounter within which the procedure proposal or request was created." )
435    protected Reference encounter;
436
437    /**
438     * The actual object that is the target of the reference (The encounter within which the procedure proposal or request was created.)
439     */
440    protected Encounter encounterTarget;
441
442    /**
443     * For example, the surgeon, anaethetist, endoscopist, etc.
444     */
445    @Child(name = "performer", type = {Practitioner.class, Organization.class, Patient.class, RelatedPerson.class}, order=7, min=0, max=1, modifier=false, summary=true)
446    @Description(shortDefinition="Who should perform the procedure", formalDefinition="For example, the surgeon, anaethetist, endoscopist, etc." )
447    protected Reference performer;
448
449    /**
450     * The actual object that is the target of the reference (For example, the surgeon, anaethetist, endoscopist, etc.)
451     */
452    protected Resource performerTarget;
453
454    /**
455     * The status of the order.
456     */
457    @Child(name = "status", type = {CodeType.class}, order=8, min=0, max=1, modifier=true, summary=true)
458    @Description(shortDefinition="proposed | draft | requested | received | accepted | in-progress | completed | suspended | rejected | aborted", formalDefinition="The status of the order." )
459    protected Enumeration<ProcedureRequestStatus> status;
460
461    /**
462     * Any other notes associated with this proposal or order - e.g. provider instructions.
463     */
464    @Child(name = "notes", type = {Annotation.class}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
465    @Description(shortDefinition="Additional information about desired procedure", formalDefinition="Any other notes associated with this proposal or order - e.g. provider instructions." )
466    protected List<Annotation> notes;
467
468    /**
469     * If a CodeableConcept is present, it indicates the pre-condition for performing the procedure.
470     */
471    @Child(name = "asNeeded", type = {BooleanType.class, CodeableConcept.class}, order=10, min=0, max=1, modifier=false, summary=true)
472    @Description(shortDefinition="Preconditions for procedure", formalDefinition="If a CodeableConcept is present, it indicates the pre-condition for performing the procedure." )
473    protected Type asNeeded;
474
475    /**
476     * The time when the request was made.
477     */
478    @Child(name = "orderedOn", type = {DateTimeType.class}, order=11, min=0, max=1, modifier=false, summary=true)
479    @Description(shortDefinition="When request was created", formalDefinition="The time when the request was made." )
480    protected DateTimeType orderedOn;
481
482    /**
483     * The healthcare professional responsible for proposing or ordering the procedure.
484     */
485    @Child(name = "orderer", type = {Practitioner.class, Patient.class, RelatedPerson.class, Device.class}, order=12, min=0, max=1, modifier=false, summary=true)
486    @Description(shortDefinition="Who made request", formalDefinition="The healthcare professional responsible for proposing or ordering the procedure." )
487    protected Reference orderer;
488
489    /**
490     * The actual object that is the target of the reference (The healthcare professional responsible for proposing or ordering the procedure.)
491     */
492    protected Resource ordererTarget;
493
494    /**
495     * The clinical priority associated with this order.
496     */
497    @Child(name = "priority", type = {CodeType.class}, order=13, min=0, max=1, modifier=false, summary=true)
498    @Description(shortDefinition="routine | urgent | stat | asap", formalDefinition="The clinical priority associated with this order." )
499    protected Enumeration<ProcedureRequestPriority> priority;
500
501    private static final long serialVersionUID = -916650578L;
502
503  /**
504   * Constructor
505   */
506    public ProcedureRequest() {
507      super();
508    }
509
510  /**
511   * Constructor
512   */
513    public ProcedureRequest(Reference subject, CodeableConcept code) {
514      super();
515      this.subject = subject;
516      this.code = code;
517    }
518
519    /**
520     * @return {@link #identifier} (Identifiers assigned to this order by the order or by the receiver.)
521     */
522    public List<Identifier> getIdentifier() { 
523      if (this.identifier == null)
524        this.identifier = new ArrayList<Identifier>();
525      return this.identifier;
526    }
527
528    public boolean hasIdentifier() { 
529      if (this.identifier == null)
530        return false;
531      for (Identifier item : this.identifier)
532        if (!item.isEmpty())
533          return true;
534      return false;
535    }
536
537    /**
538     * @return {@link #identifier} (Identifiers assigned to this order by the order or by the receiver.)
539     */
540    // syntactic sugar
541    public Identifier addIdentifier() { //3
542      Identifier t = new Identifier();
543      if (this.identifier == null)
544        this.identifier = new ArrayList<Identifier>();
545      this.identifier.add(t);
546      return t;
547    }
548
549    // syntactic sugar
550    public ProcedureRequest addIdentifier(Identifier t) { //3
551      if (t == null)
552        return this;
553      if (this.identifier == null)
554        this.identifier = new ArrayList<Identifier>();
555      this.identifier.add(t);
556      return this;
557    }
558
559    /**
560     * @return {@link #subject} (The person, animal or group that should receive the procedure.)
561     */
562    public Reference getSubject() { 
563      if (this.subject == null)
564        if (Configuration.errorOnAutoCreate())
565          throw new Error("Attempt to auto-create ProcedureRequest.subject");
566        else if (Configuration.doAutoCreate())
567          this.subject = new Reference(); // cc
568      return this.subject;
569    }
570
571    public boolean hasSubject() { 
572      return this.subject != null && !this.subject.isEmpty();
573    }
574
575    /**
576     * @param value {@link #subject} (The person, animal or group that should receive the procedure.)
577     */
578    public ProcedureRequest setSubject(Reference value) { 
579      this.subject = value;
580      return this;
581    }
582
583    /**
584     * @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. (The person, animal or group that should receive the procedure.)
585     */
586    public Resource getSubjectTarget() { 
587      return this.subjectTarget;
588    }
589
590    /**
591     * @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. (The person, animal or group that should receive the procedure.)
592     */
593    public ProcedureRequest setSubjectTarget(Resource value) { 
594      this.subjectTarget = value;
595      return this;
596    }
597
598    /**
599     * @return {@link #code} (The specific procedure that is ordered. Use text if the exact nature of the procedure cannot be coded.)
600     */
601    public CodeableConcept getCode() { 
602      if (this.code == null)
603        if (Configuration.errorOnAutoCreate())
604          throw new Error("Attempt to auto-create ProcedureRequest.code");
605        else if (Configuration.doAutoCreate())
606          this.code = new CodeableConcept(); // cc
607      return this.code;
608    }
609
610    public boolean hasCode() { 
611      return this.code != null && !this.code.isEmpty();
612    }
613
614    /**
615     * @param value {@link #code} (The specific procedure that is ordered. Use text if the exact nature of the procedure cannot be coded.)
616     */
617    public ProcedureRequest setCode(CodeableConcept value) { 
618      this.code = value;
619      return this;
620    }
621
622    /**
623     * @return {@link #bodySite} (Indicates the sites on the subject's body where the procedure should be performed (I.e. the target sites).)
624     */
625    public List<CodeableConcept> getBodySite() { 
626      if (this.bodySite == null)
627        this.bodySite = new ArrayList<CodeableConcept>();
628      return this.bodySite;
629    }
630
631    public boolean hasBodySite() { 
632      if (this.bodySite == null)
633        return false;
634      for (CodeableConcept item : this.bodySite)
635        if (!item.isEmpty())
636          return true;
637      return false;
638    }
639
640    /**
641     * @return {@link #bodySite} (Indicates the sites on the subject's body where the procedure should be performed (I.e. the target sites).)
642     */
643    // syntactic sugar
644    public CodeableConcept addBodySite() { //3
645      CodeableConcept t = new CodeableConcept();
646      if (this.bodySite == null)
647        this.bodySite = new ArrayList<CodeableConcept>();
648      this.bodySite.add(t);
649      return t;
650    }
651
652    // syntactic sugar
653    public ProcedureRequest addBodySite(CodeableConcept t) { //3
654      if (t == null)
655        return this;
656      if (this.bodySite == null)
657        this.bodySite = new ArrayList<CodeableConcept>();
658      this.bodySite.add(t);
659      return this;
660    }
661
662    /**
663     * @return {@link #reason} (The reason why the procedure is being proposed or ordered. This procedure request may be motivated by a Condition for instance.)
664     */
665    public Type getReason() { 
666      return this.reason;
667    }
668
669    /**
670     * @return {@link #reason} (The reason why the procedure is being proposed or ordered. This procedure request may be motivated by a Condition for instance.)
671     */
672    public CodeableConcept getReasonCodeableConcept() throws FHIRException { 
673      if (!(this.reason instanceof CodeableConcept))
674        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.reason.getClass().getName()+" was encountered");
675      return (CodeableConcept) this.reason;
676    }
677
678    public boolean hasReasonCodeableConcept() { 
679      return this.reason instanceof CodeableConcept;
680    }
681
682    /**
683     * @return {@link #reason} (The reason why the procedure is being proposed or ordered. This procedure request may be motivated by a Condition for instance.)
684     */
685    public Reference getReasonReference() throws FHIRException { 
686      if (!(this.reason instanceof Reference))
687        throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.reason.getClass().getName()+" was encountered");
688      return (Reference) this.reason;
689    }
690
691    public boolean hasReasonReference() { 
692      return this.reason instanceof Reference;
693    }
694
695    public boolean hasReason() { 
696      return this.reason != null && !this.reason.isEmpty();
697    }
698
699    /**
700     * @param value {@link #reason} (The reason why the procedure is being proposed or ordered. This procedure request may be motivated by a Condition for instance.)
701     */
702    public ProcedureRequest setReason(Type value) { 
703      this.reason = value;
704      return this;
705    }
706
707    /**
708     * @return {@link #scheduled} (The timing schedule for the proposed or ordered procedure. The Schedule data type allows many different expressions.  E.g. "Every 8 hours"; "Three times a day"; "1/2 an hour before breakfast for 10 days from 23-Dec 2011:"; "15 Oct 2013, 17 Oct 2013 and 1 Nov 2013".)
709     */
710    public Type getScheduled() { 
711      return this.scheduled;
712    }
713
714    /**
715     * @return {@link #scheduled} (The timing schedule for the proposed or ordered procedure. The Schedule data type allows many different expressions.  E.g. "Every 8 hours"; "Three times a day"; "1/2 an hour before breakfast for 10 days from 23-Dec 2011:"; "15 Oct 2013, 17 Oct 2013 and 1 Nov 2013".)
716     */
717    public DateTimeType getScheduledDateTimeType() throws FHIRException { 
718      if (!(this.scheduled instanceof DateTimeType))
719        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.scheduled.getClass().getName()+" was encountered");
720      return (DateTimeType) this.scheduled;
721    }
722
723    public boolean hasScheduledDateTimeType() { 
724      return this.scheduled instanceof DateTimeType;
725    }
726
727    /**
728     * @return {@link #scheduled} (The timing schedule for the proposed or ordered procedure. The Schedule data type allows many different expressions.  E.g. "Every 8 hours"; "Three times a day"; "1/2 an hour before breakfast for 10 days from 23-Dec 2011:"; "15 Oct 2013, 17 Oct 2013 and 1 Nov 2013".)
729     */
730    public Period getScheduledPeriod() throws FHIRException { 
731      if (!(this.scheduled instanceof Period))
732        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.scheduled.getClass().getName()+" was encountered");
733      return (Period) this.scheduled;
734    }
735
736    public boolean hasScheduledPeriod() { 
737      return this.scheduled instanceof Period;
738    }
739
740    /**
741     * @return {@link #scheduled} (The timing schedule for the proposed or ordered procedure. The Schedule data type allows many different expressions.  E.g. "Every 8 hours"; "Three times a day"; "1/2 an hour before breakfast for 10 days from 23-Dec 2011:"; "15 Oct 2013, 17 Oct 2013 and 1 Nov 2013".)
742     */
743    public Timing getScheduledTiming() throws FHIRException { 
744      if (!(this.scheduled instanceof Timing))
745        throw new FHIRException("Type mismatch: the type Timing was expected, but "+this.scheduled.getClass().getName()+" was encountered");
746      return (Timing) this.scheduled;
747    }
748
749    public boolean hasScheduledTiming() { 
750      return this.scheduled instanceof Timing;
751    }
752
753    public boolean hasScheduled() { 
754      return this.scheduled != null && !this.scheduled.isEmpty();
755    }
756
757    /**
758     * @param value {@link #scheduled} (The timing schedule for the proposed or ordered procedure. The Schedule data type allows many different expressions.  E.g. "Every 8 hours"; "Three times a day"; "1/2 an hour before breakfast for 10 days from 23-Dec 2011:"; "15 Oct 2013, 17 Oct 2013 and 1 Nov 2013".)
759     */
760    public ProcedureRequest setScheduled(Type value) { 
761      this.scheduled = value;
762      return this;
763    }
764
765    /**
766     * @return {@link #encounter} (The encounter within which the procedure proposal or request was created.)
767     */
768    public Reference getEncounter() { 
769      if (this.encounter == null)
770        if (Configuration.errorOnAutoCreate())
771          throw new Error("Attempt to auto-create ProcedureRequest.encounter");
772        else if (Configuration.doAutoCreate())
773          this.encounter = new Reference(); // cc
774      return this.encounter;
775    }
776
777    public boolean hasEncounter() { 
778      return this.encounter != null && !this.encounter.isEmpty();
779    }
780
781    /**
782     * @param value {@link #encounter} (The encounter within which the procedure proposal or request was created.)
783     */
784    public ProcedureRequest setEncounter(Reference value) { 
785      this.encounter = value;
786      return this;
787    }
788
789    /**
790     * @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. (The encounter within which the procedure proposal or request was created.)
791     */
792    public Encounter getEncounterTarget() { 
793      if (this.encounterTarget == null)
794        if (Configuration.errorOnAutoCreate())
795          throw new Error("Attempt to auto-create ProcedureRequest.encounter");
796        else if (Configuration.doAutoCreate())
797          this.encounterTarget = new Encounter(); // aa
798      return this.encounterTarget;
799    }
800
801    /**
802     * @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. (The encounter within which the procedure proposal or request was created.)
803     */
804    public ProcedureRequest setEncounterTarget(Encounter value) { 
805      this.encounterTarget = value;
806      return this;
807    }
808
809    /**
810     * @return {@link #performer} (For example, the surgeon, anaethetist, endoscopist, etc.)
811     */
812    public Reference getPerformer() { 
813      if (this.performer == null)
814        if (Configuration.errorOnAutoCreate())
815          throw new Error("Attempt to auto-create ProcedureRequest.performer");
816        else if (Configuration.doAutoCreate())
817          this.performer = new Reference(); // cc
818      return this.performer;
819    }
820
821    public boolean hasPerformer() { 
822      return this.performer != null && !this.performer.isEmpty();
823    }
824
825    /**
826     * @param value {@link #performer} (For example, the surgeon, anaethetist, endoscopist, etc.)
827     */
828    public ProcedureRequest setPerformer(Reference value) { 
829      this.performer = value;
830      return this;
831    }
832
833    /**
834     * @return {@link #performer} 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. (For example, the surgeon, anaethetist, endoscopist, etc.)
835     */
836    public Resource getPerformerTarget() { 
837      return this.performerTarget;
838    }
839
840    /**
841     * @param value {@link #performer} 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. (For example, the surgeon, anaethetist, endoscopist, etc.)
842     */
843    public ProcedureRequest setPerformerTarget(Resource value) { 
844      this.performerTarget = value;
845      return this;
846    }
847
848    /**
849     * @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
850     */
851    public Enumeration<ProcedureRequestStatus> getStatusElement() { 
852      if (this.status == null)
853        if (Configuration.errorOnAutoCreate())
854          throw new Error("Attempt to auto-create ProcedureRequest.status");
855        else if (Configuration.doAutoCreate())
856          this.status = new Enumeration<ProcedureRequestStatus>(new ProcedureRequestStatusEnumFactory()); // bb
857      return this.status;
858    }
859
860    public boolean hasStatusElement() { 
861      return this.status != null && !this.status.isEmpty();
862    }
863
864    public boolean hasStatus() { 
865      return this.status != null && !this.status.isEmpty();
866    }
867
868    /**
869     * @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
870     */
871    public ProcedureRequest setStatusElement(Enumeration<ProcedureRequestStatus> value) { 
872      this.status = value;
873      return this;
874    }
875
876    /**
877     * @return The status of the order.
878     */
879    public ProcedureRequestStatus getStatus() { 
880      return this.status == null ? null : this.status.getValue();
881    }
882
883    /**
884     * @param value The status of the order.
885     */
886    public ProcedureRequest setStatus(ProcedureRequestStatus value) { 
887      if (value == null)
888        this.status = null;
889      else {
890        if (this.status == null)
891          this.status = new Enumeration<ProcedureRequestStatus>(new ProcedureRequestStatusEnumFactory());
892        this.status.setValue(value);
893      }
894      return this;
895    }
896
897    /**
898     * @return {@link #notes} (Any other notes associated with this proposal or order - e.g. provider instructions.)
899     */
900    public List<Annotation> getNotes() { 
901      if (this.notes == null)
902        this.notes = new ArrayList<Annotation>();
903      return this.notes;
904    }
905
906    public boolean hasNotes() { 
907      if (this.notes == null)
908        return false;
909      for (Annotation item : this.notes)
910        if (!item.isEmpty())
911          return true;
912      return false;
913    }
914
915    /**
916     * @return {@link #notes} (Any other notes associated with this proposal or order - e.g. provider instructions.)
917     */
918    // syntactic sugar
919    public Annotation addNotes() { //3
920      Annotation t = new Annotation();
921      if (this.notes == null)
922        this.notes = new ArrayList<Annotation>();
923      this.notes.add(t);
924      return t;
925    }
926
927    // syntactic sugar
928    public ProcedureRequest addNotes(Annotation t) { //3
929      if (t == null)
930        return this;
931      if (this.notes == null)
932        this.notes = new ArrayList<Annotation>();
933      this.notes.add(t);
934      return this;
935    }
936
937    /**
938     * @return {@link #asNeeded} (If a CodeableConcept is present, it indicates the pre-condition for performing the procedure.)
939     */
940    public Type getAsNeeded() { 
941      return this.asNeeded;
942    }
943
944    /**
945     * @return {@link #asNeeded} (If a CodeableConcept is present, it indicates the pre-condition for performing the procedure.)
946     */
947    public BooleanType getAsNeededBooleanType() throws FHIRException { 
948      if (!(this.asNeeded instanceof BooleanType))
949        throw new FHIRException("Type mismatch: the type BooleanType was expected, but "+this.asNeeded.getClass().getName()+" was encountered");
950      return (BooleanType) this.asNeeded;
951    }
952
953    public boolean hasAsNeededBooleanType() { 
954      return this.asNeeded instanceof BooleanType;
955    }
956
957    /**
958     * @return {@link #asNeeded} (If a CodeableConcept is present, it indicates the pre-condition for performing the procedure.)
959     */
960    public CodeableConcept getAsNeededCodeableConcept() throws FHIRException { 
961      if (!(this.asNeeded instanceof CodeableConcept))
962        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.asNeeded.getClass().getName()+" was encountered");
963      return (CodeableConcept) this.asNeeded;
964    }
965
966    public boolean hasAsNeededCodeableConcept() { 
967      return this.asNeeded instanceof CodeableConcept;
968    }
969
970    public boolean hasAsNeeded() { 
971      return this.asNeeded != null && !this.asNeeded.isEmpty();
972    }
973
974    /**
975     * @param value {@link #asNeeded} (If a CodeableConcept is present, it indicates the pre-condition for performing the procedure.)
976     */
977    public ProcedureRequest setAsNeeded(Type value) { 
978      this.asNeeded = value;
979      return this;
980    }
981
982    /**
983     * @return {@link #orderedOn} (The time when the request was made.). This is the underlying object with id, value and extensions. The accessor "getOrderedOn" gives direct access to the value
984     */
985    public DateTimeType getOrderedOnElement() { 
986      if (this.orderedOn == null)
987        if (Configuration.errorOnAutoCreate())
988          throw new Error("Attempt to auto-create ProcedureRequest.orderedOn");
989        else if (Configuration.doAutoCreate())
990          this.orderedOn = new DateTimeType(); // bb
991      return this.orderedOn;
992    }
993
994    public boolean hasOrderedOnElement() { 
995      return this.orderedOn != null && !this.orderedOn.isEmpty();
996    }
997
998    public boolean hasOrderedOn() { 
999      return this.orderedOn != null && !this.orderedOn.isEmpty();
1000    }
1001
1002    /**
1003     * @param value {@link #orderedOn} (The time when the request was made.). This is the underlying object with id, value and extensions. The accessor "getOrderedOn" gives direct access to the value
1004     */
1005    public ProcedureRequest setOrderedOnElement(DateTimeType value) { 
1006      this.orderedOn = value;
1007      return this;
1008    }
1009
1010    /**
1011     * @return The time when the request was made.
1012     */
1013    public Date getOrderedOn() { 
1014      return this.orderedOn == null ? null : this.orderedOn.getValue();
1015    }
1016
1017    /**
1018     * @param value The time when the request was made.
1019     */
1020    public ProcedureRequest setOrderedOn(Date value) { 
1021      if (value == null)
1022        this.orderedOn = null;
1023      else {
1024        if (this.orderedOn == null)
1025          this.orderedOn = new DateTimeType();
1026        this.orderedOn.setValue(value);
1027      }
1028      return this;
1029    }
1030
1031    /**
1032     * @return {@link #orderer} (The healthcare professional responsible for proposing or ordering the procedure.)
1033     */
1034    public Reference getOrderer() { 
1035      if (this.orderer == null)
1036        if (Configuration.errorOnAutoCreate())
1037          throw new Error("Attempt to auto-create ProcedureRequest.orderer");
1038        else if (Configuration.doAutoCreate())
1039          this.orderer = new Reference(); // cc
1040      return this.orderer;
1041    }
1042
1043    public boolean hasOrderer() { 
1044      return this.orderer != null && !this.orderer.isEmpty();
1045    }
1046
1047    /**
1048     * @param value {@link #orderer} (The healthcare professional responsible for proposing or ordering the procedure.)
1049     */
1050    public ProcedureRequest setOrderer(Reference value) { 
1051      this.orderer = value;
1052      return this;
1053    }
1054
1055    /**
1056     * @return {@link #orderer} 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 healthcare professional responsible for proposing or ordering the procedure.)
1057     */
1058    public Resource getOrdererTarget() { 
1059      return this.ordererTarget;
1060    }
1061
1062    /**
1063     * @param value {@link #orderer} 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 healthcare professional responsible for proposing or ordering the procedure.)
1064     */
1065    public ProcedureRequest setOrdererTarget(Resource value) { 
1066      this.ordererTarget = value;
1067      return this;
1068    }
1069
1070    /**
1071     * @return {@link #priority} (The clinical priority associated with this order.). This is the underlying object with id, value and extensions. The accessor "getPriority" gives direct access to the value
1072     */
1073    public Enumeration<ProcedureRequestPriority> getPriorityElement() { 
1074      if (this.priority == null)
1075        if (Configuration.errorOnAutoCreate())
1076          throw new Error("Attempt to auto-create ProcedureRequest.priority");
1077        else if (Configuration.doAutoCreate())
1078          this.priority = new Enumeration<ProcedureRequestPriority>(new ProcedureRequestPriorityEnumFactory()); // bb
1079      return this.priority;
1080    }
1081
1082    public boolean hasPriorityElement() { 
1083      return this.priority != null && !this.priority.isEmpty();
1084    }
1085
1086    public boolean hasPriority() { 
1087      return this.priority != null && !this.priority.isEmpty();
1088    }
1089
1090    /**
1091     * @param value {@link #priority} (The clinical priority associated with this order.). This is the underlying object with id, value and extensions. The accessor "getPriority" gives direct access to the value
1092     */
1093    public ProcedureRequest setPriorityElement(Enumeration<ProcedureRequestPriority> value) { 
1094      this.priority = value;
1095      return this;
1096    }
1097
1098    /**
1099     * @return The clinical priority associated with this order.
1100     */
1101    public ProcedureRequestPriority getPriority() { 
1102      return this.priority == null ? null : this.priority.getValue();
1103    }
1104
1105    /**
1106     * @param value The clinical priority associated with this order.
1107     */
1108    public ProcedureRequest setPriority(ProcedureRequestPriority value) { 
1109      if (value == null)
1110        this.priority = null;
1111      else {
1112        if (this.priority == null)
1113          this.priority = new Enumeration<ProcedureRequestPriority>(new ProcedureRequestPriorityEnumFactory());
1114        this.priority.setValue(value);
1115      }
1116      return this;
1117    }
1118
1119      protected void listChildren(List<Property> childrenList) {
1120        super.listChildren(childrenList);
1121        childrenList.add(new Property("identifier", "Identifier", "Identifiers assigned to this order by the order or by the receiver.", 0, java.lang.Integer.MAX_VALUE, identifier));
1122        childrenList.add(new Property("subject", "Reference(Patient|Group)", "The person, animal or group that should receive the procedure.", 0, java.lang.Integer.MAX_VALUE, subject));
1123        childrenList.add(new Property("code", "CodeableConcept", "The specific procedure that is ordered. Use text if the exact nature of the procedure cannot be coded.", 0, java.lang.Integer.MAX_VALUE, code));
1124        childrenList.add(new Property("bodySite", "CodeableConcept", "Indicates the sites on the subject's body where the procedure should be performed (I.e. the target sites).", 0, java.lang.Integer.MAX_VALUE, bodySite));
1125        childrenList.add(new Property("reason[x]", "CodeableConcept|Reference(Condition)", "The reason why the procedure is being proposed or ordered. This procedure request may be motivated by a Condition for instance.", 0, java.lang.Integer.MAX_VALUE, reason));
1126        childrenList.add(new Property("scheduled[x]", "dateTime|Period|Timing", "The timing schedule for the proposed or ordered procedure. The Schedule data type allows many different expressions.  E.g. \"Every 8 hours\"; \"Three times a day\"; \"1/2 an hour before breakfast for 10 days from 23-Dec 2011:\"; \"15 Oct 2013, 17 Oct 2013 and 1 Nov 2013\".", 0, java.lang.Integer.MAX_VALUE, scheduled));
1127        childrenList.add(new Property("encounter", "Reference(Encounter)", "The encounter within which the procedure proposal or request was created.", 0, java.lang.Integer.MAX_VALUE, encounter));
1128        childrenList.add(new Property("performer", "Reference(Practitioner|Organization|Patient|RelatedPerson)", "For example, the surgeon, anaethetist, endoscopist, etc.", 0, java.lang.Integer.MAX_VALUE, performer));
1129        childrenList.add(new Property("status", "code", "The status of the order.", 0, java.lang.Integer.MAX_VALUE, status));
1130        childrenList.add(new Property("notes", "Annotation", "Any other notes associated with this proposal or order - e.g. provider instructions.", 0, java.lang.Integer.MAX_VALUE, notes));
1131        childrenList.add(new Property("asNeeded[x]", "boolean|CodeableConcept", "If a CodeableConcept is present, it indicates the pre-condition for performing the procedure.", 0, java.lang.Integer.MAX_VALUE, asNeeded));
1132        childrenList.add(new Property("orderedOn", "dateTime", "The time when the request was made.", 0, java.lang.Integer.MAX_VALUE, orderedOn));
1133        childrenList.add(new Property("orderer", "Reference(Practitioner|Patient|RelatedPerson|Device)", "The healthcare professional responsible for proposing or ordering the procedure.", 0, java.lang.Integer.MAX_VALUE, orderer));
1134        childrenList.add(new Property("priority", "code", "The clinical priority associated with this order.", 0, java.lang.Integer.MAX_VALUE, priority));
1135      }
1136
1137      @Override
1138      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1139        switch (hash) {
1140        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1141        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
1142        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept
1143        case 1702620169: /*bodySite*/ return this.bodySite == null ? new Base[0] : this.bodySite.toArray(new Base[this.bodySite.size()]); // CodeableConcept
1144        case -934964668: /*reason*/ return this.reason == null ? new Base[0] : new Base[] {this.reason}; // Type
1145        case -160710483: /*scheduled*/ return this.scheduled == null ? new Base[0] : new Base[] {this.scheduled}; // Type
1146        case 1524132147: /*encounter*/ return this.encounter == null ? new Base[0] : new Base[] {this.encounter}; // Reference
1147        case 481140686: /*performer*/ return this.performer == null ? new Base[0] : new Base[] {this.performer}; // Reference
1148        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<ProcedureRequestStatus>
1149        case 105008833: /*notes*/ return this.notes == null ? new Base[0] : this.notes.toArray(new Base[this.notes.size()]); // Annotation
1150        case -1432923513: /*asNeeded*/ return this.asNeeded == null ? new Base[0] : new Base[] {this.asNeeded}; // Type
1151        case -391079124: /*orderedOn*/ return this.orderedOn == null ? new Base[0] : new Base[] {this.orderedOn}; // DateTimeType
1152        case -1207109509: /*orderer*/ return this.orderer == null ? new Base[0] : new Base[] {this.orderer}; // Reference
1153        case -1165461084: /*priority*/ return this.priority == null ? new Base[0] : new Base[] {this.priority}; // Enumeration<ProcedureRequestPriority>
1154        default: return super.getProperty(hash, name, checkValid);
1155        }
1156
1157      }
1158
1159      @Override
1160      public void setProperty(int hash, String name, Base value) throws FHIRException {
1161        switch (hash) {
1162        case -1618432855: // identifier
1163          this.getIdentifier().add(castToIdentifier(value)); // Identifier
1164          break;
1165        case -1867885268: // subject
1166          this.subject = castToReference(value); // Reference
1167          break;
1168        case 3059181: // code
1169          this.code = castToCodeableConcept(value); // CodeableConcept
1170          break;
1171        case 1702620169: // bodySite
1172          this.getBodySite().add(castToCodeableConcept(value)); // CodeableConcept
1173          break;
1174        case -934964668: // reason
1175          this.reason = (Type) value; // Type
1176          break;
1177        case -160710483: // scheduled
1178          this.scheduled = (Type) value; // Type
1179          break;
1180        case 1524132147: // encounter
1181          this.encounter = castToReference(value); // Reference
1182          break;
1183        case 481140686: // performer
1184          this.performer = castToReference(value); // Reference
1185          break;
1186        case -892481550: // status
1187          this.status = new ProcedureRequestStatusEnumFactory().fromType(value); // Enumeration<ProcedureRequestStatus>
1188          break;
1189        case 105008833: // notes
1190          this.getNotes().add(castToAnnotation(value)); // Annotation
1191          break;
1192        case -1432923513: // asNeeded
1193          this.asNeeded = (Type) value; // Type
1194          break;
1195        case -391079124: // orderedOn
1196          this.orderedOn = castToDateTime(value); // DateTimeType
1197          break;
1198        case -1207109509: // orderer
1199          this.orderer = castToReference(value); // Reference
1200          break;
1201        case -1165461084: // priority
1202          this.priority = new ProcedureRequestPriorityEnumFactory().fromType(value); // Enumeration<ProcedureRequestPriority>
1203          break;
1204        default: super.setProperty(hash, name, value);
1205        }
1206
1207      }
1208
1209      @Override
1210      public void setProperty(String name, Base value) throws FHIRException {
1211        if (name.equals("identifier"))
1212          this.getIdentifier().add(castToIdentifier(value));
1213        else if (name.equals("subject"))
1214          this.subject = castToReference(value); // Reference
1215        else if (name.equals("code"))
1216          this.code = castToCodeableConcept(value); // CodeableConcept
1217        else if (name.equals("bodySite"))
1218          this.getBodySite().add(castToCodeableConcept(value));
1219        else if (name.equals("reason[x]"))
1220          this.reason = (Type) value; // Type
1221        else if (name.equals("scheduled[x]"))
1222          this.scheduled = (Type) value; // Type
1223        else if (name.equals("encounter"))
1224          this.encounter = castToReference(value); // Reference
1225        else if (name.equals("performer"))
1226          this.performer = castToReference(value); // Reference
1227        else if (name.equals("status"))
1228          this.status = new ProcedureRequestStatusEnumFactory().fromType(value); // Enumeration<ProcedureRequestStatus>
1229        else if (name.equals("notes"))
1230          this.getNotes().add(castToAnnotation(value));
1231        else if (name.equals("asNeeded[x]"))
1232          this.asNeeded = (Type) value; // Type
1233        else if (name.equals("orderedOn"))
1234          this.orderedOn = castToDateTime(value); // DateTimeType
1235        else if (name.equals("orderer"))
1236          this.orderer = castToReference(value); // Reference
1237        else if (name.equals("priority"))
1238          this.priority = new ProcedureRequestPriorityEnumFactory().fromType(value); // Enumeration<ProcedureRequestPriority>
1239        else
1240          super.setProperty(name, value);
1241      }
1242
1243      @Override
1244      public Base makeProperty(int hash, String name) throws FHIRException {
1245        switch (hash) {
1246        case -1618432855:  return addIdentifier(); // Identifier
1247        case -1867885268:  return getSubject(); // Reference
1248        case 3059181:  return getCode(); // CodeableConcept
1249        case 1702620169:  return addBodySite(); // CodeableConcept
1250        case -669418564:  return getReason(); // Type
1251        case 1162627251:  return getScheduled(); // Type
1252        case 1524132147:  return getEncounter(); // Reference
1253        case 481140686:  return getPerformer(); // Reference
1254        case -892481550: throw new FHIRException("Cannot make property status as it is not a complex type"); // Enumeration<ProcedureRequestStatus>
1255        case 105008833:  return addNotes(); // Annotation
1256        case -544329575:  return getAsNeeded(); // Type
1257        case -391079124: throw new FHIRException("Cannot make property orderedOn as it is not a complex type"); // DateTimeType
1258        case -1207109509:  return getOrderer(); // Reference
1259        case -1165461084: throw new FHIRException("Cannot make property priority as it is not a complex type"); // Enumeration<ProcedureRequestPriority>
1260        default: return super.makeProperty(hash, name);
1261        }
1262
1263      }
1264
1265      @Override
1266      public Base addChild(String name) throws FHIRException {
1267        if (name.equals("identifier")) {
1268          return addIdentifier();
1269        }
1270        else if (name.equals("subject")) {
1271          this.subject = new Reference();
1272          return this.subject;
1273        }
1274        else if (name.equals("code")) {
1275          this.code = new CodeableConcept();
1276          return this.code;
1277        }
1278        else if (name.equals("bodySite")) {
1279          return addBodySite();
1280        }
1281        else if (name.equals("reasonCodeableConcept")) {
1282          this.reason = new CodeableConcept();
1283          return this.reason;
1284        }
1285        else if (name.equals("reasonReference")) {
1286          this.reason = new Reference();
1287          return this.reason;
1288        }
1289        else if (name.equals("scheduledDateTime")) {
1290          this.scheduled = new DateTimeType();
1291          return this.scheduled;
1292        }
1293        else if (name.equals("scheduledPeriod")) {
1294          this.scheduled = new Period();
1295          return this.scheduled;
1296        }
1297        else if (name.equals("scheduledTiming")) {
1298          this.scheduled = new Timing();
1299          return this.scheduled;
1300        }
1301        else if (name.equals("encounter")) {
1302          this.encounter = new Reference();
1303          return this.encounter;
1304        }
1305        else if (name.equals("performer")) {
1306          this.performer = new Reference();
1307          return this.performer;
1308        }
1309        else if (name.equals("status")) {
1310          throw new FHIRException("Cannot call addChild on a primitive type ProcedureRequest.status");
1311        }
1312        else if (name.equals("notes")) {
1313          return addNotes();
1314        }
1315        else if (name.equals("asNeededBoolean")) {
1316          this.asNeeded = new BooleanType();
1317          return this.asNeeded;
1318        }
1319        else if (name.equals("asNeededCodeableConcept")) {
1320          this.asNeeded = new CodeableConcept();
1321          return this.asNeeded;
1322        }
1323        else if (name.equals("orderedOn")) {
1324          throw new FHIRException("Cannot call addChild on a primitive type ProcedureRequest.orderedOn");
1325        }
1326        else if (name.equals("orderer")) {
1327          this.orderer = new Reference();
1328          return this.orderer;
1329        }
1330        else if (name.equals("priority")) {
1331          throw new FHIRException("Cannot call addChild on a primitive type ProcedureRequest.priority");
1332        }
1333        else
1334          return super.addChild(name);
1335      }
1336
1337  public String fhirType() {
1338    return "ProcedureRequest";
1339
1340  }
1341
1342      public ProcedureRequest copy() {
1343        ProcedureRequest dst = new ProcedureRequest();
1344        copyValues(dst);
1345        if (identifier != null) {
1346          dst.identifier = new ArrayList<Identifier>();
1347          for (Identifier i : identifier)
1348            dst.identifier.add(i.copy());
1349        };
1350        dst.subject = subject == null ? null : subject.copy();
1351        dst.code = code == null ? null : code.copy();
1352        if (bodySite != null) {
1353          dst.bodySite = new ArrayList<CodeableConcept>();
1354          for (CodeableConcept i : bodySite)
1355            dst.bodySite.add(i.copy());
1356        };
1357        dst.reason = reason == null ? null : reason.copy();
1358        dst.scheduled = scheduled == null ? null : scheduled.copy();
1359        dst.encounter = encounter == null ? null : encounter.copy();
1360        dst.performer = performer == null ? null : performer.copy();
1361        dst.status = status == null ? null : status.copy();
1362        if (notes != null) {
1363          dst.notes = new ArrayList<Annotation>();
1364          for (Annotation i : notes)
1365            dst.notes.add(i.copy());
1366        };
1367        dst.asNeeded = asNeeded == null ? null : asNeeded.copy();
1368        dst.orderedOn = orderedOn == null ? null : orderedOn.copy();
1369        dst.orderer = orderer == null ? null : orderer.copy();
1370        dst.priority = priority == null ? null : priority.copy();
1371        return dst;
1372      }
1373
1374      protected ProcedureRequest typedCopy() {
1375        return copy();
1376      }
1377
1378      @Override
1379      public boolean equalsDeep(Base other) {
1380        if (!super.equalsDeep(other))
1381          return false;
1382        if (!(other instanceof ProcedureRequest))
1383          return false;
1384        ProcedureRequest o = (ProcedureRequest) other;
1385        return compareDeep(identifier, o.identifier, true) && compareDeep(subject, o.subject, true) && compareDeep(code, o.code, true)
1386           && compareDeep(bodySite, o.bodySite, true) && compareDeep(reason, o.reason, true) && compareDeep(scheduled, o.scheduled, true)
1387           && compareDeep(encounter, o.encounter, true) && compareDeep(performer, o.performer, true) && compareDeep(status, o.status, true)
1388           && compareDeep(notes, o.notes, true) && compareDeep(asNeeded, o.asNeeded, true) && compareDeep(orderedOn, o.orderedOn, true)
1389           && compareDeep(orderer, o.orderer, true) && compareDeep(priority, o.priority, true);
1390      }
1391
1392      @Override
1393      public boolean equalsShallow(Base other) {
1394        if (!super.equalsShallow(other))
1395          return false;
1396        if (!(other instanceof ProcedureRequest))
1397          return false;
1398        ProcedureRequest o = (ProcedureRequest) other;
1399        return compareValues(status, o.status, true) && compareValues(orderedOn, o.orderedOn, true) && compareValues(priority, o.priority, true)
1400          ;
1401      }
1402
1403      public boolean isEmpty() {
1404        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (subject == null || subject.isEmpty())
1405           && (code == null || code.isEmpty()) && (bodySite == null || bodySite.isEmpty()) && (reason == null || reason.isEmpty())
1406           && (scheduled == null || scheduled.isEmpty()) && (encounter == null || encounter.isEmpty())
1407           && (performer == null || performer.isEmpty()) && (status == null || status.isEmpty()) && (notes == null || notes.isEmpty())
1408           && (asNeeded == null || asNeeded.isEmpty()) && (orderedOn == null || orderedOn.isEmpty())
1409           && (orderer == null || orderer.isEmpty()) && (priority == null || priority.isEmpty());
1410      }
1411
1412  @Override
1413  public ResourceType getResourceType() {
1414    return ResourceType.ProcedureRequest;
1415   }
1416
1417 /**
1418   * Search parameter: <b>orderer</b>
1419   * <p>
1420   * Description: <b>Who made request</b><br>
1421   * Type: <b>reference</b><br>
1422   * Path: <b>ProcedureRequest.orderer</b><br>
1423   * </p>
1424   */
1425  @SearchParamDefinition(name="orderer", path="ProcedureRequest.orderer", description="Who made request", type="reference" )
1426  public static final String SP_ORDERER = "orderer";
1427 /**
1428   * <b>Fluent Client</b> search parameter constant for <b>orderer</b>
1429   * <p>
1430   * Description: <b>Who made request</b><br>
1431   * Type: <b>reference</b><br>
1432   * Path: <b>ProcedureRequest.orderer</b><br>
1433   * </p>
1434   */
1435  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ORDERER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ORDERER);
1436
1437/**
1438   * Constant for fluent queries to be used to add include statements. Specifies
1439   * the path value of "<b>ProcedureRequest:orderer</b>".
1440   */
1441  public static final ca.uhn.fhir.model.api.Include INCLUDE_ORDERER = new ca.uhn.fhir.model.api.Include("ProcedureRequest:orderer").toLocked();
1442
1443 /**
1444   * Search parameter: <b>patient</b>
1445   * <p>
1446   * Description: <b>Search by subject - a patient</b><br>
1447   * Type: <b>reference</b><br>
1448   * Path: <b>ProcedureRequest.subject</b><br>
1449   * </p>
1450   */
1451  @SearchParamDefinition(name="patient", path="ProcedureRequest.subject", description="Search by subject - a patient", type="reference" )
1452  public static final String SP_PATIENT = "patient";
1453 /**
1454   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
1455   * <p>
1456   * Description: <b>Search by subject - a patient</b><br>
1457   * Type: <b>reference</b><br>
1458   * Path: <b>ProcedureRequest.subject</b><br>
1459   * </p>
1460   */
1461  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
1462
1463/**
1464   * Constant for fluent queries to be used to add include statements. Specifies
1465   * the path value of "<b>ProcedureRequest:patient</b>".
1466   */
1467  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("ProcedureRequest:patient").toLocked();
1468
1469 /**
1470   * Search parameter: <b>subject</b>
1471   * <p>
1472   * Description: <b>Search by subject</b><br>
1473   * Type: <b>reference</b><br>
1474   * Path: <b>ProcedureRequest.subject</b><br>
1475   * </p>
1476   */
1477  @SearchParamDefinition(name="subject", path="ProcedureRequest.subject", description="Search by subject", type="reference" )
1478  public static final String SP_SUBJECT = "subject";
1479 /**
1480   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
1481   * <p>
1482   * Description: <b>Search by subject</b><br>
1483   * Type: <b>reference</b><br>
1484   * Path: <b>ProcedureRequest.subject</b><br>
1485   * </p>
1486   */
1487  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
1488
1489/**
1490   * Constant for fluent queries to be used to add include statements. Specifies
1491   * the path value of "<b>ProcedureRequest:subject</b>".
1492   */
1493  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("ProcedureRequest:subject").toLocked();
1494
1495 /**
1496   * Search parameter: <b>performer</b>
1497   * <p>
1498   * Description: <b>Who should perform the procedure</b><br>
1499   * Type: <b>reference</b><br>
1500   * Path: <b>ProcedureRequest.performer</b><br>
1501   * </p>
1502   */
1503  @SearchParamDefinition(name="performer", path="ProcedureRequest.performer", description="Who should perform the procedure", type="reference" )
1504  public static final String SP_PERFORMER = "performer";
1505 /**
1506   * <b>Fluent Client</b> search parameter constant for <b>performer</b>
1507   * <p>
1508   * Description: <b>Who should perform the procedure</b><br>
1509   * Type: <b>reference</b><br>
1510   * Path: <b>ProcedureRequest.performer</b><br>
1511   * </p>
1512   */
1513  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PERFORMER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PERFORMER);
1514
1515/**
1516   * Constant for fluent queries to be used to add include statements. Specifies
1517   * the path value of "<b>ProcedureRequest:performer</b>".
1518   */
1519  public static final ca.uhn.fhir.model.api.Include INCLUDE_PERFORMER = new ca.uhn.fhir.model.api.Include("ProcedureRequest:performer").toLocked();
1520
1521 /**
1522   * Search parameter: <b>encounter</b>
1523   * <p>
1524   * Description: <b>Encounter request created during</b><br>
1525   * Type: <b>reference</b><br>
1526   * Path: <b>ProcedureRequest.encounter</b><br>
1527   * </p>
1528   */
1529  @SearchParamDefinition(name="encounter", path="ProcedureRequest.encounter", description="Encounter request created during", type="reference" )
1530  public static final String SP_ENCOUNTER = "encounter";
1531 /**
1532   * <b>Fluent Client</b> search parameter constant for <b>encounter</b>
1533   * <p>
1534   * Description: <b>Encounter request created during</b><br>
1535   * Type: <b>reference</b><br>
1536   * Path: <b>ProcedureRequest.encounter</b><br>
1537   * </p>
1538   */
1539  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENCOUNTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENCOUNTER);
1540
1541/**
1542   * Constant for fluent queries to be used to add include statements. Specifies
1543   * the path value of "<b>ProcedureRequest:encounter</b>".
1544   */
1545  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENCOUNTER = new ca.uhn.fhir.model.api.Include("ProcedureRequest:encounter").toLocked();
1546
1547 /**
1548   * Search parameter: <b>identifier</b>
1549   * <p>
1550   * Description: <b>A unique identifier of the Procedure Request</b><br>
1551   * Type: <b>token</b><br>
1552   * Path: <b>ProcedureRequest.identifier</b><br>
1553   * </p>
1554   */
1555  @SearchParamDefinition(name="identifier", path="ProcedureRequest.identifier", description="A unique identifier of the Procedure Request", type="token" )
1556  public static final String SP_IDENTIFIER = "identifier";
1557 /**
1558   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
1559   * <p>
1560   * Description: <b>A unique identifier of the Procedure Request</b><br>
1561   * Type: <b>token</b><br>
1562   * Path: <b>ProcedureRequest.identifier</b><br>
1563   * </p>
1564   */
1565  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
1566
1567
1568}
1569