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