001package org.hl7.fhir.dstu2016may.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
033import java.util.ArrayList;
034import java.util.List;
035
036import org.hl7.fhir.exceptions.FHIRException;
037import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
038
039import ca.uhn.fhir.model.api.annotation.Block;
040import ca.uhn.fhir.model.api.annotation.Child;
041import ca.uhn.fhir.model.api.annotation.Description;
042import ca.uhn.fhir.model.api.annotation.ResourceDef;
043import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
044/**
045 * 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.
046 */
047@ResourceDef(name="Procedure", profile="http://hl7.org/fhir/Profile/Procedure")
048public class Procedure extends DomainResource {
049
050    public enum ProcedureStatus {
051        /**
052         * The procedure is still occurring.
053         */
054        INPROGRESS, 
055        /**
056         * The procedure was terminated without completing successfully.
057         */
058        ABORTED, 
059        /**
060         * All actions involved in the procedure have taken place.
061         */
062        COMPLETED, 
063        /**
064         * The statement was entered in error and Is not valid.
065         */
066        ENTEREDINERROR, 
067        /**
068         * added to help the parsers
069         */
070        NULL;
071        public static ProcedureStatus fromCode(String codeString) throws FHIRException {
072            if (codeString == null || "".equals(codeString))
073                return null;
074        if ("in-progress".equals(codeString))
075          return INPROGRESS;
076        if ("aborted".equals(codeString))
077          return ABORTED;
078        if ("completed".equals(codeString))
079          return COMPLETED;
080        if ("entered-in-error".equals(codeString))
081          return ENTEREDINERROR;
082        throw new FHIRException("Unknown ProcedureStatus code '"+codeString+"'");
083        }
084        public String toCode() {
085          switch (this) {
086            case INPROGRESS: return "in-progress";
087            case ABORTED: return "aborted";
088            case COMPLETED: return "completed";
089            case ENTEREDINERROR: return "entered-in-error";
090            default: return "?";
091          }
092        }
093        public String getSystem() {
094          switch (this) {
095            case INPROGRESS: return "http://hl7.org/fhir/procedure-status";
096            case ABORTED: return "http://hl7.org/fhir/procedure-status";
097            case COMPLETED: return "http://hl7.org/fhir/procedure-status";
098            case ENTEREDINERROR: return "http://hl7.org/fhir/procedure-status";
099            default: return "?";
100          }
101        }
102        public String getDefinition() {
103          switch (this) {
104            case INPROGRESS: return "The procedure is still occurring.";
105            case ABORTED: return "The procedure was terminated without completing successfully.";
106            case COMPLETED: return "All actions involved in the procedure have taken place.";
107            case ENTEREDINERROR: return "The statement was entered in error and Is not valid.";
108            default: return "?";
109          }
110        }
111        public String getDisplay() {
112          switch (this) {
113            case INPROGRESS: return "In Progress";
114            case ABORTED: return "Aboted";
115            case COMPLETED: return "Completed";
116            case ENTEREDINERROR: return "Entered in Error";
117            default: return "?";
118          }
119        }
120    }
121
122  public static class ProcedureStatusEnumFactory implements EnumFactory<ProcedureStatus> {
123    public ProcedureStatus fromCode(String codeString) throws IllegalArgumentException {
124      if (codeString == null || "".equals(codeString))
125            if (codeString == null || "".equals(codeString))
126                return null;
127        if ("in-progress".equals(codeString))
128          return ProcedureStatus.INPROGRESS;
129        if ("aborted".equals(codeString))
130          return ProcedureStatus.ABORTED;
131        if ("completed".equals(codeString))
132          return ProcedureStatus.COMPLETED;
133        if ("entered-in-error".equals(codeString))
134          return ProcedureStatus.ENTEREDINERROR;
135        throw new IllegalArgumentException("Unknown ProcedureStatus code '"+codeString+"'");
136        }
137        public Enumeration<ProcedureStatus> fromType(Base code) throws FHIRException {
138          if (code == null || code.isEmpty())
139            return null;
140          String codeString = ((PrimitiveType) code).asStringValue();
141          if (codeString == null || "".equals(codeString))
142            return null;
143        if ("in-progress".equals(codeString))
144          return new Enumeration<ProcedureStatus>(this, ProcedureStatus.INPROGRESS);
145        if ("aborted".equals(codeString))
146          return new Enumeration<ProcedureStatus>(this, ProcedureStatus.ABORTED);
147        if ("completed".equals(codeString))
148          return new Enumeration<ProcedureStatus>(this, ProcedureStatus.COMPLETED);
149        if ("entered-in-error".equals(codeString))
150          return new Enumeration<ProcedureStatus>(this, ProcedureStatus.ENTEREDINERROR);
151        throw new FHIRException("Unknown ProcedureStatus code '"+codeString+"'");
152        }
153    public String toCode(ProcedureStatus code) {
154      if (code == ProcedureStatus.INPROGRESS)
155        return "in-progress";
156      if (code == ProcedureStatus.ABORTED)
157        return "aborted";
158      if (code == ProcedureStatus.COMPLETED)
159        return "completed";
160      if (code == ProcedureStatus.ENTEREDINERROR)
161        return "entered-in-error";
162      return "?";
163      }
164    public String toSystem(ProcedureStatus code) {
165      return code.getSystem();
166      }
167    }
168
169    @Block()
170    public static class ProcedurePerformerComponent extends BackboneElement implements IBaseBackboneElement {
171        /**
172         * The practitioner who was involved in the procedure.
173         */
174        @Child(name = "actor", type = {Practitioner.class, Organization.class, Patient.class, RelatedPerson.class}, order=1, min=0, max=1, modifier=false, summary=true)
175        @Description(shortDefinition="The reference to the practitioner", formalDefinition="The practitioner who was involved in the procedure." )
176        protected Reference actor;
177
178        /**
179         * The actual object that is the target of the reference (The practitioner who was involved in the procedure.)
180         */
181        protected Resource actorTarget;
182
183        /**
184         * For example: surgeon, anaethetist, endoscopist.
185         */
186        @Child(name = "role", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
187        @Description(shortDefinition="The role the actor was in", formalDefinition="For example: surgeon, anaethetist, endoscopist." )
188        protected CodeableConcept role;
189
190        private static final long serialVersionUID = -843698327L;
191
192    /**
193     * Constructor
194     */
195      public ProcedurePerformerComponent() {
196        super();
197      }
198
199        /**
200         * @return {@link #actor} (The practitioner who was involved in the procedure.)
201         */
202        public Reference getActor() { 
203          if (this.actor == null)
204            if (Configuration.errorOnAutoCreate())
205              throw new Error("Attempt to auto-create ProcedurePerformerComponent.actor");
206            else if (Configuration.doAutoCreate())
207              this.actor = new Reference(); // cc
208          return this.actor;
209        }
210
211        public boolean hasActor() { 
212          return this.actor != null && !this.actor.isEmpty();
213        }
214
215        /**
216         * @param value {@link #actor} (The practitioner who was involved in the procedure.)
217         */
218        public ProcedurePerformerComponent setActor(Reference value) { 
219          this.actor = value;
220          return this;
221        }
222
223        /**
224         * @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.)
225         */
226        public Resource getActorTarget() { 
227          return this.actorTarget;
228        }
229
230        /**
231         * @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.)
232         */
233        public ProcedurePerformerComponent setActorTarget(Resource value) { 
234          this.actorTarget = value;
235          return this;
236        }
237
238        /**
239         * @return {@link #role} (For example: surgeon, anaethetist, endoscopist.)
240         */
241        public CodeableConcept getRole() { 
242          if (this.role == null)
243            if (Configuration.errorOnAutoCreate())
244              throw new Error("Attempt to auto-create ProcedurePerformerComponent.role");
245            else if (Configuration.doAutoCreate())
246              this.role = new CodeableConcept(); // cc
247          return this.role;
248        }
249
250        public boolean hasRole() { 
251          return this.role != null && !this.role.isEmpty();
252        }
253
254        /**
255         * @param value {@link #role} (For example: surgeon, anaethetist, endoscopist.)
256         */
257        public ProcedurePerformerComponent setRole(CodeableConcept value) { 
258          this.role = value;
259          return this;
260        }
261
262        protected void listChildren(List<Property> childrenList) {
263          super.listChildren(childrenList);
264          childrenList.add(new Property("actor", "Reference(Practitioner|Organization|Patient|RelatedPerson)", "The practitioner who was involved in the procedure.", 0, java.lang.Integer.MAX_VALUE, actor));
265          childrenList.add(new Property("role", "CodeableConcept", "For example: surgeon, anaethetist, endoscopist.", 0, java.lang.Integer.MAX_VALUE, role));
266        }
267
268      @Override
269      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
270        switch (hash) {
271        case 92645877: /*actor*/ return this.actor == null ? new Base[0] : new Base[] {this.actor}; // Reference
272        case 3506294: /*role*/ return this.role == null ? new Base[0] : new Base[] {this.role}; // CodeableConcept
273        default: return super.getProperty(hash, name, checkValid);
274        }
275
276      }
277
278      @Override
279      public void setProperty(int hash, String name, Base value) throws FHIRException {
280        switch (hash) {
281        case 92645877: // actor
282          this.actor = castToReference(value); // Reference
283          break;
284        case 3506294: // role
285          this.role = castToCodeableConcept(value); // CodeableConcept
286          break;
287        default: super.setProperty(hash, name, value);
288        }
289
290      }
291
292      @Override
293      public void setProperty(String name, Base value) throws FHIRException {
294        if (name.equals("actor"))
295          this.actor = castToReference(value); // Reference
296        else if (name.equals("role"))
297          this.role = castToCodeableConcept(value); // CodeableConcept
298        else
299          super.setProperty(name, value);
300      }
301
302      @Override
303      public Base makeProperty(int hash, String name) throws FHIRException {
304        switch (hash) {
305        case 92645877:  return getActor(); // Reference
306        case 3506294:  return getRole(); // CodeableConcept
307        default: return super.makeProperty(hash, name);
308        }
309
310      }
311
312      @Override
313      public Base addChild(String name) throws FHIRException {
314        if (name.equals("actor")) {
315          this.actor = new Reference();
316          return this.actor;
317        }
318        else if (name.equals("role")) {
319          this.role = new CodeableConcept();
320          return this.role;
321        }
322        else
323          return super.addChild(name);
324      }
325
326      public ProcedurePerformerComponent copy() {
327        ProcedurePerformerComponent dst = new ProcedurePerformerComponent();
328        copyValues(dst);
329        dst.actor = actor == null ? null : actor.copy();
330        dst.role = role == null ? null : role.copy();
331        return dst;
332      }
333
334      @Override
335      public boolean equalsDeep(Base other) {
336        if (!super.equalsDeep(other))
337          return false;
338        if (!(other instanceof ProcedurePerformerComponent))
339          return false;
340        ProcedurePerformerComponent o = (ProcedurePerformerComponent) other;
341        return compareDeep(actor, o.actor, true) && compareDeep(role, o.role, true);
342      }
343
344      @Override
345      public boolean equalsShallow(Base other) {
346        if (!super.equalsShallow(other))
347          return false;
348        if (!(other instanceof ProcedurePerformerComponent))
349          return false;
350        ProcedurePerformerComponent o = (ProcedurePerformerComponent) other;
351        return true;
352      }
353
354      public boolean isEmpty() {
355        return super.isEmpty() && (actor == null || actor.isEmpty()) && (role == null || role.isEmpty())
356          ;
357      }
358
359  public String fhirType() {
360    return "Procedure.performer";
361
362  }
363
364  }
365
366    @Block()
367    public static class ProcedureFocalDeviceComponent extends BackboneElement implements IBaseBackboneElement {
368        /**
369         * The kind of change that happened to the device during the procedure.
370         */
371        @Child(name = "action", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=false)
372        @Description(shortDefinition="Kind of change to device", formalDefinition="The kind of change that happened to the device during the procedure." )
373        protected CodeableConcept action;
374
375        /**
376         * The device that was manipulated (changed) during the procedure.
377         */
378        @Child(name = "manipulated", type = {Device.class}, order=2, min=1, max=1, modifier=false, summary=false)
379        @Description(shortDefinition="Device that was changed", formalDefinition="The device that was manipulated (changed) during the procedure." )
380        protected Reference manipulated;
381
382        /**
383         * The actual object that is the target of the reference (The device that was manipulated (changed) during the procedure.)
384         */
385        protected Device manipulatedTarget;
386
387        private static final long serialVersionUID = 1779937807L;
388
389    /**
390     * Constructor
391     */
392      public ProcedureFocalDeviceComponent() {
393        super();
394      }
395
396    /**
397     * Constructor
398     */
399      public ProcedureFocalDeviceComponent(Reference manipulated) {
400        super();
401        this.manipulated = manipulated;
402      }
403
404        /**
405         * @return {@link #action} (The kind of change that happened to the device during the procedure.)
406         */
407        public CodeableConcept getAction() { 
408          if (this.action == null)
409            if (Configuration.errorOnAutoCreate())
410              throw new Error("Attempt to auto-create ProcedureFocalDeviceComponent.action");
411            else if (Configuration.doAutoCreate())
412              this.action = new CodeableConcept(); // cc
413          return this.action;
414        }
415
416        public boolean hasAction() { 
417          return this.action != null && !this.action.isEmpty();
418        }
419
420        /**
421         * @param value {@link #action} (The kind of change that happened to the device during the procedure.)
422         */
423        public ProcedureFocalDeviceComponent setAction(CodeableConcept value) { 
424          this.action = value;
425          return this;
426        }
427
428        /**
429         * @return {@link #manipulated} (The device that was manipulated (changed) during the procedure.)
430         */
431        public Reference getManipulated() { 
432          if (this.manipulated == null)
433            if (Configuration.errorOnAutoCreate())
434              throw new Error("Attempt to auto-create ProcedureFocalDeviceComponent.manipulated");
435            else if (Configuration.doAutoCreate())
436              this.manipulated = new Reference(); // cc
437          return this.manipulated;
438        }
439
440        public boolean hasManipulated() { 
441          return this.manipulated != null && !this.manipulated.isEmpty();
442        }
443
444        /**
445         * @param value {@link #manipulated} (The device that was manipulated (changed) during the procedure.)
446         */
447        public ProcedureFocalDeviceComponent setManipulated(Reference value) { 
448          this.manipulated = value;
449          return this;
450        }
451
452        /**
453         * @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.)
454         */
455        public Device getManipulatedTarget() { 
456          if (this.manipulatedTarget == null)
457            if (Configuration.errorOnAutoCreate())
458              throw new Error("Attempt to auto-create ProcedureFocalDeviceComponent.manipulated");
459            else if (Configuration.doAutoCreate())
460              this.manipulatedTarget = new Device(); // aa
461          return this.manipulatedTarget;
462        }
463
464        /**
465         * @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.)
466         */
467        public ProcedureFocalDeviceComponent setManipulatedTarget(Device value) { 
468          this.manipulatedTarget = value;
469          return this;
470        }
471
472        protected void listChildren(List<Property> childrenList) {
473          super.listChildren(childrenList);
474          childrenList.add(new Property("action", "CodeableConcept", "The kind of change that happened to the device during the procedure.", 0, java.lang.Integer.MAX_VALUE, action));
475          childrenList.add(new Property("manipulated", "Reference(Device)", "The device that was manipulated (changed) during the procedure.", 0, java.lang.Integer.MAX_VALUE, manipulated));
476        }
477
478      @Override
479      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
480        switch (hash) {
481        case -1422950858: /*action*/ return this.action == null ? new Base[0] : new Base[] {this.action}; // CodeableConcept
482        case 947372650: /*manipulated*/ return this.manipulated == null ? new Base[0] : new Base[] {this.manipulated}; // Reference
483        default: return super.getProperty(hash, name, checkValid);
484        }
485
486      }
487
488      @Override
489      public void setProperty(int hash, String name, Base value) throws FHIRException {
490        switch (hash) {
491        case -1422950858: // action
492          this.action = castToCodeableConcept(value); // CodeableConcept
493          break;
494        case 947372650: // manipulated
495          this.manipulated = castToReference(value); // Reference
496          break;
497        default: super.setProperty(hash, name, value);
498        }
499
500      }
501
502      @Override
503      public void setProperty(String name, Base value) throws FHIRException {
504        if (name.equals("action"))
505          this.action = castToCodeableConcept(value); // CodeableConcept
506        else if (name.equals("manipulated"))
507          this.manipulated = castToReference(value); // Reference
508        else
509          super.setProperty(name, value);
510      }
511
512      @Override
513      public Base makeProperty(int hash, String name) throws FHIRException {
514        switch (hash) {
515        case -1422950858:  return getAction(); // CodeableConcept
516        case 947372650:  return getManipulated(); // Reference
517        default: return super.makeProperty(hash, name);
518        }
519
520      }
521
522      @Override
523      public Base addChild(String name) throws FHIRException {
524        if (name.equals("action")) {
525          this.action = new CodeableConcept();
526          return this.action;
527        }
528        else if (name.equals("manipulated")) {
529          this.manipulated = new Reference();
530          return this.manipulated;
531        }
532        else
533          return super.addChild(name);
534      }
535
536      public ProcedureFocalDeviceComponent copy() {
537        ProcedureFocalDeviceComponent dst = new ProcedureFocalDeviceComponent();
538        copyValues(dst);
539        dst.action = action == null ? null : action.copy();
540        dst.manipulated = manipulated == null ? null : manipulated.copy();
541        return dst;
542      }
543
544      @Override
545      public boolean equalsDeep(Base other) {
546        if (!super.equalsDeep(other))
547          return false;
548        if (!(other instanceof ProcedureFocalDeviceComponent))
549          return false;
550        ProcedureFocalDeviceComponent o = (ProcedureFocalDeviceComponent) other;
551        return compareDeep(action, o.action, true) && compareDeep(manipulated, o.manipulated, true);
552      }
553
554      @Override
555      public boolean equalsShallow(Base other) {
556        if (!super.equalsShallow(other))
557          return false;
558        if (!(other instanceof ProcedureFocalDeviceComponent))
559          return false;
560        ProcedureFocalDeviceComponent o = (ProcedureFocalDeviceComponent) other;
561        return true;
562      }
563
564      public boolean isEmpty() {
565        return super.isEmpty() && (action == null || action.isEmpty()) && (manipulated == null || manipulated.isEmpty())
566          ;
567      }
568
569  public String fhirType() {
570    return "Procedure.focalDevice";
571
572  }
573
574  }
575
576    /**
577     * 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).
578     */
579    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
580    @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)." )
581    protected List<Identifier> identifier;
582
583    /**
584     * The person, animal or group on which the procedure was performed.
585     */
586    @Child(name = "subject", type = {Patient.class, Group.class}, order=1, min=1, max=1, modifier=false, summary=true)
587    @Description(shortDefinition="Who the procedure was performed on", formalDefinition="The person, animal or group on which the procedure was performed." )
588    protected Reference subject;
589
590    /**
591     * The actual object that is the target of the reference (The person, animal or group on which the procedure was performed.)
592     */
593    protected Resource subjectTarget;
594
595    /**
596     * A code specifying the state of the procedure. Generally this will be in-progress or completed state.
597     */
598    @Child(name = "status", type = {CodeType.class}, order=2, min=1, max=1, modifier=true, summary=true)
599    @Description(shortDefinition="in-progress | aborted | completed | entered-in-error", formalDefinition="A code specifying the state of the procedure. Generally this will be in-progress or completed state." )
600    protected Enumeration<ProcedureStatus> status;
601
602    /**
603     * A code that classifies the procedure for searching, sorting and display purposes (e.g. "Surgical Procedure").
604     */
605    @Child(name = "category", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=true)
606    @Description(shortDefinition="Classification of the procedure", formalDefinition="A code that classifies the procedure for searching, sorting and display purposes (e.g. \"Surgical Procedure\")." )
607    protected CodeableConcept category;
608
609    /**
610     * The specific procedure that is performed. Use text if the exact nature of the procedure cannot be coded (e.g. "Laparoscopic Appendectomy").
611     */
612    @Child(name = "code", type = {CodeableConcept.class}, order=4, min=1, max=1, modifier=false, summary=true)
613    @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\")." )
614    protected CodeableConcept code;
615
616    /**
617     * Set this to true if the record is saying that the procedure was NOT performed.
618     */
619    @Child(name = "notPerformed", type = {BooleanType.class}, order=5, min=0, max=1, modifier=true, summary=false)
620    @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." )
621    protected BooleanType notPerformed;
622
623    /**
624     * A code indicating why the procedure was not performed.
625     */
626    @Child(name = "reasonNotPerformed", type = {CodeableConcept.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
627    @Description(shortDefinition="Reason procedure was not performed", formalDefinition="A code indicating why the procedure was not performed." )
628    protected List<CodeableConcept> reasonNotPerformed;
629
630    /**
631     * Detailed and structured anatomical location information. Multiple locations are allowed - e.g. multiple punch biopsies of a lesion.
632     */
633    @Child(name = "bodySite", type = {CodeableConcept.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
634    @Description(shortDefinition="Target body sites", formalDefinition="Detailed and structured anatomical location information. Multiple locations are allowed - e.g. multiple punch biopsies of a lesion." )
635    protected List<CodeableConcept> bodySite;
636
637    /**
638     * The reason why the procedure was performed. This may be due to a Condition, may be coded entity of some type, or may simply be present as text.
639     */
640    @Child(name = "reason", type = {CodeableConcept.class, Condition.class}, order=8, min=0, max=1, modifier=false, summary=true)
641    @Description(shortDefinition="Reason procedure performed", formalDefinition="The reason why the procedure was performed. This may be due to a Condition, may be coded entity of some type, or may simply be present as text." )
642    protected Type reason;
643
644    /**
645     * Limited to 'real' people rather than equipment.
646     */
647    @Child(name = "performer", type = {}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
648    @Description(shortDefinition="The people who performed the procedure", formalDefinition="Limited to 'real' people rather than equipment." )
649    protected List<ProcedurePerformerComponent> performer;
650
651    /**
652     * 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.
653     */
654    @Child(name = "performed", type = {DateTimeType.class, Period.class}, order=10, min=0, max=1, modifier=false, summary=true)
655    @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." )
656    protected Type performed;
657
658    /**
659     * The encounter during which the procedure was performed.
660     */
661    @Child(name = "encounter", type = {Encounter.class}, order=11, min=0, max=1, modifier=false, summary=true)
662    @Description(shortDefinition="The encounter associated with the procedure", formalDefinition="The encounter during which the procedure was performed." )
663    protected Reference encounter;
664
665    /**
666     * The actual object that is the target of the reference (The encounter during which the procedure was performed.)
667     */
668    protected Encounter encounterTarget;
669
670    /**
671     * The location where the procedure actually happened.  E.g. a newborn at home, a tracheostomy at a restaurant.
672     */
673    @Child(name = "location", type = {Location.class}, order=12, min=0, max=1, modifier=false, summary=true)
674    @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." )
675    protected Reference location;
676
677    /**
678     * 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.)
679     */
680    protected Location locationTarget;
681
682    /**
683     * The outcome of the procedure - did it resolve reasons for the procedure being performed?
684     */
685    @Child(name = "outcome", type = {CodeableConcept.class}, order=13, min=0, max=1, modifier=false, summary=true)
686    @Description(shortDefinition="The result of procedure", formalDefinition="The outcome of the procedure - did it resolve reasons for the procedure being performed?" )
687    protected CodeableConcept outcome;
688
689    /**
690     * This could be a histology result, pathology report, surgical report, etc..
691     */
692    @Child(name = "report", type = {DiagnosticReport.class}, order=14, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
693    @Description(shortDefinition="Any report resulting from the procedure", formalDefinition="This could be a histology result, pathology report, surgical report, etc.." )
694    protected List<Reference> report;
695    /**
696     * The actual objects that are the target of the reference (This could be a histology result, pathology report, surgical report, etc..)
697     */
698    protected List<DiagnosticReport> reportTarget;
699
700
701    /**
702     * 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.
703     */
704    @Child(name = "complication", type = {CodeableConcept.class}, order=15, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
705    @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." )
706    protected List<CodeableConcept> complication;
707
708    /**
709     * 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.
710     */
711    @Child(name = "followUp", type = {CodeableConcept.class}, order=16, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
712    @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." )
713    protected List<CodeableConcept> followUp;
714
715    /**
716     * A reference to a resource that contains details of the request for this procedure.
717     */
718    @Child(name = "request", type = {CarePlan.class, DiagnosticOrder.class, ProcedureRequest.class, ReferralRequest.class}, order=17, min=0, max=1, modifier=false, summary=false)
719    @Description(shortDefinition="A request for this procedure", formalDefinition="A reference to a resource that contains details of the request for this procedure." )
720    protected Reference request;
721
722    /**
723     * The actual object that is the target of the reference (A reference to a resource that contains details of the request for this procedure.)
724     */
725    protected Resource requestTarget;
726
727    /**
728     * Any other notes about the procedure.  E.g. the operative notes.
729     */
730    @Child(name = "notes", type = {Annotation.class}, order=18, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
731    @Description(shortDefinition="Additional information about the procedure", formalDefinition="Any other notes about the procedure.  E.g. the operative notes." )
732    protected List<Annotation> notes;
733
734    /**
735     * 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.
736     */
737    @Child(name = "focalDevice", type = {}, order=19, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
738    @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." )
739    protected List<ProcedureFocalDeviceComponent> focalDevice;
740
741    /**
742     * Identifies medications, devices and any other substance used as part of the procedure.
743     */
744    @Child(name = "used", type = {Device.class, Medication.class, Substance.class}, order=20, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
745    @Description(shortDefinition="Items used during procedure", formalDefinition="Identifies medications, devices and any other substance used as part of the procedure." )
746    protected List<Reference> used;
747    /**
748     * The actual objects that are the target of the reference (Identifies medications, devices and any other substance used as part of the procedure.)
749     */
750    protected List<Resource> usedTarget;
751
752
753    private static final long serialVersionUID = -489125036L;
754
755  /**
756   * Constructor
757   */
758    public Procedure() {
759      super();
760    }
761
762  /**
763   * Constructor
764   */
765    public Procedure(Reference subject, Enumeration<ProcedureStatus> status, CodeableConcept code) {
766      super();
767      this.subject = subject;
768      this.status = status;
769      this.code = code;
770    }
771
772    /**
773     * @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).)
774     */
775    public List<Identifier> getIdentifier() { 
776      if (this.identifier == null)
777        this.identifier = new ArrayList<Identifier>();
778      return this.identifier;
779    }
780
781    public boolean hasIdentifier() { 
782      if (this.identifier == null)
783        return false;
784      for (Identifier item : this.identifier)
785        if (!item.isEmpty())
786          return true;
787      return false;
788    }
789
790    /**
791     * @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).)
792     */
793    // syntactic sugar
794    public Identifier addIdentifier() { //3
795      Identifier t = new Identifier();
796      if (this.identifier == null)
797        this.identifier = new ArrayList<Identifier>();
798      this.identifier.add(t);
799      return t;
800    }
801
802    // syntactic sugar
803    public Procedure addIdentifier(Identifier t) { //3
804      if (t == null)
805        return this;
806      if (this.identifier == null)
807        this.identifier = new ArrayList<Identifier>();
808      this.identifier.add(t);
809      return this;
810    }
811
812    /**
813     * @return {@link #subject} (The person, animal or group on which the procedure was performed.)
814     */
815    public Reference getSubject() { 
816      if (this.subject == null)
817        if (Configuration.errorOnAutoCreate())
818          throw new Error("Attempt to auto-create Procedure.subject");
819        else if (Configuration.doAutoCreate())
820          this.subject = new Reference(); // cc
821      return this.subject;
822    }
823
824    public boolean hasSubject() { 
825      return this.subject != null && !this.subject.isEmpty();
826    }
827
828    /**
829     * @param value {@link #subject} (The person, animal or group on which the procedure was performed.)
830     */
831    public Procedure setSubject(Reference value) { 
832      this.subject = value;
833      return this;
834    }
835
836    /**
837     * @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.)
838     */
839    public Resource getSubjectTarget() { 
840      return this.subjectTarget;
841    }
842
843    /**
844     * @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.)
845     */
846    public Procedure setSubjectTarget(Resource value) { 
847      this.subjectTarget = value;
848      return this;
849    }
850
851    /**
852     * @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
853     */
854    public Enumeration<ProcedureStatus> getStatusElement() { 
855      if (this.status == null)
856        if (Configuration.errorOnAutoCreate())
857          throw new Error("Attempt to auto-create Procedure.status");
858        else if (Configuration.doAutoCreate())
859          this.status = new Enumeration<ProcedureStatus>(new ProcedureStatusEnumFactory()); // bb
860      return this.status;
861    }
862
863    public boolean hasStatusElement() { 
864      return this.status != null && !this.status.isEmpty();
865    }
866
867    public boolean hasStatus() { 
868      return this.status != null && !this.status.isEmpty();
869    }
870
871    /**
872     * @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
873     */
874    public Procedure setStatusElement(Enumeration<ProcedureStatus> value) { 
875      this.status = value;
876      return this;
877    }
878
879    /**
880     * @return A code specifying the state of the procedure. Generally this will be in-progress or completed state.
881     */
882    public ProcedureStatus getStatus() { 
883      return this.status == null ? null : this.status.getValue();
884    }
885
886    /**
887     * @param value A code specifying the state of the procedure. Generally this will be in-progress or completed state.
888     */
889    public Procedure setStatus(ProcedureStatus value) { 
890        if (this.status == null)
891          this.status = new Enumeration<ProcedureStatus>(new ProcedureStatusEnumFactory());
892        this.status.setValue(value);
893      return this;
894    }
895
896    /**
897     * @return {@link #category} (A code that classifies the procedure for searching, sorting and display purposes (e.g. "Surgical Procedure").)
898     */
899    public CodeableConcept getCategory() { 
900      if (this.category == null)
901        if (Configuration.errorOnAutoCreate())
902          throw new Error("Attempt to auto-create Procedure.category");
903        else if (Configuration.doAutoCreate())
904          this.category = new CodeableConcept(); // cc
905      return this.category;
906    }
907
908    public boolean hasCategory() { 
909      return this.category != null && !this.category.isEmpty();
910    }
911
912    /**
913     * @param value {@link #category} (A code that classifies the procedure for searching, sorting and display purposes (e.g. "Surgical Procedure").)
914     */
915    public Procedure setCategory(CodeableConcept value) { 
916      this.category = value;
917      return this;
918    }
919
920    /**
921     * @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").)
922     */
923    public CodeableConcept getCode() { 
924      if (this.code == null)
925        if (Configuration.errorOnAutoCreate())
926          throw new Error("Attempt to auto-create Procedure.code");
927        else if (Configuration.doAutoCreate())
928          this.code = new CodeableConcept(); // cc
929      return this.code;
930    }
931
932    public boolean hasCode() { 
933      return this.code != null && !this.code.isEmpty();
934    }
935
936    /**
937     * @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").)
938     */
939    public Procedure setCode(CodeableConcept value) { 
940      this.code = value;
941      return this;
942    }
943
944    /**
945     * @return {@link #notPerformed} (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 "getNotPerformed" gives direct access to the value
946     */
947    public BooleanType getNotPerformedElement() { 
948      if (this.notPerformed == null)
949        if (Configuration.errorOnAutoCreate())
950          throw new Error("Attempt to auto-create Procedure.notPerformed");
951        else if (Configuration.doAutoCreate())
952          this.notPerformed = new BooleanType(); // bb
953      return this.notPerformed;
954    }
955
956    public boolean hasNotPerformedElement() { 
957      return this.notPerformed != null && !this.notPerformed.isEmpty();
958    }
959
960    public boolean hasNotPerformed() { 
961      return this.notPerformed != null && !this.notPerformed.isEmpty();
962    }
963
964    /**
965     * @param value {@link #notPerformed} (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 "getNotPerformed" gives direct access to the value
966     */
967    public Procedure setNotPerformedElement(BooleanType value) { 
968      this.notPerformed = value;
969      return this;
970    }
971
972    /**
973     * @return Set this to true if the record is saying that the procedure was NOT performed.
974     */
975    public boolean getNotPerformed() { 
976      return this.notPerformed == null || this.notPerformed.isEmpty() ? false : this.notPerformed.getValue();
977    }
978
979    /**
980     * @param value Set this to true if the record is saying that the procedure was NOT performed.
981     */
982    public Procedure setNotPerformed(boolean value) { 
983        if (this.notPerformed == null)
984          this.notPerformed = new BooleanType();
985        this.notPerformed.setValue(value);
986      return this;
987    }
988
989    /**
990     * @return {@link #reasonNotPerformed} (A code indicating why the procedure was not performed.)
991     */
992    public List<CodeableConcept> getReasonNotPerformed() { 
993      if (this.reasonNotPerformed == null)
994        this.reasonNotPerformed = new ArrayList<CodeableConcept>();
995      return this.reasonNotPerformed;
996    }
997
998    public boolean hasReasonNotPerformed() { 
999      if (this.reasonNotPerformed == null)
1000        return false;
1001      for (CodeableConcept item : this.reasonNotPerformed)
1002        if (!item.isEmpty())
1003          return true;
1004      return false;
1005    }
1006
1007    /**
1008     * @return {@link #reasonNotPerformed} (A code indicating why the procedure was not performed.)
1009     */
1010    // syntactic sugar
1011    public CodeableConcept addReasonNotPerformed() { //3
1012      CodeableConcept t = new CodeableConcept();
1013      if (this.reasonNotPerformed == null)
1014        this.reasonNotPerformed = new ArrayList<CodeableConcept>();
1015      this.reasonNotPerformed.add(t);
1016      return t;
1017    }
1018
1019    // syntactic sugar
1020    public Procedure addReasonNotPerformed(CodeableConcept t) { //3
1021      if (t == null)
1022        return this;
1023      if (this.reasonNotPerformed == null)
1024        this.reasonNotPerformed = new ArrayList<CodeableConcept>();
1025      this.reasonNotPerformed.add(t);
1026      return this;
1027    }
1028
1029    /**
1030     * @return {@link #bodySite} (Detailed and structured anatomical location information. Multiple locations are allowed - e.g. multiple punch biopsies of a lesion.)
1031     */
1032    public List<CodeableConcept> getBodySite() { 
1033      if (this.bodySite == null)
1034        this.bodySite = new ArrayList<CodeableConcept>();
1035      return this.bodySite;
1036    }
1037
1038    public boolean hasBodySite() { 
1039      if (this.bodySite == null)
1040        return false;
1041      for (CodeableConcept item : this.bodySite)
1042        if (!item.isEmpty())
1043          return true;
1044      return false;
1045    }
1046
1047    /**
1048     * @return {@link #bodySite} (Detailed and structured anatomical location information. Multiple locations are allowed - e.g. multiple punch biopsies of a lesion.)
1049     */
1050    // syntactic sugar
1051    public CodeableConcept addBodySite() { //3
1052      CodeableConcept t = new CodeableConcept();
1053      if (this.bodySite == null)
1054        this.bodySite = new ArrayList<CodeableConcept>();
1055      this.bodySite.add(t);
1056      return t;
1057    }
1058
1059    // syntactic sugar
1060    public Procedure addBodySite(CodeableConcept t) { //3
1061      if (t == null)
1062        return this;
1063      if (this.bodySite == null)
1064        this.bodySite = new ArrayList<CodeableConcept>();
1065      this.bodySite.add(t);
1066      return this;
1067    }
1068
1069    /**
1070     * @return {@link #reason} (The reason why the procedure was performed. This may be due to a Condition, may be coded entity of some type, or may simply be present as text.)
1071     */
1072    public Type getReason() { 
1073      return this.reason;
1074    }
1075
1076    /**
1077     * @return {@link #reason} (The reason why the procedure was performed. This may be due to a Condition, may be coded entity of some type, or may simply be present as text.)
1078     */
1079    public CodeableConcept getReasonCodeableConcept() throws FHIRException { 
1080      if (!(this.reason instanceof CodeableConcept))
1081        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.reason.getClass().getName()+" was encountered");
1082      return (CodeableConcept) this.reason;
1083    }
1084
1085    public boolean hasReasonCodeableConcept() { 
1086      return this.reason instanceof CodeableConcept;
1087    }
1088
1089    /**
1090     * @return {@link #reason} (The reason why the procedure was performed. This may be due to a Condition, may be coded entity of some type, or may simply be present as text.)
1091     */
1092    public Reference getReasonReference() throws FHIRException { 
1093      if (!(this.reason instanceof Reference))
1094        throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.reason.getClass().getName()+" was encountered");
1095      return (Reference) this.reason;
1096    }
1097
1098    public boolean hasReasonReference() { 
1099      return this.reason instanceof Reference;
1100    }
1101
1102    public boolean hasReason() { 
1103      return this.reason != null && !this.reason.isEmpty();
1104    }
1105
1106    /**
1107     * @param value {@link #reason} (The reason why the procedure was performed. This may be due to a Condition, may be coded entity of some type, or may simply be present as text.)
1108     */
1109    public Procedure setReason(Type value) { 
1110      this.reason = value;
1111      return this;
1112    }
1113
1114    /**
1115     * @return {@link #performer} (Limited to 'real' people rather than equipment.)
1116     */
1117    public List<ProcedurePerformerComponent> getPerformer() { 
1118      if (this.performer == null)
1119        this.performer = new ArrayList<ProcedurePerformerComponent>();
1120      return this.performer;
1121    }
1122
1123    public boolean hasPerformer() { 
1124      if (this.performer == null)
1125        return false;
1126      for (ProcedurePerformerComponent item : this.performer)
1127        if (!item.isEmpty())
1128          return true;
1129      return false;
1130    }
1131
1132    /**
1133     * @return {@link #performer} (Limited to 'real' people rather than equipment.)
1134     */
1135    // syntactic sugar
1136    public ProcedurePerformerComponent addPerformer() { //3
1137      ProcedurePerformerComponent t = new ProcedurePerformerComponent();
1138      if (this.performer == null)
1139        this.performer = new ArrayList<ProcedurePerformerComponent>();
1140      this.performer.add(t);
1141      return t;
1142    }
1143
1144    // syntactic sugar
1145    public Procedure addPerformer(ProcedurePerformerComponent t) { //3
1146      if (t == null)
1147        return this;
1148      if (this.performer == null)
1149        this.performer = new ArrayList<ProcedurePerformerComponent>();
1150      this.performer.add(t);
1151      return this;
1152    }
1153
1154    /**
1155     * @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.)
1156     */
1157    public Type getPerformed() { 
1158      return this.performed;
1159    }
1160
1161    /**
1162     * @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.)
1163     */
1164    public DateTimeType getPerformedDateTimeType() throws FHIRException { 
1165      if (!(this.performed instanceof DateTimeType))
1166        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.performed.getClass().getName()+" was encountered");
1167      return (DateTimeType) this.performed;
1168    }
1169
1170    public boolean hasPerformedDateTimeType() { 
1171      return this.performed instanceof DateTimeType;
1172    }
1173
1174    /**
1175     * @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.)
1176     */
1177    public Period getPerformedPeriod() throws FHIRException { 
1178      if (!(this.performed instanceof Period))
1179        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.performed.getClass().getName()+" was encountered");
1180      return (Period) this.performed;
1181    }
1182
1183    public boolean hasPerformedPeriod() { 
1184      return this.performed instanceof Period;
1185    }
1186
1187    public boolean hasPerformed() { 
1188      return this.performed != null && !this.performed.isEmpty();
1189    }
1190
1191    /**
1192     * @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.)
1193     */
1194    public Procedure setPerformed(Type value) { 
1195      this.performed = value;
1196      return this;
1197    }
1198
1199    /**
1200     * @return {@link #encounter} (The encounter during which the procedure was performed.)
1201     */
1202    public Reference getEncounter() { 
1203      if (this.encounter == null)
1204        if (Configuration.errorOnAutoCreate())
1205          throw new Error("Attempt to auto-create Procedure.encounter");
1206        else if (Configuration.doAutoCreate())
1207          this.encounter = new Reference(); // cc
1208      return this.encounter;
1209    }
1210
1211    public boolean hasEncounter() { 
1212      return this.encounter != null && !this.encounter.isEmpty();
1213    }
1214
1215    /**
1216     * @param value {@link #encounter} (The encounter during which the procedure was performed.)
1217     */
1218    public Procedure setEncounter(Reference value) { 
1219      this.encounter = value;
1220      return this;
1221    }
1222
1223    /**
1224     * @return {@link #encounter} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The encounter during which the procedure was performed.)
1225     */
1226    public Encounter getEncounterTarget() { 
1227      if (this.encounterTarget == null)
1228        if (Configuration.errorOnAutoCreate())
1229          throw new Error("Attempt to auto-create Procedure.encounter");
1230        else if (Configuration.doAutoCreate())
1231          this.encounterTarget = new Encounter(); // aa
1232      return this.encounterTarget;
1233    }
1234
1235    /**
1236     * @param value {@link #encounter} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The encounter during which the procedure was performed.)
1237     */
1238    public Procedure setEncounterTarget(Encounter value) { 
1239      this.encounterTarget = value;
1240      return this;
1241    }
1242
1243    /**
1244     * @return {@link #location} (The location where the procedure actually happened.  E.g. a newborn at home, a tracheostomy at a restaurant.)
1245     */
1246    public Reference getLocation() { 
1247      if (this.location == null)
1248        if (Configuration.errorOnAutoCreate())
1249          throw new Error("Attempt to auto-create Procedure.location");
1250        else if (Configuration.doAutoCreate())
1251          this.location = new Reference(); // cc
1252      return this.location;
1253    }
1254
1255    public boolean hasLocation() { 
1256      return this.location != null && !this.location.isEmpty();
1257    }
1258
1259    /**
1260     * @param value {@link #location} (The location where the procedure actually happened.  E.g. a newborn at home, a tracheostomy at a restaurant.)
1261     */
1262    public Procedure setLocation(Reference value) { 
1263      this.location = value;
1264      return this;
1265    }
1266
1267    /**
1268     * @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.)
1269     */
1270    public Location getLocationTarget() { 
1271      if (this.locationTarget == null)
1272        if (Configuration.errorOnAutoCreate())
1273          throw new Error("Attempt to auto-create Procedure.location");
1274        else if (Configuration.doAutoCreate())
1275          this.locationTarget = new Location(); // aa
1276      return this.locationTarget;
1277    }
1278
1279    /**
1280     * @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.)
1281     */
1282    public Procedure setLocationTarget(Location value) { 
1283      this.locationTarget = value;
1284      return this;
1285    }
1286
1287    /**
1288     * @return {@link #outcome} (The outcome of the procedure - did it resolve reasons for the procedure being performed?)
1289     */
1290    public CodeableConcept getOutcome() { 
1291      if (this.outcome == null)
1292        if (Configuration.errorOnAutoCreate())
1293          throw new Error("Attempt to auto-create Procedure.outcome");
1294        else if (Configuration.doAutoCreate())
1295          this.outcome = new CodeableConcept(); // cc
1296      return this.outcome;
1297    }
1298
1299    public boolean hasOutcome() { 
1300      return this.outcome != null && !this.outcome.isEmpty();
1301    }
1302
1303    /**
1304     * @param value {@link #outcome} (The outcome of the procedure - did it resolve reasons for the procedure being performed?)
1305     */
1306    public Procedure setOutcome(CodeableConcept value) { 
1307      this.outcome = value;
1308      return this;
1309    }
1310
1311    /**
1312     * @return {@link #report} (This could be a histology result, pathology report, surgical report, etc..)
1313     */
1314    public List<Reference> getReport() { 
1315      if (this.report == null)
1316        this.report = new ArrayList<Reference>();
1317      return this.report;
1318    }
1319
1320    public boolean hasReport() { 
1321      if (this.report == null)
1322        return false;
1323      for (Reference item : this.report)
1324        if (!item.isEmpty())
1325          return true;
1326      return false;
1327    }
1328
1329    /**
1330     * @return {@link #report} (This could be a histology result, pathology report, surgical report, etc..)
1331     */
1332    // syntactic sugar
1333    public Reference addReport() { //3
1334      Reference t = new Reference();
1335      if (this.report == null)
1336        this.report = new ArrayList<Reference>();
1337      this.report.add(t);
1338      return t;
1339    }
1340
1341    // syntactic sugar
1342    public Procedure addReport(Reference t) { //3
1343      if (t == null)
1344        return this;
1345      if (this.report == null)
1346        this.report = new ArrayList<Reference>();
1347      this.report.add(t);
1348      return this;
1349    }
1350
1351    /**
1352     * @return {@link #report} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. This could be a histology result, pathology report, surgical report, etc..)
1353     */
1354    public List<DiagnosticReport> getReportTarget() { 
1355      if (this.reportTarget == null)
1356        this.reportTarget = new ArrayList<DiagnosticReport>();
1357      return this.reportTarget;
1358    }
1359
1360    // syntactic sugar
1361    /**
1362     * @return {@link #report} (Add an actual object that is the target of the reference. The reference library doesn't use these, but you can use this to hold the resources if you resolvethemt. This could be a histology result, pathology report, surgical report, etc..)
1363     */
1364    public DiagnosticReport addReportTarget() { 
1365      DiagnosticReport r = new DiagnosticReport();
1366      if (this.reportTarget == null)
1367        this.reportTarget = new ArrayList<DiagnosticReport>();
1368      this.reportTarget.add(r);
1369      return r;
1370    }
1371
1372    /**
1373     * @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.)
1374     */
1375    public List<CodeableConcept> getComplication() { 
1376      if (this.complication == null)
1377        this.complication = new ArrayList<CodeableConcept>();
1378      return this.complication;
1379    }
1380
1381    public boolean hasComplication() { 
1382      if (this.complication == null)
1383        return false;
1384      for (CodeableConcept item : this.complication)
1385        if (!item.isEmpty())
1386          return true;
1387      return false;
1388    }
1389
1390    /**
1391     * @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.)
1392     */
1393    // syntactic sugar
1394    public CodeableConcept addComplication() { //3
1395      CodeableConcept t = new CodeableConcept();
1396      if (this.complication == null)
1397        this.complication = new ArrayList<CodeableConcept>();
1398      this.complication.add(t);
1399      return t;
1400    }
1401
1402    // syntactic sugar
1403    public Procedure addComplication(CodeableConcept t) { //3
1404      if (t == null)
1405        return this;
1406      if (this.complication == null)
1407        this.complication = new ArrayList<CodeableConcept>();
1408      this.complication.add(t);
1409      return this;
1410    }
1411
1412    /**
1413     * @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.)
1414     */
1415    public List<CodeableConcept> getFollowUp() { 
1416      if (this.followUp == null)
1417        this.followUp = new ArrayList<CodeableConcept>();
1418      return this.followUp;
1419    }
1420
1421    public boolean hasFollowUp() { 
1422      if (this.followUp == null)
1423        return false;
1424      for (CodeableConcept item : this.followUp)
1425        if (!item.isEmpty())
1426          return true;
1427      return false;
1428    }
1429
1430    /**
1431     * @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.)
1432     */
1433    // syntactic sugar
1434    public CodeableConcept addFollowUp() { //3
1435      CodeableConcept t = new CodeableConcept();
1436      if (this.followUp == null)
1437        this.followUp = new ArrayList<CodeableConcept>();
1438      this.followUp.add(t);
1439      return t;
1440    }
1441
1442    // syntactic sugar
1443    public Procedure addFollowUp(CodeableConcept t) { //3
1444      if (t == null)
1445        return this;
1446      if (this.followUp == null)
1447        this.followUp = new ArrayList<CodeableConcept>();
1448      this.followUp.add(t);
1449      return this;
1450    }
1451
1452    /**
1453     * @return {@link #request} (A reference to a resource that contains details of the request for this procedure.)
1454     */
1455    public Reference getRequest() { 
1456      if (this.request == null)
1457        if (Configuration.errorOnAutoCreate())
1458          throw new Error("Attempt to auto-create Procedure.request");
1459        else if (Configuration.doAutoCreate())
1460          this.request = new Reference(); // cc
1461      return this.request;
1462    }
1463
1464    public boolean hasRequest() { 
1465      return this.request != null && !this.request.isEmpty();
1466    }
1467
1468    /**
1469     * @param value {@link #request} (A reference to a resource that contains details of the request for this procedure.)
1470     */
1471    public Procedure setRequest(Reference value) { 
1472      this.request = value;
1473      return this;
1474    }
1475
1476    /**
1477     * @return {@link #request} 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. (A reference to a resource that contains details of the request for this procedure.)
1478     */
1479    public Resource getRequestTarget() { 
1480      return this.requestTarget;
1481    }
1482
1483    /**
1484     * @param value {@link #request} 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. (A reference to a resource that contains details of the request for this procedure.)
1485     */
1486    public Procedure setRequestTarget(Resource value) { 
1487      this.requestTarget = value;
1488      return this;
1489    }
1490
1491    /**
1492     * @return {@link #notes} (Any other notes about the procedure.  E.g. the operative notes.)
1493     */
1494    public List<Annotation> getNotes() { 
1495      if (this.notes == null)
1496        this.notes = new ArrayList<Annotation>();
1497      return this.notes;
1498    }
1499
1500    public boolean hasNotes() { 
1501      if (this.notes == null)
1502        return false;
1503      for (Annotation item : this.notes)
1504        if (!item.isEmpty())
1505          return true;
1506      return false;
1507    }
1508
1509    /**
1510     * @return {@link #notes} (Any other notes about the procedure.  E.g. the operative notes.)
1511     */
1512    // syntactic sugar
1513    public Annotation addNotes() { //3
1514      Annotation t = new Annotation();
1515      if (this.notes == null)
1516        this.notes = new ArrayList<Annotation>();
1517      this.notes.add(t);
1518      return t;
1519    }
1520
1521    // syntactic sugar
1522    public Procedure addNotes(Annotation t) { //3
1523      if (t == null)
1524        return this;
1525      if (this.notes == null)
1526        this.notes = new ArrayList<Annotation>();
1527      this.notes.add(t);
1528      return this;
1529    }
1530
1531    /**
1532     * @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.)
1533     */
1534    public List<ProcedureFocalDeviceComponent> getFocalDevice() { 
1535      if (this.focalDevice == null)
1536        this.focalDevice = new ArrayList<ProcedureFocalDeviceComponent>();
1537      return this.focalDevice;
1538    }
1539
1540    public boolean hasFocalDevice() { 
1541      if (this.focalDevice == null)
1542        return false;
1543      for (ProcedureFocalDeviceComponent item : this.focalDevice)
1544        if (!item.isEmpty())
1545          return true;
1546      return false;
1547    }
1548
1549    /**
1550     * @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.)
1551     */
1552    // syntactic sugar
1553    public ProcedureFocalDeviceComponent addFocalDevice() { //3
1554      ProcedureFocalDeviceComponent t = new ProcedureFocalDeviceComponent();
1555      if (this.focalDevice == null)
1556        this.focalDevice = new ArrayList<ProcedureFocalDeviceComponent>();
1557      this.focalDevice.add(t);
1558      return t;
1559    }
1560
1561    // syntactic sugar
1562    public Procedure addFocalDevice(ProcedureFocalDeviceComponent t) { //3
1563      if (t == null)
1564        return this;
1565      if (this.focalDevice == null)
1566        this.focalDevice = new ArrayList<ProcedureFocalDeviceComponent>();
1567      this.focalDevice.add(t);
1568      return this;
1569    }
1570
1571    /**
1572     * @return {@link #used} (Identifies medications, devices and any other substance used as part of the procedure.)
1573     */
1574    public List<Reference> getUsed() { 
1575      if (this.used == null)
1576        this.used = new ArrayList<Reference>();
1577      return this.used;
1578    }
1579
1580    public boolean hasUsed() { 
1581      if (this.used == null)
1582        return false;
1583      for (Reference item : this.used)
1584        if (!item.isEmpty())
1585          return true;
1586      return false;
1587    }
1588
1589    /**
1590     * @return {@link #used} (Identifies medications, devices and any other substance used as part of the procedure.)
1591     */
1592    // syntactic sugar
1593    public Reference addUsed() { //3
1594      Reference t = new Reference();
1595      if (this.used == null)
1596        this.used = new ArrayList<Reference>();
1597      this.used.add(t);
1598      return t;
1599    }
1600
1601    // syntactic sugar
1602    public Procedure addUsed(Reference t) { //3
1603      if (t == null)
1604        return this;
1605      if (this.used == null)
1606        this.used = new ArrayList<Reference>();
1607      this.used.add(t);
1608      return this;
1609    }
1610
1611    /**
1612     * @return {@link #used} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. Identifies medications, devices and any other substance used as part of the procedure.)
1613     */
1614    public List<Resource> getUsedTarget() { 
1615      if (this.usedTarget == null)
1616        this.usedTarget = new ArrayList<Resource>();
1617      return this.usedTarget;
1618    }
1619
1620      protected void listChildren(List<Property> childrenList) {
1621        super.listChildren(childrenList);
1622        childrenList.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));
1623        childrenList.add(new Property("subject", "Reference(Patient|Group)", "The person, animal or group on which the procedure was performed.", 0, java.lang.Integer.MAX_VALUE, subject));
1624        childrenList.add(new Property("status", "code", "A code specifying the state of the procedure. Generally this will be in-progress or completed state.", 0, java.lang.Integer.MAX_VALUE, status));
1625        childrenList.add(new Property("category", "CodeableConcept", "A code that classifies the procedure for searching, sorting and display purposes (e.g. \"Surgical Procedure\").", 0, java.lang.Integer.MAX_VALUE, category));
1626        childrenList.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, java.lang.Integer.MAX_VALUE, code));
1627        childrenList.add(new Property("notPerformed", "boolean", "Set this to true if the record is saying that the procedure was NOT performed.", 0, java.lang.Integer.MAX_VALUE, notPerformed));
1628        childrenList.add(new Property("reasonNotPerformed", "CodeableConcept", "A code indicating why the procedure was not performed.", 0, java.lang.Integer.MAX_VALUE, reasonNotPerformed));
1629        childrenList.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));
1630        childrenList.add(new Property("reason[x]", "CodeableConcept|Reference(Condition)", "The reason why the procedure was performed. This may be due to a Condition, may be coded entity of some type, or may simply be present as text.", 0, java.lang.Integer.MAX_VALUE, reason));
1631        childrenList.add(new Property("performer", "", "Limited to 'real' people rather than equipment.", 0, java.lang.Integer.MAX_VALUE, performer));
1632        childrenList.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, java.lang.Integer.MAX_VALUE, performed));
1633        childrenList.add(new Property("encounter", "Reference(Encounter)", "The encounter during which the procedure was performed.", 0, java.lang.Integer.MAX_VALUE, encounter));
1634        childrenList.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, java.lang.Integer.MAX_VALUE, location));
1635        childrenList.add(new Property("outcome", "CodeableConcept", "The outcome of the procedure - did it resolve reasons for the procedure being performed?", 0, java.lang.Integer.MAX_VALUE, outcome));
1636        childrenList.add(new Property("report", "Reference(DiagnosticReport)", "This could be a histology result, pathology report, surgical report, etc..", 0, java.lang.Integer.MAX_VALUE, report));
1637        childrenList.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));
1638        childrenList.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));
1639        childrenList.add(new Property("request", "Reference(CarePlan|DiagnosticOrder|ProcedureRequest|ReferralRequest)", "A reference to a resource that contains details of the request for this procedure.", 0, java.lang.Integer.MAX_VALUE, request));
1640        childrenList.add(new Property("notes", "Annotation", "Any other notes about the procedure.  E.g. the operative notes.", 0, java.lang.Integer.MAX_VALUE, notes));
1641        childrenList.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));
1642        childrenList.add(new Property("used", "Reference(Device|Medication|Substance)", "Identifies medications, devices and any other substance used as part of the procedure.", 0, java.lang.Integer.MAX_VALUE, used));
1643      }
1644
1645      @Override
1646      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1647        switch (hash) {
1648        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1649        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
1650        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<ProcedureStatus>
1651        case 50511102: /*category*/ return this.category == null ? new Base[0] : new Base[] {this.category}; // CodeableConcept
1652        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept
1653        case 585470509: /*notPerformed*/ return this.notPerformed == null ? new Base[0] : new Base[] {this.notPerformed}; // BooleanType
1654        case -906415471: /*reasonNotPerformed*/ return this.reasonNotPerformed == null ? new Base[0] : this.reasonNotPerformed.toArray(new Base[this.reasonNotPerformed.size()]); // CodeableConcept
1655        case 1702620169: /*bodySite*/ return this.bodySite == null ? new Base[0] : this.bodySite.toArray(new Base[this.bodySite.size()]); // CodeableConcept
1656        case -934964668: /*reason*/ return this.reason == null ? new Base[0] : new Base[] {this.reason}; // Type
1657        case 481140686: /*performer*/ return this.performer == null ? new Base[0] : this.performer.toArray(new Base[this.performer.size()]); // ProcedurePerformerComponent
1658        case 481140672: /*performed*/ return this.performed == null ? new Base[0] : new Base[] {this.performed}; // Type
1659        case 1524132147: /*encounter*/ return this.encounter == null ? new Base[0] : new Base[] {this.encounter}; // Reference
1660        case 1901043637: /*location*/ return this.location == null ? new Base[0] : new Base[] {this.location}; // Reference
1661        case -1106507950: /*outcome*/ return this.outcome == null ? new Base[0] : new Base[] {this.outcome}; // CodeableConcept
1662        case -934521548: /*report*/ return this.report == null ? new Base[0] : this.report.toArray(new Base[this.report.size()]); // Reference
1663        case -1644401602: /*complication*/ return this.complication == null ? new Base[0] : this.complication.toArray(new Base[this.complication.size()]); // CodeableConcept
1664        case 301801004: /*followUp*/ return this.followUp == null ? new Base[0] : this.followUp.toArray(new Base[this.followUp.size()]); // CodeableConcept
1665        case 1095692943: /*request*/ return this.request == null ? new Base[0] : new Base[] {this.request}; // Reference
1666        case 105008833: /*notes*/ return this.notes == null ? new Base[0] : this.notes.toArray(new Base[this.notes.size()]); // Annotation
1667        case -1129235173: /*focalDevice*/ return this.focalDevice == null ? new Base[0] : this.focalDevice.toArray(new Base[this.focalDevice.size()]); // ProcedureFocalDeviceComponent
1668        case 3599293: /*used*/ return this.used == null ? new Base[0] : this.used.toArray(new Base[this.used.size()]); // Reference
1669        default: return super.getProperty(hash, name, checkValid);
1670        }
1671
1672      }
1673
1674      @Override
1675      public void setProperty(int hash, String name, Base value) throws FHIRException {
1676        switch (hash) {
1677        case -1618432855: // identifier
1678          this.getIdentifier().add(castToIdentifier(value)); // Identifier
1679          break;
1680        case -1867885268: // subject
1681          this.subject = castToReference(value); // Reference
1682          break;
1683        case -892481550: // status
1684          this.status = new ProcedureStatusEnumFactory().fromType(value); // Enumeration<ProcedureStatus>
1685          break;
1686        case 50511102: // category
1687          this.category = castToCodeableConcept(value); // CodeableConcept
1688          break;
1689        case 3059181: // code
1690          this.code = castToCodeableConcept(value); // CodeableConcept
1691          break;
1692        case 585470509: // notPerformed
1693          this.notPerformed = castToBoolean(value); // BooleanType
1694          break;
1695        case -906415471: // reasonNotPerformed
1696          this.getReasonNotPerformed().add(castToCodeableConcept(value)); // CodeableConcept
1697          break;
1698        case 1702620169: // bodySite
1699          this.getBodySite().add(castToCodeableConcept(value)); // CodeableConcept
1700          break;
1701        case -934964668: // reason
1702          this.reason = (Type) value; // Type
1703          break;
1704        case 481140686: // performer
1705          this.getPerformer().add((ProcedurePerformerComponent) value); // ProcedurePerformerComponent
1706          break;
1707        case 481140672: // performed
1708          this.performed = (Type) value; // Type
1709          break;
1710        case 1524132147: // encounter
1711          this.encounter = castToReference(value); // Reference
1712          break;
1713        case 1901043637: // location
1714          this.location = castToReference(value); // Reference
1715          break;
1716        case -1106507950: // outcome
1717          this.outcome = castToCodeableConcept(value); // CodeableConcept
1718          break;
1719        case -934521548: // report
1720          this.getReport().add(castToReference(value)); // Reference
1721          break;
1722        case -1644401602: // complication
1723          this.getComplication().add(castToCodeableConcept(value)); // CodeableConcept
1724          break;
1725        case 301801004: // followUp
1726          this.getFollowUp().add(castToCodeableConcept(value)); // CodeableConcept
1727          break;
1728        case 1095692943: // request
1729          this.request = castToReference(value); // Reference
1730          break;
1731        case 105008833: // notes
1732          this.getNotes().add(castToAnnotation(value)); // Annotation
1733          break;
1734        case -1129235173: // focalDevice
1735          this.getFocalDevice().add((ProcedureFocalDeviceComponent) value); // ProcedureFocalDeviceComponent
1736          break;
1737        case 3599293: // used
1738          this.getUsed().add(castToReference(value)); // Reference
1739          break;
1740        default: super.setProperty(hash, name, value);
1741        }
1742
1743      }
1744
1745      @Override
1746      public void setProperty(String name, Base value) throws FHIRException {
1747        if (name.equals("identifier"))
1748          this.getIdentifier().add(castToIdentifier(value));
1749        else if (name.equals("subject"))
1750          this.subject = castToReference(value); // Reference
1751        else if (name.equals("status"))
1752          this.status = new ProcedureStatusEnumFactory().fromType(value); // Enumeration<ProcedureStatus>
1753        else if (name.equals("category"))
1754          this.category = castToCodeableConcept(value); // CodeableConcept
1755        else if (name.equals("code"))
1756          this.code = castToCodeableConcept(value); // CodeableConcept
1757        else if (name.equals("notPerformed"))
1758          this.notPerformed = castToBoolean(value); // BooleanType
1759        else if (name.equals("reasonNotPerformed"))
1760          this.getReasonNotPerformed().add(castToCodeableConcept(value));
1761        else if (name.equals("bodySite"))
1762          this.getBodySite().add(castToCodeableConcept(value));
1763        else if (name.equals("reason[x]"))
1764          this.reason = (Type) value; // Type
1765        else if (name.equals("performer"))
1766          this.getPerformer().add((ProcedurePerformerComponent) value);
1767        else if (name.equals("performed[x]"))
1768          this.performed = (Type) value; // Type
1769        else if (name.equals("encounter"))
1770          this.encounter = castToReference(value); // Reference
1771        else if (name.equals("location"))
1772          this.location = castToReference(value); // Reference
1773        else if (name.equals("outcome"))
1774          this.outcome = castToCodeableConcept(value); // CodeableConcept
1775        else if (name.equals("report"))
1776          this.getReport().add(castToReference(value));
1777        else if (name.equals("complication"))
1778          this.getComplication().add(castToCodeableConcept(value));
1779        else if (name.equals("followUp"))
1780          this.getFollowUp().add(castToCodeableConcept(value));
1781        else if (name.equals("request"))
1782          this.request = castToReference(value); // Reference
1783        else if (name.equals("notes"))
1784          this.getNotes().add(castToAnnotation(value));
1785        else if (name.equals("focalDevice"))
1786          this.getFocalDevice().add((ProcedureFocalDeviceComponent) value);
1787        else if (name.equals("used"))
1788          this.getUsed().add(castToReference(value));
1789        else
1790          super.setProperty(name, value);
1791      }
1792
1793      @Override
1794      public Base makeProperty(int hash, String name) throws FHIRException {
1795        switch (hash) {
1796        case -1618432855:  return addIdentifier(); // Identifier
1797        case -1867885268:  return getSubject(); // Reference
1798        case -892481550: throw new FHIRException("Cannot make property status as it is not a complex type"); // Enumeration<ProcedureStatus>
1799        case 50511102:  return getCategory(); // CodeableConcept
1800        case 3059181:  return getCode(); // CodeableConcept
1801        case 585470509: throw new FHIRException("Cannot make property notPerformed as it is not a complex type"); // BooleanType
1802        case -906415471:  return addReasonNotPerformed(); // CodeableConcept
1803        case 1702620169:  return addBodySite(); // CodeableConcept
1804        case -669418564:  return getReason(); // Type
1805        case 481140686:  return addPerformer(); // ProcedurePerformerComponent
1806        case 1355984064:  return getPerformed(); // Type
1807        case 1524132147:  return getEncounter(); // Reference
1808        case 1901043637:  return getLocation(); // Reference
1809        case -1106507950:  return getOutcome(); // CodeableConcept
1810        case -934521548:  return addReport(); // Reference
1811        case -1644401602:  return addComplication(); // CodeableConcept
1812        case 301801004:  return addFollowUp(); // CodeableConcept
1813        case 1095692943:  return getRequest(); // Reference
1814        case 105008833:  return addNotes(); // Annotation
1815        case -1129235173:  return addFocalDevice(); // ProcedureFocalDeviceComponent
1816        case 3599293:  return addUsed(); // Reference
1817        default: return super.makeProperty(hash, name);
1818        }
1819
1820      }
1821
1822      @Override
1823      public Base addChild(String name) throws FHIRException {
1824        if (name.equals("identifier")) {
1825          return addIdentifier();
1826        }
1827        else if (name.equals("subject")) {
1828          this.subject = new Reference();
1829          return this.subject;
1830        }
1831        else if (name.equals("status")) {
1832          throw new FHIRException("Cannot call addChild on a primitive type Procedure.status");
1833        }
1834        else if (name.equals("category")) {
1835          this.category = new CodeableConcept();
1836          return this.category;
1837        }
1838        else if (name.equals("code")) {
1839          this.code = new CodeableConcept();
1840          return this.code;
1841        }
1842        else if (name.equals("notPerformed")) {
1843          throw new FHIRException("Cannot call addChild on a primitive type Procedure.notPerformed");
1844        }
1845        else if (name.equals("reasonNotPerformed")) {
1846          return addReasonNotPerformed();
1847        }
1848        else if (name.equals("bodySite")) {
1849          return addBodySite();
1850        }
1851        else if (name.equals("reasonCodeableConcept")) {
1852          this.reason = new CodeableConcept();
1853          return this.reason;
1854        }
1855        else if (name.equals("reasonReference")) {
1856          this.reason = new Reference();
1857          return this.reason;
1858        }
1859        else if (name.equals("performer")) {
1860          return addPerformer();
1861        }
1862        else if (name.equals("performedDateTime")) {
1863          this.performed = new DateTimeType();
1864          return this.performed;
1865        }
1866        else if (name.equals("performedPeriod")) {
1867          this.performed = new Period();
1868          return this.performed;
1869        }
1870        else if (name.equals("encounter")) {
1871          this.encounter = new Reference();
1872          return this.encounter;
1873        }
1874        else if (name.equals("location")) {
1875          this.location = new Reference();
1876          return this.location;
1877        }
1878        else if (name.equals("outcome")) {
1879          this.outcome = new CodeableConcept();
1880          return this.outcome;
1881        }
1882        else if (name.equals("report")) {
1883          return addReport();
1884        }
1885        else if (name.equals("complication")) {
1886          return addComplication();
1887        }
1888        else if (name.equals("followUp")) {
1889          return addFollowUp();
1890        }
1891        else if (name.equals("request")) {
1892          this.request = new Reference();
1893          return this.request;
1894        }
1895        else if (name.equals("notes")) {
1896          return addNotes();
1897        }
1898        else if (name.equals("focalDevice")) {
1899          return addFocalDevice();
1900        }
1901        else if (name.equals("used")) {
1902          return addUsed();
1903        }
1904        else
1905          return super.addChild(name);
1906      }
1907
1908  public String fhirType() {
1909    return "Procedure";
1910
1911  }
1912
1913      public Procedure copy() {
1914        Procedure dst = new Procedure();
1915        copyValues(dst);
1916        if (identifier != null) {
1917          dst.identifier = new ArrayList<Identifier>();
1918          for (Identifier i : identifier)
1919            dst.identifier.add(i.copy());
1920        };
1921        dst.subject = subject == null ? null : subject.copy();
1922        dst.status = status == null ? null : status.copy();
1923        dst.category = category == null ? null : category.copy();
1924        dst.code = code == null ? null : code.copy();
1925        dst.notPerformed = notPerformed == null ? null : notPerformed.copy();
1926        if (reasonNotPerformed != null) {
1927          dst.reasonNotPerformed = new ArrayList<CodeableConcept>();
1928          for (CodeableConcept i : reasonNotPerformed)
1929            dst.reasonNotPerformed.add(i.copy());
1930        };
1931        if (bodySite != null) {
1932          dst.bodySite = new ArrayList<CodeableConcept>();
1933          for (CodeableConcept i : bodySite)
1934            dst.bodySite.add(i.copy());
1935        };
1936        dst.reason = reason == null ? null : reason.copy();
1937        if (performer != null) {
1938          dst.performer = new ArrayList<ProcedurePerformerComponent>();
1939          for (ProcedurePerformerComponent i : performer)
1940            dst.performer.add(i.copy());
1941        };
1942        dst.performed = performed == null ? null : performed.copy();
1943        dst.encounter = encounter == null ? null : encounter.copy();
1944        dst.location = location == null ? null : location.copy();
1945        dst.outcome = outcome == null ? null : outcome.copy();
1946        if (report != null) {
1947          dst.report = new ArrayList<Reference>();
1948          for (Reference i : report)
1949            dst.report.add(i.copy());
1950        };
1951        if (complication != null) {
1952          dst.complication = new ArrayList<CodeableConcept>();
1953          for (CodeableConcept i : complication)
1954            dst.complication.add(i.copy());
1955        };
1956        if (followUp != null) {
1957          dst.followUp = new ArrayList<CodeableConcept>();
1958          for (CodeableConcept i : followUp)
1959            dst.followUp.add(i.copy());
1960        };
1961        dst.request = request == null ? null : request.copy();
1962        if (notes != null) {
1963          dst.notes = new ArrayList<Annotation>();
1964          for (Annotation i : notes)
1965            dst.notes.add(i.copy());
1966        };
1967        if (focalDevice != null) {
1968          dst.focalDevice = new ArrayList<ProcedureFocalDeviceComponent>();
1969          for (ProcedureFocalDeviceComponent i : focalDevice)
1970            dst.focalDevice.add(i.copy());
1971        };
1972        if (used != null) {
1973          dst.used = new ArrayList<Reference>();
1974          for (Reference i : used)
1975            dst.used.add(i.copy());
1976        };
1977        return dst;
1978      }
1979
1980      protected Procedure typedCopy() {
1981        return copy();
1982      }
1983
1984      @Override
1985      public boolean equalsDeep(Base other) {
1986        if (!super.equalsDeep(other))
1987          return false;
1988        if (!(other instanceof Procedure))
1989          return false;
1990        Procedure o = (Procedure) other;
1991        return compareDeep(identifier, o.identifier, true) && compareDeep(subject, o.subject, true) && compareDeep(status, o.status, true)
1992           && compareDeep(category, o.category, true) && compareDeep(code, o.code, true) && compareDeep(notPerformed, o.notPerformed, true)
1993           && compareDeep(reasonNotPerformed, o.reasonNotPerformed, true) && compareDeep(bodySite, o.bodySite, true)
1994           && compareDeep(reason, o.reason, true) && compareDeep(performer, o.performer, true) && compareDeep(performed, o.performed, true)
1995           && compareDeep(encounter, o.encounter, true) && compareDeep(location, o.location, true) && compareDeep(outcome, o.outcome, true)
1996           && compareDeep(report, o.report, true) && compareDeep(complication, o.complication, true) && compareDeep(followUp, o.followUp, true)
1997           && compareDeep(request, o.request, true) && compareDeep(notes, o.notes, true) && compareDeep(focalDevice, o.focalDevice, true)
1998           && compareDeep(used, o.used, true);
1999      }
2000
2001      @Override
2002      public boolean equalsShallow(Base other) {
2003        if (!super.equalsShallow(other))
2004          return false;
2005        if (!(other instanceof Procedure))
2006          return false;
2007        Procedure o = (Procedure) other;
2008        return compareValues(status, o.status, true) && compareValues(notPerformed, o.notPerformed, true);
2009      }
2010
2011      public boolean isEmpty() {
2012        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (subject == null || subject.isEmpty())
2013           && (status == null || status.isEmpty()) && (category == null || category.isEmpty()) && (code == null || code.isEmpty())
2014           && (notPerformed == null || notPerformed.isEmpty()) && (reasonNotPerformed == null || reasonNotPerformed.isEmpty())
2015           && (bodySite == null || bodySite.isEmpty()) && (reason == null || reason.isEmpty()) && (performer == null || performer.isEmpty())
2016           && (performed == null || performed.isEmpty()) && (encounter == null || encounter.isEmpty())
2017           && (location == null || location.isEmpty()) && (outcome == null || outcome.isEmpty()) && (report == null || report.isEmpty())
2018           && (complication == null || complication.isEmpty()) && (followUp == null || followUp.isEmpty())
2019           && (request == null || request.isEmpty()) && (notes == null || notes.isEmpty()) && (focalDevice == null || focalDevice.isEmpty())
2020           && (used == null || used.isEmpty());
2021      }
2022
2023  @Override
2024  public ResourceType getResourceType() {
2025    return ResourceType.Procedure;
2026   }
2027
2028 /**
2029   * Search parameter: <b>patient</b>
2030   * <p>
2031   * Description: <b>Search by subject - a patient</b><br>
2032   * Type: <b>reference</b><br>
2033   * Path: <b>Procedure.subject</b><br>
2034   * </p>
2035   */
2036  @SearchParamDefinition(name="patient", path="Procedure.subject", description="Search by subject - a patient", type="reference" )
2037  public static final String SP_PATIENT = "patient";
2038 /**
2039   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
2040   * <p>
2041   * Description: <b>Search by subject - a patient</b><br>
2042   * Type: <b>reference</b><br>
2043   * Path: <b>Procedure.subject</b><br>
2044   * </p>
2045   */
2046  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
2047
2048/**
2049   * Constant for fluent queries to be used to add include statements. Specifies
2050   * the path value of "<b>Procedure:patient</b>".
2051   */
2052  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("Procedure:patient").toLocked();
2053
2054 /**
2055   * Search parameter: <b>location</b>
2056   * <p>
2057   * Description: <b>Where the procedure happened</b><br>
2058   * Type: <b>reference</b><br>
2059   * Path: <b>Procedure.location</b><br>
2060   * </p>
2061   */
2062  @SearchParamDefinition(name="location", path="Procedure.location", description="Where the procedure happened", type="reference" )
2063  public static final String SP_LOCATION = "location";
2064 /**
2065   * <b>Fluent Client</b> search parameter constant for <b>location</b>
2066   * <p>
2067   * Description: <b>Where the procedure happened</b><br>
2068   * Type: <b>reference</b><br>
2069   * Path: <b>Procedure.location</b><br>
2070   * </p>
2071   */
2072  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam LOCATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_LOCATION);
2073
2074/**
2075   * Constant for fluent queries to be used to add include statements. Specifies
2076   * the path value of "<b>Procedure:location</b>".
2077   */
2078  public static final ca.uhn.fhir.model.api.Include INCLUDE_LOCATION = new ca.uhn.fhir.model.api.Include("Procedure:location").toLocked();
2079
2080 /**
2081   * Search parameter: <b>subject</b>
2082   * <p>
2083   * Description: <b>Search by subject</b><br>
2084   * Type: <b>reference</b><br>
2085   * Path: <b>Procedure.subject</b><br>
2086   * </p>
2087   */
2088  @SearchParamDefinition(name="subject", path="Procedure.subject", description="Search by subject", type="reference" )
2089  public static final String SP_SUBJECT = "subject";
2090 /**
2091   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
2092   * <p>
2093   * Description: <b>Search by subject</b><br>
2094   * Type: <b>reference</b><br>
2095   * Path: <b>Procedure.subject</b><br>
2096   * </p>
2097   */
2098  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
2099
2100/**
2101   * Constant for fluent queries to be used to add include statements. Specifies
2102   * the path value of "<b>Procedure:subject</b>".
2103   */
2104  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("Procedure:subject").toLocked();
2105
2106 /**
2107   * Search parameter: <b>performer</b>
2108   * <p>
2109   * Description: <b>The reference to the practitioner</b><br>
2110   * Type: <b>reference</b><br>
2111   * Path: <b>Procedure.performer.actor</b><br>
2112   * </p>
2113   */
2114  @SearchParamDefinition(name="performer", path="Procedure.performer.actor", description="The reference to the practitioner", type="reference" )
2115  public static final String SP_PERFORMER = "performer";
2116 /**
2117   * <b>Fluent Client</b> search parameter constant for <b>performer</b>
2118   * <p>
2119   * Description: <b>The reference to the practitioner</b><br>
2120   * Type: <b>reference</b><br>
2121   * Path: <b>Procedure.performer.actor</b><br>
2122   * </p>
2123   */
2124  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PERFORMER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PERFORMER);
2125
2126/**
2127   * Constant for fluent queries to be used to add include statements. Specifies
2128   * the path value of "<b>Procedure:performer</b>".
2129   */
2130  public static final ca.uhn.fhir.model.api.Include INCLUDE_PERFORMER = new ca.uhn.fhir.model.api.Include("Procedure:performer").toLocked();
2131
2132 /**
2133   * Search parameter: <b>encounter</b>
2134   * <p>
2135   * Description: <b>The encounter associated with the procedure</b><br>
2136   * Type: <b>reference</b><br>
2137   * Path: <b>Procedure.encounter</b><br>
2138   * </p>
2139   */
2140  @SearchParamDefinition(name="encounter", path="Procedure.encounter", description="The encounter associated with the procedure", type="reference" )
2141  public static final String SP_ENCOUNTER = "encounter";
2142 /**
2143   * <b>Fluent Client</b> search parameter constant for <b>encounter</b>
2144   * <p>
2145   * Description: <b>The encounter associated with the procedure</b><br>
2146   * Type: <b>reference</b><br>
2147   * Path: <b>Procedure.encounter</b><br>
2148   * </p>
2149   */
2150  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENCOUNTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENCOUNTER);
2151
2152/**
2153   * Constant for fluent queries to be used to add include statements. Specifies
2154   * the path value of "<b>Procedure:encounter</b>".
2155   */
2156  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENCOUNTER = new ca.uhn.fhir.model.api.Include("Procedure:encounter").toLocked();
2157
2158 /**
2159   * Search parameter: <b>code</b>
2160   * <p>
2161   * Description: <b>A code to identify a  procedure</b><br>
2162   * Type: <b>token</b><br>
2163   * Path: <b>Procedure.code</b><br>
2164   * </p>
2165   */
2166  @SearchParamDefinition(name="code", path="Procedure.code", description="A code to identify a  procedure", type="token" )
2167  public static final String SP_CODE = "code";
2168 /**
2169   * <b>Fluent Client</b> search parameter constant for <b>code</b>
2170   * <p>
2171   * Description: <b>A code to identify a  procedure</b><br>
2172   * Type: <b>token</b><br>
2173   * Path: <b>Procedure.code</b><br>
2174   * </p>
2175   */
2176  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CODE);
2177
2178 /**
2179   * Search parameter: <b>date</b>
2180   * <p>
2181   * Description: <b>Date/Period the procedure was performed</b><br>
2182   * Type: <b>date</b><br>
2183   * Path: <b>Procedure.performed[x]</b><br>
2184   * </p>
2185   */
2186  @SearchParamDefinition(name="date", path="Procedure.performed", description="Date/Period the procedure was performed", type="date" )
2187  public static final String SP_DATE = "date";
2188 /**
2189   * <b>Fluent Client</b> search parameter constant for <b>date</b>
2190   * <p>
2191   * Description: <b>Date/Period the procedure was performed</b><br>
2192   * Type: <b>date</b><br>
2193   * Path: <b>Procedure.performed[x]</b><br>
2194   * </p>
2195   */
2196  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATE);
2197
2198 /**
2199   * Search parameter: <b>identifier</b>
2200   * <p>
2201   * Description: <b>A unique identifier for a procedure</b><br>
2202   * Type: <b>token</b><br>
2203   * Path: <b>Procedure.identifier</b><br>
2204   * </p>
2205   */
2206  @SearchParamDefinition(name="identifier", path="Procedure.identifier", description="A unique identifier for a procedure", type="token" )
2207  public static final String SP_IDENTIFIER = "identifier";
2208 /**
2209   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
2210   * <p>
2211   * Description: <b>A unique identifier for a procedure</b><br>
2212   * Type: <b>token</b><br>
2213   * Path: <b>Procedure.identifier</b><br>
2214   * </p>
2215   */
2216  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
2217
2218
2219}
2220