001package org.hl7.fhir.r5.openehr;
002
003
004/*
005  Copyright (c) 2011+, HL7, Inc.
006  All rights reserved.
007  
008  Redistribution and use in source and binary forms, with or without modification, \
009  are permitted provided that the following conditions are met:
010  
011   * Redistributions of source code must retain the above copyright notice, this \
012     list of conditions and the following disclaimer.
013   * Redistributions in binary form must reproduce the above copyright notice, \
014     this list of conditions and the following disclaimer in the documentation \
015     and/or other materials provided with the distribution.
016   * Neither the name of HL7 nor the names of its contributors may be used to 
017     endorse or promote products derived from this software without specific 
018     prior written permission.
019  
020  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \
021  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \
022  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \
023  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \
024  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \
025  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \
026  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \
027  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \
028  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \
029  POSSIBILITY OF SUCH DAMAGE.
030  */
031
032// Generated on Thu, Mar 23, 2023 19:59+1100 for FHIR v5.0.0
033
034import java.util.ArrayList;
035import java.util.Date;
036import java.util.List;
037import org.hl7.fhir.utilities.Utilities;
038import org.hl7.fhir.r5.openehr.Enumerations.*;
039import org.hl7.fhir.exceptions.FHIRException;
040import org.hl7.fhir.r5.model.*;
041import org.hl7.fhir.instance.model.api.ICompositeType;
042import ca.uhn.fhir.model.api.annotation.Child;
043import ca.uhn.fhir.model.api.annotation.ChildOrder;
044import ca.uhn.fhir.model.api.annotation.DatatypeDef;
045import ca.uhn.fhir.model.api.annotation.Description;
046import ca.uhn.fhir.model.api.annotation.Block;
047
048/**
049 * Type for representing identifiers of real-world entities. Typical identifiers include drivers licence number, social security number, veterans affairs number, prescription id, order id, and so on. DV_IDENTIFIER is used to represent any identifier of a real thing, issued by some authority or agency.
050 */
051@DatatypeDef(name="DV_IDENTIFIER")
052public class DV_IDENTIFIER extends DATA_VALUE implements ICompositeType {
053
054    /**
055     * Optional authority which issues the kind of id used in the id field of this object.
056     */
057    @Child(name = "issuer", type = {StringType.class}, order=0, min=0, max=1, modifier=false, summary=false)
058    @Description(shortDefinition="Optional authority which issues the kind of id used in the id field of this object", formalDefinition="Optional authority which issues the kind of id used in the id field of this object." )
059    protected StringType issuer;
060
061    /**
062     * Optional organisation that assigned the id to the item being identified.
063     */
064    @Child(name = "assigner", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=false)
065    @Description(shortDefinition="Optional organisation that assigned the id to the item being identified", formalDefinition="Optional organisation that assigned the id to the item being identified." )
066    protected StringType assigner;
067
068    /**
069     * The identifier value. Often structured, according to the definition of the issuing authority?s rules.
070     */
071    @Child(name = "id", type = {StringType.class}, order=2, min=1, max=1, modifier=false, summary=false)
072    @Description(shortDefinition="The identifier value", formalDefinition="The identifier value. Often structured, according to the definition of the issuing authority?s rules." )
073    protected StringType id;
074
075    /**
076     * Optional identifier type, such as prescription, or Social Security Number. One day a controlled vocabulary might be possible for this.
077     */
078    @Child(name = "type", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=false)
079    @Description(shortDefinition="Optional identifier type, such as prescription, or Social Security Number", formalDefinition="Optional identifier type, such as prescription, or Social Security Number. One day a controlled vocabulary might be possible for this." )
080    protected StringType type;
081
082    private static final long serialVersionUID = -1346721174L;
083
084  /**
085   * Constructor
086   */
087    public DV_IDENTIFIER() {
088      super();
089    }
090
091  /**
092   * Constructor
093   */
094    public DV_IDENTIFIER(String id) {
095      super();
096      this.setId(id);
097    }
098
099    /**
100     * @return {@link #issuer} (Optional authority which issues the kind of id used in the id field of this object.). This is the underlying object with id, value and extensions. The accessor "getIssuer" gives direct access to the value
101     */
102    public StringType getIssuerElement() { 
103      if (this.issuer == null)
104        if (Configuration.errorOnAutoCreate())
105          throw new Error("Attempt to auto-create DV_IDENTIFIER.issuer");
106        else if (Configuration.doAutoCreate())
107          this.issuer = new StringType(); // bb
108      return this.issuer;
109    }
110
111    public boolean hasIssuerElement() { 
112      return this.issuer != null && !this.issuer.isEmpty();
113    }
114
115    public boolean hasIssuer() { 
116      return this.issuer != null && !this.issuer.isEmpty();
117    }
118
119    /**
120     * @param value {@link #issuer} (Optional authority which issues the kind of id used in the id field of this object.). This is the underlying object with id, value and extensions. The accessor "getIssuer" gives direct access to the value
121     */
122    public DV_IDENTIFIER setIssuerElement(StringType value) { 
123      this.issuer = value;
124      return this;
125    }
126
127    /**
128     * @return Optional authority which issues the kind of id used in the id field of this object.
129     */
130    public String getIssuer() { 
131      return this.issuer == null ? null : this.issuer.getValue();
132    }
133
134    /**
135     * @param value Optional authority which issues the kind of id used in the id field of this object.
136     */
137    public DV_IDENTIFIER setIssuer(String value) { 
138      if (Utilities.noString(value))
139        this.issuer = null;
140      else {
141        if (this.issuer == null)
142          this.issuer = new StringType();
143        this.issuer.setValue(value);
144      }
145      return this;
146    }
147
148    /**
149     * @return {@link #assigner} (Optional organisation that assigned the id to the item being identified.). This is the underlying object with id, value and extensions. The accessor "getAssigner" gives direct access to the value
150     */
151    public StringType getAssignerElement() { 
152      if (this.assigner == null)
153        if (Configuration.errorOnAutoCreate())
154          throw new Error("Attempt to auto-create DV_IDENTIFIER.assigner");
155        else if (Configuration.doAutoCreate())
156          this.assigner = new StringType(); // bb
157      return this.assigner;
158    }
159
160    public boolean hasAssignerElement() { 
161      return this.assigner != null && !this.assigner.isEmpty();
162    }
163
164    public boolean hasAssigner() { 
165      return this.assigner != null && !this.assigner.isEmpty();
166    }
167
168    /**
169     * @param value {@link #assigner} (Optional organisation that assigned the id to the item being identified.). This is the underlying object with id, value and extensions. The accessor "getAssigner" gives direct access to the value
170     */
171    public DV_IDENTIFIER setAssignerElement(StringType value) { 
172      this.assigner = value;
173      return this;
174    }
175
176    /**
177     * @return Optional organisation that assigned the id to the item being identified.
178     */
179    public String getAssigner() { 
180      return this.assigner == null ? null : this.assigner.getValue();
181    }
182
183    /**
184     * @param value Optional organisation that assigned the id to the item being identified.
185     */
186    public DV_IDENTIFIER setAssigner(String value) { 
187      if (Utilities.noString(value))
188        this.assigner = null;
189      else {
190        if (this.assigner == null)
191          this.assigner = new StringType();
192        this.assigner.setValue(value);
193      }
194      return this;
195    }
196
197    /**
198     * @return {@link #id} (The identifier value. Often structured, according to the definition of the issuing authority?s rules.). This is the underlying object with id, value and extensions. The accessor "getId" gives direct access to the value
199     */
200    public StringType getIdElement() { 
201      if (this.id == null)
202        if (Configuration.errorOnAutoCreate())
203          throw new Error("Attempt to auto-create DV_IDENTIFIER.id");
204        else if (Configuration.doAutoCreate())
205          this.id = new StringType(); // bb
206      return this.id;
207    }
208
209    public boolean hasIdElement() { 
210      return this.id != null && !this.id.isEmpty();
211    }
212
213    public boolean hasId() { 
214      return this.id != null && !this.id.isEmpty();
215    }
216
217    /**
218     * @param value {@link #id} (The identifier value. Often structured, according to the definition of the issuing authority?s rules.). This is the underlying object with id, value and extensions. The accessor "getId" gives direct access to the value
219     */
220    public DV_IDENTIFIER setIdElement(StringType value) { 
221      this.id = value;
222      return this;
223    }
224
225    /**
226     * @return The identifier value. Often structured, according to the definition of the issuing authority?s rules.
227     */
228    public String getId() { 
229      return this.id == null ? null : this.id.getValue();
230    }
231
232    /**
233     * @param value The identifier value. Often structured, according to the definition of the issuing authority?s rules.
234     */
235    public DV_IDENTIFIER setId(String value) { 
236        if (this.id == null)
237          this.id = new StringType();
238        this.id.setValue(value);
239      return this;
240    }
241
242    /**
243     * @return {@link #type} (Optional identifier type, such as prescription, or Social Security Number. One day a controlled vocabulary might be possible for this.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
244     */
245    public StringType getTypeElement() { 
246      if (this.type == null)
247        if (Configuration.errorOnAutoCreate())
248          throw new Error("Attempt to auto-create DV_IDENTIFIER.type");
249        else if (Configuration.doAutoCreate())
250          this.type = new StringType(); // bb
251      return this.type;
252    }
253
254    public boolean hasTypeElement() { 
255      return this.type != null && !this.type.isEmpty();
256    }
257
258    public boolean hasType() { 
259      return this.type != null && !this.type.isEmpty();
260    }
261
262    /**
263     * @param value {@link #type} (Optional identifier type, such as prescription, or Social Security Number. One day a controlled vocabulary might be possible for this.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
264     */
265    public DV_IDENTIFIER setTypeElement(StringType value) { 
266      this.type = value;
267      return this;
268    }
269
270    /**
271     * @return Optional identifier type, such as prescription, or Social Security Number. One day a controlled vocabulary might be possible for this.
272     */
273    public String getType() { 
274      return this.type == null ? null : this.type.getValue();
275    }
276
277    /**
278     * @param value Optional identifier type, such as prescription, or Social Security Number. One day a controlled vocabulary might be possible for this.
279     */
280    public DV_IDENTIFIER setType(String value) { 
281      if (Utilities.noString(value))
282        this.type = null;
283      else {
284        if (this.type == null)
285          this.type = new StringType();
286        this.type.setValue(value);
287      }
288      return this;
289    }
290
291      protected void listChildren(List<Property> children) {
292        super.listChildren(children);
293        children.add(new Property("issuer", "string", "Optional authority which issues the kind of id used in the id field of this object.", 0, 1, issuer));
294        children.add(new Property("assigner", "string", "Optional organisation that assigned the id to the item being identified.", 0, 1, assigner));
295        children.add(new Property("id", "string", "The identifier value. Often structured, according to the definition of the issuing authority?s rules.", 0, 1, id));
296        children.add(new Property("type", "string", "Optional identifier type, such as prescription, or Social Security Number. One day a controlled vocabulary might be possible for this.", 0, 1, type));
297      }
298
299      @Override
300      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
301        switch (_hash) {
302        case -1179159879: /*issuer*/  return new Property("issuer", "string", "Optional authority which issues the kind of id used in the id field of this object.", 0, 1, issuer);
303        case -369881636: /*assigner*/  return new Property("assigner", "string", "Optional organisation that assigned the id to the item being identified.", 0, 1, assigner);
304        case 3355: /*id*/  return new Property("id", "string", "The identifier value. Often structured, according to the definition of the issuing authority?s rules.", 0, 1, id);
305        case 3575610: /*type*/  return new Property("type", "string", "Optional identifier type, such as prescription, or Social Security Number. One day a controlled vocabulary might be possible for this.", 0, 1, type);
306        default: return super.getNamedProperty(_hash, _name, _checkValid);
307        }
308
309      }
310
311      @Override
312      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
313        switch (hash) {
314        case -1179159879: /*issuer*/ return this.issuer == null ? new Base[0] : new Base[] {this.issuer}; // StringType
315        case -369881636: /*assigner*/ return this.assigner == null ? new Base[0] : new Base[] {this.assigner}; // StringType
316        case 3355: /*id*/ return this.id == null ? new Base[0] : new Base[] {this.id}; // StringType
317        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // StringType
318        default: return super.getProperty(hash, name, checkValid);
319        }
320
321      }
322
323      @Override
324      public Base setProperty(int hash, String name, Base value) throws FHIRException {
325        switch (hash) {
326        case -1179159879: // issuer
327          this.issuer = TypeConvertor.castToString(value); // StringType
328          return value;
329        case -369881636: // assigner
330          this.assigner = TypeConvertor.castToString(value); // StringType
331          return value;
332        case 3355: // id
333          this.id = TypeConvertor.castToString(value); // StringType
334          return value;
335        case 3575610: // type
336          this.type = TypeConvertor.castToString(value); // StringType
337          return value;
338        default: return super.setProperty(hash, name, value);
339        }
340
341      }
342
343      @Override
344      public Base setProperty(String name, Base value) throws FHIRException {
345        if (name.equals("issuer")) {
346          this.issuer = TypeConvertor.castToString(value); // StringType
347        } else if (name.equals("assigner")) {
348          this.assigner = TypeConvertor.castToString(value); // StringType
349        } else if (name.equals("id")) {
350          this.id = TypeConvertor.castToString(value); // StringType
351        } else if (name.equals("type")) {
352          this.type = TypeConvertor.castToString(value); // StringType
353        } else
354          return super.setProperty(name, value);
355        return value;
356      }
357
358      @Override
359      public Base makeProperty(int hash, String name) throws FHIRException {
360        switch (hash) {
361        case -1179159879:  return getIssuerElement();
362        case -369881636:  return getAssignerElement();
363        case 3355:  return getIdElement();
364        case 3575610:  return getTypeElement();
365        default: return super.makeProperty(hash, name);
366        }
367
368      }
369
370      @Override
371      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
372        switch (hash) {
373        case -1179159879: /*issuer*/ return new String[] {"string"};
374        case -369881636: /*assigner*/ return new String[] {"string"};
375        case 3355: /*id*/ return new String[] {"string"};
376        case 3575610: /*type*/ return new String[] {"string"};
377        default: return super.getTypesForProperty(hash, name);
378        }
379
380      }
381
382      @Override
383      public Base addChild(String name) throws FHIRException {
384        if (name.equals("issuer")) {
385          throw new FHIRException("Cannot call addChild on a singleton property DV_IDENTIFIER.issuer");
386        }
387        else if (name.equals("assigner")) {
388          throw new FHIRException("Cannot call addChild on a singleton property DV_IDENTIFIER.assigner");
389        }
390        else if (name.equals("id")) {
391          throw new FHIRException("Cannot call addChild on a singleton property DV_IDENTIFIER.id");
392        }
393        else if (name.equals("type")) {
394          throw new FHIRException("Cannot call addChild on a singleton property DV_IDENTIFIER.type");
395        }
396        else
397          return super.addChild(name);
398      }
399
400  public String fhirType() {
401    return "DV_IDENTIFIER";
402
403  }
404
405      public DV_IDENTIFIER copy() {
406        DV_IDENTIFIER dst = new DV_IDENTIFIER();
407        copyValues(dst);
408        return dst;
409      }
410
411      public void copyValues(DV_IDENTIFIER dst) {
412        super.copyValues(dst);
413        dst.issuer = issuer == null ? null : issuer.copy();
414        dst.assigner = assigner == null ? null : assigner.copy();
415        dst.id = id == null ? null : id.copy();
416        dst.type = type == null ? null : type.copy();
417      }
418
419      protected DV_IDENTIFIER typedCopy() {
420        return copy();
421      }
422
423      @Override
424      public boolean equalsDeep(Base other_) {
425        if (!super.equalsDeep(other_))
426          return false;
427        if (!(other_ instanceof DV_IDENTIFIER))
428          return false;
429        DV_IDENTIFIER o = (DV_IDENTIFIER) other_;
430        return compareDeep(issuer, o.issuer, true) && compareDeep(assigner, o.assigner, true) && compareDeep(id, o.id, true)
431           && compareDeep(type, o.type, true);
432      }
433
434      @Override
435      public boolean equalsShallow(Base other_) {
436        if (!super.equalsShallow(other_))
437          return false;
438        if (!(other_ instanceof DV_IDENTIFIER))
439          return false;
440        DV_IDENTIFIER o = (DV_IDENTIFIER) other_;
441        return compareValues(issuer, o.issuer, true) && compareValues(assigner, o.assigner, true) && compareValues(id, o.id, true)
442           && compareValues(type, o.type, true);
443      }
444
445      public boolean isEmpty() {
446        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(issuer, assigner, id, type
447          );
448      }
449
450
451}
452