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