001package org.hl7.fhir.dstu3.model;
002
003/*-
004 * #%L
005 * org.hl7.fhir.dstu3
006 * %%
007 * Copyright (C) 2014 - 2019 Health Level 7
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 * 
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 * 
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023/*
024  Copyright (c) 2011+, HL7, Inc.
025  All rights reserved.
026  
027  Redistribution and use in source and binary forms, with or without modification, 
028  are permitted provided that the following conditions are met:
029  
030   * Redistributions of source code must retain the above copyright notice, this 
031     list of conditions and the following disclaimer.
032   * Redistributions in binary form must reproduce the above copyright notice, 
033     this list of conditions and the following disclaimer in the documentation 
034     and/or other materials provided with the distribution.
035   * Neither the name of HL7 nor the names of its contributors may be used to 
036     endorse or promote products derived from this software without specific 
037     prior written permission.
038  
039  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
040  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
041  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
042  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
043  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
044  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
045  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
046  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
047  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
048  POSSIBILITY OF SUCH DAMAGE.
049  
050*/
051
052// Generated on Fri, Mar 16, 2018 15:21+1100 for FHIR v3.0.x
053import java.util.ArrayList;
054import java.util.List;
055
056import org.hl7.fhir.exceptions.FHIRException;
057import org.hl7.fhir.exceptions.FHIRFormatError;
058import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
059
060import ca.uhn.fhir.model.api.annotation.Block;
061import ca.uhn.fhir.model.api.annotation.Child;
062import ca.uhn.fhir.model.api.annotation.Description;
063import ca.uhn.fhir.model.api.annotation.ResourceDef;
064import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
065/**
066 * An action that is or was performed on a patient. This can be a physical intervention like an operation, or less invasive like counseling or hypnotherapy.
067 */
068@ResourceDef(name="Procedure", profile="http://hl7.org/fhir/Profile/Procedure")
069public class Procedure extends DomainResource {
070
071    public enum ProcedureStatus {
072        /**
073         * The core event has not started yet, but some staging activities have begun (e.g. surgical suite preparation).  Preparation stages may be tracked for billing purposes.
074         */
075        PREPARATION, 
076        /**
077         * The event is currently occurring
078         */
079        INPROGRESS, 
080        /**
081         * The event has been temporarily stopped but is expected to resume in the future
082         */
083        SUSPENDED, 
084        /**
085         * The event was  prior to the full completion of the intended actions
086         */
087        ABORTED, 
088        /**
089         * The event has now concluded
090         */
091        COMPLETED, 
092        /**
093         * This electronic record should never have existed, though it is possible that real-world decisions were based on it.  (If real-world activity has occurred, the status should be "cancelled" rather than "entered-in-error".)
094         */
095        ENTEREDINERROR, 
096        /**
097         * The authoring system does not know which of the status values currently applies for this request.  Note: This concept is not to be used for "other" - one of the listed statuses is presumed to apply, it's just not known which one.
098         */
099        UNKNOWN, 
100        /**
101         * added to help the parsers with the generic types
102         */
103        NULL;
104        public static ProcedureStatus fromCode(String codeString) throws FHIRException {
105            if (codeString == null || "".equals(codeString))
106                return null;
107        if ("preparation".equals(codeString))
108          return PREPARATION;
109        if ("in-progress".equals(codeString))
110          return INPROGRESS;
111        if ("suspended".equals(codeString))
112          return SUSPENDED;
113        if ("aborted".equals(codeString))
114          return ABORTED;
115        if ("completed".equals(codeString))
116          return COMPLETED;
117        if ("entered-in-error".equals(codeString))
118          return ENTEREDINERROR;
119        if ("unknown".equals(codeString))
120          return UNKNOWN;
121        if (Configuration.isAcceptInvalidEnums())
122          return null;
123        else
124          throw new FHIRException("Unknown ProcedureStatus code '"+codeString+"'");
125        }
126        public String toCode() {
127          switch (this) {
128            case PREPARATION: return "preparation";
129            case INPROGRESS: return "in-progress";
130            case SUSPENDED: return "suspended";
131            case ABORTED: return "aborted";
132            case COMPLETED: return "completed";
133            case ENTEREDINERROR: return "entered-in-error";
134            case UNKNOWN: return "unknown";
135            default: return "?";
136          }
137        }
138        public String getSystem() {
139          switch (this) {
140            case PREPARATION: return "http://hl7.org/fhir/event-status";
141            case INPROGRESS: return "http://hl7.org/fhir/event-status";
142            case SUSPENDED: return "http://hl7.org/fhir/event-status";
143            case ABORTED: return "http://hl7.org/fhir/event-status";
144            case COMPLETED: return "http://hl7.org/fhir/event-status";
145            case ENTEREDINERROR: return "http://hl7.org/fhir/event-status";
146            case UNKNOWN: return "http://hl7.org/fhir/event-status";
147            default: return "?";
148          }
149        }
150        public String getDefinition() {
151          switch (this) {
152            case PREPARATION: return "The core event has not started yet, but some staging activities have begun (e.g. surgical suite preparation).  Preparation stages may be tracked for billing purposes.";
153            case INPROGRESS: return "The event is currently occurring";
154            case SUSPENDED: return "The event has been temporarily stopped but is expected to resume in the future";
155            case ABORTED: return "The event was  prior to the full completion of the intended actions";
156            case COMPLETED: return "The event has now concluded";
157            case ENTEREDINERROR: return "This electronic record should never have existed, though it is possible that real-world decisions were based on it.  (If real-world activity has occurred, the status should be \"cancelled\" rather than \"entered-in-error\".)";
158            case UNKNOWN: return "The authoring system does not know which of the status values currently applies for this request.  Note: This concept is not to be used for \"other\" - one of the listed statuses is presumed to apply, it's just not known which one.";
159            default: return "?";
160          }
161        }
162        public String getDisplay() {
163          switch (this) {
164            case PREPARATION: return "Preparation";
165            case INPROGRESS: return "In Progress";
166            case SUSPENDED: return "Suspended";
167            case ABORTED: return "Aborted";
168            case COMPLETED: return "Completed";
169            case ENTEREDINERROR: return "Entered in Error";
170            case UNKNOWN: return "Unknown";
171            default: return "?";
172          }
173        }
174    }
175
176  public static class ProcedureStatusEnumFactory implements EnumFactory<ProcedureStatus> {
177    public ProcedureStatus fromCode(String codeString) throws IllegalArgumentException {
178      if (codeString == null || "".equals(codeString))
179            if (codeString == null || "".equals(codeString))
180                return null;
181        if ("preparation".equals(codeString))
182          return ProcedureStatus.PREPARATION;
183        if ("in-progress".equals(codeString))
184          return ProcedureStatus.INPROGRESS;
185        if ("suspended".equals(codeString))
186          return ProcedureStatus.SUSPENDED;
187        if ("aborted".equals(codeString))
188          return ProcedureStatus.ABORTED;
189        if ("completed".equals(codeString))
190          return ProcedureStatus.COMPLETED;
191        if ("entered-in-error".equals(codeString))
192          return ProcedureStatus.ENTEREDINERROR;
193        if ("unknown".equals(codeString))
194          return ProcedureStatus.UNKNOWN;
195        throw new IllegalArgumentException("Unknown ProcedureStatus code '"+codeString+"'");
196        }
197        public Enumeration<ProcedureStatus> fromType(Base code) throws FHIRException {
198          if (code == null)
199            return null;
200          if (code.isEmpty())
201            return new Enumeration<ProcedureStatus>(this);
202          String codeString = ((PrimitiveType) code).asStringValue();
203          if (codeString == null || "".equals(codeString))
204            return null;
205        if ("preparation".equals(codeString))
206          return new Enumeration<ProcedureStatus>(this, ProcedureStatus.PREPARATION);
207        if ("in-progress".equals(codeString))
208          return new Enumeration<ProcedureStatus>(this, ProcedureStatus.INPROGRESS);
209        if ("suspended".equals(codeString))
210          return new Enumeration<ProcedureStatus>(this, ProcedureStatus.SUSPENDED);
211        if ("aborted".equals(codeString))
212          return new Enumeration<ProcedureStatus>(this, ProcedureStatus.ABORTED);
213        if ("completed".equals(codeString))
214          return new Enumeration<ProcedureStatus>(this, ProcedureStatus.COMPLETED);
215        if ("entered-in-error".equals(codeString))
216          return new Enumeration<ProcedureStatus>(this, ProcedureStatus.ENTEREDINERROR);
217        if ("unknown".equals(codeString))
218          return new Enumeration<ProcedureStatus>(this, ProcedureStatus.UNKNOWN);
219        throw new FHIRException("Unknown ProcedureStatus code '"+codeString+"'");
220        }
221    public String toCode(ProcedureStatus code) {
222      if (code == ProcedureStatus.PREPARATION)
223        return "preparation";
224      if (code == ProcedureStatus.INPROGRESS)
225        return "in-progress";
226      if (code == ProcedureStatus.SUSPENDED)
227        return "suspended";
228      if (code == ProcedureStatus.ABORTED)
229        return "aborted";
230      if (code == ProcedureStatus.COMPLETED)
231        return "completed";
232      if (code == ProcedureStatus.ENTEREDINERROR)
233        return "entered-in-error";
234      if (code == ProcedureStatus.UNKNOWN)
235        return "unknown";
236      return "?";
237      }
238    public String toSystem(ProcedureStatus code) {
239      return code.getSystem();
240      }
241    }
242
243    @Block()
244    public static class ProcedurePerformerComponent extends BackboneElement implements IBaseBackboneElement {
245        /**
246         * For example: surgeon, anaethetist, endoscopist.
247         */
248        @Child(name = "role", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
249        @Description(shortDefinition="The role the actor was in", formalDefinition="For example: surgeon, anaethetist, endoscopist." )
250        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/performer-role")
251        protected CodeableConcept role;
252
253        /**
254         * The practitioner who was involved in the procedure.
255         */
256        @Child(name = "actor", type = {Practitioner.class, Organization.class, Patient.class, RelatedPerson.class, Device.class}, order=2, min=1, max=1, modifier=false, summary=true)
257        @Description(shortDefinition="The reference to the practitioner", formalDefinition="The practitioner who was involved in the procedure." )
258        protected Reference actor;
259
260        /**
261         * The actual object that is the target of the reference (The practitioner who was involved in the procedure.)
262         */
263        protected Resource actorTarget;
264
265        /**
266         * The organization the device or practitioner was acting on behalf of.
267         */
268        @Child(name = "onBehalfOf", type = {Organization.class}, order=3, min=0, max=1, modifier=false, summary=false)
269        @Description(shortDefinition="Organization the device or practitioner was acting for", formalDefinition="The organization the device or practitioner was acting on behalf of." )
270        protected Reference onBehalfOf;
271
272        /**
273         * The actual object that is the target of the reference (The organization the device or practitioner was acting on behalf of.)
274         */
275        protected Organization onBehalfOfTarget;
276
277        private static final long serialVersionUID = 213950062L;
278
279    /**
280     * Constructor
281     */
282      public ProcedurePerformerComponent() {
283        super();
284      }
285
286    /**
287     * Constructor
288     */
289      public ProcedurePerformerComponent(Reference actor) {
290        super();
291        this.actor = actor;
292      }
293
294        /**
295         * @return {@link #role} (For example: surgeon, anaethetist, endoscopist.)
296         */
297        public CodeableConcept getRole() { 
298          if (this.role == null)
299            if (Configuration.errorOnAutoCreate())
300              throw new Error("Attempt to auto-create ProcedurePerformerComponent.role");
301            else if (Configuration.doAutoCreate())
302              this.role = new CodeableConcept(); // cc
303          return this.role;
304        }
305
306        public boolean hasRole() { 
307          return this.role != null && !this.role.isEmpty();
308        }
309
310        /**
311         * @param value {@link #role} (For example: surgeon, anaethetist, endoscopist.)
312         */
313        public ProcedurePerformerComponent setRole(CodeableConcept value)  { 
314          this.role = value;
315          return this;
316        }
317
318        /**
319         * @return {@link #actor} (The practitioner who was involved in the procedure.)
320         */
321        public Reference getActor() { 
322          if (this.actor == null)
323            if (Configuration.errorOnAutoCreate())
324              throw new Error("Attempt to auto-create ProcedurePerformerComponent.actor");
325            else if (Configuration.doAutoCreate())
326              this.actor = new Reference(); // cc
327          return this.actor;
328        }
329
330        public boolean hasActor() { 
331          return this.actor != null && !this.actor.isEmpty();
332        }
333
334        /**
335         * @param value {@link #actor} (The practitioner who was involved in the procedure.)
336         */
337        public ProcedurePerformerComponent setActor(Reference value)  { 
338          this.actor = value;
339          return this;
340        }
341
342        /**
343         * @return {@link #actor} 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 practitioner who was involved in the procedure.)
344         */
345        public Resource getActorTarget() { 
346          return this.actorTarget;
347        }
348
349        /**
350         * @param value {@link #actor} 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 practitioner who was involved in the procedure.)
351         */
352        public ProcedurePerformerComponent setActorTarget(Resource value) { 
353          this.actorTarget = value;
354          return this;
355        }
356
357        /**
358         * @return {@link #onBehalfOf} (The organization the device or practitioner was acting on behalf of.)
359         */
360        public Reference getOnBehalfOf() { 
361          if (this.onBehalfOf == null)
362            if (Configuration.errorOnAutoCreate())
363              throw new Error("Attempt to auto-create ProcedurePerformerComponent.onBehalfOf");
364            else if (Configuration.doAutoCreate())
365              this.onBehalfOf = new Reference(); // cc
366          return this.onBehalfOf;
367        }
368
369        public boolean hasOnBehalfOf() { 
370          return this.onBehalfOf != null && !this.onBehalfOf.isEmpty();
371        }
372
373        /**
374         * @param value {@link #onBehalfOf} (The organization the device or practitioner was acting on behalf of.)
375         */
376        public ProcedurePerformerComponent setOnBehalfOf(Reference value)  { 
377          this.onBehalfOf = value;
378          return this;
379        }
380
381        /**
382         * @return {@link #onBehalfOf} 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 organization the device or practitioner was acting on behalf of.)
383         */
384        public Organization getOnBehalfOfTarget() { 
385          if (this.onBehalfOfTarget == null)
386            if (Configuration.errorOnAutoCreate())
387              throw new Error("Attempt to auto-create ProcedurePerformerComponent.onBehalfOf");
388            else if (Configuration.doAutoCreate())
389              this.onBehalfOfTarget = new Organization(); // aa
390          return this.onBehalfOfTarget;
391        }
392
393        /**
394         * @param value {@link #onBehalfOf} 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 organization the device or practitioner was acting on behalf of.)
395         */
396        public ProcedurePerformerComponent setOnBehalfOfTarget(Organization value) { 
397          this.onBehalfOfTarget = value;
398          return this;
399        }
400
401        protected void listChildren(List<Property> children) {
402          super.listChildren(children);
403          children.add(new Property("role", "CodeableConcept", "For example: surgeon, anaethetist, endoscopist.", 0, 1, role));
404          children.add(new Property("actor", "Reference(Practitioner|Organization|Patient|RelatedPerson|Device)", "The practitioner who was involved in the procedure.", 0, 1, actor));
405          children.add(new Property("onBehalfOf", "Reference(Organization)", "The organization the device or practitioner was acting on behalf of.", 0, 1, onBehalfOf));
406        }
407
408        @Override
409        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
410          switch (_hash) {
411          case 3506294: /*role*/  return new Property("role", "CodeableConcept", "For example: surgeon, anaethetist, endoscopist.", 0, 1, role);
412          case 92645877: /*actor*/  return new Property("actor", "Reference(Practitioner|Organization|Patient|RelatedPerson|Device)", "The practitioner who was involved in the procedure.", 0, 1, actor);
413          case -14402964: /*onBehalfOf*/  return new Property("onBehalfOf", "Reference(Organization)", "The organization the device or practitioner was acting on behalf of.", 0, 1, onBehalfOf);
414          default: return super.getNamedProperty(_hash, _name, _checkValid);
415          }
416
417        }
418
419      @Override
420      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
421        switch (hash) {
422        case 3506294: /*role*/ return this.role == null ? new Base[0] : new Base[] {this.role}; // CodeableConcept
423        case 92645877: /*actor*/ return this.actor == null ? new Base[0] : new Base[] {this.actor}; // Reference
424        case -14402964: /*onBehalfOf*/ return this.onBehalfOf == null ? new Base[0] : new Base[] {this.onBehalfOf}; // Reference
425        default: return super.getProperty(hash, name, checkValid);
426        }
427
428      }
429
430      @Override
431      public Base setProperty(int hash, String name, Base value) throws FHIRException {
432        switch (hash) {
433        case 3506294: // role
434          this.role = castToCodeableConcept(value); // CodeableConcept
435          return value;
436        case 92645877: // actor
437          this.actor = castToReference(value); // Reference
438          return value;
439        case -14402964: // onBehalfOf
440          this.onBehalfOf = castToReference(value); // Reference
441          return value;
442        default: return super.setProperty(hash, name, value);
443        }
444
445      }
446
447      @Override
448      public Base setProperty(String name, Base value) throws FHIRException {
449        if (name.equals("role")) {
450          this.role = castToCodeableConcept(value); // CodeableConcept
451        } else if (name.equals("actor")) {
452          this.actor = castToReference(value); // Reference
453        } else if (name.equals("onBehalfOf")) {
454          this.onBehalfOf = castToReference(value); // Reference
455        } else
456          return super.setProperty(name, value);
457        return value;
458      }
459
460      @Override
461      public Base makeProperty(int hash, String name) throws FHIRException {
462        switch (hash) {
463        case 3506294:  return getRole(); 
464        case 92645877:  return getActor(); 
465        case -14402964:  return getOnBehalfOf(); 
466        default: return super.makeProperty(hash, name);
467        }
468
469      }
470
471      @Override
472      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
473        switch (hash) {
474        case 3506294: /*role*/ return new String[] {"CodeableConcept"};
475        case 92645877: /*actor*/ return new String[] {"Reference"};
476        case -14402964: /*onBehalfOf*/ return new String[] {"Reference"};
477        default: return super.getTypesForProperty(hash, name);
478        }
479
480      }
481
482      @Override
483      public Base addChild(String name) throws FHIRException {
484        if (name.equals("role")) {
485          this.role = new CodeableConcept();
486          return this.role;
487        }
488        else if (name.equals("actor")) {
489          this.actor = new Reference();
490          return this.actor;
491        }
492        else if (name.equals("onBehalfOf")) {
493          this.onBehalfOf = new Reference();
494          return this.onBehalfOf;
495        }
496        else
497          return super.addChild(name);
498      }
499
500      public ProcedurePerformerComponent copy() {
501        ProcedurePerformerComponent dst = new ProcedurePerformerComponent();
502        copyValues(dst);
503        dst.role = role == null ? null : role.copy();
504        dst.actor = actor == null ? null : actor.copy();
505        dst.onBehalfOf = onBehalfOf == null ? null : onBehalfOf.copy();
506        return dst;
507      }
508
509      @Override
510      public boolean equalsDeep(Base other_) {
511        if (!super.equalsDeep(other_))
512          return false;
513        if (!(other_ instanceof ProcedurePerformerComponent))
514          return false;
515        ProcedurePerformerComponent o = (ProcedurePerformerComponent) other_;
516        return compareDeep(role, o.role, true) && compareDeep(actor, o.actor, true) && compareDeep(onBehalfOf, o.onBehalfOf, true)
517          ;
518      }
519
520      @Override
521      public boolean equalsShallow(Base other_) {
522        if (!super.equalsShallow(other_))
523          return false;
524        if (!(other_ instanceof ProcedurePerformerComponent))
525          return false;
526        ProcedurePerformerComponent o = (ProcedurePerformerComponent) other_;
527        return true;
528      }
529
530      public boolean isEmpty() {
531        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(role, actor, onBehalfOf
532          );
533      }
534
535  public String fhirType() {
536    return "Procedure.performer";
537
538  }
539
540  }
541
542    @Block()
543    public static class ProcedureFocalDeviceComponent extends BackboneElement implements IBaseBackboneElement {
544        /**
545         * The kind of change that happened to the device during the procedure.
546         */
547        @Child(name = "action", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=false)
548        @Description(shortDefinition="Kind of change to device", formalDefinition="The kind of change that happened to the device during the procedure." )
549        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/device-action")
550        protected CodeableConcept action;
551
552        /**
553         * The device that was manipulated (changed) during the procedure.
554         */
555        @Child(name = "manipulated", type = {Device.class}, order=2, min=1, max=1, modifier=false, summary=false)
556        @Description(shortDefinition="Device that was changed", formalDefinition="The device that was manipulated (changed) during the procedure." )
557        protected Reference manipulated;
558
559        /**
560         * The actual object that is the target of the reference (The device that was manipulated (changed) during the procedure.)
561         */
562        protected Device manipulatedTarget;
563
564        private static final long serialVersionUID = 1779937807L;
565
566    /**
567     * Constructor
568     */
569      public ProcedureFocalDeviceComponent() {
570        super();
571      }
572
573    /**
574     * Constructor
575     */
576      public ProcedureFocalDeviceComponent(Reference manipulated) {
577        super();
578        this.manipulated = manipulated;
579      }
580
581        /**
582         * @return {@link #action} (The kind of change that happened to the device during the procedure.)
583         */
584        public CodeableConcept getAction() { 
585          if (this.action == null)
586            if (Configuration.errorOnAutoCreate())
587              throw new Error("Attempt to auto-create ProcedureFocalDeviceComponent.action");
588            else if (Configuration.doAutoCreate())
589              this.action = new CodeableConcept(); // cc
590          return this.action;
591        }
592
593        public boolean hasAction() { 
594          return this.action != null && !this.action.isEmpty();
595        }
596
597        /**
598         * @param value {@link #action} (The kind of change that happened to the device during the procedure.)
599         */
600        public ProcedureFocalDeviceComponent setAction(CodeableConcept value)  { 
601          this.action = value;
602          return this;
603        }
604
605        /**
606         * @return {@link #manipulated} (The device that was manipulated (changed) during the procedure.)
607         */
608        public Reference getManipulated() { 
609          if (this.manipulated == null)
610            if (Configuration.errorOnAutoCreate())
611              throw new Error("Attempt to auto-create ProcedureFocalDeviceComponent.manipulated");
612            else if (Configuration.doAutoCreate())
613              this.manipulated = new Reference(); // cc
614          return this.manipulated;
615        }
616
617        public boolean hasManipulated() { 
618          return this.manipulated != null && !this.manipulated.isEmpty();
619        }
620
621        /**
622         * @param value {@link #manipulated} (The device that was manipulated (changed) during the procedure.)
623         */
624        public ProcedureFocalDeviceComponent setManipulated(Reference value)  { 
625          this.manipulated = value;
626          return this;
627        }
628
629        /**
630         * @return {@link #manipulated} 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 device that was manipulated (changed) during the procedure.)
631         */
632        public Device getManipulatedTarget() { 
633          if (this.manipulatedTarget == null)
634            if (Configuration.errorOnAutoCreate())
635              throw new Error("Attempt to auto-create ProcedureFocalDeviceComponent.manipulated");
636            else if (Configuration.doAutoCreate())
637              this.manipulatedTarget = new Device(); // aa
638          return this.manipulatedTarget;
639        }
640
641        /**
642         * @param value {@link #manipulated} 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 device that was manipulated (changed) during the procedure.)
643         */
644        public ProcedureFocalDeviceComponent setManipulatedTarget(Device value) { 
645          this.manipulatedTarget = value;
646          return this;
647        }
648
649        protected void listChildren(List<Property> children) {
650          super.listChildren(children);
651          children.add(new Property("action", "CodeableConcept", "The kind of change that happened to the device during the procedure.", 0, 1, action));
652          children.add(new Property("manipulated", "Reference(Device)", "The device that was manipulated (changed) during the procedure.", 0, 1, manipulated));
653        }
654
655        @Override
656        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
657          switch (_hash) {
658          case -1422950858: /*action*/  return new Property("action", "CodeableConcept", "The kind of change that happened to the device during the procedure.", 0, 1, action);
659          case 947372650: /*manipulated*/  return new Property("manipulated", "Reference(Device)", "The device that was manipulated (changed) during the procedure.", 0, 1, manipulated);
660          default: return super.getNamedProperty(_hash, _name, _checkValid);
661          }
662
663        }
664
665      @Override
666      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
667        switch (hash) {
668        case -1422950858: /*action*/ return this.action == null ? new Base[0] : new Base[] {this.action}; // CodeableConcept
669        case 947372650: /*manipulated*/ return this.manipulated == null ? new Base[0] : new Base[] {this.manipulated}; // Reference
670        default: return super.getProperty(hash, name, checkValid);
671        }
672
673      }
674
675      @Override
676      public Base setProperty(int hash, String name, Base value) throws FHIRException {
677        switch (hash) {
678        case -1422950858: // action
679          this.action = castToCodeableConcept(value); // CodeableConcept
680          return value;
681        case 947372650: // manipulated
682          this.manipulated = castToReference(value); // Reference
683          return value;
684        default: return super.setProperty(hash, name, value);
685        }
686
687      }
688
689      @Override
690      public Base setProperty(String name, Base value) throws FHIRException {
691        if (name.equals("action")) {
692          this.action = castToCodeableConcept(value); // CodeableConcept
693        } else if (name.equals("manipulated")) {
694          this.manipulated = castToReference(value); // Reference
695        } else
696          return super.setProperty(name, value);
697        return value;
698      }
699
700      @Override
701      public Base makeProperty(int hash, String name) throws FHIRException {
702        switch (hash) {
703        case -1422950858:  return getAction(); 
704        case 947372650:  return getManipulated(); 
705        default: return super.makeProperty(hash, name);
706        }
707
708      }
709
710      @Override
711      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
712        switch (hash) {
713        case -1422950858: /*action*/ return new String[] {"CodeableConcept"};
714        case 947372650: /*manipulated*/ return new String[] {"Reference"};
715        default: return super.getTypesForProperty(hash, name);
716        }
717
718      }
719
720      @Override
721      public Base addChild(String name) throws FHIRException {
722        if (name.equals("action")) {
723          this.action = new CodeableConcept();
724          return this.action;
725        }
726        else if (name.equals("manipulated")) {
727          this.manipulated = new Reference();
728          return this.manipulated;
729        }
730        else
731          return super.addChild(name);
732      }
733
734      public ProcedureFocalDeviceComponent copy() {
735        ProcedureFocalDeviceComponent dst = new ProcedureFocalDeviceComponent();
736        copyValues(dst);
737        dst.action = action == null ? null : action.copy();
738        dst.manipulated = manipulated == null ? null : manipulated.copy();
739        return dst;
740      }
741
742      @Override
743      public boolean equalsDeep(Base other_) {
744        if (!super.equalsDeep(other_))
745          return false;
746        if (!(other_ instanceof ProcedureFocalDeviceComponent))
747          return false;
748        ProcedureFocalDeviceComponent o = (ProcedureFocalDeviceComponent) other_;
749        return compareDeep(action, o.action, true) && compareDeep(manipulated, o.manipulated, true);
750      }
751
752      @Override
753      public boolean equalsShallow(Base other_) {
754        if (!super.equalsShallow(other_))
755          return false;
756        if (!(other_ instanceof ProcedureFocalDeviceComponent))
757          return false;
758        ProcedureFocalDeviceComponent o = (ProcedureFocalDeviceComponent) other_;
759        return true;
760      }
761
762      public boolean isEmpty() {
763        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(action, manipulated);
764      }
765
766  public String fhirType() {
767    return "Procedure.focalDevice";
768
769  }
770
771  }
772
773    /**
774     * This records identifiers associated with this procedure that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).
775     */
776    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
777    @Description(shortDefinition="External Identifiers for this procedure", formalDefinition="This records identifiers associated with this procedure that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation)." )
778    protected List<Identifier> identifier;
779
780    /**
781     * A protocol, guideline, orderset or other definition that was adhered to in whole or in part by this procedure.
782     */
783    @Child(name = "definition", type = {PlanDefinition.class, ActivityDefinition.class, HealthcareService.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
784    @Description(shortDefinition="Instantiates protocol or definition", formalDefinition="A protocol, guideline, orderset or other definition that was adhered to in whole or in part by this procedure." )
785    protected List<Reference> definition;
786    /**
787     * The actual objects that are the target of the reference (A protocol, guideline, orderset or other definition that was adhered to in whole or in part by this procedure.)
788     */
789    protected List<Resource> definitionTarget;
790
791
792    /**
793     * A reference to a resource that contains details of the request for this procedure.
794     */
795    @Child(name = "basedOn", type = {CarePlan.class, ProcedureRequest.class, ReferralRequest.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
796    @Description(shortDefinition="A request for this procedure", formalDefinition="A reference to a resource that contains details of the request for this procedure." )
797    protected List<Reference> basedOn;
798    /**
799     * The actual objects that are the target of the reference (A reference to a resource that contains details of the request for this procedure.)
800     */
801    protected List<Resource> basedOnTarget;
802
803
804    /**
805     * A larger event of which this particular procedure is a component or step.
806     */
807    @Child(name = "partOf", type = {Procedure.class, Observation.class, MedicationAdministration.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
808    @Description(shortDefinition="Part of referenced event", formalDefinition="A larger event of which this particular procedure is a component or step." )
809    protected List<Reference> partOf;
810    /**
811     * The actual objects that are the target of the reference (A larger event of which this particular procedure is a component or step.)
812     */
813    protected List<Resource> partOfTarget;
814
815
816    /**
817     * A code specifying the state of the procedure. Generally this will be in-progress or completed state.
818     */
819    @Child(name = "status", type = {CodeType.class}, order=4, min=1, max=1, modifier=true, summary=true)
820    @Description(shortDefinition="preparation | in-progress | suspended | aborted | completed | entered-in-error | unknown", formalDefinition="A code specifying the state of the procedure. Generally this will be in-progress or completed state." )
821    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/event-status")
822    protected Enumeration<ProcedureStatus> status;
823
824    /**
825     * Set this to true if the record is saying that the procedure was NOT performed.
826     */
827    @Child(name = "notDone", type = {BooleanType.class}, order=5, min=0, max=1, modifier=true, summary=true)
828    @Description(shortDefinition="True if procedure was not performed as scheduled", formalDefinition="Set this to true if the record is saying that the procedure was NOT performed." )
829    protected BooleanType notDone;
830
831    /**
832     * A code indicating why the procedure was not performed.
833     */
834    @Child(name = "notDoneReason", type = {CodeableConcept.class}, order=6, min=0, max=1, modifier=false, summary=true)
835    @Description(shortDefinition="Reason procedure was not performed", formalDefinition="A code indicating why the procedure was not performed." )
836    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/procedure-not-performed-reason")
837    protected CodeableConcept notDoneReason;
838
839    /**
840     * A code that classifies the procedure for searching, sorting and display purposes (e.g. "Surgical Procedure").
841     */
842    @Child(name = "category", type = {CodeableConcept.class}, order=7, min=0, max=1, modifier=false, summary=true)
843    @Description(shortDefinition="Classification of the procedure", formalDefinition="A code that classifies the procedure for searching, sorting and display purposes (e.g. \"Surgical Procedure\")." )
844    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/procedure-category")
845    protected CodeableConcept category;
846
847    /**
848     * The specific procedure that is performed. Use text if the exact nature of the procedure cannot be coded (e.g. "Laparoscopic Appendectomy").
849     */
850    @Child(name = "code", type = {CodeableConcept.class}, order=8, min=0, max=1, modifier=false, summary=true)
851    @Description(shortDefinition="Identification of the procedure", formalDefinition="The specific procedure that is performed. Use text if the exact nature of the procedure cannot be coded (e.g. \"Laparoscopic Appendectomy\")." )
852    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/procedure-code")
853    protected CodeableConcept code;
854
855    /**
856     * The person, animal or group on which the procedure was performed.
857     */
858    @Child(name = "subject", type = {Patient.class, Group.class}, order=9, min=1, max=1, modifier=false, summary=true)
859    @Description(shortDefinition="Who the procedure was performed on", formalDefinition="The person, animal or group on which the procedure was performed." )
860    protected Reference subject;
861
862    /**
863     * The actual object that is the target of the reference (The person, animal or group on which the procedure was performed.)
864     */
865    protected Resource subjectTarget;
866
867    /**
868     * The encounter during which the procedure was performed.
869     */
870    @Child(name = "context", type = {Encounter.class, EpisodeOfCare.class}, order=10, min=0, max=1, modifier=false, summary=true)
871    @Description(shortDefinition="Encounter or episode associated with the procedure", formalDefinition="The encounter during which the procedure was performed." )
872    protected Reference context;
873
874    /**
875     * The actual object that is the target of the reference (The encounter during which the procedure was performed.)
876     */
877    protected Resource contextTarget;
878
879    /**
880     * The date(time)/period over which the procedure was performed. Allows a period to support complex procedures that span more than one date, and also allows for the length of the procedure to be captured.
881     */
882    @Child(name = "performed", type = {DateTimeType.class, Period.class}, order=11, min=0, max=1, modifier=false, summary=true)
883    @Description(shortDefinition="Date/Period the procedure was performed", formalDefinition="The date(time)/period over which the procedure was performed. Allows a period to support complex procedures that span more than one date, and also allows for the length of the procedure to be captured." )
884    protected Type performed;
885
886    /**
887     * Limited to 'real' people rather than equipment.
888     */
889    @Child(name = "performer", type = {}, order=12, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
890    @Description(shortDefinition="The people who performed the procedure", formalDefinition="Limited to 'real' people rather than equipment." )
891    protected List<ProcedurePerformerComponent> performer;
892
893    /**
894     * The location where the procedure actually happened.  E.g. a newborn at home, a tracheostomy at a restaurant.
895     */
896    @Child(name = "location", type = {Location.class}, order=13, min=0, max=1, modifier=false, summary=true)
897    @Description(shortDefinition="Where the procedure happened", formalDefinition="The location where the procedure actually happened.  E.g. a newborn at home, a tracheostomy at a restaurant." )
898    protected Reference location;
899
900    /**
901     * The actual object that is the target of the reference (The location where the procedure actually happened.  E.g. a newborn at home, a tracheostomy at a restaurant.)
902     */
903    protected Location locationTarget;
904
905    /**
906     * The coded reason why the procedure was performed. This may be coded entity of some type, or may simply be present as text.
907     */
908    @Child(name = "reasonCode", type = {CodeableConcept.class}, order=14, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
909    @Description(shortDefinition="Coded reason procedure performed", formalDefinition="The coded reason why the procedure was performed. This may be coded entity of some type, or may simply be present as text." )
910    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/procedure-reason")
911    protected List<CodeableConcept> reasonCode;
912
913    /**
914     * The condition that is the reason why the procedure was performed.
915     */
916    @Child(name = "reasonReference", type = {Condition.class, Observation.class}, order=15, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
917    @Description(shortDefinition="Condition that is the reason the procedure performed", formalDefinition="The condition that is the reason why the procedure was performed." )
918    protected List<Reference> reasonReference;
919    /**
920     * The actual objects that are the target of the reference (The condition that is the reason why the procedure was performed.)
921     */
922    protected List<Resource> reasonReferenceTarget;
923
924
925    /**
926     * Detailed and structured anatomical location information. Multiple locations are allowed - e.g. multiple punch biopsies of a lesion.
927     */
928    @Child(name = "bodySite", type = {CodeableConcept.class}, order=16, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
929    @Description(shortDefinition="Target body sites", formalDefinition="Detailed and structured anatomical location information. Multiple locations are allowed - e.g. multiple punch biopsies of a lesion." )
930    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/body-site")
931    protected List<CodeableConcept> bodySite;
932
933    /**
934     * The outcome of the procedure - did it resolve reasons for the procedure being performed?
935     */
936    @Child(name = "outcome", type = {CodeableConcept.class}, order=17, min=0, max=1, modifier=false, summary=true)
937    @Description(shortDefinition="The result of procedure", formalDefinition="The outcome of the procedure - did it resolve reasons for the procedure being performed?" )
938    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/procedure-outcome")
939    protected CodeableConcept outcome;
940
941    /**
942     * This could be a histology result, pathology report, surgical report, etc..
943     */
944    @Child(name = "report", type = {DiagnosticReport.class}, order=18, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
945    @Description(shortDefinition="Any report resulting from the procedure", formalDefinition="This could be a histology result, pathology report, surgical report, etc.." )
946    protected List<Reference> report;
947    /**
948     * The actual objects that are the target of the reference (This could be a histology result, pathology report, surgical report, etc..)
949     */
950    protected List<DiagnosticReport> reportTarget;
951
952
953    /**
954     * Any complications that occurred during the procedure, or in the immediate post-performance period. These are generally tracked separately from the notes, which will typically describe the procedure itself rather than any 'post procedure' issues.
955     */
956    @Child(name = "complication", type = {CodeableConcept.class}, order=19, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
957    @Description(shortDefinition="Complication following the procedure", formalDefinition="Any complications that occurred during the procedure, or in the immediate post-performance period. These are generally tracked separately from the notes, which will typically describe the procedure itself rather than any 'post procedure' issues." )
958    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/condition-code")
959    protected List<CodeableConcept> complication;
960
961    /**
962     * Any complications that occurred during the procedure, or in the immediate post-performance period.
963     */
964    @Child(name = "complicationDetail", type = {Condition.class}, order=20, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
965    @Description(shortDefinition="A condition that is a result of the procedure", formalDefinition="Any complications that occurred during the procedure, or in the immediate post-performance period." )
966    protected List<Reference> complicationDetail;
967    /**
968     * The actual objects that are the target of the reference (Any complications that occurred during the procedure, or in the immediate post-performance period.)
969     */
970    protected List<Condition> complicationDetailTarget;
971
972
973    /**
974     * If the procedure required specific follow up - e.g. removal of sutures. The followup may be represented as a simple note, or could potentially be more complex in which case the CarePlan resource can be used.
975     */
976    @Child(name = "followUp", type = {CodeableConcept.class}, order=21, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
977    @Description(shortDefinition="Instructions for follow up", formalDefinition="If the procedure required specific follow up - e.g. removal of sutures. The followup may be represented as a simple note, or could potentially be more complex in which case the CarePlan resource can be used." )
978    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/procedure-followup")
979    protected List<CodeableConcept> followUp;
980
981    /**
982     * Any other notes about the procedure.  E.g. the operative notes.
983     */
984    @Child(name = "note", type = {Annotation.class}, order=22, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
985    @Description(shortDefinition="Additional information about the procedure", formalDefinition="Any other notes about the procedure.  E.g. the operative notes." )
986    protected List<Annotation> note;
987
988    /**
989     * A device that is implanted, removed or otherwise manipulated (calibration, battery replacement, fitting a prosthesis, attaching a wound-vac, etc.) as a focal portion of the Procedure.
990     */
991    @Child(name = "focalDevice", type = {}, order=23, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
992    @Description(shortDefinition="Device changed in procedure", formalDefinition="A device that is implanted, removed or otherwise manipulated (calibration, battery replacement, fitting a prosthesis, attaching a wound-vac, etc.) as a focal portion of the Procedure." )
993    protected List<ProcedureFocalDeviceComponent> focalDevice;
994
995    /**
996     * Identifies medications, devices and any other substance used as part of the procedure.
997     */
998    @Child(name = "usedReference", type = {Device.class, Medication.class, Substance.class}, order=24, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
999    @Description(shortDefinition="Items used during procedure", formalDefinition="Identifies medications, devices and any other substance used as part of the procedure." )
1000    protected List<Reference> usedReference;
1001    /**
1002     * The actual objects that are the target of the reference (Identifies medications, devices and any other substance used as part of the procedure.)
1003     */
1004    protected List<Resource> usedReferenceTarget;
1005
1006
1007    /**
1008     * Identifies coded items that were used as part of the procedure.
1009     */
1010    @Child(name = "usedCode", type = {CodeableConcept.class}, order=25, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1011    @Description(shortDefinition="Coded items used during the procedure", formalDefinition="Identifies coded items that were used as part of the procedure." )
1012    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/device-kind")
1013    protected List<CodeableConcept> usedCode;
1014
1015    private static final long serialVersionUID = 7729906L;
1016
1017  /**
1018   * Constructor
1019   */
1020    public Procedure() {
1021      super();
1022    }
1023
1024  /**
1025   * Constructor
1026   */
1027    public Procedure(Enumeration<ProcedureStatus> status, Reference subject) {
1028      super();
1029      this.status = status;
1030      this.subject = subject;
1031    }
1032
1033    /**
1034     * @return {@link #identifier} (This records identifiers associated with this procedure that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).)
1035     */
1036    public List<Identifier> getIdentifier() { 
1037      if (this.identifier == null)
1038        this.identifier = new ArrayList<Identifier>();
1039      return this.identifier;
1040    }
1041
1042    /**
1043     * @return Returns a reference to <code>this</code> for easy method chaining
1044     */
1045    public Procedure setIdentifier(List<Identifier> theIdentifier) { 
1046      this.identifier = theIdentifier;
1047      return this;
1048    }
1049
1050    public boolean hasIdentifier() { 
1051      if (this.identifier == null)
1052        return false;
1053      for (Identifier item : this.identifier)
1054        if (!item.isEmpty())
1055          return true;
1056      return false;
1057    }
1058
1059    public Identifier addIdentifier() { //3
1060      Identifier t = new Identifier();
1061      if (this.identifier == null)
1062        this.identifier = new ArrayList<Identifier>();
1063      this.identifier.add(t);
1064      return t;
1065    }
1066
1067    public Procedure addIdentifier(Identifier t) { //3
1068      if (t == null)
1069        return this;
1070      if (this.identifier == null)
1071        this.identifier = new ArrayList<Identifier>();
1072      this.identifier.add(t);
1073      return this;
1074    }
1075
1076    /**
1077     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
1078     */
1079    public Identifier getIdentifierFirstRep() { 
1080      if (getIdentifier().isEmpty()) {
1081        addIdentifier();
1082      }
1083      return getIdentifier().get(0);
1084    }
1085
1086    /**
1087     * @return {@link #definition} (A protocol, guideline, orderset or other definition that was adhered to in whole or in part by this procedure.)
1088     */
1089    public List<Reference> getDefinition() { 
1090      if (this.definition == null)
1091        this.definition = new ArrayList<Reference>();
1092      return this.definition;
1093    }
1094
1095    /**
1096     * @return Returns a reference to <code>this</code> for easy method chaining
1097     */
1098    public Procedure setDefinition(List<Reference> theDefinition) { 
1099      this.definition = theDefinition;
1100      return this;
1101    }
1102
1103    public boolean hasDefinition() { 
1104      if (this.definition == null)
1105        return false;
1106      for (Reference item : this.definition)
1107        if (!item.isEmpty())
1108          return true;
1109      return false;
1110    }
1111
1112    public Reference addDefinition() { //3
1113      Reference t = new Reference();
1114      if (this.definition == null)
1115        this.definition = new ArrayList<Reference>();
1116      this.definition.add(t);
1117      return t;
1118    }
1119
1120    public Procedure addDefinition(Reference t) { //3
1121      if (t == null)
1122        return this;
1123      if (this.definition == null)
1124        this.definition = new ArrayList<Reference>();
1125      this.definition.add(t);
1126      return this;
1127    }
1128
1129    /**
1130     * @return The first repetition of repeating field {@link #definition}, creating it if it does not already exist
1131     */
1132    public Reference getDefinitionFirstRep() { 
1133      if (getDefinition().isEmpty()) {
1134        addDefinition();
1135      }
1136      return getDefinition().get(0);
1137    }
1138
1139    /**
1140     * @deprecated Use Reference#setResource(IBaseResource) instead
1141     */
1142    @Deprecated
1143    public List<Resource> getDefinitionTarget() { 
1144      if (this.definitionTarget == null)
1145        this.definitionTarget = new ArrayList<Resource>();
1146      return this.definitionTarget;
1147    }
1148
1149    /**
1150     * @return {@link #basedOn} (A reference to a resource that contains details of the request for this procedure.)
1151     */
1152    public List<Reference> getBasedOn() { 
1153      if (this.basedOn == null)
1154        this.basedOn = new ArrayList<Reference>();
1155      return this.basedOn;
1156    }
1157
1158    /**
1159     * @return Returns a reference to <code>this</code> for easy method chaining
1160     */
1161    public Procedure setBasedOn(List<Reference> theBasedOn) { 
1162      this.basedOn = theBasedOn;
1163      return this;
1164    }
1165
1166    public boolean hasBasedOn() { 
1167      if (this.basedOn == null)
1168        return false;
1169      for (Reference item : this.basedOn)
1170        if (!item.isEmpty())
1171          return true;
1172      return false;
1173    }
1174
1175    public Reference addBasedOn() { //3
1176      Reference t = new Reference();
1177      if (this.basedOn == null)
1178        this.basedOn = new ArrayList<Reference>();
1179      this.basedOn.add(t);
1180      return t;
1181    }
1182
1183    public Procedure addBasedOn(Reference t) { //3
1184      if (t == null)
1185        return this;
1186      if (this.basedOn == null)
1187        this.basedOn = new ArrayList<Reference>();
1188      this.basedOn.add(t);
1189      return this;
1190    }
1191
1192    /**
1193     * @return The first repetition of repeating field {@link #basedOn}, creating it if it does not already exist
1194     */
1195    public Reference getBasedOnFirstRep() { 
1196      if (getBasedOn().isEmpty()) {
1197        addBasedOn();
1198      }
1199      return getBasedOn().get(0);
1200    }
1201
1202    /**
1203     * @deprecated Use Reference#setResource(IBaseResource) instead
1204     */
1205    @Deprecated
1206    public List<Resource> getBasedOnTarget() { 
1207      if (this.basedOnTarget == null)
1208        this.basedOnTarget = new ArrayList<Resource>();
1209      return this.basedOnTarget;
1210    }
1211
1212    /**
1213     * @return {@link #partOf} (A larger event of which this particular procedure is a component or step.)
1214     */
1215    public List<Reference> getPartOf() { 
1216      if (this.partOf == null)
1217        this.partOf = new ArrayList<Reference>();
1218      return this.partOf;
1219    }
1220
1221    /**
1222     * @return Returns a reference to <code>this</code> for easy method chaining
1223     */
1224    public Procedure setPartOf(List<Reference> thePartOf) { 
1225      this.partOf = thePartOf;
1226      return this;
1227    }
1228
1229    public boolean hasPartOf() { 
1230      if (this.partOf == null)
1231        return false;
1232      for (Reference item : this.partOf)
1233        if (!item.isEmpty())
1234          return true;
1235      return false;
1236    }
1237
1238    public Reference addPartOf() { //3
1239      Reference t = new Reference();
1240      if (this.partOf == null)
1241        this.partOf = new ArrayList<Reference>();
1242      this.partOf.add(t);
1243      return t;
1244    }
1245
1246    public Procedure addPartOf(Reference t) { //3
1247      if (t == null)
1248        return this;
1249      if (this.partOf == null)
1250        this.partOf = new ArrayList<Reference>();
1251      this.partOf.add(t);
1252      return this;
1253    }
1254
1255    /**
1256     * @return The first repetition of repeating field {@link #partOf}, creating it if it does not already exist
1257     */
1258    public Reference getPartOfFirstRep() { 
1259      if (getPartOf().isEmpty()) {
1260        addPartOf();
1261      }
1262      return getPartOf().get(0);
1263    }
1264
1265    /**
1266     * @deprecated Use Reference#setResource(IBaseResource) instead
1267     */
1268    @Deprecated
1269    public List<Resource> getPartOfTarget() { 
1270      if (this.partOfTarget == null)
1271        this.partOfTarget = new ArrayList<Resource>();
1272      return this.partOfTarget;
1273    }
1274
1275    /**
1276     * @return {@link #status} (A code specifying the state of the procedure. Generally this will be in-progress or completed state.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1277     */
1278    public Enumeration<ProcedureStatus> getStatusElement() { 
1279      if (this.status == null)
1280        if (Configuration.errorOnAutoCreate())
1281          throw new Error("Attempt to auto-create Procedure.status");
1282        else if (Configuration.doAutoCreate())
1283          this.status = new Enumeration<ProcedureStatus>(new ProcedureStatusEnumFactory()); // bb
1284      return this.status;
1285    }
1286
1287    public boolean hasStatusElement() { 
1288      return this.status != null && !this.status.isEmpty();
1289    }
1290
1291    public boolean hasStatus() { 
1292      return this.status != null && !this.status.isEmpty();
1293    }
1294
1295    /**
1296     * @param value {@link #status} (A code specifying the state of the procedure. Generally this will be in-progress or completed state.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1297     */
1298    public Procedure setStatusElement(Enumeration<ProcedureStatus> value) { 
1299      this.status = value;
1300      return this;
1301    }
1302
1303    /**
1304     * @return A code specifying the state of the procedure. Generally this will be in-progress or completed state.
1305     */
1306    public ProcedureStatus getStatus() { 
1307      return this.status == null ? null : this.status.getValue();
1308    }
1309
1310    /**
1311     * @param value A code specifying the state of the procedure. Generally this will be in-progress or completed state.
1312     */
1313    public Procedure setStatus(ProcedureStatus value) { 
1314        if (this.status == null)
1315          this.status = new Enumeration<ProcedureStatus>(new ProcedureStatusEnumFactory());
1316        this.status.setValue(value);
1317      return this;
1318    }
1319
1320    /**
1321     * @return {@link #notDone} (Set this to true if the record is saying that the procedure was NOT performed.). This is the underlying object with id, value and extensions. The accessor "getNotDone" gives direct access to the value
1322     */
1323    public BooleanType getNotDoneElement() { 
1324      if (this.notDone == null)
1325        if (Configuration.errorOnAutoCreate())
1326          throw new Error("Attempt to auto-create Procedure.notDone");
1327        else if (Configuration.doAutoCreate())
1328          this.notDone = new BooleanType(); // bb
1329      return this.notDone;
1330    }
1331
1332    public boolean hasNotDoneElement() { 
1333      return this.notDone != null && !this.notDone.isEmpty();
1334    }
1335
1336    public boolean hasNotDone() { 
1337      return this.notDone != null && !this.notDone.isEmpty();
1338    }
1339
1340    /**
1341     * @param value {@link #notDone} (Set this to true if the record is saying that the procedure was NOT performed.). This is the underlying object with id, value and extensions. The accessor "getNotDone" gives direct access to the value
1342     */
1343    public Procedure setNotDoneElement(BooleanType value) { 
1344      this.notDone = value;
1345      return this;
1346    }
1347
1348    /**
1349     * @return Set this to true if the record is saying that the procedure was NOT performed.
1350     */
1351    public boolean getNotDone() { 
1352      return this.notDone == null || this.notDone.isEmpty() ? false : this.notDone.getValue();
1353    }
1354
1355    /**
1356     * @param value Set this to true if the record is saying that the procedure was NOT performed.
1357     */
1358    public Procedure setNotDone(boolean value) { 
1359        if (this.notDone == null)
1360          this.notDone = new BooleanType();
1361        this.notDone.setValue(value);
1362      return this;
1363    }
1364
1365    /**
1366     * @return {@link #notDoneReason} (A code indicating why the procedure was not performed.)
1367     */
1368    public CodeableConcept getNotDoneReason() { 
1369      if (this.notDoneReason == null)
1370        if (Configuration.errorOnAutoCreate())
1371          throw new Error("Attempt to auto-create Procedure.notDoneReason");
1372        else if (Configuration.doAutoCreate())
1373          this.notDoneReason = new CodeableConcept(); // cc
1374      return this.notDoneReason;
1375    }
1376
1377    public boolean hasNotDoneReason() { 
1378      return this.notDoneReason != null && !this.notDoneReason.isEmpty();
1379    }
1380
1381    /**
1382     * @param value {@link #notDoneReason} (A code indicating why the procedure was not performed.)
1383     */
1384    public Procedure setNotDoneReason(CodeableConcept value)  { 
1385      this.notDoneReason = value;
1386      return this;
1387    }
1388
1389    /**
1390     * @return {@link #category} (A code that classifies the procedure for searching, sorting and display purposes (e.g. "Surgical Procedure").)
1391     */
1392    public CodeableConcept getCategory() { 
1393      if (this.category == null)
1394        if (Configuration.errorOnAutoCreate())
1395          throw new Error("Attempt to auto-create Procedure.category");
1396        else if (Configuration.doAutoCreate())
1397          this.category = new CodeableConcept(); // cc
1398      return this.category;
1399    }
1400
1401    public boolean hasCategory() { 
1402      return this.category != null && !this.category.isEmpty();
1403    }
1404
1405    /**
1406     * @param value {@link #category} (A code that classifies the procedure for searching, sorting and display purposes (e.g. "Surgical Procedure").)
1407     */
1408    public Procedure setCategory(CodeableConcept value)  { 
1409      this.category = value;
1410      return this;
1411    }
1412
1413    /**
1414     * @return {@link #code} (The specific procedure that is performed. Use text if the exact nature of the procedure cannot be coded (e.g. "Laparoscopic Appendectomy").)
1415     */
1416    public CodeableConcept getCode() { 
1417      if (this.code == null)
1418        if (Configuration.errorOnAutoCreate())
1419          throw new Error("Attempt to auto-create Procedure.code");
1420        else if (Configuration.doAutoCreate())
1421          this.code = new CodeableConcept(); // cc
1422      return this.code;
1423    }
1424
1425    public boolean hasCode() { 
1426      return this.code != null && !this.code.isEmpty();
1427    }
1428
1429    /**
1430     * @param value {@link #code} (The specific procedure that is performed. Use text if the exact nature of the procedure cannot be coded (e.g. "Laparoscopic Appendectomy").)
1431     */
1432    public Procedure setCode(CodeableConcept value)  { 
1433      this.code = value;
1434      return this;
1435    }
1436
1437    /**
1438     * @return {@link #subject} (The person, animal or group on which the procedure was performed.)
1439     */
1440    public Reference getSubject() { 
1441      if (this.subject == null)
1442        if (Configuration.errorOnAutoCreate())
1443          throw new Error("Attempt to auto-create Procedure.subject");
1444        else if (Configuration.doAutoCreate())
1445          this.subject = new Reference(); // cc
1446      return this.subject;
1447    }
1448
1449    public boolean hasSubject() { 
1450      return this.subject != null && !this.subject.isEmpty();
1451    }
1452
1453    /**
1454     * @param value {@link #subject} (The person, animal or group on which the procedure was performed.)
1455     */
1456    public Procedure setSubject(Reference value)  { 
1457      this.subject = value;
1458      return this;
1459    }
1460
1461    /**
1462     * @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 on which the procedure was performed.)
1463     */
1464    public Resource getSubjectTarget() { 
1465      return this.subjectTarget;
1466    }
1467
1468    /**
1469     * @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 on which the procedure was performed.)
1470     */
1471    public Procedure setSubjectTarget(Resource value) { 
1472      this.subjectTarget = value;
1473      return this;
1474    }
1475
1476    /**
1477     * @return {@link #context} (The encounter during which the procedure was performed.)
1478     */
1479    public Reference getContext() { 
1480      if (this.context == null)
1481        if (Configuration.errorOnAutoCreate())
1482          throw new Error("Attempt to auto-create Procedure.context");
1483        else if (Configuration.doAutoCreate())
1484          this.context = new Reference(); // cc
1485      return this.context;
1486    }
1487
1488    public boolean hasContext() { 
1489      return this.context != null && !this.context.isEmpty();
1490    }
1491
1492    /**
1493     * @param value {@link #context} (The encounter during which the procedure was performed.)
1494     */
1495    public Procedure setContext(Reference value)  { 
1496      this.context = value;
1497      return this;
1498    }
1499
1500    /**
1501     * @return {@link #context} 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 during which the procedure was performed.)
1502     */
1503    public Resource getContextTarget() { 
1504      return this.contextTarget;
1505    }
1506
1507    /**
1508     * @param value {@link #context} 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 during which the procedure was performed.)
1509     */
1510    public Procedure setContextTarget(Resource value) { 
1511      this.contextTarget = value;
1512      return this;
1513    }
1514
1515    /**
1516     * @return {@link #performed} (The date(time)/period over which the procedure was performed. Allows a period to support complex procedures that span more than one date, and also allows for the length of the procedure to be captured.)
1517     */
1518    public Type getPerformed() { 
1519      return this.performed;
1520    }
1521
1522    /**
1523     * @return {@link #performed} (The date(time)/period over which the procedure was performed. Allows a period to support complex procedures that span more than one date, and also allows for the length of the procedure to be captured.)
1524     */
1525    public DateTimeType getPerformedDateTimeType() throws FHIRException { 
1526      if (this.performed == null)
1527        return null;
1528      if (!(this.performed instanceof DateTimeType))
1529        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.performed.getClass().getName()+" was encountered");
1530      return (DateTimeType) this.performed;
1531    }
1532
1533    public boolean hasPerformedDateTimeType() { 
1534      return this != null && this.performed instanceof DateTimeType;
1535    }
1536
1537    /**
1538     * @return {@link #performed} (The date(time)/period over which the procedure was performed. Allows a period to support complex procedures that span more than one date, and also allows for the length of the procedure to be captured.)
1539     */
1540    public Period getPerformedPeriod() throws FHIRException { 
1541      if (this.performed == null)
1542        return null;
1543      if (!(this.performed instanceof Period))
1544        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.performed.getClass().getName()+" was encountered");
1545      return (Period) this.performed;
1546    }
1547
1548    public boolean hasPerformedPeriod() { 
1549      return this != null && this.performed instanceof Period;
1550    }
1551
1552    public boolean hasPerformed() { 
1553      return this.performed != null && !this.performed.isEmpty();
1554    }
1555
1556    /**
1557     * @param value {@link #performed} (The date(time)/period over which the procedure was performed. Allows a period to support complex procedures that span more than one date, and also allows for the length of the procedure to be captured.)
1558     */
1559    public Procedure setPerformed(Type value) throws FHIRFormatError { 
1560      if (value != null && !(value instanceof DateTimeType || value instanceof Period))
1561        throw new FHIRFormatError("Not the right type for Procedure.performed[x]: "+value.fhirType());
1562      this.performed = value;
1563      return this;
1564    }
1565
1566    /**
1567     * @return {@link #performer} (Limited to 'real' people rather than equipment.)
1568     */
1569    public List<ProcedurePerformerComponent> getPerformer() { 
1570      if (this.performer == null)
1571        this.performer = new ArrayList<ProcedurePerformerComponent>();
1572      return this.performer;
1573    }
1574
1575    /**
1576     * @return Returns a reference to <code>this</code> for easy method chaining
1577     */
1578    public Procedure setPerformer(List<ProcedurePerformerComponent> thePerformer) { 
1579      this.performer = thePerformer;
1580      return this;
1581    }
1582
1583    public boolean hasPerformer() { 
1584      if (this.performer == null)
1585        return false;
1586      for (ProcedurePerformerComponent item : this.performer)
1587        if (!item.isEmpty())
1588          return true;
1589      return false;
1590    }
1591
1592    public ProcedurePerformerComponent addPerformer() { //3
1593      ProcedurePerformerComponent t = new ProcedurePerformerComponent();
1594      if (this.performer == null)
1595        this.performer = new ArrayList<ProcedurePerformerComponent>();
1596      this.performer.add(t);
1597      return t;
1598    }
1599
1600    public Procedure addPerformer(ProcedurePerformerComponent t) { //3
1601      if (t == null)
1602        return this;
1603      if (this.performer == null)
1604        this.performer = new ArrayList<ProcedurePerformerComponent>();
1605      this.performer.add(t);
1606      return this;
1607    }
1608
1609    /**
1610     * @return The first repetition of repeating field {@link #performer}, creating it if it does not already exist
1611     */
1612    public ProcedurePerformerComponent getPerformerFirstRep() { 
1613      if (getPerformer().isEmpty()) {
1614        addPerformer();
1615      }
1616      return getPerformer().get(0);
1617    }
1618
1619    /**
1620     * @return {@link #location} (The location where the procedure actually happened.  E.g. a newborn at home, a tracheostomy at a restaurant.)
1621     */
1622    public Reference getLocation() { 
1623      if (this.location == null)
1624        if (Configuration.errorOnAutoCreate())
1625          throw new Error("Attempt to auto-create Procedure.location");
1626        else if (Configuration.doAutoCreate())
1627          this.location = new Reference(); // cc
1628      return this.location;
1629    }
1630
1631    public boolean hasLocation() { 
1632      return this.location != null && !this.location.isEmpty();
1633    }
1634
1635    /**
1636     * @param value {@link #location} (The location where the procedure actually happened.  E.g. a newborn at home, a tracheostomy at a restaurant.)
1637     */
1638    public Procedure setLocation(Reference value)  { 
1639      this.location = value;
1640      return this;
1641    }
1642
1643    /**
1644     * @return {@link #location} 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 location where the procedure actually happened.  E.g. a newborn at home, a tracheostomy at a restaurant.)
1645     */
1646    public Location getLocationTarget() { 
1647      if (this.locationTarget == null)
1648        if (Configuration.errorOnAutoCreate())
1649          throw new Error("Attempt to auto-create Procedure.location");
1650        else if (Configuration.doAutoCreate())
1651          this.locationTarget = new Location(); // aa
1652      return this.locationTarget;
1653    }
1654
1655    /**
1656     * @param value {@link #location} 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 location where the procedure actually happened.  E.g. a newborn at home, a tracheostomy at a restaurant.)
1657     */
1658    public Procedure setLocationTarget(Location value) { 
1659      this.locationTarget = value;
1660      return this;
1661    }
1662
1663    /**
1664     * @return {@link #reasonCode} (The coded reason why the procedure was performed. This may be coded entity of some type, or may simply be present as text.)
1665     */
1666    public List<CodeableConcept> getReasonCode() { 
1667      if (this.reasonCode == null)
1668        this.reasonCode = new ArrayList<CodeableConcept>();
1669      return this.reasonCode;
1670    }
1671
1672    /**
1673     * @return Returns a reference to <code>this</code> for easy method chaining
1674     */
1675    public Procedure setReasonCode(List<CodeableConcept> theReasonCode) { 
1676      this.reasonCode = theReasonCode;
1677      return this;
1678    }
1679
1680    public boolean hasReasonCode() { 
1681      if (this.reasonCode == null)
1682        return false;
1683      for (CodeableConcept item : this.reasonCode)
1684        if (!item.isEmpty())
1685          return true;
1686      return false;
1687    }
1688
1689    public CodeableConcept addReasonCode() { //3
1690      CodeableConcept t = new CodeableConcept();
1691      if (this.reasonCode == null)
1692        this.reasonCode = new ArrayList<CodeableConcept>();
1693      this.reasonCode.add(t);
1694      return t;
1695    }
1696
1697    public Procedure addReasonCode(CodeableConcept t) { //3
1698      if (t == null)
1699        return this;
1700      if (this.reasonCode == null)
1701        this.reasonCode = new ArrayList<CodeableConcept>();
1702      this.reasonCode.add(t);
1703      return this;
1704    }
1705
1706    /**
1707     * @return The first repetition of repeating field {@link #reasonCode}, creating it if it does not already exist
1708     */
1709    public CodeableConcept getReasonCodeFirstRep() { 
1710      if (getReasonCode().isEmpty()) {
1711        addReasonCode();
1712      }
1713      return getReasonCode().get(0);
1714    }
1715
1716    /**
1717     * @return {@link #reasonReference} (The condition that is the reason why the procedure was performed.)
1718     */
1719    public List<Reference> getReasonReference() { 
1720      if (this.reasonReference == null)
1721        this.reasonReference = new ArrayList<Reference>();
1722      return this.reasonReference;
1723    }
1724
1725    /**
1726     * @return Returns a reference to <code>this</code> for easy method chaining
1727     */
1728    public Procedure setReasonReference(List<Reference> theReasonReference) { 
1729      this.reasonReference = theReasonReference;
1730      return this;
1731    }
1732
1733    public boolean hasReasonReference() { 
1734      if (this.reasonReference == null)
1735        return false;
1736      for (Reference item : this.reasonReference)
1737        if (!item.isEmpty())
1738          return true;
1739      return false;
1740    }
1741
1742    public Reference addReasonReference() { //3
1743      Reference t = new Reference();
1744      if (this.reasonReference == null)
1745        this.reasonReference = new ArrayList<Reference>();
1746      this.reasonReference.add(t);
1747      return t;
1748    }
1749
1750    public Procedure addReasonReference(Reference t) { //3
1751      if (t == null)
1752        return this;
1753      if (this.reasonReference == null)
1754        this.reasonReference = new ArrayList<Reference>();
1755      this.reasonReference.add(t);
1756      return this;
1757    }
1758
1759    /**
1760     * @return The first repetition of repeating field {@link #reasonReference}, creating it if it does not already exist
1761     */
1762    public Reference getReasonReferenceFirstRep() { 
1763      if (getReasonReference().isEmpty()) {
1764        addReasonReference();
1765      }
1766      return getReasonReference().get(0);
1767    }
1768
1769    /**
1770     * @deprecated Use Reference#setResource(IBaseResource) instead
1771     */
1772    @Deprecated
1773    public List<Resource> getReasonReferenceTarget() { 
1774      if (this.reasonReferenceTarget == null)
1775        this.reasonReferenceTarget = new ArrayList<Resource>();
1776      return this.reasonReferenceTarget;
1777    }
1778
1779    /**
1780     * @return {@link #bodySite} (Detailed and structured anatomical location information. Multiple locations are allowed - e.g. multiple punch biopsies of a lesion.)
1781     */
1782    public List<CodeableConcept> getBodySite() { 
1783      if (this.bodySite == null)
1784        this.bodySite = new ArrayList<CodeableConcept>();
1785      return this.bodySite;
1786    }
1787
1788    /**
1789     * @return Returns a reference to <code>this</code> for easy method chaining
1790     */
1791    public Procedure setBodySite(List<CodeableConcept> theBodySite) { 
1792      this.bodySite = theBodySite;
1793      return this;
1794    }
1795
1796    public boolean hasBodySite() { 
1797      if (this.bodySite == null)
1798        return false;
1799      for (CodeableConcept item : this.bodySite)
1800        if (!item.isEmpty())
1801          return true;
1802      return false;
1803    }
1804
1805    public CodeableConcept addBodySite() { //3
1806      CodeableConcept t = new CodeableConcept();
1807      if (this.bodySite == null)
1808        this.bodySite = new ArrayList<CodeableConcept>();
1809      this.bodySite.add(t);
1810      return t;
1811    }
1812
1813    public Procedure addBodySite(CodeableConcept t) { //3
1814      if (t == null)
1815        return this;
1816      if (this.bodySite == null)
1817        this.bodySite = new ArrayList<CodeableConcept>();
1818      this.bodySite.add(t);
1819      return this;
1820    }
1821
1822    /**
1823     * @return The first repetition of repeating field {@link #bodySite}, creating it if it does not already exist
1824     */
1825    public CodeableConcept getBodySiteFirstRep() { 
1826      if (getBodySite().isEmpty()) {
1827        addBodySite();
1828      }
1829      return getBodySite().get(0);
1830    }
1831
1832    /**
1833     * @return {@link #outcome} (The outcome of the procedure - did it resolve reasons for the procedure being performed?)
1834     */
1835    public CodeableConcept getOutcome() { 
1836      if (this.outcome == null)
1837        if (Configuration.errorOnAutoCreate())
1838          throw new Error("Attempt to auto-create Procedure.outcome");
1839        else if (Configuration.doAutoCreate())
1840          this.outcome = new CodeableConcept(); // cc
1841      return this.outcome;
1842    }
1843
1844    public boolean hasOutcome() { 
1845      return this.outcome != null && !this.outcome.isEmpty();
1846    }
1847
1848    /**
1849     * @param value {@link #outcome} (The outcome of the procedure - did it resolve reasons for the procedure being performed?)
1850     */
1851    public Procedure setOutcome(CodeableConcept value)  { 
1852      this.outcome = value;
1853      return this;
1854    }
1855
1856    /**
1857     * @return {@link #report} (This could be a histology result, pathology report, surgical report, etc..)
1858     */
1859    public List<Reference> getReport() { 
1860      if (this.report == null)
1861        this.report = new ArrayList<Reference>();
1862      return this.report;
1863    }
1864
1865    /**
1866     * @return Returns a reference to <code>this</code> for easy method chaining
1867     */
1868    public Procedure setReport(List<Reference> theReport) { 
1869      this.report = theReport;
1870      return this;
1871    }
1872
1873    public boolean hasReport() { 
1874      if (this.report == null)
1875        return false;
1876      for (Reference item : this.report)
1877        if (!item.isEmpty())
1878          return true;
1879      return false;
1880    }
1881
1882    public Reference addReport() { //3
1883      Reference t = new Reference();
1884      if (this.report == null)
1885        this.report = new ArrayList<Reference>();
1886      this.report.add(t);
1887      return t;
1888    }
1889
1890    public Procedure addReport(Reference t) { //3
1891      if (t == null)
1892        return this;
1893      if (this.report == null)
1894        this.report = new ArrayList<Reference>();
1895      this.report.add(t);
1896      return this;
1897    }
1898
1899    /**
1900     * @return The first repetition of repeating field {@link #report}, creating it if it does not already exist
1901     */
1902    public Reference getReportFirstRep() { 
1903      if (getReport().isEmpty()) {
1904        addReport();
1905      }
1906      return getReport().get(0);
1907    }
1908
1909    /**
1910     * @deprecated Use Reference#setResource(IBaseResource) instead
1911     */
1912    @Deprecated
1913    public List<DiagnosticReport> getReportTarget() { 
1914      if (this.reportTarget == null)
1915        this.reportTarget = new ArrayList<DiagnosticReport>();
1916      return this.reportTarget;
1917    }
1918
1919    /**
1920     * @deprecated Use Reference#setResource(IBaseResource) instead
1921     */
1922    @Deprecated
1923    public DiagnosticReport addReportTarget() { 
1924      DiagnosticReport r = new DiagnosticReport();
1925      if (this.reportTarget == null)
1926        this.reportTarget = new ArrayList<DiagnosticReport>();
1927      this.reportTarget.add(r);
1928      return r;
1929    }
1930
1931    /**
1932     * @return {@link #complication} (Any complications that occurred during the procedure, or in the immediate post-performance period. These are generally tracked separately from the notes, which will typically describe the procedure itself rather than any 'post procedure' issues.)
1933     */
1934    public List<CodeableConcept> getComplication() { 
1935      if (this.complication == null)
1936        this.complication = new ArrayList<CodeableConcept>();
1937      return this.complication;
1938    }
1939
1940    /**
1941     * @return Returns a reference to <code>this</code> for easy method chaining
1942     */
1943    public Procedure setComplication(List<CodeableConcept> theComplication) { 
1944      this.complication = theComplication;
1945      return this;
1946    }
1947
1948    public boolean hasComplication() { 
1949      if (this.complication == null)
1950        return false;
1951      for (CodeableConcept item : this.complication)
1952        if (!item.isEmpty())
1953          return true;
1954      return false;
1955    }
1956
1957    public CodeableConcept addComplication() { //3
1958      CodeableConcept t = new CodeableConcept();
1959      if (this.complication == null)
1960        this.complication = new ArrayList<CodeableConcept>();
1961      this.complication.add(t);
1962      return t;
1963    }
1964
1965    public Procedure addComplication(CodeableConcept t) { //3
1966      if (t == null)
1967        return this;
1968      if (this.complication == null)
1969        this.complication = new ArrayList<CodeableConcept>();
1970      this.complication.add(t);
1971      return this;
1972    }
1973
1974    /**
1975     * @return The first repetition of repeating field {@link #complication}, creating it if it does not already exist
1976     */
1977    public CodeableConcept getComplicationFirstRep() { 
1978      if (getComplication().isEmpty()) {
1979        addComplication();
1980      }
1981      return getComplication().get(0);
1982    }
1983
1984    /**
1985     * @return {@link #complicationDetail} (Any complications that occurred during the procedure, or in the immediate post-performance period.)
1986     */
1987    public List<Reference> getComplicationDetail() { 
1988      if (this.complicationDetail == null)
1989        this.complicationDetail = new ArrayList<Reference>();
1990      return this.complicationDetail;
1991    }
1992
1993    /**
1994     * @return Returns a reference to <code>this</code> for easy method chaining
1995     */
1996    public Procedure setComplicationDetail(List<Reference> theComplicationDetail) { 
1997      this.complicationDetail = theComplicationDetail;
1998      return this;
1999    }
2000
2001    public boolean hasComplicationDetail() { 
2002      if (this.complicationDetail == null)
2003        return false;
2004      for (Reference item : this.complicationDetail)
2005        if (!item.isEmpty())
2006          return true;
2007      return false;
2008    }
2009
2010    public Reference addComplicationDetail() { //3
2011      Reference t = new Reference();
2012      if (this.complicationDetail == null)
2013        this.complicationDetail = new ArrayList<Reference>();
2014      this.complicationDetail.add(t);
2015      return t;
2016    }
2017
2018    public Procedure addComplicationDetail(Reference t) { //3
2019      if (t == null)
2020        return this;
2021      if (this.complicationDetail == null)
2022        this.complicationDetail = new ArrayList<Reference>();
2023      this.complicationDetail.add(t);
2024      return this;
2025    }
2026
2027    /**
2028     * @return The first repetition of repeating field {@link #complicationDetail}, creating it if it does not already exist
2029     */
2030    public Reference getComplicationDetailFirstRep() { 
2031      if (getComplicationDetail().isEmpty()) {
2032        addComplicationDetail();
2033      }
2034      return getComplicationDetail().get(0);
2035    }
2036
2037    /**
2038     * @deprecated Use Reference#setResource(IBaseResource) instead
2039     */
2040    @Deprecated
2041    public List<Condition> getComplicationDetailTarget() { 
2042      if (this.complicationDetailTarget == null)
2043        this.complicationDetailTarget = new ArrayList<Condition>();
2044      return this.complicationDetailTarget;
2045    }
2046
2047    /**
2048     * @deprecated Use Reference#setResource(IBaseResource) instead
2049     */
2050    @Deprecated
2051    public Condition addComplicationDetailTarget() { 
2052      Condition r = new Condition();
2053      if (this.complicationDetailTarget == null)
2054        this.complicationDetailTarget = new ArrayList<Condition>();
2055      this.complicationDetailTarget.add(r);
2056      return r;
2057    }
2058
2059    /**
2060     * @return {@link #followUp} (If the procedure required specific follow up - e.g. removal of sutures. The followup may be represented as a simple note, or could potentially be more complex in which case the CarePlan resource can be used.)
2061     */
2062    public List<CodeableConcept> getFollowUp() { 
2063      if (this.followUp == null)
2064        this.followUp = new ArrayList<CodeableConcept>();
2065      return this.followUp;
2066    }
2067
2068    /**
2069     * @return Returns a reference to <code>this</code> for easy method chaining
2070     */
2071    public Procedure setFollowUp(List<CodeableConcept> theFollowUp) { 
2072      this.followUp = theFollowUp;
2073      return this;
2074    }
2075
2076    public boolean hasFollowUp() { 
2077      if (this.followUp == null)
2078        return false;
2079      for (CodeableConcept item : this.followUp)
2080        if (!item.isEmpty())
2081          return true;
2082      return false;
2083    }
2084
2085    public CodeableConcept addFollowUp() { //3
2086      CodeableConcept t = new CodeableConcept();
2087      if (this.followUp == null)
2088        this.followUp = new ArrayList<CodeableConcept>();
2089      this.followUp.add(t);
2090      return t;
2091    }
2092
2093    public Procedure addFollowUp(CodeableConcept t) { //3
2094      if (t == null)
2095        return this;
2096      if (this.followUp == null)
2097        this.followUp = new ArrayList<CodeableConcept>();
2098      this.followUp.add(t);
2099      return this;
2100    }
2101
2102    /**
2103     * @return The first repetition of repeating field {@link #followUp}, creating it if it does not already exist
2104     */
2105    public CodeableConcept getFollowUpFirstRep() { 
2106      if (getFollowUp().isEmpty()) {
2107        addFollowUp();
2108      }
2109      return getFollowUp().get(0);
2110    }
2111
2112    /**
2113     * @return {@link #note} (Any other notes about the procedure.  E.g. the operative notes.)
2114     */
2115    public List<Annotation> getNote() { 
2116      if (this.note == null)
2117        this.note = new ArrayList<Annotation>();
2118      return this.note;
2119    }
2120
2121    /**
2122     * @return Returns a reference to <code>this</code> for easy method chaining
2123     */
2124    public Procedure setNote(List<Annotation> theNote) { 
2125      this.note = theNote;
2126      return this;
2127    }
2128
2129    public boolean hasNote() { 
2130      if (this.note == null)
2131        return false;
2132      for (Annotation item : this.note)
2133        if (!item.isEmpty())
2134          return true;
2135      return false;
2136    }
2137
2138    public Annotation addNote() { //3
2139      Annotation t = new Annotation();
2140      if (this.note == null)
2141        this.note = new ArrayList<Annotation>();
2142      this.note.add(t);
2143      return t;
2144    }
2145
2146    public Procedure addNote(Annotation t) { //3
2147      if (t == null)
2148        return this;
2149      if (this.note == null)
2150        this.note = new ArrayList<Annotation>();
2151      this.note.add(t);
2152      return this;
2153    }
2154
2155    /**
2156     * @return The first repetition of repeating field {@link #note}, creating it if it does not already exist
2157     */
2158    public Annotation getNoteFirstRep() { 
2159      if (getNote().isEmpty()) {
2160        addNote();
2161      }
2162      return getNote().get(0);
2163    }
2164
2165    /**
2166     * @return {@link #focalDevice} (A device that is implanted, removed or otherwise manipulated (calibration, battery replacement, fitting a prosthesis, attaching a wound-vac, etc.) as a focal portion of the Procedure.)
2167     */
2168    public List<ProcedureFocalDeviceComponent> getFocalDevice() { 
2169      if (this.focalDevice == null)
2170        this.focalDevice = new ArrayList<ProcedureFocalDeviceComponent>();
2171      return this.focalDevice;
2172    }
2173
2174    /**
2175     * @return Returns a reference to <code>this</code> for easy method chaining
2176     */
2177    public Procedure setFocalDevice(List<ProcedureFocalDeviceComponent> theFocalDevice) { 
2178      this.focalDevice = theFocalDevice;
2179      return this;
2180    }
2181
2182    public boolean hasFocalDevice() { 
2183      if (this.focalDevice == null)
2184        return false;
2185      for (ProcedureFocalDeviceComponent item : this.focalDevice)
2186        if (!item.isEmpty())
2187          return true;
2188      return false;
2189    }
2190
2191    public ProcedureFocalDeviceComponent addFocalDevice() { //3
2192      ProcedureFocalDeviceComponent t = new ProcedureFocalDeviceComponent();
2193      if (this.focalDevice == null)
2194        this.focalDevice = new ArrayList<ProcedureFocalDeviceComponent>();
2195      this.focalDevice.add(t);
2196      return t;
2197    }
2198
2199    public Procedure addFocalDevice(ProcedureFocalDeviceComponent t) { //3
2200      if (t == null)
2201        return this;
2202      if (this.focalDevice == null)
2203        this.focalDevice = new ArrayList<ProcedureFocalDeviceComponent>();
2204      this.focalDevice.add(t);
2205      return this;
2206    }
2207
2208    /**
2209     * @return The first repetition of repeating field {@link #focalDevice}, creating it if it does not already exist
2210     */
2211    public ProcedureFocalDeviceComponent getFocalDeviceFirstRep() { 
2212      if (getFocalDevice().isEmpty()) {
2213        addFocalDevice();
2214      }
2215      return getFocalDevice().get(0);
2216    }
2217
2218    /**
2219     * @return {@link #usedReference} (Identifies medications, devices and any other substance used as part of the procedure.)
2220     */
2221    public List<Reference> getUsedReference() { 
2222      if (this.usedReference == null)
2223        this.usedReference = new ArrayList<Reference>();
2224      return this.usedReference;
2225    }
2226
2227    /**
2228     * @return Returns a reference to <code>this</code> for easy method chaining
2229     */
2230    public Procedure setUsedReference(List<Reference> theUsedReference) { 
2231      this.usedReference = theUsedReference;
2232      return this;
2233    }
2234
2235    public boolean hasUsedReference() { 
2236      if (this.usedReference == null)
2237        return false;
2238      for (Reference item : this.usedReference)
2239        if (!item.isEmpty())
2240          return true;
2241      return false;
2242    }
2243
2244    public Reference addUsedReference() { //3
2245      Reference t = new Reference();
2246      if (this.usedReference == null)
2247        this.usedReference = new ArrayList<Reference>();
2248      this.usedReference.add(t);
2249      return t;
2250    }
2251
2252    public Procedure addUsedReference(Reference t) { //3
2253      if (t == null)
2254        return this;
2255      if (this.usedReference == null)
2256        this.usedReference = new ArrayList<Reference>();
2257      this.usedReference.add(t);
2258      return this;
2259    }
2260
2261    /**
2262     * @return The first repetition of repeating field {@link #usedReference}, creating it if it does not already exist
2263     */
2264    public Reference getUsedReferenceFirstRep() { 
2265      if (getUsedReference().isEmpty()) {
2266        addUsedReference();
2267      }
2268      return getUsedReference().get(0);
2269    }
2270
2271    /**
2272     * @deprecated Use Reference#setResource(IBaseResource) instead
2273     */
2274    @Deprecated
2275    public List<Resource> getUsedReferenceTarget() { 
2276      if (this.usedReferenceTarget == null)
2277        this.usedReferenceTarget = new ArrayList<Resource>();
2278      return this.usedReferenceTarget;
2279    }
2280
2281    /**
2282     * @return {@link #usedCode} (Identifies coded items that were used as part of the procedure.)
2283     */
2284    public List<CodeableConcept> getUsedCode() { 
2285      if (this.usedCode == null)
2286        this.usedCode = new ArrayList<CodeableConcept>();
2287      return this.usedCode;
2288    }
2289
2290    /**
2291     * @return Returns a reference to <code>this</code> for easy method chaining
2292     */
2293    public Procedure setUsedCode(List<CodeableConcept> theUsedCode) { 
2294      this.usedCode = theUsedCode;
2295      return this;
2296    }
2297
2298    public boolean hasUsedCode() { 
2299      if (this.usedCode == null)
2300        return false;
2301      for (CodeableConcept item : this.usedCode)
2302        if (!item.isEmpty())
2303          return true;
2304      return false;
2305    }
2306
2307    public CodeableConcept addUsedCode() { //3
2308      CodeableConcept t = new CodeableConcept();
2309      if (this.usedCode == null)
2310        this.usedCode = new ArrayList<CodeableConcept>();
2311      this.usedCode.add(t);
2312      return t;
2313    }
2314
2315    public Procedure addUsedCode(CodeableConcept t) { //3
2316      if (t == null)
2317        return this;
2318      if (this.usedCode == null)
2319        this.usedCode = new ArrayList<CodeableConcept>();
2320      this.usedCode.add(t);
2321      return this;
2322    }
2323
2324    /**
2325     * @return The first repetition of repeating field {@link #usedCode}, creating it if it does not already exist
2326     */
2327    public CodeableConcept getUsedCodeFirstRep() { 
2328      if (getUsedCode().isEmpty()) {
2329        addUsedCode();
2330      }
2331      return getUsedCode().get(0);
2332    }
2333
2334      protected void listChildren(List<Property> children) {
2335        super.listChildren(children);
2336        children.add(new Property("identifier", "Identifier", "This records identifiers associated with this procedure that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).", 0, java.lang.Integer.MAX_VALUE, identifier));
2337        children.add(new Property("definition", "Reference(PlanDefinition|ActivityDefinition|HealthcareService)", "A protocol, guideline, orderset or other definition that was adhered to in whole or in part by this procedure.", 0, java.lang.Integer.MAX_VALUE, definition));
2338        children.add(new Property("basedOn", "Reference(CarePlan|ProcedureRequest|ReferralRequest)", "A reference to a resource that contains details of the request for this procedure.", 0, java.lang.Integer.MAX_VALUE, basedOn));
2339        children.add(new Property("partOf", "Reference(Procedure|Observation|MedicationAdministration)", "A larger event of which this particular procedure is a component or step.", 0, java.lang.Integer.MAX_VALUE, partOf));
2340        children.add(new Property("status", "code", "A code specifying the state of the procedure. Generally this will be in-progress or completed state.", 0, 1, status));
2341        children.add(new Property("notDone", "boolean", "Set this to true if the record is saying that the procedure was NOT performed.", 0, 1, notDone));
2342        children.add(new Property("notDoneReason", "CodeableConcept", "A code indicating why the procedure was not performed.", 0, 1, notDoneReason));
2343        children.add(new Property("category", "CodeableConcept", "A code that classifies the procedure for searching, sorting and display purposes (e.g. \"Surgical Procedure\").", 0, 1, category));
2344        children.add(new Property("code", "CodeableConcept", "The specific procedure that is performed. Use text if the exact nature of the procedure cannot be coded (e.g. \"Laparoscopic Appendectomy\").", 0, 1, code));
2345        children.add(new Property("subject", "Reference(Patient|Group)", "The person, animal or group on which the procedure was performed.", 0, 1, subject));
2346        children.add(new Property("context", "Reference(Encounter|EpisodeOfCare)", "The encounter during which the procedure was performed.", 0, 1, context));
2347        children.add(new Property("performed[x]", "dateTime|Period", "The date(time)/period over which the procedure was performed. Allows a period to support complex procedures that span more than one date, and also allows for the length of the procedure to be captured.", 0, 1, performed));
2348        children.add(new Property("performer", "", "Limited to 'real' people rather than equipment.", 0, java.lang.Integer.MAX_VALUE, performer));
2349        children.add(new Property("location", "Reference(Location)", "The location where the procedure actually happened.  E.g. a newborn at home, a tracheostomy at a restaurant.", 0, 1, location));
2350        children.add(new Property("reasonCode", "CodeableConcept", "The coded reason why the procedure was performed. This may be coded entity of some type, or may simply be present as text.", 0, java.lang.Integer.MAX_VALUE, reasonCode));
2351        children.add(new Property("reasonReference", "Reference(Condition|Observation)", "The condition that is the reason why the procedure was performed.", 0, java.lang.Integer.MAX_VALUE, reasonReference));
2352        children.add(new Property("bodySite", "CodeableConcept", "Detailed and structured anatomical location information. Multiple locations are allowed - e.g. multiple punch biopsies of a lesion.", 0, java.lang.Integer.MAX_VALUE, bodySite));
2353        children.add(new Property("outcome", "CodeableConcept", "The outcome of the procedure - did it resolve reasons for the procedure being performed?", 0, 1, outcome));
2354        children.add(new Property("report", "Reference(DiagnosticReport)", "This could be a histology result, pathology report, surgical report, etc..", 0, java.lang.Integer.MAX_VALUE, report));
2355        children.add(new Property("complication", "CodeableConcept", "Any complications that occurred during the procedure, or in the immediate post-performance period. These are generally tracked separately from the notes, which will typically describe the procedure itself rather than any 'post procedure' issues.", 0, java.lang.Integer.MAX_VALUE, complication));
2356        children.add(new Property("complicationDetail", "Reference(Condition)", "Any complications that occurred during the procedure, or in the immediate post-performance period.", 0, java.lang.Integer.MAX_VALUE, complicationDetail));
2357        children.add(new Property("followUp", "CodeableConcept", "If the procedure required specific follow up - e.g. removal of sutures. The followup may be represented as a simple note, or could potentially be more complex in which case the CarePlan resource can be used.", 0, java.lang.Integer.MAX_VALUE, followUp));
2358        children.add(new Property("note", "Annotation", "Any other notes about the procedure.  E.g. the operative notes.", 0, java.lang.Integer.MAX_VALUE, note));
2359        children.add(new Property("focalDevice", "", "A device that is implanted, removed or otherwise manipulated (calibration, battery replacement, fitting a prosthesis, attaching a wound-vac, etc.) as a focal portion of the Procedure.", 0, java.lang.Integer.MAX_VALUE, focalDevice));
2360        children.add(new Property("usedReference", "Reference(Device|Medication|Substance)", "Identifies medications, devices and any other substance used as part of the procedure.", 0, java.lang.Integer.MAX_VALUE, usedReference));
2361        children.add(new Property("usedCode", "CodeableConcept", "Identifies coded items that were used as part of the procedure.", 0, java.lang.Integer.MAX_VALUE, usedCode));
2362      }
2363
2364      @Override
2365      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2366        switch (_hash) {
2367        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "This records identifiers associated with this procedure that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).", 0, java.lang.Integer.MAX_VALUE, identifier);
2368        case -1014418093: /*definition*/  return new Property("definition", "Reference(PlanDefinition|ActivityDefinition|HealthcareService)", "A protocol, guideline, orderset or other definition that was adhered to in whole or in part by this procedure.", 0, java.lang.Integer.MAX_VALUE, definition);
2369        case -332612366: /*basedOn*/  return new Property("basedOn", "Reference(CarePlan|ProcedureRequest|ReferralRequest)", "A reference to a resource that contains details of the request for this procedure.", 0, java.lang.Integer.MAX_VALUE, basedOn);
2370        case -995410646: /*partOf*/  return new Property("partOf", "Reference(Procedure|Observation|MedicationAdministration)", "A larger event of which this particular procedure is a component or step.", 0, java.lang.Integer.MAX_VALUE, partOf);
2371        case -892481550: /*status*/  return new Property("status", "code", "A code specifying the state of the procedure. Generally this will be in-progress or completed state.", 0, 1, status);
2372        case 2128257269: /*notDone*/  return new Property("notDone", "boolean", "Set this to true if the record is saying that the procedure was NOT performed.", 0, 1, notDone);
2373        case -1973169255: /*notDoneReason*/  return new Property("notDoneReason", "CodeableConcept", "A code indicating why the procedure was not performed.", 0, 1, notDoneReason);
2374        case 50511102: /*category*/  return new Property("category", "CodeableConcept", "A code that classifies the procedure for searching, sorting and display purposes (e.g. \"Surgical Procedure\").", 0, 1, category);
2375        case 3059181: /*code*/  return new Property("code", "CodeableConcept", "The specific procedure that is performed. Use text if the exact nature of the procedure cannot be coded (e.g. \"Laparoscopic Appendectomy\").", 0, 1, code);
2376        case -1867885268: /*subject*/  return new Property("subject", "Reference(Patient|Group)", "The person, animal or group on which the procedure was performed.", 0, 1, subject);
2377        case 951530927: /*context*/  return new Property("context", "Reference(Encounter|EpisodeOfCare)", "The encounter during which the procedure was performed.", 0, 1, context);
2378        case 1355984064: /*performed[x]*/  return new Property("performed[x]", "dateTime|Period", "The date(time)/period over which the procedure was performed. Allows a period to support complex procedures that span more than one date, and also allows for the length of the procedure to be captured.", 0, 1, performed);
2379        case 481140672: /*performed*/  return new Property("performed[x]", "dateTime|Period", "The date(time)/period over which the procedure was performed. Allows a period to support complex procedures that span more than one date, and also allows for the length of the procedure to be captured.", 0, 1, performed);
2380        case 1118270331: /*performedDateTime*/  return new Property("performed[x]", "dateTime|Period", "The date(time)/period over which the procedure was performed. Allows a period to support complex procedures that span more than one date, and also allows for the length of the procedure to be captured.", 0, 1, performed);
2381        case 1622094241: /*performedPeriod*/  return new Property("performed[x]", "dateTime|Period", "The date(time)/period over which the procedure was performed. Allows a period to support complex procedures that span more than one date, and also allows for the length of the procedure to be captured.", 0, 1, performed);
2382        case 481140686: /*performer*/  return new Property("performer", "", "Limited to 'real' people rather than equipment.", 0, java.lang.Integer.MAX_VALUE, performer);
2383        case 1901043637: /*location*/  return new Property("location", "Reference(Location)", "The location where the procedure actually happened.  E.g. a newborn at home, a tracheostomy at a restaurant.", 0, 1, location);
2384        case 722137681: /*reasonCode*/  return new Property("reasonCode", "CodeableConcept", "The coded reason why the procedure was performed. This may be coded entity of some type, or may simply be present as text.", 0, java.lang.Integer.MAX_VALUE, reasonCode);
2385        case -1146218137: /*reasonReference*/  return new Property("reasonReference", "Reference(Condition|Observation)", "The condition that is the reason why the procedure was performed.", 0, java.lang.Integer.MAX_VALUE, reasonReference);
2386        case 1702620169: /*bodySite*/  return new Property("bodySite", "CodeableConcept", "Detailed and structured anatomical location information. Multiple locations are allowed - e.g. multiple punch biopsies of a lesion.", 0, java.lang.Integer.MAX_VALUE, bodySite);
2387        case -1106507950: /*outcome*/  return new Property("outcome", "CodeableConcept", "The outcome of the procedure - did it resolve reasons for the procedure being performed?", 0, 1, outcome);
2388        case -934521548: /*report*/  return new Property("report", "Reference(DiagnosticReport)", "This could be a histology result, pathology report, surgical report, etc..", 0, java.lang.Integer.MAX_VALUE, report);
2389        case -1644401602: /*complication*/  return new Property("complication", "CodeableConcept", "Any complications that occurred during the procedure, or in the immediate post-performance period. These are generally tracked separately from the notes, which will typically describe the procedure itself rather than any 'post procedure' issues.", 0, java.lang.Integer.MAX_VALUE, complication);
2390        case -1685272017: /*complicationDetail*/  return new Property("complicationDetail", "Reference(Condition)", "Any complications that occurred during the procedure, or in the immediate post-performance period.", 0, java.lang.Integer.MAX_VALUE, complicationDetail);
2391        case 301801004: /*followUp*/  return new Property("followUp", "CodeableConcept", "If the procedure required specific follow up - e.g. removal of sutures. The followup may be represented as a simple note, or could potentially be more complex in which case the CarePlan resource can be used.", 0, java.lang.Integer.MAX_VALUE, followUp);
2392        case 3387378: /*note*/  return new Property("note", "Annotation", "Any other notes about the procedure.  E.g. the operative notes.", 0, java.lang.Integer.MAX_VALUE, note);
2393        case -1129235173: /*focalDevice*/  return new Property("focalDevice", "", "A device that is implanted, removed or otherwise manipulated (calibration, battery replacement, fitting a prosthesis, attaching a wound-vac, etc.) as a focal portion of the Procedure.", 0, java.lang.Integer.MAX_VALUE, focalDevice);
2394        case -504932338: /*usedReference*/  return new Property("usedReference", "Reference(Device|Medication|Substance)", "Identifies medications, devices and any other substance used as part of the procedure.", 0, java.lang.Integer.MAX_VALUE, usedReference);
2395        case -279910582: /*usedCode*/  return new Property("usedCode", "CodeableConcept", "Identifies coded items that were used as part of the procedure.", 0, java.lang.Integer.MAX_VALUE, usedCode);
2396        default: return super.getNamedProperty(_hash, _name, _checkValid);
2397        }
2398
2399      }
2400
2401      @Override
2402      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2403        switch (hash) {
2404        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
2405        case -1014418093: /*definition*/ return this.definition == null ? new Base[0] : this.definition.toArray(new Base[this.definition.size()]); // Reference
2406        case -332612366: /*basedOn*/ return this.basedOn == null ? new Base[0] : this.basedOn.toArray(new Base[this.basedOn.size()]); // Reference
2407        case -995410646: /*partOf*/ return this.partOf == null ? new Base[0] : this.partOf.toArray(new Base[this.partOf.size()]); // Reference
2408        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<ProcedureStatus>
2409        case 2128257269: /*notDone*/ return this.notDone == null ? new Base[0] : new Base[] {this.notDone}; // BooleanType
2410        case -1973169255: /*notDoneReason*/ return this.notDoneReason == null ? new Base[0] : new Base[] {this.notDoneReason}; // CodeableConcept
2411        case 50511102: /*category*/ return this.category == null ? new Base[0] : new Base[] {this.category}; // CodeableConcept
2412        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept
2413        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
2414        case 951530927: /*context*/ return this.context == null ? new Base[0] : new Base[] {this.context}; // Reference
2415        case 481140672: /*performed*/ return this.performed == null ? new Base[0] : new Base[] {this.performed}; // Type
2416        case 481140686: /*performer*/ return this.performer == null ? new Base[0] : this.performer.toArray(new Base[this.performer.size()]); // ProcedurePerformerComponent
2417        case 1901043637: /*location*/ return this.location == null ? new Base[0] : new Base[] {this.location}; // Reference
2418        case 722137681: /*reasonCode*/ return this.reasonCode == null ? new Base[0] : this.reasonCode.toArray(new Base[this.reasonCode.size()]); // CodeableConcept
2419        case -1146218137: /*reasonReference*/ return this.reasonReference == null ? new Base[0] : this.reasonReference.toArray(new Base[this.reasonReference.size()]); // Reference
2420        case 1702620169: /*bodySite*/ return this.bodySite == null ? new Base[0] : this.bodySite.toArray(new Base[this.bodySite.size()]); // CodeableConcept
2421        case -1106507950: /*outcome*/ return this.outcome == null ? new Base[0] : new Base[] {this.outcome}; // CodeableConcept
2422        case -934521548: /*report*/ return this.report == null ? new Base[0] : this.report.toArray(new Base[this.report.size()]); // Reference
2423        case -1644401602: /*complication*/ return this.complication == null ? new Base[0] : this.complication.toArray(new Base[this.complication.size()]); // CodeableConcept
2424        case -1685272017: /*complicationDetail*/ return this.complicationDetail == null ? new Base[0] : this.complicationDetail.toArray(new Base[this.complicationDetail.size()]); // Reference
2425        case 301801004: /*followUp*/ return this.followUp == null ? new Base[0] : this.followUp.toArray(new Base[this.followUp.size()]); // CodeableConcept
2426        case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
2427        case -1129235173: /*focalDevice*/ return this.focalDevice == null ? new Base[0] : this.focalDevice.toArray(new Base[this.focalDevice.size()]); // ProcedureFocalDeviceComponent
2428        case -504932338: /*usedReference*/ return this.usedReference == null ? new Base[0] : this.usedReference.toArray(new Base[this.usedReference.size()]); // Reference
2429        case -279910582: /*usedCode*/ return this.usedCode == null ? new Base[0] : this.usedCode.toArray(new Base[this.usedCode.size()]); // CodeableConcept
2430        default: return super.getProperty(hash, name, checkValid);
2431        }
2432
2433      }
2434
2435      @Override
2436      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2437        switch (hash) {
2438        case -1618432855: // identifier
2439          this.getIdentifier().add(castToIdentifier(value)); // Identifier
2440          return value;
2441        case -1014418093: // definition
2442          this.getDefinition().add(castToReference(value)); // Reference
2443          return value;
2444        case -332612366: // basedOn
2445          this.getBasedOn().add(castToReference(value)); // Reference
2446          return value;
2447        case -995410646: // partOf
2448          this.getPartOf().add(castToReference(value)); // Reference
2449          return value;
2450        case -892481550: // status
2451          value = new ProcedureStatusEnumFactory().fromType(castToCode(value));
2452          this.status = (Enumeration) value; // Enumeration<ProcedureStatus>
2453          return value;
2454        case 2128257269: // notDone
2455          this.notDone = castToBoolean(value); // BooleanType
2456          return value;
2457        case -1973169255: // notDoneReason
2458          this.notDoneReason = castToCodeableConcept(value); // CodeableConcept
2459          return value;
2460        case 50511102: // category
2461          this.category = castToCodeableConcept(value); // CodeableConcept
2462          return value;
2463        case 3059181: // code
2464          this.code = castToCodeableConcept(value); // CodeableConcept
2465          return value;
2466        case -1867885268: // subject
2467          this.subject = castToReference(value); // Reference
2468          return value;
2469        case 951530927: // context
2470          this.context = castToReference(value); // Reference
2471          return value;
2472        case 481140672: // performed
2473          this.performed = castToType(value); // Type
2474          return value;
2475        case 481140686: // performer
2476          this.getPerformer().add((ProcedurePerformerComponent) value); // ProcedurePerformerComponent
2477          return value;
2478        case 1901043637: // location
2479          this.location = castToReference(value); // Reference
2480          return value;
2481        case 722137681: // reasonCode
2482          this.getReasonCode().add(castToCodeableConcept(value)); // CodeableConcept
2483          return value;
2484        case -1146218137: // reasonReference
2485          this.getReasonReference().add(castToReference(value)); // Reference
2486          return value;
2487        case 1702620169: // bodySite
2488          this.getBodySite().add(castToCodeableConcept(value)); // CodeableConcept
2489          return value;
2490        case -1106507950: // outcome
2491          this.outcome = castToCodeableConcept(value); // CodeableConcept
2492          return value;
2493        case -934521548: // report
2494          this.getReport().add(castToReference(value)); // Reference
2495          return value;
2496        case -1644401602: // complication
2497          this.getComplication().add(castToCodeableConcept(value)); // CodeableConcept
2498          return value;
2499        case -1685272017: // complicationDetail
2500          this.getComplicationDetail().add(castToReference(value)); // Reference
2501          return value;
2502        case 301801004: // followUp
2503          this.getFollowUp().add(castToCodeableConcept(value)); // CodeableConcept
2504          return value;
2505        case 3387378: // note
2506          this.getNote().add(castToAnnotation(value)); // Annotation
2507          return value;
2508        case -1129235173: // focalDevice
2509          this.getFocalDevice().add((ProcedureFocalDeviceComponent) value); // ProcedureFocalDeviceComponent
2510          return value;
2511        case -504932338: // usedReference
2512          this.getUsedReference().add(castToReference(value)); // Reference
2513          return value;
2514        case -279910582: // usedCode
2515          this.getUsedCode().add(castToCodeableConcept(value)); // CodeableConcept
2516          return value;
2517        default: return super.setProperty(hash, name, value);
2518        }
2519
2520      }
2521
2522      @Override
2523      public Base setProperty(String name, Base value) throws FHIRException {
2524        if (name.equals("identifier")) {
2525          this.getIdentifier().add(castToIdentifier(value));
2526        } else if (name.equals("definition")) {
2527          this.getDefinition().add(castToReference(value));
2528        } else if (name.equals("basedOn")) {
2529          this.getBasedOn().add(castToReference(value));
2530        } else if (name.equals("partOf")) {
2531          this.getPartOf().add(castToReference(value));
2532        } else if (name.equals("status")) {
2533          value = new ProcedureStatusEnumFactory().fromType(castToCode(value));
2534          this.status = (Enumeration) value; // Enumeration<ProcedureStatus>
2535        } else if (name.equals("notDone")) {
2536          this.notDone = castToBoolean(value); // BooleanType
2537        } else if (name.equals("notDoneReason")) {
2538          this.notDoneReason = castToCodeableConcept(value); // CodeableConcept
2539        } else if (name.equals("category")) {
2540          this.category = castToCodeableConcept(value); // CodeableConcept
2541        } else if (name.equals("code")) {
2542          this.code = castToCodeableConcept(value); // CodeableConcept
2543        } else if (name.equals("subject")) {
2544          this.subject = castToReference(value); // Reference
2545        } else if (name.equals("context")) {
2546          this.context = castToReference(value); // Reference
2547        } else if (name.equals("performed[x]")) {
2548          this.performed = castToType(value); // Type
2549        } else if (name.equals("performer")) {
2550          this.getPerformer().add((ProcedurePerformerComponent) value);
2551        } else if (name.equals("location")) {
2552          this.location = castToReference(value); // Reference
2553        } else if (name.equals("reasonCode")) {
2554          this.getReasonCode().add(castToCodeableConcept(value));
2555        } else if (name.equals("reasonReference")) {
2556          this.getReasonReference().add(castToReference(value));
2557        } else if (name.equals("bodySite")) {
2558          this.getBodySite().add(castToCodeableConcept(value));
2559        } else if (name.equals("outcome")) {
2560          this.outcome = castToCodeableConcept(value); // CodeableConcept
2561        } else if (name.equals("report")) {
2562          this.getReport().add(castToReference(value));
2563        } else if (name.equals("complication")) {
2564          this.getComplication().add(castToCodeableConcept(value));
2565        } else if (name.equals("complicationDetail")) {
2566          this.getComplicationDetail().add(castToReference(value));
2567        } else if (name.equals("followUp")) {
2568          this.getFollowUp().add(castToCodeableConcept(value));
2569        } else if (name.equals("note")) {
2570          this.getNote().add(castToAnnotation(value));
2571        } else if (name.equals("focalDevice")) {
2572          this.getFocalDevice().add((ProcedureFocalDeviceComponent) value);
2573        } else if (name.equals("usedReference")) {
2574          this.getUsedReference().add(castToReference(value));
2575        } else if (name.equals("usedCode")) {
2576          this.getUsedCode().add(castToCodeableConcept(value));
2577        } else
2578          return super.setProperty(name, value);
2579        return value;
2580      }
2581
2582      @Override
2583      public Base makeProperty(int hash, String name) throws FHIRException {
2584        switch (hash) {
2585        case -1618432855:  return addIdentifier(); 
2586        case -1014418093:  return addDefinition(); 
2587        case -332612366:  return addBasedOn(); 
2588        case -995410646:  return addPartOf(); 
2589        case -892481550:  return getStatusElement();
2590        case 2128257269:  return getNotDoneElement();
2591        case -1973169255:  return getNotDoneReason(); 
2592        case 50511102:  return getCategory(); 
2593        case 3059181:  return getCode(); 
2594        case -1867885268:  return getSubject(); 
2595        case 951530927:  return getContext(); 
2596        case 1355984064:  return getPerformed(); 
2597        case 481140672:  return getPerformed(); 
2598        case 481140686:  return addPerformer(); 
2599        case 1901043637:  return getLocation(); 
2600        case 722137681:  return addReasonCode(); 
2601        case -1146218137:  return addReasonReference(); 
2602        case 1702620169:  return addBodySite(); 
2603        case -1106507950:  return getOutcome(); 
2604        case -934521548:  return addReport(); 
2605        case -1644401602:  return addComplication(); 
2606        case -1685272017:  return addComplicationDetail(); 
2607        case 301801004:  return addFollowUp(); 
2608        case 3387378:  return addNote(); 
2609        case -1129235173:  return addFocalDevice(); 
2610        case -504932338:  return addUsedReference(); 
2611        case -279910582:  return addUsedCode(); 
2612        default: return super.makeProperty(hash, name);
2613        }
2614
2615      }
2616
2617      @Override
2618      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2619        switch (hash) {
2620        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
2621        case -1014418093: /*definition*/ return new String[] {"Reference"};
2622        case -332612366: /*basedOn*/ return new String[] {"Reference"};
2623        case -995410646: /*partOf*/ return new String[] {"Reference"};
2624        case -892481550: /*status*/ return new String[] {"code"};
2625        case 2128257269: /*notDone*/ return new String[] {"boolean"};
2626        case -1973169255: /*notDoneReason*/ return new String[] {"CodeableConcept"};
2627        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
2628        case 3059181: /*code*/ return new String[] {"CodeableConcept"};
2629        case -1867885268: /*subject*/ return new String[] {"Reference"};
2630        case 951530927: /*context*/ return new String[] {"Reference"};
2631        case 481140672: /*performed*/ return new String[] {"dateTime", "Period"};
2632        case 481140686: /*performer*/ return new String[] {};
2633        case 1901043637: /*location*/ return new String[] {"Reference"};
2634        case 722137681: /*reasonCode*/ return new String[] {"CodeableConcept"};
2635        case -1146218137: /*reasonReference*/ return new String[] {"Reference"};
2636        case 1702620169: /*bodySite*/ return new String[] {"CodeableConcept"};
2637        case -1106507950: /*outcome*/ return new String[] {"CodeableConcept"};
2638        case -934521548: /*report*/ return new String[] {"Reference"};
2639        case -1644401602: /*complication*/ return new String[] {"CodeableConcept"};
2640        case -1685272017: /*complicationDetail*/ return new String[] {"Reference"};
2641        case 301801004: /*followUp*/ return new String[] {"CodeableConcept"};
2642        case 3387378: /*note*/ return new String[] {"Annotation"};
2643        case -1129235173: /*focalDevice*/ return new String[] {};
2644        case -504932338: /*usedReference*/ return new String[] {"Reference"};
2645        case -279910582: /*usedCode*/ return new String[] {"CodeableConcept"};
2646        default: return super.getTypesForProperty(hash, name);
2647        }
2648
2649      }
2650
2651      @Override
2652      public Base addChild(String name) throws FHIRException {
2653        if (name.equals("identifier")) {
2654          return addIdentifier();
2655        }
2656        else if (name.equals("definition")) {
2657          return addDefinition();
2658        }
2659        else if (name.equals("basedOn")) {
2660          return addBasedOn();
2661        }
2662        else if (name.equals("partOf")) {
2663          return addPartOf();
2664        }
2665        else if (name.equals("status")) {
2666          throw new FHIRException("Cannot call addChild on a primitive type Procedure.status");
2667        }
2668        else if (name.equals("notDone")) {
2669          throw new FHIRException("Cannot call addChild on a primitive type Procedure.notDone");
2670        }
2671        else if (name.equals("notDoneReason")) {
2672          this.notDoneReason = new CodeableConcept();
2673          return this.notDoneReason;
2674        }
2675        else if (name.equals("category")) {
2676          this.category = new CodeableConcept();
2677          return this.category;
2678        }
2679        else if (name.equals("code")) {
2680          this.code = new CodeableConcept();
2681          return this.code;
2682        }
2683        else if (name.equals("subject")) {
2684          this.subject = new Reference();
2685          return this.subject;
2686        }
2687        else if (name.equals("context")) {
2688          this.context = new Reference();
2689          return this.context;
2690        }
2691        else if (name.equals("performedDateTime")) {
2692          this.performed = new DateTimeType();
2693          return this.performed;
2694        }
2695        else if (name.equals("performedPeriod")) {
2696          this.performed = new Period();
2697          return this.performed;
2698        }
2699        else if (name.equals("performer")) {
2700          return addPerformer();
2701        }
2702        else if (name.equals("location")) {
2703          this.location = new Reference();
2704          return this.location;
2705        }
2706        else if (name.equals("reasonCode")) {
2707          return addReasonCode();
2708        }
2709        else if (name.equals("reasonReference")) {
2710          return addReasonReference();
2711        }
2712        else if (name.equals("bodySite")) {
2713          return addBodySite();
2714        }
2715        else if (name.equals("outcome")) {
2716          this.outcome = new CodeableConcept();
2717          return this.outcome;
2718        }
2719        else if (name.equals("report")) {
2720          return addReport();
2721        }
2722        else if (name.equals("complication")) {
2723          return addComplication();
2724        }
2725        else if (name.equals("complicationDetail")) {
2726          return addComplicationDetail();
2727        }
2728        else if (name.equals("followUp")) {
2729          return addFollowUp();
2730        }
2731        else if (name.equals("note")) {
2732          return addNote();
2733        }
2734        else if (name.equals("focalDevice")) {
2735          return addFocalDevice();
2736        }
2737        else if (name.equals("usedReference")) {
2738          return addUsedReference();
2739        }
2740        else if (name.equals("usedCode")) {
2741          return addUsedCode();
2742        }
2743        else
2744          return super.addChild(name);
2745      }
2746
2747  public String fhirType() {
2748    return "Procedure";
2749
2750  }
2751
2752      public Procedure copy() {
2753        Procedure dst = new Procedure();
2754        copyValues(dst);
2755        if (identifier != null) {
2756          dst.identifier = new ArrayList<Identifier>();
2757          for (Identifier i : identifier)
2758            dst.identifier.add(i.copy());
2759        };
2760        if (definition != null) {
2761          dst.definition = new ArrayList<Reference>();
2762          for (Reference i : definition)
2763            dst.definition.add(i.copy());
2764        };
2765        if (basedOn != null) {
2766          dst.basedOn = new ArrayList<Reference>();
2767          for (Reference i : basedOn)
2768            dst.basedOn.add(i.copy());
2769        };
2770        if (partOf != null) {
2771          dst.partOf = new ArrayList<Reference>();
2772          for (Reference i : partOf)
2773            dst.partOf.add(i.copy());
2774        };
2775        dst.status = status == null ? null : status.copy();
2776        dst.notDone = notDone == null ? null : notDone.copy();
2777        dst.notDoneReason = notDoneReason == null ? null : notDoneReason.copy();
2778        dst.category = category == null ? null : category.copy();
2779        dst.code = code == null ? null : code.copy();
2780        dst.subject = subject == null ? null : subject.copy();
2781        dst.context = context == null ? null : context.copy();
2782        dst.performed = performed == null ? null : performed.copy();
2783        if (performer != null) {
2784          dst.performer = new ArrayList<ProcedurePerformerComponent>();
2785          for (ProcedurePerformerComponent i : performer)
2786            dst.performer.add(i.copy());
2787        };
2788        dst.location = location == null ? null : location.copy();
2789        if (reasonCode != null) {
2790          dst.reasonCode = new ArrayList<CodeableConcept>();
2791          for (CodeableConcept i : reasonCode)
2792            dst.reasonCode.add(i.copy());
2793        };
2794        if (reasonReference != null) {
2795          dst.reasonReference = new ArrayList<Reference>();
2796          for (Reference i : reasonReference)
2797            dst.reasonReference.add(i.copy());
2798        };
2799        if (bodySite != null) {
2800          dst.bodySite = new ArrayList<CodeableConcept>();
2801          for (CodeableConcept i : bodySite)
2802            dst.bodySite.add(i.copy());
2803        };
2804        dst.outcome = outcome == null ? null : outcome.copy();
2805        if (report != null) {
2806          dst.report = new ArrayList<Reference>();
2807          for (Reference i : report)
2808            dst.report.add(i.copy());
2809        };
2810        if (complication != null) {
2811          dst.complication = new ArrayList<CodeableConcept>();
2812          for (CodeableConcept i : complication)
2813            dst.complication.add(i.copy());
2814        };
2815        if (complicationDetail != null) {
2816          dst.complicationDetail = new ArrayList<Reference>();
2817          for (Reference i : complicationDetail)
2818            dst.complicationDetail.add(i.copy());
2819        };
2820        if (followUp != null) {
2821          dst.followUp = new ArrayList<CodeableConcept>();
2822          for (CodeableConcept i : followUp)
2823            dst.followUp.add(i.copy());
2824        };
2825        if (note != null) {
2826          dst.note = new ArrayList<Annotation>();
2827          for (Annotation i : note)
2828            dst.note.add(i.copy());
2829        };
2830        if (focalDevice != null) {
2831          dst.focalDevice = new ArrayList<ProcedureFocalDeviceComponent>();
2832          for (ProcedureFocalDeviceComponent i : focalDevice)
2833            dst.focalDevice.add(i.copy());
2834        };
2835        if (usedReference != null) {
2836          dst.usedReference = new ArrayList<Reference>();
2837          for (Reference i : usedReference)
2838            dst.usedReference.add(i.copy());
2839        };
2840        if (usedCode != null) {
2841          dst.usedCode = new ArrayList<CodeableConcept>();
2842          for (CodeableConcept i : usedCode)
2843            dst.usedCode.add(i.copy());
2844        };
2845        return dst;
2846      }
2847
2848      protected Procedure typedCopy() {
2849        return copy();
2850      }
2851
2852      @Override
2853      public boolean equalsDeep(Base other_) {
2854        if (!super.equalsDeep(other_))
2855          return false;
2856        if (!(other_ instanceof Procedure))
2857          return false;
2858        Procedure o = (Procedure) other_;
2859        return compareDeep(identifier, o.identifier, true) && compareDeep(definition, o.definition, true)
2860           && compareDeep(basedOn, o.basedOn, true) && compareDeep(partOf, o.partOf, true) && compareDeep(status, o.status, true)
2861           && compareDeep(notDone, o.notDone, true) && compareDeep(notDoneReason, o.notDoneReason, true) && compareDeep(category, o.category, true)
2862           && compareDeep(code, o.code, true) && compareDeep(subject, o.subject, true) && compareDeep(context, o.context, true)
2863           && compareDeep(performed, o.performed, true) && compareDeep(performer, o.performer, true) && compareDeep(location, o.location, true)
2864           && compareDeep(reasonCode, o.reasonCode, true) && compareDeep(reasonReference, o.reasonReference, true)
2865           && compareDeep(bodySite, o.bodySite, true) && compareDeep(outcome, o.outcome, true) && compareDeep(report, o.report, true)
2866           && compareDeep(complication, o.complication, true) && compareDeep(complicationDetail, o.complicationDetail, true)
2867           && compareDeep(followUp, o.followUp, true) && compareDeep(note, o.note, true) && compareDeep(focalDevice, o.focalDevice, true)
2868           && compareDeep(usedReference, o.usedReference, true) && compareDeep(usedCode, o.usedCode, true)
2869          ;
2870      }
2871
2872      @Override
2873      public boolean equalsShallow(Base other_) {
2874        if (!super.equalsShallow(other_))
2875          return false;
2876        if (!(other_ instanceof Procedure))
2877          return false;
2878        Procedure o = (Procedure) other_;
2879        return compareValues(status, o.status, true) && compareValues(notDone, o.notDone, true);
2880      }
2881
2882      public boolean isEmpty() {
2883        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, definition, basedOn
2884          , partOf, status, notDone, notDoneReason, category, code, subject, context, performed
2885          , performer, location, reasonCode, reasonReference, bodySite, outcome, report
2886          , complication, complicationDetail, followUp, note, focalDevice, usedReference, usedCode
2887          );
2888      }
2889
2890  @Override
2891  public ResourceType getResourceType() {
2892    return ResourceType.Procedure;
2893   }
2894
2895 /**
2896   * Search parameter: <b>date</b>
2897   * <p>
2898   * Description: <b>Date/Period the procedure was performed</b><br>
2899   * Type: <b>date</b><br>
2900   * Path: <b>Procedure.performed[x]</b><br>
2901   * </p>
2902   */
2903  @SearchParamDefinition(name="date", path="Procedure.performed", description="Date/Period the procedure was performed", type="date" )
2904  public static final String SP_DATE = "date";
2905 /**
2906   * <b>Fluent Client</b> search parameter constant for <b>date</b>
2907   * <p>
2908   * Description: <b>Date/Period the procedure was performed</b><br>
2909   * Type: <b>date</b><br>
2910   * Path: <b>Procedure.performed[x]</b><br>
2911   * </p>
2912   */
2913  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATE);
2914
2915 /**
2916   * Search parameter: <b>identifier</b>
2917   * <p>
2918   * Description: <b>A unique identifier for a procedure</b><br>
2919   * Type: <b>token</b><br>
2920   * Path: <b>Procedure.identifier</b><br>
2921   * </p>
2922   */
2923  @SearchParamDefinition(name="identifier", path="Procedure.identifier", description="A unique identifier for a procedure", type="token" )
2924  public static final String SP_IDENTIFIER = "identifier";
2925 /**
2926   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
2927   * <p>
2928   * Description: <b>A unique identifier for a procedure</b><br>
2929   * Type: <b>token</b><br>
2930   * Path: <b>Procedure.identifier</b><br>
2931   * </p>
2932   */
2933  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
2934
2935 /**
2936   * Search parameter: <b>code</b>
2937   * <p>
2938   * Description: <b>A code to identify a  procedure</b><br>
2939   * Type: <b>token</b><br>
2940   * Path: <b>Procedure.code</b><br>
2941   * </p>
2942   */
2943  @SearchParamDefinition(name="code", path="Procedure.code", description="A code to identify a  procedure", type="token" )
2944  public static final String SP_CODE = "code";
2945 /**
2946   * <b>Fluent Client</b> search parameter constant for <b>code</b>
2947   * <p>
2948   * Description: <b>A code to identify a  procedure</b><br>
2949   * Type: <b>token</b><br>
2950   * Path: <b>Procedure.code</b><br>
2951   * </p>
2952   */
2953  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CODE);
2954
2955 /**
2956   * Search parameter: <b>performer</b>
2957   * <p>
2958   * Description: <b>The reference to the practitioner</b><br>
2959   * Type: <b>reference</b><br>
2960   * Path: <b>Procedure.performer.actor</b><br>
2961   * </p>
2962   */
2963  @SearchParamDefinition(name="performer", path="Procedure.performer.actor", description="The reference to the practitioner", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner"), @ca.uhn.fhir.model.api.annotation.Compartment(name="RelatedPerson") }, target={Device.class, Organization.class, Patient.class, Practitioner.class, RelatedPerson.class } )
2964  public static final String SP_PERFORMER = "performer";
2965 /**
2966   * <b>Fluent Client</b> search parameter constant for <b>performer</b>
2967   * <p>
2968   * Description: <b>The reference to the practitioner</b><br>
2969   * Type: <b>reference</b><br>
2970   * Path: <b>Procedure.performer.actor</b><br>
2971   * </p>
2972   */
2973  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PERFORMER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PERFORMER);
2974
2975/**
2976   * Constant for fluent queries to be used to add include statements. Specifies
2977   * the path value of "<b>Procedure:performer</b>".
2978   */
2979  public static final ca.uhn.fhir.model.api.Include INCLUDE_PERFORMER = new ca.uhn.fhir.model.api.Include("Procedure:performer").toLocked();
2980
2981 /**
2982   * Search parameter: <b>subject</b>
2983   * <p>
2984   * Description: <b>Search by subject</b><br>
2985   * Type: <b>reference</b><br>
2986   * Path: <b>Procedure.subject</b><br>
2987   * </p>
2988   */
2989  @SearchParamDefinition(name="subject", path="Procedure.subject", description="Search by subject", type="reference", target={Group.class, Patient.class } )
2990  public static final String SP_SUBJECT = "subject";
2991 /**
2992   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
2993   * <p>
2994   * Description: <b>Search by subject</b><br>
2995   * Type: <b>reference</b><br>
2996   * Path: <b>Procedure.subject</b><br>
2997   * </p>
2998   */
2999  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
3000
3001/**
3002   * Constant for fluent queries to be used to add include statements. Specifies
3003   * the path value of "<b>Procedure:subject</b>".
3004   */
3005  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("Procedure:subject").toLocked();
3006
3007 /**
3008   * Search parameter: <b>part-of</b>
3009   * <p>
3010   * Description: <b>Part of referenced event</b><br>
3011   * Type: <b>reference</b><br>
3012   * Path: <b>Procedure.partOf</b><br>
3013   * </p>
3014   */
3015  @SearchParamDefinition(name="part-of", path="Procedure.partOf", description="Part of referenced event", type="reference", target={MedicationAdministration.class, Observation.class, Procedure.class } )
3016  public static final String SP_PART_OF = "part-of";
3017 /**
3018   * <b>Fluent Client</b> search parameter constant for <b>part-of</b>
3019   * <p>
3020   * Description: <b>Part of referenced event</b><br>
3021   * Type: <b>reference</b><br>
3022   * Path: <b>Procedure.partOf</b><br>
3023   * </p>
3024   */
3025  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PART_OF = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PART_OF);
3026
3027/**
3028   * Constant for fluent queries to be used to add include statements. Specifies
3029   * the path value of "<b>Procedure:part-of</b>".
3030   */
3031  public static final ca.uhn.fhir.model.api.Include INCLUDE_PART_OF = new ca.uhn.fhir.model.api.Include("Procedure:part-of").toLocked();
3032
3033 /**
3034   * Search parameter: <b>encounter</b>
3035   * <p>
3036   * Description: <b>Search by encounter</b><br>
3037   * Type: <b>reference</b><br>
3038   * Path: <b>Procedure.context</b><br>
3039   * </p>
3040   */
3041  @SearchParamDefinition(name="encounter", path="Procedure.context", description="Search by encounter", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Encounter") }, target={Encounter.class } )
3042  public static final String SP_ENCOUNTER = "encounter";
3043 /**
3044   * <b>Fluent Client</b> search parameter constant for <b>encounter</b>
3045   * <p>
3046   * Description: <b>Search by encounter</b><br>
3047   * Type: <b>reference</b><br>
3048   * Path: <b>Procedure.context</b><br>
3049   * </p>
3050   */
3051  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENCOUNTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENCOUNTER);
3052
3053/**
3054   * Constant for fluent queries to be used to add include statements. Specifies
3055   * the path value of "<b>Procedure:encounter</b>".
3056   */
3057  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENCOUNTER = new ca.uhn.fhir.model.api.Include("Procedure:encounter").toLocked();
3058
3059 /**
3060   * Search parameter: <b>based-on</b>
3061   * <p>
3062   * Description: <b>A request for this procedure</b><br>
3063   * Type: <b>reference</b><br>
3064   * Path: <b>Procedure.basedOn</b><br>
3065   * </p>
3066   */
3067  @SearchParamDefinition(name="based-on", path="Procedure.basedOn", description="A request for this procedure", type="reference", target={CarePlan.class, ProcedureRequest.class, ReferralRequest.class } )
3068  public static final String SP_BASED_ON = "based-on";
3069 /**
3070   * <b>Fluent Client</b> search parameter constant for <b>based-on</b>
3071   * <p>
3072   * Description: <b>A request for this procedure</b><br>
3073   * Type: <b>reference</b><br>
3074   * Path: <b>Procedure.basedOn</b><br>
3075   * </p>
3076   */
3077  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam BASED_ON = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_BASED_ON);
3078
3079/**
3080   * Constant for fluent queries to be used to add include statements. Specifies
3081   * the path value of "<b>Procedure:based-on</b>".
3082   */
3083  public static final ca.uhn.fhir.model.api.Include INCLUDE_BASED_ON = new ca.uhn.fhir.model.api.Include("Procedure:based-on").toLocked();
3084
3085 /**
3086   * Search parameter: <b>patient</b>
3087   * <p>
3088   * Description: <b>Search by subject - a patient</b><br>
3089   * Type: <b>reference</b><br>
3090   * Path: <b>Procedure.subject</b><br>
3091   * </p>
3092   */
3093  @SearchParamDefinition(name="patient", path="Procedure.subject", description="Search by subject - a patient", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Patient.class } )
3094  public static final String SP_PATIENT = "patient";
3095 /**
3096   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
3097   * <p>
3098   * Description: <b>Search by subject - a patient</b><br>
3099   * Type: <b>reference</b><br>
3100   * Path: <b>Procedure.subject</b><br>
3101   * </p>
3102   */
3103  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
3104
3105/**
3106   * Constant for fluent queries to be used to add include statements. Specifies
3107   * the path value of "<b>Procedure:patient</b>".
3108   */
3109  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("Procedure:patient").toLocked();
3110
3111 /**
3112   * Search parameter: <b>context</b>
3113   * <p>
3114   * Description: <b>Encounter or episode associated with the procedure</b><br>
3115   * Type: <b>reference</b><br>
3116   * Path: <b>Procedure.context</b><br>
3117   * </p>
3118   */
3119  @SearchParamDefinition(name="context", path="Procedure.context", description="Encounter or episode associated with the procedure", type="reference", target={Encounter.class, EpisodeOfCare.class } )
3120  public static final String SP_CONTEXT = "context";
3121 /**
3122   * <b>Fluent Client</b> search parameter constant for <b>context</b>
3123   * <p>
3124   * Description: <b>Encounter or episode associated with the procedure</b><br>
3125   * Type: <b>reference</b><br>
3126   * Path: <b>Procedure.context</b><br>
3127   * </p>
3128   */
3129  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam CONTEXT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_CONTEXT);
3130
3131/**
3132   * Constant for fluent queries to be used to add include statements. Specifies
3133   * the path value of "<b>Procedure:context</b>".
3134   */
3135  public static final ca.uhn.fhir.model.api.Include INCLUDE_CONTEXT = new ca.uhn.fhir.model.api.Include("Procedure:context").toLocked();
3136
3137 /**
3138   * Search parameter: <b>location</b>
3139   * <p>
3140   * Description: <b>Where the procedure happened</b><br>
3141   * Type: <b>reference</b><br>
3142   * Path: <b>Procedure.location</b><br>
3143   * </p>
3144   */
3145  @SearchParamDefinition(name="location", path="Procedure.location", description="Where the procedure happened", type="reference", target={Location.class } )
3146  public static final String SP_LOCATION = "location";
3147 /**
3148   * <b>Fluent Client</b> search parameter constant for <b>location</b>
3149   * <p>
3150   * Description: <b>Where the procedure happened</b><br>
3151   * Type: <b>reference</b><br>
3152   * Path: <b>Procedure.location</b><br>
3153   * </p>
3154   */
3155  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam LOCATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_LOCATION);
3156
3157/**
3158   * Constant for fluent queries to be used to add include statements. Specifies
3159   * the path value of "<b>Procedure:location</b>".
3160   */
3161  public static final ca.uhn.fhir.model.api.Include INCLUDE_LOCATION = new ca.uhn.fhir.model.api.Include("Procedure:location").toLocked();
3162
3163 /**
3164   * Search parameter: <b>definition</b>
3165   * <p>
3166   * Description: <b>Instantiates protocol or definition</b><br>
3167   * Type: <b>reference</b><br>
3168   * Path: <b>Procedure.definition</b><br>
3169   * </p>
3170   */
3171  @SearchParamDefinition(name="definition", path="Procedure.definition", description="Instantiates protocol or definition", type="reference", target={ActivityDefinition.class, HealthcareService.class, PlanDefinition.class } )
3172  public static final String SP_DEFINITION = "definition";
3173 /**
3174   * <b>Fluent Client</b> search parameter constant for <b>definition</b>
3175   * <p>
3176   * Description: <b>Instantiates protocol or definition</b><br>
3177   * Type: <b>reference</b><br>
3178   * Path: <b>Procedure.definition</b><br>
3179   * </p>
3180   */
3181  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam DEFINITION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_DEFINITION);
3182
3183/**
3184   * Constant for fluent queries to be used to add include statements. Specifies
3185   * the path value of "<b>Procedure:definition</b>".
3186   */
3187  public static final ca.uhn.fhir.model.api.Include INCLUDE_DEFINITION = new ca.uhn.fhir.model.api.Include("Procedure:definition").toLocked();
3188
3189 /**
3190   * Search parameter: <b>category</b>
3191   * <p>
3192   * Description: <b>Classification of the procedure</b><br>
3193   * Type: <b>token</b><br>
3194   * Path: <b>Procedure.category</b><br>
3195   * </p>
3196   */
3197  @SearchParamDefinition(name="category", path="Procedure.category", description="Classification of the procedure", type="token" )
3198  public static final String SP_CATEGORY = "category";
3199 /**
3200   * <b>Fluent Client</b> search parameter constant for <b>category</b>
3201   * <p>
3202   * Description: <b>Classification of the procedure</b><br>
3203   * Type: <b>token</b><br>
3204   * Path: <b>Procedure.category</b><br>
3205   * </p>
3206   */
3207  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CATEGORY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CATEGORY);
3208
3209 /**
3210   * Search parameter: <b>status</b>
3211   * <p>
3212   * Description: <b>preparation | in-progress | suspended | aborted | completed | entered-in-error | unknown</b><br>
3213   * Type: <b>token</b><br>
3214   * Path: <b>Procedure.status</b><br>
3215   * </p>
3216   */
3217  @SearchParamDefinition(name="status", path="Procedure.status", description="preparation | in-progress | suspended | aborted | completed | entered-in-error | unknown", type="token" )
3218  public static final String SP_STATUS = "status";
3219 /**
3220   * <b>Fluent Client</b> search parameter constant for <b>status</b>
3221   * <p>
3222   * Description: <b>preparation | in-progress | suspended | aborted | completed | entered-in-error | unknown</b><br>
3223   * Type: <b>token</b><br>
3224   * Path: <b>Procedure.status</b><br>
3225   * </p>
3226   */
3227  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
3228
3229
3230}
3231