001package org.hl7.fhir.r4.model;
002
003
004
005/*
006  Copyright (c) 2011+, HL7, Inc.
007  All rights reserved.
008  
009  Redistribution and use in source and binary forms, with or without modification, 
010  are permitted provided that the following conditions are met:
011  
012   * Redistributions of source code must retain the above copyright notice, this 
013     list of conditions and the following disclaimer.
014   * Redistributions in binary form must reproduce the above copyright notice, 
015     this list of conditions and the following disclaimer in the documentation 
016     and/or other materials provided with the distribution.
017   * Neither the name of HL7 nor the names of its contributors may be used to 
018     endorse or promote products derived from this software without specific 
019     prior written permission.
020  
021  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
022  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
023  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
024  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
025  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
026  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
027  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
028  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
029  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
030  POSSIBILITY OF SUCH DAMAGE.
031  
032*/
033
034
035// Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1
036
037import java.util.*;
038
039import org.hl7.fhir.utilities.Utilities;
040import org.hl7.fhir.r4.model.Enumerations.*;
041import ca.uhn.fhir.model.api.annotation.ResourceDef;
042import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
043import ca.uhn.fhir.model.api.annotation.Child;
044import ca.uhn.fhir.model.api.annotation.ChildOrder;
045import ca.uhn.fhir.model.api.annotation.Description;
046import ca.uhn.fhir.model.api.annotation.Block;
047import org.hl7.fhir.instance.model.api.*;
048import org.hl7.fhir.exceptions.FHIRException;
049/**
050 * A reference to a document of any kind for any purpose. Provides metadata about the document so that the document can be discovered and managed. The scope of a document is any seralized object with a mime-type, so includes formal patient centric documents (CDA), cliical notes, scanned paper, and non-patient specific documents like policy text.
051 */
052@ResourceDef(name="DocumentReference", profile="http://hl7.org/fhir/StructureDefinition/DocumentReference")
053public class DocumentReference extends DomainResource {
054
055    public enum ReferredDocumentStatus {
056        /**
057         * This is a preliminary composition or document (also known as initial or interim). The content may be incomplete or unverified.
058         */
059        PRELIMINARY, 
060        /**
061         * 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.
062         */
063        FINAL, 
064        /**
065         * 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.
066         */
067        AMENDED, 
068        /**
069         * 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.
070         */
071        ENTEREDINERROR, 
072        /**
073         * added to help the parsers with the generic types
074         */
075        NULL;
076        public static ReferredDocumentStatus fromCode(String codeString) throws FHIRException {
077            if (codeString == null || "".equals(codeString))
078                return null;
079        if ("preliminary".equals(codeString))
080          return PRELIMINARY;
081        if ("final".equals(codeString))
082          return FINAL;
083        if ("amended".equals(codeString))
084          return AMENDED;
085        if ("entered-in-error".equals(codeString))
086          return ENTEREDINERROR;
087        if (Configuration.isAcceptInvalidEnums())
088          return null;
089        else
090          throw new FHIRException("Unknown ReferredDocumentStatus code '"+codeString+"'");
091        }
092        public String toCode() {
093          switch (this) {
094            case PRELIMINARY: return "preliminary";
095            case FINAL: return "final";
096            case AMENDED: return "amended";
097            case ENTEREDINERROR: return "entered-in-error";
098            case NULL: return null;
099            default: return "?";
100          }
101        }
102        public String getSystem() {
103          switch (this) {
104            case PRELIMINARY: return "http://hl7.org/fhir/composition-status";
105            case FINAL: return "http://hl7.org/fhir/composition-status";
106            case AMENDED: return "http://hl7.org/fhir/composition-status";
107            case ENTEREDINERROR: return "http://hl7.org/fhir/composition-status";
108            case NULL: return null;
109            default: return "?";
110          }
111        }
112        public String getDefinition() {
113          switch (this) {
114            case PRELIMINARY: return "This is a preliminary composition or document (also known as initial or interim). The content may be incomplete or unverified.";
115            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.";
116            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.";
117            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.";
118            case NULL: return null;
119            default: return "?";
120          }
121        }
122        public String getDisplay() {
123          switch (this) {
124            case PRELIMINARY: return "Preliminary";
125            case FINAL: return "Final";
126            case AMENDED: return "Amended";
127            case ENTEREDINERROR: return "Entered in Error";
128            case NULL: return null;
129            default: return "?";
130          }
131        }
132    }
133
134  public static class ReferredDocumentStatusEnumFactory implements EnumFactory<ReferredDocumentStatus> {
135    public ReferredDocumentStatus fromCode(String codeString) throws IllegalArgumentException {
136      if (codeString == null || "".equals(codeString))
137            if (codeString == null || "".equals(codeString))
138                return null;
139        if ("preliminary".equals(codeString))
140          return ReferredDocumentStatus.PRELIMINARY;
141        if ("final".equals(codeString))
142          return ReferredDocumentStatus.FINAL;
143        if ("amended".equals(codeString))
144          return ReferredDocumentStatus.AMENDED;
145        if ("entered-in-error".equals(codeString))
146          return ReferredDocumentStatus.ENTEREDINERROR;
147        throw new IllegalArgumentException("Unknown ReferredDocumentStatus code '"+codeString+"'");
148        }
149        public Enumeration<ReferredDocumentStatus> fromType(Base code) throws FHIRException {
150          if (code == null)
151            return null;
152          if (code.isEmpty())
153            return new Enumeration<ReferredDocumentStatus>(this);
154          String codeString = ((PrimitiveType) code).asStringValue();
155          if (codeString == null || "".equals(codeString))
156            return null;
157        if ("preliminary".equals(codeString))
158          return new Enumeration<ReferredDocumentStatus>(this, ReferredDocumentStatus.PRELIMINARY);
159        if ("final".equals(codeString))
160          return new Enumeration<ReferredDocumentStatus>(this, ReferredDocumentStatus.FINAL);
161        if ("amended".equals(codeString))
162          return new Enumeration<ReferredDocumentStatus>(this, ReferredDocumentStatus.AMENDED);
163        if ("entered-in-error".equals(codeString))
164          return new Enumeration<ReferredDocumentStatus>(this, ReferredDocumentStatus.ENTEREDINERROR);
165        throw new FHIRException("Unknown ReferredDocumentStatus code '"+codeString+"'");
166        }
167    public String toCode(ReferredDocumentStatus code) {
168      if (code == ReferredDocumentStatus.PRELIMINARY)
169        return "preliminary";
170      if (code == ReferredDocumentStatus.FINAL)
171        return "final";
172      if (code == ReferredDocumentStatus.AMENDED)
173        return "amended";
174      if (code == ReferredDocumentStatus.ENTEREDINERROR)
175        return "entered-in-error";
176      return "?";
177      }
178    public String toSystem(ReferredDocumentStatus code) {
179      return code.getSystem();
180      }
181    }
182
183    public enum DocumentRelationshipType {
184        /**
185         * This document logically replaces or supersedes the target document.
186         */
187        REPLACES, 
188        /**
189         * This document was generated by transforming the target document (e.g. format or language conversion).
190         */
191        TRANSFORMS, 
192        /**
193         * This document is a signature of the target document.
194         */
195        SIGNS, 
196        /**
197         * This document adds additional information to the target document.
198         */
199        APPENDS, 
200        /**
201         * added to help the parsers with the generic types
202         */
203        NULL;
204        public static DocumentRelationshipType fromCode(String codeString) throws FHIRException {
205            if (codeString == null || "".equals(codeString))
206                return null;
207        if ("replaces".equals(codeString))
208          return REPLACES;
209        if ("transforms".equals(codeString))
210          return TRANSFORMS;
211        if ("signs".equals(codeString))
212          return SIGNS;
213        if ("appends".equals(codeString))
214          return APPENDS;
215        if (Configuration.isAcceptInvalidEnums())
216          return null;
217        else
218          throw new FHIRException("Unknown DocumentRelationshipType code '"+codeString+"'");
219        }
220        public String toCode() {
221          switch (this) {
222            case REPLACES: return "replaces";
223            case TRANSFORMS: return "transforms";
224            case SIGNS: return "signs";
225            case APPENDS: return "appends";
226            case NULL: return null;
227            default: return "?";
228          }
229        }
230        public String getSystem() {
231          switch (this) {
232            case REPLACES: return "http://hl7.org/fhir/document-relationship-type";
233            case TRANSFORMS: return "http://hl7.org/fhir/document-relationship-type";
234            case SIGNS: return "http://hl7.org/fhir/document-relationship-type";
235            case APPENDS: return "http://hl7.org/fhir/document-relationship-type";
236            case NULL: return null;
237            default: return "?";
238          }
239        }
240        public String getDefinition() {
241          switch (this) {
242            case REPLACES: return "This document logically replaces or supersedes the target document.";
243            case TRANSFORMS: return "This document was generated by transforming the target document (e.g. format or language conversion).";
244            case SIGNS: return "This document is a signature of the target document.";
245            case APPENDS: return "This document adds additional information to the target document.";
246            case NULL: return null;
247            default: return "?";
248          }
249        }
250        public String getDisplay() {
251          switch (this) {
252            case REPLACES: return "Replaces";
253            case TRANSFORMS: return "Transforms";
254            case SIGNS: return "Signs";
255            case APPENDS: return "Appends";
256            case NULL: return null;
257            default: return "?";
258          }
259        }
260    }
261
262  public static class DocumentRelationshipTypeEnumFactory implements EnumFactory<DocumentRelationshipType> {
263    public DocumentRelationshipType fromCode(String codeString) throws IllegalArgumentException {
264      if (codeString == null || "".equals(codeString))
265            if (codeString == null || "".equals(codeString))
266                return null;
267        if ("replaces".equals(codeString))
268          return DocumentRelationshipType.REPLACES;
269        if ("transforms".equals(codeString))
270          return DocumentRelationshipType.TRANSFORMS;
271        if ("signs".equals(codeString))
272          return DocumentRelationshipType.SIGNS;
273        if ("appends".equals(codeString))
274          return DocumentRelationshipType.APPENDS;
275        throw new IllegalArgumentException("Unknown DocumentRelationshipType code '"+codeString+"'");
276        }
277        public Enumeration<DocumentRelationshipType> fromType(Base code) throws FHIRException {
278          if (code == null)
279            return null;
280          if (code.isEmpty())
281            return new Enumeration<DocumentRelationshipType>(this);
282          String codeString = ((PrimitiveType) code).asStringValue();
283          if (codeString == null || "".equals(codeString))
284            return null;
285        if ("replaces".equals(codeString))
286          return new Enumeration<DocumentRelationshipType>(this, DocumentRelationshipType.REPLACES);
287        if ("transforms".equals(codeString))
288          return new Enumeration<DocumentRelationshipType>(this, DocumentRelationshipType.TRANSFORMS);
289        if ("signs".equals(codeString))
290          return new Enumeration<DocumentRelationshipType>(this, DocumentRelationshipType.SIGNS);
291        if ("appends".equals(codeString))
292          return new Enumeration<DocumentRelationshipType>(this, DocumentRelationshipType.APPENDS);
293        throw new FHIRException("Unknown DocumentRelationshipType code '"+codeString+"'");
294        }
295    public String toCode(DocumentRelationshipType code) {
296      if (code == DocumentRelationshipType.REPLACES)
297        return "replaces";
298      if (code == DocumentRelationshipType.TRANSFORMS)
299        return "transforms";
300      if (code == DocumentRelationshipType.SIGNS)
301        return "signs";
302      if (code == DocumentRelationshipType.APPENDS)
303        return "appends";
304      return "?";
305      }
306    public String toSystem(DocumentRelationshipType code) {
307      return code.getSystem();
308      }
309    }
310
311    @Block()
312    public static class DocumentReferenceRelatesToComponent extends BackboneElement implements IBaseBackboneElement {
313        /**
314         * The type of relationship that this document has with anther document.
315         */
316        @Child(name = "code", type = {CodeType.class}, order=1, min=1, max=1, modifier=false, summary=true)
317        @Description(shortDefinition="replaces | transforms | signs | appends", formalDefinition="The type of relationship that this document has with anther document." )
318        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/document-relationship-type")
319        protected Enumeration<DocumentRelationshipType> code;
320
321        /**
322         * The target document of this relationship.
323         */
324        @Child(name = "target", type = {DocumentReference.class}, order=2, min=1, max=1, modifier=false, summary=true)
325        @Description(shortDefinition="Target of the relationship", formalDefinition="The target document of this relationship." )
326        protected Reference target;
327
328        /**
329         * The actual object that is the target of the reference (The target document of this relationship.)
330         */
331        protected DocumentReference targetTarget;
332
333        private static final long serialVersionUID = -347257495L;
334
335    /**
336     * Constructor
337     */
338      public DocumentReferenceRelatesToComponent() {
339        super();
340      }
341
342    /**
343     * Constructor
344     */
345      public DocumentReferenceRelatesToComponent(Enumeration<DocumentRelationshipType> code, Reference target) {
346        super();
347        this.code = code;
348        this.target = target;
349      }
350
351        /**
352         * @return {@link #code} (The type of relationship that this document has with anther document.). This is the underlying object with id, value and extensions. The accessor "getCode" gives direct access to the value
353         */
354        public Enumeration<DocumentRelationshipType> getCodeElement() { 
355          if (this.code == null)
356            if (Configuration.errorOnAutoCreate())
357              throw new Error("Attempt to auto-create DocumentReferenceRelatesToComponent.code");
358            else if (Configuration.doAutoCreate())
359              this.code = new Enumeration<DocumentRelationshipType>(new DocumentRelationshipTypeEnumFactory()); // bb
360          return this.code;
361        }
362
363        public boolean hasCodeElement() { 
364          return this.code != null && !this.code.isEmpty();
365        }
366
367        public boolean hasCode() { 
368          return this.code != null && !this.code.isEmpty();
369        }
370
371        /**
372         * @param value {@link #code} (The type of relationship that this document has with anther document.). This is the underlying object with id, value and extensions. The accessor "getCode" gives direct access to the value
373         */
374        public DocumentReferenceRelatesToComponent setCodeElement(Enumeration<DocumentRelationshipType> value) { 
375          this.code = value;
376          return this;
377        }
378
379        /**
380         * @return The type of relationship that this document has with anther document.
381         */
382        public DocumentRelationshipType getCode() { 
383          return this.code == null ? null : this.code.getValue();
384        }
385
386        /**
387         * @param value The type of relationship that this document has with anther document.
388         */
389        public DocumentReferenceRelatesToComponent setCode(DocumentRelationshipType value) { 
390            if (this.code == null)
391              this.code = new Enumeration<DocumentRelationshipType>(new DocumentRelationshipTypeEnumFactory());
392            this.code.setValue(value);
393          return this;
394        }
395
396        /**
397         * @return {@link #target} (The target document of this relationship.)
398         */
399        public Reference getTarget() { 
400          if (this.target == null)
401            if (Configuration.errorOnAutoCreate())
402              throw new Error("Attempt to auto-create DocumentReferenceRelatesToComponent.target");
403            else if (Configuration.doAutoCreate())
404              this.target = new Reference(); // cc
405          return this.target;
406        }
407
408        public boolean hasTarget() { 
409          return this.target != null && !this.target.isEmpty();
410        }
411
412        /**
413         * @param value {@link #target} (The target document of this relationship.)
414         */
415        public DocumentReferenceRelatesToComponent setTarget(Reference value) { 
416          this.target = value;
417          return this;
418        }
419
420        /**
421         * @return {@link #target} 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 target document of this relationship.)
422         */
423        public DocumentReference getTargetTarget() { 
424          if (this.targetTarget == null)
425            if (Configuration.errorOnAutoCreate())
426              throw new Error("Attempt to auto-create DocumentReferenceRelatesToComponent.target");
427            else if (Configuration.doAutoCreate())
428              this.targetTarget = new DocumentReference(); // aa
429          return this.targetTarget;
430        }
431
432        /**
433         * @param value {@link #target} 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 target document of this relationship.)
434         */
435        public DocumentReferenceRelatesToComponent setTargetTarget(DocumentReference value) { 
436          this.targetTarget = value;
437          return this;
438        }
439
440        protected void listChildren(List<Property> children) {
441          super.listChildren(children);
442          children.add(new Property("code", "code", "The type of relationship that this document has with anther document.", 0, 1, code));
443          children.add(new Property("target", "Reference(DocumentReference)", "The target document of this relationship.", 0, 1, target));
444        }
445
446        @Override
447        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
448          switch (_hash) {
449          case 3059181: /*code*/  return new Property("code", "code", "The type of relationship that this document has with anther document.", 0, 1, code);
450          case -880905839: /*target*/  return new Property("target", "Reference(DocumentReference)", "The target document of this relationship.", 0, 1, target);
451          default: return super.getNamedProperty(_hash, _name, _checkValid);
452          }
453
454        }
455
456      @Override
457      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
458        switch (hash) {
459        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // Enumeration<DocumentRelationshipType>
460        case -880905839: /*target*/ return this.target == null ? new Base[0] : new Base[] {this.target}; // Reference
461        default: return super.getProperty(hash, name, checkValid);
462        }
463
464      }
465
466      @Override
467      public Base setProperty(int hash, String name, Base value) throws FHIRException {
468        switch (hash) {
469        case 3059181: // code
470          value = new DocumentRelationshipTypeEnumFactory().fromType(castToCode(value));
471          this.code = (Enumeration) value; // Enumeration<DocumentRelationshipType>
472          return value;
473        case -880905839: // target
474          this.target = castToReference(value); // Reference
475          return value;
476        default: return super.setProperty(hash, name, value);
477        }
478
479      }
480
481      @Override
482      public Base setProperty(String name, Base value) throws FHIRException {
483        if (name.equals("code")) {
484          value = new DocumentRelationshipTypeEnumFactory().fromType(castToCode(value));
485          this.code = (Enumeration) value; // Enumeration<DocumentRelationshipType>
486        } else if (name.equals("target")) {
487          this.target = castToReference(value); // Reference
488        } else
489          return super.setProperty(name, value);
490        return value;
491      }
492
493      @Override
494      public Base makeProperty(int hash, String name) throws FHIRException {
495        switch (hash) {
496        case 3059181:  return getCodeElement();
497        case -880905839:  return getTarget(); 
498        default: return super.makeProperty(hash, name);
499        }
500
501      }
502
503      @Override
504      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
505        switch (hash) {
506        case 3059181: /*code*/ return new String[] {"code"};
507        case -880905839: /*target*/ return new String[] {"Reference"};
508        default: return super.getTypesForProperty(hash, name);
509        }
510
511      }
512
513      @Override
514      public Base addChild(String name) throws FHIRException {
515        if (name.equals("code")) {
516          throw new FHIRException("Cannot call addChild on a primitive type DocumentReference.code");
517        }
518        else if (name.equals("target")) {
519          this.target = new Reference();
520          return this.target;
521        }
522        else
523          return super.addChild(name);
524      }
525
526      public DocumentReferenceRelatesToComponent copy() {
527        DocumentReferenceRelatesToComponent dst = new DocumentReferenceRelatesToComponent();
528        copyValues(dst);
529        return dst;
530      }
531
532      public void copyValues(DocumentReferenceRelatesToComponent dst) {
533        super.copyValues(dst);
534        dst.code = code == null ? null : code.copy();
535        dst.target = target == null ? null : target.copy();
536      }
537
538      @Override
539      public boolean equalsDeep(Base other_) {
540        if (!super.equalsDeep(other_))
541          return false;
542        if (!(other_ instanceof DocumentReferenceRelatesToComponent))
543          return false;
544        DocumentReferenceRelatesToComponent o = (DocumentReferenceRelatesToComponent) other_;
545        return compareDeep(code, o.code, true) && compareDeep(target, o.target, true);
546      }
547
548      @Override
549      public boolean equalsShallow(Base other_) {
550        if (!super.equalsShallow(other_))
551          return false;
552        if (!(other_ instanceof DocumentReferenceRelatesToComponent))
553          return false;
554        DocumentReferenceRelatesToComponent o = (DocumentReferenceRelatesToComponent) other_;
555        return compareValues(code, o.code, true);
556      }
557
558      public boolean isEmpty() {
559        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(code, target);
560      }
561
562  public String fhirType() {
563    return "DocumentReference.relatesTo";
564
565  }
566
567  }
568
569    @Block()
570    public static class DocumentReferenceContentComponent extends BackboneElement implements IBaseBackboneElement {
571        /**
572         * The document or URL of the document along with critical metadata to prove content has integrity.
573         */
574        @Child(name = "attachment", type = {Attachment.class}, order=1, min=1, max=1, modifier=false, summary=true)
575        @Description(shortDefinition="Where to access the document", formalDefinition="The document or URL of the document along with critical metadata to prove content has integrity." )
576        protected Attachment attachment;
577
578        /**
579         * An identifier of the document encoding, structure, and template that the document conforms to beyond the base format indicated in the mimeType.
580         */
581        @Child(name = "format", type = {Coding.class}, order=2, min=0, max=1, modifier=false, summary=true)
582        @Description(shortDefinition="Format/content rules for the document", formalDefinition="An identifier of the document encoding, structure, and template that the document conforms to beyond the base format indicated in the mimeType." )
583        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/formatcodes")
584        protected Coding format;
585
586        private static final long serialVersionUID = -1313860217L;
587
588    /**
589     * Constructor
590     */
591      public DocumentReferenceContentComponent() {
592        super();
593      }
594
595    /**
596     * Constructor
597     */
598      public DocumentReferenceContentComponent(Attachment attachment) {
599        super();
600        this.attachment = attachment;
601      }
602
603        /**
604         * @return {@link #attachment} (The document or URL of the document along with critical metadata to prove content has integrity.)
605         */
606        public Attachment getAttachment() { 
607          if (this.attachment == null)
608            if (Configuration.errorOnAutoCreate())
609              throw new Error("Attempt to auto-create DocumentReferenceContentComponent.attachment");
610            else if (Configuration.doAutoCreate())
611              this.attachment = new Attachment(); // cc
612          return this.attachment;
613        }
614
615        public boolean hasAttachment() { 
616          return this.attachment != null && !this.attachment.isEmpty();
617        }
618
619        /**
620         * @param value {@link #attachment} (The document or URL of the document along with critical metadata to prove content has integrity.)
621         */
622        public DocumentReferenceContentComponent setAttachment(Attachment value) { 
623          this.attachment = value;
624          return this;
625        }
626
627        /**
628         * @return {@link #format} (An identifier of the document encoding, structure, and template that the document conforms to beyond the base format indicated in the mimeType.)
629         */
630        public Coding getFormat() { 
631          if (this.format == null)
632            if (Configuration.errorOnAutoCreate())
633              throw new Error("Attempt to auto-create DocumentReferenceContentComponent.format");
634            else if (Configuration.doAutoCreate())
635              this.format = new Coding(); // cc
636          return this.format;
637        }
638
639        public boolean hasFormat() { 
640          return this.format != null && !this.format.isEmpty();
641        }
642
643        /**
644         * @param value {@link #format} (An identifier of the document encoding, structure, and template that the document conforms to beyond the base format indicated in the mimeType.)
645         */
646        public DocumentReferenceContentComponent setFormat(Coding value) { 
647          this.format = value;
648          return this;
649        }
650
651        protected void listChildren(List<Property> children) {
652          super.listChildren(children);
653          children.add(new Property("attachment", "Attachment", "The document or URL of the document along with critical metadata to prove content has integrity.", 0, 1, attachment));
654          children.add(new Property("format", "Coding", "An identifier of the document encoding, structure, and template that the document conforms to beyond the base format indicated in the mimeType.", 0, 1, format));
655        }
656
657        @Override
658        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
659          switch (_hash) {
660          case -1963501277: /*attachment*/  return new Property("attachment", "Attachment", "The document or URL of the document along with critical metadata to prove content has integrity.", 0, 1, attachment);
661          case -1268779017: /*format*/  return new Property("format", "Coding", "An identifier of the document encoding, structure, and template that the document conforms to beyond the base format indicated in the mimeType.", 0, 1, format);
662          default: return super.getNamedProperty(_hash, _name, _checkValid);
663          }
664
665        }
666
667      @Override
668      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
669        switch (hash) {
670        case -1963501277: /*attachment*/ return this.attachment == null ? new Base[0] : new Base[] {this.attachment}; // Attachment
671        case -1268779017: /*format*/ return this.format == null ? new Base[0] : new Base[] {this.format}; // Coding
672        default: return super.getProperty(hash, name, checkValid);
673        }
674
675      }
676
677      @Override
678      public Base setProperty(int hash, String name, Base value) throws FHIRException {
679        switch (hash) {
680        case -1963501277: // attachment
681          this.attachment = castToAttachment(value); // Attachment
682          return value;
683        case -1268779017: // format
684          this.format = castToCoding(value); // Coding
685          return value;
686        default: return super.setProperty(hash, name, value);
687        }
688
689      }
690
691      @Override
692      public Base setProperty(String name, Base value) throws FHIRException {
693        if (name.equals("attachment")) {
694          this.attachment = castToAttachment(value); // Attachment
695        } else if (name.equals("format")) {
696          this.format = castToCoding(value); // Coding
697        } else
698          return super.setProperty(name, value);
699        return value;
700      }
701
702      @Override
703      public Base makeProperty(int hash, String name) throws FHIRException {
704        switch (hash) {
705        case -1963501277:  return getAttachment(); 
706        case -1268779017:  return getFormat(); 
707        default: return super.makeProperty(hash, name);
708        }
709
710      }
711
712      @Override
713      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
714        switch (hash) {
715        case -1963501277: /*attachment*/ return new String[] {"Attachment"};
716        case -1268779017: /*format*/ return new String[] {"Coding"};
717        default: return super.getTypesForProperty(hash, name);
718        }
719
720      }
721
722      @Override
723      public Base addChild(String name) throws FHIRException {
724        if (name.equals("attachment")) {
725          this.attachment = new Attachment();
726          return this.attachment;
727        }
728        else if (name.equals("format")) {
729          this.format = new Coding();
730          return this.format;
731        }
732        else
733          return super.addChild(name);
734      }
735
736      public DocumentReferenceContentComponent copy() {
737        DocumentReferenceContentComponent dst = new DocumentReferenceContentComponent();
738        copyValues(dst);
739        return dst;
740      }
741
742      public void copyValues(DocumentReferenceContentComponent dst) {
743        super.copyValues(dst);
744        dst.attachment = attachment == null ? null : attachment.copy();
745        dst.format = format == null ? null : format.copy();
746      }
747
748      @Override
749      public boolean equalsDeep(Base other_) {
750        if (!super.equalsDeep(other_))
751          return false;
752        if (!(other_ instanceof DocumentReferenceContentComponent))
753          return false;
754        DocumentReferenceContentComponent o = (DocumentReferenceContentComponent) other_;
755        return compareDeep(attachment, o.attachment, true) && compareDeep(format, o.format, true);
756      }
757
758      @Override
759      public boolean equalsShallow(Base other_) {
760        if (!super.equalsShallow(other_))
761          return false;
762        if (!(other_ instanceof DocumentReferenceContentComponent))
763          return false;
764        DocumentReferenceContentComponent o = (DocumentReferenceContentComponent) other_;
765        return true;
766      }
767
768      public boolean isEmpty() {
769        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(attachment, format);
770      }
771
772  public String fhirType() {
773    return "DocumentReference.content";
774
775  }
776
777  }
778
779    @Block()
780    public static class DocumentReferenceContextComponent extends BackboneElement implements IBaseBackboneElement {
781        /**
782         * Describes the clinical encounter or type of care that the document content is associated with.
783         */
784        @Child(name = "encounter", type = {Encounter.class, EpisodeOfCare.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
785        @Description(shortDefinition="Context of the document  content", formalDefinition="Describes the clinical encounter or type of care that the document content is associated with." )
786        protected List<Reference> encounter;
787        /**
788         * The actual objects that are the target of the reference (Describes the clinical encounter or type of care that the document content is associated with.)
789         */
790        protected List<Resource> encounterTarget;
791
792
793        /**
794         * 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 type Code, such as a "History and Physical Report" in which the procedure being documented is necessarily a "History and Physical" act.
795         */
796        @Child(name = "event", type = {CodeableConcept.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
797        @Description(shortDefinition="Main clinical acts 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 type Code, such as a \"History and Physical Report\" in which the procedure being documented is necessarily a \"History and Physical\" act." )
798        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://terminology.hl7.org/ValueSet/v3-ActCode")
799        protected List<CodeableConcept> event;
800
801        /**
802         * The time period over which the service that is described by the document was provided.
803         */
804        @Child(name = "period", type = {Period.class}, order=3, min=0, max=1, modifier=false, summary=true)
805        @Description(shortDefinition="Time of service that is being documented", formalDefinition="The time period over which the service that is described by the document was provided." )
806        protected Period period;
807
808        /**
809         * The kind of facility where the patient was seen.
810         */
811        @Child(name = "facilityType", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=false)
812        @Description(shortDefinition="Kind of facility where patient was seen", formalDefinition="The kind of facility where the patient was seen." )
813        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/c80-facilitycodes")
814        protected CodeableConcept facilityType;
815
816        /**
817         * This property may convey specifics about the practice setting where the content was created, often reflecting the clinical specialty.
818         */
819        @Child(name = "practiceSetting", type = {CodeableConcept.class}, order=5, min=0, max=1, modifier=false, summary=false)
820        @Description(shortDefinition="Additional details about where the content was created (e.g. clinical specialty)", formalDefinition="This property may convey specifics about the practice setting where the content was created, often reflecting the clinical specialty." )
821        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/c80-practice-codes")
822        protected CodeableConcept practiceSetting;
823
824        /**
825         * The Patient Information as known when the document was published. May be a reference to a version specific, or contained.
826         */
827        @Child(name = "sourcePatientInfo", type = {Patient.class}, order=6, min=0, max=1, modifier=false, summary=false)
828        @Description(shortDefinition="Patient demographics from source", formalDefinition="The Patient Information as known when the document was published. May be a reference to a version specific, or contained." )
829        protected Reference sourcePatientInfo;
830
831        /**
832         * The actual object that is the target of the reference (The Patient Information as known when the document was published. May be a reference to a version specific, or contained.)
833         */
834        protected Patient sourcePatientInfoTarget;
835
836        /**
837         * Related identifiers or resources associated with the DocumentReference.
838         */
839        @Child(name = "related", type = {Reference.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
840        @Description(shortDefinition="Related identifiers or resources", formalDefinition="Related identifiers or resources associated with the DocumentReference." )
841        protected List<Reference> related;
842        /**
843         * The actual objects that are the target of the reference (Related identifiers or resources associated with the DocumentReference.)
844         */
845        protected List<Resource> relatedTarget;
846
847
848        private static final long serialVersionUID = 140463218L;
849
850    /**
851     * Constructor
852     */
853      public DocumentReferenceContextComponent() {
854        super();
855      }
856
857        /**
858         * @return {@link #encounter} (Describes the clinical encounter or type of care that the document content is associated with.)
859         */
860        public List<Reference> getEncounter() { 
861          if (this.encounter == null)
862            this.encounter = new ArrayList<Reference>();
863          return this.encounter;
864        }
865
866        /**
867         * @return Returns a reference to <code>this</code> for easy method chaining
868         */
869        public DocumentReferenceContextComponent setEncounter(List<Reference> theEncounter) { 
870          this.encounter = theEncounter;
871          return this;
872        }
873
874        public boolean hasEncounter() { 
875          if (this.encounter == null)
876            return false;
877          for (Reference item : this.encounter)
878            if (!item.isEmpty())
879              return true;
880          return false;
881        }
882
883        public Reference addEncounter() { //3
884          Reference t = new Reference();
885          if (this.encounter == null)
886            this.encounter = new ArrayList<Reference>();
887          this.encounter.add(t);
888          return t;
889        }
890
891        public DocumentReferenceContextComponent addEncounter(Reference t) { //3
892          if (t == null)
893            return this;
894          if (this.encounter == null)
895            this.encounter = new ArrayList<Reference>();
896          this.encounter.add(t);
897          return this;
898        }
899
900        /**
901         * @return The first repetition of repeating field {@link #encounter}, creating it if it does not already exist
902         */
903        public Reference getEncounterFirstRep() { 
904          if (getEncounter().isEmpty()) {
905            addEncounter();
906          }
907          return getEncounter().get(0);
908        }
909
910        /**
911         * @deprecated Use Reference#setResource(IBaseResource) instead
912         */
913        @Deprecated
914        public List<Resource> getEncounterTarget() { 
915          if (this.encounterTarget == null)
916            this.encounterTarget = new ArrayList<Resource>();
917          return this.encounterTarget;
918        }
919
920        /**
921         * @return {@link #event} (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 type Code, such as a "History and Physical Report" in which the procedure being documented is necessarily a "History and Physical" act.)
922         */
923        public List<CodeableConcept> getEvent() { 
924          if (this.event == null)
925            this.event = new ArrayList<CodeableConcept>();
926          return this.event;
927        }
928
929        /**
930         * @return Returns a reference to <code>this</code> for easy method chaining
931         */
932        public DocumentReferenceContextComponent setEvent(List<CodeableConcept> theEvent) { 
933          this.event = theEvent;
934          return this;
935        }
936
937        public boolean hasEvent() { 
938          if (this.event == null)
939            return false;
940          for (CodeableConcept item : this.event)
941            if (!item.isEmpty())
942              return true;
943          return false;
944        }
945
946        public CodeableConcept addEvent() { //3
947          CodeableConcept t = new CodeableConcept();
948          if (this.event == null)
949            this.event = new ArrayList<CodeableConcept>();
950          this.event.add(t);
951          return t;
952        }
953
954        public DocumentReferenceContextComponent addEvent(CodeableConcept t) { //3
955          if (t == null)
956            return this;
957          if (this.event == null)
958            this.event = new ArrayList<CodeableConcept>();
959          this.event.add(t);
960          return this;
961        }
962
963        /**
964         * @return The first repetition of repeating field {@link #event}, creating it if it does not already exist
965         */
966        public CodeableConcept getEventFirstRep() { 
967          if (getEvent().isEmpty()) {
968            addEvent();
969          }
970          return getEvent().get(0);
971        }
972
973        /**
974         * @return {@link #period} (The time period over which the service that is described by the document was provided.)
975         */
976        public Period getPeriod() { 
977          if (this.period == null)
978            if (Configuration.errorOnAutoCreate())
979              throw new Error("Attempt to auto-create DocumentReferenceContextComponent.period");
980            else if (Configuration.doAutoCreate())
981              this.period = new Period(); // cc
982          return this.period;
983        }
984
985        public boolean hasPeriod() { 
986          return this.period != null && !this.period.isEmpty();
987        }
988
989        /**
990         * @param value {@link #period} (The time period over which the service that is described by the document was provided.)
991         */
992        public DocumentReferenceContextComponent setPeriod(Period value) { 
993          this.period = value;
994          return this;
995        }
996
997        /**
998         * @return {@link #facilityType} (The kind of facility where the patient was seen.)
999         */
1000        public CodeableConcept getFacilityType() { 
1001          if (this.facilityType == null)
1002            if (Configuration.errorOnAutoCreate())
1003              throw new Error("Attempt to auto-create DocumentReferenceContextComponent.facilityType");
1004            else if (Configuration.doAutoCreate())
1005              this.facilityType = new CodeableConcept(); // cc
1006          return this.facilityType;
1007        }
1008
1009        public boolean hasFacilityType() { 
1010          return this.facilityType != null && !this.facilityType.isEmpty();
1011        }
1012
1013        /**
1014         * @param value {@link #facilityType} (The kind of facility where the patient was seen.)
1015         */
1016        public DocumentReferenceContextComponent setFacilityType(CodeableConcept value) { 
1017          this.facilityType = value;
1018          return this;
1019        }
1020
1021        /**
1022         * @return {@link #practiceSetting} (This property may convey specifics about the practice setting where the content was created, often reflecting the clinical specialty.)
1023         */
1024        public CodeableConcept getPracticeSetting() { 
1025          if (this.practiceSetting == null)
1026            if (Configuration.errorOnAutoCreate())
1027              throw new Error("Attempt to auto-create DocumentReferenceContextComponent.practiceSetting");
1028            else if (Configuration.doAutoCreate())
1029              this.practiceSetting = new CodeableConcept(); // cc
1030          return this.practiceSetting;
1031        }
1032
1033        public boolean hasPracticeSetting() { 
1034          return this.practiceSetting != null && !this.practiceSetting.isEmpty();
1035        }
1036
1037        /**
1038         * @param value {@link #practiceSetting} (This property may convey specifics about the practice setting where the content was created, often reflecting the clinical specialty.)
1039         */
1040        public DocumentReferenceContextComponent setPracticeSetting(CodeableConcept value) { 
1041          this.practiceSetting = value;
1042          return this;
1043        }
1044
1045        /**
1046         * @return {@link #sourcePatientInfo} (The Patient Information as known when the document was published. May be a reference to a version specific, or contained.)
1047         */
1048        public Reference getSourcePatientInfo() { 
1049          if (this.sourcePatientInfo == null)
1050            if (Configuration.errorOnAutoCreate())
1051              throw new Error("Attempt to auto-create DocumentReferenceContextComponent.sourcePatientInfo");
1052            else if (Configuration.doAutoCreate())
1053              this.sourcePatientInfo = new Reference(); // cc
1054          return this.sourcePatientInfo;
1055        }
1056
1057        public boolean hasSourcePatientInfo() { 
1058          return this.sourcePatientInfo != null && !this.sourcePatientInfo.isEmpty();
1059        }
1060
1061        /**
1062         * @param value {@link #sourcePatientInfo} (The Patient Information as known when the document was published. May be a reference to a version specific, or contained.)
1063         */
1064        public DocumentReferenceContextComponent setSourcePatientInfo(Reference value) { 
1065          this.sourcePatientInfo = value;
1066          return this;
1067        }
1068
1069        /**
1070         * @return {@link #sourcePatientInfo} 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 Patient Information as known when the document was published. May be a reference to a version specific, or contained.)
1071         */
1072        public Patient getSourcePatientInfoTarget() { 
1073          if (this.sourcePatientInfoTarget == null)
1074            if (Configuration.errorOnAutoCreate())
1075              throw new Error("Attempt to auto-create DocumentReferenceContextComponent.sourcePatientInfo");
1076            else if (Configuration.doAutoCreate())
1077              this.sourcePatientInfoTarget = new Patient(); // aa
1078          return this.sourcePatientInfoTarget;
1079        }
1080
1081        /**
1082         * @param value {@link #sourcePatientInfo} 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 Patient Information as known when the document was published. May be a reference to a version specific, or contained.)
1083         */
1084        public DocumentReferenceContextComponent setSourcePatientInfoTarget(Patient value) { 
1085          this.sourcePatientInfoTarget = value;
1086          return this;
1087        }
1088
1089        /**
1090         * @return {@link #related} (Related identifiers or resources associated with the DocumentReference.)
1091         */
1092        public List<Reference> getRelated() { 
1093          if (this.related == null)
1094            this.related = new ArrayList<Reference>();
1095          return this.related;
1096        }
1097
1098        /**
1099         * @return Returns a reference to <code>this</code> for easy method chaining
1100         */
1101        public DocumentReferenceContextComponent setRelated(List<Reference> theRelated) { 
1102          this.related = theRelated;
1103          return this;
1104        }
1105
1106        public boolean hasRelated() { 
1107          if (this.related == null)
1108            return false;
1109          for (Reference item : this.related)
1110            if (!item.isEmpty())
1111              return true;
1112          return false;
1113        }
1114
1115        public Reference addRelated() { //3
1116          Reference t = new Reference();
1117          if (this.related == null)
1118            this.related = new ArrayList<Reference>();
1119          this.related.add(t);
1120          return t;
1121        }
1122
1123        public DocumentReferenceContextComponent addRelated(Reference t) { //3
1124          if (t == null)
1125            return this;
1126          if (this.related == null)
1127            this.related = new ArrayList<Reference>();
1128          this.related.add(t);
1129          return this;
1130        }
1131
1132        /**
1133         * @return The first repetition of repeating field {@link #related}, creating it if it does not already exist
1134         */
1135        public Reference getRelatedFirstRep() { 
1136          if (getRelated().isEmpty()) {
1137            addRelated();
1138          }
1139          return getRelated().get(0);
1140        }
1141
1142        /**
1143         * @deprecated Use Reference#setResource(IBaseResource) instead
1144         */
1145        @Deprecated
1146        public List<Resource> getRelatedTarget() { 
1147          if (this.relatedTarget == null)
1148            this.relatedTarget = new ArrayList<Resource>();
1149          return this.relatedTarget;
1150        }
1151
1152        protected void listChildren(List<Property> children) {
1153          super.listChildren(children);
1154          children.add(new Property("encounter", "Reference(Encounter|EpisodeOfCare)", "Describes the clinical encounter or type of care that the document content is associated with.", 0, java.lang.Integer.MAX_VALUE, encounter));
1155          children.add(new Property("event", "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 type Code, 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, event));
1156          children.add(new Property("period", "Period", "The time period over which the service that is described by the document was provided.", 0, 1, period));
1157          children.add(new Property("facilityType", "CodeableConcept", "The kind of facility where the patient was seen.", 0, 1, facilityType));
1158          children.add(new Property("practiceSetting", "CodeableConcept", "This property may convey specifics about the practice setting where the content was created, often reflecting the clinical specialty.", 0, 1, practiceSetting));
1159          children.add(new Property("sourcePatientInfo", "Reference(Patient)", "The Patient Information as known when the document was published. May be a reference to a version specific, or contained.", 0, 1, sourcePatientInfo));
1160          children.add(new Property("related", "Reference(Any)", "Related identifiers or resources associated with the DocumentReference.", 0, java.lang.Integer.MAX_VALUE, related));
1161        }
1162
1163        @Override
1164        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1165          switch (_hash) {
1166          case 1524132147: /*encounter*/  return new Property("encounter", "Reference(Encounter|EpisodeOfCare)", "Describes the clinical encounter or type of care that the document content is associated with.", 0, java.lang.Integer.MAX_VALUE, encounter);
1167          case 96891546: /*event*/  return new Property("event", "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 type Code, 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, event);
1168          case -991726143: /*period*/  return new Property("period", "Period", "The time period over which the service that is described by the document was provided.", 0, 1, period);
1169          case 370698365: /*facilityType*/  return new Property("facilityType", "CodeableConcept", "The kind of facility where the patient was seen.", 0, 1, facilityType);
1170          case 331373717: /*practiceSetting*/  return new Property("practiceSetting", "CodeableConcept", "This property may convey specifics about the practice setting where the content was created, often reflecting the clinical specialty.", 0, 1, practiceSetting);
1171          case 2031381048: /*sourcePatientInfo*/  return new Property("sourcePatientInfo", "Reference(Patient)", "The Patient Information as known when the document was published. May be a reference to a version specific, or contained.", 0, 1, sourcePatientInfo);
1172          case 1090493483: /*related*/  return new Property("related", "Reference(Any)", "Related identifiers or resources associated with the DocumentReference.", 0, java.lang.Integer.MAX_VALUE, related);
1173          default: return super.getNamedProperty(_hash, _name, _checkValid);
1174          }
1175
1176        }
1177
1178      @Override
1179      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1180        switch (hash) {
1181        case 1524132147: /*encounter*/ return this.encounter == null ? new Base[0] : this.encounter.toArray(new Base[this.encounter.size()]); // Reference
1182        case 96891546: /*event*/ return this.event == null ? new Base[0] : this.event.toArray(new Base[this.event.size()]); // CodeableConcept
1183        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
1184        case 370698365: /*facilityType*/ return this.facilityType == null ? new Base[0] : new Base[] {this.facilityType}; // CodeableConcept
1185        case 331373717: /*practiceSetting*/ return this.practiceSetting == null ? new Base[0] : new Base[] {this.practiceSetting}; // CodeableConcept
1186        case 2031381048: /*sourcePatientInfo*/ return this.sourcePatientInfo == null ? new Base[0] : new Base[] {this.sourcePatientInfo}; // Reference
1187        case 1090493483: /*related*/ return this.related == null ? new Base[0] : this.related.toArray(new Base[this.related.size()]); // Reference
1188        default: return super.getProperty(hash, name, checkValid);
1189        }
1190
1191      }
1192
1193      @Override
1194      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1195        switch (hash) {
1196        case 1524132147: // encounter
1197          this.getEncounter().add(castToReference(value)); // Reference
1198          return value;
1199        case 96891546: // event
1200          this.getEvent().add(castToCodeableConcept(value)); // CodeableConcept
1201          return value;
1202        case -991726143: // period
1203          this.period = castToPeriod(value); // Period
1204          return value;
1205        case 370698365: // facilityType
1206          this.facilityType = castToCodeableConcept(value); // CodeableConcept
1207          return value;
1208        case 331373717: // practiceSetting
1209          this.practiceSetting = castToCodeableConcept(value); // CodeableConcept
1210          return value;
1211        case 2031381048: // sourcePatientInfo
1212          this.sourcePatientInfo = castToReference(value); // Reference
1213          return value;
1214        case 1090493483: // related
1215          this.getRelated().add(castToReference(value)); // Reference
1216          return value;
1217        default: return super.setProperty(hash, name, value);
1218        }
1219
1220      }
1221
1222      @Override
1223      public Base setProperty(String name, Base value) throws FHIRException {
1224        if (name.equals("encounter")) {
1225          this.getEncounter().add(castToReference(value));
1226        } else if (name.equals("event")) {
1227          this.getEvent().add(castToCodeableConcept(value));
1228        } else if (name.equals("period")) {
1229          this.period = castToPeriod(value); // Period
1230        } else if (name.equals("facilityType")) {
1231          this.facilityType = castToCodeableConcept(value); // CodeableConcept
1232        } else if (name.equals("practiceSetting")) {
1233          this.practiceSetting = castToCodeableConcept(value); // CodeableConcept
1234        } else if (name.equals("sourcePatientInfo")) {
1235          this.sourcePatientInfo = castToReference(value); // Reference
1236        } else if (name.equals("related")) {
1237          this.getRelated().add(castToReference(value));
1238        } else
1239          return super.setProperty(name, value);
1240        return value;
1241      }
1242
1243      @Override
1244      public Base makeProperty(int hash, String name) throws FHIRException {
1245        switch (hash) {
1246        case 1524132147:  return addEncounter(); 
1247        case 96891546:  return addEvent(); 
1248        case -991726143:  return getPeriod(); 
1249        case 370698365:  return getFacilityType(); 
1250        case 331373717:  return getPracticeSetting(); 
1251        case 2031381048:  return getSourcePatientInfo(); 
1252        case 1090493483:  return addRelated(); 
1253        default: return super.makeProperty(hash, name);
1254        }
1255
1256      }
1257
1258      @Override
1259      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1260        switch (hash) {
1261        case 1524132147: /*encounter*/ return new String[] {"Reference"};
1262        case 96891546: /*event*/ return new String[] {"CodeableConcept"};
1263        case -991726143: /*period*/ return new String[] {"Period"};
1264        case 370698365: /*facilityType*/ return new String[] {"CodeableConcept"};
1265        case 331373717: /*practiceSetting*/ return new String[] {"CodeableConcept"};
1266        case 2031381048: /*sourcePatientInfo*/ return new String[] {"Reference"};
1267        case 1090493483: /*related*/ return new String[] {"Reference"};
1268        default: return super.getTypesForProperty(hash, name);
1269        }
1270
1271      }
1272
1273      @Override
1274      public Base addChild(String name) throws FHIRException {
1275        if (name.equals("encounter")) {
1276          return addEncounter();
1277        }
1278        else if (name.equals("event")) {
1279          return addEvent();
1280        }
1281        else if (name.equals("period")) {
1282          this.period = new Period();
1283          return this.period;
1284        }
1285        else if (name.equals("facilityType")) {
1286          this.facilityType = new CodeableConcept();
1287          return this.facilityType;
1288        }
1289        else if (name.equals("practiceSetting")) {
1290          this.practiceSetting = new CodeableConcept();
1291          return this.practiceSetting;
1292        }
1293        else if (name.equals("sourcePatientInfo")) {
1294          this.sourcePatientInfo = new Reference();
1295          return this.sourcePatientInfo;
1296        }
1297        else if (name.equals("related")) {
1298          return addRelated();
1299        }
1300        else
1301          return super.addChild(name);
1302      }
1303
1304      public DocumentReferenceContextComponent copy() {
1305        DocumentReferenceContextComponent dst = new DocumentReferenceContextComponent();
1306        copyValues(dst);
1307        return dst;
1308      }
1309
1310      public void copyValues(DocumentReferenceContextComponent dst) {
1311        super.copyValues(dst);
1312        if (encounter != null) {
1313          dst.encounter = new ArrayList<Reference>();
1314          for (Reference i : encounter)
1315            dst.encounter.add(i.copy());
1316        };
1317        if (event != null) {
1318          dst.event = new ArrayList<CodeableConcept>();
1319          for (CodeableConcept i : event)
1320            dst.event.add(i.copy());
1321        };
1322        dst.period = period == null ? null : period.copy();
1323        dst.facilityType = facilityType == null ? null : facilityType.copy();
1324        dst.practiceSetting = practiceSetting == null ? null : practiceSetting.copy();
1325        dst.sourcePatientInfo = sourcePatientInfo == null ? null : sourcePatientInfo.copy();
1326        if (related != null) {
1327          dst.related = new ArrayList<Reference>();
1328          for (Reference i : related)
1329            dst.related.add(i.copy());
1330        };
1331      }
1332
1333      @Override
1334      public boolean equalsDeep(Base other_) {
1335        if (!super.equalsDeep(other_))
1336          return false;
1337        if (!(other_ instanceof DocumentReferenceContextComponent))
1338          return false;
1339        DocumentReferenceContextComponent o = (DocumentReferenceContextComponent) other_;
1340        return compareDeep(encounter, o.encounter, true) && compareDeep(event, o.event, true) && compareDeep(period, o.period, true)
1341           && compareDeep(facilityType, o.facilityType, true) && compareDeep(practiceSetting, o.practiceSetting, true)
1342           && compareDeep(sourcePatientInfo, o.sourcePatientInfo, true) && compareDeep(related, o.related, true)
1343          ;
1344      }
1345
1346      @Override
1347      public boolean equalsShallow(Base other_) {
1348        if (!super.equalsShallow(other_))
1349          return false;
1350        if (!(other_ instanceof DocumentReferenceContextComponent))
1351          return false;
1352        DocumentReferenceContextComponent o = (DocumentReferenceContextComponent) other_;
1353        return true;
1354      }
1355
1356      public boolean isEmpty() {
1357        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(encounter, event, period
1358          , facilityType, practiceSetting, sourcePatientInfo, related);
1359      }
1360
1361  public String fhirType() {
1362    return "DocumentReference.context";
1363
1364  }
1365
1366  }
1367
1368    /**
1369     * Document identifier as assigned by the source of the document. This identifier is specific to this version of the document. This unique identifier may be used elsewhere to identify this version of the document.
1370     */
1371    @Child(name = "masterIdentifier", type = {Identifier.class}, order=0, min=0, max=1, modifier=false, summary=true)
1372    @Description(shortDefinition="Master Version Specific Identifier", formalDefinition="Document identifier as assigned by the source of the document. This identifier is specific to this version of the document. This unique identifier may be used elsewhere to identify this version of the document." )
1373    protected Identifier masterIdentifier;
1374
1375    /**
1376     * Other identifiers associated with the document, including version independent identifiers.
1377     */
1378    @Child(name = "identifier", type = {Identifier.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1379    @Description(shortDefinition="Other identifiers for the document", formalDefinition="Other identifiers associated with the document, including version independent identifiers." )
1380    protected List<Identifier> identifier;
1381
1382    /**
1383     * The status of this document reference.
1384     */
1385    @Child(name = "status", type = {CodeType.class}, order=2, min=1, max=1, modifier=true, summary=true)
1386    @Description(shortDefinition="current | superseded | entered-in-error", formalDefinition="The status of this document reference." )
1387    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/document-reference-status")
1388    protected Enumeration<DocumentReferenceStatus> status;
1389
1390    /**
1391     * The status of the underlying document.
1392     */
1393    @Child(name = "docStatus", type = {CodeType.class}, order=3, min=0, max=1, modifier=false, summary=true)
1394    @Description(shortDefinition="preliminary | final | amended | entered-in-error", formalDefinition="The status of the underlying document." )
1395    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/composition-status")
1396    protected Enumeration<ReferredDocumentStatus> docStatus;
1397
1398    /**
1399     * Specifies the particular kind of document referenced  (e.g. History and Physical, Discharge Summary, Progress Note). This usually equates to the purpose of making the document referenced.
1400     */
1401    @Child(name = "type", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=true)
1402    @Description(shortDefinition="Kind of document (LOINC if possible)", formalDefinition="Specifies the particular kind of document referenced  (e.g. History and Physical, Discharge Summary, Progress Note). This usually equates to the purpose of making the document referenced." )
1403    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/c80-doc-typecodes")
1404    protected CodeableConcept type;
1405
1406    /**
1407     * A categorization for the type of document referenced - helps for indexing and searching. This may be implied by or derived from the code specified in the DocumentReference.type.
1408     */
1409    @Child(name = "category", type = {CodeableConcept.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1410    @Description(shortDefinition="Categorization of document", formalDefinition="A categorization for the type of document referenced - helps for indexing and searching. This may be implied by or derived from the code specified in the DocumentReference.type." )
1411    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/document-classcodes")
1412    protected List<CodeableConcept> category;
1413
1414    /**
1415     * Who or what the document is about. The document 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 farm animals, or a set of patients that share a common exposure).
1416     */
1417    @Child(name = "subject", type = {Patient.class, Practitioner.class, Group.class, Device.class}, order=6, min=0, max=1, modifier=false, summary=true)
1418    @Description(shortDefinition="Who/what is the subject of the document", formalDefinition="Who or what the document is about. The document 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 farm animals, or a set of patients that share a common exposure)." )
1419    protected Reference subject;
1420
1421    /**
1422     * The actual object that is the target of the reference (Who or what the document is about. The document 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 farm animals, or a set of patients that share a common exposure).)
1423     */
1424    protected Resource subjectTarget;
1425
1426    /**
1427     * When the document reference was created.
1428     */
1429    @Child(name = "date", type = {InstantType.class}, order=7, min=0, max=1, modifier=false, summary=true)
1430    @Description(shortDefinition="When this document reference was created", formalDefinition="When the document reference was created." )
1431    protected InstantType date;
1432
1433    /**
1434     * Identifies who is responsible for adding the information to the document.
1435     */
1436    @Child(name = "author", type = {Practitioner.class, PractitionerRole.class, Organization.class, Device.class, Patient.class, RelatedPerson.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1437    @Description(shortDefinition="Who and/or what authored the document", formalDefinition="Identifies who is responsible for adding the information to the document." )
1438    protected List<Reference> author;
1439    /**
1440     * The actual objects that are the target of the reference (Identifies who is responsible for adding the information to the document.)
1441     */
1442    protected List<Resource> authorTarget;
1443
1444
1445    /**
1446     * Which person or organization authenticates that this document is valid.
1447     */
1448    @Child(name = "authenticator", type = {Practitioner.class, PractitionerRole.class, Organization.class}, order=9, min=0, max=1, modifier=false, summary=false)
1449    @Description(shortDefinition="Who/what authenticated the document", formalDefinition="Which person or organization authenticates that this document is valid." )
1450    protected Reference authenticator;
1451
1452    /**
1453     * The actual object that is the target of the reference (Which person or organization authenticates that this document is valid.)
1454     */
1455    protected Resource authenticatorTarget;
1456
1457    /**
1458     * Identifies the organization or group who is responsible for ongoing maintenance of and access to the document.
1459     */
1460    @Child(name = "custodian", type = {Organization.class}, order=10, min=0, max=1, modifier=false, summary=false)
1461    @Description(shortDefinition="Organization which maintains the document", formalDefinition="Identifies the organization or group who is responsible for ongoing maintenance of and access to the document." )
1462    protected Reference custodian;
1463
1464    /**
1465     * 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 document.)
1466     */
1467    protected Organization custodianTarget;
1468
1469    /**
1470     * Relationships that this document has with other document references that already exist.
1471     */
1472    @Child(name = "relatesTo", type = {}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1473    @Description(shortDefinition="Relationships to other documents", formalDefinition="Relationships that this document has with other document references that already exist." )
1474    protected List<DocumentReferenceRelatesToComponent> relatesTo;
1475
1476    /**
1477     * Human-readable description of the source document.
1478     */
1479    @Child(name = "description", type = {StringType.class}, order=12, min=0, max=1, modifier=false, summary=true)
1480    @Description(shortDefinition="Human-readable description", formalDefinition="Human-readable description of the source document." )
1481    protected StringType description;
1482
1483    /**
1484     * A set of Security-Tag codes specifying the level of privacy/security of the Document. Note that DocumentReference.meta.security contains the security labels of the "reference" to the document, while DocumentReference.securityLabel contains a snapshot of the security labels on the document the reference refers to.
1485     */
1486    @Child(name = "securityLabel", type = {CodeableConcept.class}, order=13, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1487    @Description(shortDefinition="Document security-tags", formalDefinition="A set of Security-Tag codes specifying the level of privacy/security of the Document. Note that DocumentReference.meta.security contains the security labels of the \"reference\" to the document, while DocumentReference.securityLabel contains a snapshot of the security labels on the document the reference refers to." )
1488    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/security-labels")
1489    protected List<CodeableConcept> securityLabel;
1490
1491    /**
1492     * The document and format referenced. There may be multiple content element repetitions, each with a different format.
1493     */
1494    @Child(name = "content", type = {}, order=14, min=1, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1495    @Description(shortDefinition="Document referenced", formalDefinition="The document and format referenced. There may be multiple content element repetitions, each with a different format." )
1496    protected List<DocumentReferenceContentComponent> content;
1497
1498    /**
1499     * The clinical context in which the document was prepared.
1500     */
1501    @Child(name = "context", type = {}, order=15, min=0, max=1, modifier=false, summary=true)
1502    @Description(shortDefinition="Clinical context of document", formalDefinition="The clinical context in which the document was prepared." )
1503    protected DocumentReferenceContextComponent context;
1504
1505    private static final long serialVersionUID = 307086535L;
1506
1507  /**
1508   * Constructor
1509   */
1510    public DocumentReference() {
1511      super();
1512    }
1513
1514  /**
1515   * Constructor
1516   */
1517    public DocumentReference(Enumeration<DocumentReferenceStatus> status) {
1518      super();
1519      this.status = status;
1520    }
1521
1522    /**
1523     * @return {@link #masterIdentifier} (Document identifier as assigned by the source of the document. This identifier is specific to this version of the document. This unique identifier may be used elsewhere to identify this version of the document.)
1524     */
1525    public Identifier getMasterIdentifier() { 
1526      if (this.masterIdentifier == null)
1527        if (Configuration.errorOnAutoCreate())
1528          throw new Error("Attempt to auto-create DocumentReference.masterIdentifier");
1529        else if (Configuration.doAutoCreate())
1530          this.masterIdentifier = new Identifier(); // cc
1531      return this.masterIdentifier;
1532    }
1533
1534    public boolean hasMasterIdentifier() { 
1535      return this.masterIdentifier != null && !this.masterIdentifier.isEmpty();
1536    }
1537
1538    /**
1539     * @param value {@link #masterIdentifier} (Document identifier as assigned by the source of the document. This identifier is specific to this version of the document. This unique identifier may be used elsewhere to identify this version of the document.)
1540     */
1541    public DocumentReference setMasterIdentifier(Identifier value) { 
1542      this.masterIdentifier = value;
1543      return this;
1544    }
1545
1546    /**
1547     * @return {@link #identifier} (Other identifiers associated with the document, including version independent identifiers.)
1548     */
1549    public List<Identifier> getIdentifier() { 
1550      if (this.identifier == null)
1551        this.identifier = new ArrayList<Identifier>();
1552      return this.identifier;
1553    }
1554
1555    /**
1556     * @return Returns a reference to <code>this</code> for easy method chaining
1557     */
1558    public DocumentReference setIdentifier(List<Identifier> theIdentifier) { 
1559      this.identifier = theIdentifier;
1560      return this;
1561    }
1562
1563    public boolean hasIdentifier() { 
1564      if (this.identifier == null)
1565        return false;
1566      for (Identifier item : this.identifier)
1567        if (!item.isEmpty())
1568          return true;
1569      return false;
1570    }
1571
1572    public Identifier addIdentifier() { //3
1573      Identifier t = new Identifier();
1574      if (this.identifier == null)
1575        this.identifier = new ArrayList<Identifier>();
1576      this.identifier.add(t);
1577      return t;
1578    }
1579
1580    public DocumentReference addIdentifier(Identifier t) { //3
1581      if (t == null)
1582        return this;
1583      if (this.identifier == null)
1584        this.identifier = new ArrayList<Identifier>();
1585      this.identifier.add(t);
1586      return this;
1587    }
1588
1589    /**
1590     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
1591     */
1592    public Identifier getIdentifierFirstRep() { 
1593      if (getIdentifier().isEmpty()) {
1594        addIdentifier();
1595      }
1596      return getIdentifier().get(0);
1597    }
1598
1599    /**
1600     * @return {@link #status} (The status of this document reference.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1601     */
1602    public Enumeration<DocumentReferenceStatus> getStatusElement() { 
1603      if (this.status == null)
1604        if (Configuration.errorOnAutoCreate())
1605          throw new Error("Attempt to auto-create DocumentReference.status");
1606        else if (Configuration.doAutoCreate())
1607          this.status = new Enumeration<DocumentReferenceStatus>(new DocumentReferenceStatusEnumFactory()); // bb
1608      return this.status;
1609    }
1610
1611    public boolean hasStatusElement() { 
1612      return this.status != null && !this.status.isEmpty();
1613    }
1614
1615    public boolean hasStatus() { 
1616      return this.status != null && !this.status.isEmpty();
1617    }
1618
1619    /**
1620     * @param value {@link #status} (The status of this document reference.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1621     */
1622    public DocumentReference setStatusElement(Enumeration<DocumentReferenceStatus> value) { 
1623      this.status = value;
1624      return this;
1625    }
1626
1627    /**
1628     * @return The status of this document reference.
1629     */
1630    public DocumentReferenceStatus getStatus() { 
1631      return this.status == null ? null : this.status.getValue();
1632    }
1633
1634    /**
1635     * @param value The status of this document reference.
1636     */
1637    public DocumentReference setStatus(DocumentReferenceStatus value) { 
1638        if (this.status == null)
1639          this.status = new Enumeration<DocumentReferenceStatus>(new DocumentReferenceStatusEnumFactory());
1640        this.status.setValue(value);
1641      return this;
1642    }
1643
1644    /**
1645     * @return {@link #docStatus} (The status of the underlying document.). This is the underlying object with id, value and extensions. The accessor "getDocStatus" gives direct access to the value
1646     */
1647    public Enumeration<ReferredDocumentStatus> getDocStatusElement() { 
1648      if (this.docStatus == null)
1649        if (Configuration.errorOnAutoCreate())
1650          throw new Error("Attempt to auto-create DocumentReference.docStatus");
1651        else if (Configuration.doAutoCreate())
1652          this.docStatus = new Enumeration<ReferredDocumentStatus>(new ReferredDocumentStatusEnumFactory()); // bb
1653      return this.docStatus;
1654    }
1655
1656    public boolean hasDocStatusElement() { 
1657      return this.docStatus != null && !this.docStatus.isEmpty();
1658    }
1659
1660    public boolean hasDocStatus() { 
1661      return this.docStatus != null && !this.docStatus.isEmpty();
1662    }
1663
1664    /**
1665     * @param value {@link #docStatus} (The status of the underlying document.). This is the underlying object with id, value and extensions. The accessor "getDocStatus" gives direct access to the value
1666     */
1667    public DocumentReference setDocStatusElement(Enumeration<ReferredDocumentStatus> value) { 
1668      this.docStatus = value;
1669      return this;
1670    }
1671
1672    /**
1673     * @return The status of the underlying document.
1674     */
1675    public ReferredDocumentStatus getDocStatus() { 
1676      return this.docStatus == null ? null : this.docStatus.getValue();
1677    }
1678
1679    /**
1680     * @param value The status of the underlying document.
1681     */
1682    public DocumentReference setDocStatus(ReferredDocumentStatus value) { 
1683      if (value == null)
1684        this.docStatus = null;
1685      else {
1686        if (this.docStatus == null)
1687          this.docStatus = new Enumeration<ReferredDocumentStatus>(new ReferredDocumentStatusEnumFactory());
1688        this.docStatus.setValue(value);
1689      }
1690      return this;
1691    }
1692
1693    /**
1694     * @return {@link #type} (Specifies the particular kind of document referenced  (e.g. History and Physical, Discharge Summary, Progress Note). This usually equates to the purpose of making the document referenced.)
1695     */
1696    public CodeableConcept getType() { 
1697      if (this.type == null)
1698        if (Configuration.errorOnAutoCreate())
1699          throw new Error("Attempt to auto-create DocumentReference.type");
1700        else if (Configuration.doAutoCreate())
1701          this.type = new CodeableConcept(); // cc
1702      return this.type;
1703    }
1704
1705    public boolean hasType() { 
1706      return this.type != null && !this.type.isEmpty();
1707    }
1708
1709    /**
1710     * @param value {@link #type} (Specifies the particular kind of document referenced  (e.g. History and Physical, Discharge Summary, Progress Note). This usually equates to the purpose of making the document referenced.)
1711     */
1712    public DocumentReference setType(CodeableConcept value) { 
1713      this.type = value;
1714      return this;
1715    }
1716
1717    /**
1718     * @return {@link #category} (A categorization for the type of document referenced - helps for indexing and searching. This may be implied by or derived from the code specified in the DocumentReference.type.)
1719     */
1720    public List<CodeableConcept> getCategory() { 
1721      if (this.category == null)
1722        this.category = new ArrayList<CodeableConcept>();
1723      return this.category;
1724    }
1725
1726    /**
1727     * @return Returns a reference to <code>this</code> for easy method chaining
1728     */
1729    public DocumentReference setCategory(List<CodeableConcept> theCategory) { 
1730      this.category = theCategory;
1731      return this;
1732    }
1733
1734    public boolean hasCategory() { 
1735      if (this.category == null)
1736        return false;
1737      for (CodeableConcept item : this.category)
1738        if (!item.isEmpty())
1739          return true;
1740      return false;
1741    }
1742
1743    public CodeableConcept addCategory() { //3
1744      CodeableConcept t = new CodeableConcept();
1745      if (this.category == null)
1746        this.category = new ArrayList<CodeableConcept>();
1747      this.category.add(t);
1748      return t;
1749    }
1750
1751    public DocumentReference addCategory(CodeableConcept t) { //3
1752      if (t == null)
1753        return this;
1754      if (this.category == null)
1755        this.category = new ArrayList<CodeableConcept>();
1756      this.category.add(t);
1757      return this;
1758    }
1759
1760    /**
1761     * @return The first repetition of repeating field {@link #category}, creating it if it does not already exist
1762     */
1763    public CodeableConcept getCategoryFirstRep() { 
1764      if (getCategory().isEmpty()) {
1765        addCategory();
1766      }
1767      return getCategory().get(0);
1768    }
1769
1770    /**
1771     * @return {@link #subject} (Who or what the document is about. The document 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 farm animals, or a set of patients that share a common exposure).)
1772     */
1773    public Reference getSubject() { 
1774      if (this.subject == null)
1775        if (Configuration.errorOnAutoCreate())
1776          throw new Error("Attempt to auto-create DocumentReference.subject");
1777        else if (Configuration.doAutoCreate())
1778          this.subject = new Reference(); // cc
1779      return this.subject;
1780    }
1781
1782    public boolean hasSubject() { 
1783      return this.subject != null && !this.subject.isEmpty();
1784    }
1785
1786    /**
1787     * @param value {@link #subject} (Who or what the document is about. The document 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 farm animals, or a set of patients that share a common exposure).)
1788     */
1789    public DocumentReference setSubject(Reference value) { 
1790      this.subject = value;
1791      return this;
1792    }
1793
1794    /**
1795     * @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 document is about. The document 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 farm animals, or a set of patients that share a common exposure).)
1796     */
1797    public Resource getSubjectTarget() { 
1798      return this.subjectTarget;
1799    }
1800
1801    /**
1802     * @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 document is about. The document 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 farm animals, or a set of patients that share a common exposure).)
1803     */
1804    public DocumentReference setSubjectTarget(Resource value) { 
1805      this.subjectTarget = value;
1806      return this;
1807    }
1808
1809    /**
1810     * @return {@link #date} (When the document reference was created.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
1811     */
1812    public InstantType getDateElement() { 
1813      if (this.date == null)
1814        if (Configuration.errorOnAutoCreate())
1815          throw new Error("Attempt to auto-create DocumentReference.date");
1816        else if (Configuration.doAutoCreate())
1817          this.date = new InstantType(); // bb
1818      return this.date;
1819    }
1820
1821    public boolean hasDateElement() { 
1822      return this.date != null && !this.date.isEmpty();
1823    }
1824
1825    public boolean hasDate() { 
1826      return this.date != null && !this.date.isEmpty();
1827    }
1828
1829    /**
1830     * @param value {@link #date} (When the document reference was created.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
1831     */
1832    public DocumentReference setDateElement(InstantType value) { 
1833      this.date = value;
1834      return this;
1835    }
1836
1837    /**
1838     * @return When the document reference was created.
1839     */
1840    public Date getDate() { 
1841      return this.date == null ? null : this.date.getValue();
1842    }
1843
1844    /**
1845     * @param value When the document reference was created.
1846     */
1847    public DocumentReference setDate(Date value) { 
1848      if (value == null)
1849        this.date = null;
1850      else {
1851        if (this.date == null)
1852          this.date = new InstantType();
1853        this.date.setValue(value);
1854      }
1855      return this;
1856    }
1857
1858    /**
1859     * @return {@link #author} (Identifies who is responsible for adding the information to the document.)
1860     */
1861    public List<Reference> getAuthor() { 
1862      if (this.author == null)
1863        this.author = new ArrayList<Reference>();
1864      return this.author;
1865    }
1866
1867    /**
1868     * @return Returns a reference to <code>this</code> for easy method chaining
1869     */
1870    public DocumentReference setAuthor(List<Reference> theAuthor) { 
1871      this.author = theAuthor;
1872      return this;
1873    }
1874
1875    public boolean hasAuthor() { 
1876      if (this.author == null)
1877        return false;
1878      for (Reference item : this.author)
1879        if (!item.isEmpty())
1880          return true;
1881      return false;
1882    }
1883
1884    public Reference addAuthor() { //3
1885      Reference t = new Reference();
1886      if (this.author == null)
1887        this.author = new ArrayList<Reference>();
1888      this.author.add(t);
1889      return t;
1890    }
1891
1892    public DocumentReference addAuthor(Reference t) { //3
1893      if (t == null)
1894        return this;
1895      if (this.author == null)
1896        this.author = new ArrayList<Reference>();
1897      this.author.add(t);
1898      return this;
1899    }
1900
1901    /**
1902     * @return The first repetition of repeating field {@link #author}, creating it if it does not already exist
1903     */
1904    public Reference getAuthorFirstRep() { 
1905      if (getAuthor().isEmpty()) {
1906        addAuthor();
1907      }
1908      return getAuthor().get(0);
1909    }
1910
1911    /**
1912     * @deprecated Use Reference#setResource(IBaseResource) instead
1913     */
1914    @Deprecated
1915    public List<Resource> getAuthorTarget() { 
1916      if (this.authorTarget == null)
1917        this.authorTarget = new ArrayList<Resource>();
1918      return this.authorTarget;
1919    }
1920
1921    /**
1922     * @return {@link #authenticator} (Which person or organization authenticates that this document is valid.)
1923     */
1924    public Reference getAuthenticator() { 
1925      if (this.authenticator == null)
1926        if (Configuration.errorOnAutoCreate())
1927          throw new Error("Attempt to auto-create DocumentReference.authenticator");
1928        else if (Configuration.doAutoCreate())
1929          this.authenticator = new Reference(); // cc
1930      return this.authenticator;
1931    }
1932
1933    public boolean hasAuthenticator() { 
1934      return this.authenticator != null && !this.authenticator.isEmpty();
1935    }
1936
1937    /**
1938     * @param value {@link #authenticator} (Which person or organization authenticates that this document is valid.)
1939     */
1940    public DocumentReference setAuthenticator(Reference value) { 
1941      this.authenticator = value;
1942      return this;
1943    }
1944
1945    /**
1946     * @return {@link #authenticator} 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. (Which person or organization authenticates that this document is valid.)
1947     */
1948    public Resource getAuthenticatorTarget() { 
1949      return this.authenticatorTarget;
1950    }
1951
1952    /**
1953     * @param value {@link #authenticator} 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. (Which person or organization authenticates that this document is valid.)
1954     */
1955    public DocumentReference setAuthenticatorTarget(Resource value) { 
1956      this.authenticatorTarget = value;
1957      return this;
1958    }
1959
1960    /**
1961     * @return {@link #custodian} (Identifies the organization or group who is responsible for ongoing maintenance of and access to the document.)
1962     */
1963    public Reference getCustodian() { 
1964      if (this.custodian == null)
1965        if (Configuration.errorOnAutoCreate())
1966          throw new Error("Attempt to auto-create DocumentReference.custodian");
1967        else if (Configuration.doAutoCreate())
1968          this.custodian = new Reference(); // cc
1969      return this.custodian;
1970    }
1971
1972    public boolean hasCustodian() { 
1973      return this.custodian != null && !this.custodian.isEmpty();
1974    }
1975
1976    /**
1977     * @param value {@link #custodian} (Identifies the organization or group who is responsible for ongoing maintenance of and access to the document.)
1978     */
1979    public DocumentReference setCustodian(Reference value) { 
1980      this.custodian = value;
1981      return this;
1982    }
1983
1984    /**
1985     * @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 document.)
1986     */
1987    public Organization getCustodianTarget() { 
1988      if (this.custodianTarget == null)
1989        if (Configuration.errorOnAutoCreate())
1990          throw new Error("Attempt to auto-create DocumentReference.custodian");
1991        else if (Configuration.doAutoCreate())
1992          this.custodianTarget = new Organization(); // aa
1993      return this.custodianTarget;
1994    }
1995
1996    /**
1997     * @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 document.)
1998     */
1999    public DocumentReference setCustodianTarget(Organization value) { 
2000      this.custodianTarget = value;
2001      return this;
2002    }
2003
2004    /**
2005     * @return {@link #relatesTo} (Relationships that this document has with other document references that already exist.)
2006     */
2007    public List<DocumentReferenceRelatesToComponent> getRelatesTo() { 
2008      if (this.relatesTo == null)
2009        this.relatesTo = new ArrayList<DocumentReferenceRelatesToComponent>();
2010      return this.relatesTo;
2011    }
2012
2013    /**
2014     * @return Returns a reference to <code>this</code> for easy method chaining
2015     */
2016    public DocumentReference setRelatesTo(List<DocumentReferenceRelatesToComponent> theRelatesTo) { 
2017      this.relatesTo = theRelatesTo;
2018      return this;
2019    }
2020
2021    public boolean hasRelatesTo() { 
2022      if (this.relatesTo == null)
2023        return false;
2024      for (DocumentReferenceRelatesToComponent item : this.relatesTo)
2025        if (!item.isEmpty())
2026          return true;
2027      return false;
2028    }
2029
2030    public DocumentReferenceRelatesToComponent addRelatesTo() { //3
2031      DocumentReferenceRelatesToComponent t = new DocumentReferenceRelatesToComponent();
2032      if (this.relatesTo == null)
2033        this.relatesTo = new ArrayList<DocumentReferenceRelatesToComponent>();
2034      this.relatesTo.add(t);
2035      return t;
2036    }
2037
2038    public DocumentReference addRelatesTo(DocumentReferenceRelatesToComponent t) { //3
2039      if (t == null)
2040        return this;
2041      if (this.relatesTo == null)
2042        this.relatesTo = new ArrayList<DocumentReferenceRelatesToComponent>();
2043      this.relatesTo.add(t);
2044      return this;
2045    }
2046
2047    /**
2048     * @return The first repetition of repeating field {@link #relatesTo}, creating it if it does not already exist
2049     */
2050    public DocumentReferenceRelatesToComponent getRelatesToFirstRep() { 
2051      if (getRelatesTo().isEmpty()) {
2052        addRelatesTo();
2053      }
2054      return getRelatesTo().get(0);
2055    }
2056
2057    /**
2058     * @return {@link #description} (Human-readable description of the source document.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
2059     */
2060    public StringType getDescriptionElement() { 
2061      if (this.description == null)
2062        if (Configuration.errorOnAutoCreate())
2063          throw new Error("Attempt to auto-create DocumentReference.description");
2064        else if (Configuration.doAutoCreate())
2065          this.description = new StringType(); // bb
2066      return this.description;
2067    }
2068
2069    public boolean hasDescriptionElement() { 
2070      return this.description != null && !this.description.isEmpty();
2071    }
2072
2073    public boolean hasDescription() { 
2074      return this.description != null && !this.description.isEmpty();
2075    }
2076
2077    /**
2078     * @param value {@link #description} (Human-readable description of the source document.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
2079     */
2080    public DocumentReference setDescriptionElement(StringType value) { 
2081      this.description = value;
2082      return this;
2083    }
2084
2085    /**
2086     * @return Human-readable description of the source document.
2087     */
2088    public String getDescription() { 
2089      return this.description == null ? null : this.description.getValue();
2090    }
2091
2092    /**
2093     * @param value Human-readable description of the source document.
2094     */
2095    public DocumentReference setDescription(String value) { 
2096      if (Utilities.noString(value))
2097        this.description = null;
2098      else {
2099        if (this.description == null)
2100          this.description = new StringType();
2101        this.description.setValue(value);
2102      }
2103      return this;
2104    }
2105
2106    /**
2107     * @return {@link #securityLabel} (A set of Security-Tag codes specifying the level of privacy/security of the Document. Note that DocumentReference.meta.security contains the security labels of the "reference" to the document, while DocumentReference.securityLabel contains a snapshot of the security labels on the document the reference refers to.)
2108     */
2109    public List<CodeableConcept> getSecurityLabel() { 
2110      if (this.securityLabel == null)
2111        this.securityLabel = new ArrayList<CodeableConcept>();
2112      return this.securityLabel;
2113    }
2114
2115    /**
2116     * @return Returns a reference to <code>this</code> for easy method chaining
2117     */
2118    public DocumentReference setSecurityLabel(List<CodeableConcept> theSecurityLabel) { 
2119      this.securityLabel = theSecurityLabel;
2120      return this;
2121    }
2122
2123    public boolean hasSecurityLabel() { 
2124      if (this.securityLabel == null)
2125        return false;
2126      for (CodeableConcept item : this.securityLabel)
2127        if (!item.isEmpty())
2128          return true;
2129      return false;
2130    }
2131
2132    public CodeableConcept addSecurityLabel() { //3
2133      CodeableConcept t = new CodeableConcept();
2134      if (this.securityLabel == null)
2135        this.securityLabel = new ArrayList<CodeableConcept>();
2136      this.securityLabel.add(t);
2137      return t;
2138    }
2139
2140    public DocumentReference addSecurityLabel(CodeableConcept t) { //3
2141      if (t == null)
2142        return this;
2143      if (this.securityLabel == null)
2144        this.securityLabel = new ArrayList<CodeableConcept>();
2145      this.securityLabel.add(t);
2146      return this;
2147    }
2148
2149    /**
2150     * @return The first repetition of repeating field {@link #securityLabel}, creating it if it does not already exist
2151     */
2152    public CodeableConcept getSecurityLabelFirstRep() { 
2153      if (getSecurityLabel().isEmpty()) {
2154        addSecurityLabel();
2155      }
2156      return getSecurityLabel().get(0);
2157    }
2158
2159    /**
2160     * @return {@link #content} (The document and format referenced. There may be multiple content element repetitions, each with a different format.)
2161     */
2162    public List<DocumentReferenceContentComponent> getContent() { 
2163      if (this.content == null)
2164        this.content = new ArrayList<DocumentReferenceContentComponent>();
2165      return this.content;
2166    }
2167
2168    /**
2169     * @return Returns a reference to <code>this</code> for easy method chaining
2170     */
2171    public DocumentReference setContent(List<DocumentReferenceContentComponent> theContent) { 
2172      this.content = theContent;
2173      return this;
2174    }
2175
2176    public boolean hasContent() { 
2177      if (this.content == null)
2178        return false;
2179      for (DocumentReferenceContentComponent item : this.content)
2180        if (!item.isEmpty())
2181          return true;
2182      return false;
2183    }
2184
2185    public DocumentReferenceContentComponent addContent() { //3
2186      DocumentReferenceContentComponent t = new DocumentReferenceContentComponent();
2187      if (this.content == null)
2188        this.content = new ArrayList<DocumentReferenceContentComponent>();
2189      this.content.add(t);
2190      return t;
2191    }
2192
2193    public DocumentReference addContent(DocumentReferenceContentComponent t) { //3
2194      if (t == null)
2195        return this;
2196      if (this.content == null)
2197        this.content = new ArrayList<DocumentReferenceContentComponent>();
2198      this.content.add(t);
2199      return this;
2200    }
2201
2202    /**
2203     * @return The first repetition of repeating field {@link #content}, creating it if it does not already exist
2204     */
2205    public DocumentReferenceContentComponent getContentFirstRep() { 
2206      if (getContent().isEmpty()) {
2207        addContent();
2208      }
2209      return getContent().get(0);
2210    }
2211
2212    /**
2213     * @return {@link #context} (The clinical context in which the document was prepared.)
2214     */
2215    public DocumentReferenceContextComponent getContext() { 
2216      if (this.context == null)
2217        if (Configuration.errorOnAutoCreate())
2218          throw new Error("Attempt to auto-create DocumentReference.context");
2219        else if (Configuration.doAutoCreate())
2220          this.context = new DocumentReferenceContextComponent(); // cc
2221      return this.context;
2222    }
2223
2224    public boolean hasContext() { 
2225      return this.context != null && !this.context.isEmpty();
2226    }
2227
2228    /**
2229     * @param value {@link #context} (The clinical context in which the document was prepared.)
2230     */
2231    public DocumentReference setContext(DocumentReferenceContextComponent value) { 
2232      this.context = value;
2233      return this;
2234    }
2235
2236      protected void listChildren(List<Property> children) {
2237        super.listChildren(children);
2238        children.add(new Property("masterIdentifier", "Identifier", "Document identifier as assigned by the source of the document. This identifier is specific to this version of the document. This unique identifier may be used elsewhere to identify this version of the document.", 0, 1, masterIdentifier));
2239        children.add(new Property("identifier", "Identifier", "Other identifiers associated with the document, including version independent identifiers.", 0, java.lang.Integer.MAX_VALUE, identifier));
2240        children.add(new Property("status", "code", "The status of this document reference.", 0, 1, status));
2241        children.add(new Property("docStatus", "code", "The status of the underlying document.", 0, 1, docStatus));
2242        children.add(new Property("type", "CodeableConcept", "Specifies the particular kind of document referenced  (e.g. History and Physical, Discharge Summary, Progress Note). This usually equates to the purpose of making the document referenced.", 0, 1, type));
2243        children.add(new Property("category", "CodeableConcept", "A categorization for the type of document referenced - helps for indexing and searching. This may be implied by or derived from the code specified in the DocumentReference.type.", 0, java.lang.Integer.MAX_VALUE, category));
2244        children.add(new Property("subject", "Reference(Patient|Practitioner|Group|Device)", "Who or what the document is about. The document 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 farm animals, or a set of patients that share a common exposure).", 0, 1, subject));
2245        children.add(new Property("date", "instant", "When the document reference was created.", 0, 1, date));
2246        children.add(new Property("author", "Reference(Practitioner|PractitionerRole|Organization|Device|Patient|RelatedPerson)", "Identifies who is responsible for adding the information to the document.", 0, java.lang.Integer.MAX_VALUE, author));
2247        children.add(new Property("authenticator", "Reference(Practitioner|PractitionerRole|Organization)", "Which person or organization authenticates that this document is valid.", 0, 1, authenticator));
2248        children.add(new Property("custodian", "Reference(Organization)", "Identifies the organization or group who is responsible for ongoing maintenance of and access to the document.", 0, 1, custodian));
2249        children.add(new Property("relatesTo", "", "Relationships that this document has with other document references that already exist.", 0, java.lang.Integer.MAX_VALUE, relatesTo));
2250        children.add(new Property("description", "string", "Human-readable description of the source document.", 0, 1, description));
2251        children.add(new Property("securityLabel", "CodeableConcept", "A set of Security-Tag codes specifying the level of privacy/security of the Document. Note that DocumentReference.meta.security contains the security labels of the \"reference\" to the document, while DocumentReference.securityLabel contains a snapshot of the security labels on the document the reference refers to.", 0, java.lang.Integer.MAX_VALUE, securityLabel));
2252        children.add(new Property("content", "", "The document and format referenced. There may be multiple content element repetitions, each with a different format.", 0, java.lang.Integer.MAX_VALUE, content));
2253        children.add(new Property("context", "", "The clinical context in which the document was prepared.", 0, 1, context));
2254      }
2255
2256      @Override
2257      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2258        switch (_hash) {
2259        case 243769515: /*masterIdentifier*/  return new Property("masterIdentifier", "Identifier", "Document identifier as assigned by the source of the document. This identifier is specific to this version of the document. This unique identifier may be used elsewhere to identify this version of the document.", 0, 1, masterIdentifier);
2260        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Other identifiers associated with the document, including version independent identifiers.", 0, java.lang.Integer.MAX_VALUE, identifier);
2261        case -892481550: /*status*/  return new Property("status", "code", "The status of this document reference.", 0, 1, status);
2262        case -23496886: /*docStatus*/  return new Property("docStatus", "code", "The status of the underlying document.", 0, 1, docStatus);
2263        case 3575610: /*type*/  return new Property("type", "CodeableConcept", "Specifies the particular kind of document referenced  (e.g. History and Physical, Discharge Summary, Progress Note). This usually equates to the purpose of making the document referenced.", 0, 1, type);
2264        case 50511102: /*category*/  return new Property("category", "CodeableConcept", "A categorization for the type of document referenced - helps for indexing and searching. This may be implied by or derived from the code specified in the DocumentReference.type.", 0, java.lang.Integer.MAX_VALUE, category);
2265        case -1867885268: /*subject*/  return new Property("subject", "Reference(Patient|Practitioner|Group|Device)", "Who or what the document is about. The document 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 farm animals, or a set of patients that share a common exposure).", 0, 1, subject);
2266        case 3076014: /*date*/  return new Property("date", "instant", "When the document reference was created.", 0, 1, date);
2267        case -1406328437: /*author*/  return new Property("author", "Reference(Practitioner|PractitionerRole|Organization|Device|Patient|RelatedPerson)", "Identifies who is responsible for adding the information to the document.", 0, java.lang.Integer.MAX_VALUE, author);
2268        case 1815000435: /*authenticator*/  return new Property("authenticator", "Reference(Practitioner|PractitionerRole|Organization)", "Which person or organization authenticates that this document is valid.", 0, 1, authenticator);
2269        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 document.", 0, 1, custodian);
2270        case -7765931: /*relatesTo*/  return new Property("relatesTo", "", "Relationships that this document has with other document references that already exist.", 0, java.lang.Integer.MAX_VALUE, relatesTo);
2271        case -1724546052: /*description*/  return new Property("description", "string", "Human-readable description of the source document.", 0, 1, description);
2272        case -722296940: /*securityLabel*/  return new Property("securityLabel", "CodeableConcept", "A set of Security-Tag codes specifying the level of privacy/security of the Document. Note that DocumentReference.meta.security contains the security labels of the \"reference\" to the document, while DocumentReference.securityLabel contains a snapshot of the security labels on the document the reference refers to.", 0, java.lang.Integer.MAX_VALUE, securityLabel);
2273        case 951530617: /*content*/  return new Property("content", "", "The document and format referenced. There may be multiple content element repetitions, each with a different format.", 0, java.lang.Integer.MAX_VALUE, content);
2274        case 951530927: /*context*/  return new Property("context", "", "The clinical context in which the document was prepared.", 0, 1, context);
2275        default: return super.getNamedProperty(_hash, _name, _checkValid);
2276        }
2277
2278      }
2279
2280      @Override
2281      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2282        switch (hash) {
2283        case 243769515: /*masterIdentifier*/ return this.masterIdentifier == null ? new Base[0] : new Base[] {this.masterIdentifier}; // Identifier
2284        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
2285        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<DocumentReferenceStatus>
2286        case -23496886: /*docStatus*/ return this.docStatus == null ? new Base[0] : new Base[] {this.docStatus}; // Enumeration<ReferredDocumentStatus>
2287        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
2288        case 50511102: /*category*/ return this.category == null ? new Base[0] : this.category.toArray(new Base[this.category.size()]); // CodeableConcept
2289        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
2290        case 3076014: /*date*/ return this.date == null ? new Base[0] : new Base[] {this.date}; // InstantType
2291        case -1406328437: /*author*/ return this.author == null ? new Base[0] : this.author.toArray(new Base[this.author.size()]); // Reference
2292        case 1815000435: /*authenticator*/ return this.authenticator == null ? new Base[0] : new Base[] {this.authenticator}; // Reference
2293        case 1611297262: /*custodian*/ return this.custodian == null ? new Base[0] : new Base[] {this.custodian}; // Reference
2294        case -7765931: /*relatesTo*/ return this.relatesTo == null ? new Base[0] : this.relatesTo.toArray(new Base[this.relatesTo.size()]); // DocumentReferenceRelatesToComponent
2295        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // StringType
2296        case -722296940: /*securityLabel*/ return this.securityLabel == null ? new Base[0] : this.securityLabel.toArray(new Base[this.securityLabel.size()]); // CodeableConcept
2297        case 951530617: /*content*/ return this.content == null ? new Base[0] : this.content.toArray(new Base[this.content.size()]); // DocumentReferenceContentComponent
2298        case 951530927: /*context*/ return this.context == null ? new Base[0] : new Base[] {this.context}; // DocumentReferenceContextComponent
2299        default: return super.getProperty(hash, name, checkValid);
2300        }
2301
2302      }
2303
2304      @Override
2305      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2306        switch (hash) {
2307        case 243769515: // masterIdentifier
2308          this.masterIdentifier = castToIdentifier(value); // Identifier
2309          return value;
2310        case -1618432855: // identifier
2311          this.getIdentifier().add(castToIdentifier(value)); // Identifier
2312          return value;
2313        case -892481550: // status
2314          value = new DocumentReferenceStatusEnumFactory().fromType(castToCode(value));
2315          this.status = (Enumeration) value; // Enumeration<DocumentReferenceStatus>
2316          return value;
2317        case -23496886: // docStatus
2318          value = new ReferredDocumentStatusEnumFactory().fromType(castToCode(value));
2319          this.docStatus = (Enumeration) value; // Enumeration<ReferredDocumentStatus>
2320          return value;
2321        case 3575610: // type
2322          this.type = castToCodeableConcept(value); // CodeableConcept
2323          return value;
2324        case 50511102: // category
2325          this.getCategory().add(castToCodeableConcept(value)); // CodeableConcept
2326          return value;
2327        case -1867885268: // subject
2328          this.subject = castToReference(value); // Reference
2329          return value;
2330        case 3076014: // date
2331          this.date = castToInstant(value); // InstantType
2332          return value;
2333        case -1406328437: // author
2334          this.getAuthor().add(castToReference(value)); // Reference
2335          return value;
2336        case 1815000435: // authenticator
2337          this.authenticator = castToReference(value); // Reference
2338          return value;
2339        case 1611297262: // custodian
2340          this.custodian = castToReference(value); // Reference
2341          return value;
2342        case -7765931: // relatesTo
2343          this.getRelatesTo().add((DocumentReferenceRelatesToComponent) value); // DocumentReferenceRelatesToComponent
2344          return value;
2345        case -1724546052: // description
2346          this.description = castToString(value); // StringType
2347          return value;
2348        case -722296940: // securityLabel
2349          this.getSecurityLabel().add(castToCodeableConcept(value)); // CodeableConcept
2350          return value;
2351        case 951530617: // content
2352          this.getContent().add((DocumentReferenceContentComponent) value); // DocumentReferenceContentComponent
2353          return value;
2354        case 951530927: // context
2355          this.context = (DocumentReferenceContextComponent) value; // DocumentReferenceContextComponent
2356          return value;
2357        default: return super.setProperty(hash, name, value);
2358        }
2359
2360      }
2361
2362      @Override
2363      public Base setProperty(String name, Base value) throws FHIRException {
2364        if (name.equals("masterIdentifier")) {
2365          this.masterIdentifier = castToIdentifier(value); // Identifier
2366        } else if (name.equals("identifier")) {
2367          this.getIdentifier().add(castToIdentifier(value));
2368        } else if (name.equals("status")) {
2369          value = new DocumentReferenceStatusEnumFactory().fromType(castToCode(value));
2370          this.status = (Enumeration) value; // Enumeration<DocumentReferenceStatus>
2371        } else if (name.equals("docStatus")) {
2372          value = new ReferredDocumentStatusEnumFactory().fromType(castToCode(value));
2373          this.docStatus = (Enumeration) value; // Enumeration<ReferredDocumentStatus>
2374        } else if (name.equals("type")) {
2375          this.type = castToCodeableConcept(value); // CodeableConcept
2376        } else if (name.equals("category")) {
2377          this.getCategory().add(castToCodeableConcept(value));
2378        } else if (name.equals("subject")) {
2379          this.subject = castToReference(value); // Reference
2380        } else if (name.equals("date")) {
2381          this.date = castToInstant(value); // InstantType
2382        } else if (name.equals("author")) {
2383          this.getAuthor().add(castToReference(value));
2384        } else if (name.equals("authenticator")) {
2385          this.authenticator = castToReference(value); // Reference
2386        } else if (name.equals("custodian")) {
2387          this.custodian = castToReference(value); // Reference
2388        } else if (name.equals("relatesTo")) {
2389          this.getRelatesTo().add((DocumentReferenceRelatesToComponent) value);
2390        } else if (name.equals("description")) {
2391          this.description = castToString(value); // StringType
2392        } else if (name.equals("securityLabel")) {
2393          this.getSecurityLabel().add(castToCodeableConcept(value));
2394        } else if (name.equals("content")) {
2395          this.getContent().add((DocumentReferenceContentComponent) value);
2396        } else if (name.equals("context")) {
2397          this.context = (DocumentReferenceContextComponent) value; // DocumentReferenceContextComponent
2398        } else
2399          return super.setProperty(name, value);
2400        return value;
2401      }
2402
2403      @Override
2404      public Base makeProperty(int hash, String name) throws FHIRException {
2405        switch (hash) {
2406        case 243769515:  return getMasterIdentifier(); 
2407        case -1618432855:  return addIdentifier(); 
2408        case -892481550:  return getStatusElement();
2409        case -23496886:  return getDocStatusElement();
2410        case 3575610:  return getType(); 
2411        case 50511102:  return addCategory(); 
2412        case -1867885268:  return getSubject(); 
2413        case 3076014:  return getDateElement();
2414        case -1406328437:  return addAuthor(); 
2415        case 1815000435:  return getAuthenticator(); 
2416        case 1611297262:  return getCustodian(); 
2417        case -7765931:  return addRelatesTo(); 
2418        case -1724546052:  return getDescriptionElement();
2419        case -722296940:  return addSecurityLabel(); 
2420        case 951530617:  return addContent(); 
2421        case 951530927:  return getContext(); 
2422        default: return super.makeProperty(hash, name);
2423        }
2424
2425      }
2426
2427      @Override
2428      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2429        switch (hash) {
2430        case 243769515: /*masterIdentifier*/ return new String[] {"Identifier"};
2431        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
2432        case -892481550: /*status*/ return new String[] {"code"};
2433        case -23496886: /*docStatus*/ return new String[] {"code"};
2434        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
2435        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
2436        case -1867885268: /*subject*/ return new String[] {"Reference"};
2437        case 3076014: /*date*/ return new String[] {"instant"};
2438        case -1406328437: /*author*/ return new String[] {"Reference"};
2439        case 1815000435: /*authenticator*/ return new String[] {"Reference"};
2440        case 1611297262: /*custodian*/ return new String[] {"Reference"};
2441        case -7765931: /*relatesTo*/ return new String[] {};
2442        case -1724546052: /*description*/ return new String[] {"string"};
2443        case -722296940: /*securityLabel*/ return new String[] {"CodeableConcept"};
2444        case 951530617: /*content*/ return new String[] {};
2445        case 951530927: /*context*/ return new String[] {};
2446        default: return super.getTypesForProperty(hash, name);
2447        }
2448
2449      }
2450
2451      @Override
2452      public Base addChild(String name) throws FHIRException {
2453        if (name.equals("masterIdentifier")) {
2454          this.masterIdentifier = new Identifier();
2455          return this.masterIdentifier;
2456        }
2457        else if (name.equals("identifier")) {
2458          return addIdentifier();
2459        }
2460        else if (name.equals("status")) {
2461          throw new FHIRException("Cannot call addChild on a primitive type DocumentReference.status");
2462        }
2463        else if (name.equals("docStatus")) {
2464          throw new FHIRException("Cannot call addChild on a primitive type DocumentReference.docStatus");
2465        }
2466        else if (name.equals("type")) {
2467          this.type = new CodeableConcept();
2468          return this.type;
2469        }
2470        else if (name.equals("category")) {
2471          return addCategory();
2472        }
2473        else if (name.equals("subject")) {
2474          this.subject = new Reference();
2475          return this.subject;
2476        }
2477        else if (name.equals("date")) {
2478          throw new FHIRException("Cannot call addChild on a primitive type DocumentReference.date");
2479        }
2480        else if (name.equals("author")) {
2481          return addAuthor();
2482        }
2483        else if (name.equals("authenticator")) {
2484          this.authenticator = new Reference();
2485          return this.authenticator;
2486        }
2487        else if (name.equals("custodian")) {
2488          this.custodian = new Reference();
2489          return this.custodian;
2490        }
2491        else if (name.equals("relatesTo")) {
2492          return addRelatesTo();
2493        }
2494        else if (name.equals("description")) {
2495          throw new FHIRException("Cannot call addChild on a primitive type DocumentReference.description");
2496        }
2497        else if (name.equals("securityLabel")) {
2498          return addSecurityLabel();
2499        }
2500        else if (name.equals("content")) {
2501          return addContent();
2502        }
2503        else if (name.equals("context")) {
2504          this.context = new DocumentReferenceContextComponent();
2505          return this.context;
2506        }
2507        else
2508          return super.addChild(name);
2509      }
2510
2511  public String fhirType() {
2512    return "DocumentReference";
2513
2514  }
2515
2516      public DocumentReference copy() {
2517        DocumentReference dst = new DocumentReference();
2518        copyValues(dst);
2519        return dst;
2520      }
2521
2522      public void copyValues(DocumentReference dst) {
2523        super.copyValues(dst);
2524        dst.masterIdentifier = masterIdentifier == null ? null : masterIdentifier.copy();
2525        if (identifier != null) {
2526          dst.identifier = new ArrayList<Identifier>();
2527          for (Identifier i : identifier)
2528            dst.identifier.add(i.copy());
2529        };
2530        dst.status = status == null ? null : status.copy();
2531        dst.docStatus = docStatus == null ? null : docStatus.copy();
2532        dst.type = type == null ? null : type.copy();
2533        if (category != null) {
2534          dst.category = new ArrayList<CodeableConcept>();
2535          for (CodeableConcept i : category)
2536            dst.category.add(i.copy());
2537        };
2538        dst.subject = subject == null ? null : subject.copy();
2539        dst.date = date == null ? null : date.copy();
2540        if (author != null) {
2541          dst.author = new ArrayList<Reference>();
2542          for (Reference i : author)
2543            dst.author.add(i.copy());
2544        };
2545        dst.authenticator = authenticator == null ? null : authenticator.copy();
2546        dst.custodian = custodian == null ? null : custodian.copy();
2547        if (relatesTo != null) {
2548          dst.relatesTo = new ArrayList<DocumentReferenceRelatesToComponent>();
2549          for (DocumentReferenceRelatesToComponent i : relatesTo)
2550            dst.relatesTo.add(i.copy());
2551        };
2552        dst.description = description == null ? null : description.copy();
2553        if (securityLabel != null) {
2554          dst.securityLabel = new ArrayList<CodeableConcept>();
2555          for (CodeableConcept i : securityLabel)
2556            dst.securityLabel.add(i.copy());
2557        };
2558        if (content != null) {
2559          dst.content = new ArrayList<DocumentReferenceContentComponent>();
2560          for (DocumentReferenceContentComponent i : content)
2561            dst.content.add(i.copy());
2562        };
2563        dst.context = context == null ? null : context.copy();
2564      }
2565
2566      protected DocumentReference typedCopy() {
2567        return copy();
2568      }
2569
2570      @Override
2571      public boolean equalsDeep(Base other_) {
2572        if (!super.equalsDeep(other_))
2573          return false;
2574        if (!(other_ instanceof DocumentReference))
2575          return false;
2576        DocumentReference o = (DocumentReference) other_;
2577        return compareDeep(masterIdentifier, o.masterIdentifier, true) && compareDeep(identifier, o.identifier, true)
2578           && compareDeep(status, o.status, true) && compareDeep(docStatus, o.docStatus, true) && compareDeep(type, o.type, true)
2579           && compareDeep(category, o.category, true) && compareDeep(subject, o.subject, true) && compareDeep(date, o.date, true)
2580           && compareDeep(author, o.author, true) && compareDeep(authenticator, o.authenticator, true) && compareDeep(custodian, o.custodian, true)
2581           && compareDeep(relatesTo, o.relatesTo, true) && compareDeep(description, o.description, true) && compareDeep(securityLabel, o.securityLabel, true)
2582           && compareDeep(content, o.content, true) && compareDeep(context, o.context, true);
2583      }
2584
2585      @Override
2586      public boolean equalsShallow(Base other_) {
2587        if (!super.equalsShallow(other_))
2588          return false;
2589        if (!(other_ instanceof DocumentReference))
2590          return false;
2591        DocumentReference o = (DocumentReference) other_;
2592        return compareValues(status, o.status, true) && compareValues(docStatus, o.docStatus, true) && compareValues(date, o.date, true)
2593           && compareValues(description, o.description, true);
2594      }
2595
2596      public boolean isEmpty() {
2597        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(masterIdentifier, identifier
2598          , status, docStatus, type, category, subject, date, author, authenticator, custodian
2599          , relatesTo, description, securityLabel, content, context);
2600      }
2601
2602  @Override
2603  public ResourceType getResourceType() {
2604    return ResourceType.DocumentReference;
2605   }
2606
2607 /**
2608   * Search parameter: <b>date</b>
2609   * <p>
2610   * Description: <b>When this document reference was created</b><br>
2611   * Type: <b>date</b><br>
2612   * Path: <b>DocumentReference.date</b><br>
2613   * </p>
2614   */
2615  @SearchParamDefinition(name="date", path="DocumentReference.date", description="When this document reference was created", type="date" )
2616  public static final String SP_DATE = "date";
2617 /**
2618   * <b>Fluent Client</b> search parameter constant for <b>date</b>
2619   * <p>
2620   * Description: <b>When this document reference was created</b><br>
2621   * Type: <b>date</b><br>
2622   * Path: <b>DocumentReference.date</b><br>
2623   * </p>
2624   */
2625  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATE);
2626
2627 /**
2628   * Search parameter: <b>subject</b>
2629   * <p>
2630   * Description: <b>Who/what is the subject of the document</b><br>
2631   * Type: <b>reference</b><br>
2632   * Path: <b>DocumentReference.subject</b><br>
2633   * </p>
2634   */
2635  @SearchParamDefinition(name="subject", path="DocumentReference.subject", description="Who/what is the subject of the document", 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") }, target={Device.class, Group.class, Patient.class, Practitioner.class } )
2636  public static final String SP_SUBJECT = "subject";
2637 /**
2638   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
2639   * <p>
2640   * Description: <b>Who/what is the subject of the document</b><br>
2641   * Type: <b>reference</b><br>
2642   * Path: <b>DocumentReference.subject</b><br>
2643   * </p>
2644   */
2645  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
2646
2647/**
2648   * Constant for fluent queries to be used to add include statements. Specifies
2649   * the path value of "<b>DocumentReference:subject</b>".
2650   */
2651  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("DocumentReference:subject").toLocked();
2652
2653 /**
2654   * Search parameter: <b>description</b>
2655   * <p>
2656   * Description: <b>Human-readable description</b><br>
2657   * Type: <b>string</b><br>
2658   * Path: <b>DocumentReference.description</b><br>
2659   * </p>
2660   */
2661  @SearchParamDefinition(name="description", path="DocumentReference.description", description="Human-readable description", type="string" )
2662  public static final String SP_DESCRIPTION = "description";
2663 /**
2664   * <b>Fluent Client</b> search parameter constant for <b>description</b>
2665   * <p>
2666   * Description: <b>Human-readable description</b><br>
2667   * Type: <b>string</b><br>
2668   * Path: <b>DocumentReference.description</b><br>
2669   * </p>
2670   */
2671  public static final ca.uhn.fhir.rest.gclient.StringClientParam DESCRIPTION = new ca.uhn.fhir.rest.gclient.StringClientParam(SP_DESCRIPTION);
2672
2673 /**
2674   * Search parameter: <b>language</b>
2675   * <p>
2676   * Description: <b>Human language of the content (BCP-47)</b><br>
2677   * Type: <b>token</b><br>
2678   * Path: <b>DocumentReference.content.attachment.language</b><br>
2679   * </p>
2680   */
2681  @SearchParamDefinition(name="language", path="DocumentReference.content.attachment.language", description="Human language of the content (BCP-47)", type="token" )
2682  public static final String SP_LANGUAGE = "language";
2683 /**
2684   * <b>Fluent Client</b> search parameter constant for <b>language</b>
2685   * <p>
2686   * Description: <b>Human language of the content (BCP-47)</b><br>
2687   * Type: <b>token</b><br>
2688   * Path: <b>DocumentReference.content.attachment.language</b><br>
2689   * </p>
2690   */
2691  public static final ca.uhn.fhir.rest.gclient.TokenClientParam LANGUAGE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_LANGUAGE);
2692
2693 /**
2694   * Search parameter: <b>type</b>
2695   * <p>
2696   * Description: <b>Kind of document (LOINC if possible)</b><br>
2697   * Type: <b>token</b><br>
2698   * Path: <b>DocumentReference.type</b><br>
2699   * </p>
2700   */
2701  @SearchParamDefinition(name="type", path="DocumentReference.type", description="Kind of document (LOINC if possible)", type="token" )
2702  public static final String SP_TYPE = "type";
2703 /**
2704   * <b>Fluent Client</b> search parameter constant for <b>type</b>
2705   * <p>
2706   * Description: <b>Kind of document (LOINC if possible)</b><br>
2707   * Type: <b>token</b><br>
2708   * Path: <b>DocumentReference.type</b><br>
2709   * </p>
2710   */
2711  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_TYPE);
2712
2713 /**
2714   * Search parameter: <b>relation</b>
2715   * <p>
2716   * Description: <b>replaces | transforms | signs | appends</b><br>
2717   * Type: <b>token</b><br>
2718   * Path: <b>DocumentReference.relatesTo.code</b><br>
2719   * </p>
2720   */
2721  @SearchParamDefinition(name="relation", path="DocumentReference.relatesTo.code", description="replaces | transforms | signs | appends", type="token" )
2722  public static final String SP_RELATION = "relation";
2723 /**
2724   * <b>Fluent Client</b> search parameter constant for <b>relation</b>
2725   * <p>
2726   * Description: <b>replaces | transforms | signs | appends</b><br>
2727   * Type: <b>token</b><br>
2728   * Path: <b>DocumentReference.relatesTo.code</b><br>
2729   * </p>
2730   */
2731  public static final ca.uhn.fhir.rest.gclient.TokenClientParam RELATION = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_RELATION);
2732
2733 /**
2734   * Search parameter: <b>setting</b>
2735   * <p>
2736   * Description: <b>Additional details about where the content was created (e.g. clinical specialty)</b><br>
2737   * Type: <b>token</b><br>
2738   * Path: <b>DocumentReference.context.practiceSetting</b><br>
2739   * </p>
2740   */
2741  @SearchParamDefinition(name="setting", path="DocumentReference.context.practiceSetting", description="Additional details about where the content was created (e.g. clinical specialty)", type="token" )
2742  public static final String SP_SETTING = "setting";
2743 /**
2744   * <b>Fluent Client</b> search parameter constant for <b>setting</b>
2745   * <p>
2746   * Description: <b>Additional details about where the content was created (e.g. clinical specialty)</b><br>
2747   * Type: <b>token</b><br>
2748   * Path: <b>DocumentReference.context.practiceSetting</b><br>
2749   * </p>
2750   */
2751  public static final ca.uhn.fhir.rest.gclient.TokenClientParam SETTING = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_SETTING);
2752
2753 /**
2754   * Search parameter: <b>related</b>
2755   * <p>
2756   * Description: <b>Related identifiers or resources</b><br>
2757   * Type: <b>reference</b><br>
2758   * Path: <b>DocumentReference.context.related</b><br>
2759   * </p>
2760   */
2761  @SearchParamDefinition(name="related", path="DocumentReference.context.related", description="Related identifiers or resources", type="reference" )
2762  public static final String SP_RELATED = "related";
2763 /**
2764   * <b>Fluent Client</b> search parameter constant for <b>related</b>
2765   * <p>
2766   * Description: <b>Related identifiers or resources</b><br>
2767   * Type: <b>reference</b><br>
2768   * Path: <b>DocumentReference.context.related</b><br>
2769   * </p>
2770   */
2771  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam RELATED = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_RELATED);
2772
2773/**
2774   * Constant for fluent queries to be used to add include statements. Specifies
2775   * the path value of "<b>DocumentReference:related</b>".
2776   */
2777  public static final ca.uhn.fhir.model.api.Include INCLUDE_RELATED = new ca.uhn.fhir.model.api.Include("DocumentReference:related").toLocked();
2778
2779 /**
2780   * Search parameter: <b>patient</b>
2781   * <p>
2782   * Description: <b>Who/what is the subject of the document</b><br>
2783   * Type: <b>reference</b><br>
2784   * Path: <b>DocumentReference.subject</b><br>
2785   * </p>
2786   */
2787  @SearchParamDefinition(name="patient", path="DocumentReference.subject.where(resolve() is Patient)", description="Who/what is the subject of the document", type="reference", target={Patient.class } )
2788  public static final String SP_PATIENT = "patient";
2789 /**
2790   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
2791   * <p>
2792   * Description: <b>Who/what is the subject of the document</b><br>
2793   * Type: <b>reference</b><br>
2794   * Path: <b>DocumentReference.subject</b><br>
2795   * </p>
2796   */
2797  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
2798
2799/**
2800   * Constant for fluent queries to be used to add include statements. Specifies
2801   * the path value of "<b>DocumentReference:patient</b>".
2802   */
2803  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("DocumentReference:patient").toLocked();
2804
2805 /**
2806   * Search parameter: <b>relationship</b>
2807   * <p>
2808   * Description: <b>Combination of relation and relatesTo</b><br>
2809   * Type: <b>composite</b><br>
2810   * Path: <b></b><br>
2811   * </p>
2812   */
2813  @SearchParamDefinition(name="relationship", path="DocumentReference.relatesTo", description="Combination of relation and relatesTo", type="composite", compositeOf={"relatesto", "relation"} )
2814  public static final String SP_RELATIONSHIP = "relationship";
2815 /**
2816   * <b>Fluent Client</b> search parameter constant for <b>relationship</b>
2817   * <p>
2818   * Description: <b>Combination of relation and relatesTo</b><br>
2819   * Type: <b>composite</b><br>
2820   * Path: <b></b><br>
2821   * </p>
2822   */
2823  public static final ca.uhn.fhir.rest.gclient.CompositeClientParam<ca.uhn.fhir.rest.gclient.ReferenceClientParam, ca.uhn.fhir.rest.gclient.TokenClientParam> RELATIONSHIP = new ca.uhn.fhir.rest.gclient.CompositeClientParam<ca.uhn.fhir.rest.gclient.ReferenceClientParam, ca.uhn.fhir.rest.gclient.TokenClientParam>(SP_RELATIONSHIP);
2824
2825 /**
2826   * Search parameter: <b>event</b>
2827   * <p>
2828   * Description: <b>Main clinical acts documented</b><br>
2829   * Type: <b>token</b><br>
2830   * Path: <b>DocumentReference.context.event</b><br>
2831   * </p>
2832   */
2833  @SearchParamDefinition(name="event", path="DocumentReference.context.event", description="Main clinical acts documented", type="token" )
2834  public static final String SP_EVENT = "event";
2835 /**
2836   * <b>Fluent Client</b> search parameter constant for <b>event</b>
2837   * <p>
2838   * Description: <b>Main clinical acts documented</b><br>
2839   * Type: <b>token</b><br>
2840   * Path: <b>DocumentReference.context.event</b><br>
2841   * </p>
2842   */
2843  public static final ca.uhn.fhir.rest.gclient.TokenClientParam EVENT = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_EVENT);
2844
2845 /**
2846   * Search parameter: <b>authenticator</b>
2847   * <p>
2848   * Description: <b>Who/what authenticated the document</b><br>
2849   * Type: <b>reference</b><br>
2850   * Path: <b>DocumentReference.authenticator</b><br>
2851   * </p>
2852   */
2853  @SearchParamDefinition(name="authenticator", path="DocumentReference.authenticator", description="Who/what authenticated the document", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner") }, target={Organization.class, Practitioner.class, PractitionerRole.class } )
2854  public static final String SP_AUTHENTICATOR = "authenticator";
2855 /**
2856   * <b>Fluent Client</b> search parameter constant for <b>authenticator</b>
2857   * <p>
2858   * Description: <b>Who/what authenticated the document</b><br>
2859   * Type: <b>reference</b><br>
2860   * Path: <b>DocumentReference.authenticator</b><br>
2861   * </p>
2862   */
2863  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam AUTHENTICATOR = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_AUTHENTICATOR);
2864
2865/**
2866   * Constant for fluent queries to be used to add include statements. Specifies
2867   * the path value of "<b>DocumentReference:authenticator</b>".
2868   */
2869  public static final ca.uhn.fhir.model.api.Include INCLUDE_AUTHENTICATOR = new ca.uhn.fhir.model.api.Include("DocumentReference:authenticator").toLocked();
2870
2871 /**
2872   * Search parameter: <b>identifier</b>
2873   * <p>
2874   * Description: <b>Master Version Specific Identifier</b><br>
2875   * Type: <b>token</b><br>
2876   * Path: <b>DocumentReference.masterIdentifier, DocumentReference.identifier</b><br>
2877   * </p>
2878   */
2879  @SearchParamDefinition(name="identifier", path="DocumentReference.masterIdentifier | DocumentReference.identifier", description="Master Version Specific Identifier", type="token" )
2880  public static final String SP_IDENTIFIER = "identifier";
2881 /**
2882   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
2883   * <p>
2884   * Description: <b>Master Version Specific Identifier</b><br>
2885   * Type: <b>token</b><br>
2886   * Path: <b>DocumentReference.masterIdentifier, DocumentReference.identifier</b><br>
2887   * </p>
2888   */
2889  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
2890
2891 /**
2892   * Search parameter: <b>period</b>
2893   * <p>
2894   * Description: <b>Time of service that is being documented</b><br>
2895   * Type: <b>date</b><br>
2896   * Path: <b>DocumentReference.context.period</b><br>
2897   * </p>
2898   */
2899  @SearchParamDefinition(name="period", path="DocumentReference.context.period", description="Time of service that is being documented", type="date" )
2900  public static final String SP_PERIOD = "period";
2901 /**
2902   * <b>Fluent Client</b> search parameter constant for <b>period</b>
2903   * <p>
2904   * Description: <b>Time of service that is being documented</b><br>
2905   * Type: <b>date</b><br>
2906   * Path: <b>DocumentReference.context.period</b><br>
2907   * </p>
2908   */
2909  public static final ca.uhn.fhir.rest.gclient.DateClientParam PERIOD = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_PERIOD);
2910
2911 /**
2912   * Search parameter: <b>custodian</b>
2913   * <p>
2914   * Description: <b>Organization which maintains the document</b><br>
2915   * Type: <b>reference</b><br>
2916   * Path: <b>DocumentReference.custodian</b><br>
2917   * </p>
2918   */
2919  @SearchParamDefinition(name="custodian", path="DocumentReference.custodian", description="Organization which maintains the document", type="reference", target={Organization.class } )
2920  public static final String SP_CUSTODIAN = "custodian";
2921 /**
2922   * <b>Fluent Client</b> search parameter constant for <b>custodian</b>
2923   * <p>
2924   * Description: <b>Organization which maintains the document</b><br>
2925   * Type: <b>reference</b><br>
2926   * Path: <b>DocumentReference.custodian</b><br>
2927   * </p>
2928   */
2929  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam CUSTODIAN = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_CUSTODIAN);
2930
2931/**
2932   * Constant for fluent queries to be used to add include statements. Specifies
2933   * the path value of "<b>DocumentReference:custodian</b>".
2934   */
2935  public static final ca.uhn.fhir.model.api.Include INCLUDE_CUSTODIAN = new ca.uhn.fhir.model.api.Include("DocumentReference:custodian").toLocked();
2936
2937 /**
2938   * Search parameter: <b>author</b>
2939   * <p>
2940   * Description: <b>Who and/or what authored the document</b><br>
2941   * Type: <b>reference</b><br>
2942   * Path: <b>DocumentReference.author</b><br>
2943   * </p>
2944   */
2945  @SearchParamDefinition(name="author", path="DocumentReference.author", description="Who and/or what authored the document", 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 } )
2946  public static final String SP_AUTHOR = "author";
2947 /**
2948   * <b>Fluent Client</b> search parameter constant for <b>author</b>
2949   * <p>
2950   * Description: <b>Who and/or what authored the document</b><br>
2951   * Type: <b>reference</b><br>
2952   * Path: <b>DocumentReference.author</b><br>
2953   * </p>
2954   */
2955  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam AUTHOR = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_AUTHOR);
2956
2957/**
2958   * Constant for fluent queries to be used to add include statements. Specifies
2959   * the path value of "<b>DocumentReference:author</b>".
2960   */
2961  public static final ca.uhn.fhir.model.api.Include INCLUDE_AUTHOR = new ca.uhn.fhir.model.api.Include("DocumentReference:author").toLocked();
2962
2963 /**
2964   * Search parameter: <b>format</b>
2965   * <p>
2966   * Description: <b>Format/content rules for the document</b><br>
2967   * Type: <b>token</b><br>
2968   * Path: <b>DocumentReference.content.format</b><br>
2969   * </p>
2970   */
2971  @SearchParamDefinition(name="format", path="DocumentReference.content.format", description="Format/content rules for the document", type="token" )
2972  public static final String SP_FORMAT = "format";
2973 /**
2974   * <b>Fluent Client</b> search parameter constant for <b>format</b>
2975   * <p>
2976   * Description: <b>Format/content rules for the document</b><br>
2977   * Type: <b>token</b><br>
2978   * Path: <b>DocumentReference.content.format</b><br>
2979   * </p>
2980   */
2981  public static final ca.uhn.fhir.rest.gclient.TokenClientParam FORMAT = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_FORMAT);
2982
2983 /**
2984   * Search parameter: <b>encounter</b>
2985   * <p>
2986   * Description: <b>Context of the document  content</b><br>
2987   * Type: <b>reference</b><br>
2988   * Path: <b>DocumentReference.context.encounter</b><br>
2989   * </p>
2990   */
2991  @SearchParamDefinition(name="encounter", path="DocumentReference.context.encounter", description="Context of the document  content", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Encounter") }, target={Encounter.class, EpisodeOfCare.class } )
2992  public static final String SP_ENCOUNTER = "encounter";
2993 /**
2994   * <b>Fluent Client</b> search parameter constant for <b>encounter</b>
2995   * <p>
2996   * Description: <b>Context of the document  content</b><br>
2997   * Type: <b>reference</b><br>
2998   * Path: <b>DocumentReference.context.encounter</b><br>
2999   * </p>
3000   */
3001  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENCOUNTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENCOUNTER);
3002
3003/**
3004   * Constant for fluent queries to be used to add include statements. Specifies
3005   * the path value of "<b>DocumentReference:encounter</b>".
3006   */
3007  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENCOUNTER = new ca.uhn.fhir.model.api.Include("DocumentReference:encounter").toLocked();
3008
3009 /**
3010   * Search parameter: <b>contenttype</b>
3011   * <p>
3012   * Description: <b>Mime type of the content, with charset etc.</b><br>
3013   * Type: <b>token</b><br>
3014   * Path: <b>DocumentReference.content.attachment.contentType</b><br>
3015   * </p>
3016   */
3017  @SearchParamDefinition(name="contenttype", path="DocumentReference.content.attachment.contentType", description="Mime type of the content, with charset etc.", type="token" )
3018  public static final String SP_CONTENTTYPE = "contenttype";
3019 /**
3020   * <b>Fluent Client</b> search parameter constant for <b>contenttype</b>
3021   * <p>
3022   * Description: <b>Mime type of the content, with charset etc.</b><br>
3023   * Type: <b>token</b><br>
3024   * Path: <b>DocumentReference.content.attachment.contentType</b><br>
3025   * </p>
3026   */
3027  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CONTENTTYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CONTENTTYPE);
3028
3029 /**
3030   * Search parameter: <b>security-label</b>
3031   * <p>
3032   * Description: <b>Document security-tags</b><br>
3033   * Type: <b>token</b><br>
3034   * Path: <b>DocumentReference.securityLabel</b><br>
3035   * </p>
3036   */
3037  @SearchParamDefinition(name="security-label", path="DocumentReference.securityLabel", description="Document security-tags", type="token" )
3038  public static final String SP_SECURITY_LABEL = "security-label";
3039 /**
3040   * <b>Fluent Client</b> search parameter constant for <b>security-label</b>
3041   * <p>
3042   * Description: <b>Document security-tags</b><br>
3043   * Type: <b>token</b><br>
3044   * Path: <b>DocumentReference.securityLabel</b><br>
3045   * </p>
3046   */
3047  public static final ca.uhn.fhir.rest.gclient.TokenClientParam SECURITY_LABEL = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_SECURITY_LABEL);
3048
3049 /**
3050   * Search parameter: <b>location</b>
3051   * <p>
3052   * Description: <b>Uri where the data can be found</b><br>
3053   * Type: <b>uri</b><br>
3054   * Path: <b>DocumentReference.content.attachment.url</b><br>
3055   * </p>
3056   */
3057  @SearchParamDefinition(name="location", path="DocumentReference.content.attachment.url", description="Uri where the data can be found", type="uri" )
3058  public static final String SP_LOCATION = "location";
3059 /**
3060   * <b>Fluent Client</b> search parameter constant for <b>location</b>
3061   * <p>
3062   * Description: <b>Uri where the data can be found</b><br>
3063   * Type: <b>uri</b><br>
3064   * Path: <b>DocumentReference.content.attachment.url</b><br>
3065   * </p>
3066   */
3067  public static final ca.uhn.fhir.rest.gclient.UriClientParam LOCATION = new ca.uhn.fhir.rest.gclient.UriClientParam(SP_LOCATION);
3068
3069 /**
3070   * Search parameter: <b>category</b>
3071   * <p>
3072   * Description: <b>Categorization of document</b><br>
3073   * Type: <b>token</b><br>
3074   * Path: <b>DocumentReference.category</b><br>
3075   * </p>
3076   */
3077  @SearchParamDefinition(name="category", path="DocumentReference.category", description="Categorization of document", type="token" )
3078  public static final String SP_CATEGORY = "category";
3079 /**
3080   * <b>Fluent Client</b> search parameter constant for <b>category</b>
3081   * <p>
3082   * Description: <b>Categorization of document</b><br>
3083   * Type: <b>token</b><br>
3084   * Path: <b>DocumentReference.category</b><br>
3085   * </p>
3086   */
3087  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CATEGORY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CATEGORY);
3088
3089 /**
3090   * Search parameter: <b>relatesto</b>
3091   * <p>
3092   * Description: <b>Target of the relationship</b><br>
3093   * Type: <b>reference</b><br>
3094   * Path: <b>DocumentReference.relatesTo.target</b><br>
3095   * </p>
3096   */
3097  @SearchParamDefinition(name="relatesto", path="DocumentReference.relatesTo.target", description="Target of the relationship", type="reference", target={DocumentReference.class } )
3098  public static final String SP_RELATESTO = "relatesto";
3099 /**
3100   * <b>Fluent Client</b> search parameter constant for <b>relatesto</b>
3101   * <p>
3102   * Description: <b>Target of the relationship</b><br>
3103   * Type: <b>reference</b><br>
3104   * Path: <b>DocumentReference.relatesTo.target</b><br>
3105   * </p>
3106   */
3107  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam RELATESTO = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_RELATESTO);
3108
3109/**
3110   * Constant for fluent queries to be used to add include statements. Specifies
3111   * the path value of "<b>DocumentReference:relatesto</b>".
3112   */
3113  public static final ca.uhn.fhir.model.api.Include INCLUDE_RELATESTO = new ca.uhn.fhir.model.api.Include("DocumentReference:relatesto").toLocked();
3114
3115 /**
3116   * Search parameter: <b>facility</b>
3117   * <p>
3118   * Description: <b>Kind of facility where patient was seen</b><br>
3119   * Type: <b>token</b><br>
3120   * Path: <b>DocumentReference.context.facilityType</b><br>
3121   * </p>
3122   */
3123  @SearchParamDefinition(name="facility", path="DocumentReference.context.facilityType", description="Kind of facility where patient was seen", type="token" )
3124  public static final String SP_FACILITY = "facility";
3125 /**
3126   * <b>Fluent Client</b> search parameter constant for <b>facility</b>
3127   * <p>
3128   * Description: <b>Kind of facility where patient was seen</b><br>
3129   * Type: <b>token</b><br>
3130   * Path: <b>DocumentReference.context.facilityType</b><br>
3131   * </p>
3132   */
3133  public static final ca.uhn.fhir.rest.gclient.TokenClientParam FACILITY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_FACILITY);
3134
3135 /**
3136   * Search parameter: <b>status</b>
3137   * <p>
3138   * Description: <b>current | superseded | entered-in-error</b><br>
3139   * Type: <b>token</b><br>
3140   * Path: <b>DocumentReference.status</b><br>
3141   * </p>
3142   */
3143  @SearchParamDefinition(name="status", path="DocumentReference.status", description="current | superseded | entered-in-error", type="token" )
3144  public static final String SP_STATUS = "status";
3145 /**
3146   * <b>Fluent Client</b> search parameter constant for <b>status</b>
3147   * <p>
3148   * Description: <b>current | superseded | entered-in-error</b><br>
3149   * Type: <b>token</b><br>
3150   * Path: <b>DocumentReference.status</b><br>
3151   * </p>
3152   */
3153  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
3154
3155
3156}