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;
056
057import org.hl7.fhir.exceptions.FHIRException;
058import org.hl7.fhir.instance.model.api.ICompositeType;
059
060import java.math.*;
061import org.hl7.fhir.instance.model.api.IBaseDatatypeElement;
062import org.hl7.fhir.utilities.Utilities;
063import org.hl7.fhir.r5.model.Enumerations.*;
064import ca.uhn.fhir.model.api.annotation.Child;
065import ca.uhn.fhir.model.api.annotation.ChildOrder;
066import ca.uhn.fhir.model.api.annotation.DatatypeDef;
067import ca.uhn.fhir.model.api.annotation.Description;
068import ca.uhn.fhir.model.api.annotation.Block;
069/**
070 * For referring to data content defined in other formats.
071 */
072@DatatypeDef(name="Attachment")
073public class Attachment extends Type implements ICompositeType {
074
075    /**
076     * Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate.
077     */
078    @Child(name = "contentType", type = {CodeType.class}, order=0, min=0, max=1, modifier=false, summary=true)
079    @Description(shortDefinition="Mime type of the content, with charset etc.", formalDefinition="Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate." )
080    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/mimetypes")
081    protected CodeType contentType;
082
083    /**
084     * The human language of the content. The value can be any valid value according to BCP 47.
085     */
086    @Child(name = "language", type = {CodeType.class}, order=1, min=0, max=1, modifier=false, summary=true)
087    @Description(shortDefinition="Human language of the content (BCP-47)", formalDefinition="The human language of the content. The value can be any valid value according to BCP 47." )
088    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/languages")
089    protected CodeType language;
090
091    /**
092     * The actual data of the attachment - a sequence of bytes, base64 encoded.
093     */
094    @Child(name = "data", type = {Base64BinaryType.class}, order=2, min=0, max=1, modifier=false, summary=false)
095    @Description(shortDefinition="Data inline, base64ed", formalDefinition="The actual data of the attachment - a sequence of bytes, base64 encoded." )
096    protected Base64BinaryType data;
097
098    /**
099     * A location where the data can be accessed.
100     */
101    @Child(name = "url", type = {UrlType.class}, order=3, min=0, max=1, modifier=false, summary=true)
102    @Description(shortDefinition="Uri where the data can be found", formalDefinition="A location where the data can be accessed." )
103    protected UrlType url;
104
105    /**
106     * The number of bytes of data that make up this attachment (before base64 encoding, if that is done).
107     */
108    @Child(name = "size", type = {UnsignedIntType.class}, order=4, min=0, max=1, modifier=false, summary=true)
109    @Description(shortDefinition="Number of bytes of content (if url provided)", formalDefinition="The number of bytes of data that make up this attachment (before base64 encoding, if that is done)." )
110    protected UnsignedIntType size;
111
112    /**
113     * The calculated hash of the data using SHA-1. Represented using base64.
114     */
115    @Child(name = "hash", type = {Base64BinaryType.class}, order=5, min=0, max=1, modifier=false, summary=true)
116    @Description(shortDefinition="Hash of the data (sha-1, base64ed)", formalDefinition="The calculated hash of the data using SHA-1. Represented using base64." )
117    protected Base64BinaryType hash;
118
119    /**
120     * A label or set of text to display in place of the data.
121     */
122    @Child(name = "title", type = {StringType.class}, order=6, min=0, max=1, modifier=false, summary=true)
123    @Description(shortDefinition="Label to display in place of the data", formalDefinition="A label or set of text to display in place of the data." )
124    protected StringType title;
125
126    /**
127     * The date that the attachment was first created.
128     */
129    @Child(name = "creation", type = {DateTimeType.class}, order=7, min=0, max=1, modifier=false, summary=true)
130    @Description(shortDefinition="Date attachment was first created", formalDefinition="The date that the attachment was first created." )
131    protected DateTimeType creation;
132
133    /**
134     * Height of the image in pixels (photo/video).
135     */
136    @Child(name = "height", type = {PositiveIntType.class}, order=8, min=0, max=1, modifier=false, summary=false)
137    @Description(shortDefinition="Height of the image in pixels (photo/video)", formalDefinition="Height of the image in pixels (photo/video)." )
138    protected PositiveIntType height;
139
140    /**
141     * Width of the image in pixels (photo/video).
142     */
143    @Child(name = "width", type = {PositiveIntType.class}, order=9, min=0, max=1, modifier=false, summary=false)
144    @Description(shortDefinition="Width of the image in pixels (photo/video)", formalDefinition="Width of the image in pixels (photo/video)." )
145    protected PositiveIntType width;
146
147    /**
148     * The number of frames in a photo. This is used with a multi-page fax, or an imaging acquisition context that takes multiple slices in a single image, or an animated gif. If there is more than one frame, this SHALL have a value in order to alert interface software that a multi-frame capable rendering widget is required.
149     */
150    @Child(name = "frames", type = {PositiveIntType.class}, order=10, min=0, max=1, modifier=false, summary=false)
151    @Description(shortDefinition="Number of frames if > 1 (photo)", formalDefinition="The number of frames in a photo. This is used with a multi-page fax, or an imaging acquisition context that takes multiple slices in a single image, or an animated gif. If there is more than one frame, this SHALL have a value in order to alert interface software that a multi-frame capable rendering widget is required." )
152    protected PositiveIntType frames;
153
154    /**
155     * The duration of the recording in seconds - for audio and video.
156     */
157    @Child(name = "duration", type = {DecimalType.class}, order=11, min=0, max=1, modifier=false, summary=false)
158    @Description(shortDefinition="Length in seconds (audio / video)", formalDefinition="The duration of the recording in seconds - for audio and video." )
159    protected DecimalType duration;
160
161    /**
162     * The number of pages when printed.
163     */
164    @Child(name = "pages", type = {PositiveIntType.class}, order=12, min=0, max=1, modifier=false, summary=false)
165    @Description(shortDefinition="Number of printed pages", formalDefinition="The number of pages when printed." )
166    protected PositiveIntType pages;
167
168    private static final long serialVersionUID = -738137631L;
169
170  /**
171   * Constructor
172   */
173    public Attachment() {
174      super();
175    }
176
177    /**
178     * @return {@link #contentType} (Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate.). This is the underlying object with id, value and extensions. The accessor "getContentType" gives direct access to the value
179     */
180    public CodeType getContentTypeElement() { 
181      if (this.contentType == null)
182        if (Configuration.errorOnAutoCreate())
183          throw new Error("Attempt to auto-create Attachment.contentType");
184        else if (Configuration.doAutoCreate())
185          this.contentType = new CodeType(); // bb
186      return this.contentType;
187    }
188
189    public boolean hasContentTypeElement() { 
190      return this.contentType != null && !this.contentType.isEmpty();
191    }
192
193    public boolean hasContentType() { 
194      return this.contentType != null && !this.contentType.isEmpty();
195    }
196
197    /**
198     * @param value {@link #contentType} (Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate.). This is the underlying object with id, value and extensions. The accessor "getContentType" gives direct access to the value
199     */
200    public Attachment setContentTypeElement(CodeType value) { 
201      this.contentType = value;
202      return this;
203    }
204
205    /**
206     * @return Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate.
207     */
208    public String getContentType() { 
209      return this.contentType == null ? null : this.contentType.getValue();
210    }
211
212    /**
213     * @param value Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate.
214     */
215    public Attachment setContentType(String value) { 
216      if (Utilities.noString(value))
217        this.contentType = null;
218      else {
219        if (this.contentType == null)
220          this.contentType = new CodeType();
221        this.contentType.setValue(value);
222      }
223      return this;
224    }
225
226    /**
227     * @return {@link #language} (The human language of the content. The value can be any valid value according to BCP 47.). This is the underlying object with id, value and extensions. The accessor "getLanguage" gives direct access to the value
228     */
229    public CodeType getLanguageElement() { 
230      if (this.language == null)
231        if (Configuration.errorOnAutoCreate())
232          throw new Error("Attempt to auto-create Attachment.language");
233        else if (Configuration.doAutoCreate())
234          this.language = new CodeType(); // bb
235      return this.language;
236    }
237
238    public boolean hasLanguageElement() { 
239      return this.language != null && !this.language.isEmpty();
240    }
241
242    public boolean hasLanguage() { 
243      return this.language != null && !this.language.isEmpty();
244    }
245
246    /**
247     * @param value {@link #language} (The human language of the content. The value can be any valid value according to BCP 47.). This is the underlying object with id, value and extensions. The accessor "getLanguage" gives direct access to the value
248     */
249    public Attachment setLanguageElement(CodeType value) { 
250      this.language = value;
251      return this;
252    }
253
254    /**
255     * @return The human language of the content. The value can be any valid value according to BCP 47.
256     */
257    public String getLanguage() { 
258      return this.language == null ? null : this.language.getValue();
259    }
260
261    /**
262     * @param value The human language of the content. The value can be any valid value according to BCP 47.
263     */
264    public Attachment setLanguage(String value) { 
265      if (Utilities.noString(value))
266        this.language = null;
267      else {
268        if (this.language == null)
269          this.language = new CodeType();
270        this.language.setValue(value);
271      }
272      return this;
273    }
274
275    /**
276     * @return {@link #data} (The actual data of the attachment - a sequence of bytes, base64 encoded.). This is the underlying object with id, value and extensions. The accessor "getData" gives direct access to the value
277     */
278    public Base64BinaryType getDataElement() { 
279      if (this.data == null)
280        if (Configuration.errorOnAutoCreate())
281          throw new Error("Attempt to auto-create Attachment.data");
282        else if (Configuration.doAutoCreate())
283          this.data = new Base64BinaryType(); // bb
284      return this.data;
285    }
286
287    public boolean hasDataElement() { 
288      return this.data != null && !this.data.isEmpty();
289    }
290
291    public boolean hasData() { 
292      return this.data != null && !this.data.isEmpty();
293    }
294
295    /**
296     * @param value {@link #data} (The actual data of the attachment - a sequence of bytes, base64 encoded.). This is the underlying object with id, value and extensions. The accessor "getData" gives direct access to the value
297     */
298    public Attachment setDataElement(Base64BinaryType value) { 
299      this.data = value;
300      return this;
301    }
302
303    /**
304     * @return The actual data of the attachment - a sequence of bytes, base64 encoded.
305     */
306    public byte[] getData() { 
307      return this.data == null ? null : this.data.getValue();
308    }
309
310    /**
311     * @param value The actual data of the attachment - a sequence of bytes, base64 encoded.
312     */
313    public Attachment setData(byte[] value) { 
314      if (value == null)
315        this.data = null;
316      else {
317        if (this.data == null)
318          this.data = new Base64BinaryType();
319        this.data.setValue(value);
320      }
321      return this;
322    }
323
324    /**
325     * @return {@link #url} (A location where the data can be accessed.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value
326     */
327    public UrlType getUrlElement() { 
328      if (this.url == null)
329        if (Configuration.errorOnAutoCreate())
330          throw new Error("Attempt to auto-create Attachment.url");
331        else if (Configuration.doAutoCreate())
332          this.url = new UrlType(); // bb
333      return this.url;
334    }
335
336    public boolean hasUrlElement() { 
337      return this.url != null && !this.url.isEmpty();
338    }
339
340    public boolean hasUrl() { 
341      return this.url != null && !this.url.isEmpty();
342    }
343
344    /**
345     * @param value {@link #url} (A location where the data can be accessed.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value
346     */
347    public Attachment setUrlElement(UrlType value) { 
348      this.url = value;
349      return this;
350    }
351
352    /**
353     * @return A location where the data can be accessed.
354     */
355    public String getUrl() { 
356      return this.url == null ? null : this.url.getValue();
357    }
358
359    /**
360     * @param value A location where the data can be accessed.
361     */
362    public Attachment setUrl(String value) { 
363      if (Utilities.noString(value))
364        this.url = null;
365      else {
366        if (this.url == null)
367          this.url = new UrlType();
368        this.url.setValue(value);
369      }
370      return this;
371    }
372
373    /**
374     * @return {@link #size} (The number of bytes of data that make up this attachment (before base64 encoding, if that is done).). This is the underlying object with id, value and extensions. The accessor "getSize" gives direct access to the value
375     */
376    public UnsignedIntType getSizeElement() { 
377      if (this.size == null)
378        if (Configuration.errorOnAutoCreate())
379          throw new Error("Attempt to auto-create Attachment.size");
380        else if (Configuration.doAutoCreate())
381          this.size = new UnsignedIntType(); // bb
382      return this.size;
383    }
384
385    public boolean hasSizeElement() { 
386      return this.size != null && !this.size.isEmpty();
387    }
388
389    public boolean hasSize() { 
390      return this.size != null && !this.size.isEmpty();
391    }
392
393    /**
394     * @param value {@link #size} (The number of bytes of data that make up this attachment (before base64 encoding, if that is done).). This is the underlying object with id, value and extensions. The accessor "getSize" gives direct access to the value
395     */
396    public Attachment setSizeElement(UnsignedIntType value) { 
397      this.size = value;
398      return this;
399    }
400
401    /**
402     * @return The number of bytes of data that make up this attachment (before base64 encoding, if that is done).
403     */
404    public int getSize() { 
405      return this.size == null || this.size.isEmpty() ? 0 : this.size.getValue();
406    }
407
408    /**
409     * @param value The number of bytes of data that make up this attachment (before base64 encoding, if that is done).
410     */
411    public Attachment setSize(int value) { 
412        if (this.size == null)
413          this.size = new UnsignedIntType();
414        this.size.setValue(value);
415      return this;
416    }
417
418    /**
419     * @return {@link #hash} (The calculated hash of the data using SHA-1. Represented using base64.). This is the underlying object with id, value and extensions. The accessor "getHash" gives direct access to the value
420     */
421    public Base64BinaryType getHashElement() { 
422      if (this.hash == null)
423        if (Configuration.errorOnAutoCreate())
424          throw new Error("Attempt to auto-create Attachment.hash");
425        else if (Configuration.doAutoCreate())
426          this.hash = new Base64BinaryType(); // bb
427      return this.hash;
428    }
429
430    public boolean hasHashElement() { 
431      return this.hash != null && !this.hash.isEmpty();
432    }
433
434    public boolean hasHash() { 
435      return this.hash != null && !this.hash.isEmpty();
436    }
437
438    /**
439     * @param value {@link #hash} (The calculated hash of the data using SHA-1. Represented using base64.). This is the underlying object with id, value and extensions. The accessor "getHash" gives direct access to the value
440     */
441    public Attachment setHashElement(Base64BinaryType value) { 
442      this.hash = value;
443      return this;
444    }
445
446    /**
447     * @return The calculated hash of the data using SHA-1. Represented using base64.
448     */
449    public byte[] getHash() { 
450      return this.hash == null ? null : this.hash.getValue();
451    }
452
453    /**
454     * @param value The calculated hash of the data using SHA-1. Represented using base64.
455     */
456    public Attachment setHash(byte[] value) { 
457      if (value == null)
458        this.hash = null;
459      else {
460        if (this.hash == null)
461          this.hash = new Base64BinaryType();
462        this.hash.setValue(value);
463      }
464      return this;
465    }
466
467    /**
468     * @return {@link #title} (A label or set of text to display in place of the data.). This is the underlying object with id, value and extensions. The accessor "getTitle" gives direct access to the value
469     */
470    public StringType getTitleElement() { 
471      if (this.title == null)
472        if (Configuration.errorOnAutoCreate())
473          throw new Error("Attempt to auto-create Attachment.title");
474        else if (Configuration.doAutoCreate())
475          this.title = new StringType(); // bb
476      return this.title;
477    }
478
479    public boolean hasTitleElement() { 
480      return this.title != null && !this.title.isEmpty();
481    }
482
483    public boolean hasTitle() { 
484      return this.title != null && !this.title.isEmpty();
485    }
486
487    /**
488     * @param value {@link #title} (A label or set of text to display in place of the data.). This is the underlying object with id, value and extensions. The accessor "getTitle" gives direct access to the value
489     */
490    public Attachment setTitleElement(StringType value) { 
491      this.title = value;
492      return this;
493    }
494
495    /**
496     * @return A label or set of text to display in place of the data.
497     */
498    public String getTitle() { 
499      return this.title == null ? null : this.title.getValue();
500    }
501
502    /**
503     * @param value A label or set of text to display in place of the data.
504     */
505    public Attachment setTitle(String value) { 
506      if (Utilities.noString(value))
507        this.title = null;
508      else {
509        if (this.title == null)
510          this.title = new StringType();
511        this.title.setValue(value);
512      }
513      return this;
514    }
515
516    /**
517     * @return {@link #creation} (The date that the attachment was first created.). This is the underlying object with id, value and extensions. The accessor "getCreation" gives direct access to the value
518     */
519    public DateTimeType getCreationElement() { 
520      if (this.creation == null)
521        if (Configuration.errorOnAutoCreate())
522          throw new Error("Attempt to auto-create Attachment.creation");
523        else if (Configuration.doAutoCreate())
524          this.creation = new DateTimeType(); // bb
525      return this.creation;
526    }
527
528    public boolean hasCreationElement() { 
529      return this.creation != null && !this.creation.isEmpty();
530    }
531
532    public boolean hasCreation() { 
533      return this.creation != null && !this.creation.isEmpty();
534    }
535
536    /**
537     * @param value {@link #creation} (The date that the attachment was first created.). This is the underlying object with id, value and extensions. The accessor "getCreation" gives direct access to the value
538     */
539    public Attachment setCreationElement(DateTimeType value) { 
540      this.creation = value;
541      return this;
542    }
543
544    /**
545     * @return The date that the attachment was first created.
546     */
547    public Date getCreation() { 
548      return this.creation == null ? null : this.creation.getValue();
549    }
550
551    /**
552     * @param value The date that the attachment was first created.
553     */
554    public Attachment setCreation(Date value) { 
555      if (value == null)
556        this.creation = null;
557      else {
558        if (this.creation == null)
559          this.creation = new DateTimeType();
560        this.creation.setValue(value);
561      }
562      return this;
563    }
564
565    /**
566     * @return {@link #height} (Height of the image in pixels (photo/video).). This is the underlying object with id, value and extensions. The accessor "getHeight" gives direct access to the value
567     */
568    public PositiveIntType getHeightElement() { 
569      if (this.height == null)
570        if (Configuration.errorOnAutoCreate())
571          throw new Error("Attempt to auto-create Attachment.height");
572        else if (Configuration.doAutoCreate())
573          this.height = new PositiveIntType(); // bb
574      return this.height;
575    }
576
577    public boolean hasHeightElement() { 
578      return this.height != null && !this.height.isEmpty();
579    }
580
581    public boolean hasHeight() { 
582      return this.height != null && !this.height.isEmpty();
583    }
584
585    /**
586     * @param value {@link #height} (Height of the image in pixels (photo/video).). This is the underlying object with id, value and extensions. The accessor "getHeight" gives direct access to the value
587     */
588    public Attachment setHeightElement(PositiveIntType value) { 
589      this.height = value;
590      return this;
591    }
592
593    /**
594     * @return Height of the image in pixels (photo/video).
595     */
596    public int getHeight() { 
597      return this.height == null || this.height.isEmpty() ? 0 : this.height.getValue();
598    }
599
600    /**
601     * @param value Height of the image in pixels (photo/video).
602     */
603    public Attachment setHeight(int value) { 
604        if (this.height == null)
605          this.height = new PositiveIntType();
606        this.height.setValue(value);
607      return this;
608    }
609
610    /**
611     * @return {@link #width} (Width of the image in pixels (photo/video).). This is the underlying object with id, value and extensions. The accessor "getWidth" gives direct access to the value
612     */
613    public PositiveIntType getWidthElement() { 
614      if (this.width == null)
615        if (Configuration.errorOnAutoCreate())
616          throw new Error("Attempt to auto-create Attachment.width");
617        else if (Configuration.doAutoCreate())
618          this.width = new PositiveIntType(); // bb
619      return this.width;
620    }
621
622    public boolean hasWidthElement() { 
623      return this.width != null && !this.width.isEmpty();
624    }
625
626    public boolean hasWidth() { 
627      return this.width != null && !this.width.isEmpty();
628    }
629
630    /**
631     * @param value {@link #width} (Width of the image in pixels (photo/video).). This is the underlying object with id, value and extensions. The accessor "getWidth" gives direct access to the value
632     */
633    public Attachment setWidthElement(PositiveIntType value) { 
634      this.width = value;
635      return this;
636    }
637
638    /**
639     * @return Width of the image in pixels (photo/video).
640     */
641    public int getWidth() { 
642      return this.width == null || this.width.isEmpty() ? 0 : this.width.getValue();
643    }
644
645    /**
646     * @param value Width of the image in pixels (photo/video).
647     */
648    public Attachment setWidth(int value) { 
649        if (this.width == null)
650          this.width = new PositiveIntType();
651        this.width.setValue(value);
652      return this;
653    }
654
655    /**
656     * @return {@link #frames} (The number of frames in a photo. This is used with a multi-page fax, or an imaging acquisition context that takes multiple slices in a single image, or an animated gif. If there is more than one frame, this SHALL have a value in order to alert interface software that a multi-frame capable rendering widget is required.). This is the underlying object with id, value and extensions. The accessor "getFrames" gives direct access to the value
657     */
658    public PositiveIntType getFramesElement() { 
659      if (this.frames == null)
660        if (Configuration.errorOnAutoCreate())
661          throw new Error("Attempt to auto-create Attachment.frames");
662        else if (Configuration.doAutoCreate())
663          this.frames = new PositiveIntType(); // bb
664      return this.frames;
665    }
666
667    public boolean hasFramesElement() { 
668      return this.frames != null && !this.frames.isEmpty();
669    }
670
671    public boolean hasFrames() { 
672      return this.frames != null && !this.frames.isEmpty();
673    }
674
675    /**
676     * @param value {@link #frames} (The number of frames in a photo. This is used with a multi-page fax, or an imaging acquisition context that takes multiple slices in a single image, or an animated gif. If there is more than one frame, this SHALL have a value in order to alert interface software that a multi-frame capable rendering widget is required.). This is the underlying object with id, value and extensions. The accessor "getFrames" gives direct access to the value
677     */
678    public Attachment setFramesElement(PositiveIntType value) { 
679      this.frames = value;
680      return this;
681    }
682
683    /**
684     * @return The number of frames in a photo. This is used with a multi-page fax, or an imaging acquisition context that takes multiple slices in a single image, or an animated gif. If there is more than one frame, this SHALL have a value in order to alert interface software that a multi-frame capable rendering widget is required.
685     */
686    public int getFrames() { 
687      return this.frames == null || this.frames.isEmpty() ? 0 : this.frames.getValue();
688    }
689
690    /**
691     * @param value The number of frames in a photo. This is used with a multi-page fax, or an imaging acquisition context that takes multiple slices in a single image, or an animated gif. If there is more than one frame, this SHALL have a value in order to alert interface software that a multi-frame capable rendering widget is required.
692     */
693    public Attachment setFrames(int value) { 
694        if (this.frames == null)
695          this.frames = new PositiveIntType();
696        this.frames.setValue(value);
697      return this;
698    }
699
700    /**
701     * @return {@link #duration} (The duration of the recording in seconds - for audio and video.). This is the underlying object with id, value and extensions. The accessor "getDuration" gives direct access to the value
702     */
703    public DecimalType getDurationElement() { 
704      if (this.duration == null)
705        if (Configuration.errorOnAutoCreate())
706          throw new Error("Attempt to auto-create Attachment.duration");
707        else if (Configuration.doAutoCreate())
708          this.duration = new DecimalType(); // bb
709      return this.duration;
710    }
711
712    public boolean hasDurationElement() { 
713      return this.duration != null && !this.duration.isEmpty();
714    }
715
716    public boolean hasDuration() { 
717      return this.duration != null && !this.duration.isEmpty();
718    }
719
720    /**
721     * @param value {@link #duration} (The duration of the recording in seconds - for audio and video.). This is the underlying object with id, value and extensions. The accessor "getDuration" gives direct access to the value
722     */
723    public Attachment setDurationElement(DecimalType value) { 
724      this.duration = value;
725      return this;
726    }
727
728    /**
729     * @return The duration of the recording in seconds - for audio and video.
730     */
731    public BigDecimal getDuration() { 
732      return this.duration == null ? null : this.duration.getValue();
733    }
734
735    /**
736     * @param value The duration of the recording in seconds - for audio and video.
737     */
738    public Attachment setDuration(BigDecimal value) { 
739      if (value == null)
740        this.duration = null;
741      else {
742        if (this.duration == null)
743          this.duration = new DecimalType();
744        this.duration.setValue(value);
745      }
746      return this;
747    }
748
749    /**
750     * @param value The duration of the recording in seconds - for audio and video.
751     */
752    public Attachment setDuration(long value) { 
753          this.duration = new DecimalType();
754        this.duration.setValue(value);
755      return this;
756    }
757
758    /**
759     * @param value The duration of the recording in seconds - for audio and video.
760     */
761    public Attachment setDuration(double value) { 
762          this.duration = new DecimalType();
763        this.duration.setValue(value);
764      return this;
765    }
766
767    /**
768     * @return {@link #pages} (The number of pages when printed.). This is the underlying object with id, value and extensions. The accessor "getPages" gives direct access to the value
769     */
770    public PositiveIntType getPagesElement() { 
771      if (this.pages == null)
772        if (Configuration.errorOnAutoCreate())
773          throw new Error("Attempt to auto-create Attachment.pages");
774        else if (Configuration.doAutoCreate())
775          this.pages = new PositiveIntType(); // bb
776      return this.pages;
777    }
778
779    public boolean hasPagesElement() { 
780      return this.pages != null && !this.pages.isEmpty();
781    }
782
783    public boolean hasPages() { 
784      return this.pages != null && !this.pages.isEmpty();
785    }
786
787    /**
788     * @param value {@link #pages} (The number of pages when printed.). This is the underlying object with id, value and extensions. The accessor "getPages" gives direct access to the value
789     */
790    public Attachment setPagesElement(PositiveIntType value) { 
791      this.pages = value;
792      return this;
793    }
794
795    /**
796     * @return The number of pages when printed.
797     */
798    public int getPages() { 
799      return this.pages == null || this.pages.isEmpty() ? 0 : this.pages.getValue();
800    }
801
802    /**
803     * @param value The number of pages when printed.
804     */
805    public Attachment setPages(int value) { 
806        if (this.pages == null)
807          this.pages = new PositiveIntType();
808        this.pages.setValue(value);
809      return this;
810    }
811
812      protected void listChildren(List<Property> children) {
813        super.listChildren(children);
814        children.add(new Property("contentType", "code", "Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate.", 0, 1, contentType));
815        children.add(new Property("language", "code", "The human language of the content. The value can be any valid value according to BCP 47.", 0, 1, language));
816        children.add(new Property("data", "base64Binary", "The actual data of the attachment - a sequence of bytes, base64 encoded.", 0, 1, data));
817        children.add(new Property("url", "url", "A location where the data can be accessed.", 0, 1, url));
818        children.add(new Property("size", "unsignedInt", "The number of bytes of data that make up this attachment (before base64 encoding, if that is done).", 0, 1, size));
819        children.add(new Property("hash", "base64Binary", "The calculated hash of the data using SHA-1. Represented using base64.", 0, 1, hash));
820        children.add(new Property("title", "string", "A label or set of text to display in place of the data.", 0, 1, title));
821        children.add(new Property("creation", "dateTime", "The date that the attachment was first created.", 0, 1, creation));
822        children.add(new Property("height", "positiveInt", "Height of the image in pixels (photo/video).", 0, 1, height));
823        children.add(new Property("width", "positiveInt", "Width of the image in pixels (photo/video).", 0, 1, width));
824        children.add(new Property("frames", "positiveInt", "The number of frames in a photo. This is used with a multi-page fax, or an imaging acquisition context that takes multiple slices in a single image, or an animated gif. If there is more than one frame, this SHALL have a value in order to alert interface software that a multi-frame capable rendering widget is required.", 0, 1, frames));
825        children.add(new Property("duration", "decimal", "The duration of the recording in seconds - for audio and video.", 0, 1, duration));
826        children.add(new Property("pages", "positiveInt", "The number of pages when printed.", 0, 1, pages));
827      }
828
829      @Override
830      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
831        switch (_hash) {
832        case -389131437: /*contentType*/  return new Property("contentType", "code", "Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate.", 0, 1, contentType);
833        case -1613589672: /*language*/  return new Property("language", "code", "The human language of the content. The value can be any valid value according to BCP 47.", 0, 1, language);
834        case 3076010: /*data*/  return new Property("data", "base64Binary", "The actual data of the attachment - a sequence of bytes, base64 encoded.", 0, 1, data);
835        case 116079: /*url*/  return new Property("url", "url", "A location where the data can be accessed.", 0, 1, url);
836        case 3530753: /*size*/  return new Property("size", "unsignedInt", "The number of bytes of data that make up this attachment (before base64 encoding, if that is done).", 0, 1, size);
837        case 3195150: /*hash*/  return new Property("hash", "base64Binary", "The calculated hash of the data using SHA-1. Represented using base64.", 0, 1, hash);
838        case 110371416: /*title*/  return new Property("title", "string", "A label or set of text to display in place of the data.", 0, 1, title);
839        case 1820421855: /*creation*/  return new Property("creation", "dateTime", "The date that the attachment was first created.", 0, 1, creation);
840        case -1221029593: /*height*/  return new Property("height", "positiveInt", "Height of the image in pixels (photo/video).", 0, 1, height);
841        case 113126854: /*width*/  return new Property("width", "positiveInt", "Width of the image in pixels (photo/video).", 0, 1, width);
842        case -1266514778: /*frames*/  return new Property("frames", "positiveInt", "The number of frames in a photo. This is used with a multi-page fax, or an imaging acquisition context that takes multiple slices in a single image, or an animated gif. If there is more than one frame, this SHALL have a value in order to alert interface software that a multi-frame capable rendering widget is required.", 0, 1, frames);
843        case -1992012396: /*duration*/  return new Property("duration", "decimal", "The duration of the recording in seconds - for audio and video.", 0, 1, duration);
844        case 106426308: /*pages*/  return new Property("pages", "positiveInt", "The number of pages when printed.", 0, 1, pages);
845        default: return super.getNamedProperty(_hash, _name, _checkValid);
846        }
847
848      }
849
850      @Override
851      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
852        switch (hash) {
853        case -389131437: /*contentType*/ return this.contentType == null ? new Base[0] : new Base[] {this.contentType}; // CodeType
854        case -1613589672: /*language*/ return this.language == null ? new Base[0] : new Base[] {this.language}; // CodeType
855        case 3076010: /*data*/ return this.data == null ? new Base[0] : new Base[] {this.data}; // Base64BinaryType
856        case 116079: /*url*/ return this.url == null ? new Base[0] : new Base[] {this.url}; // UrlType
857        case 3530753: /*size*/ return this.size == null ? new Base[0] : new Base[] {this.size}; // UnsignedIntType
858        case 3195150: /*hash*/ return this.hash == null ? new Base[0] : new Base[] {this.hash}; // Base64BinaryType
859        case 110371416: /*title*/ return this.title == null ? new Base[0] : new Base[] {this.title}; // StringType
860        case 1820421855: /*creation*/ return this.creation == null ? new Base[0] : new Base[] {this.creation}; // DateTimeType
861        case -1221029593: /*height*/ return this.height == null ? new Base[0] : new Base[] {this.height}; // PositiveIntType
862        case 113126854: /*width*/ return this.width == null ? new Base[0] : new Base[] {this.width}; // PositiveIntType
863        case -1266514778: /*frames*/ return this.frames == null ? new Base[0] : new Base[] {this.frames}; // PositiveIntType
864        case -1992012396: /*duration*/ return this.duration == null ? new Base[0] : new Base[] {this.duration}; // DecimalType
865        case 106426308: /*pages*/ return this.pages == null ? new Base[0] : new Base[] {this.pages}; // PositiveIntType
866        default: return super.getProperty(hash, name, checkValid);
867        }
868
869      }
870
871      @Override
872      public Base setProperty(int hash, String name, Base value) throws FHIRException {
873        switch (hash) {
874        case -389131437: // contentType
875          this.contentType = castToCode(value); // CodeType
876          return value;
877        case -1613589672: // language
878          this.language = castToCode(value); // CodeType
879          return value;
880        case 3076010: // data
881          this.data = castToBase64Binary(value); // Base64BinaryType
882          return value;
883        case 116079: // url
884          this.url = castToUrl(value); // UrlType
885          return value;
886        case 3530753: // size
887          this.size = castToUnsignedInt(value); // UnsignedIntType
888          return value;
889        case 3195150: // hash
890          this.hash = castToBase64Binary(value); // Base64BinaryType
891          return value;
892        case 110371416: // title
893          this.title = castToString(value); // StringType
894          return value;
895        case 1820421855: // creation
896          this.creation = castToDateTime(value); // DateTimeType
897          return value;
898        case -1221029593: // height
899          this.height = castToPositiveInt(value); // PositiveIntType
900          return value;
901        case 113126854: // width
902          this.width = castToPositiveInt(value); // PositiveIntType
903          return value;
904        case -1266514778: // frames
905          this.frames = castToPositiveInt(value); // PositiveIntType
906          return value;
907        case -1992012396: // duration
908          this.duration = castToDecimal(value); // DecimalType
909          return value;
910        case 106426308: // pages
911          this.pages = castToPositiveInt(value); // PositiveIntType
912          return value;
913        default: return super.setProperty(hash, name, value);
914        }
915
916      }
917
918      @Override
919      public Base setProperty(String name, Base value) throws FHIRException {
920        if (name.equals("contentType")) {
921          this.contentType = castToCode(value); // CodeType
922        } else if (name.equals("language")) {
923          this.language = castToCode(value); // CodeType
924        } else if (name.equals("data")) {
925          this.data = castToBase64Binary(value); // Base64BinaryType
926        } else if (name.equals("url")) {
927          this.url = castToUrl(value); // UrlType
928        } else if (name.equals("size")) {
929          this.size = castToUnsignedInt(value); // UnsignedIntType
930        } else if (name.equals("hash")) {
931          this.hash = castToBase64Binary(value); // Base64BinaryType
932        } else if (name.equals("title")) {
933          this.title = castToString(value); // StringType
934        } else if (name.equals("creation")) {
935          this.creation = castToDateTime(value); // DateTimeType
936        } else if (name.equals("height")) {
937          this.height = castToPositiveInt(value); // PositiveIntType
938        } else if (name.equals("width")) {
939          this.width = castToPositiveInt(value); // PositiveIntType
940        } else if (name.equals("frames")) {
941          this.frames = castToPositiveInt(value); // PositiveIntType
942        } else if (name.equals("duration")) {
943          this.duration = castToDecimal(value); // DecimalType
944        } else if (name.equals("pages")) {
945          this.pages = castToPositiveInt(value); // PositiveIntType
946        } else
947          return super.setProperty(name, value);
948        return value;
949      }
950
951      @Override
952      public Base makeProperty(int hash, String name) throws FHIRException {
953        switch (hash) {
954        case -389131437:  return getContentTypeElement();
955        case -1613589672:  return getLanguageElement();
956        case 3076010:  return getDataElement();
957        case 116079:  return getUrlElement();
958        case 3530753:  return getSizeElement();
959        case 3195150:  return getHashElement();
960        case 110371416:  return getTitleElement();
961        case 1820421855:  return getCreationElement();
962        case -1221029593:  return getHeightElement();
963        case 113126854:  return getWidthElement();
964        case -1266514778:  return getFramesElement();
965        case -1992012396:  return getDurationElement();
966        case 106426308:  return getPagesElement();
967        default: return super.makeProperty(hash, name);
968        }
969
970      }
971
972      @Override
973      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
974        switch (hash) {
975        case -389131437: /*contentType*/ return new String[] {"code"};
976        case -1613589672: /*language*/ return new String[] {"code"};
977        case 3076010: /*data*/ return new String[] {"base64Binary"};
978        case 116079: /*url*/ return new String[] {"url"};
979        case 3530753: /*size*/ return new String[] {"unsignedInt"};
980        case 3195150: /*hash*/ return new String[] {"base64Binary"};
981        case 110371416: /*title*/ return new String[] {"string"};
982        case 1820421855: /*creation*/ return new String[] {"dateTime"};
983        case -1221029593: /*height*/ return new String[] {"positiveInt"};
984        case 113126854: /*width*/ return new String[] {"positiveInt"};
985        case -1266514778: /*frames*/ return new String[] {"positiveInt"};
986        case -1992012396: /*duration*/ return new String[] {"decimal"};
987        case 106426308: /*pages*/ return new String[] {"positiveInt"};
988        default: return super.getTypesForProperty(hash, name);
989        }
990
991      }
992
993      @Override
994      public Base addChild(String name) throws FHIRException {
995        if (name.equals("contentType")) {
996          throw new FHIRException("Cannot call addChild on a primitive type Attachment.contentType");
997        }
998        else if (name.equals("language")) {
999          throw new FHIRException("Cannot call addChild on a primitive type Attachment.language");
1000        }
1001        else if (name.equals("data")) {
1002          throw new FHIRException("Cannot call addChild on a primitive type Attachment.data");
1003        }
1004        else if (name.equals("url")) {
1005          throw new FHIRException("Cannot call addChild on a primitive type Attachment.url");
1006        }
1007        else if (name.equals("size")) {
1008          throw new FHIRException("Cannot call addChild on a primitive type Attachment.size");
1009        }
1010        else if (name.equals("hash")) {
1011          throw new FHIRException("Cannot call addChild on a primitive type Attachment.hash");
1012        }
1013        else if (name.equals("title")) {
1014          throw new FHIRException("Cannot call addChild on a primitive type Attachment.title");
1015        }
1016        else if (name.equals("creation")) {
1017          throw new FHIRException("Cannot call addChild on a primitive type Attachment.creation");
1018        }
1019        else if (name.equals("height")) {
1020          throw new FHIRException("Cannot call addChild on a primitive type Attachment.height");
1021        }
1022        else if (name.equals("width")) {
1023          throw new FHIRException("Cannot call addChild on a primitive type Attachment.width");
1024        }
1025        else if (name.equals("frames")) {
1026          throw new FHIRException("Cannot call addChild on a primitive type Attachment.frames");
1027        }
1028        else if (name.equals("duration")) {
1029          throw new FHIRException("Cannot call addChild on a primitive type Attachment.duration");
1030        }
1031        else if (name.equals("pages")) {
1032          throw new FHIRException("Cannot call addChild on a primitive type Attachment.pages");
1033        }
1034        else
1035          return super.addChild(name);
1036      }
1037
1038  public String fhirType() {
1039    return "Attachment";
1040
1041  }
1042
1043      public Attachment copy() {
1044        Attachment dst = new Attachment();
1045        copyValues(dst);
1046        return dst;
1047      }
1048
1049      public void copyValues(Attachment dst) {
1050        super.copyValues(dst);
1051        dst.contentType = contentType == null ? null : contentType.copy();
1052        dst.language = language == null ? null : language.copy();
1053        dst.data = data == null ? null : data.copy();
1054        dst.url = url == null ? null : url.copy();
1055        dst.size = size == null ? null : size.copy();
1056        dst.hash = hash == null ? null : hash.copy();
1057        dst.title = title == null ? null : title.copy();
1058        dst.creation = creation == null ? null : creation.copy();
1059        dst.height = height == null ? null : height.copy();
1060        dst.width = width == null ? null : width.copy();
1061        dst.frames = frames == null ? null : frames.copy();
1062        dst.duration = duration == null ? null : duration.copy();
1063        dst.pages = pages == null ? null : pages.copy();
1064      }
1065
1066      protected Attachment typedCopy() {
1067        return copy();
1068      }
1069
1070      @Override
1071      public boolean equalsDeep(Base other_) {
1072        if (!super.equalsDeep(other_))
1073          return false;
1074        if (!(other_ instanceof Attachment))
1075          return false;
1076        Attachment o = (Attachment) other_;
1077        return compareDeep(contentType, o.contentType, true) && compareDeep(language, o.language, true)
1078           && compareDeep(data, o.data, true) && compareDeep(url, o.url, true) && compareDeep(size, o.size, true)
1079           && compareDeep(hash, o.hash, true) && compareDeep(title, o.title, true) && compareDeep(creation, o.creation, true)
1080           && compareDeep(height, o.height, true) && compareDeep(width, o.width, true) && compareDeep(frames, o.frames, true)
1081           && compareDeep(duration, o.duration, true) && compareDeep(pages, o.pages, true);
1082      }
1083
1084      @Override
1085      public boolean equalsShallow(Base other_) {
1086        if (!super.equalsShallow(other_))
1087          return false;
1088        if (!(other_ instanceof Attachment))
1089          return false;
1090        Attachment o = (Attachment) other_;
1091        return compareValues(contentType, o.contentType, true) && compareValues(language, o.language, true)
1092           && compareValues(data, o.data, true) && compareValues(url, o.url, true) && compareValues(size, o.size, true)
1093           && compareValues(hash, o.hash, true) && compareValues(title, o.title, true) && compareValues(creation, o.creation, true)
1094           && compareValues(height, o.height, true) && compareValues(width, o.width, true) && compareValues(frames, o.frames, true)
1095           && compareValues(duration, o.duration, true) && compareValues(pages, o.pages, true);
1096      }
1097
1098      public boolean isEmpty() {
1099        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(contentType, language, data
1100          , url, size, hash, title, creation, height, width, frames, duration, pages
1101          );
1102      }
1103
1104
1105}
1106