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