001package org.hl7.fhir.r5.model;
002
003
004/*
005 * #%L
006 * org.hl7.fhir.r5
007 * %%
008 * Copyright (C) 2014 - 2019 Health Level 7
009 * %%
010 * Licensed under the Apache License, Version 2.0 (the \"License\");
011 * you may not use this file except in compliance with the License.
012 * You may obtain a copy of the License at
013 * 
014 *      http://www.apache.org/licenses/LICENSE-2.0
015 * 
016 * Unless required by applicable law or agreed to in writing, software
017 * distributed under the License is distributed on an \"AS IS\" BASIS,
018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
019 * See the License for the specific language governing permissions and
020 * limitations under the License.
021 * #L%
022 */
023
024/*
025  Copyright (c) 2011+, HL7, Inc.
026  All rights reserved.
027  
028  Redistribution and use in source and binary forms, with or without modification, \
029  are permitted provided that the following conditions are met:
030  
031   * Redistributions of source code must retain the above copyright notice, this \
032     list of conditions and the following disclaimer.
033   * Redistributions in binary form must reproduce the above copyright notice, \
034     this list of conditions and the following disclaimer in the documentation \
035     and/or other materials provided with the distribution.
036   * Neither the name of HL7 nor the names of its contributors may be used to 
037     endorse or promote products derived from this software without specific 
038     prior written permission.
039  
040  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \
041  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \
042  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \
043  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \
044  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \
045  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \
046  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \
047  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \
048  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \
049  POSSIBILITY OF SUCH DAMAGE.
050  */
051
052// Generated on Tue, Dec 31, 2019 12:12+1100 for FHIR vcurrent
053
054import java.util.ArrayList;
055import java.util.Date;
056import java.util.List;
057import java.math.*;
058import org.hl7.fhir.utilities.Utilities;
059import org.hl7.fhir.r5.model.Enumerations.*;
060import org.hl7.fhir.instance.model.api.IBaseDatatypeElement;
061import org.hl7.fhir.exceptions.FHIRException;
062import org.hl7.fhir.instance.model.api.ICompositeType;
063import ca.uhn.fhir.model.api.annotation.Child;
064import ca.uhn.fhir.model.api.annotation.ChildOrder;
065import ca.uhn.fhir.model.api.annotation.DatatypeDef;
066import ca.uhn.fhir.model.api.annotation.Description;
067import ca.uhn.fhir.model.api.annotation.Block;
068
069/**
070 * Base StructureDefinition for Attachment Type: For referring to data content defined in other formats.
071 */
072@DatatypeDef(name="Attachment")
073public class Attachment extends DataType 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 = {Integer64Type.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 Integer64Type 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 = -1904332061L;
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 Integer64Type 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 Integer64Type(); // 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(Integer64Type 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 long 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(long value) { 
412          this.size = new Integer64Type();
413        this.size.setValue(value);
414      return this;
415    }
416
417    /**
418     * @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
419     */
420    public Base64BinaryType getHashElement() { 
421      if (this.hash == null)
422        if (Configuration.errorOnAutoCreate())
423          throw new Error("Attempt to auto-create Attachment.hash");
424        else if (Configuration.doAutoCreate())
425          this.hash = new Base64BinaryType(); // bb
426      return this.hash;
427    }
428
429    public boolean hasHashElement() { 
430      return this.hash != null && !this.hash.isEmpty();
431    }
432
433    public boolean hasHash() { 
434      return this.hash != null && !this.hash.isEmpty();
435    }
436
437    /**
438     * @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
439     */
440    public Attachment setHashElement(Base64BinaryType value) { 
441      this.hash = value;
442      return this;
443    }
444
445    /**
446     * @return The calculated hash of the data using SHA-1. Represented using base64.
447     */
448    public byte[] getHash() { 
449      return this.hash == null ? null : this.hash.getValue();
450    }
451
452    /**
453     * @param value The calculated hash of the data using SHA-1. Represented using base64.
454     */
455    public Attachment setHash(byte[] value) { 
456      if (value == null)
457        this.hash = null;
458      else {
459        if (this.hash == null)
460          this.hash = new Base64BinaryType();
461        this.hash.setValue(value);
462      }
463      return this;
464    }
465
466    /**
467     * @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
468     */
469    public StringType getTitleElement() { 
470      if (this.title == null)
471        if (Configuration.errorOnAutoCreate())
472          throw new Error("Attempt to auto-create Attachment.title");
473        else if (Configuration.doAutoCreate())
474          this.title = new StringType(); // bb
475      return this.title;
476    }
477
478    public boolean hasTitleElement() { 
479      return this.title != null && !this.title.isEmpty();
480    }
481
482    public boolean hasTitle() { 
483      return this.title != null && !this.title.isEmpty();
484    }
485
486    /**
487     * @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
488     */
489    public Attachment setTitleElement(StringType value) { 
490      this.title = value;
491      return this;
492    }
493
494    /**
495     * @return A label or set of text to display in place of the data.
496     */
497    public String getTitle() { 
498      return this.title == null ? null : this.title.getValue();
499    }
500
501    /**
502     * @param value A label or set of text to display in place of the data.
503     */
504    public Attachment setTitle(String value) { 
505      if (Utilities.noString(value))
506        this.title = null;
507      else {
508        if (this.title == null)
509          this.title = new StringType();
510        this.title.setValue(value);
511      }
512      return this;
513    }
514
515    /**
516     * @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
517     */
518    public DateTimeType getCreationElement() { 
519      if (this.creation == null)
520        if (Configuration.errorOnAutoCreate())
521          throw new Error("Attempt to auto-create Attachment.creation");
522        else if (Configuration.doAutoCreate())
523          this.creation = new DateTimeType(); // bb
524      return this.creation;
525    }
526
527    public boolean hasCreationElement() { 
528      return this.creation != null && !this.creation.isEmpty();
529    }
530
531    public boolean hasCreation() { 
532      return this.creation != null && !this.creation.isEmpty();
533    }
534
535    /**
536     * @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
537     */
538    public Attachment setCreationElement(DateTimeType value) { 
539      this.creation = value;
540      return this;
541    }
542
543    /**
544     * @return The date that the attachment was first created.
545     */
546    public Date getCreation() { 
547      return this.creation == null ? null : this.creation.getValue();
548    }
549
550    /**
551     * @param value The date that the attachment was first created.
552     */
553    public Attachment setCreation(Date value) { 
554      if (value == null)
555        this.creation = null;
556      else {
557        if (this.creation == null)
558          this.creation = new DateTimeType();
559        this.creation.setValue(value);
560      }
561      return this;
562    }
563
564    /**
565     * @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
566     */
567    public PositiveIntType getHeightElement() { 
568      if (this.height == null)
569        if (Configuration.errorOnAutoCreate())
570          throw new Error("Attempt to auto-create Attachment.height");
571        else if (Configuration.doAutoCreate())
572          this.height = new PositiveIntType(); // bb
573      return this.height;
574    }
575
576    public boolean hasHeightElement() { 
577      return this.height != null && !this.height.isEmpty();
578    }
579
580    public boolean hasHeight() { 
581      return this.height != null && !this.height.isEmpty();
582    }
583
584    /**
585     * @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
586     */
587    public Attachment setHeightElement(PositiveIntType value) { 
588      this.height = value;
589      return this;
590    }
591
592    /**
593     * @return Height of the image in pixels (photo/video).
594     */
595    public int getHeight() { 
596      return this.height == null || this.height.isEmpty() ? 0 : this.height.getValue();
597    }
598
599    /**
600     * @param value Height of the image in pixels (photo/video).
601     */
602    public Attachment setHeight(int value) { 
603        if (this.height == null)
604          this.height = new PositiveIntType();
605        this.height.setValue(value);
606      return this;
607    }
608
609    /**
610     * @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
611     */
612    public PositiveIntType getWidthElement() { 
613      if (this.width == null)
614        if (Configuration.errorOnAutoCreate())
615          throw new Error("Attempt to auto-create Attachment.width");
616        else if (Configuration.doAutoCreate())
617          this.width = new PositiveIntType(); // bb
618      return this.width;
619    }
620
621    public boolean hasWidthElement() { 
622      return this.width != null && !this.width.isEmpty();
623    }
624
625    public boolean hasWidth() { 
626      return this.width != null && !this.width.isEmpty();
627    }
628
629    /**
630     * @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
631     */
632    public Attachment setWidthElement(PositiveIntType value) { 
633      this.width = value;
634      return this;
635    }
636
637    /**
638     * @return Width of the image in pixels (photo/video).
639     */
640    public int getWidth() { 
641      return this.width == null || this.width.isEmpty() ? 0 : this.width.getValue();
642    }
643
644    /**
645     * @param value Width of the image in pixels (photo/video).
646     */
647    public Attachment setWidth(int value) { 
648        if (this.width == null)
649          this.width = new PositiveIntType();
650        this.width.setValue(value);
651      return this;
652    }
653
654    /**
655     * @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
656     */
657    public PositiveIntType getFramesElement() { 
658      if (this.frames == null)
659        if (Configuration.errorOnAutoCreate())
660          throw new Error("Attempt to auto-create Attachment.frames");
661        else if (Configuration.doAutoCreate())
662          this.frames = new PositiveIntType(); // bb
663      return this.frames;
664    }
665
666    public boolean hasFramesElement() { 
667      return this.frames != null && !this.frames.isEmpty();
668    }
669
670    public boolean hasFrames() { 
671      return this.frames != null && !this.frames.isEmpty();
672    }
673
674    /**
675     * @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
676     */
677    public Attachment setFramesElement(PositiveIntType value) { 
678      this.frames = value;
679      return this;
680    }
681
682    /**
683     * @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.
684     */
685    public int getFrames() { 
686      return this.frames == null || this.frames.isEmpty() ? 0 : this.frames.getValue();
687    }
688
689    /**
690     * @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.
691     */
692    public Attachment setFrames(int value) { 
693        if (this.frames == null)
694          this.frames = new PositiveIntType();
695        this.frames.setValue(value);
696      return this;
697    }
698
699    /**
700     * @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
701     */
702    public DecimalType getDurationElement() { 
703      if (this.duration == null)
704        if (Configuration.errorOnAutoCreate())
705          throw new Error("Attempt to auto-create Attachment.duration");
706        else if (Configuration.doAutoCreate())
707          this.duration = new DecimalType(); // bb
708      return this.duration;
709    }
710
711    public boolean hasDurationElement() { 
712      return this.duration != null && !this.duration.isEmpty();
713    }
714
715    public boolean hasDuration() { 
716      return this.duration != null && !this.duration.isEmpty();
717    }
718
719    /**
720     * @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
721     */
722    public Attachment setDurationElement(DecimalType value) { 
723      this.duration = value;
724      return this;
725    }
726
727    /**
728     * @return The duration of the recording in seconds - for audio and video.
729     */
730    public BigDecimal getDuration() { 
731      return this.duration == null ? null : this.duration.getValue();
732    }
733
734    /**
735     * @param value The duration of the recording in seconds - for audio and video.
736     */
737    public Attachment setDuration(BigDecimal value) { 
738      if (value == null)
739        this.duration = null;
740      else {
741        if (this.duration == null)
742          this.duration = new DecimalType();
743        this.duration.setValue(value);
744      }
745      return this;
746    }
747
748    /**
749     * @param value The duration of the recording in seconds - for audio and video.
750     */
751    public Attachment setDuration(long value) { 
752          this.duration = new DecimalType();
753        this.duration.setValue(value);
754      return this;
755    }
756
757    /**
758     * @param value The duration of the recording in seconds - for audio and video.
759     */
760    public Attachment setDuration(double value) { 
761          this.duration = new DecimalType();
762        this.duration.setValue(value);
763      return this;
764    }
765
766    /**
767     * @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
768     */
769    public PositiveIntType getPagesElement() { 
770      if (this.pages == null)
771        if (Configuration.errorOnAutoCreate())
772          throw new Error("Attempt to auto-create Attachment.pages");
773        else if (Configuration.doAutoCreate())
774          this.pages = new PositiveIntType(); // bb
775      return this.pages;
776    }
777
778    public boolean hasPagesElement() { 
779      return this.pages != null && !this.pages.isEmpty();
780    }
781
782    public boolean hasPages() { 
783      return this.pages != null && !this.pages.isEmpty();
784    }
785
786    /**
787     * @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
788     */
789    public Attachment setPagesElement(PositiveIntType value) { 
790      this.pages = value;
791      return this;
792    }
793
794    /**
795     * @return The number of pages when printed.
796     */
797    public int getPages() { 
798      return this.pages == null || this.pages.isEmpty() ? 0 : this.pages.getValue();
799    }
800
801    /**
802     * @param value The number of pages when printed.
803     */
804    public Attachment setPages(int value) { 
805        if (this.pages == null)
806          this.pages = new PositiveIntType();
807        this.pages.setValue(value);
808      return this;
809    }
810
811      protected void listChildren(List<Property> children) {
812        super.listChildren(children);
813        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));
814        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));
815        children.add(new Property("data", "base64Binary", "The actual data of the attachment - a sequence of bytes, base64 encoded.", 0, 1, data));
816        children.add(new Property("url", "url", "A location where the data can be accessed.", 0, 1, url));
817        children.add(new Property("size", "integer64", "The number of bytes of data that make up this attachment (before base64 encoding, if that is done).", 0, 1, size));
818        children.add(new Property("hash", "base64Binary", "The calculated hash of the data using SHA-1. Represented using base64.", 0, 1, hash));
819        children.add(new Property("title", "string", "A label or set of text to display in place of the data.", 0, 1, title));
820        children.add(new Property("creation", "dateTime", "The date that the attachment was first created.", 0, 1, creation));
821        children.add(new Property("height", "positiveInt", "Height of the image in pixels (photo/video).", 0, 1, height));
822        children.add(new Property("width", "positiveInt", "Width of the image in pixels (photo/video).", 0, 1, width));
823        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));
824        children.add(new Property("duration", "decimal", "The duration of the recording in seconds - for audio and video.", 0, 1, duration));
825        children.add(new Property("pages", "positiveInt", "The number of pages when printed.", 0, 1, pages));
826      }
827
828      @Override
829      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
830        switch (_hash) {
831        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);
832        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);
833        case 3076010: /*data*/  return new Property("data", "base64Binary", "The actual data of the attachment - a sequence of bytes, base64 encoded.", 0, 1, data);
834        case 116079: /*url*/  return new Property("url", "url", "A location where the data can be accessed.", 0, 1, url);
835        case 3530753: /*size*/  return new Property("size", "integer64", "The number of bytes of data that make up this attachment (before base64 encoding, if that is done).", 0, 1, size);
836        case 3195150: /*hash*/  return new Property("hash", "base64Binary", "The calculated hash of the data using SHA-1. Represented using base64.", 0, 1, hash);
837        case 110371416: /*title*/  return new Property("title", "string", "A label or set of text to display in place of the data.", 0, 1, title);
838        case 1820421855: /*creation*/  return new Property("creation", "dateTime", "The date that the attachment was first created.", 0, 1, creation);
839        case -1221029593: /*height*/  return new Property("height", "positiveInt", "Height of the image in pixels (photo/video).", 0, 1, height);
840        case 113126854: /*width*/  return new Property("width", "positiveInt", "Width of the image in pixels (photo/video).", 0, 1, width);
841        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);
842        case -1992012396: /*duration*/  return new Property("duration", "decimal", "The duration of the recording in seconds - for audio and video.", 0, 1, duration);
843        case 106426308: /*pages*/  return new Property("pages", "positiveInt", "The number of pages when printed.", 0, 1, pages);
844        default: return super.getNamedProperty(_hash, _name, _checkValid);
845        }
846
847      }
848
849      @Override
850      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
851        switch (hash) {
852        case -389131437: /*contentType*/ return this.contentType == null ? new Base[0] : new Base[] {this.contentType}; // CodeType
853        case -1613589672: /*language*/ return this.language == null ? new Base[0] : new Base[] {this.language}; // CodeType
854        case 3076010: /*data*/ return this.data == null ? new Base[0] : new Base[] {this.data}; // Base64BinaryType
855        case 116079: /*url*/ return this.url == null ? new Base[0] : new Base[] {this.url}; // UrlType
856        case 3530753: /*size*/ return this.size == null ? new Base[0] : new Base[] {this.size}; // Integer64Type
857        case 3195150: /*hash*/ return this.hash == null ? new Base[0] : new Base[] {this.hash}; // Base64BinaryType
858        case 110371416: /*title*/ return this.title == null ? new Base[0] : new Base[] {this.title}; // StringType
859        case 1820421855: /*creation*/ return this.creation == null ? new Base[0] : new Base[] {this.creation}; // DateTimeType
860        case -1221029593: /*height*/ return this.height == null ? new Base[0] : new Base[] {this.height}; // PositiveIntType
861        case 113126854: /*width*/ return this.width == null ? new Base[0] : new Base[] {this.width}; // PositiveIntType
862        case -1266514778: /*frames*/ return this.frames == null ? new Base[0] : new Base[] {this.frames}; // PositiveIntType
863        case -1992012396: /*duration*/ return this.duration == null ? new Base[0] : new Base[] {this.duration}; // DecimalType
864        case 106426308: /*pages*/ return this.pages == null ? new Base[0] : new Base[] {this.pages}; // PositiveIntType
865        default: return super.getProperty(hash, name, checkValid);
866        }
867
868      }
869
870      @Override
871      public Base setProperty(int hash, String name, Base value) throws FHIRException {
872        switch (hash) {
873        case -389131437: // contentType
874          this.contentType = TypeConvertor.castToCode(value); // CodeType
875          return value;
876        case -1613589672: // language
877          this.language = TypeConvertor.castToCode(value); // CodeType
878          return value;
879        case 3076010: // data
880          this.data = TypeConvertor.castToBase64Binary(value); // Base64BinaryType
881          return value;
882        case 116079: // url
883          this.url = TypeConvertor.castToUrl(value); // UrlType
884          return value;
885        case 3530753: // size
886          this.size = TypeConvertor.castToInteger64(value); // Integer64Type
887          return value;
888        case 3195150: // hash
889          this.hash = TypeConvertor.castToBase64Binary(value); // Base64BinaryType
890          return value;
891        case 110371416: // title
892          this.title = TypeConvertor.castToString(value); // StringType
893          return value;
894        case 1820421855: // creation
895          this.creation = TypeConvertor.castToDateTime(value); // DateTimeType
896          return value;
897        case -1221029593: // height
898          this.height = TypeConvertor.castToPositiveInt(value); // PositiveIntType
899          return value;
900        case 113126854: // width
901          this.width = TypeConvertor.castToPositiveInt(value); // PositiveIntType
902          return value;
903        case -1266514778: // frames
904          this.frames = TypeConvertor.castToPositiveInt(value); // PositiveIntType
905          return value;
906        case -1992012396: // duration
907          this.duration = TypeConvertor.castToDecimal(value); // DecimalType
908          return value;
909        case 106426308: // pages
910          this.pages = TypeConvertor.castToPositiveInt(value); // PositiveIntType
911          return value;
912        default: return super.setProperty(hash, name, value);
913        }
914
915      }
916
917      @Override
918      public Base setProperty(String name, Base value) throws FHIRException {
919        if (name.equals("contentType")) {
920          this.contentType = TypeConvertor.castToCode(value); // CodeType
921        } else if (name.equals("language")) {
922          this.language = TypeConvertor.castToCode(value); // CodeType
923        } else if (name.equals("data")) {
924          this.data = TypeConvertor.castToBase64Binary(value); // Base64BinaryType
925        } else if (name.equals("url")) {
926          this.url = TypeConvertor.castToUrl(value); // UrlType
927        } else if (name.equals("size")) {
928          this.size = TypeConvertor.castToInteger64(value); // Integer64Type
929        } else if (name.equals("hash")) {
930          this.hash = TypeConvertor.castToBase64Binary(value); // Base64BinaryType
931        } else if (name.equals("title")) {
932          this.title = TypeConvertor.castToString(value); // StringType
933        } else if (name.equals("creation")) {
934          this.creation = TypeConvertor.castToDateTime(value); // DateTimeType
935        } else if (name.equals("height")) {
936          this.height = TypeConvertor.castToPositiveInt(value); // PositiveIntType
937        } else if (name.equals("width")) {
938          this.width = TypeConvertor.castToPositiveInt(value); // PositiveIntType
939        } else if (name.equals("frames")) {
940          this.frames = TypeConvertor.castToPositiveInt(value); // PositiveIntType
941        } else if (name.equals("duration")) {
942          this.duration = TypeConvertor.castToDecimal(value); // DecimalType
943        } else if (name.equals("pages")) {
944          this.pages = TypeConvertor.castToPositiveInt(value); // PositiveIntType
945        } else
946          return super.setProperty(name, value);
947        return value;
948      }
949
950      @Override
951      public Base makeProperty(int hash, String name) throws FHIRException {
952        switch (hash) {
953        case -389131437:  return getContentTypeElement();
954        case -1613589672:  return getLanguageElement();
955        case 3076010:  return getDataElement();
956        case 116079:  return getUrlElement();
957        case 3530753:  return getSizeElement();
958        case 3195150:  return getHashElement();
959        case 110371416:  return getTitleElement();
960        case 1820421855:  return getCreationElement();
961        case -1221029593:  return getHeightElement();
962        case 113126854:  return getWidthElement();
963        case -1266514778:  return getFramesElement();
964        case -1992012396:  return getDurationElement();
965        case 106426308:  return getPagesElement();
966        default: return super.makeProperty(hash, name);
967        }
968
969      }
970
971      @Override
972      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
973        switch (hash) {
974        case -389131437: /*contentType*/ return new String[] {"code"};
975        case -1613589672: /*language*/ return new String[] {"code"};
976        case 3076010: /*data*/ return new String[] {"base64Binary"};
977        case 116079: /*url*/ return new String[] {"url"};
978        case 3530753: /*size*/ return new String[] {"integer64"};
979        case 3195150: /*hash*/ return new String[] {"base64Binary"};
980        case 110371416: /*title*/ return new String[] {"string"};
981        case 1820421855: /*creation*/ return new String[] {"dateTime"};
982        case -1221029593: /*height*/ return new String[] {"positiveInt"};
983        case 113126854: /*width*/ return new String[] {"positiveInt"};
984        case -1266514778: /*frames*/ return new String[] {"positiveInt"};
985        case -1992012396: /*duration*/ return new String[] {"decimal"};
986        case 106426308: /*pages*/ return new String[] {"positiveInt"};
987        default: return super.getTypesForProperty(hash, name);
988        }
989
990      }
991
992      @Override
993      public Base addChild(String name) throws FHIRException {
994        if (name.equals("contentType")) {
995          throw new FHIRException("Cannot call addChild on a primitive type Attachment.contentType");
996        }
997        else if (name.equals("language")) {
998          throw new FHIRException("Cannot call addChild on a primitive type Attachment.language");
999        }
1000        else if (name.equals("data")) {
1001          throw new FHIRException("Cannot call addChild on a primitive type Attachment.data");
1002        }
1003        else if (name.equals("url")) {
1004          throw new FHIRException("Cannot call addChild on a primitive type Attachment.url");
1005        }
1006        else if (name.equals("size")) {
1007          throw new FHIRException("Cannot call addChild on a primitive type Attachment.size");
1008        }
1009        else if (name.equals("hash")) {
1010          throw new FHIRException("Cannot call addChild on a primitive type Attachment.hash");
1011        }
1012        else if (name.equals("title")) {
1013          throw new FHIRException("Cannot call addChild on a primitive type Attachment.title");
1014        }
1015        else if (name.equals("creation")) {
1016          throw new FHIRException("Cannot call addChild on a primitive type Attachment.creation");
1017        }
1018        else if (name.equals("height")) {
1019          throw new FHIRException("Cannot call addChild on a primitive type Attachment.height");
1020        }
1021        else if (name.equals("width")) {
1022          throw new FHIRException("Cannot call addChild on a primitive type Attachment.width");
1023        }
1024        else if (name.equals("frames")) {
1025          throw new FHIRException("Cannot call addChild on a primitive type Attachment.frames");
1026        }
1027        else if (name.equals("duration")) {
1028          throw new FHIRException("Cannot call addChild on a primitive type Attachment.duration");
1029        }
1030        else if (name.equals("pages")) {
1031          throw new FHIRException("Cannot call addChild on a primitive type Attachment.pages");
1032        }
1033        else
1034          return super.addChild(name);
1035      }
1036
1037  public String fhirType() {
1038    return "Attachment";
1039
1040  }
1041
1042      public Attachment copy() {
1043        Attachment dst = new Attachment();
1044        copyValues(dst);
1045        return dst;
1046      }
1047
1048      public void copyValues(Attachment dst) {
1049        super.copyValues(dst);
1050        dst.contentType = contentType == null ? null : contentType.copy();
1051        dst.language = language == null ? null : language.copy();
1052        dst.data = data == null ? null : data.copy();
1053        dst.url = url == null ? null : url.copy();
1054        dst.size = size == null ? null : size.copy();
1055        dst.hash = hash == null ? null : hash.copy();
1056        dst.title = title == null ? null : title.copy();
1057        dst.creation = creation == null ? null : creation.copy();
1058        dst.height = height == null ? null : height.copy();
1059        dst.width = width == null ? null : width.copy();
1060        dst.frames = frames == null ? null : frames.copy();
1061        dst.duration = duration == null ? null : duration.copy();
1062        dst.pages = pages == null ? null : pages.copy();
1063      }
1064
1065      protected Attachment typedCopy() {
1066        return copy();
1067      }
1068
1069      @Override
1070      public boolean equalsDeep(Base other_) {
1071        if (!super.equalsDeep(other_))
1072          return false;
1073        if (!(other_ instanceof Attachment))
1074          return false;
1075        Attachment o = (Attachment) other_;
1076        return compareDeep(contentType, o.contentType, true) && compareDeep(language, o.language, true)
1077           && compareDeep(data, o.data, true) && compareDeep(url, o.url, true) && compareDeep(size, o.size, true)
1078           && compareDeep(hash, o.hash, true) && compareDeep(title, o.title, true) && compareDeep(creation, o.creation, true)
1079           && compareDeep(height, o.height, true) && compareDeep(width, o.width, true) && compareDeep(frames, o.frames, true)
1080           && compareDeep(duration, o.duration, true) && compareDeep(pages, o.pages, true);
1081      }
1082
1083      @Override
1084      public boolean equalsShallow(Base other_) {
1085        if (!super.equalsShallow(other_))
1086          return false;
1087        if (!(other_ instanceof Attachment))
1088          return false;
1089        Attachment o = (Attachment) other_;
1090        return compareValues(contentType, o.contentType, true) && compareValues(language, o.language, true)
1091           && compareValues(data, o.data, true) && compareValues(url, o.url, true) && compareValues(size, o.size, true)
1092           && compareValues(hash, o.hash, true) && compareValues(title, o.title, true) && compareValues(creation, o.creation, true)
1093           && compareValues(height, o.height, true) && compareValues(width, o.width, true) && compareValues(frames, o.frames, true)
1094           && compareValues(duration, o.duration, true) && compareValues(pages, o.pages, true);
1095      }
1096
1097      public boolean isEmpty() {
1098        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(contentType, language, data
1099          , url, size, hash, title, creation, height, width, frames, duration, pages
1100          );
1101      }
1102
1103
1104}
1105