001package org.hl7.fhir.instance.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
033import java.util.*;
034
035import org.hl7.fhir.exceptions.FHIRException;
036import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
037import org.hl7.fhir.utilities.Utilities;
038
039import ca.uhn.fhir.model.api.annotation.*;
040/**
041 * A set of healthcare-related information that is assembled together into a single logical document that provides a single coherent statement of meaning, establishes its own context and that has clinical attestation with regard to who is making the statement. While a Composition defines the structure, it does not actually contain the content: rather the full content of a document is contained in a Bundle, of which the Composition is the first resource contained.
042 */
043@ResourceDef(name="Composition", profile="http://hl7.org/fhir/Profile/Composition")
044public class Composition extends DomainResource {
045
046    public enum CompositionStatus {
047        /**
048         * This is a preliminary composition or document (also known as initial or interim). The content may be incomplete or unverified.
049         */
050        PRELIMINARY, 
051        /**
052         * This version of the composition is complete and verified by an appropriate person and no further work is planned. Any subsequent updates would be on a new version of the composition.
053         */
054        FINAL, 
055        /**
056         * The composition content or the referenced resources have been modified (edited or added to) subsequent to being released as "final" and the composition is complete and verified by an authorized person.
057         */
058        AMENDED, 
059        /**
060         * The composition or document was originally created/issued in error, and this is an amendment that marks that the entire series should not be considered as valid.
061         */
062        ENTEREDINERROR, 
063        /**
064         * added to help the parsers
065         */
066        NULL;
067        public static CompositionStatus fromCode(String codeString) throws FHIRException {
068            if (codeString == null || "".equals(codeString))
069                return null;
070        if ("preliminary".equals(codeString))
071          return PRELIMINARY;
072        if ("final".equals(codeString))
073          return FINAL;
074        if ("amended".equals(codeString))
075          return AMENDED;
076        if ("entered-in-error".equals(codeString))
077          return ENTEREDINERROR;
078        throw new FHIRException("Unknown CompositionStatus code '"+codeString+"'");
079        }
080        public String toCode() {
081          switch (this) {
082            case PRELIMINARY: return "preliminary";
083            case FINAL: return "final";
084            case AMENDED: return "amended";
085            case ENTEREDINERROR: return "entered-in-error";
086            default: return "?";
087          }
088        }
089        public String getSystem() {
090          switch (this) {
091            case PRELIMINARY: return "http://hl7.org/fhir/composition-status";
092            case FINAL: return "http://hl7.org/fhir/composition-status";
093            case AMENDED: return "http://hl7.org/fhir/composition-status";
094            case ENTEREDINERROR: return "http://hl7.org/fhir/composition-status";
095            default: return "?";
096          }
097        }
098        public String getDefinition() {
099          switch (this) {
100            case PRELIMINARY: return "This is a preliminary composition or document (also known as initial or interim). The content may be incomplete or unverified.";
101            case FINAL: return "This version of the composition is complete and verified by an appropriate person and no further work is planned. Any subsequent updates would be on a new version of the composition.";
102            case AMENDED: return "The composition content or the referenced resources have been modified (edited or added to) subsequent to being released as \"final\" and the composition is complete and verified by an authorized person.";
103            case ENTEREDINERROR: return "The composition or document was originally created/issued in error, and this is an amendment that marks that the entire series should not be considered as valid.";
104            default: return "?";
105          }
106        }
107        public String getDisplay() {
108          switch (this) {
109            case PRELIMINARY: return "Preliminary";
110            case FINAL: return "Final";
111            case AMENDED: return "Amended";
112            case ENTEREDINERROR: return "Entered in Error";
113            default: return "?";
114          }
115        }
116    }
117
118  public static class CompositionStatusEnumFactory implements EnumFactory<CompositionStatus> {
119    public CompositionStatus fromCode(String codeString) throws IllegalArgumentException {
120      if (codeString == null || "".equals(codeString))
121            if (codeString == null || "".equals(codeString))
122                return null;
123        if ("preliminary".equals(codeString))
124          return CompositionStatus.PRELIMINARY;
125        if ("final".equals(codeString))
126          return CompositionStatus.FINAL;
127        if ("amended".equals(codeString))
128          return CompositionStatus.AMENDED;
129        if ("entered-in-error".equals(codeString))
130          return CompositionStatus.ENTEREDINERROR;
131        throw new IllegalArgumentException("Unknown CompositionStatus code '"+codeString+"'");
132        }
133        public Enumeration<CompositionStatus> fromType(Base code) throws FHIRException {
134          if (code == null || code.isEmpty())
135            return null;
136          String codeString = ((PrimitiveType) code).asStringValue();
137          if (codeString == null || "".equals(codeString))
138            return null;
139        if ("preliminary".equals(codeString))
140          return new Enumeration<CompositionStatus>(this, CompositionStatus.PRELIMINARY);
141        if ("final".equals(codeString))
142          return new Enumeration<CompositionStatus>(this, CompositionStatus.FINAL);
143        if ("amended".equals(codeString))
144          return new Enumeration<CompositionStatus>(this, CompositionStatus.AMENDED);
145        if ("entered-in-error".equals(codeString))
146          return new Enumeration<CompositionStatus>(this, CompositionStatus.ENTEREDINERROR);
147        throw new FHIRException("Unknown CompositionStatus code '"+codeString+"'");
148        }
149    public String toCode(CompositionStatus code) {
150      if (code == CompositionStatus.PRELIMINARY)
151        return "preliminary";
152      if (code == CompositionStatus.FINAL)
153        return "final";
154      if (code == CompositionStatus.AMENDED)
155        return "amended";
156      if (code == CompositionStatus.ENTEREDINERROR)
157        return "entered-in-error";
158      return "?";
159      }
160    }
161
162    public enum CompositionAttestationMode {
163        /**
164         * The person authenticated the content in their personal capacity.
165         */
166        PERSONAL, 
167        /**
168         * The person authenticated the content in their professional capacity.
169         */
170        PROFESSIONAL, 
171        /**
172         * The person authenticated the content and accepted legal responsibility for its content.
173         */
174        LEGAL, 
175        /**
176         * The organization authenticated the content as consistent with their policies and procedures.
177         */
178        OFFICIAL, 
179        /**
180         * added to help the parsers
181         */
182        NULL;
183        public static CompositionAttestationMode fromCode(String codeString) throws FHIRException {
184            if (codeString == null || "".equals(codeString))
185                return null;
186        if ("personal".equals(codeString))
187          return PERSONAL;
188        if ("professional".equals(codeString))
189          return PROFESSIONAL;
190        if ("legal".equals(codeString))
191          return LEGAL;
192        if ("official".equals(codeString))
193          return OFFICIAL;
194        throw new FHIRException("Unknown CompositionAttestationMode code '"+codeString+"'");
195        }
196        public String toCode() {
197          switch (this) {
198            case PERSONAL: return "personal";
199            case PROFESSIONAL: return "professional";
200            case LEGAL: return "legal";
201            case OFFICIAL: return "official";
202            default: return "?";
203          }
204        }
205        public String getSystem() {
206          switch (this) {
207            case PERSONAL: return "http://hl7.org/fhir/composition-attestation-mode";
208            case PROFESSIONAL: return "http://hl7.org/fhir/composition-attestation-mode";
209            case LEGAL: return "http://hl7.org/fhir/composition-attestation-mode";
210            case OFFICIAL: return "http://hl7.org/fhir/composition-attestation-mode";
211            default: return "?";
212          }
213        }
214        public String getDefinition() {
215          switch (this) {
216            case PERSONAL: return "The person authenticated the content in their personal capacity.";
217            case PROFESSIONAL: return "The person authenticated the content in their professional capacity.";
218            case LEGAL: return "The person authenticated the content and accepted legal responsibility for its content.";
219            case OFFICIAL: return "The organization authenticated the content as consistent with their policies and procedures.";
220            default: return "?";
221          }
222        }
223        public String getDisplay() {
224          switch (this) {
225            case PERSONAL: return "Personal";
226            case PROFESSIONAL: return "Professional";
227            case LEGAL: return "Legal";
228            case OFFICIAL: return "Official";
229            default: return "?";
230          }
231        }
232    }
233
234  public static class CompositionAttestationModeEnumFactory implements EnumFactory<CompositionAttestationMode> {
235    public CompositionAttestationMode fromCode(String codeString) throws IllegalArgumentException {
236      if (codeString == null || "".equals(codeString))
237            if (codeString == null || "".equals(codeString))
238                return null;
239        if ("personal".equals(codeString))
240          return CompositionAttestationMode.PERSONAL;
241        if ("professional".equals(codeString))
242          return CompositionAttestationMode.PROFESSIONAL;
243        if ("legal".equals(codeString))
244          return CompositionAttestationMode.LEGAL;
245        if ("official".equals(codeString))
246          return CompositionAttestationMode.OFFICIAL;
247        throw new IllegalArgumentException("Unknown CompositionAttestationMode code '"+codeString+"'");
248        }
249        public Enumeration<CompositionAttestationMode> fromType(Base code) throws FHIRException {
250          if (code == null || code.isEmpty())
251            return null;
252          String codeString = ((PrimitiveType) code).asStringValue();
253          if (codeString == null || "".equals(codeString))
254            return null;
255        if ("personal".equals(codeString))
256          return new Enumeration<CompositionAttestationMode>(this, CompositionAttestationMode.PERSONAL);
257        if ("professional".equals(codeString))
258          return new Enumeration<CompositionAttestationMode>(this, CompositionAttestationMode.PROFESSIONAL);
259        if ("legal".equals(codeString))
260          return new Enumeration<CompositionAttestationMode>(this, CompositionAttestationMode.LEGAL);
261        if ("official".equals(codeString))
262          return new Enumeration<CompositionAttestationMode>(this, CompositionAttestationMode.OFFICIAL);
263        throw new FHIRException("Unknown CompositionAttestationMode code '"+codeString+"'");
264        }
265    public String toCode(CompositionAttestationMode code) {
266      if (code == CompositionAttestationMode.PERSONAL)
267        return "personal";
268      if (code == CompositionAttestationMode.PROFESSIONAL)
269        return "professional";
270      if (code == CompositionAttestationMode.LEGAL)
271        return "legal";
272      if (code == CompositionAttestationMode.OFFICIAL)
273        return "official";
274      return "?";
275      }
276    }
277
278    @Block()
279    public static class CompositionAttesterComponent extends BackboneElement implements IBaseBackboneElement {
280        /**
281         * The type of attestation the authenticator offers.
282         */
283        @Child(name = "mode", type = {CodeType.class}, order=1, min=1, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
284        @Description(shortDefinition="personal | professional | legal | official", formalDefinition="The type of attestation the authenticator offers." )
285        protected List<Enumeration<CompositionAttestationMode>> mode;
286
287        /**
288         * When composition was attested by the party.
289         */
290        @Child(name = "time", type = {DateTimeType.class}, order=2, min=0, max=1, modifier=false, summary=true)
291        @Description(shortDefinition="When composition attested", formalDefinition="When composition was attested by the party." )
292        protected DateTimeType time;
293
294        /**
295         * Who attested the composition in the specified way.
296         */
297        @Child(name = "party", type = {Patient.class, Practitioner.class, Organization.class}, order=3, min=0, max=1, modifier=false, summary=true)
298        @Description(shortDefinition="Who attested the composition", formalDefinition="Who attested the composition in the specified way." )
299        protected Reference party;
300
301        /**
302         * The actual object that is the target of the reference (Who attested the composition in the specified way.)
303         */
304        protected Resource partyTarget;
305
306        private static final long serialVersionUID = -436604745L;
307
308    /*
309     * Constructor
310     */
311      public CompositionAttesterComponent() {
312        super();
313      }
314
315        /**
316         * @return {@link #mode} (The type of attestation the authenticator offers.)
317         */
318        public List<Enumeration<CompositionAttestationMode>> getMode() { 
319          if (this.mode == null)
320            this.mode = new ArrayList<Enumeration<CompositionAttestationMode>>();
321          return this.mode;
322        }
323
324        public boolean hasMode() { 
325          if (this.mode == null)
326            return false;
327          for (Enumeration<CompositionAttestationMode> item : this.mode)
328            if (!item.isEmpty())
329              return true;
330          return false;
331        }
332
333        /**
334         * @return {@link #mode} (The type of attestation the authenticator offers.)
335         */
336    // syntactic sugar
337        public Enumeration<CompositionAttestationMode> addModeElement() {//2 
338          Enumeration<CompositionAttestationMode> t = new Enumeration<CompositionAttestationMode>(new CompositionAttestationModeEnumFactory());
339          if (this.mode == null)
340            this.mode = new ArrayList<Enumeration<CompositionAttestationMode>>();
341          this.mode.add(t);
342          return t;
343        }
344
345        /**
346         * @param value {@link #mode} (The type of attestation the authenticator offers.)
347         */
348        public CompositionAttesterComponent addMode(CompositionAttestationMode value) { //1
349          Enumeration<CompositionAttestationMode> t = new Enumeration<CompositionAttestationMode>(new CompositionAttestationModeEnumFactory());
350          t.setValue(value);
351          if (this.mode == null)
352            this.mode = new ArrayList<Enumeration<CompositionAttestationMode>>();
353          this.mode.add(t);
354          return this;
355        }
356
357        /**
358         * @param value {@link #mode} (The type of attestation the authenticator offers.)
359         */
360        public boolean hasMode(CompositionAttestationMode value) { 
361          if (this.mode == null)
362            return false;
363          for (Enumeration<CompositionAttestationMode> v : this.mode)
364            if (v.equals(value)) // code
365              return true;
366          return false;
367        }
368
369        /**
370         * @return {@link #time} (When composition was attested by the party.). This is the underlying object with id, value and extensions. The accessor "getTime" gives direct access to the value
371         */
372        public DateTimeType getTimeElement() { 
373          if (this.time == null)
374            if (Configuration.errorOnAutoCreate())
375              throw new Error("Attempt to auto-create CompositionAttesterComponent.time");
376            else if (Configuration.doAutoCreate())
377              this.time = new DateTimeType(); // bb
378          return this.time;
379        }
380
381        public boolean hasTimeElement() { 
382          return this.time != null && !this.time.isEmpty();
383        }
384
385        public boolean hasTime() { 
386          return this.time != null && !this.time.isEmpty();
387        }
388
389        /**
390         * @param value {@link #time} (When composition was attested by the party.). This is the underlying object with id, value and extensions. The accessor "getTime" gives direct access to the value
391         */
392        public CompositionAttesterComponent setTimeElement(DateTimeType value) { 
393          this.time = value;
394          return this;
395        }
396
397        /**
398         * @return When composition was attested by the party.
399         */
400        public Date getTime() { 
401          return this.time == null ? null : this.time.getValue();
402        }
403
404        /**
405         * @param value When composition was attested by the party.
406         */
407        public CompositionAttesterComponent setTime(Date value) { 
408          if (value == null)
409            this.time = null;
410          else {
411            if (this.time == null)
412              this.time = new DateTimeType();
413            this.time.setValue(value);
414          }
415          return this;
416        }
417
418        /**
419         * @return {@link #party} (Who attested the composition in the specified way.)
420         */
421        public Reference getParty() { 
422          if (this.party == null)
423            if (Configuration.errorOnAutoCreate())
424              throw new Error("Attempt to auto-create CompositionAttesterComponent.party");
425            else if (Configuration.doAutoCreate())
426              this.party = new Reference(); // cc
427          return this.party;
428        }
429
430        public boolean hasParty() { 
431          return this.party != null && !this.party.isEmpty();
432        }
433
434        /**
435         * @param value {@link #party} (Who attested the composition in the specified way.)
436         */
437        public CompositionAttesterComponent setParty(Reference value) { 
438          this.party = value;
439          return this;
440        }
441
442        /**
443         * @return {@link #party} 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. (Who attested the composition in the specified way.)
444         */
445        public Resource getPartyTarget() { 
446          return this.partyTarget;
447        }
448
449        /**
450         * @param value {@link #party} 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. (Who attested the composition in the specified way.)
451         */
452        public CompositionAttesterComponent setPartyTarget(Resource value) { 
453          this.partyTarget = value;
454          return this;
455        }
456
457        protected void listChildren(List<Property> childrenList) {
458          super.listChildren(childrenList);
459          childrenList.add(new Property("mode", "code", "The type of attestation the authenticator offers.", 0, java.lang.Integer.MAX_VALUE, mode));
460          childrenList.add(new Property("time", "dateTime", "When composition was attested by the party.", 0, java.lang.Integer.MAX_VALUE, time));
461          childrenList.add(new Property("party", "Reference(Patient|Practitioner|Organization)", "Who attested the composition in the specified way.", 0, java.lang.Integer.MAX_VALUE, party));
462        }
463
464      @Override
465      public void setProperty(String name, Base value) throws FHIRException {
466        if (name.equals("mode"))
467          this.getMode().add(new CompositionAttestationModeEnumFactory().fromType(value));
468        else if (name.equals("time"))
469          this.time = castToDateTime(value); // DateTimeType
470        else if (name.equals("party"))
471          this.party = castToReference(value); // Reference
472        else
473          super.setProperty(name, value);
474      }
475
476      @Override
477      public Base addChild(String name) throws FHIRException {
478        if (name.equals("mode")) {
479          throw new FHIRException("Cannot call addChild on a primitive type Composition.mode");
480        }
481        else if (name.equals("time")) {
482          throw new FHIRException("Cannot call addChild on a primitive type Composition.time");
483        }
484        else if (name.equals("party")) {
485          this.party = new Reference();
486          return this.party;
487        }
488        else
489          return super.addChild(name);
490      }
491
492      public CompositionAttesterComponent copy() {
493        CompositionAttesterComponent dst = new CompositionAttesterComponent();
494        copyValues(dst);
495        if (mode != null) {
496          dst.mode = new ArrayList<Enumeration<CompositionAttestationMode>>();
497          for (Enumeration<CompositionAttestationMode> i : mode)
498            dst.mode.add(i.copy());
499        };
500        dst.time = time == null ? null : time.copy();
501        dst.party = party == null ? null : party.copy();
502        return dst;
503      }
504
505      @Override
506      public boolean equalsDeep(Base other) {
507        if (!super.equalsDeep(other))
508          return false;
509        if (!(other instanceof CompositionAttesterComponent))
510          return false;
511        CompositionAttesterComponent o = (CompositionAttesterComponent) other;
512        return compareDeep(mode, o.mode, true) && compareDeep(time, o.time, true) && compareDeep(party, o.party, true)
513          ;
514      }
515
516      @Override
517      public boolean equalsShallow(Base other) {
518        if (!super.equalsShallow(other))
519          return false;
520        if (!(other instanceof CompositionAttesterComponent))
521          return false;
522        CompositionAttesterComponent o = (CompositionAttesterComponent) other;
523        return compareValues(mode, o.mode, true) && compareValues(time, o.time, true);
524      }
525
526      public boolean isEmpty() {
527        return super.isEmpty() && (mode == null || mode.isEmpty()) && (time == null || time.isEmpty())
528           && (party == null || party.isEmpty());
529      }
530
531  public String fhirType() {
532    return "Composition.attester";
533
534  }
535
536  }
537
538    @Block()
539    public static class CompositionEventComponent extends BackboneElement implements IBaseBackboneElement {
540        /**
541         * This list of codes represents the main clinical acts, such as a colonoscopy or an appendectomy, being documented. In some cases, the event is inherent in the typeCode, such as a "History and Physical Report" in which the procedure being documented is necessarily a "History and Physical" act.
542         */
543        @Child(name = "code", type = {CodeableConcept.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
544        @Description(shortDefinition="Code(s) that apply to the event being documented", formalDefinition="This list of codes represents the main clinical acts, such as a colonoscopy or an appendectomy, being documented. In some cases, the event is inherent in the typeCode, such as a \"History and Physical Report\" in which the procedure being documented is necessarily a \"History and Physical\" act." )
545        protected List<CodeableConcept> code;
546
547        /**
548         * The period of time covered by the documentation. There is no assertion that the documentation is a complete representation for this period, only that it documents events during this time.
549         */
550        @Child(name = "period", type = {Period.class}, order=2, min=0, max=1, modifier=false, summary=true)
551        @Description(shortDefinition="The period covered by the documentation", formalDefinition="The period of time covered by the documentation. There is no assertion that the documentation is a complete representation for this period, only that it documents events during this time." )
552        protected Period period;
553
554        /**
555         * The description and/or reference of the event(s) being documented. For example, this could be used to document such a colonoscopy or an appendectomy.
556         */
557        @Child(name = "detail", type = {}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
558        @Description(shortDefinition="The event(s) being documented", formalDefinition="The description and/or reference of the event(s) being documented. For example, this could be used to document such a colonoscopy or an appendectomy." )
559        protected List<Reference> detail;
560        /**
561         * The actual objects that are the target of the reference (The description and/or reference of the event(s) being documented. For example, this could be used to document such a colonoscopy or an appendectomy.)
562         */
563        protected List<Resource> detailTarget;
564
565
566        private static final long serialVersionUID = -1581379774L;
567
568    /*
569     * Constructor
570     */
571      public CompositionEventComponent() {
572        super();
573      }
574
575        /**
576         * @return {@link #code} (This list of codes represents the main clinical acts, such as a colonoscopy or an appendectomy, being documented. In some cases, the event is inherent in the typeCode, such as a "History and Physical Report" in which the procedure being documented is necessarily a "History and Physical" act.)
577         */
578        public List<CodeableConcept> getCode() { 
579          if (this.code == null)
580            this.code = new ArrayList<CodeableConcept>();
581          return this.code;
582        }
583
584        public boolean hasCode() { 
585          if (this.code == null)
586            return false;
587          for (CodeableConcept item : this.code)
588            if (!item.isEmpty())
589              return true;
590          return false;
591        }
592
593        /**
594         * @return {@link #code} (This list of codes represents the main clinical acts, such as a colonoscopy or an appendectomy, being documented. In some cases, the event is inherent in the typeCode, such as a "History and Physical Report" in which the procedure being documented is necessarily a "History and Physical" act.)
595         */
596    // syntactic sugar
597        public CodeableConcept addCode() { //3
598          CodeableConcept t = new CodeableConcept();
599          if (this.code == null)
600            this.code = new ArrayList<CodeableConcept>();
601          this.code.add(t);
602          return t;
603        }
604
605    // syntactic sugar
606        public CompositionEventComponent addCode(CodeableConcept t) { //3
607          if (t == null)
608            return this;
609          if (this.code == null)
610            this.code = new ArrayList<CodeableConcept>();
611          this.code.add(t);
612          return this;
613        }
614
615        /**
616         * @return {@link #period} (The period of time covered by the documentation. There is no assertion that the documentation is a complete representation for this period, only that it documents events during this time.)
617         */
618        public Period getPeriod() { 
619          if (this.period == null)
620            if (Configuration.errorOnAutoCreate())
621              throw new Error("Attempt to auto-create CompositionEventComponent.period");
622            else if (Configuration.doAutoCreate())
623              this.period = new Period(); // cc
624          return this.period;
625        }
626
627        public boolean hasPeriod() { 
628          return this.period != null && !this.period.isEmpty();
629        }
630
631        /**
632         * @param value {@link #period} (The period of time covered by the documentation. There is no assertion that the documentation is a complete representation for this period, only that it documents events during this time.)
633         */
634        public CompositionEventComponent setPeriod(Period value) { 
635          this.period = value;
636          return this;
637        }
638
639        /**
640         * @return {@link #detail} (The description and/or reference of the event(s) being documented. For example, this could be used to document such a colonoscopy or an appendectomy.)
641         */
642        public List<Reference> getDetail() { 
643          if (this.detail == null)
644            this.detail = new ArrayList<Reference>();
645          return this.detail;
646        }
647
648        public boolean hasDetail() { 
649          if (this.detail == null)
650            return false;
651          for (Reference item : this.detail)
652            if (!item.isEmpty())
653              return true;
654          return false;
655        }
656
657        /**
658         * @return {@link #detail} (The description and/or reference of the event(s) being documented. For example, this could be used to document such a colonoscopy or an appendectomy.)
659         */
660    // syntactic sugar
661        public Reference addDetail() { //3
662          Reference t = new Reference();
663          if (this.detail == null)
664            this.detail = new ArrayList<Reference>();
665          this.detail.add(t);
666          return t;
667        }
668
669    // syntactic sugar
670        public CompositionEventComponent addDetail(Reference t) { //3
671          if (t == null)
672            return this;
673          if (this.detail == null)
674            this.detail = new ArrayList<Reference>();
675          this.detail.add(t);
676          return this;
677        }
678
679        /**
680         * @return {@link #detail} (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. The description and/or reference of the event(s) being documented. For example, this could be used to document such a colonoscopy or an appendectomy.)
681         */
682        public List<Resource> getDetailTarget() { 
683          if (this.detailTarget == null)
684            this.detailTarget = new ArrayList<Resource>();
685          return this.detailTarget;
686        }
687
688        protected void listChildren(List<Property> childrenList) {
689          super.listChildren(childrenList);
690          childrenList.add(new Property("code", "CodeableConcept", "This list of codes represents the main clinical acts, such as a colonoscopy or an appendectomy, being documented. In some cases, the event is inherent in the typeCode, such as a \"History and Physical Report\" in which the procedure being documented is necessarily a \"History and Physical\" act.", 0, java.lang.Integer.MAX_VALUE, code));
691          childrenList.add(new Property("period", "Period", "The period of time covered by the documentation. There is no assertion that the documentation is a complete representation for this period, only that it documents events during this time.", 0, java.lang.Integer.MAX_VALUE, period));
692          childrenList.add(new Property("detail", "Reference(Any)", "The description and/or reference of the event(s) being documented. For example, this could be used to document such a colonoscopy or an appendectomy.", 0, java.lang.Integer.MAX_VALUE, detail));
693        }
694
695      @Override
696      public void setProperty(String name, Base value) throws FHIRException {
697        if (name.equals("code"))
698          this.getCode().add(castToCodeableConcept(value));
699        else if (name.equals("period"))
700          this.period = castToPeriod(value); // Period
701        else if (name.equals("detail"))
702          this.getDetail().add(castToReference(value));
703        else
704          super.setProperty(name, value);
705      }
706
707      @Override
708      public Base addChild(String name) throws FHIRException {
709        if (name.equals("code")) {
710          return addCode();
711        }
712        else if (name.equals("period")) {
713          this.period = new Period();
714          return this.period;
715        }
716        else if (name.equals("detail")) {
717          return addDetail();
718        }
719        else
720          return super.addChild(name);
721      }
722
723      public CompositionEventComponent copy() {
724        CompositionEventComponent dst = new CompositionEventComponent();
725        copyValues(dst);
726        if (code != null) {
727          dst.code = new ArrayList<CodeableConcept>();
728          for (CodeableConcept i : code)
729            dst.code.add(i.copy());
730        };
731        dst.period = period == null ? null : period.copy();
732        if (detail != null) {
733          dst.detail = new ArrayList<Reference>();
734          for (Reference i : detail)
735            dst.detail.add(i.copy());
736        };
737        return dst;
738      }
739
740      @Override
741      public boolean equalsDeep(Base other) {
742        if (!super.equalsDeep(other))
743          return false;
744        if (!(other instanceof CompositionEventComponent))
745          return false;
746        CompositionEventComponent o = (CompositionEventComponent) other;
747        return compareDeep(code, o.code, true) && compareDeep(period, o.period, true) && compareDeep(detail, o.detail, true)
748          ;
749      }
750
751      @Override
752      public boolean equalsShallow(Base other) {
753        if (!super.equalsShallow(other))
754          return false;
755        if (!(other instanceof CompositionEventComponent))
756          return false;
757        CompositionEventComponent o = (CompositionEventComponent) other;
758        return true;
759      }
760
761      public boolean isEmpty() {
762        return super.isEmpty() && (code == null || code.isEmpty()) && (period == null || period.isEmpty())
763           && (detail == null || detail.isEmpty());
764      }
765
766  public String fhirType() {
767    return "Composition.event";
768
769  }
770
771  }
772
773    @Block()
774    public static class SectionComponent extends BackboneElement implements IBaseBackboneElement {
775        /**
776         * The label for this particular section.  This will be part of the rendered content for the document, and is often used to build a table of contents.
777         */
778        @Child(name = "title", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=false)
779        @Description(shortDefinition="Label for section (e.g. for ToC)", formalDefinition="The label for this particular section.  This will be part of the rendered content for the document, and is often used to build a table of contents." )
780        protected StringType title;
781
782        /**
783         * A code identifying the kind of content contained within the section. This must be consistent with the section title.
784         */
785        @Child(name = "code", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
786        @Description(shortDefinition="Classification of section (recommended)", formalDefinition="A code identifying the kind of content contained within the section. This must be consistent with the section title." )
787        protected CodeableConcept code;
788
789        /**
790         * A human-readable narrative that contains the attested content of the section, used to represent the content of the resource to a human. The narrative need not encode all the structured data, but is required to contain sufficient detail to make it "clinically safe" for a human to just read the narrative.
791         */
792        @Child(name = "text", type = {Narrative.class}, order=3, min=0, max=1, modifier=false, summary=false)
793        @Description(shortDefinition="Text summary of the section, for human interpretation", formalDefinition="A human-readable narrative that contains the attested content of the section, used to represent the content of the resource to a human. The narrative need not encode all the structured data, but is required to contain sufficient detail to make it \"clinically safe\" for a human to just read the narrative." )
794        protected Narrative text;
795
796        /**
797         * How the entry list was prepared - whether it is a working list that is suitable for being maintained on an ongoing basis, or if it represents a snapshot of a list of items from another source, or whether it is a prepared list where items may be marked as added, modified or deleted.
798         */
799        @Child(name = "mode", type = {CodeType.class}, order=4, min=0, max=1, modifier=true, summary=true)
800        @Description(shortDefinition="working | snapshot | changes", formalDefinition="How the entry list was prepared - whether it is a working list that is suitable for being maintained on an ongoing basis, or if it represents a snapshot of a list of items from another source, or whether it is a prepared list where items may be marked as added, modified or deleted." )
801        protected CodeType mode;
802
803        /**
804         * Specifies the order applied to the items in the section entries.
805         */
806        @Child(name = "orderedBy", type = {CodeableConcept.class}, order=5, min=0, max=1, modifier=false, summary=false)
807        @Description(shortDefinition="Order of section entries", formalDefinition="Specifies the order applied to the items in the section entries." )
808        protected CodeableConcept orderedBy;
809
810        /**
811         * A reference to the actual resource from which the narrative in the section is derived.
812         */
813        @Child(name = "entry", type = {}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
814        @Description(shortDefinition="A reference to data that supports this section", formalDefinition="A reference to the actual resource from which the narrative in the section is derived." )
815        protected List<Reference> entry;
816        /**
817         * The actual objects that are the target of the reference (A reference to the actual resource from which the narrative in the section is derived.)
818         */
819        protected List<Resource> entryTarget;
820
821
822        /**
823         * If the section is empty, why the list is empty. An empty section typically has some text explaining the empty reason.
824         */
825        @Child(name = "emptyReason", type = {CodeableConcept.class}, order=7, min=0, max=1, modifier=false, summary=false)
826        @Description(shortDefinition="Why the section is empty", formalDefinition="If the section is empty, why the list is empty. An empty section typically has some text explaining the empty reason." )
827        protected CodeableConcept emptyReason;
828
829        /**
830         * A nested sub-section within this section.
831         */
832        @Child(name = "section", type = {SectionComponent.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
833        @Description(shortDefinition="Nested Section", formalDefinition="A nested sub-section within this section." )
834        protected List<SectionComponent> section;
835
836        private static final long serialVersionUID = -726390626L;
837
838    /*
839     * Constructor
840     */
841      public SectionComponent() {
842        super();
843      }
844
845        /**
846         * @return {@link #title} (The label for this particular section.  This will be part of the rendered content for the document, and is often used to build a table of contents.). This is the underlying object with id, value and extensions. The accessor "getTitle" gives direct access to the value
847         */
848        public StringType getTitleElement() { 
849          if (this.title == null)
850            if (Configuration.errorOnAutoCreate())
851              throw new Error("Attempt to auto-create SectionComponent.title");
852            else if (Configuration.doAutoCreate())
853              this.title = new StringType(); // bb
854          return this.title;
855        }
856
857        public boolean hasTitleElement() { 
858          return this.title != null && !this.title.isEmpty();
859        }
860
861        public boolean hasTitle() { 
862          return this.title != null && !this.title.isEmpty();
863        }
864
865        /**
866         * @param value {@link #title} (The label for this particular section.  This will be part of the rendered content for the document, and is often used to build a table of contents.). This is the underlying object with id, value and extensions. The accessor "getTitle" gives direct access to the value
867         */
868        public SectionComponent setTitleElement(StringType value) { 
869          this.title = value;
870          return this;
871        }
872
873        /**
874         * @return The label for this particular section.  This will be part of the rendered content for the document, and is often used to build a table of contents.
875         */
876        public String getTitle() { 
877          return this.title == null ? null : this.title.getValue();
878        }
879
880        /**
881         * @param value The label for this particular section.  This will be part of the rendered content for the document, and is often used to build a table of contents.
882         */
883        public SectionComponent setTitle(String value) { 
884          if (Utilities.noString(value))
885            this.title = null;
886          else {
887            if (this.title == null)
888              this.title = new StringType();
889            this.title.setValue(value);
890          }
891          return this;
892        }
893
894        /**
895         * @return {@link #code} (A code identifying the kind of content contained within the section. This must be consistent with the section title.)
896         */
897        public CodeableConcept getCode() { 
898          if (this.code == null)
899            if (Configuration.errorOnAutoCreate())
900              throw new Error("Attempt to auto-create SectionComponent.code");
901            else if (Configuration.doAutoCreate())
902              this.code = new CodeableConcept(); // cc
903          return this.code;
904        }
905
906        public boolean hasCode() { 
907          return this.code != null && !this.code.isEmpty();
908        }
909
910        /**
911         * @param value {@link #code} (A code identifying the kind of content contained within the section. This must be consistent with the section title.)
912         */
913        public SectionComponent setCode(CodeableConcept value) { 
914          this.code = value;
915          return this;
916        }
917
918        /**
919         * @return {@link #text} (A human-readable narrative that contains the attested content of the section, used to represent the content of the resource to a human. The narrative need not encode all the structured data, but is required to contain sufficient detail to make it "clinically safe" for a human to just read the narrative.)
920         */
921        public Narrative getText() { 
922          if (this.text == null)
923            if (Configuration.errorOnAutoCreate())
924              throw new Error("Attempt to auto-create SectionComponent.text");
925            else if (Configuration.doAutoCreate())
926              this.text = new Narrative(); // cc
927          return this.text;
928        }
929
930        public boolean hasText() { 
931          return this.text != null && !this.text.isEmpty();
932        }
933
934        /**
935         * @param value {@link #text} (A human-readable narrative that contains the attested content of the section, used to represent the content of the resource to a human. The narrative need not encode all the structured data, but is required to contain sufficient detail to make it "clinically safe" for a human to just read the narrative.)
936         */
937        public SectionComponent setText(Narrative value) { 
938          this.text = value;
939          return this;
940        }
941
942        /**
943         * @return {@link #mode} (How the entry list was prepared - whether it is a working list that is suitable for being maintained on an ongoing basis, or if it represents a snapshot of a list of items from another source, or whether it is a prepared list where items may be marked as added, modified or deleted.). This is the underlying object with id, value and extensions. The accessor "getMode" gives direct access to the value
944         */
945        public CodeType getModeElement() { 
946          if (this.mode == null)
947            if (Configuration.errorOnAutoCreate())
948              throw new Error("Attempt to auto-create SectionComponent.mode");
949            else if (Configuration.doAutoCreate())
950              this.mode = new CodeType(); // bb
951          return this.mode;
952        }
953
954        public boolean hasModeElement() { 
955          return this.mode != null && !this.mode.isEmpty();
956        }
957
958        public boolean hasMode() { 
959          return this.mode != null && !this.mode.isEmpty();
960        }
961
962        /**
963         * @param value {@link #mode} (How the entry list was prepared - whether it is a working list that is suitable for being maintained on an ongoing basis, or if it represents a snapshot of a list of items from another source, or whether it is a prepared list where items may be marked as added, modified or deleted.). This is the underlying object with id, value and extensions. The accessor "getMode" gives direct access to the value
964         */
965        public SectionComponent setModeElement(CodeType value) { 
966          this.mode = value;
967          return this;
968        }
969
970        /**
971         * @return How the entry list was prepared - whether it is a working list that is suitable for being maintained on an ongoing basis, or if it represents a snapshot of a list of items from another source, or whether it is a prepared list where items may be marked as added, modified or deleted.
972         */
973        public String getMode() { 
974          return this.mode == null ? null : this.mode.getValue();
975        }
976
977        /**
978         * @param value How the entry list was prepared - whether it is a working list that is suitable for being maintained on an ongoing basis, or if it represents a snapshot of a list of items from another source, or whether it is a prepared list where items may be marked as added, modified or deleted.
979         */
980        public SectionComponent setMode(String value) { 
981          if (Utilities.noString(value))
982            this.mode = null;
983          else {
984            if (this.mode == null)
985              this.mode = new CodeType();
986            this.mode.setValue(value);
987          }
988          return this;
989        }
990
991        /**
992         * @return {@link #orderedBy} (Specifies the order applied to the items in the section entries.)
993         */
994        public CodeableConcept getOrderedBy() { 
995          if (this.orderedBy == null)
996            if (Configuration.errorOnAutoCreate())
997              throw new Error("Attempt to auto-create SectionComponent.orderedBy");
998            else if (Configuration.doAutoCreate())
999              this.orderedBy = new CodeableConcept(); // cc
1000          return this.orderedBy;
1001        }
1002
1003        public boolean hasOrderedBy() { 
1004          return this.orderedBy != null && !this.orderedBy.isEmpty();
1005        }
1006
1007        /**
1008         * @param value {@link #orderedBy} (Specifies the order applied to the items in the section entries.)
1009         */
1010        public SectionComponent setOrderedBy(CodeableConcept value) { 
1011          this.orderedBy = value;
1012          return this;
1013        }
1014
1015        /**
1016         * @return {@link #entry} (A reference to the actual resource from which the narrative in the section is derived.)
1017         */
1018        public List<Reference> getEntry() { 
1019          if (this.entry == null)
1020            this.entry = new ArrayList<Reference>();
1021          return this.entry;
1022        }
1023
1024        public boolean hasEntry() { 
1025          if (this.entry == null)
1026            return false;
1027          for (Reference item : this.entry)
1028            if (!item.isEmpty())
1029              return true;
1030          return false;
1031        }
1032
1033        /**
1034         * @return {@link #entry} (A reference to the actual resource from which the narrative in the section is derived.)
1035         */
1036    // syntactic sugar
1037        public Reference addEntry() { //3
1038          Reference t = new Reference();
1039          if (this.entry == null)
1040            this.entry = new ArrayList<Reference>();
1041          this.entry.add(t);
1042          return t;
1043        }
1044
1045    // syntactic sugar
1046        public SectionComponent addEntry(Reference t) { //3
1047          if (t == null)
1048            return this;
1049          if (this.entry == null)
1050            this.entry = new ArrayList<Reference>();
1051          this.entry.add(t);
1052          return this;
1053        }
1054
1055        /**
1056         * @return {@link #entry} (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. A reference to the actual resource from which the narrative in the section is derived.)
1057         */
1058        public List<Resource> getEntryTarget() { 
1059          if (this.entryTarget == null)
1060            this.entryTarget = new ArrayList<Resource>();
1061          return this.entryTarget;
1062        }
1063
1064        /**
1065         * @return {@link #emptyReason} (If the section is empty, why the list is empty. An empty section typically has some text explaining the empty reason.)
1066         */
1067        public CodeableConcept getEmptyReason() { 
1068          if (this.emptyReason == null)
1069            if (Configuration.errorOnAutoCreate())
1070              throw new Error("Attempt to auto-create SectionComponent.emptyReason");
1071            else if (Configuration.doAutoCreate())
1072              this.emptyReason = new CodeableConcept(); // cc
1073          return this.emptyReason;
1074        }
1075
1076        public boolean hasEmptyReason() { 
1077          return this.emptyReason != null && !this.emptyReason.isEmpty();
1078        }
1079
1080        /**
1081         * @param value {@link #emptyReason} (If the section is empty, why the list is empty. An empty section typically has some text explaining the empty reason.)
1082         */
1083        public SectionComponent setEmptyReason(CodeableConcept value) { 
1084          this.emptyReason = value;
1085          return this;
1086        }
1087
1088        /**
1089         * @return {@link #section} (A nested sub-section within this section.)
1090         */
1091        public List<SectionComponent> getSection() { 
1092          if (this.section == null)
1093            this.section = new ArrayList<SectionComponent>();
1094          return this.section;
1095        }
1096
1097        public boolean hasSection() { 
1098          if (this.section == null)
1099            return false;
1100          for (SectionComponent item : this.section)
1101            if (!item.isEmpty())
1102              return true;
1103          return false;
1104        }
1105
1106        /**
1107         * @return {@link #section} (A nested sub-section within this section.)
1108         */
1109    // syntactic sugar
1110        public SectionComponent addSection() { //3
1111          SectionComponent t = new SectionComponent();
1112          if (this.section == null)
1113            this.section = new ArrayList<SectionComponent>();
1114          this.section.add(t);
1115          return t;
1116        }
1117
1118    // syntactic sugar
1119        public SectionComponent addSection(SectionComponent t) { //3
1120          if (t == null)
1121            return this;
1122          if (this.section == null)
1123            this.section = new ArrayList<SectionComponent>();
1124          this.section.add(t);
1125          return this;
1126        }
1127
1128        protected void listChildren(List<Property> childrenList) {
1129          super.listChildren(childrenList);
1130          childrenList.add(new Property("title", "string", "The label for this particular section.  This will be part of the rendered content for the document, and is often used to build a table of contents.", 0, java.lang.Integer.MAX_VALUE, title));
1131          childrenList.add(new Property("code", "CodeableConcept", "A code identifying the kind of content contained within the section. This must be consistent with the section title.", 0, java.lang.Integer.MAX_VALUE, code));
1132          childrenList.add(new Property("text", "Narrative", "A human-readable narrative that contains the attested content of the section, used to represent the content of the resource to a human. The narrative need not encode all the structured data, but is required to contain sufficient detail to make it \"clinically safe\" for a human to just read the narrative.", 0, java.lang.Integer.MAX_VALUE, text));
1133          childrenList.add(new Property("mode", "code", "How the entry list was prepared - whether it is a working list that is suitable for being maintained on an ongoing basis, or if it represents a snapshot of a list of items from another source, or whether it is a prepared list where items may be marked as added, modified or deleted.", 0, java.lang.Integer.MAX_VALUE, mode));
1134          childrenList.add(new Property("orderedBy", "CodeableConcept", "Specifies the order applied to the items in the section entries.", 0, java.lang.Integer.MAX_VALUE, orderedBy));
1135          childrenList.add(new Property("entry", "Reference(Any)", "A reference to the actual resource from which the narrative in the section is derived.", 0, java.lang.Integer.MAX_VALUE, entry));
1136          childrenList.add(new Property("emptyReason", "CodeableConcept", "If the section is empty, why the list is empty. An empty section typically has some text explaining the empty reason.", 0, java.lang.Integer.MAX_VALUE, emptyReason));
1137          childrenList.add(new Property("section", "@Composition.section", "A nested sub-section within this section.", 0, java.lang.Integer.MAX_VALUE, section));
1138        }
1139
1140      @Override
1141      public void setProperty(String name, Base value) throws FHIRException {
1142        if (name.equals("title"))
1143          this.title = castToString(value); // StringType
1144        else if (name.equals("code"))
1145          this.code = castToCodeableConcept(value); // CodeableConcept
1146        else if (name.equals("text"))
1147          this.text = castToNarrative(value); // Narrative
1148        else if (name.equals("mode"))
1149          this.mode = castToCode(value); // CodeType
1150        else if (name.equals("orderedBy"))
1151          this.orderedBy = castToCodeableConcept(value); // CodeableConcept
1152        else if (name.equals("entry"))
1153          this.getEntry().add(castToReference(value));
1154        else if (name.equals("emptyReason"))
1155          this.emptyReason = castToCodeableConcept(value); // CodeableConcept
1156        else if (name.equals("section"))
1157          this.getSection().add((SectionComponent) value);
1158        else
1159          super.setProperty(name, value);
1160      }
1161
1162      @Override
1163      public Base addChild(String name) throws FHIRException {
1164        if (name.equals("title")) {
1165          throw new FHIRException("Cannot call addChild on a primitive type Composition.title");
1166        }
1167        else if (name.equals("code")) {
1168          this.code = new CodeableConcept();
1169          return this.code;
1170        }
1171        else if (name.equals("text")) {
1172          this.text = new Narrative();
1173          return this.text;
1174        }
1175        else if (name.equals("mode")) {
1176          throw new FHIRException("Cannot call addChild on a primitive type Composition.mode");
1177        }
1178        else if (name.equals("orderedBy")) {
1179          this.orderedBy = new CodeableConcept();
1180          return this.orderedBy;
1181        }
1182        else if (name.equals("entry")) {
1183          return addEntry();
1184        }
1185        else if (name.equals("emptyReason")) {
1186          this.emptyReason = new CodeableConcept();
1187          return this.emptyReason;
1188        }
1189        else if (name.equals("section")) {
1190          return addSection();
1191        }
1192        else
1193          return super.addChild(name);
1194      }
1195
1196      public SectionComponent copy() {
1197        SectionComponent dst = new SectionComponent();
1198        copyValues(dst);
1199        dst.title = title == null ? null : title.copy();
1200        dst.code = code == null ? null : code.copy();
1201        dst.text = text == null ? null : text.copy();
1202        dst.mode = mode == null ? null : mode.copy();
1203        dst.orderedBy = orderedBy == null ? null : orderedBy.copy();
1204        if (entry != null) {
1205          dst.entry = new ArrayList<Reference>();
1206          for (Reference i : entry)
1207            dst.entry.add(i.copy());
1208        };
1209        dst.emptyReason = emptyReason == null ? null : emptyReason.copy();
1210        if (section != null) {
1211          dst.section = new ArrayList<SectionComponent>();
1212          for (SectionComponent i : section)
1213            dst.section.add(i.copy());
1214        };
1215        return dst;
1216      }
1217
1218      @Override
1219      public boolean equalsDeep(Base other) {
1220        if (!super.equalsDeep(other))
1221          return false;
1222        if (!(other instanceof SectionComponent))
1223          return false;
1224        SectionComponent o = (SectionComponent) other;
1225        return compareDeep(title, o.title, true) && compareDeep(code, o.code, true) && compareDeep(text, o.text, true)
1226           && compareDeep(mode, o.mode, true) && compareDeep(orderedBy, o.orderedBy, true) && compareDeep(entry, o.entry, true)
1227           && compareDeep(emptyReason, o.emptyReason, true) && compareDeep(section, o.section, true);
1228      }
1229
1230      @Override
1231      public boolean equalsShallow(Base other) {
1232        if (!super.equalsShallow(other))
1233          return false;
1234        if (!(other instanceof SectionComponent))
1235          return false;
1236        SectionComponent o = (SectionComponent) other;
1237        return compareValues(title, o.title, true) && compareValues(mode, o.mode, true);
1238      }
1239
1240      public boolean isEmpty() {
1241        return super.isEmpty() && (title == null || title.isEmpty()) && (code == null || code.isEmpty())
1242           && (text == null || text.isEmpty()) && (mode == null || mode.isEmpty()) && (orderedBy == null || orderedBy.isEmpty())
1243           && (entry == null || entry.isEmpty()) && (emptyReason == null || emptyReason.isEmpty()) && (section == null || section.isEmpty())
1244          ;
1245      }
1246
1247  public String fhirType() {
1248    return "Composition.section";
1249
1250  }
1251
1252  }
1253
1254    /**
1255     * Logical identifier for the composition, assigned when created. This identifier stays constant as the composition is changed over time.
1256     */
1257    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=1, modifier=false, summary=true)
1258    @Description(shortDefinition="Logical identifier of composition (version-independent)", formalDefinition="Logical identifier for the composition, assigned when created. This identifier stays constant as the composition is changed over time." )
1259    protected Identifier identifier;
1260
1261    /**
1262     * The composition editing time, when the composition was last logically changed by the author.
1263     */
1264    @Child(name = "date", type = {DateTimeType.class}, order=1, min=1, max=1, modifier=false, summary=true)
1265    @Description(shortDefinition="Composition editing time", formalDefinition="The composition editing time, when the composition was last logically changed by the author." )
1266    protected DateTimeType date;
1267
1268    /**
1269     * Specifies the particular kind of composition (e.g. History and Physical, Discharge Summary, Progress Note). This usually equates to the purpose of making the composition.
1270     */
1271    @Child(name = "type", type = {CodeableConcept.class}, order=2, min=1, max=1, modifier=false, summary=true)
1272    @Description(shortDefinition="Kind of composition (LOINC if possible)", formalDefinition="Specifies the particular kind of composition (e.g. History and Physical, Discharge Summary, Progress Note). This usually equates to the purpose of making the composition." )
1273    protected CodeableConcept type;
1274
1275    /**
1276     * A categorization for the type of the composition - helps for indexing and searching. This may be implied by or derived from the code specified in the Composition Type.
1277     */
1278    @Child(name = "class", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=true)
1279    @Description(shortDefinition="Categorization of Composition", formalDefinition="A categorization for the type of the composition - helps for indexing and searching. This may be implied by or derived from the code specified in the Composition Type." )
1280    protected CodeableConcept class_;
1281
1282    /**
1283     * Official human-readable label for the composition.
1284     */
1285    @Child(name = "title", type = {StringType.class}, order=4, min=1, max=1, modifier=false, summary=true)
1286    @Description(shortDefinition="Human Readable name/title", formalDefinition="Official human-readable label for the composition." )
1287    protected StringType title;
1288
1289    /**
1290     * The workflow/clinical status of this composition. The status is a marker for the clinical standing of the document.
1291     */
1292    @Child(name = "status", type = {CodeType.class}, order=5, min=1, max=1, modifier=true, summary=true)
1293    @Description(shortDefinition="preliminary | final | amended | entered-in-error", formalDefinition="The workflow/clinical status of this composition. The status is a marker for the clinical standing of the document." )
1294    protected Enumeration<CompositionStatus> status;
1295
1296    /**
1297     * The code specifying the level of confidentiality of the Composition.
1298     */
1299    @Child(name = "confidentiality", type = {CodeType.class}, order=6, min=0, max=1, modifier=true, summary=true)
1300    @Description(shortDefinition="As defined by affinity domain", formalDefinition="The code specifying the level of confidentiality of the Composition." )
1301    protected CodeType confidentiality;
1302
1303    /**
1304     * Who or what the composition is about. The composition can be about a person, (patient or healthcare practitioner), a device (e.g. a machine) or even a group of subjects (such as a document about a herd of livestock, or a set of patients that share a common exposure).
1305     */
1306    @Child(name = "subject", type = {}, order=7, min=1, max=1, modifier=false, summary=true)
1307    @Description(shortDefinition="Who and/or what the composition is about", formalDefinition="Who or what the composition is about. The composition can be about a person, (patient or healthcare practitioner), a device (e.g. a machine) or even a group of subjects (such as a document about a herd of livestock, or a set of patients that share a common exposure)." )
1308    protected Reference subject;
1309
1310    /**
1311     * The actual object that is the target of the reference (Who or what the composition is about. The composition can be about a person, (patient or healthcare practitioner), a device (e.g. a machine) or even a group of subjects (such as a document about a herd of livestock, or a set of patients that share a common exposure).)
1312     */
1313    protected Resource subjectTarget;
1314
1315    /**
1316     * Identifies who is responsible for the information in the composition, not necessarily who typed it in.
1317     */
1318    @Child(name = "author", type = {Practitioner.class, Device.class, Patient.class, RelatedPerson.class}, order=8, min=1, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1319    @Description(shortDefinition="Who and/or what authored the composition", formalDefinition="Identifies who is responsible for the information in the composition, not necessarily who typed it in." )
1320    protected List<Reference> author;
1321    /**
1322     * The actual objects that are the target of the reference (Identifies who is responsible for the information in the composition, not necessarily who typed it in.)
1323     */
1324    protected List<Resource> authorTarget;
1325
1326
1327    /**
1328     * A participant who has attested to the accuracy of the composition/document.
1329     */
1330    @Child(name = "attester", type = {}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1331    @Description(shortDefinition="Attests to accuracy of composition", formalDefinition="A participant who has attested to the accuracy of the composition/document." )
1332    protected List<CompositionAttesterComponent> attester;
1333
1334    /**
1335     * Identifies the organization or group who is responsible for ongoing maintenance of and access to the composition/document information.
1336     */
1337    @Child(name = "custodian", type = {Organization.class}, order=10, min=0, max=1, modifier=false, summary=true)
1338    @Description(shortDefinition="Organization which maintains the composition", formalDefinition="Identifies the organization or group who is responsible for ongoing maintenance of and access to the composition/document information." )
1339    protected Reference custodian;
1340
1341    /**
1342     * The actual object that is the target of the reference (Identifies the organization or group who is responsible for ongoing maintenance of and access to the composition/document information.)
1343     */
1344    protected Organization custodianTarget;
1345
1346    /**
1347     * The clinical service, such as a colonoscopy or an appendectomy, being documented.
1348     */
1349    @Child(name = "event", type = {}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1350    @Description(shortDefinition="The clinical service(s) being documented", formalDefinition="The clinical service, such as a colonoscopy or an appendectomy, being documented." )
1351    protected List<CompositionEventComponent> event;
1352
1353    /**
1354     * Describes the clinical encounter or type of care this documentation is associated with.
1355     */
1356    @Child(name = "encounter", type = {Encounter.class}, order=12, min=0, max=1, modifier=false, summary=true)
1357    @Description(shortDefinition="Context of the Composition", formalDefinition="Describes the clinical encounter or type of care this documentation is associated with." )
1358    protected Reference encounter;
1359
1360    /**
1361     * The actual object that is the target of the reference (Describes the clinical encounter or type of care this documentation is associated with.)
1362     */
1363    protected Encounter encounterTarget;
1364
1365    /**
1366     * The root of the sections that make up the composition.
1367     */
1368    @Child(name = "section", type = {}, order=13, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1369    @Description(shortDefinition="Composition is broken into sections", formalDefinition="The root of the sections that make up the composition." )
1370    protected List<SectionComponent> section;
1371
1372    private static final long serialVersionUID = 2127852326L;
1373
1374  /*
1375   * Constructor
1376   */
1377    public Composition() {
1378      super();
1379    }
1380
1381  /*
1382   * Constructor
1383   */
1384    public Composition(DateTimeType date, CodeableConcept type, StringType title, Enumeration<CompositionStatus> status, Reference subject) {
1385      super();
1386      this.date = date;
1387      this.type = type;
1388      this.title = title;
1389      this.status = status;
1390      this.subject = subject;
1391    }
1392
1393    /**
1394     * @return {@link #identifier} (Logical identifier for the composition, assigned when created. This identifier stays constant as the composition is changed over time.)
1395     */
1396    public Identifier getIdentifier() { 
1397      if (this.identifier == null)
1398        if (Configuration.errorOnAutoCreate())
1399          throw new Error("Attempt to auto-create Composition.identifier");
1400        else if (Configuration.doAutoCreate())
1401          this.identifier = new Identifier(); // cc
1402      return this.identifier;
1403    }
1404
1405    public boolean hasIdentifier() { 
1406      return this.identifier != null && !this.identifier.isEmpty();
1407    }
1408
1409    /**
1410     * @param value {@link #identifier} (Logical identifier for the composition, assigned when created. This identifier stays constant as the composition is changed over time.)
1411     */
1412    public Composition setIdentifier(Identifier value) { 
1413      this.identifier = value;
1414      return this;
1415    }
1416
1417    /**
1418     * @return {@link #date} (The composition editing time, when the composition was last logically changed by the author.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
1419     */
1420    public DateTimeType getDateElement() { 
1421      if (this.date == null)
1422        if (Configuration.errorOnAutoCreate())
1423          throw new Error("Attempt to auto-create Composition.date");
1424        else if (Configuration.doAutoCreate())
1425          this.date = new DateTimeType(); // bb
1426      return this.date;
1427    }
1428
1429    public boolean hasDateElement() { 
1430      return this.date != null && !this.date.isEmpty();
1431    }
1432
1433    public boolean hasDate() { 
1434      return this.date != null && !this.date.isEmpty();
1435    }
1436
1437    /**
1438     * @param value {@link #date} (The composition editing time, when the composition was last logically changed by the author.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
1439     */
1440    public Composition setDateElement(DateTimeType value) { 
1441      this.date = value;
1442      return this;
1443    }
1444
1445    /**
1446     * @return The composition editing time, when the composition was last logically changed by the author.
1447     */
1448    public Date getDate() { 
1449      return this.date == null ? null : this.date.getValue();
1450    }
1451
1452    /**
1453     * @param value The composition editing time, when the composition was last logically changed by the author.
1454     */
1455    public Composition setDate(Date value) { 
1456        if (this.date == null)
1457          this.date = new DateTimeType();
1458        this.date.setValue(value);
1459      return this;
1460    }
1461
1462    /**
1463     * @return {@link #type} (Specifies the particular kind of composition (e.g. History and Physical, Discharge Summary, Progress Note). This usually equates to the purpose of making the composition.)
1464     */
1465    public CodeableConcept getType() { 
1466      if (this.type == null)
1467        if (Configuration.errorOnAutoCreate())
1468          throw new Error("Attempt to auto-create Composition.type");
1469        else if (Configuration.doAutoCreate())
1470          this.type = new CodeableConcept(); // cc
1471      return this.type;
1472    }
1473
1474    public boolean hasType() { 
1475      return this.type != null && !this.type.isEmpty();
1476    }
1477
1478    /**
1479     * @param value {@link #type} (Specifies the particular kind of composition (e.g. History and Physical, Discharge Summary, Progress Note). This usually equates to the purpose of making the composition.)
1480     */
1481    public Composition setType(CodeableConcept value) { 
1482      this.type = value;
1483      return this;
1484    }
1485
1486    /**
1487     * @return {@link #class_} (A categorization for the type of the composition - helps for indexing and searching. This may be implied by or derived from the code specified in the Composition Type.)
1488     */
1489    public CodeableConcept getClass_() { 
1490      if (this.class_ == null)
1491        if (Configuration.errorOnAutoCreate())
1492          throw new Error("Attempt to auto-create Composition.class_");
1493        else if (Configuration.doAutoCreate())
1494          this.class_ = new CodeableConcept(); // cc
1495      return this.class_;
1496    }
1497
1498    public boolean hasClass_() { 
1499      return this.class_ != null && !this.class_.isEmpty();
1500    }
1501
1502    /**
1503     * @param value {@link #class_} (A categorization for the type of the composition - helps for indexing and searching. This may be implied by or derived from the code specified in the Composition Type.)
1504     */
1505    public Composition setClass_(CodeableConcept value) { 
1506      this.class_ = value;
1507      return this;
1508    }
1509
1510    /**
1511     * @return {@link #title} (Official human-readable label for the composition.). This is the underlying object with id, value and extensions. The accessor "getTitle" gives direct access to the value
1512     */
1513    public StringType getTitleElement() { 
1514      if (this.title == null)
1515        if (Configuration.errorOnAutoCreate())
1516          throw new Error("Attempt to auto-create Composition.title");
1517        else if (Configuration.doAutoCreate())
1518          this.title = new StringType(); // bb
1519      return this.title;
1520    }
1521
1522    public boolean hasTitleElement() { 
1523      return this.title != null && !this.title.isEmpty();
1524    }
1525
1526    public boolean hasTitle() { 
1527      return this.title != null && !this.title.isEmpty();
1528    }
1529
1530    /**
1531     * @param value {@link #title} (Official human-readable label for the composition.). This is the underlying object with id, value and extensions. The accessor "getTitle" gives direct access to the value
1532     */
1533    public Composition setTitleElement(StringType value) { 
1534      this.title = value;
1535      return this;
1536    }
1537
1538    /**
1539     * @return Official human-readable label for the composition.
1540     */
1541    public String getTitle() { 
1542      return this.title == null ? null : this.title.getValue();
1543    }
1544
1545    /**
1546     * @param value Official human-readable label for the composition.
1547     */
1548    public Composition setTitle(String value) { 
1549        if (this.title == null)
1550          this.title = new StringType();
1551        this.title.setValue(value);
1552      return this;
1553    }
1554
1555    /**
1556     * @return {@link #status} (The workflow/clinical status of this composition. The status is a marker for the clinical standing of the document.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1557     */
1558    public Enumeration<CompositionStatus> getStatusElement() { 
1559      if (this.status == null)
1560        if (Configuration.errorOnAutoCreate())
1561          throw new Error("Attempt to auto-create Composition.status");
1562        else if (Configuration.doAutoCreate())
1563          this.status = new Enumeration<CompositionStatus>(new CompositionStatusEnumFactory()); // bb
1564      return this.status;
1565    }
1566
1567    public boolean hasStatusElement() { 
1568      return this.status != null && !this.status.isEmpty();
1569    }
1570
1571    public boolean hasStatus() { 
1572      return this.status != null && !this.status.isEmpty();
1573    }
1574
1575    /**
1576     * @param value {@link #status} (The workflow/clinical status of this composition. The status is a marker for the clinical standing of the document.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1577     */
1578    public Composition setStatusElement(Enumeration<CompositionStatus> value) { 
1579      this.status = value;
1580      return this;
1581    }
1582
1583    /**
1584     * @return The workflow/clinical status of this composition. The status is a marker for the clinical standing of the document.
1585     */
1586    public CompositionStatus getStatus() { 
1587      return this.status == null ? null : this.status.getValue();
1588    }
1589
1590    /**
1591     * @param value The workflow/clinical status of this composition. The status is a marker for the clinical standing of the document.
1592     */
1593    public Composition setStatus(CompositionStatus value) { 
1594        if (this.status == null)
1595          this.status = new Enumeration<CompositionStatus>(new CompositionStatusEnumFactory());
1596        this.status.setValue(value);
1597      return this;
1598    }
1599
1600    /**
1601     * @return {@link #confidentiality} (The code specifying the level of confidentiality of the Composition.). This is the underlying object with id, value and extensions. The accessor "getConfidentiality" gives direct access to the value
1602     */
1603    public CodeType getConfidentialityElement() { 
1604      if (this.confidentiality == null)
1605        if (Configuration.errorOnAutoCreate())
1606          throw new Error("Attempt to auto-create Composition.confidentiality");
1607        else if (Configuration.doAutoCreate())
1608          this.confidentiality = new CodeType(); // bb
1609      return this.confidentiality;
1610    }
1611
1612    public boolean hasConfidentialityElement() { 
1613      return this.confidentiality != null && !this.confidentiality.isEmpty();
1614    }
1615
1616    public boolean hasConfidentiality() { 
1617      return this.confidentiality != null && !this.confidentiality.isEmpty();
1618    }
1619
1620    /**
1621     * @param value {@link #confidentiality} (The code specifying the level of confidentiality of the Composition.). This is the underlying object with id, value and extensions. The accessor "getConfidentiality" gives direct access to the value
1622     */
1623    public Composition setConfidentialityElement(CodeType value) { 
1624      this.confidentiality = value;
1625      return this;
1626    }
1627
1628    /**
1629     * @return The code specifying the level of confidentiality of the Composition.
1630     */
1631    public String getConfidentiality() { 
1632      return this.confidentiality == null ? null : this.confidentiality.getValue();
1633    }
1634
1635    /**
1636     * @param value The code specifying the level of confidentiality of the Composition.
1637     */
1638    public Composition setConfidentiality(String value) { 
1639      if (Utilities.noString(value))
1640        this.confidentiality = null;
1641      else {
1642        if (this.confidentiality == null)
1643          this.confidentiality = new CodeType();
1644        this.confidentiality.setValue(value);
1645      }
1646      return this;
1647    }
1648
1649    /**
1650     * @return {@link #subject} (Who or what the composition is about. The composition can be about a person, (patient or healthcare practitioner), a device (e.g. a machine) or even a group of subjects (such as a document about a herd of livestock, or a set of patients that share a common exposure).)
1651     */
1652    public Reference getSubject() { 
1653      if (this.subject == null)
1654        if (Configuration.errorOnAutoCreate())
1655          throw new Error("Attempt to auto-create Composition.subject");
1656        else if (Configuration.doAutoCreate())
1657          this.subject = new Reference(); // cc
1658      return this.subject;
1659    }
1660
1661    public boolean hasSubject() { 
1662      return this.subject != null && !this.subject.isEmpty();
1663    }
1664
1665    /**
1666     * @param value {@link #subject} (Who or what the composition is about. The composition can be about a person, (patient or healthcare practitioner), a device (e.g. a machine) or even a group of subjects (such as a document about a herd of livestock, or a set of patients that share a common exposure).)
1667     */
1668    public Composition setSubject(Reference value) { 
1669      this.subject = value;
1670      return this;
1671    }
1672
1673    /**
1674     * @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. (Who or what the composition is about. The composition can be about a person, (patient or healthcare practitioner), a device (e.g. a machine) or even a group of subjects (such as a document about a herd of livestock, or a set of patients that share a common exposure).)
1675     */
1676    public Resource getSubjectTarget() { 
1677      return this.subjectTarget;
1678    }
1679
1680    /**
1681     * @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. (Who or what the composition is about. The composition can be about a person, (patient or healthcare practitioner), a device (e.g. a machine) or even a group of subjects (such as a document about a herd of livestock, or a set of patients that share a common exposure).)
1682     */
1683    public Composition setSubjectTarget(Resource value) { 
1684      this.subjectTarget = value;
1685      return this;
1686    }
1687
1688    /**
1689     * @return {@link #author} (Identifies who is responsible for the information in the composition, not necessarily who typed it in.)
1690     */
1691    public List<Reference> getAuthor() { 
1692      if (this.author == null)
1693        this.author = new ArrayList<Reference>();
1694      return this.author;
1695    }
1696
1697    public boolean hasAuthor() { 
1698      if (this.author == null)
1699        return false;
1700      for (Reference item : this.author)
1701        if (!item.isEmpty())
1702          return true;
1703      return false;
1704    }
1705
1706    /**
1707     * @return {@link #author} (Identifies who is responsible for the information in the composition, not necessarily who typed it in.)
1708     */
1709    // syntactic sugar
1710    public Reference addAuthor() { //3
1711      Reference t = new Reference();
1712      if (this.author == null)
1713        this.author = new ArrayList<Reference>();
1714      this.author.add(t);
1715      return t;
1716    }
1717
1718    // syntactic sugar
1719    public Composition addAuthor(Reference t) { //3
1720      if (t == null)
1721        return this;
1722      if (this.author == null)
1723        this.author = new ArrayList<Reference>();
1724      this.author.add(t);
1725      return this;
1726    }
1727
1728    /**
1729     * @return {@link #author} (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 who is responsible for the information in the composition, not necessarily who typed it in.)
1730     */
1731    public List<Resource> getAuthorTarget() { 
1732      if (this.authorTarget == null)
1733        this.authorTarget = new ArrayList<Resource>();
1734      return this.authorTarget;
1735    }
1736
1737    /**
1738     * @return {@link #attester} (A participant who has attested to the accuracy of the composition/document.)
1739     */
1740    public List<CompositionAttesterComponent> getAttester() { 
1741      if (this.attester == null)
1742        this.attester = new ArrayList<CompositionAttesterComponent>();
1743      return this.attester;
1744    }
1745
1746    public boolean hasAttester() { 
1747      if (this.attester == null)
1748        return false;
1749      for (CompositionAttesterComponent item : this.attester)
1750        if (!item.isEmpty())
1751          return true;
1752      return false;
1753    }
1754
1755    /**
1756     * @return {@link #attester} (A participant who has attested to the accuracy of the composition/document.)
1757     */
1758    // syntactic sugar
1759    public CompositionAttesterComponent addAttester() { //3
1760      CompositionAttesterComponent t = new CompositionAttesterComponent();
1761      if (this.attester == null)
1762        this.attester = new ArrayList<CompositionAttesterComponent>();
1763      this.attester.add(t);
1764      return t;
1765    }
1766
1767    // syntactic sugar
1768    public Composition addAttester(CompositionAttesterComponent t) { //3
1769      if (t == null)
1770        return this;
1771      if (this.attester == null)
1772        this.attester = new ArrayList<CompositionAttesterComponent>();
1773      this.attester.add(t);
1774      return this;
1775    }
1776
1777    /**
1778     * @return {@link #custodian} (Identifies the organization or group who is responsible for ongoing maintenance of and access to the composition/document information.)
1779     */
1780    public Reference getCustodian() { 
1781      if (this.custodian == null)
1782        if (Configuration.errorOnAutoCreate())
1783          throw new Error("Attempt to auto-create Composition.custodian");
1784        else if (Configuration.doAutoCreate())
1785          this.custodian = new Reference(); // cc
1786      return this.custodian;
1787    }
1788
1789    public boolean hasCustodian() { 
1790      return this.custodian != null && !this.custodian.isEmpty();
1791    }
1792
1793    /**
1794     * @param value {@link #custodian} (Identifies the organization or group who is responsible for ongoing maintenance of and access to the composition/document information.)
1795     */
1796    public Composition setCustodian(Reference value) { 
1797      this.custodian = value;
1798      return this;
1799    }
1800
1801    /**
1802     * @return {@link #custodian} 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. (Identifies the organization or group who is responsible for ongoing maintenance of and access to the composition/document information.)
1803     */
1804    public Organization getCustodianTarget() { 
1805      if (this.custodianTarget == null)
1806        if (Configuration.errorOnAutoCreate())
1807          throw new Error("Attempt to auto-create Composition.custodian");
1808        else if (Configuration.doAutoCreate())
1809          this.custodianTarget = new Organization(); // aa
1810      return this.custodianTarget;
1811    }
1812
1813    /**
1814     * @param value {@link #custodian} 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. (Identifies the organization or group who is responsible for ongoing maintenance of and access to the composition/document information.)
1815     */
1816    public Composition setCustodianTarget(Organization value) { 
1817      this.custodianTarget = value;
1818      return this;
1819    }
1820
1821    /**
1822     * @return {@link #event} (The clinical service, such as a colonoscopy or an appendectomy, being documented.)
1823     */
1824    public List<CompositionEventComponent> getEvent() { 
1825      if (this.event == null)
1826        this.event = new ArrayList<CompositionEventComponent>();
1827      return this.event;
1828    }
1829
1830    public boolean hasEvent() { 
1831      if (this.event == null)
1832        return false;
1833      for (CompositionEventComponent item : this.event)
1834        if (!item.isEmpty())
1835          return true;
1836      return false;
1837    }
1838
1839    /**
1840     * @return {@link #event} (The clinical service, such as a colonoscopy or an appendectomy, being documented.)
1841     */
1842    // syntactic sugar
1843    public CompositionEventComponent addEvent() { //3
1844      CompositionEventComponent t = new CompositionEventComponent();
1845      if (this.event == null)
1846        this.event = new ArrayList<CompositionEventComponent>();
1847      this.event.add(t);
1848      return t;
1849    }
1850
1851    // syntactic sugar
1852    public Composition addEvent(CompositionEventComponent t) { //3
1853      if (t == null)
1854        return this;
1855      if (this.event == null)
1856        this.event = new ArrayList<CompositionEventComponent>();
1857      this.event.add(t);
1858      return this;
1859    }
1860
1861    /**
1862     * @return {@link #encounter} (Describes the clinical encounter or type of care this documentation is associated with.)
1863     */
1864    public Reference getEncounter() { 
1865      if (this.encounter == null)
1866        if (Configuration.errorOnAutoCreate())
1867          throw new Error("Attempt to auto-create Composition.encounter");
1868        else if (Configuration.doAutoCreate())
1869          this.encounter = new Reference(); // cc
1870      return this.encounter;
1871    }
1872
1873    public boolean hasEncounter() { 
1874      return this.encounter != null && !this.encounter.isEmpty();
1875    }
1876
1877    /**
1878     * @param value {@link #encounter} (Describes the clinical encounter or type of care this documentation is associated with.)
1879     */
1880    public Composition setEncounter(Reference value) { 
1881      this.encounter = value;
1882      return this;
1883    }
1884
1885    /**
1886     * @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. (Describes the clinical encounter or type of care this documentation is associated with.)
1887     */
1888    public Encounter getEncounterTarget() { 
1889      if (this.encounterTarget == null)
1890        if (Configuration.errorOnAutoCreate())
1891          throw new Error("Attempt to auto-create Composition.encounter");
1892        else if (Configuration.doAutoCreate())
1893          this.encounterTarget = new Encounter(); // aa
1894      return this.encounterTarget;
1895    }
1896
1897    /**
1898     * @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. (Describes the clinical encounter or type of care this documentation is associated with.)
1899     */
1900    public Composition setEncounterTarget(Encounter value) { 
1901      this.encounterTarget = value;
1902      return this;
1903    }
1904
1905    /**
1906     * @return {@link #section} (The root of the sections that make up the composition.)
1907     */
1908    public List<SectionComponent> getSection() { 
1909      if (this.section == null)
1910        this.section = new ArrayList<SectionComponent>();
1911      return this.section;
1912    }
1913
1914    public boolean hasSection() { 
1915      if (this.section == null)
1916        return false;
1917      for (SectionComponent item : this.section)
1918        if (!item.isEmpty())
1919          return true;
1920      return false;
1921    }
1922
1923    /**
1924     * @return {@link #section} (The root of the sections that make up the composition.)
1925     */
1926    // syntactic sugar
1927    public SectionComponent addSection() { //3
1928      SectionComponent t = new SectionComponent();
1929      if (this.section == null)
1930        this.section = new ArrayList<SectionComponent>();
1931      this.section.add(t);
1932      return t;
1933    }
1934
1935    // syntactic sugar
1936    public Composition addSection(SectionComponent t) { //3
1937      if (t == null)
1938        return this;
1939      if (this.section == null)
1940        this.section = new ArrayList<SectionComponent>();
1941      this.section.add(t);
1942      return this;
1943    }
1944
1945      protected void listChildren(List<Property> childrenList) {
1946        super.listChildren(childrenList);
1947        childrenList.add(new Property("identifier", "Identifier", "Logical identifier for the composition, assigned when created. This identifier stays constant as the composition is changed over time.", 0, java.lang.Integer.MAX_VALUE, identifier));
1948        childrenList.add(new Property("date", "dateTime", "The composition editing time, when the composition was last logically changed by the author.", 0, java.lang.Integer.MAX_VALUE, date));
1949        childrenList.add(new Property("type", "CodeableConcept", "Specifies the particular kind of composition (e.g. History and Physical, Discharge Summary, Progress Note). This usually equates to the purpose of making the composition.", 0, java.lang.Integer.MAX_VALUE, type));
1950        childrenList.add(new Property("class", "CodeableConcept", "A categorization for the type of the composition - helps for indexing and searching. This may be implied by or derived from the code specified in the Composition Type.", 0, java.lang.Integer.MAX_VALUE, class_));
1951        childrenList.add(new Property("title", "string", "Official human-readable label for the composition.", 0, java.lang.Integer.MAX_VALUE, title));
1952        childrenList.add(new Property("status", "code", "The workflow/clinical status of this composition. The status is a marker for the clinical standing of the document.", 0, java.lang.Integer.MAX_VALUE, status));
1953        childrenList.add(new Property("confidentiality", "code", "The code specifying the level of confidentiality of the Composition.", 0, java.lang.Integer.MAX_VALUE, confidentiality));
1954        childrenList.add(new Property("subject", "Reference(Any)", "Who or what the composition is about. The composition can be about a person, (patient or healthcare practitioner), a device (e.g. a machine) or even a group of subjects (such as a document about a herd of livestock, or a set of patients that share a common exposure).", 0, java.lang.Integer.MAX_VALUE, subject));
1955        childrenList.add(new Property("author", "Reference(Practitioner|Device|Patient|RelatedPerson)", "Identifies who is responsible for the information in the composition, not necessarily who typed it in.", 0, java.lang.Integer.MAX_VALUE, author));
1956        childrenList.add(new Property("attester", "", "A participant who has attested to the accuracy of the composition/document.", 0, java.lang.Integer.MAX_VALUE, attester));
1957        childrenList.add(new Property("custodian", "Reference(Organization)", "Identifies the organization or group who is responsible for ongoing maintenance of and access to the composition/document information.", 0, java.lang.Integer.MAX_VALUE, custodian));
1958        childrenList.add(new Property("event", "", "The clinical service, such as a colonoscopy or an appendectomy, being documented.", 0, java.lang.Integer.MAX_VALUE, event));
1959        childrenList.add(new Property("encounter", "Reference(Encounter)", "Describes the clinical encounter or type of care this documentation is associated with.", 0, java.lang.Integer.MAX_VALUE, encounter));
1960        childrenList.add(new Property("section", "", "The root of the sections that make up the composition.", 0, java.lang.Integer.MAX_VALUE, section));
1961      }
1962
1963      @Override
1964      public void setProperty(String name, Base value) throws FHIRException {
1965        if (name.equals("identifier"))
1966          this.identifier = castToIdentifier(value); // Identifier
1967        else if (name.equals("date"))
1968          this.date = castToDateTime(value); // DateTimeType
1969        else if (name.equals("type"))
1970          this.type = castToCodeableConcept(value); // CodeableConcept
1971        else if (name.equals("class"))
1972          this.class_ = castToCodeableConcept(value); // CodeableConcept
1973        else if (name.equals("title"))
1974          this.title = castToString(value); // StringType
1975        else if (name.equals("status"))
1976          this.status = new CompositionStatusEnumFactory().fromType(value); // Enumeration<CompositionStatus>
1977        else if (name.equals("confidentiality"))
1978          this.confidentiality = castToCode(value); // CodeType
1979        else if (name.equals("subject"))
1980          this.subject = castToReference(value); // Reference
1981        else if (name.equals("author"))
1982          this.getAuthor().add(castToReference(value));
1983        else if (name.equals("attester"))
1984          this.getAttester().add((CompositionAttesterComponent) value);
1985        else if (name.equals("custodian"))
1986          this.custodian = castToReference(value); // Reference
1987        else if (name.equals("event"))
1988          this.getEvent().add((CompositionEventComponent) value);
1989        else if (name.equals("encounter"))
1990          this.encounter = castToReference(value); // Reference
1991        else if (name.equals("section"))
1992          this.getSection().add((SectionComponent) value);
1993        else
1994          super.setProperty(name, value);
1995      }
1996
1997      @Override
1998      public Base addChild(String name) throws FHIRException {
1999        if (name.equals("identifier")) {
2000          this.identifier = new Identifier();
2001          return this.identifier;
2002        }
2003        else if (name.equals("date")) {
2004          throw new FHIRException("Cannot call addChild on a primitive type Composition.date");
2005        }
2006        else if (name.equals("type")) {
2007          this.type = new CodeableConcept();
2008          return this.type;
2009        }
2010        else if (name.equals("class")) {
2011          this.class_ = new CodeableConcept();
2012          return this.class_;
2013        }
2014        else if (name.equals("title")) {
2015          throw new FHIRException("Cannot call addChild on a primitive type Composition.title");
2016        }
2017        else if (name.equals("status")) {
2018          throw new FHIRException("Cannot call addChild on a primitive type Composition.status");
2019        }
2020        else if (name.equals("confidentiality")) {
2021          throw new FHIRException("Cannot call addChild on a primitive type Composition.confidentiality");
2022        }
2023        else if (name.equals("subject")) {
2024          this.subject = new Reference();
2025          return this.subject;
2026        }
2027        else if (name.equals("author")) {
2028          return addAuthor();
2029        }
2030        else if (name.equals("attester")) {
2031          return addAttester();
2032        }
2033        else if (name.equals("custodian")) {
2034          this.custodian = new Reference();
2035          return this.custodian;
2036        }
2037        else if (name.equals("event")) {
2038          return addEvent();
2039        }
2040        else if (name.equals("encounter")) {
2041          this.encounter = new Reference();
2042          return this.encounter;
2043        }
2044        else if (name.equals("section")) {
2045          return addSection();
2046        }
2047        else
2048          return super.addChild(name);
2049      }
2050
2051  public String fhirType() {
2052    return "Composition";
2053
2054  }
2055
2056      public Composition copy() {
2057        Composition dst = new Composition();
2058        copyValues(dst);
2059        dst.identifier = identifier == null ? null : identifier.copy();
2060        dst.date = date == null ? null : date.copy();
2061        dst.type = type == null ? null : type.copy();
2062        dst.class_ = class_ == null ? null : class_.copy();
2063        dst.title = title == null ? null : title.copy();
2064        dst.status = status == null ? null : status.copy();
2065        dst.confidentiality = confidentiality == null ? null : confidentiality.copy();
2066        dst.subject = subject == null ? null : subject.copy();
2067        if (author != null) {
2068          dst.author = new ArrayList<Reference>();
2069          for (Reference i : author)
2070            dst.author.add(i.copy());
2071        };
2072        if (attester != null) {
2073          dst.attester = new ArrayList<CompositionAttesterComponent>();
2074          for (CompositionAttesterComponent i : attester)
2075            dst.attester.add(i.copy());
2076        };
2077        dst.custodian = custodian == null ? null : custodian.copy();
2078        if (event != null) {
2079          dst.event = new ArrayList<CompositionEventComponent>();
2080          for (CompositionEventComponent i : event)
2081            dst.event.add(i.copy());
2082        };
2083        dst.encounter = encounter == null ? null : encounter.copy();
2084        if (section != null) {
2085          dst.section = new ArrayList<SectionComponent>();
2086          for (SectionComponent i : section)
2087            dst.section.add(i.copy());
2088        };
2089        return dst;
2090      }
2091
2092      protected Composition typedCopy() {
2093        return copy();
2094      }
2095
2096      @Override
2097      public boolean equalsDeep(Base other) {
2098        if (!super.equalsDeep(other))
2099          return false;
2100        if (!(other instanceof Composition))
2101          return false;
2102        Composition o = (Composition) other;
2103        return compareDeep(identifier, o.identifier, true) && compareDeep(date, o.date, true) && compareDeep(type, o.type, true)
2104           && compareDeep(class_, o.class_, true) && compareDeep(title, o.title, true) && compareDeep(status, o.status, true)
2105           && compareDeep(confidentiality, o.confidentiality, true) && compareDeep(subject, o.subject, true)
2106           && compareDeep(author, o.author, true) && compareDeep(attester, o.attester, true) && compareDeep(custodian, o.custodian, true)
2107           && compareDeep(event, o.event, true) && compareDeep(encounter, o.encounter, true) && compareDeep(section, o.section, true)
2108          ;
2109      }
2110
2111      @Override
2112      public boolean equalsShallow(Base other) {
2113        if (!super.equalsShallow(other))
2114          return false;
2115        if (!(other instanceof Composition))
2116          return false;
2117        Composition o = (Composition) other;
2118        return compareValues(date, o.date, true) && compareValues(title, o.title, true) && compareValues(status, o.status, true)
2119           && compareValues(confidentiality, o.confidentiality, true);
2120      }
2121
2122      public boolean isEmpty() {
2123        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (date == null || date.isEmpty())
2124           && (type == null || type.isEmpty()) && (class_ == null || class_.isEmpty()) && (title == null || title.isEmpty())
2125           && (status == null || status.isEmpty()) && (confidentiality == null || confidentiality.isEmpty())
2126           && (subject == null || subject.isEmpty()) && (author == null || author.isEmpty()) && (attester == null || attester.isEmpty())
2127           && (custodian == null || custodian.isEmpty()) && (event == null || event.isEmpty()) && (encounter == null || encounter.isEmpty())
2128           && (section == null || section.isEmpty());
2129      }
2130
2131  @Override
2132  public ResourceType getResourceType() {
2133    return ResourceType.Composition;
2134   }
2135
2136  @SearchParamDefinition(name="date", path="Composition.date", description="Composition editing time", type="date" )
2137  public static final String SP_DATE = "date";
2138  @SearchParamDefinition(name="identifier", path="Composition.identifier", description="Logical identifier of composition (version-independent)", type="token" )
2139  public static final String SP_IDENTIFIER = "identifier";
2140  @SearchParamDefinition(name="period", path="Composition.event.period", description="The period covered by the documentation", type="date" )
2141  public static final String SP_PERIOD = "period";
2142  @SearchParamDefinition(name="subject", path="Composition.subject", description="Who and/or what the composition is about", type="reference" )
2143  public static final String SP_SUBJECT = "subject";
2144  @SearchParamDefinition(name="author", path="Composition.author", description="Who and/or what authored the composition", type="reference" )
2145  public static final String SP_AUTHOR = "author";
2146  @SearchParamDefinition(name="confidentiality", path="Composition.confidentiality", description="As defined by affinity domain", type="token" )
2147  public static final String SP_CONFIDENTIALITY = "confidentiality";
2148  @SearchParamDefinition(name="section", path="Composition.section.code", description="Classification of section (recommended)", type="token" )
2149  public static final String SP_SECTION = "section";
2150  @SearchParamDefinition(name="encounter", path="Composition.encounter", description="Context of the Composition", type="reference" )
2151  public static final String SP_ENCOUNTER = "encounter";
2152  @SearchParamDefinition(name="type", path="Composition.type", description="Kind of composition (LOINC if possible)", type="token" )
2153  public static final String SP_TYPE = "type";
2154  @SearchParamDefinition(name="title", path="Composition.title", description="Human Readable name/title", type="string" )
2155  public static final String SP_TITLE = "title";
2156  @SearchParamDefinition(name="attester", path="Composition.attester.party", description="Who attested the composition", type="reference" )
2157  public static final String SP_ATTESTER = "attester";
2158  @SearchParamDefinition(name="entry", path="Composition.section.entry", description="A reference to data that supports this section", type="reference" )
2159  public static final String SP_ENTRY = "entry";
2160  @SearchParamDefinition(name="patient", path="Composition.subject", description="Who and/or what the composition is about", type="reference" )
2161  public static final String SP_PATIENT = "patient";
2162  @SearchParamDefinition(name="context", path="Composition.event.code", description="Code(s) that apply to the event being documented", type="token" )
2163  public static final String SP_CONTEXT = "context";
2164  @SearchParamDefinition(name="class", path="Composition.class", description="Categorization of Composition", type="token" )
2165  public static final String SP_CLASS = "class";
2166  @SearchParamDefinition(name="status", path="Composition.status", description="preliminary | final | amended | entered-in-error", type="token" )
2167  public static final String SP_STATUS = "status";
2168
2169}
2170