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