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