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