001package org.hl7.fhir.r5.model;
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 Tue, Dec 28, 2021 07:16+1100 for FHIR v5.0.0-snapshot1
033
034import java.util.ArrayList;
035import java.util.Date;
036import java.util.List;
037import org.hl7.fhir.utilities.Utilities;
038import org.hl7.fhir.r5.model.Enumerations.*;
039import org.hl7.fhir.instance.model.api.IBaseDatatypeElement;
040import org.hl7.fhir.exceptions.FHIRException;
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
048import ca.uhn.fhir.util.DatatypeUtil;
049import  org.hl7.fhir.instance.model.api.IPrimitiveType;
050/**
051 * Base StructureDefinition for HumanName Type: A human's name with the ability to identify parts and usage.
052 */
053@DatatypeDef(name="HumanName")
054public class HumanName extends DataType implements ICompositeType {
055
056    public enum NameUse {
057        /**
058         * Known as/conventional/the one you normally use.
059         */
060        USUAL, 
061        /**
062         * The formal name as registered in an official (government) registry, but which name might not be commonly used. May be called \"legal name\".
063         */
064        OFFICIAL, 
065        /**
066         * A temporary name. Name.period can provide more detailed information. This may also be used for temporary names assigned at birth or in emergency situations.
067         */
068        TEMP, 
069        /**
070         * A name that is used to address the person in an informal manner, but is not part of their formal or usual name.
071         */
072        NICKNAME, 
073        /**
074         * Anonymous assigned name, alias, or pseudonym (used to protect a person's identity for privacy reasons).
075         */
076        ANONYMOUS, 
077        /**
078         * This name is no longer in use (or was never correct, but retained for records).
079         */
080        OLD, 
081        /**
082         * A name used prior to changing name because of marriage. This name use is for use by applications that collect and store names that were used prior to a marriage. Marriage naming customs vary greatly around the world, and are constantly changing. This term is not gender specific. The use of this term does not imply any particular history for a person's name.
083         */
084        MAIDEN, 
085        /**
086         * added to help the parsers with the generic types
087         */
088        NULL;
089        public static NameUse fromCode(String codeString) throws FHIRException {
090            if (codeString == null || "".equals(codeString))
091                return null;
092        if ("usual".equals(codeString))
093          return USUAL;
094        if ("official".equals(codeString))
095          return OFFICIAL;
096        if ("temp".equals(codeString))
097          return TEMP;
098        if ("nickname".equals(codeString))
099          return NICKNAME;
100        if ("anonymous".equals(codeString))
101          return ANONYMOUS;
102        if ("old".equals(codeString))
103          return OLD;
104        if ("maiden".equals(codeString))
105          return MAIDEN;
106        if (Configuration.isAcceptInvalidEnums())
107          return null;
108        else
109          throw new FHIRException("Unknown NameUse code '"+codeString+"'");
110        }
111        public String toCode() {
112          switch (this) {
113            case USUAL: return "usual";
114            case OFFICIAL: return "official";
115            case TEMP: return "temp";
116            case NICKNAME: return "nickname";
117            case ANONYMOUS: return "anonymous";
118            case OLD: return "old";
119            case MAIDEN: return "maiden";
120            default: return "?";
121          }
122        }
123        public String getSystem() {
124          switch (this) {
125            case USUAL: return "http://hl7.org/fhir/name-use";
126            case OFFICIAL: return "http://hl7.org/fhir/name-use";
127            case TEMP: return "http://hl7.org/fhir/name-use";
128            case NICKNAME: return "http://hl7.org/fhir/name-use";
129            case ANONYMOUS: return "http://hl7.org/fhir/name-use";
130            case OLD: return "http://hl7.org/fhir/name-use";
131            case MAIDEN: return "http://hl7.org/fhir/name-use";
132            default: return "?";
133          }
134        }
135        public String getDefinition() {
136          switch (this) {
137            case USUAL: return "Known as/conventional/the one you normally use.";
138            case OFFICIAL: return "The formal name as registered in an official (government) registry, but which name might not be commonly used. May be called \"legal name\".";
139            case TEMP: return "A temporary name. Name.period can provide more detailed information. This may also be used for temporary names assigned at birth or in emergency situations.";
140            case NICKNAME: return "A name that is used to address the person in an informal manner, but is not part of their formal or usual name.";
141            case ANONYMOUS: return "Anonymous assigned name, alias, or pseudonym (used to protect a person's identity for privacy reasons).";
142            case OLD: return "This name is no longer in use (or was never correct, but retained for records).";
143            case MAIDEN: return "A name used prior to changing name because of marriage. This name use is for use by applications that collect and store names that were used prior to a marriage. Marriage naming customs vary greatly around the world, and are constantly changing. This term is not gender specific. The use of this term does not imply any particular history for a person's name.";
144            default: return "?";
145          }
146        }
147        public String getDisplay() {
148          switch (this) {
149            case USUAL: return "Usual";
150            case OFFICIAL: return "Official";
151            case TEMP: return "Temp";
152            case NICKNAME: return "Nickname";
153            case ANONYMOUS: return "Anonymous";
154            case OLD: return "Old";
155            case MAIDEN: return "Name changed for Marriage";
156            default: return "?";
157          }
158        }
159    }
160
161  public static class NameUseEnumFactory implements EnumFactory<NameUse> {
162    public NameUse fromCode(String codeString) throws IllegalArgumentException {
163      if (codeString == null || "".equals(codeString))
164            if (codeString == null || "".equals(codeString))
165                return null;
166        if ("usual".equals(codeString))
167          return NameUse.USUAL;
168        if ("official".equals(codeString))
169          return NameUse.OFFICIAL;
170        if ("temp".equals(codeString))
171          return NameUse.TEMP;
172        if ("nickname".equals(codeString))
173          return NameUse.NICKNAME;
174        if ("anonymous".equals(codeString))
175          return NameUse.ANONYMOUS;
176        if ("old".equals(codeString))
177          return NameUse.OLD;
178        if ("maiden".equals(codeString))
179          return NameUse.MAIDEN;
180        throw new IllegalArgumentException("Unknown NameUse code '"+codeString+"'");
181        }
182        public Enumeration<NameUse> fromType(Base code) throws FHIRException {
183          if (code == null)
184            return null;
185          if (code.isEmpty())
186            return new Enumeration<NameUse>(this);
187          String codeString = ((PrimitiveType) code).asStringValue();
188          if (codeString == null || "".equals(codeString))
189            return null;
190        if ("usual".equals(codeString))
191          return new Enumeration<NameUse>(this, NameUse.USUAL);
192        if ("official".equals(codeString))
193          return new Enumeration<NameUse>(this, NameUse.OFFICIAL);
194        if ("temp".equals(codeString))
195          return new Enumeration<NameUse>(this, NameUse.TEMP);
196        if ("nickname".equals(codeString))
197          return new Enumeration<NameUse>(this, NameUse.NICKNAME);
198        if ("anonymous".equals(codeString))
199          return new Enumeration<NameUse>(this, NameUse.ANONYMOUS);
200        if ("old".equals(codeString))
201          return new Enumeration<NameUse>(this, NameUse.OLD);
202        if ("maiden".equals(codeString))
203          return new Enumeration<NameUse>(this, NameUse.MAIDEN);
204        throw new FHIRException("Unknown NameUse code '"+codeString+"'");
205        }
206    public String toCode(NameUse code) {
207      if (code == NameUse.USUAL)
208        return "usual";
209      if (code == NameUse.OFFICIAL)
210        return "official";
211      if (code == NameUse.TEMP)
212        return "temp";
213      if (code == NameUse.NICKNAME)
214        return "nickname";
215      if (code == NameUse.ANONYMOUS)
216        return "anonymous";
217      if (code == NameUse.OLD)
218        return "old";
219      if (code == NameUse.MAIDEN)
220        return "maiden";
221      return "?";
222      }
223    public String toSystem(NameUse code) {
224      return code.getSystem();
225      }
226    }
227
228    /**
229     * Identifies the purpose for this name.
230     */
231    @Child(name = "use", type = {CodeType.class}, order=0, min=0, max=1, modifier=true, summary=true)
232    @Description(shortDefinition="usual | official | temp | nickname | anonymous | old | maiden", formalDefinition="Identifies the purpose for this name." )
233    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/name-use")
234    protected Enumeration<NameUse> use;
235
236    /**
237     * Specifies the entire name as it should be displayed e.g. on an application UI. This may be provided instead of or as well as the specific parts.
238     */
239    @Child(name = "text", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true)
240    @Description(shortDefinition="Text representation of the full name", formalDefinition="Specifies the entire name as it should be displayed e.g. on an application UI. This may be provided instead of or as well as the specific parts." )
241    protected StringType text;
242
243    /**
244     * The part of a name that links to the genealogy. In some cultures (e.g. Eritrea) the family name of a son is the first name of his father.
245     */
246    @Child(name = "family", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=true)
247    @Description(shortDefinition="Family name (often called 'Surname')", formalDefinition="The part of a name that links to the genealogy. In some cultures (e.g. Eritrea) the family name of a son is the first name of his father." )
248    protected StringType family;
249
250    /**
251     * Given name.
252     */
253    @Child(name = "given", type = {StringType.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
254    @Description(shortDefinition="Given names (not always 'first'). Includes middle names", formalDefinition="Given name." )
255    protected List<StringType> given;
256
257    /**
258     * Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the start of the name.
259     */
260    @Child(name = "prefix", type = {StringType.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
261    @Description(shortDefinition="Parts that come before the name", formalDefinition="Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the start of the name." )
262    protected List<StringType> prefix;
263
264    /**
265     * Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the end of the name.
266     */
267    @Child(name = "suffix", type = {StringType.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
268    @Description(shortDefinition="Parts that come after the name", formalDefinition="Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the end of the name." )
269    protected List<StringType> suffix;
270
271    /**
272     * Indicates the period of time when this name was valid for the named person.
273     */
274    @Child(name = "period", type = {Period.class}, order=6, min=0, max=1, modifier=false, summary=true)
275    @Description(shortDefinition="Time period when name was/is in use", formalDefinition="Indicates the period of time when this name was valid for the named person." )
276    protected Period period;
277
278    private static final long serialVersionUID = -507469160L;
279
280  /**
281   * Constructor
282   */
283    public HumanName() {
284      super();
285    }
286
287    /**
288     * @return {@link #use} (Identifies the purpose for this name.). This is the underlying object with id, value and extensions. The accessor "getUse" gives direct access to the value
289     */
290    public Enumeration<NameUse> getUseElement() { 
291      if (this.use == null)
292        if (Configuration.errorOnAutoCreate())
293          throw new Error("Attempt to auto-create HumanName.use");
294        else if (Configuration.doAutoCreate())
295          this.use = new Enumeration<NameUse>(new NameUseEnumFactory()); // bb
296      return this.use;
297    }
298
299    public boolean hasUseElement() { 
300      return this.use != null && !this.use.isEmpty();
301    }
302
303    public boolean hasUse() { 
304      return this.use != null && !this.use.isEmpty();
305    }
306
307    /**
308     * @param value {@link #use} (Identifies the purpose for this name.). This is the underlying object with id, value and extensions. The accessor "getUse" gives direct access to the value
309     */
310    public HumanName setUseElement(Enumeration<NameUse> value) { 
311      this.use = value;
312      return this;
313    }
314
315    /**
316     * @return Identifies the purpose for this name.
317     */
318    public NameUse getUse() { 
319      return this.use == null ? null : this.use.getValue();
320    }
321
322    /**
323     * @param value Identifies the purpose for this name.
324     */
325    public HumanName setUse(NameUse value) { 
326      if (value == null)
327        this.use = null;
328      else {
329        if (this.use == null)
330          this.use = new Enumeration<NameUse>(new NameUseEnumFactory());
331        this.use.setValue(value);
332      }
333      return this;
334    }
335
336    /**
337     * @return {@link #text} (Specifies the entire name as it should be displayed e.g. on an application UI. This may be provided instead of or as well as the specific parts.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value
338     */
339    public StringType getTextElement() { 
340      if (this.text == null)
341        if (Configuration.errorOnAutoCreate())
342          throw new Error("Attempt to auto-create HumanName.text");
343        else if (Configuration.doAutoCreate())
344          this.text = new StringType(); // bb
345      return this.text;
346    }
347
348    public boolean hasTextElement() { 
349      return this.text != null && !this.text.isEmpty();
350    }
351
352    public boolean hasText() { 
353      return this.text != null && !this.text.isEmpty();
354    }
355
356    /**
357     * @param value {@link #text} (Specifies the entire name as it should be displayed e.g. on an application UI. This may be provided instead of or as well as the specific parts.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value
358     */
359    public HumanName setTextElement(StringType value) { 
360      this.text = value;
361      return this;
362    }
363
364    /**
365     * @return Specifies the entire name as it should be displayed e.g. on an application UI. This may be provided instead of or as well as the specific parts.
366     */
367    public String getText() { 
368      return this.text == null ? null : this.text.getValue();
369    }
370
371    /**
372     * @param value Specifies the entire name as it should be displayed e.g. on an application UI. This may be provided instead of or as well as the specific parts.
373     */
374    public HumanName setText(String value) { 
375      if (Utilities.noString(value))
376        this.text = null;
377      else {
378        if (this.text == null)
379          this.text = new StringType();
380        this.text.setValue(value);
381      }
382      return this;
383    }
384
385    /**
386     * @return {@link #family} (The part of a name that links to the genealogy. In some cultures (e.g. Eritrea) the family name of a son is the first name of his father.). This is the underlying object with id, value and extensions. The accessor "getFamily" gives direct access to the value
387     */
388    public StringType getFamilyElement() { 
389      if (this.family == null)
390        if (Configuration.errorOnAutoCreate())
391          throw new Error("Attempt to auto-create HumanName.family");
392        else if (Configuration.doAutoCreate())
393          this.family = new StringType(); // bb
394      return this.family;
395    }
396
397    public boolean hasFamilyElement() { 
398      return this.family != null && !this.family.isEmpty();
399    }
400
401    public boolean hasFamily() { 
402      return this.family != null && !this.family.isEmpty();
403    }
404
405    /**
406     * @param value {@link #family} (The part of a name that links to the genealogy. In some cultures (e.g. Eritrea) the family name of a son is the first name of his father.). This is the underlying object with id, value and extensions. The accessor "getFamily" gives direct access to the value
407     */
408    public HumanName setFamilyElement(StringType value) { 
409      this.family = value;
410      return this;
411    }
412
413    /**
414     * @return The part of a name that links to the genealogy. In some cultures (e.g. Eritrea) the family name of a son is the first name of his father.
415     */
416    public String getFamily() { 
417      return this.family == null ? null : this.family.getValue();
418    }
419
420    /**
421     * @param value The part of a name that links to the genealogy. In some cultures (e.g. Eritrea) the family name of a son is the first name of his father.
422     */
423    public HumanName setFamily(String value) { 
424      if (Utilities.noString(value))
425        this.family = null;
426      else {
427        if (this.family == null)
428          this.family = new StringType();
429        this.family.setValue(value);
430      }
431      return this;
432    }
433
434    /**
435     * @return {@link #given} (Given name.)
436     */
437    public List<StringType> getGiven() { 
438      if (this.given == null)
439        this.given = new ArrayList<StringType>();
440      return this.given;
441    }
442
443    /**
444     * @return Returns a reference to <code>this</code> for easy method chaining
445     */
446    public HumanName setGiven(List<StringType> theGiven) { 
447      this.given = theGiven;
448      return this;
449    }
450
451    public boolean hasGiven() { 
452      if (this.given == null)
453        return false;
454      for (StringType item : this.given)
455        if (!item.isEmpty())
456          return true;
457      return false;
458    }
459
460    /**
461     * @return {@link #given} (Given name.)
462     */
463    public StringType addGivenElement() {//2 
464      StringType t = new StringType();
465      if (this.given == null)
466        this.given = new ArrayList<StringType>();
467      this.given.add(t);
468      return t;
469    }
470
471    /**
472     * @param value {@link #given} (Given name.)
473     */
474    public HumanName addGiven(String value) { //1
475      StringType t = new StringType();
476      t.setValue(value);
477      if (this.given == null)
478        this.given = new ArrayList<StringType>();
479      this.given.add(t);
480      return this;
481    }
482
483    /**
484     * @param value {@link #given} (Given name.)
485     */
486    public boolean hasGiven(String value) { 
487      if (this.given == null)
488        return false;
489      for (StringType v : this.given)
490        if (v.getValue().equals(value)) // string
491          return true;
492      return false;
493    }
494
495    /**
496     * @return {@link #prefix} (Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the start of the name.)
497     */
498    public List<StringType> getPrefix() { 
499      if (this.prefix == null)
500        this.prefix = new ArrayList<StringType>();
501      return this.prefix;
502    }
503
504    /**
505     * @return Returns a reference to <code>this</code> for easy method chaining
506     */
507    public HumanName setPrefix(List<StringType> thePrefix) { 
508      this.prefix = thePrefix;
509      return this;
510    }
511
512    public boolean hasPrefix() { 
513      if (this.prefix == null)
514        return false;
515      for (StringType item : this.prefix)
516        if (!item.isEmpty())
517          return true;
518      return false;
519    }
520
521    /**
522     * @return {@link #prefix} (Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the start of the name.)
523     */
524    public StringType addPrefixElement() {//2 
525      StringType t = new StringType();
526      if (this.prefix == null)
527        this.prefix = new ArrayList<StringType>();
528      this.prefix.add(t);
529      return t;
530    }
531
532    /**
533     * @param value {@link #prefix} (Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the start of the name.)
534     */
535    public HumanName addPrefix(String value) { //1
536      StringType t = new StringType();
537      t.setValue(value);
538      if (this.prefix == null)
539        this.prefix = new ArrayList<StringType>();
540      this.prefix.add(t);
541      return this;
542    }
543
544    /**
545     * @param value {@link #prefix} (Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the start of the name.)
546     */
547    public boolean hasPrefix(String value) { 
548      if (this.prefix == null)
549        return false;
550      for (StringType v : this.prefix)
551        if (v.getValue().equals(value)) // string
552          return true;
553      return false;
554    }
555
556    /**
557     * @return {@link #suffix} (Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the end of the name.)
558     */
559    public List<StringType> getSuffix() { 
560      if (this.suffix == null)
561        this.suffix = new ArrayList<StringType>();
562      return this.suffix;
563    }
564
565    /**
566     * @return Returns a reference to <code>this</code> for easy method chaining
567     */
568    public HumanName setSuffix(List<StringType> theSuffix) { 
569      this.suffix = theSuffix;
570      return this;
571    }
572
573    public boolean hasSuffix() { 
574      if (this.suffix == null)
575        return false;
576      for (StringType item : this.suffix)
577        if (!item.isEmpty())
578          return true;
579      return false;
580    }
581
582    /**
583     * @return {@link #suffix} (Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the end of the name.)
584     */
585    public StringType addSuffixElement() {//2 
586      StringType t = new StringType();
587      if (this.suffix == null)
588        this.suffix = new ArrayList<StringType>();
589      this.suffix.add(t);
590      return t;
591    }
592
593    /**
594     * @param value {@link #suffix} (Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the end of the name.)
595     */
596    public HumanName addSuffix(String value) { //1
597      StringType t = new StringType();
598      t.setValue(value);
599      if (this.suffix == null)
600        this.suffix = new ArrayList<StringType>();
601      this.suffix.add(t);
602      return this;
603    }
604
605    /**
606     * @param value {@link #suffix} (Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the end of the name.)
607     */
608    public boolean hasSuffix(String value) { 
609      if (this.suffix == null)
610        return false;
611      for (StringType v : this.suffix)
612        if (v.getValue().equals(value)) // string
613          return true;
614      return false;
615    }
616
617    /**
618     * @return {@link #period} (Indicates the period of time when this name was valid for the named person.)
619     */
620    public Period getPeriod() { 
621      if (this.period == null)
622        if (Configuration.errorOnAutoCreate())
623          throw new Error("Attempt to auto-create HumanName.period");
624        else if (Configuration.doAutoCreate())
625          this.period = new Period(); // cc
626      return this.period;
627    }
628
629    public boolean hasPeriod() { 
630      return this.period != null && !this.period.isEmpty();
631    }
632
633    /**
634     * @param value {@link #period} (Indicates the period of time when this name was valid for the named person.)
635     */
636    public HumanName setPeriod(Period value) { 
637      this.period = value;
638      return this;
639    }
640
641      protected void listChildren(List<Property> children) {
642        super.listChildren(children);
643        children.add(new Property("use", "code", "Identifies the purpose for this name.", 0, 1, use));
644        children.add(new Property("text", "string", "Specifies the entire name as it should be displayed e.g. on an application UI. This may be provided instead of or as well as the specific parts.", 0, 1, text));
645        children.add(new Property("family", "string", "The part of a name that links to the genealogy. In some cultures (e.g. Eritrea) the family name of a son is the first name of his father.", 0, 1, family));
646        children.add(new Property("given", "string", "Given name.", 0, java.lang.Integer.MAX_VALUE, given));
647        children.add(new Property("prefix", "string", "Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the start of the name.", 0, java.lang.Integer.MAX_VALUE, prefix));
648        children.add(new Property("suffix", "string", "Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the end of the name.", 0, java.lang.Integer.MAX_VALUE, suffix));
649        children.add(new Property("period", "Period", "Indicates the period of time when this name was valid for the named person.", 0, 1, period));
650      }
651
652      @Override
653      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
654        switch (_hash) {
655        case 116103: /*use*/  return new Property("use", "code", "Identifies the purpose for this name.", 0, 1, use);
656        case 3556653: /*text*/  return new Property("text", "string", "Specifies the entire name as it should be displayed e.g. on an application UI. This may be provided instead of or as well as the specific parts.", 0, 1, text);
657        case -1281860764: /*family*/  return new Property("family", "string", "The part of a name that links to the genealogy. In some cultures (e.g. Eritrea) the family name of a son is the first name of his father.", 0, 1, family);
658        case 98367357: /*given*/  return new Property("given", "string", "Given name.", 0, java.lang.Integer.MAX_VALUE, given);
659        case -980110702: /*prefix*/  return new Property("prefix", "string", "Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the start of the name.", 0, java.lang.Integer.MAX_VALUE, prefix);
660        case -891422895: /*suffix*/  return new Property("suffix", "string", "Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the end of the name.", 0, java.lang.Integer.MAX_VALUE, suffix);
661        case -991726143: /*period*/  return new Property("period", "Period", "Indicates the period of time when this name was valid for the named person.", 0, 1, period);
662        default: return super.getNamedProperty(_hash, _name, _checkValid);
663        }
664
665      }
666
667      @Override
668      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
669        switch (hash) {
670        case 116103: /*use*/ return this.use == null ? new Base[0] : new Base[] {this.use}; // Enumeration<NameUse>
671        case 3556653: /*text*/ return this.text == null ? new Base[0] : new Base[] {this.text}; // StringType
672        case -1281860764: /*family*/ return this.family == null ? new Base[0] : new Base[] {this.family}; // StringType
673        case 98367357: /*given*/ return this.given == null ? new Base[0] : this.given.toArray(new Base[this.given.size()]); // StringType
674        case -980110702: /*prefix*/ return this.prefix == null ? new Base[0] : this.prefix.toArray(new Base[this.prefix.size()]); // StringType
675        case -891422895: /*suffix*/ return this.suffix == null ? new Base[0] : this.suffix.toArray(new Base[this.suffix.size()]); // StringType
676        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
677        default: return super.getProperty(hash, name, checkValid);
678        }
679
680      }
681
682      @Override
683      public Base setProperty(int hash, String name, Base value) throws FHIRException {
684        switch (hash) {
685        case 116103: // use
686          value = new NameUseEnumFactory().fromType(TypeConvertor.castToCode(value));
687          this.use = (Enumeration) value; // Enumeration<NameUse>
688          return value;
689        case 3556653: // text
690          this.text = TypeConvertor.castToString(value); // StringType
691          return value;
692        case -1281860764: // family
693          this.family = TypeConvertor.castToString(value); // StringType
694          return value;
695        case 98367357: // given
696          this.getGiven().add(TypeConvertor.castToString(value)); // StringType
697          return value;
698        case -980110702: // prefix
699          this.getPrefix().add(TypeConvertor.castToString(value)); // StringType
700          return value;
701        case -891422895: // suffix
702          this.getSuffix().add(TypeConvertor.castToString(value)); // StringType
703          return value;
704        case -991726143: // period
705          this.period = TypeConvertor.castToPeriod(value); // Period
706          return value;
707        default: return super.setProperty(hash, name, value);
708        }
709
710      }
711
712      @Override
713      public Base setProperty(String name, Base value) throws FHIRException {
714        if (name.equals("use")) {
715          value = new NameUseEnumFactory().fromType(TypeConvertor.castToCode(value));
716          this.use = (Enumeration) value; // Enumeration<NameUse>
717        } else if (name.equals("text")) {
718          this.text = TypeConvertor.castToString(value); // StringType
719        } else if (name.equals("family")) {
720          this.family = TypeConvertor.castToString(value); // StringType
721        } else if (name.equals("given")) {
722          this.getGiven().add(TypeConvertor.castToString(value));
723        } else if (name.equals("prefix")) {
724          this.getPrefix().add(TypeConvertor.castToString(value));
725        } else if (name.equals("suffix")) {
726          this.getSuffix().add(TypeConvertor.castToString(value));
727        } else if (name.equals("period")) {
728          this.period = TypeConvertor.castToPeriod(value); // Period
729        } else
730          return super.setProperty(name, value);
731        return value;
732      }
733
734      @Override
735      public Base makeProperty(int hash, String name) throws FHIRException {
736        switch (hash) {
737        case 116103:  return getUseElement();
738        case 3556653:  return getTextElement();
739        case -1281860764:  return getFamilyElement();
740        case 98367357:  return addGivenElement();
741        case -980110702:  return addPrefixElement();
742        case -891422895:  return addSuffixElement();
743        case -991726143:  return getPeriod();
744        default: return super.makeProperty(hash, name);
745        }
746
747      }
748
749      @Override
750      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
751        switch (hash) {
752        case 116103: /*use*/ return new String[] {"code"};
753        case 3556653: /*text*/ return new String[] {"string"};
754        case -1281860764: /*family*/ return new String[] {"string"};
755        case 98367357: /*given*/ return new String[] {"string"};
756        case -980110702: /*prefix*/ return new String[] {"string"};
757        case -891422895: /*suffix*/ return new String[] {"string"};
758        case -991726143: /*period*/ return new String[] {"Period"};
759        default: return super.getTypesForProperty(hash, name);
760        }
761
762      }
763
764      @Override
765      public Base addChild(String name) throws FHIRException {
766        if (name.equals("use")) {
767          throw new FHIRException("Cannot call addChild on a primitive type HumanName.use");
768        }
769        else if (name.equals("text")) {
770          throw new FHIRException("Cannot call addChild on a primitive type HumanName.text");
771        }
772        else if (name.equals("family")) {
773          throw new FHIRException("Cannot call addChild on a primitive type HumanName.family");
774        }
775        else if (name.equals("given")) {
776          throw new FHIRException("Cannot call addChild on a primitive type HumanName.given");
777        }
778        else if (name.equals("prefix")) {
779          throw new FHIRException("Cannot call addChild on a primitive type HumanName.prefix");
780        }
781        else if (name.equals("suffix")) {
782          throw new FHIRException("Cannot call addChild on a primitive type HumanName.suffix");
783        }
784        else if (name.equals("period")) {
785          this.period = new Period();
786          return this.period;
787        }
788        else
789          return super.addChild(name);
790      }
791
792  public String fhirType() {
793    return "HumanName";
794
795  }
796
797      public HumanName copy() {
798        HumanName dst = new HumanName();
799        copyValues(dst);
800        return dst;
801      }
802
803      public void copyValues(HumanName dst) {
804        super.copyValues(dst);
805        dst.use = use == null ? null : use.copy();
806        dst.text = text == null ? null : text.copy();
807        dst.family = family == null ? null : family.copy();
808        if (given != null) {
809          dst.given = new ArrayList<StringType>();
810          for (StringType i : given)
811            dst.given.add(i.copy());
812        };
813        if (prefix != null) {
814          dst.prefix = new ArrayList<StringType>();
815          for (StringType i : prefix)
816            dst.prefix.add(i.copy());
817        };
818        if (suffix != null) {
819          dst.suffix = new ArrayList<StringType>();
820          for (StringType i : suffix)
821            dst.suffix.add(i.copy());
822        };
823        dst.period = period == null ? null : period.copy();
824      }
825
826      protected HumanName typedCopy() {
827        return copy();
828      }
829
830      @Override
831      public boolean equalsDeep(Base other_) {
832        if (!super.equalsDeep(other_))
833          return false;
834        if (!(other_ instanceof HumanName))
835          return false;
836        HumanName o = (HumanName) other_;
837        return compareDeep(use, o.use, true) && compareDeep(text, o.text, true) && compareDeep(family, o.family, true)
838           && compareDeep(given, o.given, true) && compareDeep(prefix, o.prefix, true) && compareDeep(suffix, o.suffix, true)
839           && compareDeep(period, o.period, true);
840      }
841
842      @Override
843      public boolean equalsShallow(Base other_) {
844        if (!super.equalsShallow(other_))
845          return false;
846        if (!(other_ instanceof HumanName))
847          return false;
848        HumanName o = (HumanName) other_;
849        return compareValues(use, o.use, true) && compareValues(text, o.text, true) && compareValues(family, o.family, true)
850           && compareValues(given, o.given, true) && compareValues(prefix, o.prefix, true) && compareValues(suffix, o.suffix, true)
851          ;
852      }
853
854      public boolean isEmpty() {
855        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(use, text, family, given
856          , prefix, suffix, period);
857      }
858
859// Manual code (from Configuration.txt):
860/** 
861  /** 
862   * Returns all repetitions of {@link #getGiven() given name} as a space separated string 
863   *  
864   * @see DatatypeUtil#joinStringsSpaceSeparated(List) 
865   */ 
866  public String getGivenAsSingleString() { 
867    return joinStringsSpaceSeparated(getGiven()); 
868  } 
869
870  /** 
871   * Returns all repetitions of {@link #getPrefix() prefix name} as a space separated string 
872   *  
873   * @see DatatypeUtil#joinStringsSpaceSeparated(List) 
874   */ 
875  public String getPrefixAsSingleString() { 
876    return joinStringsSpaceSeparated(getPrefix()); 
877  } 
878
879  /** 
880   * Returns all repetitions of {@link #getSuffix() suffix} as a space separated string 
881   *  
882   * @see DatatypeUtil#joinStringsSpaceSeparated(List) 
883   */ 
884  public String getSuffixAsSingleString() { 
885    return joinStringsSpaceSeparated(getSuffix()); 
886  } 
887
888  /** 
889   * Returns all of the components of the name (prefix, given, family, suffix) as a single string with a single spaced 
890   * string separating each part. 
891   * <p> 
892   * If none of the parts are populated, returns the {@link #getTextElement() text} element value instead. 
893   * </p> 
894   */ 
895  public String getNameAsSingleString() { 
896    List<StringType> nameParts = new ArrayList<StringType>(); 
897    nameParts.addAll(getPrefix()); 
898    nameParts.addAll(getGiven()); 
899    nameParts.add(getFamilyElement()); 
900    nameParts.addAll(getSuffix()); 
901    if (nameParts.size() > 0) { 
902      return joinStringsSpaceSeparated(nameParts); 
903    } else { 
904      return getTextElement().getValue(); 
905    } 
906  } 
907
908  /** 
909   * Joins a list of strings with a single space (' ') between each string 
910   *  
911   * TODO: replace with call to ca.uhn.fhir.util.DatatypeUtil.joinStringsSpaceSeparated when HAPI upgrades to 1.4 
912   */ 
913  private static String joinStringsSpaceSeparated(List<? extends IPrimitiveType<String>> theStrings) { 
914    StringBuilder b = new StringBuilder(); 
915    for (IPrimitiveType<String> next : theStrings) { 
916      if (next.isEmpty()) { 
917        continue; 
918      } 
919      if (b.length() > 0) { 
920        b.append(' '); 
921      } 
922      b.append(next.getValue()); 
923    } 
924    return b.toString(); 
925  }
926// end addition
927
928}
929