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