001package org.hl7.fhir.dstu2.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 Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
036import java.util.ArrayList;
037import java.util.Date;
038import java.util.List;
039
040import ca.uhn.fhir.model.api.annotation.Child;
041import ca.uhn.fhir.model.api.annotation.Description;
042import ca.uhn.fhir.model.api.annotation.ResourceDef;
043import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
044import org.hl7.fhir.exceptions.FHIRException;
045/**
046 * A request for a procedure to be performed. May be a proposal or an order.
047 */
048@ResourceDef(name="ProcedureRequest", profile="http://hl7.org/fhir/Profile/ProcedureRequest")
049public class ProcedureRequest extends DomainResource {
050
051    public enum ProcedureRequestStatus {
052        /**
053         * The request has been proposed.
054         */
055        PROPOSED, 
056        /**
057         * The request is in preliminary form, prior to being requested.
058         */
059        DRAFT, 
060        /**
061         * The request has been placed.
062         */
063        REQUESTED, 
064        /**
065         * The receiving system has received the request but not yet decided whether it will be performed.
066         */
067        RECEIVED, 
068        /**
069         * The receiving system has accepted the request, but work has not yet commenced.
070         */
071        ACCEPTED, 
072        /**
073         * The work to fulfill the request is happening.
074         */
075        INPROGRESS, 
076        /**
077         * The work has been completed, the report(s) released, and no further work is planned.
078         */
079        COMPLETED, 
080        /**
081         * The request has been held by originating system/user request.
082         */
083        SUSPENDED, 
084        /**
085         * The receiving system has declined to fulfill the request.
086         */
087        REJECTED, 
088        /**
089         * The request was attempted, but due to some procedural error, it could not be completed.
090         */
091        ABORTED, 
092        /**
093         * added to help the parsers
094         */
095        NULL;
096        public static ProcedureRequestStatus fromCode(String codeString) throws FHIRException {
097            if (codeString == null || "".equals(codeString))
098                return null;
099        if ("proposed".equals(codeString))
100          return PROPOSED;
101        if ("draft".equals(codeString))
102          return DRAFT;
103        if ("requested".equals(codeString))
104          return REQUESTED;
105        if ("received".equals(codeString))
106          return RECEIVED;
107        if ("accepted".equals(codeString))
108          return ACCEPTED;
109        if ("in-progress".equals(codeString))
110          return INPROGRESS;
111        if ("completed".equals(codeString))
112          return COMPLETED;
113        if ("suspended".equals(codeString))
114          return SUSPENDED;
115        if ("rejected".equals(codeString))
116          return REJECTED;
117        if ("aborted".equals(codeString))
118          return ABORTED;
119        throw new FHIRException("Unknown ProcedureRequestStatus code '"+codeString+"'");
120        }
121        public String toCode() {
122          switch (this) {
123            case PROPOSED: return "proposed";
124            case DRAFT: return "draft";
125            case REQUESTED: return "requested";
126            case RECEIVED: return "received";
127            case ACCEPTED: return "accepted";
128            case INPROGRESS: return "in-progress";
129            case COMPLETED: return "completed";
130            case SUSPENDED: return "suspended";
131            case REJECTED: return "rejected";
132            case ABORTED: return "aborted";
133            default: return "?";
134          }
135        }
136        public String getSystem() {
137          switch (this) {
138            case PROPOSED: return "http://hl7.org/fhir/procedure-request-status";
139            case DRAFT: return "http://hl7.org/fhir/procedure-request-status";
140            case REQUESTED: return "http://hl7.org/fhir/procedure-request-status";
141            case RECEIVED: return "http://hl7.org/fhir/procedure-request-status";
142            case ACCEPTED: return "http://hl7.org/fhir/procedure-request-status";
143            case INPROGRESS: return "http://hl7.org/fhir/procedure-request-status";
144            case COMPLETED: return "http://hl7.org/fhir/procedure-request-status";
145            case SUSPENDED: return "http://hl7.org/fhir/procedure-request-status";
146            case REJECTED: return "http://hl7.org/fhir/procedure-request-status";
147            case ABORTED: return "http://hl7.org/fhir/procedure-request-status";
148            default: return "?";
149          }
150        }
151        public String getDefinition() {
152          switch (this) {
153            case PROPOSED: return "The request has been proposed.";
154            case DRAFT: return "The request is in preliminary form, prior to being requested.";
155            case REQUESTED: return "The request has been placed.";
156            case RECEIVED: return "The receiving system has received the request but not yet decided whether it will be performed.";
157            case ACCEPTED: return "The receiving system has accepted the request, but work has not yet commenced.";
158            case INPROGRESS: return "The work to fulfill the request is happening.";
159            case COMPLETED: return "The work has been completed, the report(s) released, and no further work is planned.";
160            case SUSPENDED: return "The request has been held by originating system/user request.";
161            case REJECTED: return "The receiving system has declined to fulfill the request.";
162            case ABORTED: return "The request was attempted, but due to some procedural error, it could not be completed.";
163            default: return "?";
164          }
165        }
166        public String getDisplay() {
167          switch (this) {
168            case PROPOSED: return "Proposed";
169            case DRAFT: return "Draft";
170            case REQUESTED: return "Requested";
171            case RECEIVED: return "Received";
172            case ACCEPTED: return "Accepted";
173            case INPROGRESS: return "In Progress";
174            case COMPLETED: return "Completed";
175            case SUSPENDED: return "Suspended";
176            case REJECTED: return "Rejected";
177            case ABORTED: return "Aborted";
178            default: return "?";
179          }
180        }
181    }
182
183  public static class ProcedureRequestStatusEnumFactory implements EnumFactory<ProcedureRequestStatus> {
184    public ProcedureRequestStatus fromCode(String codeString) throws IllegalArgumentException {
185      if (codeString == null || "".equals(codeString))
186            if (codeString == null || "".equals(codeString))
187                return null;
188        if ("proposed".equals(codeString))
189          return ProcedureRequestStatus.PROPOSED;
190        if ("draft".equals(codeString))
191          return ProcedureRequestStatus.DRAFT;
192        if ("requested".equals(codeString))
193          return ProcedureRequestStatus.REQUESTED;
194        if ("received".equals(codeString))
195          return ProcedureRequestStatus.RECEIVED;
196        if ("accepted".equals(codeString))
197          return ProcedureRequestStatus.ACCEPTED;
198        if ("in-progress".equals(codeString))
199          return ProcedureRequestStatus.INPROGRESS;
200        if ("completed".equals(codeString))
201          return ProcedureRequestStatus.COMPLETED;
202        if ("suspended".equals(codeString))
203          return ProcedureRequestStatus.SUSPENDED;
204        if ("rejected".equals(codeString))
205          return ProcedureRequestStatus.REJECTED;
206        if ("aborted".equals(codeString))
207          return ProcedureRequestStatus.ABORTED;
208        throw new IllegalArgumentException("Unknown ProcedureRequestStatus code '"+codeString+"'");
209        }
210        public Enumeration<ProcedureRequestStatus> fromType(Base code) throws FHIRException {
211          if (code == null || code.isEmpty())
212            return null;
213          String codeString = ((PrimitiveType) code).asStringValue();
214          if (codeString == null || "".equals(codeString))
215            return null;
216        if ("proposed".equals(codeString))
217          return new Enumeration<ProcedureRequestStatus>(this, ProcedureRequestStatus.PROPOSED);
218        if ("draft".equals(codeString))
219          return new Enumeration<ProcedureRequestStatus>(this, ProcedureRequestStatus.DRAFT);
220        if ("requested".equals(codeString))
221          return new Enumeration<ProcedureRequestStatus>(this, ProcedureRequestStatus.REQUESTED);
222        if ("received".equals(codeString))
223          return new Enumeration<ProcedureRequestStatus>(this, ProcedureRequestStatus.RECEIVED);
224        if ("accepted".equals(codeString))
225          return new Enumeration<ProcedureRequestStatus>(this, ProcedureRequestStatus.ACCEPTED);
226        if ("in-progress".equals(codeString))
227          return new Enumeration<ProcedureRequestStatus>(this, ProcedureRequestStatus.INPROGRESS);
228        if ("completed".equals(codeString))
229          return new Enumeration<ProcedureRequestStatus>(this, ProcedureRequestStatus.COMPLETED);
230        if ("suspended".equals(codeString))
231          return new Enumeration<ProcedureRequestStatus>(this, ProcedureRequestStatus.SUSPENDED);
232        if ("rejected".equals(codeString))
233          return new Enumeration<ProcedureRequestStatus>(this, ProcedureRequestStatus.REJECTED);
234        if ("aborted".equals(codeString))
235          return new Enumeration<ProcedureRequestStatus>(this, ProcedureRequestStatus.ABORTED);
236        throw new FHIRException("Unknown ProcedureRequestStatus code '"+codeString+"'");
237        }
238    public String toCode(ProcedureRequestStatus code) {
239      if (code == ProcedureRequestStatus.PROPOSED)
240        return "proposed";
241      if (code == ProcedureRequestStatus.DRAFT)
242        return "draft";
243      if (code == ProcedureRequestStatus.REQUESTED)
244        return "requested";
245      if (code == ProcedureRequestStatus.RECEIVED)
246        return "received";
247      if (code == ProcedureRequestStatus.ACCEPTED)
248        return "accepted";
249      if (code == ProcedureRequestStatus.INPROGRESS)
250        return "in-progress";
251      if (code == ProcedureRequestStatus.COMPLETED)
252        return "completed";
253      if (code == ProcedureRequestStatus.SUSPENDED)
254        return "suspended";
255      if (code == ProcedureRequestStatus.REJECTED)
256        return "rejected";
257      if (code == ProcedureRequestStatus.ABORTED)
258        return "aborted";
259      return "?";
260      }
261    }
262
263    public enum ProcedureRequestPriority {
264        /**
265         * The request has a normal priority.
266         */
267        ROUTINE, 
268        /**
269         * The request should be done urgently.
270         */
271        URGENT, 
272        /**
273         * The request is time-critical.
274         */
275        STAT, 
276        /**
277         * The request should be acted on as soon as possible.
278         */
279        ASAP, 
280        /**
281         * added to help the parsers
282         */
283        NULL;
284        public static ProcedureRequestPriority fromCode(String codeString) throws FHIRException {
285            if (codeString == null || "".equals(codeString))
286                return null;
287        if ("routine".equals(codeString))
288          return ROUTINE;
289        if ("urgent".equals(codeString))
290          return URGENT;
291        if ("stat".equals(codeString))
292          return STAT;
293        if ("asap".equals(codeString))
294          return ASAP;
295        throw new FHIRException("Unknown ProcedureRequestPriority code '"+codeString+"'");
296        }
297        public String toCode() {
298          switch (this) {
299            case ROUTINE: return "routine";
300            case URGENT: return "urgent";
301            case STAT: return "stat";
302            case ASAP: return "asap";
303            default: return "?";
304          }
305        }
306        public String getSystem() {
307          switch (this) {
308            case ROUTINE: return "http://hl7.org/fhir/procedure-request-priority";
309            case URGENT: return "http://hl7.org/fhir/procedure-request-priority";
310            case STAT: return "http://hl7.org/fhir/procedure-request-priority";
311            case ASAP: return "http://hl7.org/fhir/procedure-request-priority";
312            default: return "?";
313          }
314        }
315        public String getDefinition() {
316          switch (this) {
317            case ROUTINE: return "The request has a normal priority.";
318            case URGENT: return "The request should be done urgently.";
319            case STAT: return "The request is time-critical.";
320            case ASAP: return "The request should be acted on as soon as possible.";
321            default: return "?";
322          }
323        }
324        public String getDisplay() {
325          switch (this) {
326            case ROUTINE: return "Routine";
327            case URGENT: return "Urgent";
328            case STAT: return "Stat";
329            case ASAP: return "ASAP";
330            default: return "?";
331          }
332        }
333    }
334
335  public static class ProcedureRequestPriorityEnumFactory implements EnumFactory<ProcedureRequestPriority> {
336    public ProcedureRequestPriority fromCode(String codeString) throws IllegalArgumentException {
337      if (codeString == null || "".equals(codeString))
338            if (codeString == null || "".equals(codeString))
339                return null;
340        if ("routine".equals(codeString))
341          return ProcedureRequestPriority.ROUTINE;
342        if ("urgent".equals(codeString))
343          return ProcedureRequestPriority.URGENT;
344        if ("stat".equals(codeString))
345          return ProcedureRequestPriority.STAT;
346        if ("asap".equals(codeString))
347          return ProcedureRequestPriority.ASAP;
348        throw new IllegalArgumentException("Unknown ProcedureRequestPriority code '"+codeString+"'");
349        }
350        public Enumeration<ProcedureRequestPriority> fromType(Base code) throws FHIRException {
351          if (code == null || code.isEmpty())
352            return null;
353          String codeString = ((PrimitiveType) code).asStringValue();
354          if (codeString == null || "".equals(codeString))
355            return null;
356        if ("routine".equals(codeString))
357          return new Enumeration<ProcedureRequestPriority>(this, ProcedureRequestPriority.ROUTINE);
358        if ("urgent".equals(codeString))
359          return new Enumeration<ProcedureRequestPriority>(this, ProcedureRequestPriority.URGENT);
360        if ("stat".equals(codeString))
361          return new Enumeration<ProcedureRequestPriority>(this, ProcedureRequestPriority.STAT);
362        if ("asap".equals(codeString))
363          return new Enumeration<ProcedureRequestPriority>(this, ProcedureRequestPriority.ASAP);
364        throw new FHIRException("Unknown ProcedureRequestPriority code '"+codeString+"'");
365        }
366    public String toCode(ProcedureRequestPriority code) {
367      if (code == ProcedureRequestPriority.ROUTINE)
368        return "routine";
369      if (code == ProcedureRequestPriority.URGENT)
370        return "urgent";
371      if (code == ProcedureRequestPriority.STAT)
372        return "stat";
373      if (code == ProcedureRequestPriority.ASAP)
374        return "asap";
375      return "?";
376      }
377    }
378
379    /**
380     * Identifiers assigned to this order by the order or by the receiver.
381     */
382    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
383    @Description(shortDefinition="Unique identifier for the request", formalDefinition="Identifiers assigned to this order by the order or by the receiver." )
384    protected List<Identifier> identifier;
385
386    /**
387     * The person, animal or group that should receive the procedure.
388     */
389    @Child(name = "subject", type = {Patient.class, Group.class}, order=1, min=1, max=1, modifier=false, summary=true)
390    @Description(shortDefinition="Who the procedure should be done to", formalDefinition="The person, animal or group that should receive the procedure." )
391    protected Reference subject;
392
393    /**
394     * The actual object that is the target of the reference (The person, animal or group that should receive the procedure.)
395     */
396    protected Resource subjectTarget;
397
398    /**
399     * The specific procedure that is ordered. Use text if the exact nature of the procedure cannot be coded.
400     */
401    @Child(name = "code", type = {CodeableConcept.class}, order=2, min=1, max=1, modifier=false, summary=true)
402    @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." )
403    protected CodeableConcept code;
404
405    /**
406     * Indicates the sites on the subject's body where the procedure should be performed (I.e. the target sites).
407     */
408    @Child(name = "bodySite", type = {CodeableConcept.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
409    @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)." )
410    protected List<CodeableConcept> bodySite;
411
412    /**
413     * The reason why the procedure is being proposed or ordered. This procedure request may be motivated by a Condition for instance.
414     */
415    @Child(name = "reason", type = {CodeableConcept.class, Condition.class}, order=4, min=0, max=1, modifier=false, summary=true)
416    @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." )
417    protected Type reason;
418
419    /**
420     * 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".
421     */
422    @Child(name = "scheduled", type = {DateTimeType.class, Period.class, Timing.class}, order=5, min=0, max=1, modifier=false, summary=true)
423    @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\"." )
424    protected Type scheduled;
425
426    /**
427     * The encounter within which the procedure proposal or request was created.
428     */
429    @Child(name = "encounter", type = {Encounter.class}, order=6, min=0, max=1, modifier=false, summary=true)
430    @Description(shortDefinition="Encounter request created during", formalDefinition="The encounter within which the procedure proposal or request was created." )
431    protected Reference encounter;
432
433    /**
434     * The actual object that is the target of the reference (The encounter within which the procedure proposal or request was created.)
435     */
436    protected Encounter encounterTarget;
437
438    /**
439     * For example, the surgeon, anaethetist, endoscopist, etc.
440     */
441    @Child(name = "performer", type = {Practitioner.class, Organization.class, Patient.class, RelatedPerson.class}, order=7, min=0, max=1, modifier=false, summary=true)
442    @Description(shortDefinition="Who should perform the procedure", formalDefinition="For example, the surgeon, anaethetist, endoscopist, etc." )
443    protected Reference performer;
444
445    /**
446     * The actual object that is the target of the reference (For example, the surgeon, anaethetist, endoscopist, etc.)
447     */
448    protected Resource performerTarget;
449
450    /**
451     * The status of the order.
452     */
453    @Child(name = "status", type = {CodeType.class}, order=8, min=0, max=1, modifier=true, summary=true)
454    @Description(shortDefinition="proposed | draft | requested | received | accepted | in-progress | completed | suspended | rejected | aborted", formalDefinition="The status of the order." )
455    protected Enumeration<ProcedureRequestStatus> status;
456
457    /**
458     * Any other notes associated with this proposal or order - e.g. provider instructions.
459     */
460    @Child(name = "notes", type = {Annotation.class}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
461    @Description(shortDefinition="Additional information about desired procedure", formalDefinition="Any other notes associated with this proposal or order - e.g. provider instructions." )
462    protected List<Annotation> notes;
463
464    /**
465     * If a CodeableConcept is present, it indicates the pre-condition for performing the procedure.
466     */
467    @Child(name = "asNeeded", type = {BooleanType.class, CodeableConcept.class}, order=10, min=0, max=1, modifier=false, summary=true)
468    @Description(shortDefinition="Preconditions for procedure", formalDefinition="If a CodeableConcept is present, it indicates the pre-condition for performing the procedure." )
469    protected Type asNeeded;
470
471    /**
472     * The time when the request was made.
473     */
474    @Child(name = "orderedOn", type = {DateTimeType.class}, order=11, min=0, max=1, modifier=false, summary=true)
475    @Description(shortDefinition="When request was created", formalDefinition="The time when the request was made." )
476    protected DateTimeType orderedOn;
477
478    /**
479     * The healthcare professional responsible for proposing or ordering the procedure.
480     */
481    @Child(name = "orderer", type = {Practitioner.class, Patient.class, RelatedPerson.class, Device.class}, order=12, min=0, max=1, modifier=false, summary=true)
482    @Description(shortDefinition="Who made request", formalDefinition="The healthcare professional responsible for proposing or ordering the procedure." )
483    protected Reference orderer;
484
485    /**
486     * The actual object that is the target of the reference (The healthcare professional responsible for proposing or ordering the procedure.)
487     */
488    protected Resource ordererTarget;
489
490    /**
491     * The clinical priority associated with this order.
492     */
493    @Child(name = "priority", type = {CodeType.class}, order=13, min=0, max=1, modifier=false, summary=true)
494    @Description(shortDefinition="routine | urgent | stat | asap", formalDefinition="The clinical priority associated with this order." )
495    protected Enumeration<ProcedureRequestPriority> priority;
496
497    private static final long serialVersionUID = -916650578L;
498
499  /*
500   * Constructor
501   */
502    public ProcedureRequest() {
503      super();
504    }
505
506  /*
507   * Constructor
508   */
509    public ProcedureRequest(Reference subject, CodeableConcept code) {
510      super();
511      this.subject = subject;
512      this.code = code;
513    }
514
515    /**
516     * @return {@link #identifier} (Identifiers assigned to this order by the order or by the receiver.)
517     */
518    public List<Identifier> getIdentifier() { 
519      if (this.identifier == null)
520        this.identifier = new ArrayList<Identifier>();
521      return this.identifier;
522    }
523
524    public boolean hasIdentifier() { 
525      if (this.identifier == null)
526        return false;
527      for (Identifier item : this.identifier)
528        if (!item.isEmpty())
529          return true;
530      return false;
531    }
532
533    /**
534     * @return {@link #identifier} (Identifiers assigned to this order by the order or by the receiver.)
535     */
536    // syntactic sugar
537    public Identifier addIdentifier() { //3
538      Identifier t = new Identifier();
539      if (this.identifier == null)
540        this.identifier = new ArrayList<Identifier>();
541      this.identifier.add(t);
542      return t;
543    }
544
545    // syntactic sugar
546    public ProcedureRequest addIdentifier(Identifier t) { //3
547      if (t == null)
548        return this;
549      if (this.identifier == null)
550        this.identifier = new ArrayList<Identifier>();
551      this.identifier.add(t);
552      return this;
553    }
554
555    /**
556     * @return {@link #subject} (The person, animal or group that should receive the procedure.)
557     */
558    public Reference getSubject() { 
559      if (this.subject == null)
560        if (Configuration.errorOnAutoCreate())
561          throw new Error("Attempt to auto-create ProcedureRequest.subject");
562        else if (Configuration.doAutoCreate())
563          this.subject = new Reference(); // cc
564      return this.subject;
565    }
566
567    public boolean hasSubject() { 
568      return this.subject != null && !this.subject.isEmpty();
569    }
570
571    /**
572     * @param value {@link #subject} (The person, animal or group that should receive the procedure.)
573     */
574    public ProcedureRequest setSubject(Reference value) { 
575      this.subject = value;
576      return this;
577    }
578
579    /**
580     * @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.)
581     */
582    public Resource getSubjectTarget() { 
583      return this.subjectTarget;
584    }
585
586    /**
587     * @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.)
588     */
589    public ProcedureRequest setSubjectTarget(Resource value) { 
590      this.subjectTarget = value;
591      return this;
592    }
593
594    /**
595     * @return {@link #code} (The specific procedure that is ordered. Use text if the exact nature of the procedure cannot be coded.)
596     */
597    public CodeableConcept getCode() { 
598      if (this.code == null)
599        if (Configuration.errorOnAutoCreate())
600          throw new Error("Attempt to auto-create ProcedureRequest.code");
601        else if (Configuration.doAutoCreate())
602          this.code = new CodeableConcept(); // cc
603      return this.code;
604    }
605
606    public boolean hasCode() { 
607      return this.code != null && !this.code.isEmpty();
608    }
609
610    /**
611     * @param value {@link #code} (The specific procedure that is ordered. Use text if the exact nature of the procedure cannot be coded.)
612     */
613    public ProcedureRequest setCode(CodeableConcept value) { 
614      this.code = value;
615      return this;
616    }
617
618    /**
619     * @return {@link #bodySite} (Indicates the sites on the subject's body where the procedure should be performed (I.e. the target sites).)
620     */
621    public List<CodeableConcept> getBodySite() { 
622      if (this.bodySite == null)
623        this.bodySite = new ArrayList<CodeableConcept>();
624      return this.bodySite;
625    }
626
627    public boolean hasBodySite() { 
628      if (this.bodySite == null)
629        return false;
630      for (CodeableConcept item : this.bodySite)
631        if (!item.isEmpty())
632          return true;
633      return false;
634    }
635
636    /**
637     * @return {@link #bodySite} (Indicates the sites on the subject's body where the procedure should be performed (I.e. the target sites).)
638     */
639    // syntactic sugar
640    public CodeableConcept addBodySite() { //3
641      CodeableConcept t = new CodeableConcept();
642      if (this.bodySite == null)
643        this.bodySite = new ArrayList<CodeableConcept>();
644      this.bodySite.add(t);
645      return t;
646    }
647
648    // syntactic sugar
649    public ProcedureRequest addBodySite(CodeableConcept t) { //3
650      if (t == null)
651        return this;
652      if (this.bodySite == null)
653        this.bodySite = new ArrayList<CodeableConcept>();
654      this.bodySite.add(t);
655      return this;
656    }
657
658    /**
659     * @return {@link #reason} (The reason why the procedure is being proposed or ordered. This procedure request may be motivated by a Condition for instance.)
660     */
661    public Type getReason() { 
662      return this.reason;
663    }
664
665    /**
666     * @return {@link #reason} (The reason why the procedure is being proposed or ordered. This procedure request may be motivated by a Condition for instance.)
667     */
668    public CodeableConcept getReasonCodeableConcept() throws FHIRException { 
669      if (!(this.reason instanceof CodeableConcept))
670        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.reason.getClass().getName()+" was encountered");
671      return (CodeableConcept) this.reason;
672    }
673
674    public boolean hasReasonCodeableConcept() { 
675      return this.reason instanceof CodeableConcept;
676    }
677
678    /**
679     * @return {@link #reason} (The reason why the procedure is being proposed or ordered. This procedure request may be motivated by a Condition for instance.)
680     */
681    public Reference getReasonReference() throws FHIRException { 
682      if (!(this.reason instanceof Reference))
683        throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.reason.getClass().getName()+" was encountered");
684      return (Reference) this.reason;
685    }
686
687    public boolean hasReasonReference() { 
688      return this.reason instanceof Reference;
689    }
690
691    public boolean hasReason() { 
692      return this.reason != null && !this.reason.isEmpty();
693    }
694
695    /**
696     * @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.)
697     */
698    public ProcedureRequest setReason(Type value) { 
699      this.reason = value;
700      return this;
701    }
702
703    /**
704     * @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".)
705     */
706    public Type getScheduled() { 
707      return this.scheduled;
708    }
709
710    /**
711     * @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".)
712     */
713    public DateTimeType getScheduledDateTimeType() throws FHIRException { 
714      if (!(this.scheduled instanceof DateTimeType))
715        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.scheduled.getClass().getName()+" was encountered");
716      return (DateTimeType) this.scheduled;
717    }
718
719    public boolean hasScheduledDateTimeType() { 
720      return this.scheduled instanceof DateTimeType;
721    }
722
723    /**
724     * @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".)
725     */
726    public Period getScheduledPeriod() throws FHIRException { 
727      if (!(this.scheduled instanceof Period))
728        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.scheduled.getClass().getName()+" was encountered");
729      return (Period) this.scheduled;
730    }
731
732    public boolean hasScheduledPeriod() { 
733      return this.scheduled instanceof Period;
734    }
735
736    /**
737     * @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".)
738     */
739    public Timing getScheduledTiming() throws FHIRException { 
740      if (!(this.scheduled instanceof Timing))
741        throw new FHIRException("Type mismatch: the type Timing was expected, but "+this.scheduled.getClass().getName()+" was encountered");
742      return (Timing) this.scheduled;
743    }
744
745    public boolean hasScheduledTiming() { 
746      return this.scheduled instanceof Timing;
747    }
748
749    public boolean hasScheduled() { 
750      return this.scheduled != null && !this.scheduled.isEmpty();
751    }
752
753    /**
754     * @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".)
755     */
756    public ProcedureRequest setScheduled(Type value) { 
757      this.scheduled = value;
758      return this;
759    }
760
761    /**
762     * @return {@link #encounter} (The encounter within which the procedure proposal or request was created.)
763     */
764    public Reference getEncounter() { 
765      if (this.encounter == null)
766        if (Configuration.errorOnAutoCreate())
767          throw new Error("Attempt to auto-create ProcedureRequest.encounter");
768        else if (Configuration.doAutoCreate())
769          this.encounter = new Reference(); // cc
770      return this.encounter;
771    }
772
773    public boolean hasEncounter() { 
774      return this.encounter != null && !this.encounter.isEmpty();
775    }
776
777    /**
778     * @param value {@link #encounter} (The encounter within which the procedure proposal or request was created.)
779     */
780    public ProcedureRequest setEncounter(Reference value) { 
781      this.encounter = value;
782      return this;
783    }
784
785    /**
786     * @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.)
787     */
788    public Encounter getEncounterTarget() { 
789      if (this.encounterTarget == null)
790        if (Configuration.errorOnAutoCreate())
791          throw new Error("Attempt to auto-create ProcedureRequest.encounter");
792        else if (Configuration.doAutoCreate())
793          this.encounterTarget = new Encounter(); // aa
794      return this.encounterTarget;
795    }
796
797    /**
798     * @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.)
799     */
800    public ProcedureRequest setEncounterTarget(Encounter value) { 
801      this.encounterTarget = value;
802      return this;
803    }
804
805    /**
806     * @return {@link #performer} (For example, the surgeon, anaethetist, endoscopist, etc.)
807     */
808    public Reference getPerformer() { 
809      if (this.performer == null)
810        if (Configuration.errorOnAutoCreate())
811          throw new Error("Attempt to auto-create ProcedureRequest.performer");
812        else if (Configuration.doAutoCreate())
813          this.performer = new Reference(); // cc
814      return this.performer;
815    }
816
817    public boolean hasPerformer() { 
818      return this.performer != null && !this.performer.isEmpty();
819    }
820
821    /**
822     * @param value {@link #performer} (For example, the surgeon, anaethetist, endoscopist, etc.)
823     */
824    public ProcedureRequest setPerformer(Reference value) { 
825      this.performer = value;
826      return this;
827    }
828
829    /**
830     * @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.)
831     */
832    public Resource getPerformerTarget() { 
833      return this.performerTarget;
834    }
835
836    /**
837     * @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.)
838     */
839    public ProcedureRequest setPerformerTarget(Resource value) { 
840      this.performerTarget = value;
841      return this;
842    }
843
844    /**
845     * @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
846     */
847    public Enumeration<ProcedureRequestStatus> getStatusElement() { 
848      if (this.status == null)
849        if (Configuration.errorOnAutoCreate())
850          throw new Error("Attempt to auto-create ProcedureRequest.status");
851        else if (Configuration.doAutoCreate())
852          this.status = new Enumeration<ProcedureRequestStatus>(new ProcedureRequestStatusEnumFactory()); // bb
853      return this.status;
854    }
855
856    public boolean hasStatusElement() { 
857      return this.status != null && !this.status.isEmpty();
858    }
859
860    public boolean hasStatus() { 
861      return this.status != null && !this.status.isEmpty();
862    }
863
864    /**
865     * @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
866     */
867    public ProcedureRequest setStatusElement(Enumeration<ProcedureRequestStatus> value) { 
868      this.status = value;
869      return this;
870    }
871
872    /**
873     * @return The status of the order.
874     */
875    public ProcedureRequestStatus getStatus() { 
876      return this.status == null ? null : this.status.getValue();
877    }
878
879    /**
880     * @param value The status of the order.
881     */
882    public ProcedureRequest setStatus(ProcedureRequestStatus value) { 
883      if (value == null)
884        this.status = null;
885      else {
886        if (this.status == null)
887          this.status = new Enumeration<ProcedureRequestStatus>(new ProcedureRequestStatusEnumFactory());
888        this.status.setValue(value);
889      }
890      return this;
891    }
892
893    /**
894     * @return {@link #notes} (Any other notes associated with this proposal or order - e.g. provider instructions.)
895     */
896    public List<Annotation> getNotes() { 
897      if (this.notes == null)
898        this.notes = new ArrayList<Annotation>();
899      return this.notes;
900    }
901
902    public boolean hasNotes() { 
903      if (this.notes == null)
904        return false;
905      for (Annotation item : this.notes)
906        if (!item.isEmpty())
907          return true;
908      return false;
909    }
910
911    /**
912     * @return {@link #notes} (Any other notes associated with this proposal or order - e.g. provider instructions.)
913     */
914    // syntactic sugar
915    public Annotation addNotes() { //3
916      Annotation t = new Annotation();
917      if (this.notes == null)
918        this.notes = new ArrayList<Annotation>();
919      this.notes.add(t);
920      return t;
921    }
922
923    // syntactic sugar
924    public ProcedureRequest addNotes(Annotation t) { //3
925      if (t == null)
926        return this;
927      if (this.notes == null)
928        this.notes = new ArrayList<Annotation>();
929      this.notes.add(t);
930      return this;
931    }
932
933    /**
934     * @return {@link #asNeeded} (If a CodeableConcept is present, it indicates the pre-condition for performing the procedure.)
935     */
936    public Type getAsNeeded() { 
937      return this.asNeeded;
938    }
939
940    /**
941     * @return {@link #asNeeded} (If a CodeableConcept is present, it indicates the pre-condition for performing the procedure.)
942     */
943    public BooleanType getAsNeededBooleanType() throws FHIRException { 
944      if (!(this.asNeeded instanceof BooleanType))
945        throw new FHIRException("Type mismatch: the type BooleanType was expected, but "+this.asNeeded.getClass().getName()+" was encountered");
946      return (BooleanType) this.asNeeded;
947    }
948
949    public boolean hasAsNeededBooleanType() { 
950      return this.asNeeded instanceof BooleanType;
951    }
952
953    /**
954     * @return {@link #asNeeded} (If a CodeableConcept is present, it indicates the pre-condition for performing the procedure.)
955     */
956    public CodeableConcept getAsNeededCodeableConcept() throws FHIRException { 
957      if (!(this.asNeeded instanceof CodeableConcept))
958        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.asNeeded.getClass().getName()+" was encountered");
959      return (CodeableConcept) this.asNeeded;
960    }
961
962    public boolean hasAsNeededCodeableConcept() { 
963      return this.asNeeded instanceof CodeableConcept;
964    }
965
966    public boolean hasAsNeeded() { 
967      return this.asNeeded != null && !this.asNeeded.isEmpty();
968    }
969
970    /**
971     * @param value {@link #asNeeded} (If a CodeableConcept is present, it indicates the pre-condition for performing the procedure.)
972     */
973    public ProcedureRequest setAsNeeded(Type value) { 
974      this.asNeeded = value;
975      return this;
976    }
977
978    /**
979     * @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
980     */
981    public DateTimeType getOrderedOnElement() { 
982      if (this.orderedOn == null)
983        if (Configuration.errorOnAutoCreate())
984          throw new Error("Attempt to auto-create ProcedureRequest.orderedOn");
985        else if (Configuration.doAutoCreate())
986          this.orderedOn = new DateTimeType(); // bb
987      return this.orderedOn;
988    }
989
990    public boolean hasOrderedOnElement() { 
991      return this.orderedOn != null && !this.orderedOn.isEmpty();
992    }
993
994    public boolean hasOrderedOn() { 
995      return this.orderedOn != null && !this.orderedOn.isEmpty();
996    }
997
998    /**
999     * @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
1000     */
1001    public ProcedureRequest setOrderedOnElement(DateTimeType value) { 
1002      this.orderedOn = value;
1003      return this;
1004    }
1005
1006    /**
1007     * @return The time when the request was made.
1008     */
1009    public Date getOrderedOn() { 
1010      return this.orderedOn == null ? null : this.orderedOn.getValue();
1011    }
1012
1013    /**
1014     * @param value The time when the request was made.
1015     */
1016    public ProcedureRequest setOrderedOn(Date value) { 
1017      if (value == null)
1018        this.orderedOn = null;
1019      else {
1020        if (this.orderedOn == null)
1021          this.orderedOn = new DateTimeType();
1022        this.orderedOn.setValue(value);
1023      }
1024      return this;
1025    }
1026
1027    /**
1028     * @return {@link #orderer} (The healthcare professional responsible for proposing or ordering the procedure.)
1029     */
1030    public Reference getOrderer() { 
1031      if (this.orderer == null)
1032        if (Configuration.errorOnAutoCreate())
1033          throw new Error("Attempt to auto-create ProcedureRequest.orderer");
1034        else if (Configuration.doAutoCreate())
1035          this.orderer = new Reference(); // cc
1036      return this.orderer;
1037    }
1038
1039    public boolean hasOrderer() { 
1040      return this.orderer != null && !this.orderer.isEmpty();
1041    }
1042
1043    /**
1044     * @param value {@link #orderer} (The healthcare professional responsible for proposing or ordering the procedure.)
1045     */
1046    public ProcedureRequest setOrderer(Reference value) { 
1047      this.orderer = value;
1048      return this;
1049    }
1050
1051    /**
1052     * @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.)
1053     */
1054    public Resource getOrdererTarget() { 
1055      return this.ordererTarget;
1056    }
1057
1058    /**
1059     * @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.)
1060     */
1061    public ProcedureRequest setOrdererTarget(Resource value) { 
1062      this.ordererTarget = value;
1063      return this;
1064    }
1065
1066    /**
1067     * @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
1068     */
1069    public Enumeration<ProcedureRequestPriority> getPriorityElement() { 
1070      if (this.priority == null)
1071        if (Configuration.errorOnAutoCreate())
1072          throw new Error("Attempt to auto-create ProcedureRequest.priority");
1073        else if (Configuration.doAutoCreate())
1074          this.priority = new Enumeration<ProcedureRequestPriority>(new ProcedureRequestPriorityEnumFactory()); // bb
1075      return this.priority;
1076    }
1077
1078    public boolean hasPriorityElement() { 
1079      return this.priority != null && !this.priority.isEmpty();
1080    }
1081
1082    public boolean hasPriority() { 
1083      return this.priority != null && !this.priority.isEmpty();
1084    }
1085
1086    /**
1087     * @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
1088     */
1089    public ProcedureRequest setPriorityElement(Enumeration<ProcedureRequestPriority> value) { 
1090      this.priority = value;
1091      return this;
1092    }
1093
1094    /**
1095     * @return The clinical priority associated with this order.
1096     */
1097    public ProcedureRequestPriority getPriority() { 
1098      return this.priority == null ? null : this.priority.getValue();
1099    }
1100
1101    /**
1102     * @param value The clinical priority associated with this order.
1103     */
1104    public ProcedureRequest setPriority(ProcedureRequestPriority value) { 
1105      if (value == null)
1106        this.priority = null;
1107      else {
1108        if (this.priority == null)
1109          this.priority = new Enumeration<ProcedureRequestPriority>(new ProcedureRequestPriorityEnumFactory());
1110        this.priority.setValue(value);
1111      }
1112      return this;
1113    }
1114
1115      protected void listChildren(List<Property> childrenList) {
1116        super.listChildren(childrenList);
1117        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));
1118        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));
1119        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));
1120        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));
1121        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));
1122        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));
1123        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));
1124        childrenList.add(new Property("performer", "Reference(Practitioner|Organization|Patient|RelatedPerson)", "For example, the surgeon, anaethetist, endoscopist, etc.", 0, java.lang.Integer.MAX_VALUE, performer));
1125        childrenList.add(new Property("status", "code", "The status of the order.", 0, java.lang.Integer.MAX_VALUE, status));
1126        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));
1127        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));
1128        childrenList.add(new Property("orderedOn", "dateTime", "The time when the request was made.", 0, java.lang.Integer.MAX_VALUE, orderedOn));
1129        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));
1130        childrenList.add(new Property("priority", "code", "The clinical priority associated with this order.", 0, java.lang.Integer.MAX_VALUE, priority));
1131      }
1132
1133      @Override
1134      public void setProperty(String name, Base value) throws FHIRException {
1135        if (name.equals("identifier"))
1136          this.getIdentifier().add(castToIdentifier(value));
1137        else if (name.equals("subject"))
1138          this.subject = castToReference(value); // Reference
1139        else if (name.equals("code"))
1140          this.code = castToCodeableConcept(value); // CodeableConcept
1141        else if (name.equals("bodySite"))
1142          this.getBodySite().add(castToCodeableConcept(value));
1143        else if (name.equals("reason[x]"))
1144          this.reason = (Type) value; // Type
1145        else if (name.equals("scheduled[x]"))
1146          this.scheduled = (Type) value; // Type
1147        else if (name.equals("encounter"))
1148          this.encounter = castToReference(value); // Reference
1149        else if (name.equals("performer"))
1150          this.performer = castToReference(value); // Reference
1151        else if (name.equals("status"))
1152          this.status = new ProcedureRequestStatusEnumFactory().fromType(value); // Enumeration<ProcedureRequestStatus>
1153        else if (name.equals("notes"))
1154          this.getNotes().add(castToAnnotation(value));
1155        else if (name.equals("asNeeded[x]"))
1156          this.asNeeded = (Type) value; // Type
1157        else if (name.equals("orderedOn"))
1158          this.orderedOn = castToDateTime(value); // DateTimeType
1159        else if (name.equals("orderer"))
1160          this.orderer = castToReference(value); // Reference
1161        else if (name.equals("priority"))
1162          this.priority = new ProcedureRequestPriorityEnumFactory().fromType(value); // Enumeration<ProcedureRequestPriority>
1163        else
1164          super.setProperty(name, value);
1165      }
1166
1167      @Override
1168      public Base addChild(String name) throws FHIRException {
1169        if (name.equals("identifier")) {
1170          return addIdentifier();
1171        }
1172        else if (name.equals("subject")) {
1173          this.subject = new Reference();
1174          return this.subject;
1175        }
1176        else if (name.equals("code")) {
1177          this.code = new CodeableConcept();
1178          return this.code;
1179        }
1180        else if (name.equals("bodySite")) {
1181          return addBodySite();
1182        }
1183        else if (name.equals("reasonCodeableConcept")) {
1184          this.reason = new CodeableConcept();
1185          return this.reason;
1186        }
1187        else if (name.equals("reasonReference")) {
1188          this.reason = new Reference();
1189          return this.reason;
1190        }
1191        else if (name.equals("scheduledDateTime")) {
1192          this.scheduled = new DateTimeType();
1193          return this.scheduled;
1194        }
1195        else if (name.equals("scheduledPeriod")) {
1196          this.scheduled = new Period();
1197          return this.scheduled;
1198        }
1199        else if (name.equals("scheduledTiming")) {
1200          this.scheduled = new Timing();
1201          return this.scheduled;
1202        }
1203        else if (name.equals("encounter")) {
1204          this.encounter = new Reference();
1205          return this.encounter;
1206        }
1207        else if (name.equals("performer")) {
1208          this.performer = new Reference();
1209          return this.performer;
1210        }
1211        else if (name.equals("status")) {
1212          throw new FHIRException("Cannot call addChild on a primitive type ProcedureRequest.status");
1213        }
1214        else if (name.equals("notes")) {
1215          return addNotes();
1216        }
1217        else if (name.equals("asNeededBoolean")) {
1218          this.asNeeded = new BooleanType();
1219          return this.asNeeded;
1220        }
1221        else if (name.equals("asNeededCodeableConcept")) {
1222          this.asNeeded = new CodeableConcept();
1223          return this.asNeeded;
1224        }
1225        else if (name.equals("orderedOn")) {
1226          throw new FHIRException("Cannot call addChild on a primitive type ProcedureRequest.orderedOn");
1227        }
1228        else if (name.equals("orderer")) {
1229          this.orderer = new Reference();
1230          return this.orderer;
1231        }
1232        else if (name.equals("priority")) {
1233          throw new FHIRException("Cannot call addChild on a primitive type ProcedureRequest.priority");
1234        }
1235        else
1236          return super.addChild(name);
1237      }
1238
1239  public String fhirType() {
1240    return "ProcedureRequest";
1241
1242  }
1243
1244      public ProcedureRequest copy() {
1245        ProcedureRequest dst = new ProcedureRequest();
1246        copyValues(dst);
1247        if (identifier != null) {
1248          dst.identifier = new ArrayList<Identifier>();
1249          for (Identifier i : identifier)
1250            dst.identifier.add(i.copy());
1251        };
1252        dst.subject = subject == null ? null : subject.copy();
1253        dst.code = code == null ? null : code.copy();
1254        if (bodySite != null) {
1255          dst.bodySite = new ArrayList<CodeableConcept>();
1256          for (CodeableConcept i : bodySite)
1257            dst.bodySite.add(i.copy());
1258        };
1259        dst.reason = reason == null ? null : reason.copy();
1260        dst.scheduled = scheduled == null ? null : scheduled.copy();
1261        dst.encounter = encounter == null ? null : encounter.copy();
1262        dst.performer = performer == null ? null : performer.copy();
1263        dst.status = status == null ? null : status.copy();
1264        if (notes != null) {
1265          dst.notes = new ArrayList<Annotation>();
1266          for (Annotation i : notes)
1267            dst.notes.add(i.copy());
1268        };
1269        dst.asNeeded = asNeeded == null ? null : asNeeded.copy();
1270        dst.orderedOn = orderedOn == null ? null : orderedOn.copy();
1271        dst.orderer = orderer == null ? null : orderer.copy();
1272        dst.priority = priority == null ? null : priority.copy();
1273        return dst;
1274      }
1275
1276      protected ProcedureRequest typedCopy() {
1277        return copy();
1278      }
1279
1280      @Override
1281      public boolean equalsDeep(Base other) {
1282        if (!super.equalsDeep(other))
1283          return false;
1284        if (!(other instanceof ProcedureRequest))
1285          return false;
1286        ProcedureRequest o = (ProcedureRequest) other;
1287        return compareDeep(identifier, o.identifier, true) && compareDeep(subject, o.subject, true) && compareDeep(code, o.code, true)
1288           && compareDeep(bodySite, o.bodySite, true) && compareDeep(reason, o.reason, true) && compareDeep(scheduled, o.scheduled, true)
1289           && compareDeep(encounter, o.encounter, true) && compareDeep(performer, o.performer, true) && compareDeep(status, o.status, true)
1290           && compareDeep(notes, o.notes, true) && compareDeep(asNeeded, o.asNeeded, true) && compareDeep(orderedOn, o.orderedOn, true)
1291           && compareDeep(orderer, o.orderer, true) && compareDeep(priority, o.priority, true);
1292      }
1293
1294      @Override
1295      public boolean equalsShallow(Base other) {
1296        if (!super.equalsShallow(other))
1297          return false;
1298        if (!(other instanceof ProcedureRequest))
1299          return false;
1300        ProcedureRequest o = (ProcedureRequest) other;
1301        return compareValues(status, o.status, true) && compareValues(orderedOn, o.orderedOn, true) && compareValues(priority, o.priority, true)
1302          ;
1303      }
1304
1305      public boolean isEmpty() {
1306        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (subject == null || subject.isEmpty())
1307           && (code == null || code.isEmpty()) && (bodySite == null || bodySite.isEmpty()) && (reason == null || reason.isEmpty())
1308           && (scheduled == null || scheduled.isEmpty()) && (encounter == null || encounter.isEmpty())
1309           && (performer == null || performer.isEmpty()) && (status == null || status.isEmpty()) && (notes == null || notes.isEmpty())
1310           && (asNeeded == null || asNeeded.isEmpty()) && (orderedOn == null || orderedOn.isEmpty())
1311           && (orderer == null || orderer.isEmpty()) && (priority == null || priority.isEmpty());
1312      }
1313
1314  @Override
1315  public ResourceType getResourceType() {
1316    return ResourceType.ProcedureRequest;
1317   }
1318
1319  @SearchParamDefinition(name="identifier", path="ProcedureRequest.identifier", description="A unique identifier of the Procedure Request", type="token" )
1320  public static final String SP_IDENTIFIER = "identifier";
1321  @SearchParamDefinition(name="performer", path="ProcedureRequest.performer", description="Who should perform the procedure", type="reference" )
1322  public static final String SP_PERFORMER = "performer";
1323  @SearchParamDefinition(name="subject", path="ProcedureRequest.subject", description="Search by subject", type="reference" )
1324  public static final String SP_SUBJECT = "subject";
1325  @SearchParamDefinition(name="patient", path="ProcedureRequest.subject", description="Search by subject - a patient", type="reference" )
1326  public static final String SP_PATIENT = "patient";
1327  @SearchParamDefinition(name="orderer", path="ProcedureRequest.orderer", description="Who made request", type="reference" )
1328  public static final String SP_ORDERER = "orderer";
1329  @SearchParamDefinition(name="encounter", path="ProcedureRequest.encounter", description="Encounter request created during", type="reference" )
1330  public static final String SP_ENCOUNTER = "encounter";
1331
1332}