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