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