001package org.hl7.fhir.r4.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Thu, Dec 27, 2018 10:06-0500 for FHIR v4.0.0
033
034import java.util.*;
035
036import org.hl7.fhir.utilities.Utilities;
037import ca.uhn.fhir.model.api.annotation.ResourceDef;
038import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
039import ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.ChildOrder;
041import ca.uhn.fhir.model.api.annotation.Description;
042import ca.uhn.fhir.model.api.annotation.Block;
043import org.hl7.fhir.instance.model.api.*;
044import org.hl7.fhir.exceptions.FHIRException;
045/**
046 * A set of healthcare-related information that is assembled together into a single logical package 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. A Composition defines the structure and narrative content necessary for a document. However, a Composition alone does not constitute a document. Rather, the Composition must be the first entry in a Bundle where Bundle.type=document, and any other resources referenced from Composition must be included as subsequent entries in the Bundle (for example Patient, Practitioner, Encounter, etc.).
047 */
048@ResourceDef(name="Composition", profile="http://hl7.org/fhir/StructureDefinition/Composition")
049public class Composition extends DomainResource {
050
051    public enum CompositionStatus {
052        /**
053         * This is a preliminary composition or document (also known as initial or interim). The content may be incomplete or unverified.
054         */
055        PRELIMINARY, 
056        /**
057         * 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.
058         */
059        FINAL, 
060        /**
061         * 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.
062         */
063        AMENDED, 
064        /**
065         * 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.
066         */
067        ENTEREDINERROR, 
068        /**
069         * added to help the parsers with the generic types
070         */
071        NULL;
072        public static CompositionStatus fromCode(String codeString) throws FHIRException {
073            if (codeString == null || "".equals(codeString))
074                return null;
075        if ("preliminary".equals(codeString))
076          return PRELIMINARY;
077        if ("final".equals(codeString))
078          return FINAL;
079        if ("amended".equals(codeString))
080          return AMENDED;
081        if ("entered-in-error".equals(codeString))
082          return ENTEREDINERROR;
083        if (Configuration.isAcceptInvalidEnums())
084          return null;
085        else
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            default: return "?";
095          }
096        }
097        public String getSystem() {
098          switch (this) {
099            case PRELIMINARY: return "http://hl7.org/fhir/composition-status";
100            case FINAL: return "http://hl7.org/fhir/composition-status";
101            case AMENDED: return "http://hl7.org/fhir/composition-status";
102            case ENTEREDINERROR: return "http://hl7.org/fhir/composition-status";
103            default: return "?";
104          }
105        }
106        public String getDefinition() {
107          switch (this) {
108            case PRELIMINARY: return "This is a preliminary composition or document (also known as initial or interim). The content may be incomplete or unverified.";
109            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.";
110            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.";
111            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.";
112            default: return "?";
113          }
114        }
115        public String getDisplay() {
116          switch (this) {
117            case PRELIMINARY: return "Preliminary";
118            case FINAL: return "Final";
119            case AMENDED: return "Amended";
120            case ENTEREDINERROR: return "Entered in Error";
121            default: return "?";
122          }
123        }
124    }
125
126  public static class CompositionStatusEnumFactory implements EnumFactory<CompositionStatus> {
127    public CompositionStatus fromCode(String codeString) throws IllegalArgumentException {
128      if (codeString == null || "".equals(codeString))
129            if (codeString == null || "".equals(codeString))
130                return null;
131        if ("preliminary".equals(codeString))
132          return CompositionStatus.PRELIMINARY;
133        if ("final".equals(codeString))
134          return CompositionStatus.FINAL;
135        if ("amended".equals(codeString))
136          return CompositionStatus.AMENDED;
137        if ("entered-in-error".equals(codeString))
138          return CompositionStatus.ENTEREDINERROR;
139        throw new IllegalArgumentException("Unknown CompositionStatus code '"+codeString+"'");
140        }
141        public Enumeration<CompositionStatus> fromType(Base code) throws FHIRException {
142          if (code == null)
143            return null;
144          if (code.isEmpty())
145            return new Enumeration<CompositionStatus>(this);
146          String codeString = ((PrimitiveType) code).asStringValue();
147          if (codeString == null || "".equals(codeString))
148            return null;
149        if ("preliminary".equals(codeString))
150          return new Enumeration<CompositionStatus>(this, CompositionStatus.PRELIMINARY);
151        if ("final".equals(codeString))
152          return new Enumeration<CompositionStatus>(this, CompositionStatus.FINAL);
153        if ("amended".equals(codeString))
154          return new Enumeration<CompositionStatus>(this, CompositionStatus.AMENDED);
155        if ("entered-in-error".equals(codeString))
156          return new Enumeration<CompositionStatus>(this, CompositionStatus.ENTEREDINERROR);
157        throw new FHIRException("Unknown CompositionStatus code '"+codeString+"'");
158        }
159    public String toCode(CompositionStatus code) {
160      if (code == CompositionStatus.PRELIMINARY)
161        return "preliminary";
162      if (code == CompositionStatus.FINAL)
163        return "final";
164      if (code == CompositionStatus.AMENDED)
165        return "amended";
166      if (code == CompositionStatus.ENTEREDINERROR)
167        return "entered-in-error";
168      return "?";
169      }
170    public String toSystem(CompositionStatus code) {
171      return code.getSystem();
172      }
173    }
174
175    public enum DocumentConfidentiality {
176        /**
177         * null
178         */
179        U, 
180        /**
181         * null
182         */
183        L, 
184        /**
185         * null
186         */
187        M, 
188        /**
189         * null
190         */
191        N, 
192        /**
193         * null
194         */
195        R, 
196        /**
197         * null
198         */
199        V, 
200        /**
201         * added to help the parsers with the generic types
202         */
203        NULL;
204        public static DocumentConfidentiality fromCode(String codeString) throws FHIRException {
205            if (codeString == null || "".equals(codeString))
206                return null;
207        if ("U".equals(codeString))
208          return U;
209        if ("L".equals(codeString))
210          return L;
211        if ("M".equals(codeString))
212          return M;
213        if ("N".equals(codeString))
214          return N;
215        if ("R".equals(codeString))
216          return R;
217        if ("V".equals(codeString))
218          return V;
219        if (Configuration.isAcceptInvalidEnums())
220          return null;
221        else
222          throw new FHIRException("Unknown DocumentConfidentiality code '"+codeString+"'");
223        }
224        public String toCode() {
225          switch (this) {
226            case U: return "U";
227            case L: return "L";
228            case M: return "M";
229            case N: return "N";
230            case R: return "R";
231            case V: return "V";
232            default: return "?";
233          }
234        }
235        public String getSystem() {
236          switch (this) {
237            case U: return "http://terminology.hl7.org/CodeSystem/v3-Confidentiality";
238            case L: return "http://terminology.hl7.org/CodeSystem/v3-Confidentiality";
239            case M: return "http://terminology.hl7.org/CodeSystem/v3-Confidentiality";
240            case N: return "http://terminology.hl7.org/CodeSystem/v3-Confidentiality";
241            case R: return "http://terminology.hl7.org/CodeSystem/v3-Confidentiality";
242            case V: return "http://terminology.hl7.org/CodeSystem/v3-Confidentiality";
243            default: return "?";
244          }
245        }
246        public String getDefinition() {
247          switch (this) {
248            case U: return "";
249            case L: return "";
250            case M: return "";
251            case N: return "";
252            case R: return "";
253            case V: return "";
254            default: return "?";
255          }
256        }
257        public String getDisplay() {
258          switch (this) {
259            case U: return "U";
260            case L: return "L";
261            case M: return "M";
262            case N: return "N";
263            case R: return "R";
264            case V: return "V";
265            default: return "?";
266          }
267        }
268    }
269
270  public static class DocumentConfidentialityEnumFactory implements EnumFactory<DocumentConfidentiality> {
271    public DocumentConfidentiality fromCode(String codeString) throws IllegalArgumentException {
272      if (codeString == null || "".equals(codeString))
273            if (codeString == null || "".equals(codeString))
274                return null;
275        if ("U".equals(codeString))
276          return DocumentConfidentiality.U;
277        if ("L".equals(codeString))
278          return DocumentConfidentiality.L;
279        if ("M".equals(codeString))
280          return DocumentConfidentiality.M;
281        if ("N".equals(codeString))
282          return DocumentConfidentiality.N;
283        if ("R".equals(codeString))
284          return DocumentConfidentiality.R;
285        if ("V".equals(codeString))
286          return DocumentConfidentiality.V;
287        throw new IllegalArgumentException("Unknown DocumentConfidentiality code '"+codeString+"'");
288        }
289        public Enumeration<DocumentConfidentiality> fromType(Base code) throws FHIRException {
290          if (code == null)
291            return null;
292          if (code.isEmpty())
293            return new Enumeration<DocumentConfidentiality>(this);
294          String codeString = ((PrimitiveType) code).asStringValue();
295          if (codeString == null || "".equals(codeString))
296            return null;
297        if ("U".equals(codeString))
298          return new Enumeration<DocumentConfidentiality>(this, DocumentConfidentiality.U);
299        if ("L".equals(codeString))
300          return new Enumeration<DocumentConfidentiality>(this, DocumentConfidentiality.L);
301        if ("M".equals(codeString))
302          return new Enumeration<DocumentConfidentiality>(this, DocumentConfidentiality.M);
303        if ("N".equals(codeString))
304          return new Enumeration<DocumentConfidentiality>(this, DocumentConfidentiality.N);
305        if ("R".equals(codeString))
306          return new Enumeration<DocumentConfidentiality>(this, DocumentConfidentiality.R);
307        if ("V".equals(codeString))
308          return new Enumeration<DocumentConfidentiality>(this, DocumentConfidentiality.V);
309        throw new FHIRException("Unknown DocumentConfidentiality code '"+codeString+"'");
310        }
311    public String toCode(DocumentConfidentiality code) {
312      if (code == DocumentConfidentiality.U)
313        return "U";
314      if (code == DocumentConfidentiality.L)
315        return "L";
316      if (code == DocumentConfidentiality.M)
317        return "M";
318      if (code == DocumentConfidentiality.N)
319        return "N";
320      if (code == DocumentConfidentiality.R)
321        return "R";
322      if (code == DocumentConfidentiality.V)
323        return "V";
324      return "?";
325      }
326    public String toSystem(DocumentConfidentiality code) {
327      return code.getSystem();
328      }
329    }
330
331    public enum CompositionAttestationMode {
332        /**
333         * The person authenticated the content in their personal capacity.
334         */
335        PERSONAL, 
336        /**
337         * The person authenticated the content in their professional capacity.
338         */
339        PROFESSIONAL, 
340        /**
341         * The person authenticated the content and accepted legal responsibility for its content.
342         */
343        LEGAL, 
344        /**
345         * The organization authenticated the content as consistent with their policies and procedures.
346         */
347        OFFICIAL, 
348        /**
349         * added to help the parsers with the generic types
350         */
351        NULL;
352        public static CompositionAttestationMode fromCode(String codeString) throws FHIRException {
353            if (codeString == null || "".equals(codeString))
354                return null;
355        if ("personal".equals(codeString))
356          return PERSONAL;
357        if ("professional".equals(codeString))
358          return PROFESSIONAL;
359        if ("legal".equals(codeString))
360          return LEGAL;
361        if ("official".equals(codeString))
362          return OFFICIAL;
363        if (Configuration.isAcceptInvalidEnums())
364          return null;
365        else
366          throw new FHIRException("Unknown CompositionAttestationMode code '"+codeString+"'");
367        }
368        public String toCode() {
369          switch (this) {
370            case PERSONAL: return "personal";
371            case PROFESSIONAL: return "professional";
372            case LEGAL: return "legal";
373            case OFFICIAL: return "official";
374            default: return "?";
375          }
376        }
377        public String getSystem() {
378          switch (this) {
379            case PERSONAL: return "http://hl7.org/fhir/composition-attestation-mode";
380            case PROFESSIONAL: return "http://hl7.org/fhir/composition-attestation-mode";
381            case LEGAL: return "http://hl7.org/fhir/composition-attestation-mode";
382            case OFFICIAL: return "http://hl7.org/fhir/composition-attestation-mode";
383            default: return "?";
384          }
385        }
386        public String getDefinition() {
387          switch (this) {
388            case PERSONAL: return "The person authenticated the content in their personal capacity.";
389            case PROFESSIONAL: return "The person authenticated the content in their professional capacity.";
390            case LEGAL: return "The person authenticated the content and accepted legal responsibility for its content.";
391            case OFFICIAL: return "The organization authenticated the content as consistent with their policies and procedures.";
392            default: return "?";
393          }
394        }
395        public String getDisplay() {
396          switch (this) {
397            case PERSONAL: return "Personal";
398            case PROFESSIONAL: return "Professional";
399            case LEGAL: return "Legal";
400            case OFFICIAL: return "Official";
401            default: return "?";
402          }
403        }
404    }
405
406  public static class CompositionAttestationModeEnumFactory implements EnumFactory<CompositionAttestationMode> {
407    public CompositionAttestationMode fromCode(String codeString) throws IllegalArgumentException {
408      if (codeString == null || "".equals(codeString))
409            if (codeString == null || "".equals(codeString))
410                return null;
411        if ("personal".equals(codeString))
412          return CompositionAttestationMode.PERSONAL;
413        if ("professional".equals(codeString))
414          return CompositionAttestationMode.PROFESSIONAL;
415        if ("legal".equals(codeString))
416          return CompositionAttestationMode.LEGAL;
417        if ("official".equals(codeString))
418          return CompositionAttestationMode.OFFICIAL;
419        throw new IllegalArgumentException("Unknown CompositionAttestationMode code '"+codeString+"'");
420        }
421        public Enumeration<CompositionAttestationMode> fromType(Base code) throws FHIRException {
422          if (code == null)
423            return null;
424          if (code.isEmpty())
425            return new Enumeration<CompositionAttestationMode>(this);
426          String codeString = ((PrimitiveType) code).asStringValue();
427          if (codeString == null || "".equals(codeString))
428            return null;
429        if ("personal".equals(codeString))
430          return new Enumeration<CompositionAttestationMode>(this, CompositionAttestationMode.PERSONAL);
431        if ("professional".equals(codeString))
432          return new Enumeration<CompositionAttestationMode>(this, CompositionAttestationMode.PROFESSIONAL);
433        if ("legal".equals(codeString))
434          return new Enumeration<CompositionAttestationMode>(this, CompositionAttestationMode.LEGAL);
435        if ("official".equals(codeString))
436          return new Enumeration<CompositionAttestationMode>(this, CompositionAttestationMode.OFFICIAL);
437        throw new FHIRException("Unknown CompositionAttestationMode code '"+codeString+"'");
438        }
439    public String toCode(CompositionAttestationMode code) {
440      if (code == CompositionAttestationMode.PERSONAL)
441        return "personal";
442      if (code == CompositionAttestationMode.PROFESSIONAL)
443        return "professional";
444      if (code == CompositionAttestationMode.LEGAL)
445        return "legal";
446      if (code == CompositionAttestationMode.OFFICIAL)
447        return "official";
448      return "?";
449      }
450    public String toSystem(CompositionAttestationMode code) {
451      return code.getSystem();
452      }
453    }
454
455    public enum DocumentRelationshipType {
456        /**
457         * This document logically replaces or supersedes the target document.
458         */
459        REPLACES, 
460        /**
461         * This document was generated by transforming the target document (e.g. format or language conversion).
462         */
463        TRANSFORMS, 
464        /**
465         * This document is a signature of the target document.
466         */
467        SIGNS, 
468        /**
469         * This document adds additional information to the target document.
470         */
471        APPENDS, 
472        /**
473         * added to help the parsers with the generic types
474         */
475        NULL;
476        public static DocumentRelationshipType fromCode(String codeString) throws FHIRException {
477            if (codeString == null || "".equals(codeString))
478                return null;
479        if ("replaces".equals(codeString))
480          return REPLACES;
481        if ("transforms".equals(codeString))
482          return TRANSFORMS;
483        if ("signs".equals(codeString))
484          return SIGNS;
485        if ("appends".equals(codeString))
486          return APPENDS;
487        if (Configuration.isAcceptInvalidEnums())
488          return null;
489        else
490          throw new FHIRException("Unknown DocumentRelationshipType code '"+codeString+"'");
491        }
492        public String toCode() {
493          switch (this) {
494            case REPLACES: return "replaces";
495            case TRANSFORMS: return "transforms";
496            case SIGNS: return "signs";
497            case APPENDS: return "appends";
498            default: return "?";
499          }
500        }
501        public String getSystem() {
502          switch (this) {
503            case REPLACES: return "http://hl7.org/fhir/document-relationship-type";
504            case TRANSFORMS: return "http://hl7.org/fhir/document-relationship-type";
505            case SIGNS: return "http://hl7.org/fhir/document-relationship-type";
506            case APPENDS: return "http://hl7.org/fhir/document-relationship-type";
507            default: return "?";
508          }
509        }
510        public String getDefinition() {
511          switch (this) {
512            case REPLACES: return "This document logically replaces or supersedes the target document.";
513            case TRANSFORMS: return "This document was generated by transforming the target document (e.g. format or language conversion).";
514            case SIGNS: return "This document is a signature of the target document.";
515            case APPENDS: return "This document adds additional information to the target document.";
516            default: return "?";
517          }
518        }
519        public String getDisplay() {
520          switch (this) {
521            case REPLACES: return "Replaces";
522            case TRANSFORMS: return "Transforms";
523            case SIGNS: return "Signs";
524            case APPENDS: return "Appends";
525            default: return "?";
526          }
527        }
528    }
529
530  public static class DocumentRelationshipTypeEnumFactory implements EnumFactory<DocumentRelationshipType> {
531    public DocumentRelationshipType fromCode(String codeString) throws IllegalArgumentException {
532      if (codeString == null || "".equals(codeString))
533            if (codeString == null || "".equals(codeString))
534                return null;
535        if ("replaces".equals(codeString))
536          return DocumentRelationshipType.REPLACES;
537        if ("transforms".equals(codeString))
538          return DocumentRelationshipType.TRANSFORMS;
539        if ("signs".equals(codeString))
540          return DocumentRelationshipType.SIGNS;
541        if ("appends".equals(codeString))
542          return DocumentRelationshipType.APPENDS;
543        throw new IllegalArgumentException("Unknown DocumentRelationshipType code '"+codeString+"'");
544        }
545        public Enumeration<DocumentRelationshipType> fromType(Base code) throws FHIRException {
546          if (code == null)
547            return null;
548          if (code.isEmpty())
549            return new Enumeration<DocumentRelationshipType>(this);
550          String codeString = ((PrimitiveType) code).asStringValue();
551          if (codeString == null || "".equals(codeString))
552            return null;
553        if ("replaces".equals(codeString))
554          return new Enumeration<DocumentRelationshipType>(this, DocumentRelationshipType.REPLACES);
555        if ("transforms".equals(codeString))
556          return new Enumeration<DocumentRelationshipType>(this, DocumentRelationshipType.TRANSFORMS);
557        if ("signs".equals(codeString))
558          return new Enumeration<DocumentRelationshipType>(this, DocumentRelationshipType.SIGNS);
559        if ("appends".equals(codeString))
560          return new Enumeration<DocumentRelationshipType>(this, DocumentRelationshipType.APPENDS);
561        throw new FHIRException("Unknown DocumentRelationshipType code '"+codeString+"'");
562        }
563    public String toCode(DocumentRelationshipType code) {
564      if (code == DocumentRelationshipType.REPLACES)
565        return "replaces";
566      if (code == DocumentRelationshipType.TRANSFORMS)
567        return "transforms";
568      if (code == DocumentRelationshipType.SIGNS)
569        return "signs";
570      if (code == DocumentRelationshipType.APPENDS)
571        return "appends";
572      return "?";
573      }
574    public String toSystem(DocumentRelationshipType code) {
575      return code.getSystem();
576      }
577    }
578
579    public enum SectionMode {
580        /**
581         * This list is the master list, maintained in an ongoing fashion with regular updates as the real world list it is tracking changes.
582         */
583        WORKING, 
584        /**
585         * This list was prepared as a snapshot. It should not be assumed to be current.
586         */
587        SNAPSHOT, 
588        /**
589         * A point-in-time list that shows what changes have been made or recommended.  E.g. a discharge medication list showing what was added and removed during an encounter.
590         */
591        CHANGES, 
592        /**
593         * added to help the parsers with the generic types
594         */
595        NULL;
596        public static SectionMode fromCode(String codeString) throws FHIRException {
597            if (codeString == null || "".equals(codeString))
598                return null;
599        if ("working".equals(codeString))
600          return WORKING;
601        if ("snapshot".equals(codeString))
602          return SNAPSHOT;
603        if ("changes".equals(codeString))
604          return CHANGES;
605        if (Configuration.isAcceptInvalidEnums())
606          return null;
607        else
608          throw new FHIRException("Unknown SectionMode code '"+codeString+"'");
609        }
610        public String toCode() {
611          switch (this) {
612            case WORKING: return "working";
613            case SNAPSHOT: return "snapshot";
614            case CHANGES: return "changes";
615            default: return "?";
616          }
617        }
618        public String getSystem() {
619          switch (this) {
620            case WORKING: return "http://hl7.org/fhir/list-mode";
621            case SNAPSHOT: return "http://hl7.org/fhir/list-mode";
622            case CHANGES: return "http://hl7.org/fhir/list-mode";
623            default: return "?";
624          }
625        }
626        public String getDefinition() {
627          switch (this) {
628            case WORKING: return "This list is the master list, maintained in an ongoing fashion with regular updates as the real world list it is tracking changes.";
629            case SNAPSHOT: return "This list was prepared as a snapshot. It should not be assumed to be current.";
630            case CHANGES: return "A point-in-time list that shows what changes have been made or recommended.  E.g. a discharge medication list showing what was added and removed during an encounter.";
631            default: return "?";
632          }
633        }
634        public String getDisplay() {
635          switch (this) {
636            case WORKING: return "Working List";
637            case SNAPSHOT: return "Snapshot List";
638            case CHANGES: return "Change List";
639            default: return "?";
640          }
641        }
642    }
643
644  public static class SectionModeEnumFactory implements EnumFactory<SectionMode> {
645    public SectionMode fromCode(String codeString) throws IllegalArgumentException {
646      if (codeString == null || "".equals(codeString))
647            if (codeString == null || "".equals(codeString))
648                return null;
649        if ("working".equals(codeString))
650          return SectionMode.WORKING;
651        if ("snapshot".equals(codeString))
652          return SectionMode.SNAPSHOT;
653        if ("changes".equals(codeString))
654          return SectionMode.CHANGES;
655        throw new IllegalArgumentException("Unknown SectionMode code '"+codeString+"'");
656        }
657        public Enumeration<SectionMode> fromType(Base code) throws FHIRException {
658          if (code == null)
659            return null;
660          if (code.isEmpty())
661            return new Enumeration<SectionMode>(this);
662          String codeString = ((PrimitiveType) code).asStringValue();
663          if (codeString == null || "".equals(codeString))
664            return null;
665        if ("working".equals(codeString))
666          return new Enumeration<SectionMode>(this, SectionMode.WORKING);
667        if ("snapshot".equals(codeString))
668          return new Enumeration<SectionMode>(this, SectionMode.SNAPSHOT);
669        if ("changes".equals(codeString))
670          return new Enumeration<SectionMode>(this, SectionMode.CHANGES);
671        throw new FHIRException("Unknown SectionMode code '"+codeString+"'");
672        }
673    public String toCode(SectionMode code) {
674      if (code == SectionMode.WORKING)
675        return "working";
676      if (code == SectionMode.SNAPSHOT)
677        return "snapshot";
678      if (code == SectionMode.CHANGES)
679        return "changes";
680      return "?";
681      }
682    public String toSystem(SectionMode code) {
683      return code.getSystem();
684      }
685    }
686
687    @Block()
688    public static class CompositionAttesterComponent extends BackboneElement implements IBaseBackboneElement {
689        /**
690         * The type of attestation the authenticator offers.
691         */
692        @Child(name = "mode", type = {CodeType.class}, order=1, min=1, max=1, modifier=false, summary=false)
693        @Description(shortDefinition="personal | professional | legal | official", formalDefinition="The type of attestation the authenticator offers." )
694        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/composition-attestation-mode")
695        protected Enumeration<CompositionAttestationMode> mode;
696
697        /**
698         * When the composition was attested by the party.
699         */
700        @Child(name = "time", type = {DateTimeType.class}, order=2, min=0, max=1, modifier=false, summary=false)
701        @Description(shortDefinition="When the composition was attested", formalDefinition="When the composition was attested by the party." )
702        protected DateTimeType time;
703
704        /**
705         * Who attested the composition in the specified way.
706         */
707        @Child(name = "party", type = {Patient.class, RelatedPerson.class, Practitioner.class, PractitionerRole.class, Organization.class}, order=3, min=0, max=1, modifier=false, summary=false)
708        @Description(shortDefinition="Who attested the composition", formalDefinition="Who attested the composition in the specified way." )
709        protected Reference party;
710
711        /**
712         * The actual object that is the target of the reference (Who attested the composition in the specified way.)
713         */
714        protected Resource partyTarget;
715
716        private static final long serialVersionUID = -1917768205L;
717
718    /**
719     * Constructor
720     */
721      public CompositionAttesterComponent() {
722        super();
723      }
724
725    /**
726     * Constructor
727     */
728      public CompositionAttesterComponent(Enumeration<CompositionAttestationMode> mode) {
729        super();
730        this.mode = mode;
731      }
732
733        /**
734         * @return {@link #mode} (The type of attestation the authenticator offers.). This is the underlying object with id, value and extensions. The accessor "getMode" gives direct access to the value
735         */
736        public Enumeration<CompositionAttestationMode> getModeElement() { 
737          if (this.mode == null)
738            if (Configuration.errorOnAutoCreate())
739              throw new Error("Attempt to auto-create CompositionAttesterComponent.mode");
740            else if (Configuration.doAutoCreate())
741              this.mode = new Enumeration<CompositionAttestationMode>(new CompositionAttestationModeEnumFactory()); // bb
742          return this.mode;
743        }
744
745        public boolean hasModeElement() { 
746          return this.mode != null && !this.mode.isEmpty();
747        }
748
749        public boolean hasMode() { 
750          return this.mode != null && !this.mode.isEmpty();
751        }
752
753        /**
754         * @param value {@link #mode} (The type of attestation the authenticator offers.). This is the underlying object with id, value and extensions. The accessor "getMode" gives direct access to the value
755         */
756        public CompositionAttesterComponent setModeElement(Enumeration<CompositionAttestationMode> value) { 
757          this.mode = value;
758          return this;
759        }
760
761        /**
762         * @return The type of attestation the authenticator offers.
763         */
764        public CompositionAttestationMode getMode() { 
765          return this.mode == null ? null : this.mode.getValue();
766        }
767
768        /**
769         * @param value The type of attestation the authenticator offers.
770         */
771        public CompositionAttesterComponent setMode(CompositionAttestationMode value) { 
772            if (this.mode == null)
773              this.mode = new Enumeration<CompositionAttestationMode>(new CompositionAttestationModeEnumFactory());
774            this.mode.setValue(value);
775          return this;
776        }
777
778        /**
779         * @return {@link #time} (When the 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
780         */
781        public DateTimeType getTimeElement() { 
782          if (this.time == null)
783            if (Configuration.errorOnAutoCreate())
784              throw new Error("Attempt to auto-create CompositionAttesterComponent.time");
785            else if (Configuration.doAutoCreate())
786              this.time = new DateTimeType(); // bb
787          return this.time;
788        }
789
790        public boolean hasTimeElement() { 
791          return this.time != null && !this.time.isEmpty();
792        }
793
794        public boolean hasTime() { 
795          return this.time != null && !this.time.isEmpty();
796        }
797
798        /**
799         * @param value {@link #time} (When the 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
800         */
801        public CompositionAttesterComponent setTimeElement(DateTimeType value) { 
802          this.time = value;
803          return this;
804        }
805
806        /**
807         * @return When the composition was attested by the party.
808         */
809        public Date getTime() { 
810          return this.time == null ? null : this.time.getValue();
811        }
812
813        /**
814         * @param value When the composition was attested by the party.
815         */
816        public CompositionAttesterComponent setTime(Date value) { 
817          if (value == null)
818            this.time = null;
819          else {
820            if (this.time == null)
821              this.time = new DateTimeType();
822            this.time.setValue(value);
823          }
824          return this;
825        }
826
827        /**
828         * @return {@link #party} (Who attested the composition in the specified way.)
829         */
830        public Reference getParty() { 
831          if (this.party == null)
832            if (Configuration.errorOnAutoCreate())
833              throw new Error("Attempt to auto-create CompositionAttesterComponent.party");
834            else if (Configuration.doAutoCreate())
835              this.party = new Reference(); // cc
836          return this.party;
837        }
838
839        public boolean hasParty() { 
840          return this.party != null && !this.party.isEmpty();
841        }
842
843        /**
844         * @param value {@link #party} (Who attested the composition in the specified way.)
845         */
846        public CompositionAttesterComponent setParty(Reference value) { 
847          this.party = value;
848          return this;
849        }
850
851        /**
852         * @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.)
853         */
854        public Resource getPartyTarget() { 
855          return this.partyTarget;
856        }
857
858        /**
859         * @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.)
860         */
861        public CompositionAttesterComponent setPartyTarget(Resource value) { 
862          this.partyTarget = value;
863          return this;
864        }
865
866        protected void listChildren(List<Property> children) {
867          super.listChildren(children);
868          children.add(new Property("mode", "code", "The type of attestation the authenticator offers.", 0, 1, mode));
869          children.add(new Property("time", "dateTime", "When the composition was attested by the party.", 0, 1, time));
870          children.add(new Property("party", "Reference(Patient|RelatedPerson|Practitioner|PractitionerRole|Organization)", "Who attested the composition in the specified way.", 0, 1, party));
871        }
872
873        @Override
874        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
875          switch (_hash) {
876          case 3357091: /*mode*/  return new Property("mode", "code", "The type of attestation the authenticator offers.", 0, 1, mode);
877          case 3560141: /*time*/  return new Property("time", "dateTime", "When the composition was attested by the party.", 0, 1, time);
878          case 106437350: /*party*/  return new Property("party", "Reference(Patient|RelatedPerson|Practitioner|PractitionerRole|Organization)", "Who attested the composition in the specified way.", 0, 1, party);
879          default: return super.getNamedProperty(_hash, _name, _checkValid);
880          }
881
882        }
883
884      @Override
885      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
886        switch (hash) {
887        case 3357091: /*mode*/ return this.mode == null ? new Base[0] : new Base[] {this.mode}; // Enumeration<CompositionAttestationMode>
888        case 3560141: /*time*/ return this.time == null ? new Base[0] : new Base[] {this.time}; // DateTimeType
889        case 106437350: /*party*/ return this.party == null ? new Base[0] : new Base[] {this.party}; // Reference
890        default: return super.getProperty(hash, name, checkValid);
891        }
892
893      }
894
895      @Override
896      public Base setProperty(int hash, String name, Base value) throws FHIRException {
897        switch (hash) {
898        case 3357091: // mode
899          value = new CompositionAttestationModeEnumFactory().fromType(castToCode(value));
900          this.mode = (Enumeration) value; // Enumeration<CompositionAttestationMode>
901          return value;
902        case 3560141: // time
903          this.time = castToDateTime(value); // DateTimeType
904          return value;
905        case 106437350: // party
906          this.party = castToReference(value); // Reference
907          return value;
908        default: return super.setProperty(hash, name, value);
909        }
910
911      }
912
913      @Override
914      public Base setProperty(String name, Base value) throws FHIRException {
915        if (name.equals("mode")) {
916          value = new CompositionAttestationModeEnumFactory().fromType(castToCode(value));
917          this.mode = (Enumeration) value; // Enumeration<CompositionAttestationMode>
918        } else if (name.equals("time")) {
919          this.time = castToDateTime(value); // DateTimeType
920        } else if (name.equals("party")) {
921          this.party = castToReference(value); // Reference
922        } else
923          return super.setProperty(name, value);
924        return value;
925      }
926
927      @Override
928      public Base makeProperty(int hash, String name) throws FHIRException {
929        switch (hash) {
930        case 3357091:  return getModeElement();
931        case 3560141:  return getTimeElement();
932        case 106437350:  return getParty(); 
933        default: return super.makeProperty(hash, name);
934        }
935
936      }
937
938      @Override
939      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
940        switch (hash) {
941        case 3357091: /*mode*/ return new String[] {"code"};
942        case 3560141: /*time*/ return new String[] {"dateTime"};
943        case 106437350: /*party*/ return new String[] {"Reference"};
944        default: return super.getTypesForProperty(hash, name);
945        }
946
947      }
948
949      @Override
950      public Base addChild(String name) throws FHIRException {
951        if (name.equals("mode")) {
952          throw new FHIRException("Cannot call addChild on a primitive type Composition.mode");
953        }
954        else if (name.equals("time")) {
955          throw new FHIRException("Cannot call addChild on a primitive type Composition.time");
956        }
957        else if (name.equals("party")) {
958          this.party = new Reference();
959          return this.party;
960        }
961        else
962          return super.addChild(name);
963      }
964
965      public CompositionAttesterComponent copy() {
966        CompositionAttesterComponent dst = new CompositionAttesterComponent();
967        copyValues(dst);
968        dst.mode = mode == null ? null : mode.copy();
969        dst.time = time == null ? null : time.copy();
970        dst.party = party == null ? null : party.copy();
971        return dst;
972      }
973
974      @Override
975      public boolean equalsDeep(Base other_) {
976        if (!super.equalsDeep(other_))
977          return false;
978        if (!(other_ instanceof CompositionAttesterComponent))
979          return false;
980        CompositionAttesterComponent o = (CompositionAttesterComponent) other_;
981        return compareDeep(mode, o.mode, true) && compareDeep(time, o.time, true) && compareDeep(party, o.party, true)
982          ;
983      }
984
985      @Override
986      public boolean equalsShallow(Base other_) {
987        if (!super.equalsShallow(other_))
988          return false;
989        if (!(other_ instanceof CompositionAttesterComponent))
990          return false;
991        CompositionAttesterComponent o = (CompositionAttesterComponent) other_;
992        return compareValues(mode, o.mode, true) && compareValues(time, o.time, true);
993      }
994
995      public boolean isEmpty() {
996        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(mode, time, party);
997      }
998
999  public String fhirType() {
1000    return "Composition.attester";
1001
1002  }
1003
1004  }
1005
1006    @Block()
1007    public static class CompositionRelatesToComponent extends BackboneElement implements IBaseBackboneElement {
1008        /**
1009         * The type of relationship that this composition has with anther composition or document.
1010         */
1011        @Child(name = "code", type = {CodeType.class}, order=1, min=1, max=1, modifier=false, summary=false)
1012        @Description(shortDefinition="replaces | transforms | signs | appends", formalDefinition="The type of relationship that this composition has with anther composition or document." )
1013        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/document-relationship-type")
1014        protected Enumeration<DocumentRelationshipType> code;
1015
1016        /**
1017         * The target composition/document of this relationship.
1018         */
1019        @Child(name = "target", type = {Identifier.class, Composition.class}, order=2, min=1, max=1, modifier=false, summary=false)
1020        @Description(shortDefinition="Target of the relationship", formalDefinition="The target composition/document of this relationship." )
1021        protected Type target;
1022
1023        private static final long serialVersionUID = 1536930280L;
1024
1025    /**
1026     * Constructor
1027     */
1028      public CompositionRelatesToComponent() {
1029        super();
1030      }
1031
1032    /**
1033     * Constructor
1034     */
1035      public CompositionRelatesToComponent(Enumeration<DocumentRelationshipType> code, Type target) {
1036        super();
1037        this.code = code;
1038        this.target = target;
1039      }
1040
1041        /**
1042         * @return {@link #code} (The type of relationship that this composition has with anther composition or document.). This is the underlying object with id, value and extensions. The accessor "getCode" gives direct access to the value
1043         */
1044        public Enumeration<DocumentRelationshipType> getCodeElement() { 
1045          if (this.code == null)
1046            if (Configuration.errorOnAutoCreate())
1047              throw new Error("Attempt to auto-create CompositionRelatesToComponent.code");
1048            else if (Configuration.doAutoCreate())
1049              this.code = new Enumeration<DocumentRelationshipType>(new DocumentRelationshipTypeEnumFactory()); // bb
1050          return this.code;
1051        }
1052
1053        public boolean hasCodeElement() { 
1054          return this.code != null && !this.code.isEmpty();
1055        }
1056
1057        public boolean hasCode() { 
1058          return this.code != null && !this.code.isEmpty();
1059        }
1060
1061        /**
1062         * @param value {@link #code} (The type of relationship that this composition has with anther composition or document.). This is the underlying object with id, value and extensions. The accessor "getCode" gives direct access to the value
1063         */
1064        public CompositionRelatesToComponent setCodeElement(Enumeration<DocumentRelationshipType> value) { 
1065          this.code = value;
1066          return this;
1067        }
1068
1069        /**
1070         * @return The type of relationship that this composition has with anther composition or document.
1071         */
1072        public DocumentRelationshipType getCode() { 
1073          return this.code == null ? null : this.code.getValue();
1074        }
1075
1076        /**
1077         * @param value The type of relationship that this composition has with anther composition or document.
1078         */
1079        public CompositionRelatesToComponent setCode(DocumentRelationshipType value) { 
1080            if (this.code == null)
1081              this.code = new Enumeration<DocumentRelationshipType>(new DocumentRelationshipTypeEnumFactory());
1082            this.code.setValue(value);
1083          return this;
1084        }
1085
1086        /**
1087         * @return {@link #target} (The target composition/document of this relationship.)
1088         */
1089        public Type getTarget() { 
1090          return this.target;
1091        }
1092
1093        /**
1094         * @return {@link #target} (The target composition/document of this relationship.)
1095         */
1096        public Identifier getTargetIdentifier() throws FHIRException { 
1097          if (this.target == null)
1098            this.target = new Identifier();
1099          if (!(this.target instanceof Identifier))
1100            throw new FHIRException("Type mismatch: the type Identifier was expected, but "+this.target.getClass().getName()+" was encountered");
1101          return (Identifier) this.target;
1102        }
1103
1104        public boolean hasTargetIdentifier() { 
1105          return this != null && this.target instanceof Identifier;
1106        }
1107
1108        /**
1109         * @return {@link #target} (The target composition/document of this relationship.)
1110         */
1111        public Reference getTargetReference() throws FHIRException { 
1112          if (this.target == null)
1113            this.target = new Reference();
1114          if (!(this.target instanceof Reference))
1115            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.target.getClass().getName()+" was encountered");
1116          return (Reference) this.target;
1117        }
1118
1119        public boolean hasTargetReference() { 
1120          return this != null && this.target instanceof Reference;
1121        }
1122
1123        public boolean hasTarget() { 
1124          return this.target != null && !this.target.isEmpty();
1125        }
1126
1127        /**
1128         * @param value {@link #target} (The target composition/document of this relationship.)
1129         */
1130        public CompositionRelatesToComponent setTarget(Type value) { 
1131          if (value != null && !(value instanceof Identifier || value instanceof Reference))
1132            throw new Error("Not the right type for Composition.relatesTo.target[x]: "+value.fhirType());
1133          this.target = value;
1134          return this;
1135        }
1136
1137        protected void listChildren(List<Property> children) {
1138          super.listChildren(children);
1139          children.add(new Property("code", "code", "The type of relationship that this composition has with anther composition or document.", 0, 1, code));
1140          children.add(new Property("target[x]", "Identifier|Reference(Composition)", "The target composition/document of this relationship.", 0, 1, target));
1141        }
1142
1143        @Override
1144        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1145          switch (_hash) {
1146          case 3059181: /*code*/  return new Property("code", "code", "The type of relationship that this composition has with anther composition or document.", 0, 1, code);
1147          case -815579825: /*target[x]*/  return new Property("target[x]", "Identifier|Reference(Composition)", "The target composition/document of this relationship.", 0, 1, target);
1148          case -880905839: /*target*/  return new Property("target[x]", "Identifier|Reference(Composition)", "The target composition/document of this relationship.", 0, 1, target);
1149          case 1690892570: /*targetIdentifier*/  return new Property("target[x]", "Identifier|Reference(Composition)", "The target composition/document of this relationship.", 0, 1, target);
1150          case 1259806906: /*targetReference*/  return new Property("target[x]", "Identifier|Reference(Composition)", "The target composition/document of this relationship.", 0, 1, target);
1151          default: return super.getNamedProperty(_hash, _name, _checkValid);
1152          }
1153
1154        }
1155
1156      @Override
1157      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1158        switch (hash) {
1159        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // Enumeration<DocumentRelationshipType>
1160        case -880905839: /*target*/ return this.target == null ? new Base[0] : new Base[] {this.target}; // Type
1161        default: return super.getProperty(hash, name, checkValid);
1162        }
1163
1164      }
1165
1166      @Override
1167      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1168        switch (hash) {
1169        case 3059181: // code
1170          value = new DocumentRelationshipTypeEnumFactory().fromType(castToCode(value));
1171          this.code = (Enumeration) value; // Enumeration<DocumentRelationshipType>
1172          return value;
1173        case -880905839: // target
1174          this.target = castToType(value); // Type
1175          return value;
1176        default: return super.setProperty(hash, name, value);
1177        }
1178
1179      }
1180
1181      @Override
1182      public Base setProperty(String name, Base value) throws FHIRException {
1183        if (name.equals("code")) {
1184          value = new DocumentRelationshipTypeEnumFactory().fromType(castToCode(value));
1185          this.code = (Enumeration) value; // Enumeration<DocumentRelationshipType>
1186        } else if (name.equals("target[x]")) {
1187          this.target = castToType(value); // Type
1188        } else
1189          return super.setProperty(name, value);
1190        return value;
1191      }
1192
1193      @Override
1194      public Base makeProperty(int hash, String name) throws FHIRException {
1195        switch (hash) {
1196        case 3059181:  return getCodeElement();
1197        case -815579825:  return getTarget(); 
1198        case -880905839:  return getTarget(); 
1199        default: return super.makeProperty(hash, name);
1200        }
1201
1202      }
1203
1204      @Override
1205      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1206        switch (hash) {
1207        case 3059181: /*code*/ return new String[] {"code"};
1208        case -880905839: /*target*/ return new String[] {"Identifier", "Reference"};
1209        default: return super.getTypesForProperty(hash, name);
1210        }
1211
1212      }
1213
1214      @Override
1215      public Base addChild(String name) throws FHIRException {
1216        if (name.equals("code")) {
1217          throw new FHIRException("Cannot call addChild on a primitive type Composition.code");
1218        }
1219        else if (name.equals("targetIdentifier")) {
1220          this.target = new Identifier();
1221          return this.target;
1222        }
1223        else if (name.equals("targetReference")) {
1224          this.target = new Reference();
1225          return this.target;
1226        }
1227        else
1228          return super.addChild(name);
1229      }
1230
1231      public CompositionRelatesToComponent copy() {
1232        CompositionRelatesToComponent dst = new CompositionRelatesToComponent();
1233        copyValues(dst);
1234        dst.code = code == null ? null : code.copy();
1235        dst.target = target == null ? null : target.copy();
1236        return dst;
1237      }
1238
1239      @Override
1240      public boolean equalsDeep(Base other_) {
1241        if (!super.equalsDeep(other_))
1242          return false;
1243        if (!(other_ instanceof CompositionRelatesToComponent))
1244          return false;
1245        CompositionRelatesToComponent o = (CompositionRelatesToComponent) other_;
1246        return compareDeep(code, o.code, true) && compareDeep(target, o.target, true);
1247      }
1248
1249      @Override
1250      public boolean equalsShallow(Base other_) {
1251        if (!super.equalsShallow(other_))
1252          return false;
1253        if (!(other_ instanceof CompositionRelatesToComponent))
1254          return false;
1255        CompositionRelatesToComponent o = (CompositionRelatesToComponent) other_;
1256        return compareValues(code, o.code, true);
1257      }
1258
1259      public boolean isEmpty() {
1260        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(code, target);
1261      }
1262
1263  public String fhirType() {
1264    return "Composition.relatesTo";
1265
1266  }
1267
1268  }
1269
1270    @Block()
1271    public static class CompositionEventComponent extends BackboneElement implements IBaseBackboneElement {
1272        /**
1273         * 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.
1274         */
1275        @Child(name = "code", type = {CodeableConcept.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1276        @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." )
1277        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://terminology.hl7.org/ValueSet/v3-ActCode")
1278        protected List<CodeableConcept> code;
1279
1280        /**
1281         * 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.
1282         */
1283        @Child(name = "period", type = {Period.class}, order=2, min=0, max=1, modifier=false, summary=true)
1284        @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." )
1285        protected Period period;
1286
1287        /**
1288         * 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.
1289         */
1290        @Child(name = "detail", type = {Reference.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1291        @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." )
1292        protected List<Reference> detail;
1293        /**
1294         * 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.)
1295         */
1296        protected List<Resource> detailTarget;
1297
1298
1299        private static final long serialVersionUID = -1581379774L;
1300
1301    /**
1302     * Constructor
1303     */
1304      public CompositionEventComponent() {
1305        super();
1306      }
1307
1308        /**
1309         * @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.)
1310         */
1311        public List<CodeableConcept> getCode() { 
1312          if (this.code == null)
1313            this.code = new ArrayList<CodeableConcept>();
1314          return this.code;
1315        }
1316
1317        /**
1318         * @return Returns a reference to <code>this</code> for easy method chaining
1319         */
1320        public CompositionEventComponent setCode(List<CodeableConcept> theCode) { 
1321          this.code = theCode;
1322          return this;
1323        }
1324
1325        public boolean hasCode() { 
1326          if (this.code == null)
1327            return false;
1328          for (CodeableConcept item : this.code)
1329            if (!item.isEmpty())
1330              return true;
1331          return false;
1332        }
1333
1334        public CodeableConcept addCode() { //3
1335          CodeableConcept t = new CodeableConcept();
1336          if (this.code == null)
1337            this.code = new ArrayList<CodeableConcept>();
1338          this.code.add(t);
1339          return t;
1340        }
1341
1342        public CompositionEventComponent addCode(CodeableConcept t) { //3
1343          if (t == null)
1344            return this;
1345          if (this.code == null)
1346            this.code = new ArrayList<CodeableConcept>();
1347          this.code.add(t);
1348          return this;
1349        }
1350
1351        /**
1352         * @return The first repetition of repeating field {@link #code}, creating it if it does not already exist
1353         */
1354        public CodeableConcept getCodeFirstRep() { 
1355          if (getCode().isEmpty()) {
1356            addCode();
1357          }
1358          return getCode().get(0);
1359        }
1360
1361        /**
1362         * @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.)
1363         */
1364        public Period getPeriod() { 
1365          if (this.period == null)
1366            if (Configuration.errorOnAutoCreate())
1367              throw new Error("Attempt to auto-create CompositionEventComponent.period");
1368            else if (Configuration.doAutoCreate())
1369              this.period = new Period(); // cc
1370          return this.period;
1371        }
1372
1373        public boolean hasPeriod() { 
1374          return this.period != null && !this.period.isEmpty();
1375        }
1376
1377        /**
1378         * @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.)
1379         */
1380        public CompositionEventComponent setPeriod(Period value) { 
1381          this.period = value;
1382          return this;
1383        }
1384
1385        /**
1386         * @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.)
1387         */
1388        public List<Reference> getDetail() { 
1389          if (this.detail == null)
1390            this.detail = new ArrayList<Reference>();
1391          return this.detail;
1392        }
1393
1394        /**
1395         * @return Returns a reference to <code>this</code> for easy method chaining
1396         */
1397        public CompositionEventComponent setDetail(List<Reference> theDetail) { 
1398          this.detail = theDetail;
1399          return this;
1400        }
1401
1402        public boolean hasDetail() { 
1403          if (this.detail == null)
1404            return false;
1405          for (Reference item : this.detail)
1406            if (!item.isEmpty())
1407              return true;
1408          return false;
1409        }
1410
1411        public Reference addDetail() { //3
1412          Reference t = new Reference();
1413          if (this.detail == null)
1414            this.detail = new ArrayList<Reference>();
1415          this.detail.add(t);
1416          return t;
1417        }
1418
1419        public CompositionEventComponent addDetail(Reference t) { //3
1420          if (t == null)
1421            return this;
1422          if (this.detail == null)
1423            this.detail = new ArrayList<Reference>();
1424          this.detail.add(t);
1425          return this;
1426        }
1427
1428        /**
1429         * @return The first repetition of repeating field {@link #detail}, creating it if it does not already exist
1430         */
1431        public Reference getDetailFirstRep() { 
1432          if (getDetail().isEmpty()) {
1433            addDetail();
1434          }
1435          return getDetail().get(0);
1436        }
1437
1438        /**
1439         * @deprecated Use Reference#setResource(IBaseResource) instead
1440         */
1441        @Deprecated
1442        public List<Resource> getDetailTarget() { 
1443          if (this.detailTarget == null)
1444            this.detailTarget = new ArrayList<Resource>();
1445          return this.detailTarget;
1446        }
1447
1448        protected void listChildren(List<Property> children) {
1449          super.listChildren(children);
1450          children.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));
1451          children.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, 1, period));
1452          children.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));
1453        }
1454
1455        @Override
1456        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1457          switch (_hash) {
1458          case 3059181: /*code*/  return 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);
1459          case -991726143: /*period*/  return 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, 1, period);
1460          case -1335224239: /*detail*/  return 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);
1461          default: return super.getNamedProperty(_hash, _name, _checkValid);
1462          }
1463
1464        }
1465
1466      @Override
1467      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1468        switch (hash) {
1469        case 3059181: /*code*/ return this.code == null ? new Base[0] : this.code.toArray(new Base[this.code.size()]); // CodeableConcept
1470        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
1471        case -1335224239: /*detail*/ return this.detail == null ? new Base[0] : this.detail.toArray(new Base[this.detail.size()]); // Reference
1472        default: return super.getProperty(hash, name, checkValid);
1473        }
1474
1475      }
1476
1477      @Override
1478      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1479        switch (hash) {
1480        case 3059181: // code
1481          this.getCode().add(castToCodeableConcept(value)); // CodeableConcept
1482          return value;
1483        case -991726143: // period
1484          this.period = castToPeriod(value); // Period
1485          return value;
1486        case -1335224239: // detail
1487          this.getDetail().add(castToReference(value)); // Reference
1488          return value;
1489        default: return super.setProperty(hash, name, value);
1490        }
1491
1492      }
1493
1494      @Override
1495      public Base setProperty(String name, Base value) throws FHIRException {
1496        if (name.equals("code")) {
1497          this.getCode().add(castToCodeableConcept(value));
1498        } else if (name.equals("period")) {
1499          this.period = castToPeriod(value); // Period
1500        } else if (name.equals("detail")) {
1501          this.getDetail().add(castToReference(value));
1502        } else
1503          return super.setProperty(name, value);
1504        return value;
1505      }
1506
1507      @Override
1508      public Base makeProperty(int hash, String name) throws FHIRException {
1509        switch (hash) {
1510        case 3059181:  return addCode(); 
1511        case -991726143:  return getPeriod(); 
1512        case -1335224239:  return addDetail(); 
1513        default: return super.makeProperty(hash, name);
1514        }
1515
1516      }
1517
1518      @Override
1519      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1520        switch (hash) {
1521        case 3059181: /*code*/ return new String[] {"CodeableConcept"};
1522        case -991726143: /*period*/ return new String[] {"Period"};
1523        case -1335224239: /*detail*/ return new String[] {"Reference"};
1524        default: return super.getTypesForProperty(hash, name);
1525        }
1526
1527      }
1528
1529      @Override
1530      public Base addChild(String name) throws FHIRException {
1531        if (name.equals("code")) {
1532          return addCode();
1533        }
1534        else if (name.equals("period")) {
1535          this.period = new Period();
1536          return this.period;
1537        }
1538        else if (name.equals("detail")) {
1539          return addDetail();
1540        }
1541        else
1542          return super.addChild(name);
1543      }
1544
1545      public CompositionEventComponent copy() {
1546        CompositionEventComponent dst = new CompositionEventComponent();
1547        copyValues(dst);
1548        if (code != null) {
1549          dst.code = new ArrayList<CodeableConcept>();
1550          for (CodeableConcept i : code)
1551            dst.code.add(i.copy());
1552        };
1553        dst.period = period == null ? null : period.copy();
1554        if (detail != null) {
1555          dst.detail = new ArrayList<Reference>();
1556          for (Reference i : detail)
1557            dst.detail.add(i.copy());
1558        };
1559        return dst;
1560      }
1561
1562      @Override
1563      public boolean equalsDeep(Base other_) {
1564        if (!super.equalsDeep(other_))
1565          return false;
1566        if (!(other_ instanceof CompositionEventComponent))
1567          return false;
1568        CompositionEventComponent o = (CompositionEventComponent) other_;
1569        return compareDeep(code, o.code, true) && compareDeep(period, o.period, true) && compareDeep(detail, o.detail, true)
1570          ;
1571      }
1572
1573      @Override
1574      public boolean equalsShallow(Base other_) {
1575        if (!super.equalsShallow(other_))
1576          return false;
1577        if (!(other_ instanceof CompositionEventComponent))
1578          return false;
1579        CompositionEventComponent o = (CompositionEventComponent) other_;
1580        return true;
1581      }
1582
1583      public boolean isEmpty() {
1584        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(code, period, detail);
1585      }
1586
1587  public String fhirType() {
1588    return "Composition.event";
1589
1590  }
1591
1592  }
1593
1594    @Block()
1595    public static class SectionComponent extends BackboneElement implements IBaseBackboneElement {
1596        /**
1597         * 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.
1598         */
1599        @Child(name = "title", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=false)
1600        @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." )
1601        protected StringType title;
1602
1603        /**
1604         * A code identifying the kind of content contained within the section. This must be consistent with the section title.
1605         */
1606        @Child(name = "code", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
1607        @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." )
1608        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/doc-section-codes")
1609        protected CodeableConcept code;
1610
1611        /**
1612         * Identifies who is responsible for the information in this section, not necessarily who typed it in.
1613         */
1614        @Child(name = "author", type = {Practitioner.class, PractitionerRole.class, Device.class, Patient.class, RelatedPerson.class, Organization.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1615        @Description(shortDefinition="Who and/or what authored the section", formalDefinition="Identifies who is responsible for the information in this section, not necessarily who typed it in." )
1616        protected List<Reference> author;
1617        /**
1618         * The actual objects that are the target of the reference (Identifies who is responsible for the information in this section, not necessarily who typed it in.)
1619         */
1620        protected List<Resource> authorTarget;
1621
1622
1623        /**
1624         * The actual focus of the section when it is not the subject of the composition, but instead represents something or someone associated with the subject such as (for a patient subject) a spouse, parent, fetus, or donor. If not focus is specified, the focus is assumed to be focus of the parent section, or, for a section in the Composition itself, the subject of the composition. Sections with a focus SHALL only include resources where the logical subject (patient, subject, focus, etc.) matches the section focus, or the resources have no logical subject (few resources).
1625         */
1626        @Child(name = "focus", type = {Reference.class}, order=4, min=0, max=1, modifier=false, summary=false)
1627        @Description(shortDefinition="Who/what the section is about, when it is not about the subject of composition", formalDefinition="The actual focus of the section when it is not the subject of the composition, but instead represents something or someone associated with the subject such as (for a patient subject) a spouse, parent, fetus, or donor. If not focus is specified, the focus is assumed to be focus of the parent section, or, for a section in the Composition itself, the subject of the composition. Sections with a focus SHALL only include resources where the logical subject (patient, subject, focus, etc.) matches the section focus, or the resources have no logical subject (few resources)." )
1628        protected Reference focus;
1629
1630        /**
1631         * The actual object that is the target of the reference (The actual focus of the section when it is not the subject of the composition, but instead represents something or someone associated with the subject such as (for a patient subject) a spouse, parent, fetus, or donor. If not focus is specified, the focus is assumed to be focus of the parent section, or, for a section in the Composition itself, the subject of the composition. Sections with a focus SHALL only include resources where the logical subject (patient, subject, focus, etc.) matches the section focus, or the resources have no logical subject (few resources).)
1632         */
1633        protected Resource focusTarget;
1634
1635        /**
1636         * 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.
1637         */
1638        @Child(name = "text", type = {Narrative.class}, order=5, min=0, max=1, modifier=false, summary=false)
1639        @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." )
1640        protected Narrative text;
1641
1642        /**
1643         * 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.
1644         */
1645        @Child(name = "mode", type = {CodeType.class}, order=6, min=0, max=1, modifier=false, summary=false)
1646        @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." )
1647        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/list-mode")
1648        protected Enumeration<SectionMode> mode;
1649
1650        /**
1651         * Specifies the order applied to the items in the section entries.
1652         */
1653        @Child(name = "orderedBy", type = {CodeableConcept.class}, order=7, min=0, max=1, modifier=false, summary=false)
1654        @Description(shortDefinition="Order of section entries", formalDefinition="Specifies the order applied to the items in the section entries." )
1655        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/list-order")
1656        protected CodeableConcept orderedBy;
1657
1658        /**
1659         * A reference to the actual resource from which the narrative in the section is derived.
1660         */
1661        @Child(name = "entry", type = {Reference.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1662        @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." )
1663        protected List<Reference> entry;
1664        /**
1665         * 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.)
1666         */
1667        protected List<Resource> entryTarget;
1668
1669
1670        /**
1671         * If the section is empty, why the list is empty. An empty section typically has some text explaining the empty reason.
1672         */
1673        @Child(name = "emptyReason", type = {CodeableConcept.class}, order=9, min=0, max=1, modifier=false, summary=false)
1674        @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." )
1675        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/list-empty-reason")
1676        protected CodeableConcept emptyReason;
1677
1678        /**
1679         * A nested sub-section within this section.
1680         */
1681        @Child(name = "section", type = {SectionComponent.class}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1682        @Description(shortDefinition="Nested Section", formalDefinition="A nested sub-section within this section." )
1683        protected List<SectionComponent> section;
1684
1685        private static final long serialVersionUID = -797396954L;
1686
1687    /**
1688     * Constructor
1689     */
1690      public SectionComponent() {
1691        super();
1692      }
1693
1694        /**
1695         * @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
1696         */
1697        public StringType getTitleElement() { 
1698          if (this.title == null)
1699            if (Configuration.errorOnAutoCreate())
1700              throw new Error("Attempt to auto-create SectionComponent.title");
1701            else if (Configuration.doAutoCreate())
1702              this.title = new StringType(); // bb
1703          return this.title;
1704        }
1705
1706        public boolean hasTitleElement() { 
1707          return this.title != null && !this.title.isEmpty();
1708        }
1709
1710        public boolean hasTitle() { 
1711          return this.title != null && !this.title.isEmpty();
1712        }
1713
1714        /**
1715         * @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
1716         */
1717        public SectionComponent setTitleElement(StringType value) { 
1718          this.title = value;
1719          return this;
1720        }
1721
1722        /**
1723         * @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.
1724         */
1725        public String getTitle() { 
1726          return this.title == null ? null : this.title.getValue();
1727        }
1728
1729        /**
1730         * @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.
1731         */
1732        public SectionComponent setTitle(String value) { 
1733          if (Utilities.noString(value))
1734            this.title = null;
1735          else {
1736            if (this.title == null)
1737              this.title = new StringType();
1738            this.title.setValue(value);
1739          }
1740          return this;
1741        }
1742
1743        /**
1744         * @return {@link #code} (A code identifying the kind of content contained within the section. This must be consistent with the section title.)
1745         */
1746        public CodeableConcept getCode() { 
1747          if (this.code == null)
1748            if (Configuration.errorOnAutoCreate())
1749              throw new Error("Attempt to auto-create SectionComponent.code");
1750            else if (Configuration.doAutoCreate())
1751              this.code = new CodeableConcept(); // cc
1752          return this.code;
1753        }
1754
1755        public boolean hasCode() { 
1756          return this.code != null && !this.code.isEmpty();
1757        }
1758
1759        /**
1760         * @param value {@link #code} (A code identifying the kind of content contained within the section. This must be consistent with the section title.)
1761         */
1762        public SectionComponent setCode(CodeableConcept value) { 
1763          this.code = value;
1764          return this;
1765        }
1766
1767        /**
1768         * @return {@link #author} (Identifies who is responsible for the information in this section, not necessarily who typed it in.)
1769         */
1770        public List<Reference> getAuthor() { 
1771          if (this.author == null)
1772            this.author = new ArrayList<Reference>();
1773          return this.author;
1774        }
1775
1776        /**
1777         * @return Returns a reference to <code>this</code> for easy method chaining
1778         */
1779        public SectionComponent setAuthor(List<Reference> theAuthor) { 
1780          this.author = theAuthor;
1781          return this;
1782        }
1783
1784        public boolean hasAuthor() { 
1785          if (this.author == null)
1786            return false;
1787          for (Reference item : this.author)
1788            if (!item.isEmpty())
1789              return true;
1790          return false;
1791        }
1792
1793        public Reference addAuthor() { //3
1794          Reference t = new Reference();
1795          if (this.author == null)
1796            this.author = new ArrayList<Reference>();
1797          this.author.add(t);
1798          return t;
1799        }
1800
1801        public SectionComponent addAuthor(Reference t) { //3
1802          if (t == null)
1803            return this;
1804          if (this.author == null)
1805            this.author = new ArrayList<Reference>();
1806          this.author.add(t);
1807          return this;
1808        }
1809
1810        /**
1811         * @return The first repetition of repeating field {@link #author}, creating it if it does not already exist
1812         */
1813        public Reference getAuthorFirstRep() { 
1814          if (getAuthor().isEmpty()) {
1815            addAuthor();
1816          }
1817          return getAuthor().get(0);
1818        }
1819
1820        /**
1821         * @deprecated Use Reference#setResource(IBaseResource) instead
1822         */
1823        @Deprecated
1824        public List<Resource> getAuthorTarget() { 
1825          if (this.authorTarget == null)
1826            this.authorTarget = new ArrayList<Resource>();
1827          return this.authorTarget;
1828        }
1829
1830        /**
1831         * @return {@link #focus} (The actual focus of the section when it is not the subject of the composition, but instead represents something or someone associated with the subject such as (for a patient subject) a spouse, parent, fetus, or donor. If not focus is specified, the focus is assumed to be focus of the parent section, or, for a section in the Composition itself, the subject of the composition. Sections with a focus SHALL only include resources where the logical subject (patient, subject, focus, etc.) matches the section focus, or the resources have no logical subject (few resources).)
1832         */
1833        public Reference getFocus() { 
1834          if (this.focus == null)
1835            if (Configuration.errorOnAutoCreate())
1836              throw new Error("Attempt to auto-create SectionComponent.focus");
1837            else if (Configuration.doAutoCreate())
1838              this.focus = new Reference(); // cc
1839          return this.focus;
1840        }
1841
1842        public boolean hasFocus() { 
1843          return this.focus != null && !this.focus.isEmpty();
1844        }
1845
1846        /**
1847         * @param value {@link #focus} (The actual focus of the section when it is not the subject of the composition, but instead represents something or someone associated with the subject such as (for a patient subject) a spouse, parent, fetus, or donor. If not focus is specified, the focus is assumed to be focus of the parent section, or, for a section in the Composition itself, the subject of the composition. Sections with a focus SHALL only include resources where the logical subject (patient, subject, focus, etc.) matches the section focus, or the resources have no logical subject (few resources).)
1848         */
1849        public SectionComponent setFocus(Reference value) { 
1850          this.focus = value;
1851          return this;
1852        }
1853
1854        /**
1855         * @return {@link #focus} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The actual focus of the section when it is not the subject of the composition, but instead represents something or someone associated with the subject such as (for a patient subject) a spouse, parent, fetus, or donor. If not focus is specified, the focus is assumed to be focus of the parent section, or, for a section in the Composition itself, the subject of the composition. Sections with a focus SHALL only include resources where the logical subject (patient, subject, focus, etc.) matches the section focus, or the resources have no logical subject (few resources).)
1856         */
1857        public Resource getFocusTarget() { 
1858          return this.focusTarget;
1859        }
1860
1861        /**
1862         * @param value {@link #focus} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The actual focus of the section when it is not the subject of the composition, but instead represents something or someone associated with the subject such as (for a patient subject) a spouse, parent, fetus, or donor. If not focus is specified, the focus is assumed to be focus of the parent section, or, for a section in the Composition itself, the subject of the composition. Sections with a focus SHALL only include resources where the logical subject (patient, subject, focus, etc.) matches the section focus, or the resources have no logical subject (few resources).)
1863         */
1864        public SectionComponent setFocusTarget(Resource value) { 
1865          this.focusTarget = value;
1866          return this;
1867        }
1868
1869        /**
1870         * @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.)
1871         */
1872        public Narrative getText() { 
1873          if (this.text == null)
1874            if (Configuration.errorOnAutoCreate())
1875              throw new Error("Attempt to auto-create SectionComponent.text");
1876            else if (Configuration.doAutoCreate())
1877              this.text = new Narrative(); // cc
1878          return this.text;
1879        }
1880
1881        public boolean hasText() { 
1882          return this.text != null && !this.text.isEmpty();
1883        }
1884
1885        /**
1886         * @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.)
1887         */
1888        public SectionComponent setText(Narrative value) { 
1889          this.text = value;
1890          return this;
1891        }
1892
1893        /**
1894         * @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
1895         */
1896        public Enumeration<SectionMode> getModeElement() { 
1897          if (this.mode == null)
1898            if (Configuration.errorOnAutoCreate())
1899              throw new Error("Attempt to auto-create SectionComponent.mode");
1900            else if (Configuration.doAutoCreate())
1901              this.mode = new Enumeration<SectionMode>(new SectionModeEnumFactory()); // bb
1902          return this.mode;
1903        }
1904
1905        public boolean hasModeElement() { 
1906          return this.mode != null && !this.mode.isEmpty();
1907        }
1908
1909        public boolean hasMode() { 
1910          return this.mode != null && !this.mode.isEmpty();
1911        }
1912
1913        /**
1914         * @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
1915         */
1916        public SectionComponent setModeElement(Enumeration<SectionMode> value) { 
1917          this.mode = value;
1918          return this;
1919        }
1920
1921        /**
1922         * @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.
1923         */
1924        public SectionMode getMode() { 
1925          return this.mode == null ? null : this.mode.getValue();
1926        }
1927
1928        /**
1929         * @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.
1930         */
1931        public SectionComponent setMode(SectionMode value) { 
1932          if (value == null)
1933            this.mode = null;
1934          else {
1935            if (this.mode == null)
1936              this.mode = new Enumeration<SectionMode>(new SectionModeEnumFactory());
1937            this.mode.setValue(value);
1938          }
1939          return this;
1940        }
1941
1942        /**
1943         * @return {@link #orderedBy} (Specifies the order applied to the items in the section entries.)
1944         */
1945        public CodeableConcept getOrderedBy() { 
1946          if (this.orderedBy == null)
1947            if (Configuration.errorOnAutoCreate())
1948              throw new Error("Attempt to auto-create SectionComponent.orderedBy");
1949            else if (Configuration.doAutoCreate())
1950              this.orderedBy = new CodeableConcept(); // cc
1951          return this.orderedBy;
1952        }
1953
1954        public boolean hasOrderedBy() { 
1955          return this.orderedBy != null && !this.orderedBy.isEmpty();
1956        }
1957
1958        /**
1959         * @param value {@link #orderedBy} (Specifies the order applied to the items in the section entries.)
1960         */
1961        public SectionComponent setOrderedBy(CodeableConcept value) { 
1962          this.orderedBy = value;
1963          return this;
1964        }
1965
1966        /**
1967         * @return {@link #entry} (A reference to the actual resource from which the narrative in the section is derived.)
1968         */
1969        public List<Reference> getEntry() { 
1970          if (this.entry == null)
1971            this.entry = new ArrayList<Reference>();
1972          return this.entry;
1973        }
1974
1975        /**
1976         * @return Returns a reference to <code>this</code> for easy method chaining
1977         */
1978        public SectionComponent setEntry(List<Reference> theEntry) { 
1979          this.entry = theEntry;
1980          return this;
1981        }
1982
1983        public boolean hasEntry() { 
1984          if (this.entry == null)
1985            return false;
1986          for (Reference item : this.entry)
1987            if (!item.isEmpty())
1988              return true;
1989          return false;
1990        }
1991
1992        public Reference addEntry() { //3
1993          Reference t = new Reference();
1994          if (this.entry == null)
1995            this.entry = new ArrayList<Reference>();
1996          this.entry.add(t);
1997          return t;
1998        }
1999
2000        public SectionComponent addEntry(Reference t) { //3
2001          if (t == null)
2002            return this;
2003          if (this.entry == null)
2004            this.entry = new ArrayList<Reference>();
2005          this.entry.add(t);
2006          return this;
2007        }
2008
2009        /**
2010         * @return The first repetition of repeating field {@link #entry}, creating it if it does not already exist
2011         */
2012        public Reference getEntryFirstRep() { 
2013          if (getEntry().isEmpty()) {
2014            addEntry();
2015          }
2016          return getEntry().get(0);
2017        }
2018
2019        /**
2020         * @deprecated Use Reference#setResource(IBaseResource) instead
2021         */
2022        @Deprecated
2023        public List<Resource> getEntryTarget() { 
2024          if (this.entryTarget == null)
2025            this.entryTarget = new ArrayList<Resource>();
2026          return this.entryTarget;
2027        }
2028
2029        /**
2030         * @return {@link #emptyReason} (If the section is empty, why the list is empty. An empty section typically has some text explaining the empty reason.)
2031         */
2032        public CodeableConcept getEmptyReason() { 
2033          if (this.emptyReason == null)
2034            if (Configuration.errorOnAutoCreate())
2035              throw new Error("Attempt to auto-create SectionComponent.emptyReason");
2036            else if (Configuration.doAutoCreate())
2037              this.emptyReason = new CodeableConcept(); // cc
2038          return this.emptyReason;
2039        }
2040
2041        public boolean hasEmptyReason() { 
2042          return this.emptyReason != null && !this.emptyReason.isEmpty();
2043        }
2044
2045        /**
2046         * @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.)
2047         */
2048        public SectionComponent setEmptyReason(CodeableConcept value) { 
2049          this.emptyReason = value;
2050          return this;
2051        }
2052
2053        /**
2054         * @return {@link #section} (A nested sub-section within this section.)
2055         */
2056        public List<SectionComponent> getSection() { 
2057          if (this.section == null)
2058            this.section = new ArrayList<SectionComponent>();
2059          return this.section;
2060        }
2061
2062        /**
2063         * @return Returns a reference to <code>this</code> for easy method chaining
2064         */
2065        public SectionComponent setSection(List<SectionComponent> theSection) { 
2066          this.section = theSection;
2067          return this;
2068        }
2069
2070        public boolean hasSection() { 
2071          if (this.section == null)
2072            return false;
2073          for (SectionComponent item : this.section)
2074            if (!item.isEmpty())
2075              return true;
2076          return false;
2077        }
2078
2079        public SectionComponent addSection() { //3
2080          SectionComponent t = new SectionComponent();
2081          if (this.section == null)
2082            this.section = new ArrayList<SectionComponent>();
2083          this.section.add(t);
2084          return t;
2085        }
2086
2087        public SectionComponent addSection(SectionComponent t) { //3
2088          if (t == null)
2089            return this;
2090          if (this.section == null)
2091            this.section = new ArrayList<SectionComponent>();
2092          this.section.add(t);
2093          return this;
2094        }
2095
2096        /**
2097         * @return The first repetition of repeating field {@link #section}, creating it if it does not already exist
2098         */
2099        public SectionComponent getSectionFirstRep() { 
2100          if (getSection().isEmpty()) {
2101            addSection();
2102          }
2103          return getSection().get(0);
2104        }
2105
2106        protected void listChildren(List<Property> children) {
2107          super.listChildren(children);
2108          children.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, 1, title));
2109          children.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, 1, code));
2110          children.add(new Property("author", "Reference(Practitioner|PractitionerRole|Device|Patient|RelatedPerson|Organization)", "Identifies who is responsible for the information in this section, not necessarily who typed it in.", 0, java.lang.Integer.MAX_VALUE, author));
2111          children.add(new Property("focus", "Reference(Any)", "The actual focus of the section when it is not the subject of the composition, but instead represents something or someone associated with the subject such as (for a patient subject) a spouse, parent, fetus, or donor. If not focus is specified, the focus is assumed to be focus of the parent section, or, for a section in the Composition itself, the subject of the composition. Sections with a focus SHALL only include resources where the logical subject (patient, subject, focus, etc.) matches the section focus, or the resources have no logical subject (few resources).", 0, 1, focus));
2112          children.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, 1, text));
2113          children.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, 1, mode));
2114          children.add(new Property("orderedBy", "CodeableConcept", "Specifies the order applied to the items in the section entries.", 0, 1, orderedBy));
2115          children.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));
2116          children.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, 1, emptyReason));
2117          children.add(new Property("section", "@Composition.section", "A nested sub-section within this section.", 0, java.lang.Integer.MAX_VALUE, section));
2118        }
2119
2120        @Override
2121        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2122          switch (_hash) {
2123          case 110371416: /*title*/  return 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, 1, title);
2124          case 3059181: /*code*/  return new Property("code", "CodeableConcept", "A code identifying the kind of content contained within the section. This must be consistent with the section title.", 0, 1, code);
2125          case -1406328437: /*author*/  return new Property("author", "Reference(Practitioner|PractitionerRole|Device|Patient|RelatedPerson|Organization)", "Identifies who is responsible for the information in this section, not necessarily who typed it in.", 0, java.lang.Integer.MAX_VALUE, author);
2126          case 97604824: /*focus*/  return new Property("focus", "Reference(Any)", "The actual focus of the section when it is not the subject of the composition, but instead represents something or someone associated with the subject such as (for a patient subject) a spouse, parent, fetus, or donor. If not focus is specified, the focus is assumed to be focus of the parent section, or, for a section in the Composition itself, the subject of the composition. Sections with a focus SHALL only include resources where the logical subject (patient, subject, focus, etc.) matches the section focus, or the resources have no logical subject (few resources).", 0, 1, focus);
2127          case 3556653: /*text*/  return 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, 1, text);
2128          case 3357091: /*mode*/  return 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, 1, mode);
2129          case -391079516: /*orderedBy*/  return new Property("orderedBy", "CodeableConcept", "Specifies the order applied to the items in the section entries.", 0, 1, orderedBy);
2130          case 96667762: /*entry*/  return 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);
2131          case 1140135409: /*emptyReason*/  return 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, 1, emptyReason);
2132          case 1970241253: /*section*/  return new Property("section", "@Composition.section", "A nested sub-section within this section.", 0, java.lang.Integer.MAX_VALUE, section);
2133          default: return super.getNamedProperty(_hash, _name, _checkValid);
2134          }
2135
2136        }
2137
2138      @Override
2139      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2140        switch (hash) {
2141        case 110371416: /*title*/ return this.title == null ? new Base[0] : new Base[] {this.title}; // StringType
2142        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept
2143        case -1406328437: /*author*/ return this.author == null ? new Base[0] : this.author.toArray(new Base[this.author.size()]); // Reference
2144        case 97604824: /*focus*/ return this.focus == null ? new Base[0] : new Base[] {this.focus}; // Reference
2145        case 3556653: /*text*/ return this.text == null ? new Base[0] : new Base[] {this.text}; // Narrative
2146        case 3357091: /*mode*/ return this.mode == null ? new Base[0] : new Base[] {this.mode}; // Enumeration<SectionMode>
2147        case -391079516: /*orderedBy*/ return this.orderedBy == null ? new Base[0] : new Base[] {this.orderedBy}; // CodeableConcept
2148        case 96667762: /*entry*/ return this.entry == null ? new Base[0] : this.entry.toArray(new Base[this.entry.size()]); // Reference
2149        case 1140135409: /*emptyReason*/ return this.emptyReason == null ? new Base[0] : new Base[] {this.emptyReason}; // CodeableConcept
2150        case 1970241253: /*section*/ return this.section == null ? new Base[0] : this.section.toArray(new Base[this.section.size()]); // SectionComponent
2151        default: return super.getProperty(hash, name, checkValid);
2152        }
2153
2154      }
2155
2156      @Override
2157      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2158        switch (hash) {
2159        case 110371416: // title
2160          this.title = castToString(value); // StringType
2161          return value;
2162        case 3059181: // code
2163          this.code = castToCodeableConcept(value); // CodeableConcept
2164          return value;
2165        case -1406328437: // author
2166          this.getAuthor().add(castToReference(value)); // Reference
2167          return value;
2168        case 97604824: // focus
2169          this.focus = castToReference(value); // Reference
2170          return value;
2171        case 3556653: // text
2172          this.text = castToNarrative(value); // Narrative
2173          return value;
2174        case 3357091: // mode
2175          value = new SectionModeEnumFactory().fromType(castToCode(value));
2176          this.mode = (Enumeration) value; // Enumeration<SectionMode>
2177          return value;
2178        case -391079516: // orderedBy
2179          this.orderedBy = castToCodeableConcept(value); // CodeableConcept
2180          return value;
2181        case 96667762: // entry
2182          this.getEntry().add(castToReference(value)); // Reference
2183          return value;
2184        case 1140135409: // emptyReason
2185          this.emptyReason = castToCodeableConcept(value); // CodeableConcept
2186          return value;
2187        case 1970241253: // section
2188          this.getSection().add((SectionComponent) value); // SectionComponent
2189          return value;
2190        default: return super.setProperty(hash, name, value);
2191        }
2192
2193      }
2194
2195      @Override
2196      public Base setProperty(String name, Base value) throws FHIRException {
2197        if (name.equals("title")) {
2198          this.title = castToString(value); // StringType
2199        } else if (name.equals("code")) {
2200          this.code = castToCodeableConcept(value); // CodeableConcept
2201        } else if (name.equals("author")) {
2202          this.getAuthor().add(castToReference(value));
2203        } else if (name.equals("focus")) {
2204          this.focus = castToReference(value); // Reference
2205        } else if (name.equals("text")) {
2206          this.text = castToNarrative(value); // Narrative
2207        } else if (name.equals("mode")) {
2208          value = new SectionModeEnumFactory().fromType(castToCode(value));
2209          this.mode = (Enumeration) value; // Enumeration<SectionMode>
2210        } else if (name.equals("orderedBy")) {
2211          this.orderedBy = castToCodeableConcept(value); // CodeableConcept
2212        } else if (name.equals("entry")) {
2213          this.getEntry().add(castToReference(value));
2214        } else if (name.equals("emptyReason")) {
2215          this.emptyReason = castToCodeableConcept(value); // CodeableConcept
2216        } else if (name.equals("section")) {
2217          this.getSection().add((SectionComponent) value);
2218        } else
2219          return super.setProperty(name, value);
2220        return value;
2221      }
2222
2223      @Override
2224      public Base makeProperty(int hash, String name) throws FHIRException {
2225        switch (hash) {
2226        case 110371416:  return getTitleElement();
2227        case 3059181:  return getCode(); 
2228        case -1406328437:  return addAuthor(); 
2229        case 97604824:  return getFocus(); 
2230        case 3556653:  return getText(); 
2231        case 3357091:  return getModeElement();
2232        case -391079516:  return getOrderedBy(); 
2233        case 96667762:  return addEntry(); 
2234        case 1140135409:  return getEmptyReason(); 
2235        case 1970241253:  return addSection(); 
2236        default: return super.makeProperty(hash, name);
2237        }
2238
2239      }
2240
2241      @Override
2242      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2243        switch (hash) {
2244        case 110371416: /*title*/ return new String[] {"string"};
2245        case 3059181: /*code*/ return new String[] {"CodeableConcept"};
2246        case -1406328437: /*author*/ return new String[] {"Reference"};
2247        case 97604824: /*focus*/ return new String[] {"Reference"};
2248        case 3556653: /*text*/ return new String[] {"Narrative"};
2249        case 3357091: /*mode*/ return new String[] {"code"};
2250        case -391079516: /*orderedBy*/ return new String[] {"CodeableConcept"};
2251        case 96667762: /*entry*/ return new String[] {"Reference"};
2252        case 1140135409: /*emptyReason*/ return new String[] {"CodeableConcept"};
2253        case 1970241253: /*section*/ return new String[] {"@Composition.section"};
2254        default: return super.getTypesForProperty(hash, name);
2255        }
2256
2257      }
2258
2259      @Override
2260      public Base addChild(String name) throws FHIRException {
2261        if (name.equals("title")) {
2262          throw new FHIRException("Cannot call addChild on a primitive type Composition.title");
2263        }
2264        else if (name.equals("code")) {
2265          this.code = new CodeableConcept();
2266          return this.code;
2267        }
2268        else if (name.equals("author")) {
2269          return addAuthor();
2270        }
2271        else if (name.equals("focus")) {
2272          this.focus = new Reference();
2273          return this.focus;
2274        }
2275        else if (name.equals("text")) {
2276          this.text = new Narrative();
2277          return this.text;
2278        }
2279        else if (name.equals("mode")) {
2280          throw new FHIRException("Cannot call addChild on a primitive type Composition.mode");
2281        }
2282        else if (name.equals("orderedBy")) {
2283          this.orderedBy = new CodeableConcept();
2284          return this.orderedBy;
2285        }
2286        else if (name.equals("entry")) {
2287          return addEntry();
2288        }
2289        else if (name.equals("emptyReason")) {
2290          this.emptyReason = new CodeableConcept();
2291          return this.emptyReason;
2292        }
2293        else if (name.equals("section")) {
2294          return addSection();
2295        }
2296        else
2297          return super.addChild(name);
2298      }
2299
2300      public SectionComponent copy() {
2301        SectionComponent dst = new SectionComponent();
2302        copyValues(dst);
2303        dst.title = title == null ? null : title.copy();
2304        dst.code = code == null ? null : code.copy();
2305        if (author != null) {
2306          dst.author = new ArrayList<Reference>();
2307          for (Reference i : author)
2308            dst.author.add(i.copy());
2309        };
2310        dst.focus = focus == null ? null : focus.copy();
2311        dst.text = text == null ? null : text.copy();
2312        dst.mode = mode == null ? null : mode.copy();
2313        dst.orderedBy = orderedBy == null ? null : orderedBy.copy();
2314        if (entry != null) {
2315          dst.entry = new ArrayList<Reference>();
2316          for (Reference i : entry)
2317            dst.entry.add(i.copy());
2318        };
2319        dst.emptyReason = emptyReason == null ? null : emptyReason.copy();
2320        if (section != null) {
2321          dst.section = new ArrayList<SectionComponent>();
2322          for (SectionComponent i : section)
2323            dst.section.add(i.copy());
2324        };
2325        return dst;
2326      }
2327
2328      @Override
2329      public boolean equalsDeep(Base other_) {
2330        if (!super.equalsDeep(other_))
2331          return false;
2332        if (!(other_ instanceof SectionComponent))
2333          return false;
2334        SectionComponent o = (SectionComponent) other_;
2335        return compareDeep(title, o.title, true) && compareDeep(code, o.code, true) && compareDeep(author, o.author, true)
2336           && compareDeep(focus, o.focus, true) && compareDeep(text, o.text, true) && compareDeep(mode, o.mode, true)
2337           && compareDeep(orderedBy, o.orderedBy, true) && compareDeep(entry, o.entry, true) && compareDeep(emptyReason, o.emptyReason, true)
2338           && compareDeep(section, o.section, true);
2339      }
2340
2341      @Override
2342      public boolean equalsShallow(Base other_) {
2343        if (!super.equalsShallow(other_))
2344          return false;
2345        if (!(other_ instanceof SectionComponent))
2346          return false;
2347        SectionComponent o = (SectionComponent) other_;
2348        return compareValues(title, o.title, true) && compareValues(mode, o.mode, true);
2349      }
2350
2351      public boolean isEmpty() {
2352        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(title, code, author, focus
2353          , text, mode, orderedBy, entry, emptyReason, section);
2354      }
2355
2356  public String fhirType() {
2357    return "Composition.section";
2358
2359  }
2360
2361  }
2362
2363    /**
2364     * A version-independent identifier for the Composition. This identifier stays constant as the composition is changed over time.
2365     */
2366    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=1, modifier=false, summary=true)
2367    @Description(shortDefinition="Version-independent identifier for the Composition", formalDefinition="A version-independent identifier for the Composition. This identifier stays constant as the composition is changed over time." )
2368    protected Identifier identifier;
2369
2370    /**
2371     * The workflow/clinical status of this composition. The status is a marker for the clinical standing of the document.
2372     */
2373    @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true)
2374    @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." )
2375    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/composition-status")
2376    protected Enumeration<CompositionStatus> status;
2377
2378    /**
2379     * 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.
2380     */
2381    @Child(name = "type", type = {CodeableConcept.class}, order=2, min=1, max=1, modifier=false, summary=true)
2382    @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." )
2383    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/doc-typecodes")
2384    protected CodeableConcept type;
2385
2386    /**
2387     * 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.
2388     */
2389    @Child(name = "category", type = {CodeableConcept.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2390    @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." )
2391    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/document-classcodes")
2392    protected List<CodeableConcept> category;
2393
2394    /**
2395     * 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).
2396     */
2397    @Child(name = "subject", type = {Reference.class}, order=4, min=0, max=1, modifier=false, summary=true)
2398    @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)." )
2399    protected Reference subject;
2400
2401    /**
2402     * 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).)
2403     */
2404    protected Resource subjectTarget;
2405
2406    /**
2407     * Describes the clinical encounter or type of care this documentation is associated with.
2408     */
2409    @Child(name = "encounter", type = {Encounter.class}, order=5, min=0, max=1, modifier=false, summary=true)
2410    @Description(shortDefinition="Context of the Composition", formalDefinition="Describes the clinical encounter or type of care this documentation is associated with." )
2411    protected Reference encounter;
2412
2413    /**
2414     * The actual object that is the target of the reference (Describes the clinical encounter or type of care this documentation is associated with.)
2415     */
2416    protected Encounter encounterTarget;
2417
2418    /**
2419     * The composition editing time, when the composition was last logically changed by the author.
2420     */
2421    @Child(name = "date", type = {DateTimeType.class}, order=6, min=1, max=1, modifier=false, summary=true)
2422    @Description(shortDefinition="Composition editing time", formalDefinition="The composition editing time, when the composition was last logically changed by the author." )
2423    protected DateTimeType date;
2424
2425    /**
2426     * Identifies who is responsible for the information in the composition, not necessarily who typed it in.
2427     */
2428    @Child(name = "author", type = {Practitioner.class, PractitionerRole.class, Device.class, Patient.class, RelatedPerson.class, Organization.class}, order=7, min=1, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2429    @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." )
2430    protected List<Reference> author;
2431    /**
2432     * 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.)
2433     */
2434    protected List<Resource> authorTarget;
2435
2436
2437    /**
2438     * Official human-readable label for the composition.
2439     */
2440    @Child(name = "title", type = {StringType.class}, order=8, min=1, max=1, modifier=false, summary=true)
2441    @Description(shortDefinition="Human Readable name/title", formalDefinition="Official human-readable label for the composition." )
2442    protected StringType title;
2443
2444    /**
2445     * The code specifying the level of confidentiality of the Composition.
2446     */
2447    @Child(name = "confidentiality", type = {CodeType.class}, order=9, min=0, max=1, modifier=false, summary=true)
2448    @Description(shortDefinition="As defined by affinity domain", formalDefinition="The code specifying the level of confidentiality of the Composition." )
2449    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://terminology.hl7.org/ValueSet/v3-ConfidentialityClassification")
2450    protected Enumeration<DocumentConfidentiality> confidentiality;
2451
2452    /**
2453     * A participant who has attested to the accuracy of the composition/document.
2454     */
2455    @Child(name = "attester", type = {}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2456    @Description(shortDefinition="Attests to accuracy of composition", formalDefinition="A participant who has attested to the accuracy of the composition/document." )
2457    protected List<CompositionAttesterComponent> attester;
2458
2459    /**
2460     * Identifies the organization or group who is responsible for ongoing maintenance of and access to the composition/document information.
2461     */
2462    @Child(name = "custodian", type = {Organization.class}, order=11, min=0, max=1, modifier=false, summary=true)
2463    @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." )
2464    protected Reference custodian;
2465
2466    /**
2467     * 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.)
2468     */
2469    protected Organization custodianTarget;
2470
2471    /**
2472     * Relationships that this composition has with other compositions or documents that already exist.
2473     */
2474    @Child(name = "relatesTo", type = {}, order=12, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2475    @Description(shortDefinition="Relationships to other compositions/documents", formalDefinition="Relationships that this composition has with other compositions or documents that already exist." )
2476    protected List<CompositionRelatesToComponent> relatesTo;
2477
2478    /**
2479     * The clinical service, such as a colonoscopy or an appendectomy, being documented.
2480     */
2481    @Child(name = "event", type = {}, order=13, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2482    @Description(shortDefinition="The clinical service(s) being documented", formalDefinition="The clinical service, such as a colonoscopy or an appendectomy, being documented." )
2483    protected List<CompositionEventComponent> event;
2484
2485    /**
2486     * The root of the sections that make up the composition.
2487     */
2488    @Child(name = "section", type = {}, order=14, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2489    @Description(shortDefinition="Composition is broken into sections", formalDefinition="The root of the sections that make up the composition." )
2490    protected List<SectionComponent> section;
2491
2492    private static final long serialVersionUID = -1490206663L;
2493
2494  /**
2495   * Constructor
2496   */
2497    public Composition() {
2498      super();
2499    }
2500
2501  /**
2502   * Constructor
2503   */
2504    public Composition(Enumeration<CompositionStatus> status, CodeableConcept type, DateTimeType date, StringType title) {
2505      super();
2506      this.status = status;
2507      this.type = type;
2508      this.date = date;
2509      this.title = title;
2510    }
2511
2512    /**
2513     * @return {@link #identifier} (A version-independent identifier for the Composition. This identifier stays constant as the composition is changed over time.)
2514     */
2515    public Identifier getIdentifier() { 
2516      if (this.identifier == null)
2517        if (Configuration.errorOnAutoCreate())
2518          throw new Error("Attempt to auto-create Composition.identifier");
2519        else if (Configuration.doAutoCreate())
2520          this.identifier = new Identifier(); // cc
2521      return this.identifier;
2522    }
2523
2524    public boolean hasIdentifier() { 
2525      return this.identifier != null && !this.identifier.isEmpty();
2526    }
2527
2528    /**
2529     * @param value {@link #identifier} (A version-independent identifier for the Composition. This identifier stays constant as the composition is changed over time.)
2530     */
2531    public Composition setIdentifier(Identifier value) { 
2532      this.identifier = value;
2533      return this;
2534    }
2535
2536    /**
2537     * @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
2538     */
2539    public Enumeration<CompositionStatus> getStatusElement() { 
2540      if (this.status == null)
2541        if (Configuration.errorOnAutoCreate())
2542          throw new Error("Attempt to auto-create Composition.status");
2543        else if (Configuration.doAutoCreate())
2544          this.status = new Enumeration<CompositionStatus>(new CompositionStatusEnumFactory()); // bb
2545      return this.status;
2546    }
2547
2548    public boolean hasStatusElement() { 
2549      return this.status != null && !this.status.isEmpty();
2550    }
2551
2552    public boolean hasStatus() { 
2553      return this.status != null && !this.status.isEmpty();
2554    }
2555
2556    /**
2557     * @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
2558     */
2559    public Composition setStatusElement(Enumeration<CompositionStatus> value) { 
2560      this.status = value;
2561      return this;
2562    }
2563
2564    /**
2565     * @return The workflow/clinical status of this composition. The status is a marker for the clinical standing of the document.
2566     */
2567    public CompositionStatus getStatus() { 
2568      return this.status == null ? null : this.status.getValue();
2569    }
2570
2571    /**
2572     * @param value The workflow/clinical status of this composition. The status is a marker for the clinical standing of the document.
2573     */
2574    public Composition setStatus(CompositionStatus value) { 
2575        if (this.status == null)
2576          this.status = new Enumeration<CompositionStatus>(new CompositionStatusEnumFactory());
2577        this.status.setValue(value);
2578      return this;
2579    }
2580
2581    /**
2582     * @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.)
2583     */
2584    public CodeableConcept getType() { 
2585      if (this.type == null)
2586        if (Configuration.errorOnAutoCreate())
2587          throw new Error("Attempt to auto-create Composition.type");
2588        else if (Configuration.doAutoCreate())
2589          this.type = new CodeableConcept(); // cc
2590      return this.type;
2591    }
2592
2593    public boolean hasType() { 
2594      return this.type != null && !this.type.isEmpty();
2595    }
2596
2597    /**
2598     * @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.)
2599     */
2600    public Composition setType(CodeableConcept value) { 
2601      this.type = value;
2602      return this;
2603    }
2604
2605    /**
2606     * @return {@link #category} (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.)
2607     */
2608    public List<CodeableConcept> getCategory() { 
2609      if (this.category == null)
2610        this.category = new ArrayList<CodeableConcept>();
2611      return this.category;
2612    }
2613
2614    /**
2615     * @return Returns a reference to <code>this</code> for easy method chaining
2616     */
2617    public Composition setCategory(List<CodeableConcept> theCategory) { 
2618      this.category = theCategory;
2619      return this;
2620    }
2621
2622    public boolean hasCategory() { 
2623      if (this.category == null)
2624        return false;
2625      for (CodeableConcept item : this.category)
2626        if (!item.isEmpty())
2627          return true;
2628      return false;
2629    }
2630
2631    public CodeableConcept addCategory() { //3
2632      CodeableConcept t = new CodeableConcept();
2633      if (this.category == null)
2634        this.category = new ArrayList<CodeableConcept>();
2635      this.category.add(t);
2636      return t;
2637    }
2638
2639    public Composition addCategory(CodeableConcept t) { //3
2640      if (t == null)
2641        return this;
2642      if (this.category == null)
2643        this.category = new ArrayList<CodeableConcept>();
2644      this.category.add(t);
2645      return this;
2646    }
2647
2648    /**
2649     * @return The first repetition of repeating field {@link #category}, creating it if it does not already exist
2650     */
2651    public CodeableConcept getCategoryFirstRep() { 
2652      if (getCategory().isEmpty()) {
2653        addCategory();
2654      }
2655      return getCategory().get(0);
2656    }
2657
2658    /**
2659     * @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).)
2660     */
2661    public Reference getSubject() { 
2662      if (this.subject == null)
2663        if (Configuration.errorOnAutoCreate())
2664          throw new Error("Attempt to auto-create Composition.subject");
2665        else if (Configuration.doAutoCreate())
2666          this.subject = new Reference(); // cc
2667      return this.subject;
2668    }
2669
2670    public boolean hasSubject() { 
2671      return this.subject != null && !this.subject.isEmpty();
2672    }
2673
2674    /**
2675     * @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).)
2676     */
2677    public Composition setSubject(Reference value) { 
2678      this.subject = value;
2679      return this;
2680    }
2681
2682    /**
2683     * @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).)
2684     */
2685    public Resource getSubjectTarget() { 
2686      return this.subjectTarget;
2687    }
2688
2689    /**
2690     * @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).)
2691     */
2692    public Composition setSubjectTarget(Resource value) { 
2693      this.subjectTarget = value;
2694      return this;
2695    }
2696
2697    /**
2698     * @return {@link #encounter} (Describes the clinical encounter or type of care this documentation is associated with.)
2699     */
2700    public Reference getEncounter() { 
2701      if (this.encounter == null)
2702        if (Configuration.errorOnAutoCreate())
2703          throw new Error("Attempt to auto-create Composition.encounter");
2704        else if (Configuration.doAutoCreate())
2705          this.encounter = new Reference(); // cc
2706      return this.encounter;
2707    }
2708
2709    public boolean hasEncounter() { 
2710      return this.encounter != null && !this.encounter.isEmpty();
2711    }
2712
2713    /**
2714     * @param value {@link #encounter} (Describes the clinical encounter or type of care this documentation is associated with.)
2715     */
2716    public Composition setEncounter(Reference value) { 
2717      this.encounter = value;
2718      return this;
2719    }
2720
2721    /**
2722     * @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.)
2723     */
2724    public Encounter getEncounterTarget() { 
2725      if (this.encounterTarget == null)
2726        if (Configuration.errorOnAutoCreate())
2727          throw new Error("Attempt to auto-create Composition.encounter");
2728        else if (Configuration.doAutoCreate())
2729          this.encounterTarget = new Encounter(); // aa
2730      return this.encounterTarget;
2731    }
2732
2733    /**
2734     * @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.)
2735     */
2736    public Composition setEncounterTarget(Encounter value) { 
2737      this.encounterTarget = value;
2738      return this;
2739    }
2740
2741    /**
2742     * @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
2743     */
2744    public DateTimeType getDateElement() { 
2745      if (this.date == null)
2746        if (Configuration.errorOnAutoCreate())
2747          throw new Error("Attempt to auto-create Composition.date");
2748        else if (Configuration.doAutoCreate())
2749          this.date = new DateTimeType(); // bb
2750      return this.date;
2751    }
2752
2753    public boolean hasDateElement() { 
2754      return this.date != null && !this.date.isEmpty();
2755    }
2756
2757    public boolean hasDate() { 
2758      return this.date != null && !this.date.isEmpty();
2759    }
2760
2761    /**
2762     * @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
2763     */
2764    public Composition setDateElement(DateTimeType value) { 
2765      this.date = value;
2766      return this;
2767    }
2768
2769    /**
2770     * @return The composition editing time, when the composition was last logically changed by the author.
2771     */
2772    public Date getDate() { 
2773      return this.date == null ? null : this.date.getValue();
2774    }
2775
2776    /**
2777     * @param value The composition editing time, when the composition was last logically changed by the author.
2778     */
2779    public Composition setDate(Date value) { 
2780        if (this.date == null)
2781          this.date = new DateTimeType();
2782        this.date.setValue(value);
2783      return this;
2784    }
2785
2786    /**
2787     * @return {@link #author} (Identifies who is responsible for the information in the composition, not necessarily who typed it in.)
2788     */
2789    public List<Reference> getAuthor() { 
2790      if (this.author == null)
2791        this.author = new ArrayList<Reference>();
2792      return this.author;
2793    }
2794
2795    /**
2796     * @return Returns a reference to <code>this</code> for easy method chaining
2797     */
2798    public Composition setAuthor(List<Reference> theAuthor) { 
2799      this.author = theAuthor;
2800      return this;
2801    }
2802
2803    public boolean hasAuthor() { 
2804      if (this.author == null)
2805        return false;
2806      for (Reference item : this.author)
2807        if (!item.isEmpty())
2808          return true;
2809      return false;
2810    }
2811
2812    public Reference addAuthor() { //3
2813      Reference t = new Reference();
2814      if (this.author == null)
2815        this.author = new ArrayList<Reference>();
2816      this.author.add(t);
2817      return t;
2818    }
2819
2820    public Composition addAuthor(Reference t) { //3
2821      if (t == null)
2822        return this;
2823      if (this.author == null)
2824        this.author = new ArrayList<Reference>();
2825      this.author.add(t);
2826      return this;
2827    }
2828
2829    /**
2830     * @return The first repetition of repeating field {@link #author}, creating it if it does not already exist
2831     */
2832    public Reference getAuthorFirstRep() { 
2833      if (getAuthor().isEmpty()) {
2834        addAuthor();
2835      }
2836      return getAuthor().get(0);
2837    }
2838
2839    /**
2840     * @deprecated Use Reference#setResource(IBaseResource) instead
2841     */
2842    @Deprecated
2843    public List<Resource> getAuthorTarget() { 
2844      if (this.authorTarget == null)
2845        this.authorTarget = new ArrayList<Resource>();
2846      return this.authorTarget;
2847    }
2848
2849    /**
2850     * @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
2851     */
2852    public StringType getTitleElement() { 
2853      if (this.title == null)
2854        if (Configuration.errorOnAutoCreate())
2855          throw new Error("Attempt to auto-create Composition.title");
2856        else if (Configuration.doAutoCreate())
2857          this.title = new StringType(); // bb
2858      return this.title;
2859    }
2860
2861    public boolean hasTitleElement() { 
2862      return this.title != null && !this.title.isEmpty();
2863    }
2864
2865    public boolean hasTitle() { 
2866      return this.title != null && !this.title.isEmpty();
2867    }
2868
2869    /**
2870     * @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
2871     */
2872    public Composition setTitleElement(StringType value) { 
2873      this.title = value;
2874      return this;
2875    }
2876
2877    /**
2878     * @return Official human-readable label for the composition.
2879     */
2880    public String getTitle() { 
2881      return this.title == null ? null : this.title.getValue();
2882    }
2883
2884    /**
2885     * @param value Official human-readable label for the composition.
2886     */
2887    public Composition setTitle(String value) { 
2888        if (this.title == null)
2889          this.title = new StringType();
2890        this.title.setValue(value);
2891      return this;
2892    }
2893
2894    /**
2895     * @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
2896     */
2897    public Enumeration<DocumentConfidentiality> getConfidentialityElement() { 
2898      if (this.confidentiality == null)
2899        if (Configuration.errorOnAutoCreate())
2900          throw new Error("Attempt to auto-create Composition.confidentiality");
2901        else if (Configuration.doAutoCreate())
2902          this.confidentiality = new Enumeration<DocumentConfidentiality>(new DocumentConfidentialityEnumFactory()); // bb
2903      return this.confidentiality;
2904    }
2905
2906    public boolean hasConfidentialityElement() { 
2907      return this.confidentiality != null && !this.confidentiality.isEmpty();
2908    }
2909
2910    public boolean hasConfidentiality() { 
2911      return this.confidentiality != null && !this.confidentiality.isEmpty();
2912    }
2913
2914    /**
2915     * @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
2916     */
2917    public Composition setConfidentialityElement(Enumeration<DocumentConfidentiality> value) { 
2918      this.confidentiality = value;
2919      return this;
2920    }
2921
2922    /**
2923     * @return The code specifying the level of confidentiality of the Composition.
2924     */
2925    public DocumentConfidentiality getConfidentiality() { 
2926      return this.confidentiality == null ? null : this.confidentiality.getValue();
2927    }
2928
2929    /**
2930     * @param value The code specifying the level of confidentiality of the Composition.
2931     */
2932    public Composition setConfidentiality(DocumentConfidentiality value) { 
2933      if (value == null)
2934        this.confidentiality = null;
2935      else {
2936        if (this.confidentiality == null)
2937          this.confidentiality = new Enumeration<DocumentConfidentiality>(new DocumentConfidentialityEnumFactory());
2938        this.confidentiality.setValue(value);
2939      }
2940      return this;
2941    }
2942
2943    /**
2944     * @return {@link #attester} (A participant who has attested to the accuracy of the composition/document.)
2945     */
2946    public List<CompositionAttesterComponent> getAttester() { 
2947      if (this.attester == null)
2948        this.attester = new ArrayList<CompositionAttesterComponent>();
2949      return this.attester;
2950    }
2951
2952    /**
2953     * @return Returns a reference to <code>this</code> for easy method chaining
2954     */
2955    public Composition setAttester(List<CompositionAttesterComponent> theAttester) { 
2956      this.attester = theAttester;
2957      return this;
2958    }
2959
2960    public boolean hasAttester() { 
2961      if (this.attester == null)
2962        return false;
2963      for (CompositionAttesterComponent item : this.attester)
2964        if (!item.isEmpty())
2965          return true;
2966      return false;
2967    }
2968
2969    public CompositionAttesterComponent addAttester() { //3
2970      CompositionAttesterComponent t = new CompositionAttesterComponent();
2971      if (this.attester == null)
2972        this.attester = new ArrayList<CompositionAttesterComponent>();
2973      this.attester.add(t);
2974      return t;
2975    }
2976
2977    public Composition addAttester(CompositionAttesterComponent t) { //3
2978      if (t == null)
2979        return this;
2980      if (this.attester == null)
2981        this.attester = new ArrayList<CompositionAttesterComponent>();
2982      this.attester.add(t);
2983      return this;
2984    }
2985
2986    /**
2987     * @return The first repetition of repeating field {@link #attester}, creating it if it does not already exist
2988     */
2989    public CompositionAttesterComponent getAttesterFirstRep() { 
2990      if (getAttester().isEmpty()) {
2991        addAttester();
2992      }
2993      return getAttester().get(0);
2994    }
2995
2996    /**
2997     * @return {@link #custodian} (Identifies the organization or group who is responsible for ongoing maintenance of and access to the composition/document information.)
2998     */
2999    public Reference getCustodian() { 
3000      if (this.custodian == null)
3001        if (Configuration.errorOnAutoCreate())
3002          throw new Error("Attempt to auto-create Composition.custodian");
3003        else if (Configuration.doAutoCreate())
3004          this.custodian = new Reference(); // cc
3005      return this.custodian;
3006    }
3007
3008    public boolean hasCustodian() { 
3009      return this.custodian != null && !this.custodian.isEmpty();
3010    }
3011
3012    /**
3013     * @param value {@link #custodian} (Identifies the organization or group who is responsible for ongoing maintenance of and access to the composition/document information.)
3014     */
3015    public Composition setCustodian(Reference value) { 
3016      this.custodian = value;
3017      return this;
3018    }
3019
3020    /**
3021     * @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.)
3022     */
3023    public Organization getCustodianTarget() { 
3024      if (this.custodianTarget == null)
3025        if (Configuration.errorOnAutoCreate())
3026          throw new Error("Attempt to auto-create Composition.custodian");
3027        else if (Configuration.doAutoCreate())
3028          this.custodianTarget = new Organization(); // aa
3029      return this.custodianTarget;
3030    }
3031
3032    /**
3033     * @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.)
3034     */
3035    public Composition setCustodianTarget(Organization value) { 
3036      this.custodianTarget = value;
3037      return this;
3038    }
3039
3040    /**
3041     * @return {@link #relatesTo} (Relationships that this composition has with other compositions or documents that already exist.)
3042     */
3043    public List<CompositionRelatesToComponent> getRelatesTo() { 
3044      if (this.relatesTo == null)
3045        this.relatesTo = new ArrayList<CompositionRelatesToComponent>();
3046      return this.relatesTo;
3047    }
3048
3049    /**
3050     * @return Returns a reference to <code>this</code> for easy method chaining
3051     */
3052    public Composition setRelatesTo(List<CompositionRelatesToComponent> theRelatesTo) { 
3053      this.relatesTo = theRelatesTo;
3054      return this;
3055    }
3056
3057    public boolean hasRelatesTo() { 
3058      if (this.relatesTo == null)
3059        return false;
3060      for (CompositionRelatesToComponent item : this.relatesTo)
3061        if (!item.isEmpty())
3062          return true;
3063      return false;
3064    }
3065
3066    public CompositionRelatesToComponent addRelatesTo() { //3
3067      CompositionRelatesToComponent t = new CompositionRelatesToComponent();
3068      if (this.relatesTo == null)
3069        this.relatesTo = new ArrayList<CompositionRelatesToComponent>();
3070      this.relatesTo.add(t);
3071      return t;
3072    }
3073
3074    public Composition addRelatesTo(CompositionRelatesToComponent t) { //3
3075      if (t == null)
3076        return this;
3077      if (this.relatesTo == null)
3078        this.relatesTo = new ArrayList<CompositionRelatesToComponent>();
3079      this.relatesTo.add(t);
3080      return this;
3081    }
3082
3083    /**
3084     * @return The first repetition of repeating field {@link #relatesTo}, creating it if it does not already exist
3085     */
3086    public CompositionRelatesToComponent getRelatesToFirstRep() { 
3087      if (getRelatesTo().isEmpty()) {
3088        addRelatesTo();
3089      }
3090      return getRelatesTo().get(0);
3091    }
3092
3093    /**
3094     * @return {@link #event} (The clinical service, such as a colonoscopy or an appendectomy, being documented.)
3095     */
3096    public List<CompositionEventComponent> getEvent() { 
3097      if (this.event == null)
3098        this.event = new ArrayList<CompositionEventComponent>();
3099      return this.event;
3100    }
3101
3102    /**
3103     * @return Returns a reference to <code>this</code> for easy method chaining
3104     */
3105    public Composition setEvent(List<CompositionEventComponent> theEvent) { 
3106      this.event = theEvent;
3107      return this;
3108    }
3109
3110    public boolean hasEvent() { 
3111      if (this.event == null)
3112        return false;
3113      for (CompositionEventComponent item : this.event)
3114        if (!item.isEmpty())
3115          return true;
3116      return false;
3117    }
3118
3119    public CompositionEventComponent addEvent() { //3
3120      CompositionEventComponent t = new CompositionEventComponent();
3121      if (this.event == null)
3122        this.event = new ArrayList<CompositionEventComponent>();
3123      this.event.add(t);
3124      return t;
3125    }
3126
3127    public Composition addEvent(CompositionEventComponent t) { //3
3128      if (t == null)
3129        return this;
3130      if (this.event == null)
3131        this.event = new ArrayList<CompositionEventComponent>();
3132      this.event.add(t);
3133      return this;
3134    }
3135
3136    /**
3137     * @return The first repetition of repeating field {@link #event}, creating it if it does not already exist
3138     */
3139    public CompositionEventComponent getEventFirstRep() { 
3140      if (getEvent().isEmpty()) {
3141        addEvent();
3142      }
3143      return getEvent().get(0);
3144    }
3145
3146    /**
3147     * @return {@link #section} (The root of the sections that make up the composition.)
3148     */
3149    public List<SectionComponent> getSection() { 
3150      if (this.section == null)
3151        this.section = new ArrayList<SectionComponent>();
3152      return this.section;
3153    }
3154
3155    /**
3156     * @return Returns a reference to <code>this</code> for easy method chaining
3157     */
3158    public Composition setSection(List<SectionComponent> theSection) { 
3159      this.section = theSection;
3160      return this;
3161    }
3162
3163    public boolean hasSection() { 
3164      if (this.section == null)
3165        return false;
3166      for (SectionComponent item : this.section)
3167        if (!item.isEmpty())
3168          return true;
3169      return false;
3170    }
3171
3172    public SectionComponent addSection() { //3
3173      SectionComponent t = new SectionComponent();
3174      if (this.section == null)
3175        this.section = new ArrayList<SectionComponent>();
3176      this.section.add(t);
3177      return t;
3178    }
3179
3180    public Composition addSection(SectionComponent t) { //3
3181      if (t == null)
3182        return this;
3183      if (this.section == null)
3184        this.section = new ArrayList<SectionComponent>();
3185      this.section.add(t);
3186      return this;
3187    }
3188
3189    /**
3190     * @return The first repetition of repeating field {@link #section}, creating it if it does not already exist
3191     */
3192    public SectionComponent getSectionFirstRep() { 
3193      if (getSection().isEmpty()) {
3194        addSection();
3195      }
3196      return getSection().get(0);
3197    }
3198
3199      protected void listChildren(List<Property> children) {
3200        super.listChildren(children);
3201        children.add(new Property("identifier", "Identifier", "A version-independent identifier for the Composition. This identifier stays constant as the composition is changed over time.", 0, 1, identifier));
3202        children.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, 1, status));
3203        children.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, 1, type));
3204        children.add(new Property("category", "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, category));
3205        children.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, 1, subject));
3206        children.add(new Property("encounter", "Reference(Encounter)", "Describes the clinical encounter or type of care this documentation is associated with.", 0, 1, encounter));
3207        children.add(new Property("date", "dateTime", "The composition editing time, when the composition was last logically changed by the author.", 0, 1, date));
3208        children.add(new Property("author", "Reference(Practitioner|PractitionerRole|Device|Patient|RelatedPerson|Organization)", "Identifies who is responsible for the information in the composition, not necessarily who typed it in.", 0, java.lang.Integer.MAX_VALUE, author));
3209        children.add(new Property("title", "string", "Official human-readable label for the composition.", 0, 1, title));
3210        children.add(new Property("confidentiality", "code", "The code specifying the level of confidentiality of the Composition.", 0, 1, confidentiality));
3211        children.add(new Property("attester", "", "A participant who has attested to the accuracy of the composition/document.", 0, java.lang.Integer.MAX_VALUE, attester));
3212        children.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, 1, custodian));
3213        children.add(new Property("relatesTo", "", "Relationships that this composition has with other compositions or documents that already exist.", 0, java.lang.Integer.MAX_VALUE, relatesTo));
3214        children.add(new Property("event", "", "The clinical service, such as a colonoscopy or an appendectomy, being documented.", 0, java.lang.Integer.MAX_VALUE, event));
3215        children.add(new Property("section", "", "The root of the sections that make up the composition.", 0, java.lang.Integer.MAX_VALUE, section));
3216      }
3217
3218      @Override
3219      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
3220        switch (_hash) {
3221        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "A version-independent identifier for the Composition. This identifier stays constant as the composition is changed over time.", 0, 1, identifier);
3222        case -892481550: /*status*/  return new Property("status", "code", "The workflow/clinical status of this composition. The status is a marker for the clinical standing of the document.", 0, 1, status);
3223        case 3575610: /*type*/  return 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, 1, type);
3224        case 50511102: /*category*/  return new Property("category", "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, category);
3225        case -1867885268: /*subject*/  return 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, 1, subject);
3226        case 1524132147: /*encounter*/  return new Property("encounter", "Reference(Encounter)", "Describes the clinical encounter or type of care this documentation is associated with.", 0, 1, encounter);
3227        case 3076014: /*date*/  return new Property("date", "dateTime", "The composition editing time, when the composition was last logically changed by the author.", 0, 1, date);
3228        case -1406328437: /*author*/  return new Property("author", "Reference(Practitioner|PractitionerRole|Device|Patient|RelatedPerson|Organization)", "Identifies who is responsible for the information in the composition, not necessarily who typed it in.", 0, java.lang.Integer.MAX_VALUE, author);
3229        case 110371416: /*title*/  return new Property("title", "string", "Official human-readable label for the composition.", 0, 1, title);
3230        case -1923018202: /*confidentiality*/  return new Property("confidentiality", "code", "The code specifying the level of confidentiality of the Composition.", 0, 1, confidentiality);
3231        case 542920370: /*attester*/  return new Property("attester", "", "A participant who has attested to the accuracy of the composition/document.", 0, java.lang.Integer.MAX_VALUE, attester);
3232        case 1611297262: /*custodian*/  return 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, 1, custodian);
3233        case -7765931: /*relatesTo*/  return new Property("relatesTo", "", "Relationships that this composition has with other compositions or documents that already exist.", 0, java.lang.Integer.MAX_VALUE, relatesTo);
3234        case 96891546: /*event*/  return new Property("event", "", "The clinical service, such as a colonoscopy or an appendectomy, being documented.", 0, java.lang.Integer.MAX_VALUE, event);
3235        case 1970241253: /*section*/  return new Property("section", "", "The root of the sections that make up the composition.", 0, java.lang.Integer.MAX_VALUE, section);
3236        default: return super.getNamedProperty(_hash, _name, _checkValid);
3237        }
3238
3239      }
3240
3241      @Override
3242      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
3243        switch (hash) {
3244        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : new Base[] {this.identifier}; // Identifier
3245        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<CompositionStatus>
3246        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
3247        case 50511102: /*category*/ return this.category == null ? new Base[0] : this.category.toArray(new Base[this.category.size()]); // CodeableConcept
3248        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
3249        case 1524132147: /*encounter*/ return this.encounter == null ? new Base[0] : new Base[] {this.encounter}; // Reference
3250        case 3076014: /*date*/ return this.date == null ? new Base[0] : new Base[] {this.date}; // DateTimeType
3251        case -1406328437: /*author*/ return this.author == null ? new Base[0] : this.author.toArray(new Base[this.author.size()]); // Reference
3252        case 110371416: /*title*/ return this.title == null ? new Base[0] : new Base[] {this.title}; // StringType
3253        case -1923018202: /*confidentiality*/ return this.confidentiality == null ? new Base[0] : new Base[] {this.confidentiality}; // Enumeration<DocumentConfidentiality>
3254        case 542920370: /*attester*/ return this.attester == null ? new Base[0] : this.attester.toArray(new Base[this.attester.size()]); // CompositionAttesterComponent
3255        case 1611297262: /*custodian*/ return this.custodian == null ? new Base[0] : new Base[] {this.custodian}; // Reference
3256        case -7765931: /*relatesTo*/ return this.relatesTo == null ? new Base[0] : this.relatesTo.toArray(new Base[this.relatesTo.size()]); // CompositionRelatesToComponent
3257        case 96891546: /*event*/ return this.event == null ? new Base[0] : this.event.toArray(new Base[this.event.size()]); // CompositionEventComponent
3258        case 1970241253: /*section*/ return this.section == null ? new Base[0] : this.section.toArray(new Base[this.section.size()]); // SectionComponent
3259        default: return super.getProperty(hash, name, checkValid);
3260        }
3261
3262      }
3263
3264      @Override
3265      public Base setProperty(int hash, String name, Base value) throws FHIRException {
3266        switch (hash) {
3267        case -1618432855: // identifier
3268          this.identifier = castToIdentifier(value); // Identifier
3269          return value;
3270        case -892481550: // status
3271          value = new CompositionStatusEnumFactory().fromType(castToCode(value));
3272          this.status = (Enumeration) value; // Enumeration<CompositionStatus>
3273          return value;
3274        case 3575610: // type
3275          this.type = castToCodeableConcept(value); // CodeableConcept
3276          return value;
3277        case 50511102: // category
3278          this.getCategory().add(castToCodeableConcept(value)); // CodeableConcept
3279          return value;
3280        case -1867885268: // subject
3281          this.subject = castToReference(value); // Reference
3282          return value;
3283        case 1524132147: // encounter
3284          this.encounter = castToReference(value); // Reference
3285          return value;
3286        case 3076014: // date
3287          this.date = castToDateTime(value); // DateTimeType
3288          return value;
3289        case -1406328437: // author
3290          this.getAuthor().add(castToReference(value)); // Reference
3291          return value;
3292        case 110371416: // title
3293          this.title = castToString(value); // StringType
3294          return value;
3295        case -1923018202: // confidentiality
3296          value = new DocumentConfidentialityEnumFactory().fromType(castToCode(value));
3297          this.confidentiality = (Enumeration) value; // Enumeration<DocumentConfidentiality>
3298          return value;
3299        case 542920370: // attester
3300          this.getAttester().add((CompositionAttesterComponent) value); // CompositionAttesterComponent
3301          return value;
3302        case 1611297262: // custodian
3303          this.custodian = castToReference(value); // Reference
3304          return value;
3305        case -7765931: // relatesTo
3306          this.getRelatesTo().add((CompositionRelatesToComponent) value); // CompositionRelatesToComponent
3307          return value;
3308        case 96891546: // event
3309          this.getEvent().add((CompositionEventComponent) value); // CompositionEventComponent
3310          return value;
3311        case 1970241253: // section
3312          this.getSection().add((SectionComponent) value); // SectionComponent
3313          return value;
3314        default: return super.setProperty(hash, name, value);
3315        }
3316
3317      }
3318
3319      @Override
3320      public Base setProperty(String name, Base value) throws FHIRException {
3321        if (name.equals("identifier")) {
3322          this.identifier = castToIdentifier(value); // Identifier
3323        } else if (name.equals("status")) {
3324          value = new CompositionStatusEnumFactory().fromType(castToCode(value));
3325          this.status = (Enumeration) value; // Enumeration<CompositionStatus>
3326        } else if (name.equals("type")) {
3327          this.type = castToCodeableConcept(value); // CodeableConcept
3328        } else if (name.equals("category")) {
3329          this.getCategory().add(castToCodeableConcept(value));
3330        } else if (name.equals("subject")) {
3331          this.subject = castToReference(value); // Reference
3332        } else if (name.equals("encounter")) {
3333          this.encounter = castToReference(value); // Reference
3334        } else if (name.equals("date")) {
3335          this.date = castToDateTime(value); // DateTimeType
3336        } else if (name.equals("author")) {
3337          this.getAuthor().add(castToReference(value));
3338        } else if (name.equals("title")) {
3339          this.title = castToString(value); // StringType
3340        } else if (name.equals("confidentiality")) {
3341          value = new DocumentConfidentialityEnumFactory().fromType(castToCode(value));
3342          this.confidentiality = (Enumeration) value; // Enumeration<DocumentConfidentiality>
3343        } else if (name.equals("attester")) {
3344          this.getAttester().add((CompositionAttesterComponent) value);
3345        } else if (name.equals("custodian")) {
3346          this.custodian = castToReference(value); // Reference
3347        } else if (name.equals("relatesTo")) {
3348          this.getRelatesTo().add((CompositionRelatesToComponent) value);
3349        } else if (name.equals("event")) {
3350          this.getEvent().add((CompositionEventComponent) value);
3351        } else if (name.equals("section")) {
3352          this.getSection().add((SectionComponent) value);
3353        } else
3354          return super.setProperty(name, value);
3355        return value;
3356      }
3357
3358      @Override
3359      public Base makeProperty(int hash, String name) throws FHIRException {
3360        switch (hash) {
3361        case -1618432855:  return getIdentifier(); 
3362        case -892481550:  return getStatusElement();
3363        case 3575610:  return getType(); 
3364        case 50511102:  return addCategory(); 
3365        case -1867885268:  return getSubject(); 
3366        case 1524132147:  return getEncounter(); 
3367        case 3076014:  return getDateElement();
3368        case -1406328437:  return addAuthor(); 
3369        case 110371416:  return getTitleElement();
3370        case -1923018202:  return getConfidentialityElement();
3371        case 542920370:  return addAttester(); 
3372        case 1611297262:  return getCustodian(); 
3373        case -7765931:  return addRelatesTo(); 
3374        case 96891546:  return addEvent(); 
3375        case 1970241253:  return addSection(); 
3376        default: return super.makeProperty(hash, name);
3377        }
3378
3379      }
3380
3381      @Override
3382      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
3383        switch (hash) {
3384        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
3385        case -892481550: /*status*/ return new String[] {"code"};
3386        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
3387        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
3388        case -1867885268: /*subject*/ return new String[] {"Reference"};
3389        case 1524132147: /*encounter*/ return new String[] {"Reference"};
3390        case 3076014: /*date*/ return new String[] {"dateTime"};
3391        case -1406328437: /*author*/ return new String[] {"Reference"};
3392        case 110371416: /*title*/ return new String[] {"string"};
3393        case -1923018202: /*confidentiality*/ return new String[] {"code"};
3394        case 542920370: /*attester*/ return new String[] {};
3395        case 1611297262: /*custodian*/ return new String[] {"Reference"};
3396        case -7765931: /*relatesTo*/ return new String[] {};
3397        case 96891546: /*event*/ return new String[] {};
3398        case 1970241253: /*section*/ return new String[] {};
3399        default: return super.getTypesForProperty(hash, name);
3400        }
3401
3402      }
3403
3404      @Override
3405      public Base addChild(String name) throws FHIRException {
3406        if (name.equals("identifier")) {
3407          this.identifier = new Identifier();
3408          return this.identifier;
3409        }
3410        else if (name.equals("status")) {
3411          throw new FHIRException("Cannot call addChild on a primitive type Composition.status");
3412        }
3413        else if (name.equals("type")) {
3414          this.type = new CodeableConcept();
3415          return this.type;
3416        }
3417        else if (name.equals("category")) {
3418          return addCategory();
3419        }
3420        else if (name.equals("subject")) {
3421          this.subject = new Reference();
3422          return this.subject;
3423        }
3424        else if (name.equals("encounter")) {
3425          this.encounter = new Reference();
3426          return this.encounter;
3427        }
3428        else if (name.equals("date")) {
3429          throw new FHIRException("Cannot call addChild on a primitive type Composition.date");
3430        }
3431        else if (name.equals("author")) {
3432          return addAuthor();
3433        }
3434        else if (name.equals("title")) {
3435          throw new FHIRException("Cannot call addChild on a primitive type Composition.title");
3436        }
3437        else if (name.equals("confidentiality")) {
3438          throw new FHIRException("Cannot call addChild on a primitive type Composition.confidentiality");
3439        }
3440        else if (name.equals("attester")) {
3441          return addAttester();
3442        }
3443        else if (name.equals("custodian")) {
3444          this.custodian = new Reference();
3445          return this.custodian;
3446        }
3447        else if (name.equals("relatesTo")) {
3448          return addRelatesTo();
3449        }
3450        else if (name.equals("event")) {
3451          return addEvent();
3452        }
3453        else if (name.equals("section")) {
3454          return addSection();
3455        }
3456        else
3457          return super.addChild(name);
3458      }
3459
3460  public String fhirType() {
3461    return "Composition";
3462
3463  }
3464
3465      public Composition copy() {
3466        Composition dst = new Composition();
3467        copyValues(dst);
3468        dst.identifier = identifier == null ? null : identifier.copy();
3469        dst.status = status == null ? null : status.copy();
3470        dst.type = type == null ? null : type.copy();
3471        if (category != null) {
3472          dst.category = new ArrayList<CodeableConcept>();
3473          for (CodeableConcept i : category)
3474            dst.category.add(i.copy());
3475        };
3476        dst.subject = subject == null ? null : subject.copy();
3477        dst.encounter = encounter == null ? null : encounter.copy();
3478        dst.date = date == null ? null : date.copy();
3479        if (author != null) {
3480          dst.author = new ArrayList<Reference>();
3481          for (Reference i : author)
3482            dst.author.add(i.copy());
3483        };
3484        dst.title = title == null ? null : title.copy();
3485        dst.confidentiality = confidentiality == null ? null : confidentiality.copy();
3486        if (attester != null) {
3487          dst.attester = new ArrayList<CompositionAttesterComponent>();
3488          for (CompositionAttesterComponent i : attester)
3489            dst.attester.add(i.copy());
3490        };
3491        dst.custodian = custodian == null ? null : custodian.copy();
3492        if (relatesTo != null) {
3493          dst.relatesTo = new ArrayList<CompositionRelatesToComponent>();
3494          for (CompositionRelatesToComponent i : relatesTo)
3495            dst.relatesTo.add(i.copy());
3496        };
3497        if (event != null) {
3498          dst.event = new ArrayList<CompositionEventComponent>();
3499          for (CompositionEventComponent i : event)
3500            dst.event.add(i.copy());
3501        };
3502        if (section != null) {
3503          dst.section = new ArrayList<SectionComponent>();
3504          for (SectionComponent i : section)
3505            dst.section.add(i.copy());
3506        };
3507        return dst;
3508      }
3509
3510      protected Composition typedCopy() {
3511        return copy();
3512      }
3513
3514      @Override
3515      public boolean equalsDeep(Base other_) {
3516        if (!super.equalsDeep(other_))
3517          return false;
3518        if (!(other_ instanceof Composition))
3519          return false;
3520        Composition o = (Composition) other_;
3521        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(type, o.type, true)
3522           && compareDeep(category, o.category, true) && compareDeep(subject, o.subject, true) && compareDeep(encounter, o.encounter, true)
3523           && compareDeep(date, o.date, true) && compareDeep(author, o.author, true) && compareDeep(title, o.title, true)
3524           && compareDeep(confidentiality, o.confidentiality, true) && compareDeep(attester, o.attester, true)
3525           && compareDeep(custodian, o.custodian, true) && compareDeep(relatesTo, o.relatesTo, true) && compareDeep(event, o.event, true)
3526           && compareDeep(section, o.section, true);
3527      }
3528
3529      @Override
3530      public boolean equalsShallow(Base other_) {
3531        if (!super.equalsShallow(other_))
3532          return false;
3533        if (!(other_ instanceof Composition))
3534          return false;
3535        Composition o = (Composition) other_;
3536        return compareValues(status, o.status, true) && compareValues(date, o.date, true) && compareValues(title, o.title, true)
3537           && compareValues(confidentiality, o.confidentiality, true);
3538      }
3539
3540      public boolean isEmpty() {
3541        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, type
3542          , category, subject, encounter, date, author, title, confidentiality, attester
3543          , custodian, relatesTo, event, section);
3544      }
3545
3546  @Override
3547  public ResourceType getResourceType() {
3548    return ResourceType.Composition;
3549   }
3550
3551 /**
3552   * Search parameter: <b>date</b>
3553   * <p>
3554   * Description: <b>Composition editing time</b><br>
3555   * Type: <b>date</b><br>
3556   * Path: <b>Composition.date</b><br>
3557   * </p>
3558   */
3559  @SearchParamDefinition(name="date", path="Composition.date", description="Composition editing time", type="date" )
3560  public static final String SP_DATE = "date";
3561 /**
3562   * <b>Fluent Client</b> search parameter constant for <b>date</b>
3563   * <p>
3564   * Description: <b>Composition editing time</b><br>
3565   * Type: <b>date</b><br>
3566   * Path: <b>Composition.date</b><br>
3567   * </p>
3568   */
3569  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATE);
3570
3571 /**
3572   * Search parameter: <b>identifier</b>
3573   * <p>
3574   * Description: <b>Version-independent identifier for the Composition</b><br>
3575   * Type: <b>token</b><br>
3576   * Path: <b>Composition.identifier</b><br>
3577   * </p>
3578   */
3579  @SearchParamDefinition(name="identifier", path="Composition.identifier", description="Version-independent identifier for the Composition", type="token" )
3580  public static final String SP_IDENTIFIER = "identifier";
3581 /**
3582   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
3583   * <p>
3584   * Description: <b>Version-independent identifier for the Composition</b><br>
3585   * Type: <b>token</b><br>
3586   * Path: <b>Composition.identifier</b><br>
3587   * </p>
3588   */
3589  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
3590
3591 /**
3592   * Search parameter: <b>period</b>
3593   * <p>
3594   * Description: <b>The period covered by the documentation</b><br>
3595   * Type: <b>date</b><br>
3596   * Path: <b>Composition.event.period</b><br>
3597   * </p>
3598   */
3599  @SearchParamDefinition(name="period", path="Composition.event.period", description="The period covered by the documentation", type="date" )
3600  public static final String SP_PERIOD = "period";
3601 /**
3602   * <b>Fluent Client</b> search parameter constant for <b>period</b>
3603   * <p>
3604   * Description: <b>The period covered by the documentation</b><br>
3605   * Type: <b>date</b><br>
3606   * Path: <b>Composition.event.period</b><br>
3607   * </p>
3608   */
3609  public static final ca.uhn.fhir.rest.gclient.DateClientParam PERIOD = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_PERIOD);
3610
3611 /**
3612   * Search parameter: <b>related-id</b>
3613   * <p>
3614   * Description: <b>Target of the relationship</b><br>
3615   * Type: <b>token</b><br>
3616   * Path: <b>Composition.relatesTo.targetIdentifier</b><br>
3617   * </p>
3618   */
3619  @SearchParamDefinition(name="related-id", path="(Composition.relatesTo.target as Identifier)", description="Target of the relationship", type="token" )
3620  public static final String SP_RELATED_ID = "related-id";
3621 /**
3622   * <b>Fluent Client</b> search parameter constant for <b>related-id</b>
3623   * <p>
3624   * Description: <b>Target of the relationship</b><br>
3625   * Type: <b>token</b><br>
3626   * Path: <b>Composition.relatesTo.targetIdentifier</b><br>
3627   * </p>
3628   */
3629  public static final ca.uhn.fhir.rest.gclient.TokenClientParam RELATED_ID = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_RELATED_ID);
3630
3631 /**
3632   * Search parameter: <b>subject</b>
3633   * <p>
3634   * Description: <b>Who and/or what the composition is about</b><br>
3635   * Type: <b>reference</b><br>
3636   * Path: <b>Composition.subject</b><br>
3637   * </p>
3638   */
3639  @SearchParamDefinition(name="subject", path="Composition.subject", description="Who and/or what the composition is about", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner") } )
3640  public static final String SP_SUBJECT = "subject";
3641 /**
3642   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
3643   * <p>
3644   * Description: <b>Who and/or what the composition is about</b><br>
3645   * Type: <b>reference</b><br>
3646   * Path: <b>Composition.subject</b><br>
3647   * </p>
3648   */
3649  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
3650
3651/**
3652   * Constant for fluent queries to be used to add include statements. Specifies
3653   * the path value of "<b>Composition:subject</b>".
3654   */
3655  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("Composition:subject").toLocked();
3656
3657 /**
3658   * Search parameter: <b>author</b>
3659   * <p>
3660   * Description: <b>Who and/or what authored the composition</b><br>
3661   * Type: <b>reference</b><br>
3662   * Path: <b>Composition.author</b><br>
3663   * </p>
3664   */
3665  @SearchParamDefinition(name="author", path="Composition.author", description="Who and/or what authored the composition", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Device"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner"), @ca.uhn.fhir.model.api.annotation.Compartment(name="RelatedPerson") }, target={Device.class, Organization.class, Patient.class, Practitioner.class, PractitionerRole.class, RelatedPerson.class } )
3666  public static final String SP_AUTHOR = "author";
3667 /**
3668   * <b>Fluent Client</b> search parameter constant for <b>author</b>
3669   * <p>
3670   * Description: <b>Who and/or what authored the composition</b><br>
3671   * Type: <b>reference</b><br>
3672   * Path: <b>Composition.author</b><br>
3673   * </p>
3674   */
3675  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam AUTHOR = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_AUTHOR);
3676
3677/**
3678   * Constant for fluent queries to be used to add include statements. Specifies
3679   * the path value of "<b>Composition:author</b>".
3680   */
3681  public static final ca.uhn.fhir.model.api.Include INCLUDE_AUTHOR = new ca.uhn.fhir.model.api.Include("Composition:author").toLocked();
3682
3683 /**
3684   * Search parameter: <b>confidentiality</b>
3685   * <p>
3686   * Description: <b>As defined by affinity domain</b><br>
3687   * Type: <b>token</b><br>
3688   * Path: <b>Composition.confidentiality</b><br>
3689   * </p>
3690   */
3691  @SearchParamDefinition(name="confidentiality", path="Composition.confidentiality", description="As defined by affinity domain", type="token" )
3692  public static final String SP_CONFIDENTIALITY = "confidentiality";
3693 /**
3694   * <b>Fluent Client</b> search parameter constant for <b>confidentiality</b>
3695   * <p>
3696   * Description: <b>As defined by affinity domain</b><br>
3697   * Type: <b>token</b><br>
3698   * Path: <b>Composition.confidentiality</b><br>
3699   * </p>
3700   */
3701  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CONFIDENTIALITY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CONFIDENTIALITY);
3702
3703 /**
3704   * Search parameter: <b>section</b>
3705   * <p>
3706   * Description: <b>Classification of section (recommended)</b><br>
3707   * Type: <b>token</b><br>
3708   * Path: <b>Composition.section.code</b><br>
3709   * </p>
3710   */
3711  @SearchParamDefinition(name="section", path="Composition.section.code", description="Classification of section (recommended)", type="token" )
3712  public static final String SP_SECTION = "section";
3713 /**
3714   * <b>Fluent Client</b> search parameter constant for <b>section</b>
3715   * <p>
3716   * Description: <b>Classification of section (recommended)</b><br>
3717   * Type: <b>token</b><br>
3718   * Path: <b>Composition.section.code</b><br>
3719   * </p>
3720   */
3721  public static final ca.uhn.fhir.rest.gclient.TokenClientParam SECTION = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_SECTION);
3722
3723 /**
3724   * Search parameter: <b>encounter</b>
3725   * <p>
3726   * Description: <b>Context of the Composition</b><br>
3727   * Type: <b>reference</b><br>
3728   * Path: <b>Composition.encounter</b><br>
3729   * </p>
3730   */
3731  @SearchParamDefinition(name="encounter", path="Composition.encounter", description="Context of the Composition", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Encounter") }, target={Encounter.class } )
3732  public static final String SP_ENCOUNTER = "encounter";
3733 /**
3734   * <b>Fluent Client</b> search parameter constant for <b>encounter</b>
3735   * <p>
3736   * Description: <b>Context of the Composition</b><br>
3737   * Type: <b>reference</b><br>
3738   * Path: <b>Composition.encounter</b><br>
3739   * </p>
3740   */
3741  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENCOUNTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENCOUNTER);
3742
3743/**
3744   * Constant for fluent queries to be used to add include statements. Specifies
3745   * the path value of "<b>Composition:encounter</b>".
3746   */
3747  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENCOUNTER = new ca.uhn.fhir.model.api.Include("Composition:encounter").toLocked();
3748
3749 /**
3750   * Search parameter: <b>type</b>
3751   * <p>
3752   * Description: <b>Kind of composition (LOINC if possible)</b><br>
3753   * Type: <b>token</b><br>
3754   * Path: <b>Composition.type</b><br>
3755   * </p>
3756   */
3757  @SearchParamDefinition(name="type", path="Composition.type", description="Kind of composition (LOINC if possible)", type="token" )
3758  public static final String SP_TYPE = "type";
3759 /**
3760   * <b>Fluent Client</b> search parameter constant for <b>type</b>
3761   * <p>
3762   * Description: <b>Kind of composition (LOINC if possible)</b><br>
3763   * Type: <b>token</b><br>
3764   * Path: <b>Composition.type</b><br>
3765   * </p>
3766   */
3767  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_TYPE);
3768
3769 /**
3770   * Search parameter: <b>title</b>
3771   * <p>
3772   * Description: <b>Human Readable name/title</b><br>
3773   * Type: <b>string</b><br>
3774   * Path: <b>Composition.title</b><br>
3775   * </p>
3776   */
3777  @SearchParamDefinition(name="title", path="Composition.title", description="Human Readable name/title", type="string" )
3778  public static final String SP_TITLE = "title";
3779 /**
3780   * <b>Fluent Client</b> search parameter constant for <b>title</b>
3781   * <p>
3782   * Description: <b>Human Readable name/title</b><br>
3783   * Type: <b>string</b><br>
3784   * Path: <b>Composition.title</b><br>
3785   * </p>
3786   */
3787  public static final ca.uhn.fhir.rest.gclient.StringClientParam TITLE = new ca.uhn.fhir.rest.gclient.StringClientParam(SP_TITLE);
3788
3789 /**
3790   * Search parameter: <b>attester</b>
3791   * <p>
3792   * Description: <b>Who attested the composition</b><br>
3793   * Type: <b>reference</b><br>
3794   * Path: <b>Composition.attester.party</b><br>
3795   * </p>
3796   */
3797  @SearchParamDefinition(name="attester", path="Composition.attester.party", description="Who attested the composition", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner") }, target={Organization.class, Patient.class, Practitioner.class, PractitionerRole.class, RelatedPerson.class } )
3798  public static final String SP_ATTESTER = "attester";
3799 /**
3800   * <b>Fluent Client</b> search parameter constant for <b>attester</b>
3801   * <p>
3802   * Description: <b>Who attested the composition</b><br>
3803   * Type: <b>reference</b><br>
3804   * Path: <b>Composition.attester.party</b><br>
3805   * </p>
3806   */
3807  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ATTESTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ATTESTER);
3808
3809/**
3810   * Constant for fluent queries to be used to add include statements. Specifies
3811   * the path value of "<b>Composition:attester</b>".
3812   */
3813  public static final ca.uhn.fhir.model.api.Include INCLUDE_ATTESTER = new ca.uhn.fhir.model.api.Include("Composition:attester").toLocked();
3814
3815 /**
3816   * Search parameter: <b>entry</b>
3817   * <p>
3818   * Description: <b>A reference to data that supports this section</b><br>
3819   * Type: <b>reference</b><br>
3820   * Path: <b>Composition.section.entry</b><br>
3821   * </p>
3822   */
3823  @SearchParamDefinition(name="entry", path="Composition.section.entry", description="A reference to data that supports this section", type="reference" )
3824  public static final String SP_ENTRY = "entry";
3825 /**
3826   * <b>Fluent Client</b> search parameter constant for <b>entry</b>
3827   * <p>
3828   * Description: <b>A reference to data that supports this section</b><br>
3829   * Type: <b>reference</b><br>
3830   * Path: <b>Composition.section.entry</b><br>
3831   * </p>
3832   */
3833  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENTRY = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENTRY);
3834
3835/**
3836   * Constant for fluent queries to be used to add include statements. Specifies
3837   * the path value of "<b>Composition:entry</b>".
3838   */
3839  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENTRY = new ca.uhn.fhir.model.api.Include("Composition:entry").toLocked();
3840
3841 /**
3842   * Search parameter: <b>related-ref</b>
3843   * <p>
3844   * Description: <b>Target of the relationship</b><br>
3845   * Type: <b>reference</b><br>
3846   * Path: <b>Composition.relatesTo.targetReference</b><br>
3847   * </p>
3848   */
3849  @SearchParamDefinition(name="related-ref", path="(Composition.relatesTo.target as Reference)", description="Target of the relationship", type="reference", target={Composition.class } )
3850  public static final String SP_RELATED_REF = "related-ref";
3851 /**
3852   * <b>Fluent Client</b> search parameter constant for <b>related-ref</b>
3853   * <p>
3854   * Description: <b>Target of the relationship</b><br>
3855   * Type: <b>reference</b><br>
3856   * Path: <b>Composition.relatesTo.targetReference</b><br>
3857   * </p>
3858   */
3859  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam RELATED_REF = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_RELATED_REF);
3860
3861/**
3862   * Constant for fluent queries to be used to add include statements. Specifies
3863   * the path value of "<b>Composition:related-ref</b>".
3864   */
3865  public static final ca.uhn.fhir.model.api.Include INCLUDE_RELATED_REF = new ca.uhn.fhir.model.api.Include("Composition:related-ref").toLocked();
3866
3867 /**
3868   * Search parameter: <b>patient</b>
3869   * <p>
3870   * Description: <b>Who and/or what the composition is about</b><br>
3871   * Type: <b>reference</b><br>
3872   * Path: <b>Composition.subject</b><br>
3873   * </p>
3874   */
3875  @SearchParamDefinition(name="patient", path="Composition.subject.where(resolve() is Patient)", description="Who and/or what the composition is about", type="reference", target={Patient.class } )
3876  public static final String SP_PATIENT = "patient";
3877 /**
3878   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
3879   * <p>
3880   * Description: <b>Who and/or what the composition is about</b><br>
3881   * Type: <b>reference</b><br>
3882   * Path: <b>Composition.subject</b><br>
3883   * </p>
3884   */
3885  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
3886
3887/**
3888   * Constant for fluent queries to be used to add include statements. Specifies
3889   * the path value of "<b>Composition:patient</b>".
3890   */
3891  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("Composition:patient").toLocked();
3892
3893 /**
3894   * Search parameter: <b>context</b>
3895   * <p>
3896   * Description: <b>Code(s) that apply to the event being documented</b><br>
3897   * Type: <b>token</b><br>
3898   * Path: <b>Composition.event.code</b><br>
3899   * </p>
3900   */
3901  @SearchParamDefinition(name="context", path="Composition.event.code", description="Code(s) that apply to the event being documented", type="token" )
3902  public static final String SP_CONTEXT = "context";
3903 /**
3904   * <b>Fluent Client</b> search parameter constant for <b>context</b>
3905   * <p>
3906   * Description: <b>Code(s) that apply to the event being documented</b><br>
3907   * Type: <b>token</b><br>
3908   * Path: <b>Composition.event.code</b><br>
3909   * </p>
3910   */
3911  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CONTEXT = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CONTEXT);
3912
3913 /**
3914   * Search parameter: <b>category</b>
3915   * <p>
3916   * Description: <b>Categorization of Composition</b><br>
3917   * Type: <b>token</b><br>
3918   * Path: <b>Composition.category</b><br>
3919   * </p>
3920   */
3921  @SearchParamDefinition(name="category", path="Composition.category", description="Categorization of Composition", type="token" )
3922  public static final String SP_CATEGORY = "category";
3923 /**
3924   * <b>Fluent Client</b> search parameter constant for <b>category</b>
3925   * <p>
3926   * Description: <b>Categorization of Composition</b><br>
3927   * Type: <b>token</b><br>
3928   * Path: <b>Composition.category</b><br>
3929   * </p>
3930   */
3931  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CATEGORY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CATEGORY);
3932
3933 /**
3934   * Search parameter: <b>status</b>
3935   * <p>
3936   * Description: <b>preliminary | final | amended | entered-in-error</b><br>
3937   * Type: <b>token</b><br>
3938   * Path: <b>Composition.status</b><br>
3939   * </p>
3940   */
3941  @SearchParamDefinition(name="status", path="Composition.status", description="preliminary | final | amended | entered-in-error", type="token" )
3942  public static final String SP_STATUS = "status";
3943 /**
3944   * <b>Fluent Client</b> search parameter constant for <b>status</b>
3945   * <p>
3946   * Description: <b>preliminary | final | amended | entered-in-error</b><br>
3947   * Type: <b>token</b><br>
3948   * Path: <b>Composition.status</b><br>
3949   * </p>
3950   */
3951  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
3952
3953
3954}
3955