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