001package org.hl7.fhir.dstu2.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 Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
036import java.util.ArrayList;
037import java.util.Date;
038import java.util.List;
039
040import ca.uhn.fhir.model.api.annotation.Child;
041import ca.uhn.fhir.model.api.annotation.Description;
042import ca.uhn.fhir.model.api.annotation.ResourceDef;
043import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
044import org.hl7.fhir.exceptions.FHIRException;
045/**
046 * This resource provides the insurance eligibility details from the insurer regarding a specified coverage and optionally some class of service.
047 */
048@ResourceDef(name="EligibilityRequest", profile="http://hl7.org/fhir/Profile/EligibilityRequest")
049public class EligibilityRequest extends DomainResource {
050
051    /**
052     * The Response business identifier.
053     */
054    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
055    @Description(shortDefinition="Business Identifier", formalDefinition="The Response business identifier." )
056    protected List<Identifier> identifier;
057
058    /**
059     * The version of the style of resource contents. This should be mapped to the allowable profiles for this and supporting resources.
060     */
061    @Child(name = "ruleset", type = {Coding.class}, order=1, min=0, max=1, modifier=false, summary=true)
062    @Description(shortDefinition="Resource version", formalDefinition="The version of the style of resource contents. This should be mapped to the allowable profiles for this and supporting resources." )
063    protected Coding ruleset;
064
065    /**
066     * The style (standard) and version of the original material which was converted into this resource.
067     */
068    @Child(name = "originalRuleset", type = {Coding.class}, order=2, min=0, max=1, modifier=false, summary=true)
069    @Description(shortDefinition="Original version", formalDefinition="The style (standard) and version of the original material which was converted into this resource." )
070    protected Coding originalRuleset;
071
072    /**
073     * The date when this resource was created.
074     */
075    @Child(name = "created", type = {DateTimeType.class}, order=3, min=0, max=1, modifier=false, summary=true)
076    @Description(shortDefinition="Creation date", formalDefinition="The date when this resource was created." )
077    protected DateTimeType created;
078
079    /**
080     * The Insurer who is target  of the request.
081     */
082    @Child(name = "target", type = {Organization.class}, order=4, min=0, max=1, modifier=false, summary=true)
083    @Description(shortDefinition="Insurer", formalDefinition="The Insurer who is target  of the request." )
084    protected Reference target;
085
086    /**
087     * The actual object that is the target of the reference (The Insurer who is target  of the request.)
088     */
089    protected Organization targetTarget;
090
091    /**
092     * The practitioner who is responsible for the services rendered to the patient.
093     */
094    @Child(name = "provider", type = {Practitioner.class}, order=5, min=0, max=1, modifier=false, summary=true)
095    @Description(shortDefinition="Responsible practitioner", formalDefinition="The practitioner who is responsible for the services rendered to the patient." )
096    protected Reference provider;
097
098    /**
099     * The actual object that is the target of the reference (The practitioner who is responsible for the services rendered to the patient.)
100     */
101    protected Practitioner providerTarget;
102
103    /**
104     * The organization which is responsible for the services rendered to the patient.
105     */
106    @Child(name = "organization", type = {Organization.class}, order=6, min=0, max=1, modifier=false, summary=true)
107    @Description(shortDefinition="Responsible organization", formalDefinition="The organization which is responsible for the services rendered to the patient." )
108    protected Reference organization;
109
110    /**
111     * The actual object that is the target of the reference (The organization which is responsible for the services rendered to the patient.)
112     */
113    protected Organization organizationTarget;
114
115    private static final long serialVersionUID = 1836339504L;
116
117  /*
118   * Constructor
119   */
120    public EligibilityRequest() {
121      super();
122    }
123
124    /**
125     * @return {@link #identifier} (The Response business identifier.)
126     */
127    public List<Identifier> getIdentifier() { 
128      if (this.identifier == null)
129        this.identifier = new ArrayList<Identifier>();
130      return this.identifier;
131    }
132
133    public boolean hasIdentifier() { 
134      if (this.identifier == null)
135        return false;
136      for (Identifier item : this.identifier)
137        if (!item.isEmpty())
138          return true;
139      return false;
140    }
141
142    /**
143     * @return {@link #identifier} (The Response business identifier.)
144     */
145    // syntactic sugar
146    public Identifier addIdentifier() { //3
147      Identifier t = new Identifier();
148      if (this.identifier == null)
149        this.identifier = new ArrayList<Identifier>();
150      this.identifier.add(t);
151      return t;
152    }
153
154    // syntactic sugar
155    public EligibilityRequest addIdentifier(Identifier t) { //3
156      if (t == null)
157        return this;
158      if (this.identifier == null)
159        this.identifier = new ArrayList<Identifier>();
160      this.identifier.add(t);
161      return this;
162    }
163
164    /**
165     * @return {@link #ruleset} (The version of the style of resource contents. This should be mapped to the allowable profiles for this and supporting resources.)
166     */
167    public Coding getRuleset() { 
168      if (this.ruleset == null)
169        if (Configuration.errorOnAutoCreate())
170          throw new Error("Attempt to auto-create EligibilityRequest.ruleset");
171        else if (Configuration.doAutoCreate())
172          this.ruleset = new Coding(); // cc
173      return this.ruleset;
174    }
175
176    public boolean hasRuleset() { 
177      return this.ruleset != null && !this.ruleset.isEmpty();
178    }
179
180    /**
181     * @param value {@link #ruleset} (The version of the style of resource contents. This should be mapped to the allowable profiles for this and supporting resources.)
182     */
183    public EligibilityRequest setRuleset(Coding value) { 
184      this.ruleset = value;
185      return this;
186    }
187
188    /**
189     * @return {@link #originalRuleset} (The style (standard) and version of the original material which was converted into this resource.)
190     */
191    public Coding getOriginalRuleset() { 
192      if (this.originalRuleset == null)
193        if (Configuration.errorOnAutoCreate())
194          throw new Error("Attempt to auto-create EligibilityRequest.originalRuleset");
195        else if (Configuration.doAutoCreate())
196          this.originalRuleset = new Coding(); // cc
197      return this.originalRuleset;
198    }
199
200    public boolean hasOriginalRuleset() { 
201      return this.originalRuleset != null && !this.originalRuleset.isEmpty();
202    }
203
204    /**
205     * @param value {@link #originalRuleset} (The style (standard) and version of the original material which was converted into this resource.)
206     */
207    public EligibilityRequest setOriginalRuleset(Coding value) { 
208      this.originalRuleset = value;
209      return this;
210    }
211
212    /**
213     * @return {@link #created} (The date when this resource was created.). This is the underlying object with id, value and extensions. The accessor "getCreated" gives direct access to the value
214     */
215    public DateTimeType getCreatedElement() { 
216      if (this.created == null)
217        if (Configuration.errorOnAutoCreate())
218          throw new Error("Attempt to auto-create EligibilityRequest.created");
219        else if (Configuration.doAutoCreate())
220          this.created = new DateTimeType(); // bb
221      return this.created;
222    }
223
224    public boolean hasCreatedElement() { 
225      return this.created != null && !this.created.isEmpty();
226    }
227
228    public boolean hasCreated() { 
229      return this.created != null && !this.created.isEmpty();
230    }
231
232    /**
233     * @param value {@link #created} (The date when this resource was created.). This is the underlying object with id, value and extensions. The accessor "getCreated" gives direct access to the value
234     */
235    public EligibilityRequest setCreatedElement(DateTimeType value) { 
236      this.created = value;
237      return this;
238    }
239
240    /**
241     * @return The date when this resource was created.
242     */
243    public Date getCreated() { 
244      return this.created == null ? null : this.created.getValue();
245    }
246
247    /**
248     * @param value The date when this resource was created.
249     */
250    public EligibilityRequest setCreated(Date value) { 
251      if (value == null)
252        this.created = null;
253      else {
254        if (this.created == null)
255          this.created = new DateTimeType();
256        this.created.setValue(value);
257      }
258      return this;
259    }
260
261    /**
262     * @return {@link #target} (The Insurer who is target  of the request.)
263     */
264    public Reference getTarget() { 
265      if (this.target == null)
266        if (Configuration.errorOnAutoCreate())
267          throw new Error("Attempt to auto-create EligibilityRequest.target");
268        else if (Configuration.doAutoCreate())
269          this.target = new Reference(); // cc
270      return this.target;
271    }
272
273    public boolean hasTarget() { 
274      return this.target != null && !this.target.isEmpty();
275    }
276
277    /**
278     * @param value {@link #target} (The Insurer who is target  of the request.)
279     */
280    public EligibilityRequest setTarget(Reference value) { 
281      this.target = value;
282      return this;
283    }
284
285    /**
286     * @return {@link #target} 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 Insurer who is target  of the request.)
287     */
288    public Organization getTargetTarget() { 
289      if (this.targetTarget == null)
290        if (Configuration.errorOnAutoCreate())
291          throw new Error("Attempt to auto-create EligibilityRequest.target");
292        else if (Configuration.doAutoCreate())
293          this.targetTarget = new Organization(); // aa
294      return this.targetTarget;
295    }
296
297    /**
298     * @param value {@link #target} 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 Insurer who is target  of the request.)
299     */
300    public EligibilityRequest setTargetTarget(Organization value) { 
301      this.targetTarget = value;
302      return this;
303    }
304
305    /**
306     * @return {@link #provider} (The practitioner who is responsible for the services rendered to the patient.)
307     */
308    public Reference getProvider() { 
309      if (this.provider == null)
310        if (Configuration.errorOnAutoCreate())
311          throw new Error("Attempt to auto-create EligibilityRequest.provider");
312        else if (Configuration.doAutoCreate())
313          this.provider = new Reference(); // cc
314      return this.provider;
315    }
316
317    public boolean hasProvider() { 
318      return this.provider != null && !this.provider.isEmpty();
319    }
320
321    /**
322     * @param value {@link #provider} (The practitioner who is responsible for the services rendered to the patient.)
323     */
324    public EligibilityRequest setProvider(Reference value) { 
325      this.provider = value;
326      return this;
327    }
328
329    /**
330     * @return {@link #provider} 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 practitioner who is responsible for the services rendered to the patient.)
331     */
332    public Practitioner getProviderTarget() { 
333      if (this.providerTarget == null)
334        if (Configuration.errorOnAutoCreate())
335          throw new Error("Attempt to auto-create EligibilityRequest.provider");
336        else if (Configuration.doAutoCreate())
337          this.providerTarget = new Practitioner(); // aa
338      return this.providerTarget;
339    }
340
341    /**
342     * @param value {@link #provider} 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 practitioner who is responsible for the services rendered to the patient.)
343     */
344    public EligibilityRequest setProviderTarget(Practitioner value) { 
345      this.providerTarget = value;
346      return this;
347    }
348
349    /**
350     * @return {@link #organization} (The organization which is responsible for the services rendered to the patient.)
351     */
352    public Reference getOrganization() { 
353      if (this.organization == null)
354        if (Configuration.errorOnAutoCreate())
355          throw new Error("Attempt to auto-create EligibilityRequest.organization");
356        else if (Configuration.doAutoCreate())
357          this.organization = new Reference(); // cc
358      return this.organization;
359    }
360
361    public boolean hasOrganization() { 
362      return this.organization != null && !this.organization.isEmpty();
363    }
364
365    /**
366     * @param value {@link #organization} (The organization which is responsible for the services rendered to the patient.)
367     */
368    public EligibilityRequest setOrganization(Reference value) { 
369      this.organization = value;
370      return this;
371    }
372
373    /**
374     * @return {@link #organization} 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 which is responsible for the services rendered to the patient.)
375     */
376    public Organization getOrganizationTarget() { 
377      if (this.organizationTarget == null)
378        if (Configuration.errorOnAutoCreate())
379          throw new Error("Attempt to auto-create EligibilityRequest.organization");
380        else if (Configuration.doAutoCreate())
381          this.organizationTarget = new Organization(); // aa
382      return this.organizationTarget;
383    }
384
385    /**
386     * @param value {@link #organization} 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 which is responsible for the services rendered to the patient.)
387     */
388    public EligibilityRequest setOrganizationTarget(Organization value) { 
389      this.organizationTarget = value;
390      return this;
391    }
392
393      protected void listChildren(List<Property> childrenList) {
394        super.listChildren(childrenList);
395        childrenList.add(new Property("identifier", "Identifier", "The Response business identifier.", 0, java.lang.Integer.MAX_VALUE, identifier));
396        childrenList.add(new Property("ruleset", "Coding", "The version of the style of resource contents. This should be mapped to the allowable profiles for this and supporting resources.", 0, java.lang.Integer.MAX_VALUE, ruleset));
397        childrenList.add(new Property("originalRuleset", "Coding", "The style (standard) and version of the original material which was converted into this resource.", 0, java.lang.Integer.MAX_VALUE, originalRuleset));
398        childrenList.add(new Property("created", "dateTime", "The date when this resource was created.", 0, java.lang.Integer.MAX_VALUE, created));
399        childrenList.add(new Property("target", "Reference(Organization)", "The Insurer who is target  of the request.", 0, java.lang.Integer.MAX_VALUE, target));
400        childrenList.add(new Property("provider", "Reference(Practitioner)", "The practitioner who is responsible for the services rendered to the patient.", 0, java.lang.Integer.MAX_VALUE, provider));
401        childrenList.add(new Property("organization", "Reference(Organization)", "The organization which is responsible for the services rendered to the patient.", 0, java.lang.Integer.MAX_VALUE, organization));
402      }
403
404      @Override
405      public void setProperty(String name, Base value) throws FHIRException {
406        if (name.equals("identifier"))
407          this.getIdentifier().add(castToIdentifier(value));
408        else if (name.equals("ruleset"))
409          this.ruleset = castToCoding(value); // Coding
410        else if (name.equals("originalRuleset"))
411          this.originalRuleset = castToCoding(value); // Coding
412        else if (name.equals("created"))
413          this.created = castToDateTime(value); // DateTimeType
414        else if (name.equals("target"))
415          this.target = castToReference(value); // Reference
416        else if (name.equals("provider"))
417          this.provider = castToReference(value); // Reference
418        else if (name.equals("organization"))
419          this.organization = castToReference(value); // Reference
420        else
421          super.setProperty(name, value);
422      }
423
424      @Override
425      public Base addChild(String name) throws FHIRException {
426        if (name.equals("identifier")) {
427          return addIdentifier();
428        }
429        else if (name.equals("ruleset")) {
430          this.ruleset = new Coding();
431          return this.ruleset;
432        }
433        else if (name.equals("originalRuleset")) {
434          this.originalRuleset = new Coding();
435          return this.originalRuleset;
436        }
437        else if (name.equals("created")) {
438          throw new FHIRException("Cannot call addChild on a primitive type EligibilityRequest.created");
439        }
440        else if (name.equals("target")) {
441          this.target = new Reference();
442          return this.target;
443        }
444        else if (name.equals("provider")) {
445          this.provider = new Reference();
446          return this.provider;
447        }
448        else if (name.equals("organization")) {
449          this.organization = new Reference();
450          return this.organization;
451        }
452        else
453          return super.addChild(name);
454      }
455
456  public String fhirType() {
457    return "EligibilityRequest";
458
459  }
460
461      public EligibilityRequest copy() {
462        EligibilityRequest dst = new EligibilityRequest();
463        copyValues(dst);
464        if (identifier != null) {
465          dst.identifier = new ArrayList<Identifier>();
466          for (Identifier i : identifier)
467            dst.identifier.add(i.copy());
468        };
469        dst.ruleset = ruleset == null ? null : ruleset.copy();
470        dst.originalRuleset = originalRuleset == null ? null : originalRuleset.copy();
471        dst.created = created == null ? null : created.copy();
472        dst.target = target == null ? null : target.copy();
473        dst.provider = provider == null ? null : provider.copy();
474        dst.organization = organization == null ? null : organization.copy();
475        return dst;
476      }
477
478      protected EligibilityRequest typedCopy() {
479        return copy();
480      }
481
482      @Override
483      public boolean equalsDeep(Base other) {
484        if (!super.equalsDeep(other))
485          return false;
486        if (!(other instanceof EligibilityRequest))
487          return false;
488        EligibilityRequest o = (EligibilityRequest) other;
489        return compareDeep(identifier, o.identifier, true) && compareDeep(ruleset, o.ruleset, true) && compareDeep(originalRuleset, o.originalRuleset, true)
490           && compareDeep(created, o.created, true) && compareDeep(target, o.target, true) && compareDeep(provider, o.provider, true)
491           && compareDeep(organization, o.organization, true);
492      }
493
494      @Override
495      public boolean equalsShallow(Base other) {
496        if (!super.equalsShallow(other))
497          return false;
498        if (!(other instanceof EligibilityRequest))
499          return false;
500        EligibilityRequest o = (EligibilityRequest) other;
501        return compareValues(created, o.created, true);
502      }
503
504      public boolean isEmpty() {
505        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (ruleset == null || ruleset.isEmpty())
506           && (originalRuleset == null || originalRuleset.isEmpty()) && (created == null || created.isEmpty())
507           && (target == null || target.isEmpty()) && (provider == null || provider.isEmpty()) && (organization == null || organization.isEmpty())
508          ;
509      }
510
511  @Override
512  public ResourceType getResourceType() {
513    return ResourceType.EligibilityRequest;
514   }
515
516  @SearchParamDefinition(name="identifier", path="EligibilityRequest.identifier", description="The business identifier of the Eligibility", type="token" )
517  public static final String SP_IDENTIFIER = "identifier";
518
519}