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