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