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