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