001package org.hl7.fhir.instance.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
033import java.util.ArrayList;
034import java.util.List;
035
036import org.hl7.fhir.exceptions.FHIRException;
037import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
038import org.hl7.fhir.utilities.Utilities;
039
040import ca.uhn.fhir.model.api.annotation.*;
041/**
042 * A formally or informally recognized grouping of people or organizations formed for the purpose of achieving some form of collective action.  Includes companies, institutions, corporations, departments, community groups, healthcare practice groups, etc.
043 */
044@ResourceDef(name="Organization", profile="http://hl7.org/fhir/Profile/Organization")
045public class Organization extends DomainResource {
046
047    @Block()
048    public static class OrganizationContactComponent extends BackboneElement implements IBaseBackboneElement {
049        /**
050         * Indicates a purpose for which the contact can be reached.
051         */
052        @Child(name = "purpose", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=false)
053        @Description(shortDefinition="The type of contact", formalDefinition="Indicates a purpose for which the contact can be reached." )
054        protected CodeableConcept purpose;
055
056        /**
057         * A name associated with the contact.
058         */
059        @Child(name = "name", type = {HumanName.class}, order=2, min=0, max=1, modifier=false, summary=false)
060        @Description(shortDefinition="A name associated with the contact", formalDefinition="A name associated with the contact." )
061        protected HumanName name;
062
063        /**
064         * A contact detail (e.g. a telephone number or an email address) by which the party may be contacted.
065         */
066        @Child(name = "telecom", type = {ContactPoint.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
067        @Description(shortDefinition="Contact details (telephone, email, etc.)  for a contact", formalDefinition="A contact detail (e.g. a telephone number or an email address) by which the party may be contacted." )
068        protected List<ContactPoint> telecom;
069
070        /**
071         * Visiting or postal addresses for the contact.
072         */
073        @Child(name = "address", type = {Address.class}, order=4, min=0, max=1, modifier=false, summary=false)
074        @Description(shortDefinition="Visiting or postal addresses for the contact", formalDefinition="Visiting or postal addresses for the contact." )
075        protected Address address;
076
077        private static final long serialVersionUID = 1831121305L;
078
079    /*
080     * Constructor
081     */
082      public OrganizationContactComponent() {
083        super();
084      }
085
086        /**
087         * @return {@link #purpose} (Indicates a purpose for which the contact can be reached.)
088         */
089        public CodeableConcept getPurpose() { 
090          if (this.purpose == null)
091            if (Configuration.errorOnAutoCreate())
092              throw new Error("Attempt to auto-create OrganizationContactComponent.purpose");
093            else if (Configuration.doAutoCreate())
094              this.purpose = new CodeableConcept(); // cc
095          return this.purpose;
096        }
097
098        public boolean hasPurpose() { 
099          return this.purpose != null && !this.purpose.isEmpty();
100        }
101
102        /**
103         * @param value {@link #purpose} (Indicates a purpose for which the contact can be reached.)
104         */
105        public OrganizationContactComponent setPurpose(CodeableConcept value) { 
106          this.purpose = value;
107          return this;
108        }
109
110        /**
111         * @return {@link #name} (A name associated with the contact.)
112         */
113        public HumanName getName() { 
114          if (this.name == null)
115            if (Configuration.errorOnAutoCreate())
116              throw new Error("Attempt to auto-create OrganizationContactComponent.name");
117            else if (Configuration.doAutoCreate())
118              this.name = new HumanName(); // cc
119          return this.name;
120        }
121
122        public boolean hasName() { 
123          return this.name != null && !this.name.isEmpty();
124        }
125
126        /**
127         * @param value {@link #name} (A name associated with the contact.)
128         */
129        public OrganizationContactComponent setName(HumanName value) { 
130          this.name = value;
131          return this;
132        }
133
134        /**
135         * @return {@link #telecom} (A contact detail (e.g. a telephone number or an email address) by which the party may be contacted.)
136         */
137        public List<ContactPoint> getTelecom() { 
138          if (this.telecom == null)
139            this.telecom = new ArrayList<ContactPoint>();
140          return this.telecom;
141        }
142
143        public boolean hasTelecom() { 
144          if (this.telecom == null)
145            return false;
146          for (ContactPoint item : this.telecom)
147            if (!item.isEmpty())
148              return true;
149          return false;
150        }
151
152        /**
153         * @return {@link #telecom} (A contact detail (e.g. a telephone number or an email address) by which the party may be contacted.)
154         */
155    // syntactic sugar
156        public ContactPoint addTelecom() { //3
157          ContactPoint t = new ContactPoint();
158          if (this.telecom == null)
159            this.telecom = new ArrayList<ContactPoint>();
160          this.telecom.add(t);
161          return t;
162        }
163
164    // syntactic sugar
165        public OrganizationContactComponent addTelecom(ContactPoint t) { //3
166          if (t == null)
167            return this;
168          if (this.telecom == null)
169            this.telecom = new ArrayList<ContactPoint>();
170          this.telecom.add(t);
171          return this;
172        }
173
174        /**
175         * @return {@link #address} (Visiting or postal addresses for the contact.)
176         */
177        public Address getAddress() { 
178          if (this.address == null)
179            if (Configuration.errorOnAutoCreate())
180              throw new Error("Attempt to auto-create OrganizationContactComponent.address");
181            else if (Configuration.doAutoCreate())
182              this.address = new Address(); // cc
183          return this.address;
184        }
185
186        public boolean hasAddress() { 
187          return this.address != null && !this.address.isEmpty();
188        }
189
190        /**
191         * @param value {@link #address} (Visiting or postal addresses for the contact.)
192         */
193        public OrganizationContactComponent setAddress(Address value) { 
194          this.address = value;
195          return this;
196        }
197
198        protected void listChildren(List<Property> childrenList) {
199          super.listChildren(childrenList);
200          childrenList.add(new Property("purpose", "CodeableConcept", "Indicates a purpose for which the contact can be reached.", 0, java.lang.Integer.MAX_VALUE, purpose));
201          childrenList.add(new Property("name", "HumanName", "A name associated with the contact.", 0, java.lang.Integer.MAX_VALUE, name));
202          childrenList.add(new Property("telecom", "ContactPoint", "A contact detail (e.g. a telephone number or an email address) by which the party may be contacted.", 0, java.lang.Integer.MAX_VALUE, telecom));
203          childrenList.add(new Property("address", "Address", "Visiting or postal addresses for the contact.", 0, java.lang.Integer.MAX_VALUE, address));
204        }
205
206      @Override
207      public void setProperty(String name, Base value) throws FHIRException {
208        if (name.equals("purpose"))
209          this.purpose = castToCodeableConcept(value); // CodeableConcept
210        else if (name.equals("name"))
211          this.name = castToHumanName(value); // HumanName
212        else if (name.equals("telecom"))
213          this.getTelecom().add(castToContactPoint(value));
214        else if (name.equals("address"))
215          this.address = castToAddress(value); // Address
216        else
217          super.setProperty(name, value);
218      }
219
220      @Override
221      public Base addChild(String name) throws FHIRException {
222        if (name.equals("purpose")) {
223          this.purpose = new CodeableConcept();
224          return this.purpose;
225        }
226        else if (name.equals("name")) {
227          this.name = new HumanName();
228          return this.name;
229        }
230        else if (name.equals("telecom")) {
231          return addTelecom();
232        }
233        else if (name.equals("address")) {
234          this.address = new Address();
235          return this.address;
236        }
237        else
238          return super.addChild(name);
239      }
240
241      public OrganizationContactComponent copy() {
242        OrganizationContactComponent dst = new OrganizationContactComponent();
243        copyValues(dst);
244        dst.purpose = purpose == null ? null : purpose.copy();
245        dst.name = name == null ? null : name.copy();
246        if (telecom != null) {
247          dst.telecom = new ArrayList<ContactPoint>();
248          for (ContactPoint i : telecom)
249            dst.telecom.add(i.copy());
250        };
251        dst.address = address == null ? null : address.copy();
252        return dst;
253      }
254
255      @Override
256      public boolean equalsDeep(Base other) {
257        if (!super.equalsDeep(other))
258          return false;
259        if (!(other instanceof OrganizationContactComponent))
260          return false;
261        OrganizationContactComponent o = (OrganizationContactComponent) other;
262        return compareDeep(purpose, o.purpose, true) && compareDeep(name, o.name, true) && compareDeep(telecom, o.telecom, true)
263           && compareDeep(address, o.address, true);
264      }
265
266      @Override
267      public boolean equalsShallow(Base other) {
268        if (!super.equalsShallow(other))
269          return false;
270        if (!(other instanceof OrganizationContactComponent))
271          return false;
272        OrganizationContactComponent o = (OrganizationContactComponent) other;
273        return true;
274      }
275
276      public boolean isEmpty() {
277        return super.isEmpty() && (purpose == null || purpose.isEmpty()) && (name == null || name.isEmpty())
278           && (telecom == null || telecom.isEmpty()) && (address == null || address.isEmpty());
279      }
280
281  public String fhirType() {
282    return "Organization.contact";
283
284  }
285
286  }
287
288    /**
289     * Identifier for the organization that is used to identify the organization across multiple disparate systems.
290     */
291    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
292    @Description(shortDefinition="Identifies this organization  across multiple systems", formalDefinition="Identifier for the organization that is used to identify the organization across multiple disparate systems." )
293    protected List<Identifier> identifier;
294
295    /**
296     * Whether the organization's record is still in active use.
297     */
298    @Child(name = "active", type = {BooleanType.class}, order=1, min=0, max=1, modifier=true, summary=true)
299    @Description(shortDefinition="Whether the organization's record is still in active use", formalDefinition="Whether the organization's record is still in active use." )
300    protected BooleanType active;
301
302    /**
303     * The kind of organization that this is.
304     */
305    @Child(name = "type", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
306    @Description(shortDefinition="Kind of organization", formalDefinition="The kind of organization that this is." )
307    protected CodeableConcept type;
308
309    /**
310     * A name associated with the organization.
311     */
312    @Child(name = "name", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=true)
313    @Description(shortDefinition="Name used for the organization", formalDefinition="A name associated with the organization." )
314    protected StringType name;
315
316    /**
317     * A contact detail for the organization.
318     */
319    @Child(name = "telecom", type = {ContactPoint.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
320    @Description(shortDefinition="A contact detail for the organization", formalDefinition="A contact detail for the organization." )
321    protected List<ContactPoint> telecom;
322
323    /**
324     * An address for the organization.
325     */
326    @Child(name = "address", type = {Address.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
327    @Description(shortDefinition="An address for the organization", formalDefinition="An address for the organization." )
328    protected List<Address> address;
329
330    /**
331     * The organization of which this organization forms a part.
332     */
333    @Child(name = "partOf", type = {Organization.class}, order=6, min=0, max=1, modifier=false, summary=true)
334    @Description(shortDefinition="The organization of which this organization forms a part", formalDefinition="The organization of which this organization forms a part." )
335    protected Reference partOf;
336
337    /**
338     * The actual object that is the target of the reference (The organization of which this organization forms a part.)
339     */
340    protected Organization partOfTarget;
341
342    /**
343     * Contact for the organization for a certain purpose.
344     */
345    @Child(name = "contact", type = {}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
346    @Description(shortDefinition="Contact for the organization for a certain purpose", formalDefinition="Contact for the organization for a certain purpose." )
347    protected List<OrganizationContactComponent> contact;
348
349    private static final long serialVersionUID = -749567123L;
350
351  /*
352   * Constructor
353   */
354    public Organization() {
355      super();
356    }
357
358    /**
359     * @return {@link #identifier} (Identifier for the organization that is used to identify the organization across multiple disparate systems.)
360     */
361    public List<Identifier> getIdentifier() { 
362      if (this.identifier == null)
363        this.identifier = new ArrayList<Identifier>();
364      return this.identifier;
365    }
366
367    public boolean hasIdentifier() { 
368      if (this.identifier == null)
369        return false;
370      for (Identifier item : this.identifier)
371        if (!item.isEmpty())
372          return true;
373      return false;
374    }
375
376    /**
377     * @return {@link #identifier} (Identifier for the organization that is used to identify the organization across multiple disparate systems.)
378     */
379    // syntactic sugar
380    public Identifier addIdentifier() { //3
381      Identifier t = new Identifier();
382      if (this.identifier == null)
383        this.identifier = new ArrayList<Identifier>();
384      this.identifier.add(t);
385      return t;
386    }
387
388    // syntactic sugar
389    public Organization addIdentifier(Identifier t) { //3
390      if (t == null)
391        return this;
392      if (this.identifier == null)
393        this.identifier = new ArrayList<Identifier>();
394      this.identifier.add(t);
395      return this;
396    }
397
398    /**
399     * @return {@link #active} (Whether the organization's record is still in active use.). This is the underlying object with id, value and extensions. The accessor "getActive" gives direct access to the value
400     */
401    public BooleanType getActiveElement() { 
402      if (this.active == null)
403        if (Configuration.errorOnAutoCreate())
404          throw new Error("Attempt to auto-create Organization.active");
405        else if (Configuration.doAutoCreate())
406          this.active = new BooleanType(); // bb
407      return this.active;
408    }
409
410    public boolean hasActiveElement() { 
411      return this.active != null && !this.active.isEmpty();
412    }
413
414    public boolean hasActive() { 
415      return this.active != null && !this.active.isEmpty();
416    }
417
418    /**
419     * @param value {@link #active} (Whether the organization's record is still in active use.). This is the underlying object with id, value and extensions. The accessor "getActive" gives direct access to the value
420     */
421    public Organization setActiveElement(BooleanType value) { 
422      this.active = value;
423      return this;
424    }
425
426    /**
427     * @return Whether the organization's record is still in active use.
428     */
429    public boolean getActive() { 
430      return this.active == null || this.active.isEmpty() ? false : this.active.getValue();
431    }
432
433    /**
434     * @param value Whether the organization's record is still in active use.
435     */
436    public Organization setActive(boolean value) { 
437        if (this.active == null)
438          this.active = new BooleanType();
439        this.active.setValue(value);
440      return this;
441    }
442
443    /**
444     * @return {@link #type} (The kind of organization that this is.)
445     */
446    public CodeableConcept getType() { 
447      if (this.type == null)
448        if (Configuration.errorOnAutoCreate())
449          throw new Error("Attempt to auto-create Organization.type");
450        else if (Configuration.doAutoCreate())
451          this.type = new CodeableConcept(); // cc
452      return this.type;
453    }
454
455    public boolean hasType() { 
456      return this.type != null && !this.type.isEmpty();
457    }
458
459    /**
460     * @param value {@link #type} (The kind of organization that this is.)
461     */
462    public Organization setType(CodeableConcept value) { 
463      this.type = value;
464      return this;
465    }
466
467    /**
468     * @return {@link #name} (A name associated with the organization.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
469     */
470    public StringType getNameElement() { 
471      if (this.name == null)
472        if (Configuration.errorOnAutoCreate())
473          throw new Error("Attempt to auto-create Organization.name");
474        else if (Configuration.doAutoCreate())
475          this.name = new StringType(); // bb
476      return this.name;
477    }
478
479    public boolean hasNameElement() { 
480      return this.name != null && !this.name.isEmpty();
481    }
482
483    public boolean hasName() { 
484      return this.name != null && !this.name.isEmpty();
485    }
486
487    /**
488     * @param value {@link #name} (A name associated with the organization.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
489     */
490    public Organization setNameElement(StringType value) { 
491      this.name = value;
492      return this;
493    }
494
495    /**
496     * @return A name associated with the organization.
497     */
498    public String getName() { 
499      return this.name == null ? null : this.name.getValue();
500    }
501
502    /**
503     * @param value A name associated with the organization.
504     */
505    public Organization setName(String value) { 
506      if (Utilities.noString(value))
507        this.name = null;
508      else {
509        if (this.name == null)
510          this.name = new StringType();
511        this.name.setValue(value);
512      }
513      return this;
514    }
515
516    /**
517     * @return {@link #telecom} (A contact detail for the organization.)
518     */
519    public List<ContactPoint> getTelecom() { 
520      if (this.telecom == null)
521        this.telecom = new ArrayList<ContactPoint>();
522      return this.telecom;
523    }
524
525    public boolean hasTelecom() { 
526      if (this.telecom == null)
527        return false;
528      for (ContactPoint item : this.telecom)
529        if (!item.isEmpty())
530          return true;
531      return false;
532    }
533
534    /**
535     * @return {@link #telecom} (A contact detail for the organization.)
536     */
537    // syntactic sugar
538    public ContactPoint addTelecom() { //3
539      ContactPoint t = new ContactPoint();
540      if (this.telecom == null)
541        this.telecom = new ArrayList<ContactPoint>();
542      this.telecom.add(t);
543      return t;
544    }
545
546    // syntactic sugar
547    public Organization addTelecom(ContactPoint t) { //3
548      if (t == null)
549        return this;
550      if (this.telecom == null)
551        this.telecom = new ArrayList<ContactPoint>();
552      this.telecom.add(t);
553      return this;
554    }
555
556    /**
557     * @return {@link #address} (An address for the organization.)
558     */
559    public List<Address> getAddress() { 
560      if (this.address == null)
561        this.address = new ArrayList<Address>();
562      return this.address;
563    }
564
565    public boolean hasAddress() { 
566      if (this.address == null)
567        return false;
568      for (Address item : this.address)
569        if (!item.isEmpty())
570          return true;
571      return false;
572    }
573
574    /**
575     * @return {@link #address} (An address for the organization.)
576     */
577    // syntactic sugar
578    public Address addAddress() { //3
579      Address t = new Address();
580      if (this.address == null)
581        this.address = new ArrayList<Address>();
582      this.address.add(t);
583      return t;
584    }
585
586    // syntactic sugar
587    public Organization addAddress(Address t) { //3
588      if (t == null)
589        return this;
590      if (this.address == null)
591        this.address = new ArrayList<Address>();
592      this.address.add(t);
593      return this;
594    }
595
596    /**
597     * @return {@link #partOf} (The organization of which this organization forms a part.)
598     */
599    public Reference getPartOf() { 
600      if (this.partOf == null)
601        if (Configuration.errorOnAutoCreate())
602          throw new Error("Attempt to auto-create Organization.partOf");
603        else if (Configuration.doAutoCreate())
604          this.partOf = new Reference(); // cc
605      return this.partOf;
606    }
607
608    public boolean hasPartOf() { 
609      return this.partOf != null && !this.partOf.isEmpty();
610    }
611
612    /**
613     * @param value {@link #partOf} (The organization of which this organization forms a part.)
614     */
615    public Organization setPartOf(Reference value) { 
616      this.partOf = value;
617      return this;
618    }
619
620    /**
621     * @return {@link #partOf} 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. (The organization of which this organization forms a part.)
622     */
623    public Organization getPartOfTarget() { 
624      if (this.partOfTarget == null)
625        if (Configuration.errorOnAutoCreate())
626          throw new Error("Attempt to auto-create Organization.partOf");
627        else if (Configuration.doAutoCreate())
628          this.partOfTarget = new Organization(); // aa
629      return this.partOfTarget;
630    }
631
632    /**
633     * @param value {@link #partOf} 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. (The organization of which this organization forms a part.)
634     */
635    public Organization setPartOfTarget(Organization value) { 
636      this.partOfTarget = value;
637      return this;
638    }
639
640    /**
641     * @return {@link #contact} (Contact for the organization for a certain purpose.)
642     */
643    public List<OrganizationContactComponent> getContact() { 
644      if (this.contact == null)
645        this.contact = new ArrayList<OrganizationContactComponent>();
646      return this.contact;
647    }
648
649    public boolean hasContact() { 
650      if (this.contact == null)
651        return false;
652      for (OrganizationContactComponent item : this.contact)
653        if (!item.isEmpty())
654          return true;
655      return false;
656    }
657
658    /**
659     * @return {@link #contact} (Contact for the organization for a certain purpose.)
660     */
661    // syntactic sugar
662    public OrganizationContactComponent addContact() { //3
663      OrganizationContactComponent t = new OrganizationContactComponent();
664      if (this.contact == null)
665        this.contact = new ArrayList<OrganizationContactComponent>();
666      this.contact.add(t);
667      return t;
668    }
669
670    // syntactic sugar
671    public Organization addContact(OrganizationContactComponent t) { //3
672      if (t == null)
673        return this;
674      if (this.contact == null)
675        this.contact = new ArrayList<OrganizationContactComponent>();
676      this.contact.add(t);
677      return this;
678    }
679
680      protected void listChildren(List<Property> childrenList) {
681        super.listChildren(childrenList);
682        childrenList.add(new Property("identifier", "Identifier", "Identifier for the organization that is used to identify the organization across multiple disparate systems.", 0, java.lang.Integer.MAX_VALUE, identifier));
683        childrenList.add(new Property("active", "boolean", "Whether the organization's record is still in active use.", 0, java.lang.Integer.MAX_VALUE, active));
684        childrenList.add(new Property("type", "CodeableConcept", "The kind of organization that this is.", 0, java.lang.Integer.MAX_VALUE, type));
685        childrenList.add(new Property("name", "string", "A name associated with the organization.", 0, java.lang.Integer.MAX_VALUE, name));
686        childrenList.add(new Property("telecom", "ContactPoint", "A contact detail for the organization.", 0, java.lang.Integer.MAX_VALUE, telecom));
687        childrenList.add(new Property("address", "Address", "An address for the organization.", 0, java.lang.Integer.MAX_VALUE, address));
688        childrenList.add(new Property("partOf", "Reference(Organization)", "The organization of which this organization forms a part.", 0, java.lang.Integer.MAX_VALUE, partOf));
689        childrenList.add(new Property("contact", "", "Contact for the organization for a certain purpose.", 0, java.lang.Integer.MAX_VALUE, contact));
690      }
691
692      @Override
693      public void setProperty(String name, Base value) throws FHIRException {
694        if (name.equals("identifier"))
695          this.getIdentifier().add(castToIdentifier(value));
696        else if (name.equals("active"))
697          this.active = castToBoolean(value); // BooleanType
698        else if (name.equals("type"))
699          this.type = castToCodeableConcept(value); // CodeableConcept
700        else if (name.equals("name"))
701          this.name = castToString(value); // StringType
702        else if (name.equals("telecom"))
703          this.getTelecom().add(castToContactPoint(value));
704        else if (name.equals("address"))
705          this.getAddress().add(castToAddress(value));
706        else if (name.equals("partOf"))
707          this.partOf = castToReference(value); // Reference
708        else if (name.equals("contact"))
709          this.getContact().add((OrganizationContactComponent) value);
710        else
711          super.setProperty(name, value);
712      }
713
714      @Override
715      public Base addChild(String name) throws FHIRException {
716        if (name.equals("identifier")) {
717          return addIdentifier();
718        }
719        else if (name.equals("active")) {
720          throw new FHIRException("Cannot call addChild on a primitive type Organization.active");
721        }
722        else if (name.equals("type")) {
723          this.type = new CodeableConcept();
724          return this.type;
725        }
726        else if (name.equals("name")) {
727          throw new FHIRException("Cannot call addChild on a primitive type Organization.name");
728        }
729        else if (name.equals("telecom")) {
730          return addTelecom();
731        }
732        else if (name.equals("address")) {
733          return addAddress();
734        }
735        else if (name.equals("partOf")) {
736          this.partOf = new Reference();
737          return this.partOf;
738        }
739        else if (name.equals("contact")) {
740          return addContact();
741        }
742        else
743          return super.addChild(name);
744      }
745
746  public String fhirType() {
747    return "Organization";
748
749  }
750
751      public Organization copy() {
752        Organization dst = new Organization();
753        copyValues(dst);
754        if (identifier != null) {
755          dst.identifier = new ArrayList<Identifier>();
756          for (Identifier i : identifier)
757            dst.identifier.add(i.copy());
758        };
759        dst.active = active == null ? null : active.copy();
760        dst.type = type == null ? null : type.copy();
761        dst.name = name == null ? null : name.copy();
762        if (telecom != null) {
763          dst.telecom = new ArrayList<ContactPoint>();
764          for (ContactPoint i : telecom)
765            dst.telecom.add(i.copy());
766        };
767        if (address != null) {
768          dst.address = new ArrayList<Address>();
769          for (Address i : address)
770            dst.address.add(i.copy());
771        };
772        dst.partOf = partOf == null ? null : partOf.copy();
773        if (contact != null) {
774          dst.contact = new ArrayList<OrganizationContactComponent>();
775          for (OrganizationContactComponent i : contact)
776            dst.contact.add(i.copy());
777        };
778        return dst;
779      }
780
781      protected Organization typedCopy() {
782        return copy();
783      }
784
785      @Override
786      public boolean equalsDeep(Base other) {
787        if (!super.equalsDeep(other))
788          return false;
789        if (!(other instanceof Organization))
790          return false;
791        Organization o = (Organization) other;
792        return compareDeep(identifier, o.identifier, true) && compareDeep(active, o.active, true) && compareDeep(type, o.type, true)
793           && compareDeep(name, o.name, true) && compareDeep(telecom, o.telecom, true) && compareDeep(address, o.address, true)
794           && compareDeep(partOf, o.partOf, true) && compareDeep(contact, o.contact, true);
795      }
796
797      @Override
798      public boolean equalsShallow(Base other) {
799        if (!super.equalsShallow(other))
800          return false;
801        if (!(other instanceof Organization))
802          return false;
803        Organization o = (Organization) other;
804        return compareValues(active, o.active, true) && compareValues(name, o.name, true);
805      }
806
807      public boolean isEmpty() {
808        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (active == null || active.isEmpty())
809           && (type == null || type.isEmpty()) && (name == null || name.isEmpty()) && (telecom == null || telecom.isEmpty())
810           && (address == null || address.isEmpty()) && (partOf == null || partOf.isEmpty()) && (contact == null || contact.isEmpty())
811          ;
812      }
813
814  @Override
815  public ResourceType getResourceType() {
816    return ResourceType.Organization;
817   }
818
819  @SearchParamDefinition(name="identifier", path="Organization.identifier", description="Any identifier for the organization (not the accreditation issuer's identifier)", type="token" )
820  public static final String SP_IDENTIFIER = "identifier";
821  @SearchParamDefinition(name="partof", path="Organization.partOf", description="Search all organizations that are part of the given organization", type="reference" )
822  public static final String SP_PARTOF = "partof";
823  @SearchParamDefinition(name="phonetic", path="Organization.name", description="A portion of the organization's name using some kind of phonetic matching algorithm", type="string" )
824  public static final String SP_PHONETIC = "phonetic";
825  @SearchParamDefinition(name="address", path="Organization.address", description="A (part of the) address of the Organization", type="string" )
826  public static final String SP_ADDRESS = "address";
827  @SearchParamDefinition(name="address-state", path="Organization.address.state", description="A state specified in an address", type="string" )
828  public static final String SP_ADDRESSSTATE = "address-state";
829  @SearchParamDefinition(name="name", path="Organization.name", description="A portion of the organization's name", type="string" )
830  public static final String SP_NAME = "name";
831  @SearchParamDefinition(name="address-use", path="Organization.address.use", description="A use code specified in an address", type="token" )
832  public static final String SP_ADDRESSUSE = "address-use";
833  @SearchParamDefinition(name="active", path="Organization.active", description="Whether the organization's record is active", type="token" )
834  public static final String SP_ACTIVE = "active";
835  @SearchParamDefinition(name="type", path="Organization.type", description="A code for the type of organization", type="token" )
836  public static final String SP_TYPE = "type";
837  @SearchParamDefinition(name="address-city", path="Organization.address.city", description="A city specified in an address", type="string" )
838  public static final String SP_ADDRESSCITY = "address-city";
839  @SearchParamDefinition(name="address-postalcode", path="Organization.address.postalCode", description="A postal code specified in an address", type="string" )
840  public static final String SP_ADDRESSPOSTALCODE = "address-postalcode";
841  @SearchParamDefinition(name="address-country", path="Organization.address.country", description="A country specified in an address", type="string" )
842  public static final String SP_ADDRESSCOUNTRY = "address-country";
843
844}
845