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