001package org.hl7.fhir.r4.model;
002
003/*-
004 * #%L
005 * org.hl7.fhir.r4
006 * %%
007 * Copyright (C) 2014 - 2019 Health Level 7
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 * 
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 * 
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023/*
024  Copyright (c) 2011+, HL7, Inc.
025  All rights reserved.
026  
027  Redistribution and use in source and binary forms, with or without modification, 
028  are permitted provided that the following conditions are met:
029  
030   * Redistributions of source code must retain the above copyright notice, this 
031     list of conditions and the following disclaimer.
032   * Redistributions in binary form must reproduce the above copyright notice, 
033     this list of conditions and the following disclaimer in the documentation 
034     and/or other materials provided with the distribution.
035   * Neither the name of HL7 nor the names of its contributors may be used to 
036     endorse or promote products derived from this software without specific 
037     prior written permission.
038  
039  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
040  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
041  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
042  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
043  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
044  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
045  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
046  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
047  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
048  POSSIBILITY OF SUCH DAMAGE.
049  
050*/
051
052// Generated on Thu, Dec 13, 2018 14:07+1100 for FHIR v4.0.0
053import java.util.ArrayList;
054import java.util.Date;
055import java.util.List;
056
057import org.hl7.fhir.exceptions.FHIRException;
058import org.hl7.fhir.instance.model.api.ICompositeType;
059import org.hl7.fhir.utilities.Utilities;
060
061import ca.uhn.fhir.model.api.annotation.Child;
062import ca.uhn.fhir.model.api.annotation.DatatypeDef;
063import ca.uhn.fhir.model.api.annotation.Description;
064/**
065 * A signature along with supporting context. The signature may be a digital signature that is cryptographic in nature, or some other signature acceptable to the domain. This other signature may be as simple as a graphical image representing a hand-written signature, or a signature ceremony Different signature approaches have different utilities.
066 */
067@DatatypeDef(name="Signature")
068public class Signature extends Type implements ICompositeType {
069
070    /**
071     * An indication of the reason that the entity signed this document. This may be explicitly included as part of the signature information and can be used when determining accountability for various actions concerning the document.
072     */
073    @Child(name = "type", type = {Coding.class}, order=0, min=1, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
074    @Description(shortDefinition="Indication of the reason the entity signed the object(s)", formalDefinition="An indication of the reason that the entity signed this document. This may be explicitly included as part of the signature information and can be used when determining accountability for various actions concerning the document." )
075    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/signature-type")
076    protected List<Coding> type;
077
078    /**
079     * When the digital signature was signed.
080     */
081    @Child(name = "when", type = {InstantType.class}, order=1, min=1, max=1, modifier=false, summary=true)
082    @Description(shortDefinition="When the signature was created", formalDefinition="When the digital signature was signed." )
083    protected InstantType when;
084
085    /**
086     * A reference to an application-usable description of the identity that signed  (e.g. the signature used their private key).
087     */
088    @Child(name = "who", type = {Practitioner.class, PractitionerRole.class, RelatedPerson.class, Patient.class, Device.class, Organization.class}, order=2, min=1, max=1, modifier=false, summary=true)
089    @Description(shortDefinition="Who signed", formalDefinition="A reference to an application-usable description of the identity that signed  (e.g. the signature used their private key)." )
090    protected Reference who;
091
092    /**
093     * The actual object that is the target of the reference (A reference to an application-usable description of the identity that signed  (e.g. the signature used their private key).)
094     */
095    protected Resource whoTarget;
096
097    /**
098     * A reference to an application-usable description of the identity that is represented by the signature.
099     */
100    @Child(name = "onBehalfOf", type = {Practitioner.class, PractitionerRole.class, RelatedPerson.class, Patient.class, Device.class, Organization.class}, order=3, min=0, max=1, modifier=false, summary=true)
101    @Description(shortDefinition="The party represented", formalDefinition="A reference to an application-usable description of the identity that is represented by the signature." )
102    protected Reference onBehalfOf;
103
104    /**
105     * The actual object that is the target of the reference (A reference to an application-usable description of the identity that is represented by the signature.)
106     */
107    protected Resource onBehalfOfTarget;
108
109    /**
110     * A mime type that indicates the technical format of the target resources signed by the signature.
111     */
112    @Child(name = "targetFormat", type = {CodeType.class}, order=4, min=0, max=1, modifier=false, summary=false)
113    @Description(shortDefinition="The technical format of the signed resources", formalDefinition="A mime type that indicates the technical format of the target resources signed by the signature." )
114    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/mimetypes")
115    protected CodeType targetFormat;
116
117    /**
118     * A mime type that indicates the technical format of the signature. Important mime types are application/signature+xml for X ML DigSig, application/jose for JWS, and image/* for a graphical image of a signature, etc.
119     */
120    @Child(name = "sigFormat", type = {CodeType.class}, order=5, min=0, max=1, modifier=false, summary=false)
121    @Description(shortDefinition="The technical format of the signature", formalDefinition="A mime type that indicates the technical format of the signature. Important mime types are application/signature+xml for X ML DigSig, application/jose for JWS, and image/* for a graphical image of a signature, etc." )
122    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/mimetypes")
123    protected CodeType sigFormat;
124
125    /**
126     * The base64 encoding of the Signature content. When signature is not recorded electronically this element would be empty.
127     */
128    @Child(name = "data", type = {Base64BinaryType.class}, order=6, min=0, max=1, modifier=false, summary=false)
129    @Description(shortDefinition="The actual signature content (XML DigSig. JWS, picture, etc.)", formalDefinition="The base64 encoding of the Signature content. When signature is not recorded electronically this element would be empty." )
130    protected Base64BinaryType data;
131
132    private static final long serialVersionUID = 1587325823L;
133
134  /**
135   * Constructor
136   */
137    public Signature() {
138      super();
139    }
140
141  /**
142   * Constructor
143   */
144    public Signature(InstantType when, Reference who) {
145      super();
146      this.when = when;
147      this.who = who;
148    }
149
150    /**
151     * @return {@link #type} (An indication of the reason that the entity signed this document. This may be explicitly included as part of the signature information and can be used when determining accountability for various actions concerning the document.)
152     */
153    public List<Coding> getType() { 
154      if (this.type == null)
155        this.type = new ArrayList<Coding>();
156      return this.type;
157    }
158
159    /**
160     * @return Returns a reference to <code>this</code> for easy method chaining
161     */
162    public Signature setType(List<Coding> theType) { 
163      this.type = theType;
164      return this;
165    }
166
167    public boolean hasType() { 
168      if (this.type == null)
169        return false;
170      for (Coding item : this.type)
171        if (!item.isEmpty())
172          return true;
173      return false;
174    }
175
176    public Coding addType() { //3
177      Coding t = new Coding();
178      if (this.type == null)
179        this.type = new ArrayList<Coding>();
180      this.type.add(t);
181      return t;
182    }
183
184    public Signature addType(Coding t) { //3
185      if (t == null)
186        return this;
187      if (this.type == null)
188        this.type = new ArrayList<Coding>();
189      this.type.add(t);
190      return this;
191    }
192
193    /**
194     * @return The first repetition of repeating field {@link #type}, creating it if it does not already exist
195     */
196    public Coding getTypeFirstRep() { 
197      if (getType().isEmpty()) {
198        addType();
199      }
200      return getType().get(0);
201    }
202
203    /**
204     * @return {@link #when} (When the digital signature was signed.). This is the underlying object with id, value and extensions. The accessor "getWhen" gives direct access to the value
205     */
206    public InstantType getWhenElement() { 
207      if (this.when == null)
208        if (Configuration.errorOnAutoCreate())
209          throw new Error("Attempt to auto-create Signature.when");
210        else if (Configuration.doAutoCreate())
211          this.when = new InstantType(); // bb
212      return this.when;
213    }
214
215    public boolean hasWhenElement() { 
216      return this.when != null && !this.when.isEmpty();
217    }
218
219    public boolean hasWhen() { 
220      return this.when != null && !this.when.isEmpty();
221    }
222
223    /**
224     * @param value {@link #when} (When the digital signature was signed.). This is the underlying object with id, value and extensions. The accessor "getWhen" gives direct access to the value
225     */
226    public Signature setWhenElement(InstantType value) { 
227      this.when = value;
228      return this;
229    }
230
231    /**
232     * @return When the digital signature was signed.
233     */
234    public Date getWhen() { 
235      return this.when == null ? null : this.when.getValue();
236    }
237
238    /**
239     * @param value When the digital signature was signed.
240     */
241    public Signature setWhen(Date value) { 
242        if (this.when == null)
243          this.when = new InstantType();
244        this.when.setValue(value);
245      return this;
246    }
247
248    /**
249     * @return {@link #who} (A reference to an application-usable description of the identity that signed  (e.g. the signature used their private key).)
250     */
251    public Reference getWho() { 
252      if (this.who == null)
253        if (Configuration.errorOnAutoCreate())
254          throw new Error("Attempt to auto-create Signature.who");
255        else if (Configuration.doAutoCreate())
256          this.who = new Reference(); // cc
257      return this.who;
258    }
259
260    public boolean hasWho() { 
261      return this.who != null && !this.who.isEmpty();
262    }
263
264    /**
265     * @param value {@link #who} (A reference to an application-usable description of the identity that signed  (e.g. the signature used their private key).)
266     */
267    public Signature setWho(Reference value) { 
268      this.who = value;
269      return this;
270    }
271
272    /**
273     * @return {@link #who} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (A reference to an application-usable description of the identity that signed  (e.g. the signature used their private key).)
274     */
275    public Resource getWhoTarget() { 
276      return this.whoTarget;
277    }
278
279    /**
280     * @param value {@link #who} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (A reference to an application-usable description of the identity that signed  (e.g. the signature used their private key).)
281     */
282    public Signature setWhoTarget(Resource value) { 
283      this.whoTarget = value;
284      return this;
285    }
286
287    /**
288     * @return {@link #onBehalfOf} (A reference to an application-usable description of the identity that is represented by the signature.)
289     */
290    public Reference getOnBehalfOf() { 
291      if (this.onBehalfOf == null)
292        if (Configuration.errorOnAutoCreate())
293          throw new Error("Attempt to auto-create Signature.onBehalfOf");
294        else if (Configuration.doAutoCreate())
295          this.onBehalfOf = new Reference(); // cc
296      return this.onBehalfOf;
297    }
298
299    public boolean hasOnBehalfOf() { 
300      return this.onBehalfOf != null && !this.onBehalfOf.isEmpty();
301    }
302
303    /**
304     * @param value {@link #onBehalfOf} (A reference to an application-usable description of the identity that is represented by the signature.)
305     */
306    public Signature setOnBehalfOf(Reference value) { 
307      this.onBehalfOf = value;
308      return this;
309    }
310
311    /**
312     * @return {@link #onBehalfOf} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (A reference to an application-usable description of the identity that is represented by the signature.)
313     */
314    public Resource getOnBehalfOfTarget() { 
315      return this.onBehalfOfTarget;
316    }
317
318    /**
319     * @param value {@link #onBehalfOf} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (A reference to an application-usable description of the identity that is represented by the signature.)
320     */
321    public Signature setOnBehalfOfTarget(Resource value) { 
322      this.onBehalfOfTarget = value;
323      return this;
324    }
325
326    /**
327     * @return {@link #targetFormat} (A mime type that indicates the technical format of the target resources signed by the signature.). This is the underlying object with id, value and extensions. The accessor "getTargetFormat" gives direct access to the value
328     */
329    public CodeType getTargetFormatElement() { 
330      if (this.targetFormat == null)
331        if (Configuration.errorOnAutoCreate())
332          throw new Error("Attempt to auto-create Signature.targetFormat");
333        else if (Configuration.doAutoCreate())
334          this.targetFormat = new CodeType(); // bb
335      return this.targetFormat;
336    }
337
338    public boolean hasTargetFormatElement() { 
339      return this.targetFormat != null && !this.targetFormat.isEmpty();
340    }
341
342    public boolean hasTargetFormat() { 
343      return this.targetFormat != null && !this.targetFormat.isEmpty();
344    }
345
346    /**
347     * @param value {@link #targetFormat} (A mime type that indicates the technical format of the target resources signed by the signature.). This is the underlying object with id, value and extensions. The accessor "getTargetFormat" gives direct access to the value
348     */
349    public Signature setTargetFormatElement(CodeType value) { 
350      this.targetFormat = value;
351      return this;
352    }
353
354    /**
355     * @return A mime type that indicates the technical format of the target resources signed by the signature.
356     */
357    public String getTargetFormat() { 
358      return this.targetFormat == null ? null : this.targetFormat.getValue();
359    }
360
361    /**
362     * @param value A mime type that indicates the technical format of the target resources signed by the signature.
363     */
364    public Signature setTargetFormat(String value) { 
365      if (Utilities.noString(value))
366        this.targetFormat = null;
367      else {
368        if (this.targetFormat == null)
369          this.targetFormat = new CodeType();
370        this.targetFormat.setValue(value);
371      }
372      return this;
373    }
374
375    /**
376     * @return {@link #sigFormat} (A mime type that indicates the technical format of the signature. Important mime types are application/signature+xml for X ML DigSig, application/jose for JWS, and image/* for a graphical image of a signature, etc.). This is the underlying object with id, value and extensions. The accessor "getSigFormat" gives direct access to the value
377     */
378    public CodeType getSigFormatElement() { 
379      if (this.sigFormat == null)
380        if (Configuration.errorOnAutoCreate())
381          throw new Error("Attempt to auto-create Signature.sigFormat");
382        else if (Configuration.doAutoCreate())
383          this.sigFormat = new CodeType(); // bb
384      return this.sigFormat;
385    }
386
387    public boolean hasSigFormatElement() { 
388      return this.sigFormat != null && !this.sigFormat.isEmpty();
389    }
390
391    public boolean hasSigFormat() { 
392      return this.sigFormat != null && !this.sigFormat.isEmpty();
393    }
394
395    /**
396     * @param value {@link #sigFormat} (A mime type that indicates the technical format of the signature. Important mime types are application/signature+xml for X ML DigSig, application/jose for JWS, and image/* for a graphical image of a signature, etc.). This is the underlying object with id, value and extensions. The accessor "getSigFormat" gives direct access to the value
397     */
398    public Signature setSigFormatElement(CodeType value) { 
399      this.sigFormat = value;
400      return this;
401    }
402
403    /**
404     * @return A mime type that indicates the technical format of the signature. Important mime types are application/signature+xml for X ML DigSig, application/jose for JWS, and image/* for a graphical image of a signature, etc.
405     */
406    public String getSigFormat() { 
407      return this.sigFormat == null ? null : this.sigFormat.getValue();
408    }
409
410    /**
411     * @param value A mime type that indicates the technical format of the signature. Important mime types are application/signature+xml for X ML DigSig, application/jose for JWS, and image/* for a graphical image of a signature, etc.
412     */
413    public Signature setSigFormat(String value) { 
414      if (Utilities.noString(value))
415        this.sigFormat = null;
416      else {
417        if (this.sigFormat == null)
418          this.sigFormat = new CodeType();
419        this.sigFormat.setValue(value);
420      }
421      return this;
422    }
423
424    /**
425     * @return {@link #data} (The base64 encoding of the Signature content. When signature is not recorded electronically this element would be empty.). This is the underlying object with id, value and extensions. The accessor "getData" gives direct access to the value
426     */
427    public Base64BinaryType getDataElement() { 
428      if (this.data == null)
429        if (Configuration.errorOnAutoCreate())
430          throw new Error("Attempt to auto-create Signature.data");
431        else if (Configuration.doAutoCreate())
432          this.data = new Base64BinaryType(); // bb
433      return this.data;
434    }
435
436    public boolean hasDataElement() { 
437      return this.data != null && !this.data.isEmpty();
438    }
439
440    public boolean hasData() { 
441      return this.data != null && !this.data.isEmpty();
442    }
443
444    /**
445     * @param value {@link #data} (The base64 encoding of the Signature content. When signature is not recorded electronically this element would be empty.). This is the underlying object with id, value and extensions. The accessor "getData" gives direct access to the value
446     */
447    public Signature setDataElement(Base64BinaryType value) { 
448      this.data = value;
449      return this;
450    }
451
452    /**
453     * @return The base64 encoding of the Signature content. When signature is not recorded electronically this element would be empty.
454     */
455    public byte[] getData() { 
456      return this.data == null ? null : this.data.getValue();
457    }
458
459    /**
460     * @param value The base64 encoding of the Signature content. When signature is not recorded electronically this element would be empty.
461     */
462    public Signature setData(byte[] value) { 
463      if (value == null)
464        this.data = null;
465      else {
466        if (this.data == null)
467          this.data = new Base64BinaryType();
468        this.data.setValue(value);
469      }
470      return this;
471    }
472
473      protected void listChildren(List<Property> children) {
474        super.listChildren(children);
475        children.add(new Property("type", "Coding", "An indication of the reason that the entity signed this document. This may be explicitly included as part of the signature information and can be used when determining accountability for various actions concerning the document.", 0, java.lang.Integer.MAX_VALUE, type));
476        children.add(new Property("when", "instant", "When the digital signature was signed.", 0, 1, when));
477        children.add(new Property("who", "Reference(Practitioner|PractitionerRole|RelatedPerson|Patient|Device|Organization)", "A reference to an application-usable description of the identity that signed  (e.g. the signature used their private key).", 0, 1, who));
478        children.add(new Property("onBehalfOf", "Reference(Practitioner|PractitionerRole|RelatedPerson|Patient|Device|Organization)", "A reference to an application-usable description of the identity that is represented by the signature.", 0, 1, onBehalfOf));
479        children.add(new Property("targetFormat", "code", "A mime type that indicates the technical format of the target resources signed by the signature.", 0, 1, targetFormat));
480        children.add(new Property("sigFormat", "code", "A mime type that indicates the technical format of the signature. Important mime types are application/signature+xml for X ML DigSig, application/jose for JWS, and image/* for a graphical image of a signature, etc.", 0, 1, sigFormat));
481        children.add(new Property("data", "base64Binary", "The base64 encoding of the Signature content. When signature is not recorded electronically this element would be empty.", 0, 1, data));
482      }
483
484      @Override
485      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
486        switch (_hash) {
487        case 3575610: /*type*/  return new Property("type", "Coding", "An indication of the reason that the entity signed this document. This may be explicitly included as part of the signature information and can be used when determining accountability for various actions concerning the document.", 0, java.lang.Integer.MAX_VALUE, type);
488        case 3648314: /*when*/  return new Property("when", "instant", "When the digital signature was signed.", 0, 1, when);
489        case 117694: /*who*/  return new Property("who", "Reference(Practitioner|PractitionerRole|RelatedPerson|Patient|Device|Organization)", "A reference to an application-usable description of the identity that signed  (e.g. the signature used their private key).", 0, 1, who);
490        case -14402964: /*onBehalfOf*/  return new Property("onBehalfOf", "Reference(Practitioner|PractitionerRole|RelatedPerson|Patient|Device|Organization)", "A reference to an application-usable description of the identity that is represented by the signature.", 0, 1, onBehalfOf);
491        case -917363480: /*targetFormat*/  return new Property("targetFormat", "code", "A mime type that indicates the technical format of the target resources signed by the signature.", 0, 1, targetFormat);
492        case -58720216: /*sigFormat*/  return new Property("sigFormat", "code", "A mime type that indicates the technical format of the signature. Important mime types are application/signature+xml for X ML DigSig, application/jose for JWS, and image/* for a graphical image of a signature, etc.", 0, 1, sigFormat);
493        case 3076010: /*data*/  return new Property("data", "base64Binary", "The base64 encoding of the Signature content. When signature is not recorded electronically this element would be empty.", 0, 1, data);
494        default: return super.getNamedProperty(_hash, _name, _checkValid);
495        }
496
497      }
498
499      @Override
500      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
501        switch (hash) {
502        case 3575610: /*type*/ return this.type == null ? new Base[0] : this.type.toArray(new Base[this.type.size()]); // Coding
503        case 3648314: /*when*/ return this.when == null ? new Base[0] : new Base[] {this.when}; // InstantType
504        case 117694: /*who*/ return this.who == null ? new Base[0] : new Base[] {this.who}; // Reference
505        case -14402964: /*onBehalfOf*/ return this.onBehalfOf == null ? new Base[0] : new Base[] {this.onBehalfOf}; // Reference
506        case -917363480: /*targetFormat*/ return this.targetFormat == null ? new Base[0] : new Base[] {this.targetFormat}; // CodeType
507        case -58720216: /*sigFormat*/ return this.sigFormat == null ? new Base[0] : new Base[] {this.sigFormat}; // CodeType
508        case 3076010: /*data*/ return this.data == null ? new Base[0] : new Base[] {this.data}; // Base64BinaryType
509        default: return super.getProperty(hash, name, checkValid);
510        }
511
512      }
513
514      @Override
515      public Base setProperty(int hash, String name, Base value) throws FHIRException {
516        switch (hash) {
517        case 3575610: // type
518          this.getType().add(castToCoding(value)); // Coding
519          return value;
520        case 3648314: // when
521          this.when = castToInstant(value); // InstantType
522          return value;
523        case 117694: // who
524          this.who = castToReference(value); // Reference
525          return value;
526        case -14402964: // onBehalfOf
527          this.onBehalfOf = castToReference(value); // Reference
528          return value;
529        case -917363480: // targetFormat
530          this.targetFormat = castToCode(value); // CodeType
531          return value;
532        case -58720216: // sigFormat
533          this.sigFormat = castToCode(value); // CodeType
534          return value;
535        case 3076010: // data
536          this.data = castToBase64Binary(value); // Base64BinaryType
537          return value;
538        default: return super.setProperty(hash, name, value);
539        }
540
541      }
542
543      @Override
544      public Base setProperty(String name, Base value) throws FHIRException {
545        if (name.equals("type")) {
546          this.getType().add(castToCoding(value));
547        } else if (name.equals("when")) {
548          this.when = castToInstant(value); // InstantType
549        } else if (name.equals("who")) {
550          this.who = castToReference(value); // Reference
551        } else if (name.equals("onBehalfOf")) {
552          this.onBehalfOf = castToReference(value); // Reference
553        } else if (name.equals("targetFormat")) {
554          this.targetFormat = castToCode(value); // CodeType
555        } else if (name.equals("sigFormat")) {
556          this.sigFormat = castToCode(value); // CodeType
557        } else if (name.equals("data")) {
558          this.data = castToBase64Binary(value); // Base64BinaryType
559        } else
560          return super.setProperty(name, value);
561        return value;
562      }
563
564      @Override
565      public Base makeProperty(int hash, String name) throws FHIRException {
566        switch (hash) {
567        case 3575610:  return addType(); 
568        case 3648314:  return getWhenElement();
569        case 117694:  return getWho(); 
570        case -14402964:  return getOnBehalfOf(); 
571        case -917363480:  return getTargetFormatElement();
572        case -58720216:  return getSigFormatElement();
573        case 3076010:  return getDataElement();
574        default: return super.makeProperty(hash, name);
575        }
576
577      }
578
579      @Override
580      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
581        switch (hash) {
582        case 3575610: /*type*/ return new String[] {"Coding"};
583        case 3648314: /*when*/ return new String[] {"instant"};
584        case 117694: /*who*/ return new String[] {"Reference"};
585        case -14402964: /*onBehalfOf*/ return new String[] {"Reference"};
586        case -917363480: /*targetFormat*/ return new String[] {"code"};
587        case -58720216: /*sigFormat*/ return new String[] {"code"};
588        case 3076010: /*data*/ return new String[] {"base64Binary"};
589        default: return super.getTypesForProperty(hash, name);
590        }
591
592      }
593
594      @Override
595      public Base addChild(String name) throws FHIRException {
596        if (name.equals("type")) {
597          return addType();
598        }
599        else if (name.equals("when")) {
600          throw new FHIRException("Cannot call addChild on a primitive type Signature.when");
601        }
602        else if (name.equals("who")) {
603          this.who = new Reference();
604          return this.who;
605        }
606        else if (name.equals("onBehalfOf")) {
607          this.onBehalfOf = new Reference();
608          return this.onBehalfOf;
609        }
610        else if (name.equals("targetFormat")) {
611          throw new FHIRException("Cannot call addChild on a primitive type Signature.targetFormat");
612        }
613        else if (name.equals("sigFormat")) {
614          throw new FHIRException("Cannot call addChild on a primitive type Signature.sigFormat");
615        }
616        else if (name.equals("data")) {
617          throw new FHIRException("Cannot call addChild on a primitive type Signature.data");
618        }
619        else
620          return super.addChild(name);
621      }
622
623  public String fhirType() {
624    return "Signature";
625
626  }
627
628      public Signature copy() {
629        Signature dst = new Signature();
630        copyValues(dst);
631        if (type != null) {
632          dst.type = new ArrayList<Coding>();
633          for (Coding i : type)
634            dst.type.add(i.copy());
635        };
636        dst.when = when == null ? null : when.copy();
637        dst.who = who == null ? null : who.copy();
638        dst.onBehalfOf = onBehalfOf == null ? null : onBehalfOf.copy();
639        dst.targetFormat = targetFormat == null ? null : targetFormat.copy();
640        dst.sigFormat = sigFormat == null ? null : sigFormat.copy();
641        dst.data = data == null ? null : data.copy();
642        return dst;
643      }
644
645      protected Signature typedCopy() {
646        return copy();
647      }
648
649      @Override
650      public boolean equalsDeep(Base other_) {
651        if (!super.equalsDeep(other_))
652          return false;
653        if (!(other_ instanceof Signature))
654          return false;
655        Signature o = (Signature) other_;
656        return compareDeep(type, o.type, true) && compareDeep(when, o.when, true) && compareDeep(who, o.who, true)
657           && compareDeep(onBehalfOf, o.onBehalfOf, true) && compareDeep(targetFormat, o.targetFormat, true)
658           && compareDeep(sigFormat, o.sigFormat, true) && compareDeep(data, o.data, true);
659      }
660
661      @Override
662      public boolean equalsShallow(Base other_) {
663        if (!super.equalsShallow(other_))
664          return false;
665        if (!(other_ instanceof Signature))
666          return false;
667        Signature o = (Signature) other_;
668        return compareValues(when, o.when, true) && compareValues(targetFormat, o.targetFormat, true) && compareValues(sigFormat, o.sigFormat, true)
669           && compareValues(data, o.data, true);
670      }
671
672      public boolean isEmpty() {
673        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, when, who, onBehalfOf
674          , targetFormat, sigFormat, data);
675      }
676
677
678}
679