001package org.hl7.fhir.instance.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
033import java.util.*;
034
035import org.hl7.fhir.exceptions.FHIRException;
036import org.hl7.fhir.instance.model.Enumerations.DocumentReferenceStatus;
037import org.hl7.fhir.instance.model.Enumerations.DocumentReferenceStatusEnumFactory;
038import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
039import org.hl7.fhir.utilities.Utilities;
040
041import ca.uhn.fhir.model.api.annotation.*;
042/**
043 * A manifest that defines a set of documents.
044 */
045@ResourceDef(name="DocumentManifest", profile="http://hl7.org/fhir/Profile/DocumentManifest")
046public class DocumentManifest extends DomainResource {
047
048    @Block()
049    public static class DocumentManifestContentComponent extends BackboneElement implements IBaseBackboneElement {
050        /**
051         * The list of references to document content, or Attachment that consist of the parts of this document manifest. Usually, these would be document references, but direct references to Media or Attachments are also allowed.
052         */
053        @Child(name = "p", type = {Attachment.class}, order=1, min=1, max=1, modifier=false, summary=true)
054        @Description(shortDefinition="Contents of this set of documents", formalDefinition="The list of references to document content, or Attachment that consist of the parts of this document manifest. Usually, these would be document references, but direct references to Media or Attachments are also allowed." )
055        protected Type p;
056
057        private static final long serialVersionUID = -347538500L;
058
059    /*
060     * Constructor
061     */
062      public DocumentManifestContentComponent() {
063        super();
064      }
065
066    /*
067     * Constructor
068     */
069      public DocumentManifestContentComponent(Type p) {
070        super();
071        this.p = p;
072      }
073
074        /**
075         * @return {@link #p} (The list of references to document content, or Attachment that consist of the parts of this document manifest. Usually, these would be document references, but direct references to Media or Attachments are also allowed.)
076         */
077        public Type getP() { 
078          return this.p;
079        }
080
081        /**
082         * @return {@link #p} (The list of references to document content, or Attachment that consist of the parts of this document manifest. Usually, these would be document references, but direct references to Media or Attachments are also allowed.)
083         */
084        public Attachment getPAttachment() throws FHIRException { 
085          if (!(this.p instanceof Attachment))
086            throw new FHIRException("Type mismatch: the type Attachment was expected, but "+this.p.getClass().getName()+" was encountered");
087          return (Attachment) this.p;
088        }
089
090        public boolean hasPAttachment() { 
091          return this.p instanceof Attachment;
092        }
093
094        /**
095         * @return {@link #p} (The list of references to document content, or Attachment that consist of the parts of this document manifest. Usually, these would be document references, but direct references to Media or Attachments are also allowed.)
096         */
097        public Reference getPReference() throws FHIRException { 
098          if (!(this.p instanceof Reference))
099            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.p.getClass().getName()+" was encountered");
100          return (Reference) this.p;
101        }
102
103        public boolean hasPReference() { 
104          return this.p instanceof Reference;
105        }
106
107        public boolean hasP() { 
108          return this.p != null && !this.p.isEmpty();
109        }
110
111        /**
112         * @param value {@link #p} (The list of references to document content, or Attachment that consist of the parts of this document manifest. Usually, these would be document references, but direct references to Media or Attachments are also allowed.)
113         */
114        public DocumentManifestContentComponent setP(Type value) { 
115          this.p = value;
116          return this;
117        }
118
119        protected void listChildren(List<Property> childrenList) {
120          super.listChildren(childrenList);
121          childrenList.add(new Property("p[x]", "Attachment|Reference(Any)", "The list of references to document content, or Attachment that consist of the parts of this document manifest. Usually, these would be document references, but direct references to Media or Attachments are also allowed.", 0, java.lang.Integer.MAX_VALUE, p));
122        }
123
124      @Override
125      public void setProperty(String name, Base value) throws FHIRException {
126        if (name.equals("p[x]"))
127          this.p = (Type) value; // Type
128        else
129          super.setProperty(name, value);
130      }
131
132      @Override
133      public Base addChild(String name) throws FHIRException {
134        if (name.equals("pAttachment")) {
135          this.p = new Attachment();
136          return this.p;
137        }
138        else if (name.equals("pReference")) {
139          this.p = new Reference();
140          return this.p;
141        }
142        else
143          return super.addChild(name);
144      }
145
146      public DocumentManifestContentComponent copy() {
147        DocumentManifestContentComponent dst = new DocumentManifestContentComponent();
148        copyValues(dst);
149        dst.p = p == null ? null : p.copy();
150        return dst;
151      }
152
153      @Override
154      public boolean equalsDeep(Base other) {
155        if (!super.equalsDeep(other))
156          return false;
157        if (!(other instanceof DocumentManifestContentComponent))
158          return false;
159        DocumentManifestContentComponent o = (DocumentManifestContentComponent) other;
160        return compareDeep(p, o.p, true);
161      }
162
163      @Override
164      public boolean equalsShallow(Base other) {
165        if (!super.equalsShallow(other))
166          return false;
167        if (!(other instanceof DocumentManifestContentComponent))
168          return false;
169        DocumentManifestContentComponent o = (DocumentManifestContentComponent) other;
170        return true;
171      }
172
173      public boolean isEmpty() {
174        return super.isEmpty() && (p == null || p.isEmpty());
175      }
176
177  public String fhirType() {
178    return "DocumentManifest.content";
179
180  }
181
182  }
183
184    @Block()
185    public static class DocumentManifestRelatedComponent extends BackboneElement implements IBaseBackboneElement {
186        /**
187         * Related identifier to this DocumentManifest.  For example, Order numbers, accession numbers, XDW workflow numbers.
188         */
189        @Child(name = "identifier", type = {Identifier.class}, order=1, min=0, max=1, modifier=false, summary=true)
190        @Description(shortDefinition="Identifiers of things that are related", formalDefinition="Related identifier to this DocumentManifest.  For example, Order numbers, accession numbers, XDW workflow numbers." )
191        protected Identifier identifier;
192
193        /**
194         * Related Resource to this DocumentManifest. For example, Order, DiagnosticOrder,  Procedure, EligibilityRequest, etc.
195         */
196        @Child(name = "ref", type = {}, order=2, min=0, max=1, modifier=false, summary=true)
197        @Description(shortDefinition="Related Resource", formalDefinition="Related Resource to this DocumentManifest. For example, Order, DiagnosticOrder,  Procedure, EligibilityRequest, etc." )
198        protected Reference ref;
199
200        /**
201         * The actual object that is the target of the reference (Related Resource to this DocumentManifest. For example, Order, DiagnosticOrder,  Procedure, EligibilityRequest, etc.)
202         */
203        protected Resource refTarget;
204
205        private static final long serialVersionUID = -1670123330L;
206
207    /*
208     * Constructor
209     */
210      public DocumentManifestRelatedComponent() {
211        super();
212      }
213
214        /**
215         * @return {@link #identifier} (Related identifier to this DocumentManifest.  For example, Order numbers, accession numbers, XDW workflow numbers.)
216         */
217        public Identifier getIdentifier() { 
218          if (this.identifier == null)
219            if (Configuration.errorOnAutoCreate())
220              throw new Error("Attempt to auto-create DocumentManifestRelatedComponent.identifier");
221            else if (Configuration.doAutoCreate())
222              this.identifier = new Identifier(); // cc
223          return this.identifier;
224        }
225
226        public boolean hasIdentifier() { 
227          return this.identifier != null && !this.identifier.isEmpty();
228        }
229
230        /**
231         * @param value {@link #identifier} (Related identifier to this DocumentManifest.  For example, Order numbers, accession numbers, XDW workflow numbers.)
232         */
233        public DocumentManifestRelatedComponent setIdentifier(Identifier value) { 
234          this.identifier = value;
235          return this;
236        }
237
238        /**
239         * @return {@link #ref} (Related Resource to this DocumentManifest. For example, Order, DiagnosticOrder,  Procedure, EligibilityRequest, etc.)
240         */
241        public Reference getRef() { 
242          if (this.ref == null)
243            if (Configuration.errorOnAutoCreate())
244              throw new Error("Attempt to auto-create DocumentManifestRelatedComponent.ref");
245            else if (Configuration.doAutoCreate())
246              this.ref = new Reference(); // cc
247          return this.ref;
248        }
249
250        public boolean hasRef() { 
251          return this.ref != null && !this.ref.isEmpty();
252        }
253
254        /**
255         * @param value {@link #ref} (Related Resource to this DocumentManifest. For example, Order, DiagnosticOrder,  Procedure, EligibilityRequest, etc.)
256         */
257        public DocumentManifestRelatedComponent setRef(Reference value) { 
258          this.ref = value;
259          return this;
260        }
261
262        /**
263         * @return {@link #ref} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Related Resource to this DocumentManifest. For example, Order, DiagnosticOrder,  Procedure, EligibilityRequest, etc.)
264         */
265        public Resource getRefTarget() { 
266          return this.refTarget;
267        }
268
269        /**
270         * @param value {@link #ref} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Related Resource to this DocumentManifest. For example, Order, DiagnosticOrder,  Procedure, EligibilityRequest, etc.)
271         */
272        public DocumentManifestRelatedComponent setRefTarget(Resource value) { 
273          this.refTarget = value;
274          return this;
275        }
276
277        protected void listChildren(List<Property> childrenList) {
278          super.listChildren(childrenList);
279          childrenList.add(new Property("identifier", "Identifier", "Related identifier to this DocumentManifest.  For example, Order numbers, accession numbers, XDW workflow numbers.", 0, java.lang.Integer.MAX_VALUE, identifier));
280          childrenList.add(new Property("ref", "Reference(Any)", "Related Resource to this DocumentManifest. For example, Order, DiagnosticOrder,  Procedure, EligibilityRequest, etc.", 0, java.lang.Integer.MAX_VALUE, ref));
281        }
282
283      @Override
284      public void setProperty(String name, Base value) throws FHIRException {
285        if (name.equals("identifier"))
286          this.identifier = castToIdentifier(value); // Identifier
287        else if (name.equals("ref"))
288          this.ref = castToReference(value); // Reference
289        else
290          super.setProperty(name, value);
291      }
292
293      @Override
294      public Base addChild(String name) throws FHIRException {
295        if (name.equals("identifier")) {
296          this.identifier = new Identifier();
297          return this.identifier;
298        }
299        else if (name.equals("ref")) {
300          this.ref = new Reference();
301          return this.ref;
302        }
303        else
304          return super.addChild(name);
305      }
306
307      public DocumentManifestRelatedComponent copy() {
308        DocumentManifestRelatedComponent dst = new DocumentManifestRelatedComponent();
309        copyValues(dst);
310        dst.identifier = identifier == null ? null : identifier.copy();
311        dst.ref = ref == null ? null : ref.copy();
312        return dst;
313      }
314
315      @Override
316      public boolean equalsDeep(Base other) {
317        if (!super.equalsDeep(other))
318          return false;
319        if (!(other instanceof DocumentManifestRelatedComponent))
320          return false;
321        DocumentManifestRelatedComponent o = (DocumentManifestRelatedComponent) other;
322        return compareDeep(identifier, o.identifier, true) && compareDeep(ref, o.ref, true);
323      }
324
325      @Override
326      public boolean equalsShallow(Base other) {
327        if (!super.equalsShallow(other))
328          return false;
329        if (!(other instanceof DocumentManifestRelatedComponent))
330          return false;
331        DocumentManifestRelatedComponent o = (DocumentManifestRelatedComponent) other;
332        return true;
333      }
334
335      public boolean isEmpty() {
336        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (ref == null || ref.isEmpty())
337          ;
338      }
339
340  public String fhirType() {
341    return "DocumentManifest.related";
342
343  }
344
345  }
346
347    /**
348     * A single identifier that uniquely identifies this manifest. Principally used to refer to the manifest in non-FHIR contexts.
349     */
350    @Child(name = "masterIdentifier", type = {Identifier.class}, order=0, min=0, max=1, modifier=false, summary=true)
351    @Description(shortDefinition="Unique Identifier for the set of documents", formalDefinition="A single identifier that uniquely identifies this manifest. Principally used to refer to the manifest in non-FHIR contexts." )
352    protected Identifier masterIdentifier;
353
354    /**
355     * Other identifiers associated with the document manifest, including version independent  identifiers.
356     */
357    @Child(name = "identifier", type = {Identifier.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
358    @Description(shortDefinition="Other identifiers for the manifest", formalDefinition="Other identifiers associated with the document manifest, including version independent  identifiers." )
359    protected List<Identifier> identifier;
360
361    /**
362     * Who or what the set of documents is about. The documents can be about a person, (patient or healthcare practitioner), a device (i.e. 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). If the documents cross more than one subject, then more than one subject is allowed here (unusual use case).
363     */
364    @Child(name = "subject", type = {Patient.class, Practitioner.class, Group.class, Device.class}, order=2, min=0, max=1, modifier=false, summary=true)
365    @Description(shortDefinition="The subject of the set of documents", formalDefinition="Who or what the set of documents is about. The documents can be about a person, (patient or healthcare practitioner), a device (i.e. 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). If the documents cross more than one subject, then more than one subject is allowed here (unusual use case)." )
366    protected Reference subject;
367
368    /**
369     * The actual object that is the target of the reference (Who or what the set of documents is about. The documents can be about a person, (patient or healthcare practitioner), a device (i.e. 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). If the documents cross more than one subject, then more than one subject is allowed here (unusual use case).)
370     */
371    protected Resource subjectTarget;
372
373    /**
374     * A patient, practitioner, or organization for which this set of documents is intended.
375     */
376    @Child(name = "recipient", type = {Patient.class, Practitioner.class, RelatedPerson.class, Organization.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
377    @Description(shortDefinition="Intended to get notified about this set of documents", formalDefinition="A patient, practitioner, or organization for which this set of documents is intended." )
378    protected List<Reference> recipient;
379    /**
380     * The actual objects that are the target of the reference (A patient, practitioner, or organization for which this set of documents is intended.)
381     */
382    protected List<Resource> recipientTarget;
383
384
385    /**
386     * Specifies the kind of this set of documents (e.g. Patient Summary, Discharge Summary, Prescription, etc.). The type of a set of documents may be the same as one of the documents in it - especially if there is only one - but it may be wider.
387     */
388    @Child(name = "type", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=true)
389    @Description(shortDefinition="Kind of document set", formalDefinition="Specifies the kind of this set of documents (e.g. Patient Summary, Discharge Summary, Prescription, etc.). The type of a set of documents may be the same as one of the documents in it - especially if there is only one - but it may be wider." )
390    protected CodeableConcept type;
391
392    /**
393     * Identifies who is responsible for creating the manifest, and adding  documents to it.
394     */
395    @Child(name = "author", type = {Practitioner.class, Organization.class, Device.class, Patient.class, RelatedPerson.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
396    @Description(shortDefinition="Who and/or what authored the manifest", formalDefinition="Identifies who is responsible for creating the manifest, and adding  documents to it." )
397    protected List<Reference> author;
398    /**
399     * The actual objects that are the target of the reference (Identifies who is responsible for creating the manifest, and adding  documents to it.)
400     */
401    protected List<Resource> authorTarget;
402
403
404    /**
405     * When the document manifest was created for submission to the server (not necessarily the same thing as the actual resource last modified time, since it may be modified, replicated, etc.).
406     */
407    @Child(name = "created", type = {DateTimeType.class}, order=6, min=0, max=1, modifier=false, summary=true)
408    @Description(shortDefinition="When this document manifest created", formalDefinition="When the document manifest was created for submission to the server (not necessarily the same thing as the actual resource last modified time, since it may be modified, replicated, etc.)." )
409    protected DateTimeType created;
410
411    /**
412     * Identifies the source system, application, or software that produced the document manifest.
413     */
414    @Child(name = "source", type = {UriType.class}, order=7, min=0, max=1, modifier=false, summary=true)
415    @Description(shortDefinition="The source system/application/software", formalDefinition="Identifies the source system, application, or software that produced the document manifest." )
416    protected UriType source;
417
418    /**
419     * The status of this document manifest.
420     */
421    @Child(name = "status", type = {CodeType.class}, order=8, min=1, max=1, modifier=true, summary=true)
422    @Description(shortDefinition="current | superseded | entered-in-error", formalDefinition="The status of this document manifest." )
423    protected Enumeration<DocumentReferenceStatus> status;
424
425    /**
426     * Human-readable description of the source document. This is sometimes known as the "title".
427     */
428    @Child(name = "description", type = {StringType.class}, order=9, min=0, max=1, modifier=false, summary=true)
429    @Description(shortDefinition="Human-readable description (title)", formalDefinition="Human-readable description of the source document. This is sometimes known as the \"title\"." )
430    protected StringType description;
431
432    /**
433     * The list of Documents included in the manifest.
434     */
435    @Child(name = "content", type = {}, order=10, min=1, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
436    @Description(shortDefinition="The items included", formalDefinition="The list of Documents included in the manifest." )
437    protected List<DocumentManifestContentComponent> content;
438
439    /**
440     * Related identifiers or resources associated with the DocumentManifest.
441     */
442    @Child(name = "related", type = {}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
443    @Description(shortDefinition="Related things", formalDefinition="Related identifiers or resources associated with the DocumentManifest." )
444    protected List<DocumentManifestRelatedComponent> related;
445
446    private static final long serialVersionUID = -2056683927L;
447
448  /*
449   * Constructor
450   */
451    public DocumentManifest() {
452      super();
453    }
454
455  /*
456   * Constructor
457   */
458    public DocumentManifest(Enumeration<DocumentReferenceStatus> status) {
459      super();
460      this.status = status;
461    }
462
463    /**
464     * @return {@link #masterIdentifier} (A single identifier that uniquely identifies this manifest. Principally used to refer to the manifest in non-FHIR contexts.)
465     */
466    public Identifier getMasterIdentifier() { 
467      if (this.masterIdentifier == null)
468        if (Configuration.errorOnAutoCreate())
469          throw new Error("Attempt to auto-create DocumentManifest.masterIdentifier");
470        else if (Configuration.doAutoCreate())
471          this.masterIdentifier = new Identifier(); // cc
472      return this.masterIdentifier;
473    }
474
475    public boolean hasMasterIdentifier() { 
476      return this.masterIdentifier != null && !this.masterIdentifier.isEmpty();
477    }
478
479    /**
480     * @param value {@link #masterIdentifier} (A single identifier that uniquely identifies this manifest. Principally used to refer to the manifest in non-FHIR contexts.)
481     */
482    public DocumentManifest setMasterIdentifier(Identifier value) { 
483      this.masterIdentifier = value;
484      return this;
485    }
486
487    /**
488     * @return {@link #identifier} (Other identifiers associated with the document manifest, including version independent  identifiers.)
489     */
490    public List<Identifier> getIdentifier() { 
491      if (this.identifier == null)
492        this.identifier = new ArrayList<Identifier>();
493      return this.identifier;
494    }
495
496    public boolean hasIdentifier() { 
497      if (this.identifier == null)
498        return false;
499      for (Identifier item : this.identifier)
500        if (!item.isEmpty())
501          return true;
502      return false;
503    }
504
505    /**
506     * @return {@link #identifier} (Other identifiers associated with the document manifest, including version independent  identifiers.)
507     */
508    // syntactic sugar
509    public Identifier addIdentifier() { //3
510      Identifier t = new Identifier();
511      if (this.identifier == null)
512        this.identifier = new ArrayList<Identifier>();
513      this.identifier.add(t);
514      return t;
515    }
516
517    // syntactic sugar
518    public DocumentManifest addIdentifier(Identifier t) { //3
519      if (t == null)
520        return this;
521      if (this.identifier == null)
522        this.identifier = new ArrayList<Identifier>();
523      this.identifier.add(t);
524      return this;
525    }
526
527    /**
528     * @return {@link #subject} (Who or what the set of documents is about. The documents can be about a person, (patient or healthcare practitioner), a device (i.e. 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). If the documents cross more than one subject, then more than one subject is allowed here (unusual use case).)
529     */
530    public Reference getSubject() { 
531      if (this.subject == null)
532        if (Configuration.errorOnAutoCreate())
533          throw new Error("Attempt to auto-create DocumentManifest.subject");
534        else if (Configuration.doAutoCreate())
535          this.subject = new Reference(); // cc
536      return this.subject;
537    }
538
539    public boolean hasSubject() { 
540      return this.subject != null && !this.subject.isEmpty();
541    }
542
543    /**
544     * @param value {@link #subject} (Who or what the set of documents is about. The documents can be about a person, (patient or healthcare practitioner), a device (i.e. 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). If the documents cross more than one subject, then more than one subject is allowed here (unusual use case).)
545     */
546    public DocumentManifest setSubject(Reference value) { 
547      this.subject = value;
548      return this;
549    }
550
551    /**
552     * @return {@link #subject} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Who or what the set of documents is about. The documents can be about a person, (patient or healthcare practitioner), a device (i.e. 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). If the documents cross more than one subject, then more than one subject is allowed here (unusual use case).)
553     */
554    public Resource getSubjectTarget() { 
555      return this.subjectTarget;
556    }
557
558    /**
559     * @param value {@link #subject} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Who or what the set of documents is about. The documents can be about a person, (patient or healthcare practitioner), a device (i.e. 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). If the documents cross more than one subject, then more than one subject is allowed here (unusual use case).)
560     */
561    public DocumentManifest setSubjectTarget(Resource value) { 
562      this.subjectTarget = value;
563      return this;
564    }
565
566    /**
567     * @return {@link #recipient} (A patient, practitioner, or organization for which this set of documents is intended.)
568     */
569    public List<Reference> getRecipient() { 
570      if (this.recipient == null)
571        this.recipient = new ArrayList<Reference>();
572      return this.recipient;
573    }
574
575    public boolean hasRecipient() { 
576      if (this.recipient == null)
577        return false;
578      for (Reference item : this.recipient)
579        if (!item.isEmpty())
580          return true;
581      return false;
582    }
583
584    /**
585     * @return {@link #recipient} (A patient, practitioner, or organization for which this set of documents is intended.)
586     */
587    // syntactic sugar
588    public Reference addRecipient() { //3
589      Reference t = new Reference();
590      if (this.recipient == null)
591        this.recipient = new ArrayList<Reference>();
592      this.recipient.add(t);
593      return t;
594    }
595
596    // syntactic sugar
597    public DocumentManifest addRecipient(Reference t) { //3
598      if (t == null)
599        return this;
600      if (this.recipient == null)
601        this.recipient = new ArrayList<Reference>();
602      this.recipient.add(t);
603      return this;
604    }
605
606    /**
607     * @return {@link #recipient} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. A patient, practitioner, or organization for which this set of documents is intended.)
608     */
609    public List<Resource> getRecipientTarget() { 
610      if (this.recipientTarget == null)
611        this.recipientTarget = new ArrayList<Resource>();
612      return this.recipientTarget;
613    }
614
615    /**
616     * @return {@link #type} (Specifies the kind of this set of documents (e.g. Patient Summary, Discharge Summary, Prescription, etc.). The type of a set of documents may be the same as one of the documents in it - especially if there is only one - but it may be wider.)
617     */
618    public CodeableConcept getType() { 
619      if (this.type == null)
620        if (Configuration.errorOnAutoCreate())
621          throw new Error("Attempt to auto-create DocumentManifest.type");
622        else if (Configuration.doAutoCreate())
623          this.type = new CodeableConcept(); // cc
624      return this.type;
625    }
626
627    public boolean hasType() { 
628      return this.type != null && !this.type.isEmpty();
629    }
630
631    /**
632     * @param value {@link #type} (Specifies the kind of this set of documents (e.g. Patient Summary, Discharge Summary, Prescription, etc.). The type of a set of documents may be the same as one of the documents in it - especially if there is only one - but it may be wider.)
633     */
634    public DocumentManifest setType(CodeableConcept value) { 
635      this.type = value;
636      return this;
637    }
638
639    /**
640     * @return {@link #author} (Identifies who is responsible for creating the manifest, and adding  documents to it.)
641     */
642    public List<Reference> getAuthor() { 
643      if (this.author == null)
644        this.author = new ArrayList<Reference>();
645      return this.author;
646    }
647
648    public boolean hasAuthor() { 
649      if (this.author == null)
650        return false;
651      for (Reference item : this.author)
652        if (!item.isEmpty())
653          return true;
654      return false;
655    }
656
657    /**
658     * @return {@link #author} (Identifies who is responsible for creating the manifest, and adding  documents to it.)
659     */
660    // syntactic sugar
661    public Reference addAuthor() { //3
662      Reference t = new Reference();
663      if (this.author == null)
664        this.author = new ArrayList<Reference>();
665      this.author.add(t);
666      return t;
667    }
668
669    // syntactic sugar
670    public DocumentManifest addAuthor(Reference t) { //3
671      if (t == null)
672        return this;
673      if (this.author == null)
674        this.author = new ArrayList<Reference>();
675      this.author.add(t);
676      return this;
677    }
678
679    /**
680     * @return {@link #author} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. Identifies who is responsible for creating the manifest, and adding  documents to it.)
681     */
682    public List<Resource> getAuthorTarget() { 
683      if (this.authorTarget == null)
684        this.authorTarget = new ArrayList<Resource>();
685      return this.authorTarget;
686    }
687
688    /**
689     * @return {@link #created} (When the document manifest was created for submission to the server (not necessarily the same thing as the actual resource last modified time, since it may be modified, replicated, etc.).). This is the underlying object with id, value and extensions. The accessor "getCreated" gives direct access to the value
690     */
691    public DateTimeType getCreatedElement() { 
692      if (this.created == null)
693        if (Configuration.errorOnAutoCreate())
694          throw new Error("Attempt to auto-create DocumentManifest.created");
695        else if (Configuration.doAutoCreate())
696          this.created = new DateTimeType(); // bb
697      return this.created;
698    }
699
700    public boolean hasCreatedElement() { 
701      return this.created != null && !this.created.isEmpty();
702    }
703
704    public boolean hasCreated() { 
705      return this.created != null && !this.created.isEmpty();
706    }
707
708    /**
709     * @param value {@link #created} (When the document manifest was created for submission to the server (not necessarily the same thing as the actual resource last modified time, since it may be modified, replicated, etc.).). This is the underlying object with id, value and extensions. The accessor "getCreated" gives direct access to the value
710     */
711    public DocumentManifest setCreatedElement(DateTimeType value) { 
712      this.created = value;
713      return this;
714    }
715
716    /**
717     * @return When the document manifest was created for submission to the server (not necessarily the same thing as the actual resource last modified time, since it may be modified, replicated, etc.).
718     */
719    public Date getCreated() { 
720      return this.created == null ? null : this.created.getValue();
721    }
722
723    /**
724     * @param value When the document manifest was created for submission to the server (not necessarily the same thing as the actual resource last modified time, since it may be modified, replicated, etc.).
725     */
726    public DocumentManifest setCreated(Date value) { 
727      if (value == null)
728        this.created = null;
729      else {
730        if (this.created == null)
731          this.created = new DateTimeType();
732        this.created.setValue(value);
733      }
734      return this;
735    }
736
737    /**
738     * @return {@link #source} (Identifies the source system, application, or software that produced the document manifest.). This is the underlying object with id, value and extensions. The accessor "getSource" gives direct access to the value
739     */
740    public UriType getSourceElement() { 
741      if (this.source == null)
742        if (Configuration.errorOnAutoCreate())
743          throw new Error("Attempt to auto-create DocumentManifest.source");
744        else if (Configuration.doAutoCreate())
745          this.source = new UriType(); // bb
746      return this.source;
747    }
748
749    public boolean hasSourceElement() { 
750      return this.source != null && !this.source.isEmpty();
751    }
752
753    public boolean hasSource() { 
754      return this.source != null && !this.source.isEmpty();
755    }
756
757    /**
758     * @param value {@link #source} (Identifies the source system, application, or software that produced the document manifest.). This is the underlying object with id, value and extensions. The accessor "getSource" gives direct access to the value
759     */
760    public DocumentManifest setSourceElement(UriType value) { 
761      this.source = value;
762      return this;
763    }
764
765    /**
766     * @return Identifies the source system, application, or software that produced the document manifest.
767     */
768    public String getSource() { 
769      return this.source == null ? null : this.source.getValue();
770    }
771
772    /**
773     * @param value Identifies the source system, application, or software that produced the document manifest.
774     */
775    public DocumentManifest setSource(String value) { 
776      if (Utilities.noString(value))
777        this.source = null;
778      else {
779        if (this.source == null)
780          this.source = new UriType();
781        this.source.setValue(value);
782      }
783      return this;
784    }
785
786    /**
787     * @return {@link #status} (The status of this document manifest.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
788     */
789    public Enumeration<DocumentReferenceStatus> getStatusElement() { 
790      if (this.status == null)
791        if (Configuration.errorOnAutoCreate())
792          throw new Error("Attempt to auto-create DocumentManifest.status");
793        else if (Configuration.doAutoCreate())
794          this.status = new Enumeration<DocumentReferenceStatus>(new DocumentReferenceStatusEnumFactory()); // bb
795      return this.status;
796    }
797
798    public boolean hasStatusElement() { 
799      return this.status != null && !this.status.isEmpty();
800    }
801
802    public boolean hasStatus() { 
803      return this.status != null && !this.status.isEmpty();
804    }
805
806    /**
807     * @param value {@link #status} (The status of this document manifest.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
808     */
809    public DocumentManifest setStatusElement(Enumeration<DocumentReferenceStatus> value) { 
810      this.status = value;
811      return this;
812    }
813
814    /**
815     * @return The status of this document manifest.
816     */
817    public DocumentReferenceStatus getStatus() { 
818      return this.status == null ? null : this.status.getValue();
819    }
820
821    /**
822     * @param value The status of this document manifest.
823     */
824    public DocumentManifest setStatus(DocumentReferenceStatus value) { 
825        if (this.status == null)
826          this.status = new Enumeration<DocumentReferenceStatus>(new DocumentReferenceStatusEnumFactory());
827        this.status.setValue(value);
828      return this;
829    }
830
831    /**
832     * @return {@link #description} (Human-readable description of the source document. This is sometimes known as the "title".). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
833     */
834    public StringType getDescriptionElement() { 
835      if (this.description == null)
836        if (Configuration.errorOnAutoCreate())
837          throw new Error("Attempt to auto-create DocumentManifest.description");
838        else if (Configuration.doAutoCreate())
839          this.description = new StringType(); // bb
840      return this.description;
841    }
842
843    public boolean hasDescriptionElement() { 
844      return this.description != null && !this.description.isEmpty();
845    }
846
847    public boolean hasDescription() { 
848      return this.description != null && !this.description.isEmpty();
849    }
850
851    /**
852     * @param value {@link #description} (Human-readable description of the source document. This is sometimes known as the "title".). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
853     */
854    public DocumentManifest setDescriptionElement(StringType value) { 
855      this.description = value;
856      return this;
857    }
858
859    /**
860     * @return Human-readable description of the source document. This is sometimes known as the "title".
861     */
862    public String getDescription() { 
863      return this.description == null ? null : this.description.getValue();
864    }
865
866    /**
867     * @param value Human-readable description of the source document. This is sometimes known as the "title".
868     */
869    public DocumentManifest setDescription(String value) { 
870      if (Utilities.noString(value))
871        this.description = null;
872      else {
873        if (this.description == null)
874          this.description = new StringType();
875        this.description.setValue(value);
876      }
877      return this;
878    }
879
880    /**
881     * @return {@link #content} (The list of Documents included in the manifest.)
882     */
883    public List<DocumentManifestContentComponent> getContent() { 
884      if (this.content == null)
885        this.content = new ArrayList<DocumentManifestContentComponent>();
886      return this.content;
887    }
888
889    public boolean hasContent() { 
890      if (this.content == null)
891        return false;
892      for (DocumentManifestContentComponent item : this.content)
893        if (!item.isEmpty())
894          return true;
895      return false;
896    }
897
898    /**
899     * @return {@link #content} (The list of Documents included in the manifest.)
900     */
901    // syntactic sugar
902    public DocumentManifestContentComponent addContent() { //3
903      DocumentManifestContentComponent t = new DocumentManifestContentComponent();
904      if (this.content == null)
905        this.content = new ArrayList<DocumentManifestContentComponent>();
906      this.content.add(t);
907      return t;
908    }
909
910    // syntactic sugar
911    public DocumentManifest addContent(DocumentManifestContentComponent t) { //3
912      if (t == null)
913        return this;
914      if (this.content == null)
915        this.content = new ArrayList<DocumentManifestContentComponent>();
916      this.content.add(t);
917      return this;
918    }
919
920    /**
921     * @return {@link #related} (Related identifiers or resources associated with the DocumentManifest.)
922     */
923    public List<DocumentManifestRelatedComponent> getRelated() { 
924      if (this.related == null)
925        this.related = new ArrayList<DocumentManifestRelatedComponent>();
926      return this.related;
927    }
928
929    public boolean hasRelated() { 
930      if (this.related == null)
931        return false;
932      for (DocumentManifestRelatedComponent item : this.related)
933        if (!item.isEmpty())
934          return true;
935      return false;
936    }
937
938    /**
939     * @return {@link #related} (Related identifiers or resources associated with the DocumentManifest.)
940     */
941    // syntactic sugar
942    public DocumentManifestRelatedComponent addRelated() { //3
943      DocumentManifestRelatedComponent t = new DocumentManifestRelatedComponent();
944      if (this.related == null)
945        this.related = new ArrayList<DocumentManifestRelatedComponent>();
946      this.related.add(t);
947      return t;
948    }
949
950    // syntactic sugar
951    public DocumentManifest addRelated(DocumentManifestRelatedComponent t) { //3
952      if (t == null)
953        return this;
954      if (this.related == null)
955        this.related = new ArrayList<DocumentManifestRelatedComponent>();
956      this.related.add(t);
957      return this;
958    }
959
960      protected void listChildren(List<Property> childrenList) {
961        super.listChildren(childrenList);
962        childrenList.add(new Property("masterIdentifier", "Identifier", "A single identifier that uniquely identifies this manifest. Principally used to refer to the manifest in non-FHIR contexts.", 0, java.lang.Integer.MAX_VALUE, masterIdentifier));
963        childrenList.add(new Property("identifier", "Identifier", "Other identifiers associated with the document manifest, including version independent  identifiers.", 0, java.lang.Integer.MAX_VALUE, identifier));
964        childrenList.add(new Property("subject", "Reference(Patient|Practitioner|Group|Device)", "Who or what the set of documents is about. The documents can be about a person, (patient or healthcare practitioner), a device (i.e. 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). If the documents cross more than one subject, then more than one subject is allowed here (unusual use case).", 0, java.lang.Integer.MAX_VALUE, subject));
965        childrenList.add(new Property("recipient", "Reference(Patient|Practitioner|RelatedPerson|Organization)", "A patient, practitioner, or organization for which this set of documents is intended.", 0, java.lang.Integer.MAX_VALUE, recipient));
966        childrenList.add(new Property("type", "CodeableConcept", "Specifies the kind of this set of documents (e.g. Patient Summary, Discharge Summary, Prescription, etc.). The type of a set of documents may be the same as one of the documents in it - especially if there is only one - but it may be wider.", 0, java.lang.Integer.MAX_VALUE, type));
967        childrenList.add(new Property("author", "Reference(Practitioner|Organization|Device|Patient|RelatedPerson)", "Identifies who is responsible for creating the manifest, and adding  documents to it.", 0, java.lang.Integer.MAX_VALUE, author));
968        childrenList.add(new Property("created", "dateTime", "When the document manifest was created for submission to the server (not necessarily the same thing as the actual resource last modified time, since it may be modified, replicated, etc.).", 0, java.lang.Integer.MAX_VALUE, created));
969        childrenList.add(new Property("source", "uri", "Identifies the source system, application, or software that produced the document manifest.", 0, java.lang.Integer.MAX_VALUE, source));
970        childrenList.add(new Property("status", "code", "The status of this document manifest.", 0, java.lang.Integer.MAX_VALUE, status));
971        childrenList.add(new Property("description", "string", "Human-readable description of the source document. This is sometimes known as the \"title\".", 0, java.lang.Integer.MAX_VALUE, description));
972        childrenList.add(new Property("content", "", "The list of Documents included in the manifest.", 0, java.lang.Integer.MAX_VALUE, content));
973        childrenList.add(new Property("related", "", "Related identifiers or resources associated with the DocumentManifest.", 0, java.lang.Integer.MAX_VALUE, related));
974      }
975
976      @Override
977      public void setProperty(String name, Base value) throws FHIRException {
978        if (name.equals("masterIdentifier"))
979          this.masterIdentifier = castToIdentifier(value); // Identifier
980        else if (name.equals("identifier"))
981          this.getIdentifier().add(castToIdentifier(value));
982        else if (name.equals("subject"))
983          this.subject = castToReference(value); // Reference
984        else if (name.equals("recipient"))
985          this.getRecipient().add(castToReference(value));
986        else if (name.equals("type"))
987          this.type = castToCodeableConcept(value); // CodeableConcept
988        else if (name.equals("author"))
989          this.getAuthor().add(castToReference(value));
990        else if (name.equals("created"))
991          this.created = castToDateTime(value); // DateTimeType
992        else if (name.equals("source"))
993          this.source = castToUri(value); // UriType
994        else if (name.equals("status"))
995          this.status = new DocumentReferenceStatusEnumFactory().fromType(value); // Enumeration<DocumentReferenceStatus>
996        else if (name.equals("description"))
997          this.description = castToString(value); // StringType
998        else if (name.equals("content"))
999          this.getContent().add((DocumentManifestContentComponent) value);
1000        else if (name.equals("related"))
1001          this.getRelated().add((DocumentManifestRelatedComponent) value);
1002        else
1003          super.setProperty(name, value);
1004      }
1005
1006      @Override
1007      public Base addChild(String name) throws FHIRException {
1008        if (name.equals("masterIdentifier")) {
1009          this.masterIdentifier = new Identifier();
1010          return this.masterIdentifier;
1011        }
1012        else if (name.equals("identifier")) {
1013          return addIdentifier();
1014        }
1015        else if (name.equals("subject")) {
1016          this.subject = new Reference();
1017          return this.subject;
1018        }
1019        else if (name.equals("recipient")) {
1020          return addRecipient();
1021        }
1022        else if (name.equals("type")) {
1023          this.type = new CodeableConcept();
1024          return this.type;
1025        }
1026        else if (name.equals("author")) {
1027          return addAuthor();
1028        }
1029        else if (name.equals("created")) {
1030          throw new FHIRException("Cannot call addChild on a primitive type DocumentManifest.created");
1031        }
1032        else if (name.equals("source")) {
1033          throw new FHIRException("Cannot call addChild on a primitive type DocumentManifest.source");
1034        }
1035        else if (name.equals("status")) {
1036          throw new FHIRException("Cannot call addChild on a primitive type DocumentManifest.status");
1037        }
1038        else if (name.equals("description")) {
1039          throw new FHIRException("Cannot call addChild on a primitive type DocumentManifest.description");
1040        }
1041        else if (name.equals("content")) {
1042          return addContent();
1043        }
1044        else if (name.equals("related")) {
1045          return addRelated();
1046        }
1047        else
1048          return super.addChild(name);
1049      }
1050
1051  public String fhirType() {
1052    return "DocumentManifest";
1053
1054  }
1055
1056      public DocumentManifest copy() {
1057        DocumentManifest dst = new DocumentManifest();
1058        copyValues(dst);
1059        dst.masterIdentifier = masterIdentifier == null ? null : masterIdentifier.copy();
1060        if (identifier != null) {
1061          dst.identifier = new ArrayList<Identifier>();
1062          for (Identifier i : identifier)
1063            dst.identifier.add(i.copy());
1064        };
1065        dst.subject = subject == null ? null : subject.copy();
1066        if (recipient != null) {
1067          dst.recipient = new ArrayList<Reference>();
1068          for (Reference i : recipient)
1069            dst.recipient.add(i.copy());
1070        };
1071        dst.type = type == null ? null : type.copy();
1072        if (author != null) {
1073          dst.author = new ArrayList<Reference>();
1074          for (Reference i : author)
1075            dst.author.add(i.copy());
1076        };
1077        dst.created = created == null ? null : created.copy();
1078        dst.source = source == null ? null : source.copy();
1079        dst.status = status == null ? null : status.copy();
1080        dst.description = description == null ? null : description.copy();
1081        if (content != null) {
1082          dst.content = new ArrayList<DocumentManifestContentComponent>();
1083          for (DocumentManifestContentComponent i : content)
1084            dst.content.add(i.copy());
1085        };
1086        if (related != null) {
1087          dst.related = new ArrayList<DocumentManifestRelatedComponent>();
1088          for (DocumentManifestRelatedComponent i : related)
1089            dst.related.add(i.copy());
1090        };
1091        return dst;
1092      }
1093
1094      protected DocumentManifest typedCopy() {
1095        return copy();
1096      }
1097
1098      @Override
1099      public boolean equalsDeep(Base other) {
1100        if (!super.equalsDeep(other))
1101          return false;
1102        if (!(other instanceof DocumentManifest))
1103          return false;
1104        DocumentManifest o = (DocumentManifest) other;
1105        return compareDeep(masterIdentifier, o.masterIdentifier, true) && compareDeep(identifier, o.identifier, true)
1106           && compareDeep(subject, o.subject, true) && compareDeep(recipient, o.recipient, true) && compareDeep(type, o.type, true)
1107           && compareDeep(author, o.author, true) && compareDeep(created, o.created, true) && compareDeep(source, o.source, true)
1108           && compareDeep(status, o.status, true) && compareDeep(description, o.description, true) && compareDeep(content, o.content, true)
1109           && compareDeep(related, o.related, true);
1110      }
1111
1112      @Override
1113      public boolean equalsShallow(Base other) {
1114        if (!super.equalsShallow(other))
1115          return false;
1116        if (!(other instanceof DocumentManifest))
1117          return false;
1118        DocumentManifest o = (DocumentManifest) other;
1119        return compareValues(created, o.created, true) && compareValues(source, o.source, true) && compareValues(status, o.status, true)
1120           && compareValues(description, o.description, true);
1121      }
1122
1123      public boolean isEmpty() {
1124        return super.isEmpty() && (masterIdentifier == null || masterIdentifier.isEmpty()) && (identifier == null || identifier.isEmpty())
1125           && (subject == null || subject.isEmpty()) && (recipient == null || recipient.isEmpty()) && (type == null || type.isEmpty())
1126           && (author == null || author.isEmpty()) && (created == null || created.isEmpty()) && (source == null || source.isEmpty())
1127           && (status == null || status.isEmpty()) && (description == null || description.isEmpty())
1128           && (content == null || content.isEmpty()) && (related == null || related.isEmpty());
1129      }
1130
1131  @Override
1132  public ResourceType getResourceType() {
1133    return ResourceType.DocumentManifest;
1134   }
1135
1136  @SearchParamDefinition(name="identifier", path="DocumentManifest.masterIdentifier | DocumentManifest.identifier", description="Unique Identifier for the set of documents", type="token" )
1137  public static final String SP_IDENTIFIER = "identifier";
1138  @SearchParamDefinition(name="related-id", path="DocumentManifest.related.identifier", description="Identifiers of things that are related", type="token" )
1139  public static final String SP_RELATEDID = "related-id";
1140  @SearchParamDefinition(name="content-ref", path="DocumentManifest.content.pReference", description="Contents of this set of documents", type="reference" )
1141  public static final String SP_CONTENTREF = "content-ref";
1142  @SearchParamDefinition(name="subject", path="DocumentManifest.subject", description="The subject of the set of documents", type="reference" )
1143  public static final String SP_SUBJECT = "subject";
1144  @SearchParamDefinition(name="author", path="DocumentManifest.author", description="Who and/or what authored the manifest", type="reference" )
1145  public static final String SP_AUTHOR = "author";
1146  @SearchParamDefinition(name="created", path="DocumentManifest.created", description="When this document manifest created", type="date" )
1147  public static final String SP_CREATED = "created";
1148  @SearchParamDefinition(name="description", path="DocumentManifest.description", description="Human-readable description (title)", type="string" )
1149  public static final String SP_DESCRIPTION = "description";
1150  @SearchParamDefinition(name="source", path="DocumentManifest.source", description="The source system/application/software", type="uri" )
1151  public static final String SP_SOURCE = "source";
1152  @SearchParamDefinition(name="type", path="DocumentManifest.type", description="Kind of document set", type="token" )
1153  public static final String SP_TYPE = "type";
1154  @SearchParamDefinition(name="related-ref", path="DocumentManifest.related.ref", description="Related Resource", type="reference" )
1155  public static final String SP_RELATEDREF = "related-ref";
1156  @SearchParamDefinition(name="patient", path="DocumentManifest.subject", description="The subject of the set of documents", type="reference" )
1157  public static final String SP_PATIENT = "patient";
1158  @SearchParamDefinition(name="recipient", path="DocumentManifest.recipient", description="Intended to get notified about this set of documents", type="reference" )
1159  public static final String SP_RECIPIENT = "recipient";
1160  @SearchParamDefinition(name="status", path="DocumentManifest.status", description="current | superseded | entered-in-error", type="token" )
1161  public static final String SP_STATUS = "status";
1162
1163}
1164