001package org.hl7.fhir.dstu2016may.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 Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
033import java.util.ArrayList;
034import java.util.Date;
035import java.util.List;
036
037import org.hl7.fhir.exceptions.FHIRException;
038
039import ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.Description;
041import ca.uhn.fhir.model.api.annotation.ResourceDef;
042import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
043/**
044 * Basic is used for handling concepts not yet defined in FHIR, narrative-only resources that don't map to an existing resource, and custom resources not appropriate for inclusion in the FHIR specification.
045 */
046@ResourceDef(name="Basic", profile="http://hl7.org/fhir/Profile/Basic")
047public class Basic extends DomainResource {
048
049    /**
050     * Identifier assigned to the resource for business purposes, outside the context of FHIR.
051     */
052    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
053    @Description(shortDefinition="Business identifier", formalDefinition="Identifier assigned to the resource for business purposes, outside the context of FHIR." )
054    protected List<Identifier> identifier;
055
056    /**
057     * Identifies the 'type' of resource - equivalent to the resource name for other resources.
058     */
059    @Child(name = "code", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=true, summary=true)
060    @Description(shortDefinition="Kind of Resource", formalDefinition="Identifies the 'type' of resource - equivalent to the resource name for other resources." )
061    protected CodeableConcept code;
062
063    /**
064     * Identifies the patient, practitioner, device or any other resource that is the "focus" of this resource.
065     */
066    @Child(name = "subject", type = {}, order=2, min=0, max=1, modifier=false, summary=true)
067    @Description(shortDefinition="Identifies the focus of this resource", formalDefinition="Identifies the patient, practitioner, device or any other resource that is the \"focus\" of this resource." )
068    protected Reference subject;
069
070    /**
071     * The actual object that is the target of the reference (Identifies the patient, practitioner, device or any other resource that is the "focus" of this resource.)
072     */
073    protected Resource subjectTarget;
074
075    /**
076     * Identifies when the resource was first created.
077     */
078    @Child(name = "created", type = {DateType.class}, order=3, min=0, max=1, modifier=false, summary=true)
079    @Description(shortDefinition="When created", formalDefinition="Identifies when the resource was first created." )
080    protected DateType created;
081
082    /**
083     * Indicates who was responsible for creating the resource instance.
084     */
085    @Child(name = "author", type = {Practitioner.class, Patient.class, RelatedPerson.class}, order=4, min=0, max=1, modifier=false, summary=true)
086    @Description(shortDefinition="Who created", formalDefinition="Indicates who was responsible for creating the resource instance." )
087    protected Reference author;
088
089    /**
090     * The actual object that is the target of the reference (Indicates who was responsible for creating the resource instance.)
091     */
092    protected Resource authorTarget;
093
094    private static final long serialVersionUID = 650756402L;
095
096  /**
097   * Constructor
098   */
099    public Basic() {
100      super();
101    }
102
103  /**
104   * Constructor
105   */
106    public Basic(CodeableConcept code) {
107      super();
108      this.code = code;
109    }
110
111    /**
112     * @return {@link #identifier} (Identifier assigned to the resource for business purposes, outside the context of FHIR.)
113     */
114    public List<Identifier> getIdentifier() { 
115      if (this.identifier == null)
116        this.identifier = new ArrayList<Identifier>();
117      return this.identifier;
118    }
119
120    public boolean hasIdentifier() { 
121      if (this.identifier == null)
122        return false;
123      for (Identifier item : this.identifier)
124        if (!item.isEmpty())
125          return true;
126      return false;
127    }
128
129    /**
130     * @return {@link #identifier} (Identifier assigned to the resource for business purposes, outside the context of FHIR.)
131     */
132    // syntactic sugar
133    public Identifier addIdentifier() { //3
134      Identifier t = new Identifier();
135      if (this.identifier == null)
136        this.identifier = new ArrayList<Identifier>();
137      this.identifier.add(t);
138      return t;
139    }
140
141    // syntactic sugar
142    public Basic addIdentifier(Identifier t) { //3
143      if (t == null)
144        return this;
145      if (this.identifier == null)
146        this.identifier = new ArrayList<Identifier>();
147      this.identifier.add(t);
148      return this;
149    }
150
151    /**
152     * @return {@link #code} (Identifies the 'type' of resource - equivalent to the resource name for other resources.)
153     */
154    public CodeableConcept getCode() { 
155      if (this.code == null)
156        if (Configuration.errorOnAutoCreate())
157          throw new Error("Attempt to auto-create Basic.code");
158        else if (Configuration.doAutoCreate())
159          this.code = new CodeableConcept(); // cc
160      return this.code;
161    }
162
163    public boolean hasCode() { 
164      return this.code != null && !this.code.isEmpty();
165    }
166
167    /**
168     * @param value {@link #code} (Identifies the 'type' of resource - equivalent to the resource name for other resources.)
169     */
170    public Basic setCode(CodeableConcept value) { 
171      this.code = value;
172      return this;
173    }
174
175    /**
176     * @return {@link #subject} (Identifies the patient, practitioner, device or any other resource that is the "focus" of this resource.)
177     */
178    public Reference getSubject() { 
179      if (this.subject == null)
180        if (Configuration.errorOnAutoCreate())
181          throw new Error("Attempt to auto-create Basic.subject");
182        else if (Configuration.doAutoCreate())
183          this.subject = new Reference(); // cc
184      return this.subject;
185    }
186
187    public boolean hasSubject() { 
188      return this.subject != null && !this.subject.isEmpty();
189    }
190
191    /**
192     * @param value {@link #subject} (Identifies the patient, practitioner, device or any other resource that is the "focus" of this resource.)
193     */
194    public Basic setSubject(Reference value) { 
195      this.subject = value;
196      return this;
197    }
198
199    /**
200     * @return {@link #subject} 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. (Identifies the patient, practitioner, device or any other resource that is the "focus" of this resource.)
201     */
202    public Resource getSubjectTarget() { 
203      return this.subjectTarget;
204    }
205
206    /**
207     * @param value {@link #subject} 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. (Identifies the patient, practitioner, device or any other resource that is the "focus" of this resource.)
208     */
209    public Basic setSubjectTarget(Resource value) { 
210      this.subjectTarget = value;
211      return this;
212    }
213
214    /**
215     * @return {@link #created} (Identifies when the resource was first created.). This is the underlying object with id, value and extensions. The accessor "getCreated" gives direct access to the value
216     */
217    public DateType getCreatedElement() { 
218      if (this.created == null)
219        if (Configuration.errorOnAutoCreate())
220          throw new Error("Attempt to auto-create Basic.created");
221        else if (Configuration.doAutoCreate())
222          this.created = new DateType(); // bb
223      return this.created;
224    }
225
226    public boolean hasCreatedElement() { 
227      return this.created != null && !this.created.isEmpty();
228    }
229
230    public boolean hasCreated() { 
231      return this.created != null && !this.created.isEmpty();
232    }
233
234    /**
235     * @param value {@link #created} (Identifies when the resource was first created.). This is the underlying object with id, value and extensions. The accessor "getCreated" gives direct access to the value
236     */
237    public Basic setCreatedElement(DateType value) { 
238      this.created = value;
239      return this;
240    }
241
242    /**
243     * @return Identifies when the resource was first created.
244     */
245    public Date getCreated() { 
246      return this.created == null ? null : this.created.getValue();
247    }
248
249    /**
250     * @param value Identifies when the resource was first created.
251     */
252    public Basic setCreated(Date value) { 
253      if (value == null)
254        this.created = null;
255      else {
256        if (this.created == null)
257          this.created = new DateType();
258        this.created.setValue(value);
259      }
260      return this;
261    }
262
263    /**
264     * @return {@link #author} (Indicates who was responsible for creating the resource instance.)
265     */
266    public Reference getAuthor() { 
267      if (this.author == null)
268        if (Configuration.errorOnAutoCreate())
269          throw new Error("Attempt to auto-create Basic.author");
270        else if (Configuration.doAutoCreate())
271          this.author = new Reference(); // cc
272      return this.author;
273    }
274
275    public boolean hasAuthor() { 
276      return this.author != null && !this.author.isEmpty();
277    }
278
279    /**
280     * @param value {@link #author} (Indicates who was responsible for creating the resource instance.)
281     */
282    public Basic setAuthor(Reference value) { 
283      this.author = value;
284      return this;
285    }
286
287    /**
288     * @return {@link #author} 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. (Indicates who was responsible for creating the resource instance.)
289     */
290    public Resource getAuthorTarget() { 
291      return this.authorTarget;
292    }
293
294    /**
295     * @param value {@link #author} 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. (Indicates who was responsible for creating the resource instance.)
296     */
297    public Basic setAuthorTarget(Resource value) { 
298      this.authorTarget = value;
299      return this;
300    }
301
302      protected void listChildren(List<Property> childrenList) {
303        super.listChildren(childrenList);
304        childrenList.add(new Property("identifier", "Identifier", "Identifier assigned to the resource for business purposes, outside the context of FHIR.", 0, java.lang.Integer.MAX_VALUE, identifier));
305        childrenList.add(new Property("code", "CodeableConcept", "Identifies the 'type' of resource - equivalent to the resource name for other resources.", 0, java.lang.Integer.MAX_VALUE, code));
306        childrenList.add(new Property("subject", "Reference(Any)", "Identifies the patient, practitioner, device or any other resource that is the \"focus\" of this resource.", 0, java.lang.Integer.MAX_VALUE, subject));
307        childrenList.add(new Property("created", "date", "Identifies when the resource was first created.", 0, java.lang.Integer.MAX_VALUE, created));
308        childrenList.add(new Property("author", "Reference(Practitioner|Patient|RelatedPerson)", "Indicates who was responsible for creating the resource instance.", 0, java.lang.Integer.MAX_VALUE, author));
309      }
310
311      @Override
312      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
313        switch (hash) {
314        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
315        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept
316        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
317        case 1028554472: /*created*/ return this.created == null ? new Base[0] : new Base[] {this.created}; // DateType
318        case -1406328437: /*author*/ return this.author == null ? new Base[0] : new Base[] {this.author}; // Reference
319        default: return super.getProperty(hash, name, checkValid);
320        }
321
322      }
323
324      @Override
325      public void setProperty(int hash, String name, Base value) throws FHIRException {
326        switch (hash) {
327        case -1618432855: // identifier
328          this.getIdentifier().add(castToIdentifier(value)); // Identifier
329          break;
330        case 3059181: // code
331          this.code = castToCodeableConcept(value); // CodeableConcept
332          break;
333        case -1867885268: // subject
334          this.subject = castToReference(value); // Reference
335          break;
336        case 1028554472: // created
337          this.created = castToDate(value); // DateType
338          break;
339        case -1406328437: // author
340          this.author = castToReference(value); // Reference
341          break;
342        default: super.setProperty(hash, name, value);
343        }
344
345      }
346
347      @Override
348      public void setProperty(String name, Base value) throws FHIRException {
349        if (name.equals("identifier"))
350          this.getIdentifier().add(castToIdentifier(value));
351        else if (name.equals("code"))
352          this.code = castToCodeableConcept(value); // CodeableConcept
353        else if (name.equals("subject"))
354          this.subject = castToReference(value); // Reference
355        else if (name.equals("created"))
356          this.created = castToDate(value); // DateType
357        else if (name.equals("author"))
358          this.author = castToReference(value); // Reference
359        else
360          super.setProperty(name, value);
361      }
362
363      @Override
364      public Base makeProperty(int hash, String name) throws FHIRException {
365        switch (hash) {
366        case -1618432855:  return addIdentifier(); // Identifier
367        case 3059181:  return getCode(); // CodeableConcept
368        case -1867885268:  return getSubject(); // Reference
369        case 1028554472: throw new FHIRException("Cannot make property created as it is not a complex type"); // DateType
370        case -1406328437:  return getAuthor(); // Reference
371        default: return super.makeProperty(hash, name);
372        }
373
374      }
375
376      @Override
377      public Base addChild(String name) throws FHIRException {
378        if (name.equals("identifier")) {
379          return addIdentifier();
380        }
381        else if (name.equals("code")) {
382          this.code = new CodeableConcept();
383          return this.code;
384        }
385        else if (name.equals("subject")) {
386          this.subject = new Reference();
387          return this.subject;
388        }
389        else if (name.equals("created")) {
390          throw new FHIRException("Cannot call addChild on a primitive type Basic.created");
391        }
392        else if (name.equals("author")) {
393          this.author = new Reference();
394          return this.author;
395        }
396        else
397          return super.addChild(name);
398      }
399
400  public String fhirType() {
401    return "Basic";
402
403  }
404
405      public Basic copy() {
406        Basic dst = new Basic();
407        copyValues(dst);
408        if (identifier != null) {
409          dst.identifier = new ArrayList<Identifier>();
410          for (Identifier i : identifier)
411            dst.identifier.add(i.copy());
412        };
413        dst.code = code == null ? null : code.copy();
414        dst.subject = subject == null ? null : subject.copy();
415        dst.created = created == null ? null : created.copy();
416        dst.author = author == null ? null : author.copy();
417        return dst;
418      }
419
420      protected Basic typedCopy() {
421        return copy();
422      }
423
424      @Override
425      public boolean equalsDeep(Base other) {
426        if (!super.equalsDeep(other))
427          return false;
428        if (!(other instanceof Basic))
429          return false;
430        Basic o = (Basic) other;
431        return compareDeep(identifier, o.identifier, true) && compareDeep(code, o.code, true) && compareDeep(subject, o.subject, true)
432           && compareDeep(created, o.created, true) && compareDeep(author, o.author, true);
433      }
434
435      @Override
436      public boolean equalsShallow(Base other) {
437        if (!super.equalsShallow(other))
438          return false;
439        if (!(other instanceof Basic))
440          return false;
441        Basic o = (Basic) other;
442        return compareValues(created, o.created, true);
443      }
444
445      public boolean isEmpty() {
446        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (code == null || code.isEmpty())
447           && (subject == null || subject.isEmpty()) && (created == null || created.isEmpty()) && (author == null || author.isEmpty())
448          ;
449      }
450
451  @Override
452  public ResourceType getResourceType() {
453    return ResourceType.Basic;
454   }
455
456 /**
457   * Search parameter: <b>author</b>
458   * <p>
459   * Description: <b>Who created</b><br>
460   * Type: <b>reference</b><br>
461   * Path: <b>Basic.author</b><br>
462   * </p>
463   */
464  @SearchParamDefinition(name="author", path="Basic.author", description="Who created", type="reference" )
465  public static final String SP_AUTHOR = "author";
466 /**
467   * <b>Fluent Client</b> search parameter constant for <b>author</b>
468   * <p>
469   * Description: <b>Who created</b><br>
470   * Type: <b>reference</b><br>
471   * Path: <b>Basic.author</b><br>
472   * </p>
473   */
474  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam AUTHOR = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_AUTHOR);
475
476/**
477   * Constant for fluent queries to be used to add include statements. Specifies
478   * the path value of "<b>Basic:author</b>".
479   */
480  public static final ca.uhn.fhir.model.api.Include INCLUDE_AUTHOR = new ca.uhn.fhir.model.api.Include("Basic:author").toLocked();
481
482 /**
483   * Search parameter: <b>patient</b>
484   * <p>
485   * Description: <b>Identifies the focus of this resource</b><br>
486   * Type: <b>reference</b><br>
487   * Path: <b>Basic.subject</b><br>
488   * </p>
489   */
490  @SearchParamDefinition(name="patient", path="Basic.subject", description="Identifies the focus of this resource", type="reference" )
491  public static final String SP_PATIENT = "patient";
492 /**
493   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
494   * <p>
495   * Description: <b>Identifies the focus of this resource</b><br>
496   * Type: <b>reference</b><br>
497   * Path: <b>Basic.subject</b><br>
498   * </p>
499   */
500  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
501
502/**
503   * Constant for fluent queries to be used to add include statements. Specifies
504   * the path value of "<b>Basic:patient</b>".
505   */
506  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("Basic:patient").toLocked();
507
508 /**
509   * Search parameter: <b>created</b>
510   * <p>
511   * Description: <b>When created</b><br>
512   * Type: <b>date</b><br>
513   * Path: <b>Basic.created</b><br>
514   * </p>
515   */
516  @SearchParamDefinition(name="created", path="Basic.created", description="When created", type="date" )
517  public static final String SP_CREATED = "created";
518 /**
519   * <b>Fluent Client</b> search parameter constant for <b>created</b>
520   * <p>
521   * Description: <b>When created</b><br>
522   * Type: <b>date</b><br>
523   * Path: <b>Basic.created</b><br>
524   * </p>
525   */
526  public static final ca.uhn.fhir.rest.gclient.DateClientParam CREATED = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_CREATED);
527
528 /**
529   * Search parameter: <b>subject</b>
530   * <p>
531   * Description: <b>Identifies the focus of this resource</b><br>
532   * Type: <b>reference</b><br>
533   * Path: <b>Basic.subject</b><br>
534   * </p>
535   */
536  @SearchParamDefinition(name="subject", path="Basic.subject", description="Identifies the focus of this resource", type="reference" )
537  public static final String SP_SUBJECT = "subject";
538 /**
539   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
540   * <p>
541   * Description: <b>Identifies the focus of this resource</b><br>
542   * Type: <b>reference</b><br>
543   * Path: <b>Basic.subject</b><br>
544   * </p>
545   */
546  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
547
548/**
549   * Constant for fluent queries to be used to add include statements. Specifies
550   * the path value of "<b>Basic:subject</b>".
551   */
552  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("Basic:subject").toLocked();
553
554 /**
555   * Search parameter: <b>code</b>
556   * <p>
557   * Description: <b>Kind of Resource</b><br>
558   * Type: <b>token</b><br>
559   * Path: <b>Basic.code</b><br>
560   * </p>
561   */
562  @SearchParamDefinition(name="code", path="Basic.code", description="Kind of Resource", type="token" )
563  public static final String SP_CODE = "code";
564 /**
565   * <b>Fluent Client</b> search parameter constant for <b>code</b>
566   * <p>
567   * Description: <b>Kind of Resource</b><br>
568   * Type: <b>token</b><br>
569   * Path: <b>Basic.code</b><br>
570   * </p>
571   */
572  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CODE);
573
574 /**
575   * Search parameter: <b>identifier</b>
576   * <p>
577   * Description: <b>Business identifier</b><br>
578   * Type: <b>token</b><br>
579   * Path: <b>Basic.identifier</b><br>
580   * </p>
581   */
582  @SearchParamDefinition(name="identifier", path="Basic.identifier", description="Business identifier", type="token" )
583  public static final String SP_IDENTIFIER = "identifier";
584 /**
585   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
586   * <p>
587   * Description: <b>Business identifier</b><br>
588   * Type: <b>token</b><br>
589   * Path: <b>Basic.identifier</b><br>
590   * </p>
591   */
592  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
593
594
595}
596