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