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.List;
037
038import org.hl7.fhir.exceptions.FHIRException;
039import org.hl7.fhir.instance.model.api.ICompositeType;
040import org.hl7.fhir.utilities.Utilities;
041
042import ca.uhn.fhir.model.api.annotation.Child;
043import ca.uhn.fhir.model.api.annotation.DatatypeDef;
044import ca.uhn.fhir.model.api.annotation.Description;
045/**
046 * A technical identifier - identifies some entity uniquely and unambiguously.
047 */
048@DatatypeDef(name="Identifier")
049public class Identifier extends Type implements ICompositeType {
050
051    public enum IdentifierUse {
052        /**
053         * The identifier recommended for display and use in real-world interactions.
054         */
055        USUAL, 
056        /**
057         * The identifier considered to be most trusted for the identification of this item.
058         */
059        OFFICIAL, 
060        /**
061         * A temporary identifier.
062         */
063        TEMP, 
064        /**
065         * An identifier that was assigned in secondary use - it serves to identify the object in a relative context, but cannot be consistently assigned to the same object again in a different context.
066         */
067        SECONDARY, 
068        /**
069         * added to help the parsers
070         */
071        NULL;
072        public static IdentifierUse fromCode(String codeString) throws FHIRException {
073            if (codeString == null || "".equals(codeString))
074                return null;
075        if ("usual".equals(codeString))
076          return USUAL;
077        if ("official".equals(codeString))
078          return OFFICIAL;
079        if ("temp".equals(codeString))
080          return TEMP;
081        if ("secondary".equals(codeString))
082          return SECONDARY;
083        throw new FHIRException("Unknown IdentifierUse code '"+codeString+"'");
084        }
085        public String toCode() {
086          switch (this) {
087            case USUAL: return "usual";
088            case OFFICIAL: return "official";
089            case TEMP: return "temp";
090            case SECONDARY: return "secondary";
091            case NULL: return null;
092            default: return "?";
093          }
094        }
095        public String getSystem() {
096          switch (this) {
097            case USUAL: return "http://hl7.org/fhir/identifier-use";
098            case OFFICIAL: return "http://hl7.org/fhir/identifier-use";
099            case TEMP: return "http://hl7.org/fhir/identifier-use";
100            case SECONDARY: return "http://hl7.org/fhir/identifier-use";
101            case NULL: return null;
102            default: return "?";
103          }
104        }
105        public String getDefinition() {
106          switch (this) {
107            case USUAL: return "The identifier recommended for display and use in real-world interactions.";
108            case OFFICIAL: return "The identifier considered to be most trusted for the identification of this item.";
109            case TEMP: return "A temporary identifier.";
110            case SECONDARY: return "An identifier that was assigned in secondary use - it serves to identify the object in a relative context, but cannot be consistently assigned to the same object again in a different context.";
111            case NULL: return null;
112            default: return "?";
113          }
114        }
115        public String getDisplay() {
116          switch (this) {
117            case USUAL: return "Usual";
118            case OFFICIAL: return "Official";
119            case TEMP: return "Temp";
120            case SECONDARY: return "Secondary";
121            case NULL: return null;
122            default: return "?";
123          }
124        }
125    }
126
127  public static class IdentifierUseEnumFactory implements EnumFactory<IdentifierUse> {
128    public IdentifierUse fromCode(String codeString) throws IllegalArgumentException {
129      if (codeString == null || "".equals(codeString))
130            if (codeString == null || "".equals(codeString))
131                return null;
132        if ("usual".equals(codeString))
133          return IdentifierUse.USUAL;
134        if ("official".equals(codeString))
135          return IdentifierUse.OFFICIAL;
136        if ("temp".equals(codeString))
137          return IdentifierUse.TEMP;
138        if ("secondary".equals(codeString))
139          return IdentifierUse.SECONDARY;
140        throw new IllegalArgumentException("Unknown IdentifierUse code '"+codeString+"'");
141        }
142        public Enumeration<IdentifierUse> fromType(Base code) throws FHIRException {
143          if (code == null || code.isEmpty())
144            return null;
145          String codeString = ((PrimitiveType) code).asStringValue();
146          if (codeString == null || "".equals(codeString))
147            return null;
148        if ("usual".equals(codeString))
149          return new Enumeration<IdentifierUse>(this, IdentifierUse.USUAL);
150        if ("official".equals(codeString))
151          return new Enumeration<IdentifierUse>(this, IdentifierUse.OFFICIAL);
152        if ("temp".equals(codeString))
153          return new Enumeration<IdentifierUse>(this, IdentifierUse.TEMP);
154        if ("secondary".equals(codeString))
155          return new Enumeration<IdentifierUse>(this, IdentifierUse.SECONDARY);
156        throw new FHIRException("Unknown IdentifierUse code '"+codeString+"'");
157        }
158    public String toCode(IdentifierUse code) {
159      if (code == IdentifierUse.USUAL)
160        return "usual";
161      if (code == IdentifierUse.OFFICIAL)
162        return "official";
163      if (code == IdentifierUse.TEMP)
164        return "temp";
165      if (code == IdentifierUse.SECONDARY)
166        return "secondary";
167      return "?";
168      }
169    public String toSystem(IdentifierUse code) {
170      return code.getSystem();
171      }
172    }
173
174    /**
175     * The purpose of this identifier.
176     */
177    @Child(name = "use", type = {CodeType.class}, order=0, min=0, max=1, modifier=true, summary=true)
178    @Description(shortDefinition="usual | official | temp | secondary (If known)", formalDefinition="The purpose of this identifier." )
179    protected Enumeration<IdentifierUse> use;
180
181    /**
182     * A coded type for the identifier that can be used to determine which identifier to use for a specific purpose.
183     */
184    @Child(name = "type", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
185    @Description(shortDefinition="Description of identifier", formalDefinition="A coded type for the identifier that can be used to determine which identifier to use for a specific purpose." )
186    protected CodeableConcept type;
187
188    /**
189     * Establishes the namespace in which set of possible id values is unique.
190     */
191    @Child(name = "system", type = {UriType.class}, order=2, min=0, max=1, modifier=false, summary=true)
192    @Description(shortDefinition="The namespace for the identifier", formalDefinition="Establishes the namespace in which set of possible id values is unique." )
193    protected UriType system;
194
195    /**
196     * The portion of the identifier typically relevant to the user and which is unique within the context of the system.
197     */
198    @Child(name = "value", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=true)
199    @Description(shortDefinition="The value that is unique", formalDefinition="The portion of the identifier typically relevant to the user and which is unique within the context of the system." )
200    protected StringType value;
201
202    /**
203     * Time period during which identifier is/was valid for use.
204     */
205    @Child(name = "period", type = {Period.class}, order=4, min=0, max=1, modifier=false, summary=true)
206    @Description(shortDefinition="Time period when id is/was valid for use", formalDefinition="Time period during which identifier is/was valid for use." )
207    protected Period period;
208
209    /**
210     * Organization that issued/manages the identifier.
211     */
212    @Child(name = "assigner", type = {Organization.class}, order=5, min=0, max=1, modifier=false, summary=true)
213    @Description(shortDefinition="Organization that issued id (may be just text)", formalDefinition="Organization that issued/manages the identifier." )
214    protected Reference assigner;
215
216    /**
217     * The actual object that is the target of the reference (Organization that issued/manages the identifier.)
218     */
219    protected Organization assignerTarget;
220
221    private static final long serialVersionUID = -478840981L;
222
223  /**
224   * Constructor
225   */
226    public Identifier() {
227      super();
228    }
229
230    /**
231     * @return {@link #use} (The purpose of this identifier.). This is the underlying object with id, value and extensions. The accessor "getUse" gives direct access to the value
232     */
233    public Enumeration<IdentifierUse> getUseElement() { 
234      if (this.use == null)
235        if (Configuration.errorOnAutoCreate())
236          throw new Error("Attempt to auto-create Identifier.use");
237        else if (Configuration.doAutoCreate())
238          this.use = new Enumeration<IdentifierUse>(new IdentifierUseEnumFactory()); // bb
239      return this.use;
240    }
241
242    public boolean hasUseElement() { 
243      return this.use != null && !this.use.isEmpty();
244    }
245
246    public boolean hasUse() { 
247      return this.use != null && !this.use.isEmpty();
248    }
249
250    /**
251     * @param value {@link #use} (The purpose of this identifier.). This is the underlying object with id, value and extensions. The accessor "getUse" gives direct access to the value
252     */
253    public Identifier setUseElement(Enumeration<IdentifierUse> value) { 
254      this.use = value;
255      return this;
256    }
257
258    /**
259     * @return The purpose of this identifier.
260     */
261    public IdentifierUse getUse() { 
262      return this.use == null ? null : this.use.getValue();
263    }
264
265    /**
266     * @param value The purpose of this identifier.
267     */
268    public Identifier setUse(IdentifierUse value) { 
269      if (value == null)
270        this.use = null;
271      else {
272        if (this.use == null)
273          this.use = new Enumeration<IdentifierUse>(new IdentifierUseEnumFactory());
274        this.use.setValue(value);
275      }
276      return this;
277    }
278
279    /**
280     * @return {@link #type} (A coded type for the identifier that can be used to determine which identifier to use for a specific purpose.)
281     */
282    public CodeableConcept getType() { 
283      if (this.type == null)
284        if (Configuration.errorOnAutoCreate())
285          throw new Error("Attempt to auto-create Identifier.type");
286        else if (Configuration.doAutoCreate())
287          this.type = new CodeableConcept(); // cc
288      return this.type;
289    }
290
291    public boolean hasType() { 
292      return this.type != null && !this.type.isEmpty();
293    }
294
295    /**
296     * @param value {@link #type} (A coded type for the identifier that can be used to determine which identifier to use for a specific purpose.)
297     */
298    public Identifier setType(CodeableConcept value) { 
299      this.type = value;
300      return this;
301    }
302
303    /**
304     * @return {@link #system} (Establishes the namespace in which set of possible id values is unique.). This is the underlying object with id, value and extensions. The accessor "getSystem" gives direct access to the value
305     */
306    public UriType getSystemElement() { 
307      if (this.system == null)
308        if (Configuration.errorOnAutoCreate())
309          throw new Error("Attempt to auto-create Identifier.system");
310        else if (Configuration.doAutoCreate())
311          this.system = new UriType(); // bb
312      return this.system;
313    }
314
315    public boolean hasSystemElement() { 
316      return this.system != null && !this.system.isEmpty();
317    }
318
319    public boolean hasSystem() { 
320      return this.system != null && !this.system.isEmpty();
321    }
322
323    /**
324     * @param value {@link #system} (Establishes the namespace in which set of possible id values is unique.). This is the underlying object with id, value and extensions. The accessor "getSystem" gives direct access to the value
325     */
326    public Identifier setSystemElement(UriType value) { 
327      this.system = value;
328      return this;
329    }
330
331    /**
332     * @return Establishes the namespace in which set of possible id values is unique.
333     */
334    public String getSystem() { 
335      return this.system == null ? null : this.system.getValue();
336    }
337
338    /**
339     * @param value Establishes the namespace in which set of possible id values is unique.
340     */
341    public Identifier setSystem(String value) { 
342      if (Utilities.noString(value))
343        this.system = null;
344      else {
345        if (this.system == null)
346          this.system = new UriType();
347        this.system.setValue(value);
348      }
349      return this;
350    }
351
352    /**
353     * @return {@link #value} (The portion of the identifier typically relevant to the user and which is unique within the context of the system.). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value
354     */
355    public StringType getValueElement() { 
356      if (this.value == null)
357        if (Configuration.errorOnAutoCreate())
358          throw new Error("Attempt to auto-create Identifier.value");
359        else if (Configuration.doAutoCreate())
360          this.value = new StringType(); // bb
361      return this.value;
362    }
363
364    public boolean hasValueElement() { 
365      return this.value != null && !this.value.isEmpty();
366    }
367
368    public boolean hasValue() { 
369      return this.value != null && !this.value.isEmpty();
370    }
371
372    /**
373     * @param value {@link #value} (The portion of the identifier typically relevant to the user and which is unique within the context of the system.). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value
374     */
375    public Identifier setValueElement(StringType value) { 
376      this.value = value;
377      return this;
378    }
379
380    /**
381     * @return The portion of the identifier typically relevant to the user and which is unique within the context of the system.
382     */
383    public String getValue() { 
384      return this.value == null ? null : this.value.getValue();
385    }
386
387    /**
388     * @param value The portion of the identifier typically relevant to the user and which is unique within the context of the system.
389     */
390    public Identifier setValue(String value) { 
391      if (Utilities.noString(value))
392        this.value = null;
393      else {
394        if (this.value == null)
395          this.value = new StringType();
396        this.value.setValue(value);
397      }
398      return this;
399    }
400
401    /**
402     * @return {@link #period} (Time period during which identifier is/was valid for use.)
403     */
404    public Period getPeriod() { 
405      if (this.period == null)
406        if (Configuration.errorOnAutoCreate())
407          throw new Error("Attempt to auto-create Identifier.period");
408        else if (Configuration.doAutoCreate())
409          this.period = new Period(); // cc
410      return this.period;
411    }
412
413    public boolean hasPeriod() { 
414      return this.period != null && !this.period.isEmpty();
415    }
416
417    /**
418     * @param value {@link #period} (Time period during which identifier is/was valid for use.)
419     */
420    public Identifier setPeriod(Period value) { 
421      this.period = value;
422      return this;
423    }
424
425    /**
426     * @return {@link #assigner} (Organization that issued/manages the identifier.)
427     */
428    public Reference getAssigner() { 
429      if (this.assigner == null)
430        if (Configuration.errorOnAutoCreate())
431          throw new Error("Attempt to auto-create Identifier.assigner");
432        else if (Configuration.doAutoCreate())
433          this.assigner = new Reference(); // cc
434      return this.assigner;
435    }
436
437    public boolean hasAssigner() { 
438      return this.assigner != null && !this.assigner.isEmpty();
439    }
440
441    /**
442     * @param value {@link #assigner} (Organization that issued/manages the identifier.)
443     */
444    public Identifier setAssigner(Reference value) { 
445      this.assigner = value;
446      return this;
447    }
448
449    /**
450     * @return {@link #assigner} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Organization that issued/manages the identifier.)
451     */
452    public Organization getAssignerTarget() { 
453      if (this.assignerTarget == null)
454        if (Configuration.errorOnAutoCreate())
455          throw new Error("Attempt to auto-create Identifier.assigner");
456        else if (Configuration.doAutoCreate())
457          this.assignerTarget = new Organization(); // aa
458      return this.assignerTarget;
459    }
460
461    /**
462     * @param value {@link #assigner} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Organization that issued/manages the identifier.)
463     */
464    public Identifier setAssignerTarget(Organization value) { 
465      this.assignerTarget = value;
466      return this;
467    }
468
469      protected void listChildren(List<Property> childrenList) {
470        super.listChildren(childrenList);
471        childrenList.add(new Property("use", "code", "The purpose of this identifier.", 0, java.lang.Integer.MAX_VALUE, use));
472        childrenList.add(new Property("type", "CodeableConcept", "A coded type for the identifier that can be used to determine which identifier to use for a specific purpose.", 0, java.lang.Integer.MAX_VALUE, type));
473        childrenList.add(new Property("system", "uri", "Establishes the namespace in which set of possible id values is unique.", 0, java.lang.Integer.MAX_VALUE, system));
474        childrenList.add(new Property("value", "string", "The portion of the identifier typically relevant to the user and which is unique within the context of the system.", 0, java.lang.Integer.MAX_VALUE, value));
475        childrenList.add(new Property("period", "Period", "Time period during which identifier is/was valid for use.", 0, java.lang.Integer.MAX_VALUE, period));
476        childrenList.add(new Property("assigner", "Reference(Organization)", "Organization that issued/manages the identifier.", 0, java.lang.Integer.MAX_VALUE, assigner));
477      }
478
479      @Override
480      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
481        switch (hash) {
482        case 116103: /*use*/ return this.use == null ? new Base[0] : new Base[] {this.use}; // Enumeration<IdentifierUse>
483        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
484        case -887328209: /*system*/ return this.system == null ? new Base[0] : new Base[] {this.system}; // UriType
485        case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // StringType
486        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
487        case -369881636: /*assigner*/ return this.assigner == null ? new Base[0] : new Base[] {this.assigner}; // Reference
488        default: return super.getProperty(hash, name, checkValid);
489        }
490
491      }
492
493      @Override
494      public void setProperty(int hash, String name, Base value) throws FHIRException {
495        switch (hash) {
496        case 116103: // use
497          this.use = new IdentifierUseEnumFactory().fromType(value); // Enumeration<IdentifierUse>
498          break;
499        case 3575610: // type
500          this.type = castToCodeableConcept(value); // CodeableConcept
501          break;
502        case -887328209: // system
503          this.system = castToUri(value); // UriType
504          break;
505        case 111972721: // value
506          this.value = castToString(value); // StringType
507          break;
508        case -991726143: // period
509          this.period = castToPeriod(value); // Period
510          break;
511        case -369881636: // assigner
512          this.assigner = castToReference(value); // Reference
513          break;
514        default: super.setProperty(hash, name, value);
515        }
516
517      }
518
519      @Override
520      public void setProperty(String name, Base value) throws FHIRException {
521        if (name.equals("use"))
522          this.use = new IdentifierUseEnumFactory().fromType(value); // Enumeration<IdentifierUse>
523        else if (name.equals("type"))
524          this.type = castToCodeableConcept(value); // CodeableConcept
525        else if (name.equals("system"))
526          this.system = castToUri(value); // UriType
527        else if (name.equals("value"))
528          this.value = castToString(value); // StringType
529        else if (name.equals("period"))
530          this.period = castToPeriod(value); // Period
531        else if (name.equals("assigner"))
532          this.assigner = castToReference(value); // Reference
533        else
534          super.setProperty(name, value);
535      }
536
537      @Override
538      public Base makeProperty(int hash, String name) throws FHIRException {
539        switch (hash) {
540        case 116103: throw new FHIRException("Cannot make property use as it is not a complex type"); // Enumeration<IdentifierUse>
541        case 3575610:  return getType(); // CodeableConcept
542        case -887328209: throw new FHIRException("Cannot make property system as it is not a complex type"); // UriType
543        case 111972721: throw new FHIRException("Cannot make property value as it is not a complex type"); // StringType
544        case -991726143:  return getPeriod(); // Period
545        case -369881636:  return getAssigner(); // Reference
546        default: return super.makeProperty(hash, name);
547        }
548
549      }
550
551      @Override
552      public Base addChild(String name) throws FHIRException {
553        if (name.equals("use")) {
554          throw new FHIRException("Cannot call addChild on a primitive type Identifier.use");
555        }
556        else if (name.equals("type")) {
557          this.type = new CodeableConcept();
558          return this.type;
559        }
560        else if (name.equals("system")) {
561          throw new FHIRException("Cannot call addChild on a primitive type Identifier.system");
562        }
563        else if (name.equals("value")) {
564          throw new FHIRException("Cannot call addChild on a primitive type Identifier.value");
565        }
566        else if (name.equals("period")) {
567          this.period = new Period();
568          return this.period;
569        }
570        else if (name.equals("assigner")) {
571          this.assigner = new Reference();
572          return this.assigner;
573        }
574        else
575          return super.addChild(name);
576      }
577
578  public String fhirType() {
579    return "Identifier";
580
581  }
582
583      public Identifier copy() {
584        Identifier dst = new Identifier();
585        copyValues(dst);
586        dst.use = use == null ? null : use.copy();
587        dst.type = type == null ? null : type.copy();
588        dst.system = system == null ? null : system.copy();
589        dst.value = value == null ? null : value.copy();
590        dst.period = period == null ? null : period.copy();
591        dst.assigner = assigner == null ? null : assigner.copy();
592        return dst;
593      }
594
595      protected Identifier typedCopy() {
596        return copy();
597      }
598
599      @Override
600      public boolean equalsDeep(Base other) {
601        if (!super.equalsDeep(other))
602          return false;
603        if (!(other instanceof Identifier))
604          return false;
605        Identifier o = (Identifier) other;
606        return compareDeep(use, o.use, true) && compareDeep(type, o.type, true) && compareDeep(system, o.system, true)
607           && compareDeep(value, o.value, true) && compareDeep(period, o.period, true) && compareDeep(assigner, o.assigner, true)
608          ;
609      }
610
611      @Override
612      public boolean equalsShallow(Base other) {
613        if (!super.equalsShallow(other))
614          return false;
615        if (!(other instanceof Identifier))
616          return false;
617        Identifier o = (Identifier) other;
618        return compareValues(use, o.use, true) && compareValues(system, o.system, true) && compareValues(value, o.value, true)
619          ;
620      }
621
622      public boolean isEmpty() {
623        return super.isEmpty() && (use == null || use.isEmpty()) && (type == null || type.isEmpty())
624           && (system == null || system.isEmpty()) && (value == null || value.isEmpty()) && (period == null || period.isEmpty())
625           && (assigner == null || assigner.isEmpty());
626      }
627
628
629}