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 * 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.
047 */
048@ResourceDef(name="Basic", profile="http://hl7.org/fhir/Profile/Basic")
049public class Basic extends DomainResource {
050
051    /**
052     * Identifier assigned to the resource for business purposes, outside the context of FHIR.
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="Identifier assigned to the resource for business purposes, outside the context of FHIR." )
056    protected List<Identifier> identifier;
057
058    /**
059     * Identifies the 'type' of resource - equivalent to the resource name for other resources.
060     */
061    @Child(name = "code", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=true, summary=true)
062    @Description(shortDefinition="Kind of Resource", formalDefinition="Identifies the 'type' of resource - equivalent to the resource name for other resources." )
063    protected CodeableConcept code;
064
065    /**
066     * Identifies the patient, practitioner, device or any other resource that is the "focus" of this resource.
067     */
068    @Child(name = "subject", type = {}, order=2, min=0, max=1, modifier=false, summary=true)
069    @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." )
070    protected Reference subject;
071
072    /**
073     * 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.)
074     */
075    protected Resource subjectTarget;
076
077    /**
078     * Indicates who was responsible for creating the resource instance.
079     */
080    @Child(name = "author", type = {Practitioner.class, Patient.class, RelatedPerson.class}, order=3, min=0, max=1, modifier=false, summary=true)
081    @Description(shortDefinition="Who created", formalDefinition="Indicates who was responsible for creating the resource instance." )
082    protected Reference author;
083
084    /**
085     * The actual object that is the target of the reference (Indicates who was responsible for creating the resource instance.)
086     */
087    protected Resource authorTarget;
088
089    /**
090     * Identifies when the resource was first created.
091     */
092    @Child(name = "created", type = {DateType.class}, order=4, min=0, max=1, modifier=false, summary=true)
093    @Description(shortDefinition="When created", formalDefinition="Identifies when the resource was first created." )
094    protected DateType created;
095
096    private static final long serialVersionUID = 916539354L;
097
098  /*
099   * Constructor
100   */
101    public Basic() {
102      super();
103    }
104
105  /*
106   * Constructor
107   */
108    public Basic(CodeableConcept code) {
109      super();
110      this.code = code;
111    }
112
113    /**
114     * @return {@link #identifier} (Identifier assigned to the resource for business purposes, outside the context of FHIR.)
115     */
116    public List<Identifier> getIdentifier() { 
117      if (this.identifier == null)
118        this.identifier = new ArrayList<Identifier>();
119      return this.identifier;
120    }
121
122    public boolean hasIdentifier() { 
123      if (this.identifier == null)
124        return false;
125      for (Identifier item : this.identifier)
126        if (!item.isEmpty())
127          return true;
128      return false;
129    }
130
131    /**
132     * @return {@link #identifier} (Identifier assigned to the resource for business purposes, outside the context of FHIR.)
133     */
134    // syntactic sugar
135    public Identifier addIdentifier() { //3
136      Identifier t = new Identifier();
137      if (this.identifier == null)
138        this.identifier = new ArrayList<Identifier>();
139      this.identifier.add(t);
140      return t;
141    }
142
143    // syntactic sugar
144    public Basic addIdentifier(Identifier t) { //3
145      if (t == null)
146        return this;
147      if (this.identifier == null)
148        this.identifier = new ArrayList<Identifier>();
149      this.identifier.add(t);
150      return this;
151    }
152
153    /**
154     * @return {@link #code} (Identifies the 'type' of resource - equivalent to the resource name for other resources.)
155     */
156    public CodeableConcept getCode() { 
157      if (this.code == null)
158        if (Configuration.errorOnAutoCreate())
159          throw new Error("Attempt to auto-create Basic.code");
160        else if (Configuration.doAutoCreate())
161          this.code = new CodeableConcept(); // cc
162      return this.code;
163    }
164
165    public boolean hasCode() { 
166      return this.code != null && !this.code.isEmpty();
167    }
168
169    /**
170     * @param value {@link #code} (Identifies the 'type' of resource - equivalent to the resource name for other resources.)
171     */
172    public Basic setCode(CodeableConcept value) { 
173      this.code = value;
174      return this;
175    }
176
177    /**
178     * @return {@link #subject} (Identifies the patient, practitioner, device or any other resource that is the "focus" of this resource.)
179     */
180    public Reference getSubject() { 
181      if (this.subject == null)
182        if (Configuration.errorOnAutoCreate())
183          throw new Error("Attempt to auto-create Basic.subject");
184        else if (Configuration.doAutoCreate())
185          this.subject = new Reference(); // cc
186      return this.subject;
187    }
188
189    public boolean hasSubject() { 
190      return this.subject != null && !this.subject.isEmpty();
191    }
192
193    /**
194     * @param value {@link #subject} (Identifies the patient, practitioner, device or any other resource that is the "focus" of this resource.)
195     */
196    public Basic setSubject(Reference value) { 
197      this.subject = value;
198      return this;
199    }
200
201    /**
202     * @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.)
203     */
204    public Resource getSubjectTarget() { 
205      return this.subjectTarget;
206    }
207
208    /**
209     * @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.)
210     */
211    public Basic setSubjectTarget(Resource value) { 
212      this.subjectTarget = value;
213      return this;
214    }
215
216    /**
217     * @return {@link #author} (Indicates who was responsible for creating the resource instance.)
218     */
219    public Reference getAuthor() { 
220      if (this.author == null)
221        if (Configuration.errorOnAutoCreate())
222          throw new Error("Attempt to auto-create Basic.author");
223        else if (Configuration.doAutoCreate())
224          this.author = new Reference(); // cc
225      return this.author;
226    }
227
228    public boolean hasAuthor() { 
229      return this.author != null && !this.author.isEmpty();
230    }
231
232    /**
233     * @param value {@link #author} (Indicates who was responsible for creating the resource instance.)
234     */
235    public Basic setAuthor(Reference value) { 
236      this.author = value;
237      return this;
238    }
239
240    /**
241     * @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.)
242     */
243    public Resource getAuthorTarget() { 
244      return this.authorTarget;
245    }
246
247    /**
248     * @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.)
249     */
250    public Basic setAuthorTarget(Resource value) { 
251      this.authorTarget = value;
252      return this;
253    }
254
255    /**
256     * @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
257     */
258    public DateType getCreatedElement() { 
259      if (this.created == null)
260        if (Configuration.errorOnAutoCreate())
261          throw new Error("Attempt to auto-create Basic.created");
262        else if (Configuration.doAutoCreate())
263          this.created = new DateType(); // bb
264      return this.created;
265    }
266
267    public boolean hasCreatedElement() { 
268      return this.created != null && !this.created.isEmpty();
269    }
270
271    public boolean hasCreated() { 
272      return this.created != null && !this.created.isEmpty();
273    }
274
275    /**
276     * @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
277     */
278    public Basic setCreatedElement(DateType value) { 
279      this.created = value;
280      return this;
281    }
282
283    /**
284     * @return Identifies when the resource was first created.
285     */
286    public Date getCreated() { 
287      return this.created == null ? null : this.created.getValue();
288    }
289
290    /**
291     * @param value Identifies when the resource was first created.
292     */
293    public Basic setCreated(Date value) { 
294      if (value == null)
295        this.created = null;
296      else {
297        if (this.created == null)
298          this.created = new DateType();
299        this.created.setValue(value);
300      }
301      return this;
302    }
303
304      protected void listChildren(List<Property> childrenList) {
305        super.listChildren(childrenList);
306        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));
307        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));
308        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));
309        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));
310        childrenList.add(new Property("created", "date", "Identifies when the resource was first created.", 0, java.lang.Integer.MAX_VALUE, created));
311      }
312
313      @Override
314      public void setProperty(String name, Base value) throws FHIRException {
315        if (name.equals("identifier"))
316          this.getIdentifier().add(castToIdentifier(value));
317        else if (name.equals("code"))
318          this.code = castToCodeableConcept(value); // CodeableConcept
319        else if (name.equals("subject"))
320          this.subject = castToReference(value); // Reference
321        else if (name.equals("author"))
322          this.author = castToReference(value); // Reference
323        else if (name.equals("created"))
324          this.created = castToDate(value); // DateType
325        else
326          super.setProperty(name, value);
327      }
328
329      @Override
330      public Base addChild(String name) throws FHIRException {
331        if (name.equals("identifier")) {
332          return addIdentifier();
333        }
334        else if (name.equals("code")) {
335          this.code = new CodeableConcept();
336          return this.code;
337        }
338        else if (name.equals("subject")) {
339          this.subject = new Reference();
340          return this.subject;
341        }
342        else if (name.equals("author")) {
343          this.author = new Reference();
344          return this.author;
345        }
346        else if (name.equals("created")) {
347          throw new FHIRException("Cannot call addChild on a primitive type Basic.created");
348        }
349        else
350          return super.addChild(name);
351      }
352
353  public String fhirType() {
354    return "Basic";
355
356  }
357
358      public Basic copy() {
359        Basic dst = new Basic();
360        copyValues(dst);
361        if (identifier != null) {
362          dst.identifier = new ArrayList<Identifier>();
363          for (Identifier i : identifier)
364            dst.identifier.add(i.copy());
365        };
366        dst.code = code == null ? null : code.copy();
367        dst.subject = subject == null ? null : subject.copy();
368        dst.author = author == null ? null : author.copy();
369        dst.created = created == null ? null : created.copy();
370        return dst;
371      }
372
373      protected Basic typedCopy() {
374        return copy();
375      }
376
377      @Override
378      public boolean equalsDeep(Base other) {
379        if (!super.equalsDeep(other))
380          return false;
381        if (!(other instanceof Basic))
382          return false;
383        Basic o = (Basic) other;
384        return compareDeep(identifier, o.identifier, true) && compareDeep(code, o.code, true) && compareDeep(subject, o.subject, true)
385           && compareDeep(author, o.author, true) && compareDeep(created, o.created, true);
386      }
387
388      @Override
389      public boolean equalsShallow(Base other) {
390        if (!super.equalsShallow(other))
391          return false;
392        if (!(other instanceof Basic))
393          return false;
394        Basic o = (Basic) other;
395        return compareValues(created, o.created, true);
396      }
397
398      public boolean isEmpty() {
399        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (code == null || code.isEmpty())
400           && (subject == null || subject.isEmpty()) && (author == null || author.isEmpty()) && (created == null || created.isEmpty())
401          ;
402      }
403
404  @Override
405  public ResourceType getResourceType() {
406    return ResourceType.Basic;
407   }
408
409  @SearchParamDefinition(name="identifier", path="Basic.identifier", description="Business identifier", type="token" )
410  public static final String SP_IDENTIFIER = "identifier";
411  @SearchParamDefinition(name="code", path="Basic.code", description="Kind of Resource", type="token" )
412  public static final String SP_CODE = "code";
413  @SearchParamDefinition(name="subject", path="Basic.subject", description="Identifies the focus of this resource", type="reference" )
414  public static final String SP_SUBJECT = "subject";
415  @SearchParamDefinition(name="created", path="Basic.created", description="When created", type="date" )
416  public static final String SP_CREATED = "created";
417  @SearchParamDefinition(name="patient", path="Basic.subject", description="Identifies the focus of this resource", type="reference" )
418  public static final String SP_PATIENT = "patient";
419  @SearchParamDefinition(name="author", path="Basic.author", description="Who created", type="reference" )
420  public static final String SP_AUTHOR = "author";
421
422}