001package org.hl7.fhir.r4b.model;
002
003
004/*
005  Copyright (c) 2011+, HL7, Inc.
006  All rights reserved.
007  
008  Redistribution and use in source and binary forms, with or without modification, \
009  are permitted provided that the following conditions are met:
010  
011   * Redistributions of source code must retain the above copyright notice, this \
012     list of conditions and the following disclaimer.
013   * Redistributions in binary form must reproduce the above copyright notice, \
014     this list of conditions and the following disclaimer in the documentation \
015     and/or other materials provided with the distribution.
016   * Neither the name of HL7 nor the names of its contributors may be used to 
017     endorse or promote products derived from this software without specific 
018     prior written permission.
019  
020  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \
021  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \
022  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \
023  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \
024  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \
025  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \
026  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \
027  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \
028  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \
029  POSSIBILITY OF SUCH DAMAGE.
030  */
031
032// Generated on Fri, Dec 31, 2021 05:58+1100 for FHIR v4.3.0-snapshot1
033
034import java.util.ArrayList;
035import java.util.Date;
036import java.util.List;
037import org.hl7.fhir.utilities.Utilities;
038import org.hl7.fhir.r4b.model.Enumerations.*;
039import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
040import org.hl7.fhir.exceptions.FHIRException;
041import org.hl7.fhir.instance.model.api.ICompositeType;
042import ca.uhn.fhir.model.api.annotation.ResourceDef;
043import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
044import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
045import ca.uhn.fhir.model.api.annotation.Child;
046import ca.uhn.fhir.model.api.annotation.ChildOrder;
047import ca.uhn.fhir.model.api.annotation.Description;
048import ca.uhn.fhir.model.api.annotation.Block;
049
050/**
051 * Record details about an anatomical structure.  This resource may be used when a coded concept does not provide the necessary detail needed for the use case.
052 */
053@ResourceDef(name="BodyStructure", profile="http://hl7.org/fhir/StructureDefinition/BodyStructure")
054public class BodyStructure extends DomainResource {
055
056    /**
057     * Identifier for this instance of the anatomical structure.
058     */
059    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
060    @Description(shortDefinition="Bodystructure identifier", formalDefinition="Identifier for this instance of the anatomical structure." )
061    protected List<Identifier> identifier;
062
063    /**
064     * Whether this body site is in active use.
065     */
066    @Child(name = "active", type = {BooleanType.class}, order=1, min=0, max=1, modifier=true, summary=true)
067    @Description(shortDefinition="Whether this record is in active use", formalDefinition="Whether this body site is in active use." )
068    protected BooleanType active;
069
070    /**
071     * The kind of structure being represented by the body structure at `BodyStructure.location`.  This can define both normal and abnormal morphologies.
072     */
073    @Child(name = "morphology", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
074    @Description(shortDefinition="Kind of Structure", formalDefinition="The kind of structure being represented by the body structure at `BodyStructure.location`.  This can define both normal and abnormal morphologies." )
075    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/bodystructure-code")
076    protected CodeableConcept morphology;
077
078    /**
079     * The anatomical location or region of the specimen, lesion, or body structure.
080     */
081    @Child(name = "location", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=true)
082    @Description(shortDefinition="Body site", formalDefinition="The anatomical location or region of the specimen, lesion, or body structure." )
083    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/body-site")
084    protected CodeableConcept location;
085
086    /**
087     * Qualifier to refine the anatomical location.  These include qualifiers for laterality, relative location, directionality, number, and plane.
088     */
089    @Child(name = "locationQualifier", type = {CodeableConcept.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
090    @Description(shortDefinition="Body site modifier", formalDefinition="Qualifier to refine the anatomical location.  These include qualifiers for laterality, relative location, directionality, number, and plane." )
091    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/bodystructure-relative-location")
092    protected List<CodeableConcept> locationQualifier;
093
094    /**
095     * A summary, characterization or explanation of the body structure.
096     */
097    @Child(name = "description", type = {StringType.class}, order=5, min=0, max=1, modifier=false, summary=true)
098    @Description(shortDefinition="Text description", formalDefinition="A summary, characterization or explanation of the body structure." )
099    protected StringType description;
100
101    /**
102     * Image or images used to identify a location.
103     */
104    @Child(name = "image", type = {Attachment.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
105    @Description(shortDefinition="Attached images", formalDefinition="Image or images used to identify a location." )
106    protected List<Attachment> image;
107
108    /**
109     * The person to which the body site belongs.
110     */
111    @Child(name = "patient", type = {Patient.class}, order=7, min=1, max=1, modifier=false, summary=true)
112    @Description(shortDefinition="Who this is about", formalDefinition="The person to which the body site belongs." )
113    protected Reference patient;
114
115    private static final long serialVersionUID = 101980276L;
116
117  /**
118   * Constructor
119   */
120    public BodyStructure() {
121      super();
122    }
123
124  /**
125   * Constructor
126   */
127    public BodyStructure(Reference patient) {
128      super();
129      this.setPatient(patient);
130    }
131
132    /**
133     * @return {@link #identifier} (Identifier for this instance of the anatomical structure.)
134     */
135    public List<Identifier> getIdentifier() { 
136      if (this.identifier == null)
137        this.identifier = new ArrayList<Identifier>();
138      return this.identifier;
139    }
140
141    /**
142     * @return Returns a reference to <code>this</code> for easy method chaining
143     */
144    public BodyStructure setIdentifier(List<Identifier> theIdentifier) { 
145      this.identifier = theIdentifier;
146      return this;
147    }
148
149    public boolean hasIdentifier() { 
150      if (this.identifier == null)
151        return false;
152      for (Identifier item : this.identifier)
153        if (!item.isEmpty())
154          return true;
155      return false;
156    }
157
158    public Identifier addIdentifier() { //3
159      Identifier t = new Identifier();
160      if (this.identifier == null)
161        this.identifier = new ArrayList<Identifier>();
162      this.identifier.add(t);
163      return t;
164    }
165
166    public BodyStructure addIdentifier(Identifier t) { //3
167      if (t == null)
168        return this;
169      if (this.identifier == null)
170        this.identifier = new ArrayList<Identifier>();
171      this.identifier.add(t);
172      return this;
173    }
174
175    /**
176     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist {3}
177     */
178    public Identifier getIdentifierFirstRep() { 
179      if (getIdentifier().isEmpty()) {
180        addIdentifier();
181      }
182      return getIdentifier().get(0);
183    }
184
185    /**
186     * @return {@link #active} (Whether this body site is in active use.). This is the underlying object with id, value and extensions. The accessor "getActive" gives direct access to the value
187     */
188    public BooleanType getActiveElement() { 
189      if (this.active == null)
190        if (Configuration.errorOnAutoCreate())
191          throw new Error("Attempt to auto-create BodyStructure.active");
192        else if (Configuration.doAutoCreate())
193          this.active = new BooleanType(); // bb
194      return this.active;
195    }
196
197    public boolean hasActiveElement() { 
198      return this.active != null && !this.active.isEmpty();
199    }
200
201    public boolean hasActive() { 
202      return this.active != null && !this.active.isEmpty();
203    }
204
205    /**
206     * @param value {@link #active} (Whether this body site is in active use.). This is the underlying object with id, value and extensions. The accessor "getActive" gives direct access to the value
207     */
208    public BodyStructure setActiveElement(BooleanType value) { 
209      this.active = value;
210      return this;
211    }
212
213    /**
214     * @return Whether this body site is in active use.
215     */
216    public boolean getActive() { 
217      return this.active == null || this.active.isEmpty() ? false : this.active.getValue();
218    }
219
220    /**
221     * @param value Whether this body site is in active use.
222     */
223    public BodyStructure setActive(boolean value) { 
224        if (this.active == null)
225          this.active = new BooleanType();
226        this.active.setValue(value);
227      return this;
228    }
229
230    /**
231     * @return {@link #morphology} (The kind of structure being represented by the body structure at `BodyStructure.location`.  This can define both normal and abnormal morphologies.)
232     */
233    public CodeableConcept getMorphology() { 
234      if (this.morphology == null)
235        if (Configuration.errorOnAutoCreate())
236          throw new Error("Attempt to auto-create BodyStructure.morphology");
237        else if (Configuration.doAutoCreate())
238          this.morphology = new CodeableConcept(); // cc
239      return this.morphology;
240    }
241
242    public boolean hasMorphology() { 
243      return this.morphology != null && !this.morphology.isEmpty();
244    }
245
246    /**
247     * @param value {@link #morphology} (The kind of structure being represented by the body structure at `BodyStructure.location`.  This can define both normal and abnormal morphologies.)
248     */
249    public BodyStructure setMorphology(CodeableConcept value) { 
250      this.morphology = value;
251      return this;
252    }
253
254    /**
255     * @return {@link #location} (The anatomical location or region of the specimen, lesion, or body structure.)
256     */
257    public CodeableConcept getLocation() { 
258      if (this.location == null)
259        if (Configuration.errorOnAutoCreate())
260          throw new Error("Attempt to auto-create BodyStructure.location");
261        else if (Configuration.doAutoCreate())
262          this.location = new CodeableConcept(); // cc
263      return this.location;
264    }
265
266    public boolean hasLocation() { 
267      return this.location != null && !this.location.isEmpty();
268    }
269
270    /**
271     * @param value {@link #location} (The anatomical location or region of the specimen, lesion, or body structure.)
272     */
273    public BodyStructure setLocation(CodeableConcept value) { 
274      this.location = value;
275      return this;
276    }
277
278    /**
279     * @return {@link #locationQualifier} (Qualifier to refine the anatomical location.  These include qualifiers for laterality, relative location, directionality, number, and plane.)
280     */
281    public List<CodeableConcept> getLocationQualifier() { 
282      if (this.locationQualifier == null)
283        this.locationQualifier = new ArrayList<CodeableConcept>();
284      return this.locationQualifier;
285    }
286
287    /**
288     * @return Returns a reference to <code>this</code> for easy method chaining
289     */
290    public BodyStructure setLocationQualifier(List<CodeableConcept> theLocationQualifier) { 
291      this.locationQualifier = theLocationQualifier;
292      return this;
293    }
294
295    public boolean hasLocationQualifier() { 
296      if (this.locationQualifier == null)
297        return false;
298      for (CodeableConcept item : this.locationQualifier)
299        if (!item.isEmpty())
300          return true;
301      return false;
302    }
303
304    public CodeableConcept addLocationQualifier() { //3
305      CodeableConcept t = new CodeableConcept();
306      if (this.locationQualifier == null)
307        this.locationQualifier = new ArrayList<CodeableConcept>();
308      this.locationQualifier.add(t);
309      return t;
310    }
311
312    public BodyStructure addLocationQualifier(CodeableConcept t) { //3
313      if (t == null)
314        return this;
315      if (this.locationQualifier == null)
316        this.locationQualifier = new ArrayList<CodeableConcept>();
317      this.locationQualifier.add(t);
318      return this;
319    }
320
321    /**
322     * @return The first repetition of repeating field {@link #locationQualifier}, creating it if it does not already exist {3}
323     */
324    public CodeableConcept getLocationQualifierFirstRep() { 
325      if (getLocationQualifier().isEmpty()) {
326        addLocationQualifier();
327      }
328      return getLocationQualifier().get(0);
329    }
330
331    /**
332     * @return {@link #description} (A summary, characterization or explanation of the body structure.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
333     */
334    public StringType getDescriptionElement() { 
335      if (this.description == null)
336        if (Configuration.errorOnAutoCreate())
337          throw new Error("Attempt to auto-create BodyStructure.description");
338        else if (Configuration.doAutoCreate())
339          this.description = new StringType(); // bb
340      return this.description;
341    }
342
343    public boolean hasDescriptionElement() { 
344      return this.description != null && !this.description.isEmpty();
345    }
346
347    public boolean hasDescription() { 
348      return this.description != null && !this.description.isEmpty();
349    }
350
351    /**
352     * @param value {@link #description} (A summary, characterization or explanation of the body structure.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
353     */
354    public BodyStructure setDescriptionElement(StringType value) { 
355      this.description = value;
356      return this;
357    }
358
359    /**
360     * @return A summary, characterization or explanation of the body structure.
361     */
362    public String getDescription() { 
363      return this.description == null ? null : this.description.getValue();
364    }
365
366    /**
367     * @param value A summary, characterization or explanation of the body structure.
368     */
369    public BodyStructure setDescription(String value) { 
370      if (Utilities.noString(value))
371        this.description = null;
372      else {
373        if (this.description == null)
374          this.description = new StringType();
375        this.description.setValue(value);
376      }
377      return this;
378    }
379
380    /**
381     * @return {@link #image} (Image or images used to identify a location.)
382     */
383    public List<Attachment> getImage() { 
384      if (this.image == null)
385        this.image = new ArrayList<Attachment>();
386      return this.image;
387    }
388
389    /**
390     * @return Returns a reference to <code>this</code> for easy method chaining
391     */
392    public BodyStructure setImage(List<Attachment> theImage) { 
393      this.image = theImage;
394      return this;
395    }
396
397    public boolean hasImage() { 
398      if (this.image == null)
399        return false;
400      for (Attachment item : this.image)
401        if (!item.isEmpty())
402          return true;
403      return false;
404    }
405
406    public Attachment addImage() { //3
407      Attachment t = new Attachment();
408      if (this.image == null)
409        this.image = new ArrayList<Attachment>();
410      this.image.add(t);
411      return t;
412    }
413
414    public BodyStructure addImage(Attachment t) { //3
415      if (t == null)
416        return this;
417      if (this.image == null)
418        this.image = new ArrayList<Attachment>();
419      this.image.add(t);
420      return this;
421    }
422
423    /**
424     * @return The first repetition of repeating field {@link #image}, creating it if it does not already exist {3}
425     */
426    public Attachment getImageFirstRep() { 
427      if (getImage().isEmpty()) {
428        addImage();
429      }
430      return getImage().get(0);
431    }
432
433    /**
434     * @return {@link #patient} (The person to which the body site belongs.)
435     */
436    public Reference getPatient() { 
437      if (this.patient == null)
438        if (Configuration.errorOnAutoCreate())
439          throw new Error("Attempt to auto-create BodyStructure.patient");
440        else if (Configuration.doAutoCreate())
441          this.patient = new Reference(); // cc
442      return this.patient;
443    }
444
445    public boolean hasPatient() { 
446      return this.patient != null && !this.patient.isEmpty();
447    }
448
449    /**
450     * @param value {@link #patient} (The person to which the body site belongs.)
451     */
452    public BodyStructure setPatient(Reference value) { 
453      this.patient = value;
454      return this;
455    }
456
457      protected void listChildren(List<Property> children) {
458        super.listChildren(children);
459        children.add(new Property("identifier", "Identifier", "Identifier for this instance of the anatomical structure.", 0, java.lang.Integer.MAX_VALUE, identifier));
460        children.add(new Property("active", "boolean", "Whether this body site is in active use.", 0, 1, active));
461        children.add(new Property("morphology", "CodeableConcept", "The kind of structure being represented by the body structure at `BodyStructure.location`.  This can define both normal and abnormal morphologies.", 0, 1, morphology));
462        children.add(new Property("location", "CodeableConcept", "The anatomical location or region of the specimen, lesion, or body structure.", 0, 1, location));
463        children.add(new Property("locationQualifier", "CodeableConcept", "Qualifier to refine the anatomical location.  These include qualifiers for laterality, relative location, directionality, number, and plane.", 0, java.lang.Integer.MAX_VALUE, locationQualifier));
464        children.add(new Property("description", "string", "A summary, characterization or explanation of the body structure.", 0, 1, description));
465        children.add(new Property("image", "Attachment", "Image or images used to identify a location.", 0, java.lang.Integer.MAX_VALUE, image));
466        children.add(new Property("patient", "Reference(Patient)", "The person to which the body site belongs.", 0, 1, patient));
467      }
468
469      @Override
470      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
471        switch (_hash) {
472        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Identifier for this instance of the anatomical structure.", 0, java.lang.Integer.MAX_VALUE, identifier);
473        case -1422950650: /*active*/  return new Property("active", "boolean", "Whether this body site is in active use.", 0, 1, active);
474        case 1807231644: /*morphology*/  return new Property("morphology", "CodeableConcept", "The kind of structure being represented by the body structure at `BodyStructure.location`.  This can define both normal and abnormal morphologies.", 0, 1, morphology);
475        case 1901043637: /*location*/  return new Property("location", "CodeableConcept", "The anatomical location or region of the specimen, lesion, or body structure.", 0, 1, location);
476        case 433081461: /*locationQualifier*/  return new Property("locationQualifier", "CodeableConcept", "Qualifier to refine the anatomical location.  These include qualifiers for laterality, relative location, directionality, number, and plane.", 0, java.lang.Integer.MAX_VALUE, locationQualifier);
477        case -1724546052: /*description*/  return new Property("description", "string", "A summary, characterization or explanation of the body structure.", 0, 1, description);
478        case 100313435: /*image*/  return new Property("image", "Attachment", "Image or images used to identify a location.", 0, java.lang.Integer.MAX_VALUE, image);
479        case -791418107: /*patient*/  return new Property("patient", "Reference(Patient)", "The person to which the body site belongs.", 0, 1, patient);
480        default: return super.getNamedProperty(_hash, _name, _checkValid);
481        }
482
483      }
484
485      @Override
486      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
487        switch (hash) {
488        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
489        case -1422950650: /*active*/ return this.active == null ? new Base[0] : new Base[] {this.active}; // BooleanType
490        case 1807231644: /*morphology*/ return this.morphology == null ? new Base[0] : new Base[] {this.morphology}; // CodeableConcept
491        case 1901043637: /*location*/ return this.location == null ? new Base[0] : new Base[] {this.location}; // CodeableConcept
492        case 433081461: /*locationQualifier*/ return this.locationQualifier == null ? new Base[0] : this.locationQualifier.toArray(new Base[this.locationQualifier.size()]); // CodeableConcept
493        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // StringType
494        case 100313435: /*image*/ return this.image == null ? new Base[0] : this.image.toArray(new Base[this.image.size()]); // Attachment
495        case -791418107: /*patient*/ return this.patient == null ? new Base[0] : new Base[] {this.patient}; // Reference
496        default: return super.getProperty(hash, name, checkValid);
497        }
498
499      }
500
501      @Override
502      public Base setProperty(int hash, String name, Base value) throws FHIRException {
503        switch (hash) {
504        case -1618432855: // identifier
505          this.getIdentifier().add(TypeConvertor.castToIdentifier(value)); // Identifier
506          return value;
507        case -1422950650: // active
508          this.active = TypeConvertor.castToBoolean(value); // BooleanType
509          return value;
510        case 1807231644: // morphology
511          this.morphology = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
512          return value;
513        case 1901043637: // location
514          this.location = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
515          return value;
516        case 433081461: // locationQualifier
517          this.getLocationQualifier().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
518          return value;
519        case -1724546052: // description
520          this.description = TypeConvertor.castToString(value); // StringType
521          return value;
522        case 100313435: // image
523          this.getImage().add(TypeConvertor.castToAttachment(value)); // Attachment
524          return value;
525        case -791418107: // patient
526          this.patient = TypeConvertor.castToReference(value); // Reference
527          return value;
528        default: return super.setProperty(hash, name, value);
529        }
530
531      }
532
533      @Override
534      public Base setProperty(String name, Base value) throws FHIRException {
535        if (name.equals("identifier")) {
536          this.getIdentifier().add(TypeConvertor.castToIdentifier(value));
537        } else if (name.equals("active")) {
538          this.active = TypeConvertor.castToBoolean(value); // BooleanType
539        } else if (name.equals("morphology")) {
540          this.morphology = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
541        } else if (name.equals("location")) {
542          this.location = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
543        } else if (name.equals("locationQualifier")) {
544          this.getLocationQualifier().add(TypeConvertor.castToCodeableConcept(value));
545        } else if (name.equals("description")) {
546          this.description = TypeConvertor.castToString(value); // StringType
547        } else if (name.equals("image")) {
548          this.getImage().add(TypeConvertor.castToAttachment(value));
549        } else if (name.equals("patient")) {
550          this.patient = TypeConvertor.castToReference(value); // Reference
551        } else
552          return super.setProperty(name, value);
553        return value;
554      }
555
556      @Override
557      public Base makeProperty(int hash, String name) throws FHIRException {
558        switch (hash) {
559        case -1618432855:  return addIdentifier(); 
560        case -1422950650:  return getActiveElement();
561        case 1807231644:  return getMorphology();
562        case 1901043637:  return getLocation();
563        case 433081461:  return addLocationQualifier(); 
564        case -1724546052:  return getDescriptionElement();
565        case 100313435:  return addImage(); 
566        case -791418107:  return getPatient();
567        default: return super.makeProperty(hash, name);
568        }
569
570      }
571
572      @Override
573      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
574        switch (hash) {
575        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
576        case -1422950650: /*active*/ return new String[] {"boolean"};
577        case 1807231644: /*morphology*/ return new String[] {"CodeableConcept"};
578        case 1901043637: /*location*/ return new String[] {"CodeableConcept"};
579        case 433081461: /*locationQualifier*/ return new String[] {"CodeableConcept"};
580        case -1724546052: /*description*/ return new String[] {"string"};
581        case 100313435: /*image*/ return new String[] {"Attachment"};
582        case -791418107: /*patient*/ return new String[] {"Reference"};
583        default: return super.getTypesForProperty(hash, name);
584        }
585
586      }
587
588      @Override
589      public Base addChild(String name) throws FHIRException {
590        if (name.equals("identifier")) {
591          return addIdentifier();
592        }
593        else if (name.equals("active")) {
594          throw new FHIRException("Cannot call addChild on a primitive type BodyStructure.active");
595        }
596        else if (name.equals("morphology")) {
597          this.morphology = new CodeableConcept();
598          return this.morphology;
599        }
600        else if (name.equals("location")) {
601          this.location = new CodeableConcept();
602          return this.location;
603        }
604        else if (name.equals("locationQualifier")) {
605          return addLocationQualifier();
606        }
607        else if (name.equals("description")) {
608          throw new FHIRException("Cannot call addChild on a primitive type BodyStructure.description");
609        }
610        else if (name.equals("image")) {
611          return addImage();
612        }
613        else if (name.equals("patient")) {
614          this.patient = new Reference();
615          return this.patient;
616        }
617        else
618          return super.addChild(name);
619      }
620
621  public String fhirType() {
622    return "BodyStructure";
623
624  }
625
626      public BodyStructure copy() {
627        BodyStructure dst = new BodyStructure();
628        copyValues(dst);
629        return dst;
630      }
631
632      public void copyValues(BodyStructure dst) {
633        super.copyValues(dst);
634        if (identifier != null) {
635          dst.identifier = new ArrayList<Identifier>();
636          for (Identifier i : identifier)
637            dst.identifier.add(i.copy());
638        };
639        dst.active = active == null ? null : active.copy();
640        dst.morphology = morphology == null ? null : morphology.copy();
641        dst.location = location == null ? null : location.copy();
642        if (locationQualifier != null) {
643          dst.locationQualifier = new ArrayList<CodeableConcept>();
644          for (CodeableConcept i : locationQualifier)
645            dst.locationQualifier.add(i.copy());
646        };
647        dst.description = description == null ? null : description.copy();
648        if (image != null) {
649          dst.image = new ArrayList<Attachment>();
650          for (Attachment i : image)
651            dst.image.add(i.copy());
652        };
653        dst.patient = patient == null ? null : patient.copy();
654      }
655
656      protected BodyStructure typedCopy() {
657        return copy();
658      }
659
660      @Override
661      public boolean equalsDeep(Base other_) {
662        if (!super.equalsDeep(other_))
663          return false;
664        if (!(other_ instanceof BodyStructure))
665          return false;
666        BodyStructure o = (BodyStructure) other_;
667        return compareDeep(identifier, o.identifier, true) && compareDeep(active, o.active, true) && compareDeep(morphology, o.morphology, true)
668           && compareDeep(location, o.location, true) && compareDeep(locationQualifier, o.locationQualifier, true)
669           && compareDeep(description, o.description, true) && compareDeep(image, o.image, true) && compareDeep(patient, o.patient, true)
670          ;
671      }
672
673      @Override
674      public boolean equalsShallow(Base other_) {
675        if (!super.equalsShallow(other_))
676          return false;
677        if (!(other_ instanceof BodyStructure))
678          return false;
679        BodyStructure o = (BodyStructure) other_;
680        return compareValues(active, o.active, true) && compareValues(description, o.description, true);
681      }
682
683      public boolean isEmpty() {
684        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, active, morphology
685          , location, locationQualifier, description, image, patient);
686      }
687
688  @Override
689  public ResourceType getResourceType() {
690    return ResourceType.BodyStructure;
691   }
692
693 /**
694   * Search parameter: <b>identifier</b>
695   * <p>
696   * Description: <b>Bodystructure identifier</b><br>
697   * Type: <b>token</b><br>
698   * Path: <b>BodyStructure.identifier</b><br>
699   * </p>
700   */
701  @SearchParamDefinition(name="identifier", path="BodyStructure.identifier", description="Bodystructure identifier", type="token" )
702  public static final String SP_IDENTIFIER = "identifier";
703 /**
704   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
705   * <p>
706   * Description: <b>Bodystructure identifier</b><br>
707   * Type: <b>token</b><br>
708   * Path: <b>BodyStructure.identifier</b><br>
709   * </p>
710   */
711  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
712
713 /**
714   * Search parameter: <b>location</b>
715   * <p>
716   * Description: <b>Body site</b><br>
717   * Type: <b>token</b><br>
718   * Path: <b>BodyStructure.location</b><br>
719   * </p>
720   */
721  @SearchParamDefinition(name="location", path="BodyStructure.location", description="Body site", type="token" )
722  public static final String SP_LOCATION = "location";
723 /**
724   * <b>Fluent Client</b> search parameter constant for <b>location</b>
725   * <p>
726   * Description: <b>Body site</b><br>
727   * Type: <b>token</b><br>
728   * Path: <b>BodyStructure.location</b><br>
729   * </p>
730   */
731  public static final ca.uhn.fhir.rest.gclient.TokenClientParam LOCATION = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_LOCATION);
732
733 /**
734   * Search parameter: <b>morphology</b>
735   * <p>
736   * Description: <b>Kind of Structure</b><br>
737   * Type: <b>token</b><br>
738   * Path: <b>BodyStructure.morphology</b><br>
739   * </p>
740   */
741  @SearchParamDefinition(name="morphology", path="BodyStructure.morphology", description="Kind of Structure", type="token" )
742  public static final String SP_MORPHOLOGY = "morphology";
743 /**
744   * <b>Fluent Client</b> search parameter constant for <b>morphology</b>
745   * <p>
746   * Description: <b>Kind of Structure</b><br>
747   * Type: <b>token</b><br>
748   * Path: <b>BodyStructure.morphology</b><br>
749   * </p>
750   */
751  public static final ca.uhn.fhir.rest.gclient.TokenClientParam MORPHOLOGY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_MORPHOLOGY);
752
753 /**
754   * Search parameter: <b>patient</b>
755   * <p>
756   * Description: <b>Who this is about</b><br>
757   * Type: <b>reference</b><br>
758   * Path: <b>BodyStructure.patient</b><br>
759   * </p>
760   */
761  @SearchParamDefinition(name="patient", path="BodyStructure.patient", description="Who this is about", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Base FHIR compartment definition for Patient") }, target={Patient.class } )
762  public static final String SP_PATIENT = "patient";
763 /**
764   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
765   * <p>
766   * Description: <b>Who this is about</b><br>
767   * Type: <b>reference</b><br>
768   * Path: <b>BodyStructure.patient</b><br>
769   * </p>
770   */
771  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
772
773/**
774   * Constant for fluent queries to be used to add include statements. Specifies
775   * the path value of "<b>BodyStructure:patient</b>".
776   */
777  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("BodyStructure:patient").toLocked();
778
779
780}
781