001package org.hl7.fhir.dstu2016may.model;
002
003
004
005
006/*
007  Copyright (c) 2011+, HL7, Inc.
008  All rights reserved.
009  
010  Redistribution and use in source and binary forms, with or without modification, 
011  are permitted provided that the following conditions are met:
012  
013   * Redistributions of source code must retain the above copyright notice, this 
014     list of conditions and the following disclaimer.
015   * Redistributions in binary form must reproduce the above copyright notice, 
016     this list of conditions and the following disclaimer in the documentation 
017     and/or other materials provided with the distribution.
018   * Neither the name of HL7 nor the names of its contributors may be used to 
019     endorse or promote products derived from this software without specific 
020     prior written permission.
021  
022  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
023  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
024  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
025  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
026  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
027  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
028  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
029  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
030  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
031  POSSIBILITY OF SUCH DAMAGE.
032  
033*/
034
035// Generated on Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
036import java.util.ArrayList;
037import java.util.List;
038
039import org.hl7.fhir.exceptions.FHIRException;
040import org.hl7.fhir.instance.model.api.ICompositeType;
041import org.hl7.fhir.instance.model.api.IPrimitiveType;
042import org.hl7.fhir.utilities.Utilities;
043
044import ca.uhn.fhir.model.api.annotation.Child;
045import ca.uhn.fhir.model.api.annotation.DatatypeDef;
046import ca.uhn.fhir.model.api.annotation.Description;
047import ca.uhn.fhir.util.DatatypeUtil;
048/**
049 * A human's name with the ability to identify parts and usage.
050 */
051@DatatypeDef(name="HumanName")
052public class HumanName extends Type implements ICompositeType {
053
054    public enum NameUse {
055        /**
056         * Known as/conventional/the one you normally use
057         */
058        USUAL, 
059        /**
060         * The formal name as registered in an official (government) registry, but which name might not be commonly used. May be called "legal name".
061         */
062        OFFICIAL, 
063        /**
064         * 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.
065         */
066        TEMP, 
067        /**
068         * A name that is used to address the person in an informal manner, but is not part of their formal or usual name
069         */
070        NICKNAME, 
071        /**
072         * Anonymous assigned name, alias, or pseudonym (used to protect a person's identity for privacy reasons)
073         */
074        ANONYMOUS, 
075        /**
076         * This name is no longer in use (or was never correct, but retained for records)
077         */
078        OLD, 
079        /**
080         * A name used prior to marriage. Marriage naming customs vary greatly around the world. This name use is for use by applications that collect and store "maiden" names. Though the concept of maiden name is often gender specific, the use of this term is not gender specific. The use of this term does not imply any particular history for a person's name, nor should the maiden name be determined algorithmically.
081         */
082        MAIDEN, 
083        /**
084         * added to help the parsers
085         */
086        NULL;
087        public static NameUse fromCode(String codeString) throws FHIRException {
088            if (codeString == null || "".equals(codeString))
089                return null;
090        if ("usual".equals(codeString))
091          return USUAL;
092        if ("official".equals(codeString))
093          return OFFICIAL;
094        if ("temp".equals(codeString))
095          return TEMP;
096        if ("nickname".equals(codeString))
097          return NICKNAME;
098        if ("anonymous".equals(codeString))
099          return ANONYMOUS;
100        if ("old".equals(codeString))
101          return OLD;
102        if ("maiden".equals(codeString))
103          return MAIDEN;
104        throw new FHIRException("Unknown NameUse code '"+codeString+"'");
105        }
106        public String toCode() {
107          switch (this) {
108            case USUAL: return "usual";
109            case OFFICIAL: return "official";
110            case TEMP: return "temp";
111            case NICKNAME: return "nickname";
112            case ANONYMOUS: return "anonymous";
113            case OLD: return "old";
114            case MAIDEN: return "maiden";
115            case NULL: return null;
116            default: return "?";
117          }
118        }
119        public String getSystem() {
120          switch (this) {
121            case USUAL: return "http://hl7.org/fhir/name-use";
122            case OFFICIAL: return "http://hl7.org/fhir/name-use";
123            case TEMP: return "http://hl7.org/fhir/name-use";
124            case NICKNAME: return "http://hl7.org/fhir/name-use";
125            case ANONYMOUS: return "http://hl7.org/fhir/name-use";
126            case OLD: return "http://hl7.org/fhir/name-use";
127            case MAIDEN: return "http://hl7.org/fhir/name-use";
128            case NULL: return null;
129            default: return "?";
130          }
131        }
132        public String getDefinition() {
133          switch (this) {
134            case USUAL: return "Known as/conventional/the one you normally use";
135            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\".";
136            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.";
137            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";
138            case ANONYMOUS: return "Anonymous assigned name, alias, or pseudonym (used to protect a person's identity for privacy reasons)";
139            case OLD: return "This name is no longer in use (or was never correct, but retained for records)";
140            case MAIDEN: return "A name used prior to marriage. Marriage naming customs vary greatly around the world. This name use is for use by applications that collect and store \"maiden\" names. Though the concept of maiden name is often gender specific, the use of this term is not gender specific. The use of this term does not imply any particular history for a person's name, nor should the maiden name be determined algorithmically.";
141            case NULL: return null;
142            default: return "?";
143          }
144        }
145        public String getDisplay() {
146          switch (this) {
147            case USUAL: return "Usual";
148            case OFFICIAL: return "Official";
149            case TEMP: return "Temp";
150            case NICKNAME: return "Nickname";
151            case ANONYMOUS: return "Anonymous";
152            case OLD: return "Old";
153            case MAIDEN: return "Maiden";
154            case NULL: return null;
155            default: return "?";
156          }
157        }
158    }
159
160  public static class NameUseEnumFactory implements EnumFactory<NameUse> {
161    public NameUse fromCode(String codeString) throws IllegalArgumentException {
162      if (codeString == null || "".equals(codeString))
163            if (codeString == null || "".equals(codeString))
164                return null;
165        if ("usual".equals(codeString))
166          return NameUse.USUAL;
167        if ("official".equals(codeString))
168          return NameUse.OFFICIAL;
169        if ("temp".equals(codeString))
170          return NameUse.TEMP;
171        if ("nickname".equals(codeString))
172          return NameUse.NICKNAME;
173        if ("anonymous".equals(codeString))
174          return NameUse.ANONYMOUS;
175        if ("old".equals(codeString))
176          return NameUse.OLD;
177        if ("maiden".equals(codeString))
178          return NameUse.MAIDEN;
179        throw new IllegalArgumentException("Unknown NameUse code '"+codeString+"'");
180        }
181        public Enumeration<NameUse> fromType(Base code) throws FHIRException {
182          if (code == null || code.isEmpty())
183            return null;
184          String codeString = ((PrimitiveType) code).asStringValue();
185          if (codeString == null || "".equals(codeString))
186            return null;
187        if ("usual".equals(codeString))
188          return new Enumeration<NameUse>(this, NameUse.USUAL);
189        if ("official".equals(codeString))
190          return new Enumeration<NameUse>(this, NameUse.OFFICIAL);
191        if ("temp".equals(codeString))
192          return new Enumeration<NameUse>(this, NameUse.TEMP);
193        if ("nickname".equals(codeString))
194          return new Enumeration<NameUse>(this, NameUse.NICKNAME);
195        if ("anonymous".equals(codeString))
196          return new Enumeration<NameUse>(this, NameUse.ANONYMOUS);
197        if ("old".equals(codeString))
198          return new Enumeration<NameUse>(this, NameUse.OLD);
199        if ("maiden".equals(codeString))
200          return new Enumeration<NameUse>(this, NameUse.MAIDEN);
201        throw new FHIRException("Unknown NameUse code '"+codeString+"'");
202        }
203    public String toCode(NameUse code) {
204      if (code == NameUse.USUAL)
205        return "usual";
206      if (code == NameUse.OFFICIAL)
207        return "official";
208      if (code == NameUse.TEMP)
209        return "temp";
210      if (code == NameUse.NICKNAME)
211        return "nickname";
212      if (code == NameUse.ANONYMOUS)
213        return "anonymous";
214      if (code == NameUse.OLD)
215        return "old";
216      if (code == NameUse.MAIDEN)
217        return "maiden";
218      return "?";
219      }
220    public String toSystem(NameUse code) {
221      return code.getSystem();
222      }
223    }
224
225    /**
226     * Identifies the purpose for this name.
227     */
228    @Child(name = "use", type = {CodeType.class}, order=0, min=0, max=1, modifier=true, summary=true)
229    @Description(shortDefinition="usual | official | temp | nickname | anonymous | old | maiden", formalDefinition="Identifies the purpose for this name." )
230    protected Enumeration<NameUse> use;
231
232    /**
233     * A full text representation of the name.
234     */
235    @Child(name = "text", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true)
236    @Description(shortDefinition="Text representation of the full name", formalDefinition="A full text representation of the name." )
237    protected StringType text;
238
239    /**
240     * 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.
241     */
242    @Child(name = "family", type = {StringType.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
243    @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." )
244    protected List<StringType> family;
245
246    /**
247     * Given name.
248     */
249    @Child(name = "given", type = {StringType.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
250    @Description(shortDefinition="Given names (not always 'first'). Includes middle names", formalDefinition="Given name." )
251    protected List<StringType> given;
252
253    /**
254     * 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.
255     */
256    @Child(name = "prefix", type = {StringType.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
257    @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." )
258    protected List<StringType> prefix;
259
260    /**
261     * 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.
262     */
263    @Child(name = "suffix", type = {StringType.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
264    @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." )
265    protected List<StringType> suffix;
266
267    /**
268     * Indicates the period of time when this name was valid for the named person.
269     */
270    @Child(name = "period", type = {Period.class}, order=6, min=0, max=1, modifier=false, summary=true)
271    @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." )
272    protected Period period;
273
274    private static final long serialVersionUID = -210174642L;
275
276  /**
277   * Constructor
278   */
279    public HumanName() {
280      super();
281    }
282
283    /**
284     * @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
285     */
286    public Enumeration<NameUse> getUseElement() { 
287      if (this.use == null)
288        if (Configuration.errorOnAutoCreate())
289          throw new Error("Attempt to auto-create HumanName.use");
290        else if (Configuration.doAutoCreate())
291          this.use = new Enumeration<NameUse>(new NameUseEnumFactory()); // bb
292      return this.use;
293    }
294
295    public boolean hasUseElement() { 
296      return this.use != null && !this.use.isEmpty();
297    }
298
299    public boolean hasUse() { 
300      return this.use != null && !this.use.isEmpty();
301    }
302
303    /**
304     * @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
305     */
306    public HumanName setUseElement(Enumeration<NameUse> value) { 
307      this.use = value;
308      return this;
309    }
310
311    /**
312     * @return Identifies the purpose for this name.
313     */
314    public NameUse getUse() { 
315      return this.use == null ? null : this.use.getValue();
316    }
317
318    /**
319     * @param value Identifies the purpose for this name.
320     */
321    public HumanName setUse(NameUse value) { 
322      if (value == null)
323        this.use = null;
324      else {
325        if (this.use == null)
326          this.use = new Enumeration<NameUse>(new NameUseEnumFactory());
327        this.use.setValue(value);
328      }
329      return this;
330    }
331
332    /**
333     * @return {@link #text} (A full text representation of the name.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value
334     */
335    public StringType getTextElement() { 
336      if (this.text == null)
337        if (Configuration.errorOnAutoCreate())
338          throw new Error("Attempt to auto-create HumanName.text");
339        else if (Configuration.doAutoCreate())
340          this.text = new StringType(); // bb
341      return this.text;
342    }
343
344    public boolean hasTextElement() { 
345      return this.text != null && !this.text.isEmpty();
346    }
347
348    public boolean hasText() { 
349      return this.text != null && !this.text.isEmpty();
350    }
351
352    /**
353     * @param value {@link #text} (A full text representation of the name.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value
354     */
355    public HumanName setTextElement(StringType value) { 
356      this.text = value;
357      return this;
358    }
359
360    /**
361     * @return A full text representation of the name.
362     */
363    public String getText() { 
364      return this.text == null ? null : this.text.getValue();
365    }
366
367    /**
368     * @param value A full text representation of the name.
369     */
370    public HumanName setText(String value) { 
371      if (Utilities.noString(value))
372        this.text = null;
373      else {
374        if (this.text == null)
375          this.text = new StringType();
376        this.text.setValue(value);
377      }
378      return this;
379    }
380
381    /**
382     * @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.)
383     */
384    public List<StringType> getFamily() { 
385      if (this.family == null)
386        this.family = new ArrayList<StringType>();
387      return this.family;
388    }
389
390    public boolean hasFamily() { 
391      if (this.family == null)
392        return false;
393      for (StringType item : this.family)
394        if (!item.isEmpty())
395          return true;
396      return false;
397    }
398
399    /**
400     * @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.)
401     */
402    // syntactic sugar
403    public StringType addFamilyElement() {//2 
404      StringType t = new StringType();
405      if (this.family == null)
406        this.family = new ArrayList<StringType>();
407      this.family.add(t);
408      return t;
409    }
410
411    /**
412     * @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.)
413     */
414    public HumanName addFamily(String value) { //1
415      StringType t = new StringType();
416      t.setValue(value);
417      if (this.family == null)
418        this.family = new ArrayList<StringType>();
419      this.family.add(t);
420      return this;
421    }
422
423    /**
424     * @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.)
425     */
426    public boolean hasFamily(String value) { 
427      if (this.family == null)
428        return false;
429      for (StringType v : this.family)
430        if (v.equals(value)) // string
431          return true;
432      return false;
433    }
434
435    /**
436     * @return {@link #given} (Given name.)
437     */
438    public List<StringType> getGiven() { 
439      if (this.given == null)
440        this.given = new ArrayList<StringType>();
441      return this.given;
442    }
443
444    public boolean hasGiven() { 
445      if (this.given == null)
446        return false;
447      for (StringType item : this.given)
448        if (!item.isEmpty())
449          return true;
450      return false;
451    }
452
453    /**
454     * @return {@link #given} (Given name.)
455     */
456    // syntactic sugar
457    public StringType addGivenElement() {//2 
458      StringType t = new StringType();
459      if (this.given == null)
460        this.given = new ArrayList<StringType>();
461      this.given.add(t);
462      return t;
463    }
464
465    /**
466     * @param value {@link #given} (Given name.)
467     */
468    public HumanName addGiven(String value) { //1
469      StringType t = new StringType();
470      t.setValue(value);
471      if (this.given == null)
472        this.given = new ArrayList<StringType>();
473      this.given.add(t);
474      return this;
475    }
476
477    /**
478     * @param value {@link #given} (Given name.)
479     */
480    public boolean hasGiven(String value) { 
481      if (this.given == null)
482        return false;
483      for (StringType v : this.given)
484        if (v.equals(value)) // string
485          return true;
486      return false;
487    }
488
489    /**
490     * @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.)
491     */
492    public List<StringType> getPrefix() { 
493      if (this.prefix == null)
494        this.prefix = new ArrayList<StringType>();
495      return this.prefix;
496    }
497
498    public boolean hasPrefix() { 
499      if (this.prefix == null)
500        return false;
501      for (StringType item : this.prefix)
502        if (!item.isEmpty())
503          return true;
504      return false;
505    }
506
507    /**
508     * @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.)
509     */
510    // syntactic sugar
511    public StringType addPrefixElement() {//2 
512      StringType t = new StringType();
513      if (this.prefix == null)
514        this.prefix = new ArrayList<StringType>();
515      this.prefix.add(t);
516      return t;
517    }
518
519    /**
520     * @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.)
521     */
522    public HumanName addPrefix(String value) { //1
523      StringType t = new StringType();
524      t.setValue(value);
525      if (this.prefix == null)
526        this.prefix = new ArrayList<StringType>();
527      this.prefix.add(t);
528      return this;
529    }
530
531    /**
532     * @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.)
533     */
534    public boolean hasPrefix(String value) { 
535      if (this.prefix == null)
536        return false;
537      for (StringType v : this.prefix)
538        if (v.equals(value)) // string
539          return true;
540      return false;
541    }
542
543    /**
544     * @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.)
545     */
546    public List<StringType> getSuffix() { 
547      if (this.suffix == null)
548        this.suffix = new ArrayList<StringType>();
549      return this.suffix;
550    }
551
552    public boolean hasSuffix() { 
553      if (this.suffix == null)
554        return false;
555      for (StringType item : this.suffix)
556        if (!item.isEmpty())
557          return true;
558      return false;
559    }
560
561    /**
562     * @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.)
563     */
564    // syntactic sugar
565    public StringType addSuffixElement() {//2 
566      StringType t = new StringType();
567      if (this.suffix == null)
568        this.suffix = new ArrayList<StringType>();
569      this.suffix.add(t);
570      return t;
571    }
572
573    /**
574     * @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.)
575     */
576    public HumanName addSuffix(String value) { //1
577      StringType t = new StringType();
578      t.setValue(value);
579      if (this.suffix == null)
580        this.suffix = new ArrayList<StringType>();
581      this.suffix.add(t);
582      return this;
583    }
584
585    /**
586     * @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.)
587     */
588    public boolean hasSuffix(String value) { 
589      if (this.suffix == null)
590        return false;
591      for (StringType v : this.suffix)
592        if (v.equals(value)) // string
593          return true;
594      return false;
595    }
596
597    /**
598     * @return {@link #period} (Indicates the period of time when this name was valid for the named person.)
599     */
600    public Period getPeriod() { 
601      if (this.period == null)
602        if (Configuration.errorOnAutoCreate())
603          throw new Error("Attempt to auto-create HumanName.period");
604        else if (Configuration.doAutoCreate())
605          this.period = new Period(); // cc
606      return this.period;
607    }
608
609    public boolean hasPeriod() { 
610      return this.period != null && !this.period.isEmpty();
611    }
612
613    /**
614     * @param value {@link #period} (Indicates the period of time when this name was valid for the named person.)
615     */
616    public HumanName setPeriod(Period value) { 
617      this.period = value;
618      return this;
619    }
620
621 /**
622   * Returns all repetitions of {@link #getFamily() family name} as a space separated string
623   * 
624   * @see DatatypeUtil#joinStringsSpaceSeparated(List)
625   */
626  public String getFamilyAsSingleString() {
627    return joinStringsSpaceSeparated(getFamily());
628  }
629
630  /**
631   * Returns all repetitions of {@link #getGiven() given name} as a space separated string
632   * 
633   * @see DatatypeUtil#joinStringsSpaceSeparated(List)
634   */
635  public String getGivenAsSingleString() {
636    return joinStringsSpaceSeparated(getGiven());
637  }
638
639  /**
640   * Returns all repetitions of {@link #getPrefix() prefix name} as a space separated string
641   * 
642   * @see DatatypeUtil#joinStringsSpaceSeparated(List)
643   */
644  public String getPrefixAsSingleString() {
645    return joinStringsSpaceSeparated(getPrefix());
646  }
647
648  /**
649   * Returns all repetitions of {@link #getSuffix() suffix} as a space separated string
650   * 
651   * @see DatatypeUtil#joinStringsSpaceSeparated(List)
652   */
653  public String getSuffixAsSingleString() {
654    return joinStringsSpaceSeparated(getSuffix());
655  }
656
657  /**
658   * Returns all of the components of the name (prefix, given, family, suffix) as a single string with a single spaced
659   * string separating each part.
660   * <p>
661   * If none of the parts are populated, returns the {@link #getTextElement() text} element value instead.
662   * </p>
663   */
664  public String getNameAsSingleString() {
665    List<StringType> nameParts = new ArrayList<StringType>();
666    nameParts.addAll(getPrefix());
667    nameParts.addAll(getGiven());
668    nameParts.addAll(getFamily());
669    nameParts.addAll(getSuffix());
670    if (nameParts.size() > 0) {
671      return joinStringsSpaceSeparated(nameParts);
672    } else {
673      return getTextElement().getValue();
674    }
675  }
676
677  /**
678   * Joins a list of strings with a single space (' ') between each string
679   * 
680   * TODO: replace with call to ca.uhn.fhir.util.DatatypeUtil.joinStringsSpaceSeparated when HAPI upgrades to 1.4
681   */
682  private static String joinStringsSpaceSeparated(List<? extends IPrimitiveType<String>> theStrings) {
683    StringBuilder b = new StringBuilder();
684    for (IPrimitiveType<String> next : theStrings) {
685      if (next.isEmpty()) {
686        continue;
687      }
688      if (b.length() > 0) {
689        b.append(' ');
690      }
691      b.append(next.getValue());
692    }
693    return b.toString();
694  }
695      protected void listChildren(List<Property> childrenList) {
696        super.listChildren(childrenList);
697        childrenList.add(new Property("use", "code", "Identifies the purpose for this name.", 0, java.lang.Integer.MAX_VALUE, use));
698        childrenList.add(new Property("text", "string", "A full text representation of the name.", 0, java.lang.Integer.MAX_VALUE, text));
699        childrenList.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, java.lang.Integer.MAX_VALUE, family));
700        childrenList.add(new Property("given", "string", "Given name.", 0, java.lang.Integer.MAX_VALUE, given));
701        childrenList.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));
702        childrenList.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));
703        childrenList.add(new Property("period", "Period", "Indicates the period of time when this name was valid for the named person.", 0, java.lang.Integer.MAX_VALUE, period));
704      }
705
706      @Override
707      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
708        switch (hash) {
709        case 116103: /*use*/ return this.use == null ? new Base[0] : new Base[] {this.use}; // Enumeration<NameUse>
710        case 3556653: /*text*/ return this.text == null ? new Base[0] : new Base[] {this.text}; // StringType
711        case -1281860764: /*family*/ return this.family == null ? new Base[0] : this.family.toArray(new Base[this.family.size()]); // StringType
712        case 98367357: /*given*/ return this.given == null ? new Base[0] : this.given.toArray(new Base[this.given.size()]); // StringType
713        case -980110702: /*prefix*/ return this.prefix == null ? new Base[0] : this.prefix.toArray(new Base[this.prefix.size()]); // StringType
714        case -891422895: /*suffix*/ return this.suffix == null ? new Base[0] : this.suffix.toArray(new Base[this.suffix.size()]); // StringType
715        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
716        default: return super.getProperty(hash, name, checkValid);
717        }
718
719      }
720
721      @Override
722      public void setProperty(int hash, String name, Base value) throws FHIRException {
723        switch (hash) {
724        case 116103: // use
725          this.use = new NameUseEnumFactory().fromType(value); // Enumeration<NameUse>
726          break;
727        case 3556653: // text
728          this.text = castToString(value); // StringType
729          break;
730        case -1281860764: // family
731          this.getFamily().add(castToString(value)); // StringType
732          break;
733        case 98367357: // given
734          this.getGiven().add(castToString(value)); // StringType
735          break;
736        case -980110702: // prefix
737          this.getPrefix().add(castToString(value)); // StringType
738          break;
739        case -891422895: // suffix
740          this.getSuffix().add(castToString(value)); // StringType
741          break;
742        case -991726143: // period
743          this.period = castToPeriod(value); // Period
744          break;
745        default: super.setProperty(hash, name, value);
746        }
747
748      }
749
750      @Override
751      public void setProperty(String name, Base value) throws FHIRException {
752        if (name.equals("use"))
753          this.use = new NameUseEnumFactory().fromType(value); // Enumeration<NameUse>
754        else if (name.equals("text"))
755          this.text = castToString(value); // StringType
756        else if (name.equals("family"))
757          this.getFamily().add(castToString(value));
758        else if (name.equals("given"))
759          this.getGiven().add(castToString(value));
760        else if (name.equals("prefix"))
761          this.getPrefix().add(castToString(value));
762        else if (name.equals("suffix"))
763          this.getSuffix().add(castToString(value));
764        else if (name.equals("period"))
765          this.period = castToPeriod(value); // Period
766        else
767          super.setProperty(name, value);
768      }
769
770      @Override
771      public Base makeProperty(int hash, String name) throws FHIRException {
772        switch (hash) {
773        case 116103: throw new FHIRException("Cannot make property use as it is not a complex type"); // Enumeration<NameUse>
774        case 3556653: throw new FHIRException("Cannot make property text as it is not a complex type"); // StringType
775        case -1281860764: throw new FHIRException("Cannot make property family as it is not a complex type"); // StringType
776        case 98367357: throw new FHIRException("Cannot make property given as it is not a complex type"); // StringType
777        case -980110702: throw new FHIRException("Cannot make property prefix as it is not a complex type"); // StringType
778        case -891422895: throw new FHIRException("Cannot make property suffix as it is not a complex type"); // StringType
779        case -991726143:  return getPeriod(); // Period
780        default: return super.makeProperty(hash, name);
781        }
782
783      }
784
785      @Override
786      public Base addChild(String name) throws FHIRException {
787        if (name.equals("use")) {
788          throw new FHIRException("Cannot call addChild on a primitive type HumanName.use");
789        }
790        else if (name.equals("text")) {
791          throw new FHIRException("Cannot call addChild on a primitive type HumanName.text");
792        }
793        else if (name.equals("family")) {
794          throw new FHIRException("Cannot call addChild on a primitive type HumanName.family");
795        }
796        else if (name.equals("given")) {
797          throw new FHIRException("Cannot call addChild on a primitive type HumanName.given");
798        }
799        else if (name.equals("prefix")) {
800          throw new FHIRException("Cannot call addChild on a primitive type HumanName.prefix");
801        }
802        else if (name.equals("suffix")) {
803          throw new FHIRException("Cannot call addChild on a primitive type HumanName.suffix");
804        }
805        else if (name.equals("period")) {
806          this.period = new Period();
807          return this.period;
808        }
809        else
810          return super.addChild(name);
811      }
812
813  public String fhirType() {
814    return "HumanName";
815
816  }
817
818      public HumanName copy() {
819        HumanName dst = new HumanName();
820        copyValues(dst);
821        dst.use = use == null ? null : use.copy();
822        dst.text = text == null ? null : text.copy();
823        if (family != null) {
824          dst.family = new ArrayList<StringType>();
825          for (StringType i : family)
826            dst.family.add(i.copy());
827        };
828        if (given != null) {
829          dst.given = new ArrayList<StringType>();
830          for (StringType i : given)
831            dst.given.add(i.copy());
832        };
833        if (prefix != null) {
834          dst.prefix = new ArrayList<StringType>();
835          for (StringType i : prefix)
836            dst.prefix.add(i.copy());
837        };
838        if (suffix != null) {
839          dst.suffix = new ArrayList<StringType>();
840          for (StringType i : suffix)
841            dst.suffix.add(i.copy());
842        };
843        dst.period = period == null ? null : period.copy();
844        return dst;
845      }
846
847      protected HumanName typedCopy() {
848        return copy();
849      }
850
851      @Override
852      public boolean equalsDeep(Base other) {
853        if (!super.equalsDeep(other))
854          return false;
855        if (!(other instanceof HumanName))
856          return false;
857        HumanName o = (HumanName) other;
858        return compareDeep(use, o.use, true) && compareDeep(text, o.text, true) && compareDeep(family, o.family, true)
859           && compareDeep(given, o.given, true) && compareDeep(prefix, o.prefix, true) && compareDeep(suffix, o.suffix, true)
860           && compareDeep(period, o.period, true);
861      }
862
863      @Override
864      public boolean equalsShallow(Base other) {
865        if (!super.equalsShallow(other))
866          return false;
867        if (!(other instanceof HumanName))
868          return false;
869        HumanName o = (HumanName) other;
870        return compareValues(use, o.use, true) && compareValues(text, o.text, true) && compareValues(family, o.family, true)
871           && compareValues(given, o.given, true) && compareValues(prefix, o.prefix, true) && compareValues(suffix, o.suffix, true)
872          ;
873      }
874
875      public boolean isEmpty() {
876        return super.isEmpty() && (use == null || use.isEmpty()) && (text == null || text.isEmpty())
877           && (family == null || family.isEmpty()) && (given == null || given.isEmpty()) && (prefix == null || prefix.isEmpty())
878           && (suffix == null || suffix.isEmpty()) && (period == null || period.isEmpty());
879      }
880
881
882}