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