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