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