001package org.hl7.fhir.r5.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 Tue, Dec 13, 2022 17:53+1100 for FHIR vcurrent
033
034import java.util.ArrayList;
035import java.util.Date;
036import java.util.List;
037import org.hl7.fhir.utilities.Utilities;
038import org.hl7.fhir.r5.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 * Representation of a molecular sequence.
052 */
053@ResourceDef(name="MolecularSequence", profile="http://hl7.org/fhir/StructureDefinition/MolecularSequence")
054public class MolecularSequence extends DomainResource {
055
056    public enum OrientationType {
057        /**
058         * Sense orientation of reference sequence.
059         */
060        SENSE, 
061        /**
062         * Antisense orientation of reference sequence.
063         */
064        ANTISENSE, 
065        /**
066         * added to help the parsers with the generic types
067         */
068        NULL;
069        public static OrientationType fromCode(String codeString) throws FHIRException {
070            if (codeString == null || "".equals(codeString))
071                return null;
072        if ("sense".equals(codeString))
073          return SENSE;
074        if ("antisense".equals(codeString))
075          return ANTISENSE;
076        if (Configuration.isAcceptInvalidEnums())
077          return null;
078        else
079          throw new FHIRException("Unknown OrientationType code '"+codeString+"'");
080        }
081        public String toCode() {
082          switch (this) {
083            case SENSE: return "sense";
084            case ANTISENSE: return "antisense";
085            case NULL: return null;
086            default: return "?";
087          }
088        }
089        public String getSystem() {
090          switch (this) {
091            case SENSE: return "http://hl7.org/fhir/orientation-type";
092            case ANTISENSE: return "http://hl7.org/fhir/orientation-type";
093            case NULL: return null;
094            default: return "?";
095          }
096        }
097        public String getDefinition() {
098          switch (this) {
099            case SENSE: return "Sense orientation of reference sequence.";
100            case ANTISENSE: return "Antisense orientation of reference sequence.";
101            case NULL: return null;
102            default: return "?";
103          }
104        }
105        public String getDisplay() {
106          switch (this) {
107            case SENSE: return "Sense orientation of referenceSeq";
108            case ANTISENSE: return "Antisense orientation of referenceSeq";
109            case NULL: return null;
110            default: return "?";
111          }
112        }
113    }
114
115  public static class OrientationTypeEnumFactory implements EnumFactory<OrientationType> {
116    public OrientationType fromCode(String codeString) throws IllegalArgumentException {
117      if (codeString == null || "".equals(codeString))
118            if (codeString == null || "".equals(codeString))
119                return null;
120        if ("sense".equals(codeString))
121          return OrientationType.SENSE;
122        if ("antisense".equals(codeString))
123          return OrientationType.ANTISENSE;
124        throw new IllegalArgumentException("Unknown OrientationType code '"+codeString+"'");
125        }
126        public Enumeration<OrientationType> fromType(PrimitiveType<?> code) throws FHIRException {
127          if (code == null)
128            return null;
129          if (code.isEmpty())
130            return new Enumeration<OrientationType>(this, OrientationType.NULL, code);
131          String codeString = ((PrimitiveType) code).asStringValue();
132          if (codeString == null || "".equals(codeString))
133            return new Enumeration<OrientationType>(this, OrientationType.NULL, code);
134        if ("sense".equals(codeString))
135          return new Enumeration<OrientationType>(this, OrientationType.SENSE, code);
136        if ("antisense".equals(codeString))
137          return new Enumeration<OrientationType>(this, OrientationType.ANTISENSE, code);
138        throw new FHIRException("Unknown OrientationType code '"+codeString+"'");
139        }
140    public String toCode(OrientationType code) {
141      if (code == OrientationType.SENSE)
142        return "sense";
143      if (code == OrientationType.ANTISENSE)
144        return "antisense";
145      return "?";
146      }
147    public String toSystem(OrientationType code) {
148      return code.getSystem();
149      }
150    }
151
152    public enum SequenceType {
153        /**
154         * Amino acid sequence.
155         */
156        AA, 
157        /**
158         * DNA Sequence.
159         */
160        DNA, 
161        /**
162         * RNA Sequence.
163         */
164        RNA, 
165        /**
166         * added to help the parsers with the generic types
167         */
168        NULL;
169        public static SequenceType fromCode(String codeString) throws FHIRException {
170            if (codeString == null || "".equals(codeString))
171                return null;
172        if ("aa".equals(codeString))
173          return AA;
174        if ("dna".equals(codeString))
175          return DNA;
176        if ("rna".equals(codeString))
177          return RNA;
178        if (Configuration.isAcceptInvalidEnums())
179          return null;
180        else
181          throw new FHIRException("Unknown SequenceType code '"+codeString+"'");
182        }
183        public String toCode() {
184          switch (this) {
185            case AA: return "aa";
186            case DNA: return "dna";
187            case RNA: return "rna";
188            case NULL: return null;
189            default: return "?";
190          }
191        }
192        public String getSystem() {
193          switch (this) {
194            case AA: return "http://hl7.org/fhir/sequence-type";
195            case DNA: return "http://hl7.org/fhir/sequence-type";
196            case RNA: return "http://hl7.org/fhir/sequence-type";
197            case NULL: return null;
198            default: return "?";
199          }
200        }
201        public String getDefinition() {
202          switch (this) {
203            case AA: return "Amino acid sequence.";
204            case DNA: return "DNA Sequence.";
205            case RNA: return "RNA Sequence.";
206            case NULL: return null;
207            default: return "?";
208          }
209        }
210        public String getDisplay() {
211          switch (this) {
212            case AA: return "AA Sequence";
213            case DNA: return "DNA Sequence";
214            case RNA: return "RNA Sequence";
215            case NULL: return null;
216            default: return "?";
217          }
218        }
219    }
220
221  public static class SequenceTypeEnumFactory implements EnumFactory<SequenceType> {
222    public SequenceType fromCode(String codeString) throws IllegalArgumentException {
223      if (codeString == null || "".equals(codeString))
224            if (codeString == null || "".equals(codeString))
225                return null;
226        if ("aa".equals(codeString))
227          return SequenceType.AA;
228        if ("dna".equals(codeString))
229          return SequenceType.DNA;
230        if ("rna".equals(codeString))
231          return SequenceType.RNA;
232        throw new IllegalArgumentException("Unknown SequenceType code '"+codeString+"'");
233        }
234        public Enumeration<SequenceType> fromType(PrimitiveType<?> code) throws FHIRException {
235          if (code == null)
236            return null;
237          if (code.isEmpty())
238            return new Enumeration<SequenceType>(this, SequenceType.NULL, code);
239          String codeString = ((PrimitiveType) code).asStringValue();
240          if (codeString == null || "".equals(codeString))
241            return new Enumeration<SequenceType>(this, SequenceType.NULL, code);
242        if ("aa".equals(codeString))
243          return new Enumeration<SequenceType>(this, SequenceType.AA, code);
244        if ("dna".equals(codeString))
245          return new Enumeration<SequenceType>(this, SequenceType.DNA, code);
246        if ("rna".equals(codeString))
247          return new Enumeration<SequenceType>(this, SequenceType.RNA, code);
248        throw new FHIRException("Unknown SequenceType code '"+codeString+"'");
249        }
250    public String toCode(SequenceType code) {
251      if (code == SequenceType.AA)
252        return "aa";
253      if (code == SequenceType.DNA)
254        return "dna";
255      if (code == SequenceType.RNA)
256        return "rna";
257      return "?";
258      }
259    public String toSystem(SequenceType code) {
260      return code.getSystem();
261      }
262    }
263
264    public enum StrandType {
265        /**
266         * Watson strand of starting sequence.
267         */
268        WATSON, 
269        /**
270         * Crick strand of starting sequence.
271         */
272        CRICK, 
273        /**
274         * added to help the parsers with the generic types
275         */
276        NULL;
277        public static StrandType fromCode(String codeString) throws FHIRException {
278            if (codeString == null || "".equals(codeString))
279                return null;
280        if ("watson".equals(codeString))
281          return WATSON;
282        if ("crick".equals(codeString))
283          return CRICK;
284        if (Configuration.isAcceptInvalidEnums())
285          return null;
286        else
287          throw new FHIRException("Unknown StrandType code '"+codeString+"'");
288        }
289        public String toCode() {
290          switch (this) {
291            case WATSON: return "watson";
292            case CRICK: return "crick";
293            case NULL: return null;
294            default: return "?";
295          }
296        }
297        public String getSystem() {
298          switch (this) {
299            case WATSON: return "http://hl7.org/fhir/strand-type";
300            case CRICK: return "http://hl7.org/fhir/strand-type";
301            case NULL: return null;
302            default: return "?";
303          }
304        }
305        public String getDefinition() {
306          switch (this) {
307            case WATSON: return "Watson strand of starting sequence.";
308            case CRICK: return "Crick strand of starting sequence.";
309            case NULL: return null;
310            default: return "?";
311          }
312        }
313        public String getDisplay() {
314          switch (this) {
315            case WATSON: return "Watson strand of starting sequence";
316            case CRICK: return "Crick strand of starting sequence";
317            case NULL: return null;
318            default: return "?";
319          }
320        }
321    }
322
323  public static class StrandTypeEnumFactory implements EnumFactory<StrandType> {
324    public StrandType fromCode(String codeString) throws IllegalArgumentException {
325      if (codeString == null || "".equals(codeString))
326            if (codeString == null || "".equals(codeString))
327                return null;
328        if ("watson".equals(codeString))
329          return StrandType.WATSON;
330        if ("crick".equals(codeString))
331          return StrandType.CRICK;
332        throw new IllegalArgumentException("Unknown StrandType code '"+codeString+"'");
333        }
334        public Enumeration<StrandType> fromType(PrimitiveType<?> code) throws FHIRException {
335          if (code == null)
336            return null;
337          if (code.isEmpty())
338            return new Enumeration<StrandType>(this, StrandType.NULL, code);
339          String codeString = ((PrimitiveType) code).asStringValue();
340          if (codeString == null || "".equals(codeString))
341            return new Enumeration<StrandType>(this, StrandType.NULL, code);
342        if ("watson".equals(codeString))
343          return new Enumeration<StrandType>(this, StrandType.WATSON, code);
344        if ("crick".equals(codeString))
345          return new Enumeration<StrandType>(this, StrandType.CRICK, code);
346        throw new FHIRException("Unknown StrandType code '"+codeString+"'");
347        }
348    public String toCode(StrandType code) {
349      if (code == StrandType.WATSON)
350        return "watson";
351      if (code == StrandType.CRICK)
352        return "crick";
353      return "?";
354      }
355    public String toSystem(StrandType code) {
356      return code.getSystem();
357      }
358    }
359
360    @Block()
361    public static class MolecularSequenceRelativeComponent extends BackboneElement implements IBaseBackboneElement {
362        /**
363         * These are different ways of identifying nucleotides or amino acids within a sequence. Different databases and file types may use different systems. For detail definitions, see https://loinc.org/92822-6/ for more detail.
364         */
365        @Child(name = "coordinateSystem", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=true)
366        @Description(shortDefinition="Ways of identifying nucleotides or amino acids within a sequence", formalDefinition="These are different ways of identifying nucleotides or amino acids within a sequence. Different databases and file types may use different systems. For detail definitions, see https://loinc.org/92822-6/ for more detail." )
367        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://loinc.org/LL5323-2/")
368        protected CodeableConcept coordinateSystem;
369
370        /**
371         * Indicates the order in which the sequence should be considered when putting multiple 'relative' elements together.
372         */
373        @Child(name = "ordinalPosition", type = {IntegerType.class}, order=2, min=0, max=1, modifier=false, summary=false)
374        @Description(shortDefinition="Indicates the order in which the sequence should be considered when putting multiple 'relative' elements together", formalDefinition="Indicates the order in which the sequence should be considered when putting multiple 'relative' elements together." )
375        protected IntegerType ordinalPosition;
376
377        /**
378         * Indicates the nucleotide range in the composed sequence when multiple 'relative' elements are used together.
379         */
380        @Child(name = "sequenceRange", type = {Range.class}, order=3, min=0, max=1, modifier=false, summary=false)
381        @Description(shortDefinition="Indicates the nucleotide range in the composed sequence when multiple 'relative' elements are used together", formalDefinition="Indicates the nucleotide range in the composed sequence when multiple 'relative' elements are used together." )
382        protected Range sequenceRange;
383
384        /**
385         * A sequence that is used as a starting sequence to describe variants that are present in a sequence analyzed.
386         */
387        @Child(name = "startingSequence", type = {}, order=4, min=0, max=1, modifier=false, summary=true)
388        @Description(shortDefinition="A sequence used as starting sequence", formalDefinition="A sequence that is used as a starting sequence to describe variants that are present in a sequence analyzed." )
389        protected MolecularSequenceRelativeStartingSequenceComponent startingSequence;
390
391        /**
392         * Changes in sequence from the starting sequence.
393         */
394        @Child(name = "edit", type = {}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
395        @Description(shortDefinition="Changes in sequence from the starting sequence", formalDefinition="Changes in sequence from the starting sequence." )
396        protected List<MolecularSequenceRelativeEditComponent> edit;
397
398        private static final long serialVersionUID = -1455983973L;
399
400    /**
401     * Constructor
402     */
403      public MolecularSequenceRelativeComponent() {
404        super();
405      }
406
407    /**
408     * Constructor
409     */
410      public MolecularSequenceRelativeComponent(CodeableConcept coordinateSystem) {
411        super();
412        this.setCoordinateSystem(coordinateSystem);
413      }
414
415        /**
416         * @return {@link #coordinateSystem} (These are different ways of identifying nucleotides or amino acids within a sequence. Different databases and file types may use different systems. For detail definitions, see https://loinc.org/92822-6/ for more detail.)
417         */
418        public CodeableConcept getCoordinateSystem() { 
419          if (this.coordinateSystem == null)
420            if (Configuration.errorOnAutoCreate())
421              throw new Error("Attempt to auto-create MolecularSequenceRelativeComponent.coordinateSystem");
422            else if (Configuration.doAutoCreate())
423              this.coordinateSystem = new CodeableConcept(); // cc
424          return this.coordinateSystem;
425        }
426
427        public boolean hasCoordinateSystem() { 
428          return this.coordinateSystem != null && !this.coordinateSystem.isEmpty();
429        }
430
431        /**
432         * @param value {@link #coordinateSystem} (These are different ways of identifying nucleotides or amino acids within a sequence. Different databases and file types may use different systems. For detail definitions, see https://loinc.org/92822-6/ for more detail.)
433         */
434        public MolecularSequenceRelativeComponent setCoordinateSystem(CodeableConcept value) { 
435          this.coordinateSystem = value;
436          return this;
437        }
438
439        /**
440         * @return {@link #ordinalPosition} (Indicates the order in which the sequence should be considered when putting multiple 'relative' elements together.). This is the underlying object with id, value and extensions. The accessor "getOrdinalPosition" gives direct access to the value
441         */
442        public IntegerType getOrdinalPositionElement() { 
443          if (this.ordinalPosition == null)
444            if (Configuration.errorOnAutoCreate())
445              throw new Error("Attempt to auto-create MolecularSequenceRelativeComponent.ordinalPosition");
446            else if (Configuration.doAutoCreate())
447              this.ordinalPosition = new IntegerType(); // bb
448          return this.ordinalPosition;
449        }
450
451        public boolean hasOrdinalPositionElement() { 
452          return this.ordinalPosition != null && !this.ordinalPosition.isEmpty();
453        }
454
455        public boolean hasOrdinalPosition() { 
456          return this.ordinalPosition != null && !this.ordinalPosition.isEmpty();
457        }
458
459        /**
460         * @param value {@link #ordinalPosition} (Indicates the order in which the sequence should be considered when putting multiple 'relative' elements together.). This is the underlying object with id, value and extensions. The accessor "getOrdinalPosition" gives direct access to the value
461         */
462        public MolecularSequenceRelativeComponent setOrdinalPositionElement(IntegerType value) { 
463          this.ordinalPosition = value;
464          return this;
465        }
466
467        /**
468         * @return Indicates the order in which the sequence should be considered when putting multiple 'relative' elements together.
469         */
470        public int getOrdinalPosition() { 
471          return this.ordinalPosition == null || this.ordinalPosition.isEmpty() ? 0 : this.ordinalPosition.getValue();
472        }
473
474        /**
475         * @param value Indicates the order in which the sequence should be considered when putting multiple 'relative' elements together.
476         */
477        public MolecularSequenceRelativeComponent setOrdinalPosition(int value) { 
478            if (this.ordinalPosition == null)
479              this.ordinalPosition = new IntegerType();
480            this.ordinalPosition.setValue(value);
481          return this;
482        }
483
484        /**
485         * @return {@link #sequenceRange} (Indicates the nucleotide range in the composed sequence when multiple 'relative' elements are used together.)
486         */
487        public Range getSequenceRange() { 
488          if (this.sequenceRange == null)
489            if (Configuration.errorOnAutoCreate())
490              throw new Error("Attempt to auto-create MolecularSequenceRelativeComponent.sequenceRange");
491            else if (Configuration.doAutoCreate())
492              this.sequenceRange = new Range(); // cc
493          return this.sequenceRange;
494        }
495
496        public boolean hasSequenceRange() { 
497          return this.sequenceRange != null && !this.sequenceRange.isEmpty();
498        }
499
500        /**
501         * @param value {@link #sequenceRange} (Indicates the nucleotide range in the composed sequence when multiple 'relative' elements are used together.)
502         */
503        public MolecularSequenceRelativeComponent setSequenceRange(Range value) { 
504          this.sequenceRange = value;
505          return this;
506        }
507
508        /**
509         * @return {@link #startingSequence} (A sequence that is used as a starting sequence to describe variants that are present in a sequence analyzed.)
510         */
511        public MolecularSequenceRelativeStartingSequenceComponent getStartingSequence() { 
512          if (this.startingSequence == null)
513            if (Configuration.errorOnAutoCreate())
514              throw new Error("Attempt to auto-create MolecularSequenceRelativeComponent.startingSequence");
515            else if (Configuration.doAutoCreate())
516              this.startingSequence = new MolecularSequenceRelativeStartingSequenceComponent(); // cc
517          return this.startingSequence;
518        }
519
520        public boolean hasStartingSequence() { 
521          return this.startingSequence != null && !this.startingSequence.isEmpty();
522        }
523
524        /**
525         * @param value {@link #startingSequence} (A sequence that is used as a starting sequence to describe variants that are present in a sequence analyzed.)
526         */
527        public MolecularSequenceRelativeComponent setStartingSequence(MolecularSequenceRelativeStartingSequenceComponent value) { 
528          this.startingSequence = value;
529          return this;
530        }
531
532        /**
533         * @return {@link #edit} (Changes in sequence from the starting sequence.)
534         */
535        public List<MolecularSequenceRelativeEditComponent> getEdit() { 
536          if (this.edit == null)
537            this.edit = new ArrayList<MolecularSequenceRelativeEditComponent>();
538          return this.edit;
539        }
540
541        /**
542         * @return Returns a reference to <code>this</code> for easy method chaining
543         */
544        public MolecularSequenceRelativeComponent setEdit(List<MolecularSequenceRelativeEditComponent> theEdit) { 
545          this.edit = theEdit;
546          return this;
547        }
548
549        public boolean hasEdit() { 
550          if (this.edit == null)
551            return false;
552          for (MolecularSequenceRelativeEditComponent item : this.edit)
553            if (!item.isEmpty())
554              return true;
555          return false;
556        }
557
558        public MolecularSequenceRelativeEditComponent addEdit() { //3
559          MolecularSequenceRelativeEditComponent t = new MolecularSequenceRelativeEditComponent();
560          if (this.edit == null)
561            this.edit = new ArrayList<MolecularSequenceRelativeEditComponent>();
562          this.edit.add(t);
563          return t;
564        }
565
566        public MolecularSequenceRelativeComponent addEdit(MolecularSequenceRelativeEditComponent t) { //3
567          if (t == null)
568            return this;
569          if (this.edit == null)
570            this.edit = new ArrayList<MolecularSequenceRelativeEditComponent>();
571          this.edit.add(t);
572          return this;
573        }
574
575        /**
576         * @return The first repetition of repeating field {@link #edit}, creating it if it does not already exist {3}
577         */
578        public MolecularSequenceRelativeEditComponent getEditFirstRep() { 
579          if (getEdit().isEmpty()) {
580            addEdit();
581          }
582          return getEdit().get(0);
583        }
584
585        protected void listChildren(List<Property> children) {
586          super.listChildren(children);
587          children.add(new Property("coordinateSystem", "CodeableConcept", "These are different ways of identifying nucleotides or amino acids within a sequence. Different databases and file types may use different systems. For detail definitions, see https://loinc.org/92822-6/ for more detail.", 0, 1, coordinateSystem));
588          children.add(new Property("ordinalPosition", "integer", "Indicates the order in which the sequence should be considered when putting multiple 'relative' elements together.", 0, 1, ordinalPosition));
589          children.add(new Property("sequenceRange", "Range", "Indicates the nucleotide range in the composed sequence when multiple 'relative' elements are used together.", 0, 1, sequenceRange));
590          children.add(new Property("startingSequence", "", "A sequence that is used as a starting sequence to describe variants that are present in a sequence analyzed.", 0, 1, startingSequence));
591          children.add(new Property("edit", "", "Changes in sequence from the starting sequence.", 0, java.lang.Integer.MAX_VALUE, edit));
592        }
593
594        @Override
595        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
596          switch (_hash) {
597          case 354212295: /*coordinateSystem*/  return new Property("coordinateSystem", "CodeableConcept", "These are different ways of identifying nucleotides or amino acids within a sequence. Different databases and file types may use different systems. For detail definitions, see https://loinc.org/92822-6/ for more detail.", 0, 1, coordinateSystem);
598          case 626439866: /*ordinalPosition*/  return new Property("ordinalPosition", "integer", "Indicates the order in which the sequence should be considered when putting multiple 'relative' elements together.", 0, 1, ordinalPosition);
599          case -733314564: /*sequenceRange*/  return new Property("sequenceRange", "Range", "Indicates the nucleotide range in the composed sequence when multiple 'relative' elements are used together.", 0, 1, sequenceRange);
600          case 1493400609: /*startingSequence*/  return new Property("startingSequence", "", "A sequence that is used as a starting sequence to describe variants that are present in a sequence analyzed.", 0, 1, startingSequence);
601          case 3108362: /*edit*/  return new Property("edit", "", "Changes in sequence from the starting sequence.", 0, java.lang.Integer.MAX_VALUE, edit);
602          default: return super.getNamedProperty(_hash, _name, _checkValid);
603          }
604
605        }
606
607      @Override
608      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
609        switch (hash) {
610        case 354212295: /*coordinateSystem*/ return this.coordinateSystem == null ? new Base[0] : new Base[] {this.coordinateSystem}; // CodeableConcept
611        case 626439866: /*ordinalPosition*/ return this.ordinalPosition == null ? new Base[0] : new Base[] {this.ordinalPosition}; // IntegerType
612        case -733314564: /*sequenceRange*/ return this.sequenceRange == null ? new Base[0] : new Base[] {this.sequenceRange}; // Range
613        case 1493400609: /*startingSequence*/ return this.startingSequence == null ? new Base[0] : new Base[] {this.startingSequence}; // MolecularSequenceRelativeStartingSequenceComponent
614        case 3108362: /*edit*/ return this.edit == null ? new Base[0] : this.edit.toArray(new Base[this.edit.size()]); // MolecularSequenceRelativeEditComponent
615        default: return super.getProperty(hash, name, checkValid);
616        }
617
618      }
619
620      @Override
621      public Base setProperty(int hash, String name, Base value) throws FHIRException {
622        switch (hash) {
623        case 354212295: // coordinateSystem
624          this.coordinateSystem = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
625          return value;
626        case 626439866: // ordinalPosition
627          this.ordinalPosition = TypeConvertor.castToInteger(value); // IntegerType
628          return value;
629        case -733314564: // sequenceRange
630          this.sequenceRange = TypeConvertor.castToRange(value); // Range
631          return value;
632        case 1493400609: // startingSequence
633          this.startingSequence = (MolecularSequenceRelativeStartingSequenceComponent) value; // MolecularSequenceRelativeStartingSequenceComponent
634          return value;
635        case 3108362: // edit
636          this.getEdit().add((MolecularSequenceRelativeEditComponent) value); // MolecularSequenceRelativeEditComponent
637          return value;
638        default: return super.setProperty(hash, name, value);
639        }
640
641      }
642
643      @Override
644      public Base setProperty(String name, Base value) throws FHIRException {
645        if (name.equals("coordinateSystem")) {
646          this.coordinateSystem = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
647        } else if (name.equals("ordinalPosition")) {
648          this.ordinalPosition = TypeConvertor.castToInteger(value); // IntegerType
649        } else if (name.equals("sequenceRange")) {
650          this.sequenceRange = TypeConvertor.castToRange(value); // Range
651        } else if (name.equals("startingSequence")) {
652          this.startingSequence = (MolecularSequenceRelativeStartingSequenceComponent) value; // MolecularSequenceRelativeStartingSequenceComponent
653        } else if (name.equals("edit")) {
654          this.getEdit().add((MolecularSequenceRelativeEditComponent) value);
655        } else
656          return super.setProperty(name, value);
657        return value;
658      }
659
660      @Override
661      public Base makeProperty(int hash, String name) throws FHIRException {
662        switch (hash) {
663        case 354212295:  return getCoordinateSystem();
664        case 626439866:  return getOrdinalPositionElement();
665        case -733314564:  return getSequenceRange();
666        case 1493400609:  return getStartingSequence();
667        case 3108362:  return addEdit(); 
668        default: return super.makeProperty(hash, name);
669        }
670
671      }
672
673      @Override
674      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
675        switch (hash) {
676        case 354212295: /*coordinateSystem*/ return new String[] {"CodeableConcept"};
677        case 626439866: /*ordinalPosition*/ return new String[] {"integer"};
678        case -733314564: /*sequenceRange*/ return new String[] {"Range"};
679        case 1493400609: /*startingSequence*/ return new String[] {};
680        case 3108362: /*edit*/ return new String[] {};
681        default: return super.getTypesForProperty(hash, name);
682        }
683
684      }
685
686      @Override
687      public Base addChild(String name) throws FHIRException {
688        if (name.equals("coordinateSystem")) {
689          this.coordinateSystem = new CodeableConcept();
690          return this.coordinateSystem;
691        }
692        else if (name.equals("ordinalPosition")) {
693          throw new FHIRException("Cannot call addChild on a primitive type MolecularSequence.relative.ordinalPosition");
694        }
695        else if (name.equals("sequenceRange")) {
696          this.sequenceRange = new Range();
697          return this.sequenceRange;
698        }
699        else if (name.equals("startingSequence")) {
700          this.startingSequence = new MolecularSequenceRelativeStartingSequenceComponent();
701          return this.startingSequence;
702        }
703        else if (name.equals("edit")) {
704          return addEdit();
705        }
706        else
707          return super.addChild(name);
708      }
709
710      public MolecularSequenceRelativeComponent copy() {
711        MolecularSequenceRelativeComponent dst = new MolecularSequenceRelativeComponent();
712        copyValues(dst);
713        return dst;
714      }
715
716      public void copyValues(MolecularSequenceRelativeComponent dst) {
717        super.copyValues(dst);
718        dst.coordinateSystem = coordinateSystem == null ? null : coordinateSystem.copy();
719        dst.ordinalPosition = ordinalPosition == null ? null : ordinalPosition.copy();
720        dst.sequenceRange = sequenceRange == null ? null : sequenceRange.copy();
721        dst.startingSequence = startingSequence == null ? null : startingSequence.copy();
722        if (edit != null) {
723          dst.edit = new ArrayList<MolecularSequenceRelativeEditComponent>();
724          for (MolecularSequenceRelativeEditComponent i : edit)
725            dst.edit.add(i.copy());
726        };
727      }
728
729      @Override
730      public boolean equalsDeep(Base other_) {
731        if (!super.equalsDeep(other_))
732          return false;
733        if (!(other_ instanceof MolecularSequenceRelativeComponent))
734          return false;
735        MolecularSequenceRelativeComponent o = (MolecularSequenceRelativeComponent) other_;
736        return compareDeep(coordinateSystem, o.coordinateSystem, true) && compareDeep(ordinalPosition, o.ordinalPosition, true)
737           && compareDeep(sequenceRange, o.sequenceRange, true) && compareDeep(startingSequence, o.startingSequence, true)
738           && compareDeep(edit, o.edit, true);
739      }
740
741      @Override
742      public boolean equalsShallow(Base other_) {
743        if (!super.equalsShallow(other_))
744          return false;
745        if (!(other_ instanceof MolecularSequenceRelativeComponent))
746          return false;
747        MolecularSequenceRelativeComponent o = (MolecularSequenceRelativeComponent) other_;
748        return compareValues(ordinalPosition, o.ordinalPosition, true);
749      }
750
751      public boolean isEmpty() {
752        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(coordinateSystem, ordinalPosition
753          , sequenceRange, startingSequence, edit);
754      }
755
756  public String fhirType() {
757    return "MolecularSequence.relative";
758
759  }
760
761  }
762
763    @Block()
764    public static class MolecularSequenceRelativeStartingSequenceComponent extends BackboneElement implements IBaseBackboneElement {
765        /**
766         * The genome assembly used for starting sequence, e.g. GRCh38.
767         */
768        @Child(name = "genomeAssembly", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
769        @Description(shortDefinition="The genome assembly used for starting sequence, e.g. GRCh38", formalDefinition="The genome assembly used for starting sequence, e.g. GRCh38." )
770        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://loinc.org/LL1040-6/")
771        protected CodeableConcept genomeAssembly;
772
773        /**
774         * Structural unit composed of a nucleic acid molecule which controls its own replication through the interaction of specific proteins at one or more origins of replication ([SO:0000340](http://www.sequenceontology.org/browser/current_svn/term/SO:0000340)).
775         */
776        @Child(name = "chromosome", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
777        @Description(shortDefinition="Chromosome Identifier", formalDefinition="Structural unit composed of a nucleic acid molecule which controls its own replication through the interaction of specific proteins at one or more origins of replication ([SO:0000340](http://www.sequenceontology.org/browser/current_svn/term/SO:0000340))." )
778        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://loinc.org/LL2938-0/")
779        protected CodeableConcept chromosome;
780
781        /**
782         * The reference sequence that represents the starting sequence.
783         */
784        @Child(name = "sequence", type = {CodeableConcept.class, StringType.class, MolecularSequence.class}, order=3, min=0, max=1, modifier=false, summary=true)
785        @Description(shortDefinition="The reference sequence that represents the starting sequence", formalDefinition="The reference sequence that represents the starting sequence." )
786        protected DataType sequence;
787
788        /**
789         * Start position of the window on the starting sequence. This value should honor the rules of the coordinateSystem.
790         */
791        @Child(name = "windowStart", type = {IntegerType.class}, order=4, min=0, max=1, modifier=false, summary=true)
792        @Description(shortDefinition="Start position of the window on the starting sequence", formalDefinition="Start position of the window on the starting sequence. This value should honor the rules of the coordinateSystem." )
793        protected IntegerType windowStart;
794
795        /**
796         * End position of the window on the starting sequence. This value should honor the rules of the  coordinateSystem.
797         */
798        @Child(name = "windowEnd", type = {IntegerType.class}, order=5, min=0, max=1, modifier=false, summary=true)
799        @Description(shortDefinition="End position of the window on the starting sequence", formalDefinition="End position of the window on the starting sequence. This value should honor the rules of the  coordinateSystem." )
800        protected IntegerType windowEnd;
801
802        /**
803         * A relative reference to a DNA strand based on gene orientation. The strand that contains the open reading frame of the gene is the "sense" strand, and the opposite complementary strand is the "antisense" strand.
804         */
805        @Child(name = "orientation", type = {CodeType.class}, order=6, min=0, max=1, modifier=false, summary=true)
806        @Description(shortDefinition="sense | antisense", formalDefinition="A relative reference to a DNA strand based on gene orientation. The strand that contains the open reading frame of the gene is the \"sense\" strand, and the opposite complementary strand is the \"antisense\" strand." )
807        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/orientation-type")
808        protected Enumeration<OrientationType> orientation;
809
810        /**
811         * An absolute reference to a strand. The Watson strand is the strand whose 5'-end is on the short arm of the chromosome, and the Crick strand as the one whose 5'-end is on the long arm.
812         */
813        @Child(name = "strand", type = {CodeType.class}, order=7, min=0, max=1, modifier=false, summary=true)
814        @Description(shortDefinition="watson | crick", formalDefinition="An absolute reference to a strand. The Watson strand is the strand whose 5'-end is on the short arm of the chromosome, and the Crick strand as the one whose 5'-end is on the long arm." )
815        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/strand-type")
816        protected Enumeration<StrandType> strand;
817
818        private static final long serialVersionUID = 502438613L;
819
820    /**
821     * Constructor
822     */
823      public MolecularSequenceRelativeStartingSequenceComponent() {
824        super();
825      }
826
827        /**
828         * @return {@link #genomeAssembly} (The genome assembly used for starting sequence, e.g. GRCh38.)
829         */
830        public CodeableConcept getGenomeAssembly() { 
831          if (this.genomeAssembly == null)
832            if (Configuration.errorOnAutoCreate())
833              throw new Error("Attempt to auto-create MolecularSequenceRelativeStartingSequenceComponent.genomeAssembly");
834            else if (Configuration.doAutoCreate())
835              this.genomeAssembly = new CodeableConcept(); // cc
836          return this.genomeAssembly;
837        }
838
839        public boolean hasGenomeAssembly() { 
840          return this.genomeAssembly != null && !this.genomeAssembly.isEmpty();
841        }
842
843        /**
844         * @param value {@link #genomeAssembly} (The genome assembly used for starting sequence, e.g. GRCh38.)
845         */
846        public MolecularSequenceRelativeStartingSequenceComponent setGenomeAssembly(CodeableConcept value) { 
847          this.genomeAssembly = value;
848          return this;
849        }
850
851        /**
852         * @return {@link #chromosome} (Structural unit composed of a nucleic acid molecule which controls its own replication through the interaction of specific proteins at one or more origins of replication ([SO:0000340](http://www.sequenceontology.org/browser/current_svn/term/SO:0000340)).)
853         */
854        public CodeableConcept getChromosome() { 
855          if (this.chromosome == null)
856            if (Configuration.errorOnAutoCreate())
857              throw new Error("Attempt to auto-create MolecularSequenceRelativeStartingSequenceComponent.chromosome");
858            else if (Configuration.doAutoCreate())
859              this.chromosome = new CodeableConcept(); // cc
860          return this.chromosome;
861        }
862
863        public boolean hasChromosome() { 
864          return this.chromosome != null && !this.chromosome.isEmpty();
865        }
866
867        /**
868         * @param value {@link #chromosome} (Structural unit composed of a nucleic acid molecule which controls its own replication through the interaction of specific proteins at one or more origins of replication ([SO:0000340](http://www.sequenceontology.org/browser/current_svn/term/SO:0000340)).)
869         */
870        public MolecularSequenceRelativeStartingSequenceComponent setChromosome(CodeableConcept value) { 
871          this.chromosome = value;
872          return this;
873        }
874
875        /**
876         * @return {@link #sequence} (The reference sequence that represents the starting sequence.)
877         */
878        public DataType getSequence() { 
879          return this.sequence;
880        }
881
882        /**
883         * @return {@link #sequence} (The reference sequence that represents the starting sequence.)
884         */
885        public CodeableConcept getSequenceCodeableConcept() throws FHIRException { 
886          if (this.sequence == null)
887            this.sequence = new CodeableConcept();
888          if (!(this.sequence instanceof CodeableConcept))
889            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.sequence.getClass().getName()+" was encountered");
890          return (CodeableConcept) this.sequence;
891        }
892
893        public boolean hasSequenceCodeableConcept() { 
894          return this != null && this.sequence instanceof CodeableConcept;
895        }
896
897        /**
898         * @return {@link #sequence} (The reference sequence that represents the starting sequence.)
899         */
900        public StringType getSequenceStringType() throws FHIRException { 
901          if (this.sequence == null)
902            this.sequence = new StringType();
903          if (!(this.sequence instanceof StringType))
904            throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.sequence.getClass().getName()+" was encountered");
905          return (StringType) this.sequence;
906        }
907
908        public boolean hasSequenceStringType() { 
909          return this != null && this.sequence instanceof StringType;
910        }
911
912        /**
913         * @return {@link #sequence} (The reference sequence that represents the starting sequence.)
914         */
915        public Reference getSequenceReference() throws FHIRException { 
916          if (this.sequence == null)
917            this.sequence = new Reference();
918          if (!(this.sequence instanceof Reference))
919            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.sequence.getClass().getName()+" was encountered");
920          return (Reference) this.sequence;
921        }
922
923        public boolean hasSequenceReference() { 
924          return this != null && this.sequence instanceof Reference;
925        }
926
927        public boolean hasSequence() { 
928          return this.sequence != null && !this.sequence.isEmpty();
929        }
930
931        /**
932         * @param value {@link #sequence} (The reference sequence that represents the starting sequence.)
933         */
934        public MolecularSequenceRelativeStartingSequenceComponent setSequence(DataType value) { 
935          if (value != null && !(value instanceof CodeableConcept || value instanceof StringType || value instanceof Reference))
936            throw new Error("Not the right type for MolecularSequence.relative.startingSequence.sequence[x]: "+value.fhirType());
937          this.sequence = value;
938          return this;
939        }
940
941        /**
942         * @return {@link #windowStart} (Start position of the window on the starting sequence. This value should honor the rules of the coordinateSystem.). This is the underlying object with id, value and extensions. The accessor "getWindowStart" gives direct access to the value
943         */
944        public IntegerType getWindowStartElement() { 
945          if (this.windowStart == null)
946            if (Configuration.errorOnAutoCreate())
947              throw new Error("Attempt to auto-create MolecularSequenceRelativeStartingSequenceComponent.windowStart");
948            else if (Configuration.doAutoCreate())
949              this.windowStart = new IntegerType(); // bb
950          return this.windowStart;
951        }
952
953        public boolean hasWindowStartElement() { 
954          return this.windowStart != null && !this.windowStart.isEmpty();
955        }
956
957        public boolean hasWindowStart() { 
958          return this.windowStart != null && !this.windowStart.isEmpty();
959        }
960
961        /**
962         * @param value {@link #windowStart} (Start position of the window on the starting sequence. This value should honor the rules of the coordinateSystem.). This is the underlying object with id, value and extensions. The accessor "getWindowStart" gives direct access to the value
963         */
964        public MolecularSequenceRelativeStartingSequenceComponent setWindowStartElement(IntegerType value) { 
965          this.windowStart = value;
966          return this;
967        }
968
969        /**
970         * @return Start position of the window on the starting sequence. This value should honor the rules of the coordinateSystem.
971         */
972        public int getWindowStart() { 
973          return this.windowStart == null || this.windowStart.isEmpty() ? 0 : this.windowStart.getValue();
974        }
975
976        /**
977         * @param value Start position of the window on the starting sequence. This value should honor the rules of the coordinateSystem.
978         */
979        public MolecularSequenceRelativeStartingSequenceComponent setWindowStart(int value) { 
980            if (this.windowStart == null)
981              this.windowStart = new IntegerType();
982            this.windowStart.setValue(value);
983          return this;
984        }
985
986        /**
987         * @return {@link #windowEnd} (End position of the window on the starting sequence. This value should honor the rules of the  coordinateSystem.). This is the underlying object with id, value and extensions. The accessor "getWindowEnd" gives direct access to the value
988         */
989        public IntegerType getWindowEndElement() { 
990          if (this.windowEnd == null)
991            if (Configuration.errorOnAutoCreate())
992              throw new Error("Attempt to auto-create MolecularSequenceRelativeStartingSequenceComponent.windowEnd");
993            else if (Configuration.doAutoCreate())
994              this.windowEnd = new IntegerType(); // bb
995          return this.windowEnd;
996        }
997
998        public boolean hasWindowEndElement() { 
999          return this.windowEnd != null && !this.windowEnd.isEmpty();
1000        }
1001
1002        public boolean hasWindowEnd() { 
1003          return this.windowEnd != null && !this.windowEnd.isEmpty();
1004        }
1005
1006        /**
1007         * @param value {@link #windowEnd} (End position of the window on the starting sequence. This value should honor the rules of the  coordinateSystem.). This is the underlying object with id, value and extensions. The accessor "getWindowEnd" gives direct access to the value
1008         */
1009        public MolecularSequenceRelativeStartingSequenceComponent setWindowEndElement(IntegerType value) { 
1010          this.windowEnd = value;
1011          return this;
1012        }
1013
1014        /**
1015         * @return End position of the window on the starting sequence. This value should honor the rules of the  coordinateSystem.
1016         */
1017        public int getWindowEnd() { 
1018          return this.windowEnd == null || this.windowEnd.isEmpty() ? 0 : this.windowEnd.getValue();
1019        }
1020
1021        /**
1022         * @param value End position of the window on the starting sequence. This value should honor the rules of the  coordinateSystem.
1023         */
1024        public MolecularSequenceRelativeStartingSequenceComponent setWindowEnd(int value) { 
1025            if (this.windowEnd == null)
1026              this.windowEnd = new IntegerType();
1027            this.windowEnd.setValue(value);
1028          return this;
1029        }
1030
1031        /**
1032         * @return {@link #orientation} (A relative reference to a DNA strand based on gene orientation. The strand that contains the open reading frame of the gene is the "sense" strand, and the opposite complementary strand is the "antisense" strand.). This is the underlying object with id, value and extensions. The accessor "getOrientation" gives direct access to the value
1033         */
1034        public Enumeration<OrientationType> getOrientationElement() { 
1035          if (this.orientation == null)
1036            if (Configuration.errorOnAutoCreate())
1037              throw new Error("Attempt to auto-create MolecularSequenceRelativeStartingSequenceComponent.orientation");
1038            else if (Configuration.doAutoCreate())
1039              this.orientation = new Enumeration<OrientationType>(new OrientationTypeEnumFactory()); // bb
1040          return this.orientation;
1041        }
1042
1043        public boolean hasOrientationElement() { 
1044          return this.orientation != null && !this.orientation.isEmpty();
1045        }
1046
1047        public boolean hasOrientation() { 
1048          return this.orientation != null && !this.orientation.isEmpty();
1049        }
1050
1051        /**
1052         * @param value {@link #orientation} (A relative reference to a DNA strand based on gene orientation. The strand that contains the open reading frame of the gene is the "sense" strand, and the opposite complementary strand is the "antisense" strand.). This is the underlying object with id, value and extensions. The accessor "getOrientation" gives direct access to the value
1053         */
1054        public MolecularSequenceRelativeStartingSequenceComponent setOrientationElement(Enumeration<OrientationType> value) { 
1055          this.orientation = value;
1056          return this;
1057        }
1058
1059        /**
1060         * @return A relative reference to a DNA strand based on gene orientation. The strand that contains the open reading frame of the gene is the "sense" strand, and the opposite complementary strand is the "antisense" strand.
1061         */
1062        public OrientationType getOrientation() { 
1063          return this.orientation == null ? null : this.orientation.getValue();
1064        }
1065
1066        /**
1067         * @param value A relative reference to a DNA strand based on gene orientation. The strand that contains the open reading frame of the gene is the "sense" strand, and the opposite complementary strand is the "antisense" strand.
1068         */
1069        public MolecularSequenceRelativeStartingSequenceComponent setOrientation(OrientationType value) { 
1070          if (value == null)
1071            this.orientation = null;
1072          else {
1073            if (this.orientation == null)
1074              this.orientation = new Enumeration<OrientationType>(new OrientationTypeEnumFactory());
1075            this.orientation.setValue(value);
1076          }
1077          return this;
1078        }
1079
1080        /**
1081         * @return {@link #strand} (An absolute reference to a strand. The Watson strand is the strand whose 5'-end is on the short arm of the chromosome, and the Crick strand as the one whose 5'-end is on the long arm.). This is the underlying object with id, value and extensions. The accessor "getStrand" gives direct access to the value
1082         */
1083        public Enumeration<StrandType> getStrandElement() { 
1084          if (this.strand == null)
1085            if (Configuration.errorOnAutoCreate())
1086              throw new Error("Attempt to auto-create MolecularSequenceRelativeStartingSequenceComponent.strand");
1087            else if (Configuration.doAutoCreate())
1088              this.strand = new Enumeration<StrandType>(new StrandTypeEnumFactory()); // bb
1089          return this.strand;
1090        }
1091
1092        public boolean hasStrandElement() { 
1093          return this.strand != null && !this.strand.isEmpty();
1094        }
1095
1096        public boolean hasStrand() { 
1097          return this.strand != null && !this.strand.isEmpty();
1098        }
1099
1100        /**
1101         * @param value {@link #strand} (An absolute reference to a strand. The Watson strand is the strand whose 5'-end is on the short arm of the chromosome, and the Crick strand as the one whose 5'-end is on the long arm.). This is the underlying object with id, value and extensions. The accessor "getStrand" gives direct access to the value
1102         */
1103        public MolecularSequenceRelativeStartingSequenceComponent setStrandElement(Enumeration<StrandType> value) { 
1104          this.strand = value;
1105          return this;
1106        }
1107
1108        /**
1109         * @return An absolute reference to a strand. The Watson strand is the strand whose 5'-end is on the short arm of the chromosome, and the Crick strand as the one whose 5'-end is on the long arm.
1110         */
1111        public StrandType getStrand() { 
1112          return this.strand == null ? null : this.strand.getValue();
1113        }
1114
1115        /**
1116         * @param value An absolute reference to a strand. The Watson strand is the strand whose 5'-end is on the short arm of the chromosome, and the Crick strand as the one whose 5'-end is on the long arm.
1117         */
1118        public MolecularSequenceRelativeStartingSequenceComponent setStrand(StrandType value) { 
1119          if (value == null)
1120            this.strand = null;
1121          else {
1122            if (this.strand == null)
1123              this.strand = new Enumeration<StrandType>(new StrandTypeEnumFactory());
1124            this.strand.setValue(value);
1125          }
1126          return this;
1127        }
1128
1129        protected void listChildren(List<Property> children) {
1130          super.listChildren(children);
1131          children.add(new Property("genomeAssembly", "CodeableConcept", "The genome assembly used for starting sequence, e.g. GRCh38.", 0, 1, genomeAssembly));
1132          children.add(new Property("chromosome", "CodeableConcept", "Structural unit composed of a nucleic acid molecule which controls its own replication through the interaction of specific proteins at one or more origins of replication ([SO:0000340](http://www.sequenceontology.org/browser/current_svn/term/SO:0000340)).", 0, 1, chromosome));
1133          children.add(new Property("sequence[x]", "CodeableConcept|string|Reference(MolecularSequence)", "The reference sequence that represents the starting sequence.", 0, 1, sequence));
1134          children.add(new Property("windowStart", "integer", "Start position of the window on the starting sequence. This value should honor the rules of the coordinateSystem.", 0, 1, windowStart));
1135          children.add(new Property("windowEnd", "integer", "End position of the window on the starting sequence. This value should honor the rules of the  coordinateSystem.", 0, 1, windowEnd));
1136          children.add(new Property("orientation", "code", "A relative reference to a DNA strand based on gene orientation. The strand that contains the open reading frame of the gene is the \"sense\" strand, and the opposite complementary strand is the \"antisense\" strand.", 0, 1, orientation));
1137          children.add(new Property("strand", "code", "An absolute reference to a strand. The Watson strand is the strand whose 5'-end is on the short arm of the chromosome, and the Crick strand as the one whose 5'-end is on the long arm.", 0, 1, strand));
1138        }
1139
1140        @Override
1141        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1142          switch (_hash) {
1143          case 1196021757: /*genomeAssembly*/  return new Property("genomeAssembly", "CodeableConcept", "The genome assembly used for starting sequence, e.g. GRCh38.", 0, 1, genomeAssembly);
1144          case -1499470472: /*chromosome*/  return new Property("chromosome", "CodeableConcept", "Structural unit composed of a nucleic acid molecule which controls its own replication through the interaction of specific proteins at one or more origins of replication ([SO:0000340](http://www.sequenceontology.org/browser/current_svn/term/SO:0000340)).", 0, 1, chromosome);
1145          case -805222113: /*sequence[x]*/  return new Property("sequence[x]", "CodeableConcept|string|Reference(MolecularSequence)", "The reference sequence that represents the starting sequence.", 0, 1, sequence);
1146          case 1349547969: /*sequence*/  return new Property("sequence[x]", "CodeableConcept|string|Reference(MolecularSequence)", "The reference sequence that represents the starting sequence.", 0, 1, sequence);
1147          case 1508480416: /*sequenceCodeableConcept*/  return new Property("sequence[x]", "CodeableConcept", "The reference sequence that represents the starting sequence.", 0, 1, sequence);
1148          case -1211617486: /*sequenceString*/  return new Property("sequence[x]", "string", "The reference sequence that represents the starting sequence.", 0, 1, sequence);
1149          case -1127149430: /*sequenceReference*/  return new Property("sequence[x]", "Reference(MolecularSequence)", "The reference sequence that represents the starting sequence.", 0, 1, sequence);
1150          case 1903685202: /*windowStart*/  return new Property("windowStart", "integer", "Start position of the window on the starting sequence. This value should honor the rules of the coordinateSystem.", 0, 1, windowStart);
1151          case -217026869: /*windowEnd*/  return new Property("windowEnd", "integer", "End position of the window on the starting sequence. This value should honor the rules of the  coordinateSystem.", 0, 1, windowEnd);
1152          case -1439500848: /*orientation*/  return new Property("orientation", "code", "A relative reference to a DNA strand based on gene orientation. The strand that contains the open reading frame of the gene is the \"sense\" strand, and the opposite complementary strand is the \"antisense\" strand.", 0, 1, orientation);
1153          case -891993594: /*strand*/  return new Property("strand", "code", "An absolute reference to a strand. The Watson strand is the strand whose 5'-end is on the short arm of the chromosome, and the Crick strand as the one whose 5'-end is on the long arm.", 0, 1, strand);
1154          default: return super.getNamedProperty(_hash, _name, _checkValid);
1155          }
1156
1157        }
1158
1159      @Override
1160      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1161        switch (hash) {
1162        case 1196021757: /*genomeAssembly*/ return this.genomeAssembly == null ? new Base[0] : new Base[] {this.genomeAssembly}; // CodeableConcept
1163        case -1499470472: /*chromosome*/ return this.chromosome == null ? new Base[0] : new Base[] {this.chromosome}; // CodeableConcept
1164        case 1349547969: /*sequence*/ return this.sequence == null ? new Base[0] : new Base[] {this.sequence}; // DataType
1165        case 1903685202: /*windowStart*/ return this.windowStart == null ? new Base[0] : new Base[] {this.windowStart}; // IntegerType
1166        case -217026869: /*windowEnd*/ return this.windowEnd == null ? new Base[0] : new Base[] {this.windowEnd}; // IntegerType
1167        case -1439500848: /*orientation*/ return this.orientation == null ? new Base[0] : new Base[] {this.orientation}; // Enumeration<OrientationType>
1168        case -891993594: /*strand*/ return this.strand == null ? new Base[0] : new Base[] {this.strand}; // Enumeration<StrandType>
1169        default: return super.getProperty(hash, name, checkValid);
1170        }
1171
1172      }
1173
1174      @Override
1175      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1176        switch (hash) {
1177        case 1196021757: // genomeAssembly
1178          this.genomeAssembly = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1179          return value;
1180        case -1499470472: // chromosome
1181          this.chromosome = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1182          return value;
1183        case 1349547969: // sequence
1184          this.sequence = TypeConvertor.castToType(value); // DataType
1185          return value;
1186        case 1903685202: // windowStart
1187          this.windowStart = TypeConvertor.castToInteger(value); // IntegerType
1188          return value;
1189        case -217026869: // windowEnd
1190          this.windowEnd = TypeConvertor.castToInteger(value); // IntegerType
1191          return value;
1192        case -1439500848: // orientation
1193          value = new OrientationTypeEnumFactory().fromType(TypeConvertor.castToCode(value));
1194          this.orientation = (Enumeration) value; // Enumeration<OrientationType>
1195          return value;
1196        case -891993594: // strand
1197          value = new StrandTypeEnumFactory().fromType(TypeConvertor.castToCode(value));
1198          this.strand = (Enumeration) value; // Enumeration<StrandType>
1199          return value;
1200        default: return super.setProperty(hash, name, value);
1201        }
1202
1203      }
1204
1205      @Override
1206      public Base setProperty(String name, Base value) throws FHIRException {
1207        if (name.equals("genomeAssembly")) {
1208          this.genomeAssembly = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1209        } else if (name.equals("chromosome")) {
1210          this.chromosome = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1211        } else if (name.equals("sequence[x]")) {
1212          this.sequence = TypeConvertor.castToType(value); // DataType
1213        } else if (name.equals("windowStart")) {
1214          this.windowStart = TypeConvertor.castToInteger(value); // IntegerType
1215        } else if (name.equals("windowEnd")) {
1216          this.windowEnd = TypeConvertor.castToInteger(value); // IntegerType
1217        } else if (name.equals("orientation")) {
1218          value = new OrientationTypeEnumFactory().fromType(TypeConvertor.castToCode(value));
1219          this.orientation = (Enumeration) value; // Enumeration<OrientationType>
1220        } else if (name.equals("strand")) {
1221          value = new StrandTypeEnumFactory().fromType(TypeConvertor.castToCode(value));
1222          this.strand = (Enumeration) value; // Enumeration<StrandType>
1223        } else
1224          return super.setProperty(name, value);
1225        return value;
1226      }
1227
1228      @Override
1229      public Base makeProperty(int hash, String name) throws FHIRException {
1230        switch (hash) {
1231        case 1196021757:  return getGenomeAssembly();
1232        case -1499470472:  return getChromosome();
1233        case -805222113:  return getSequence();
1234        case 1349547969:  return getSequence();
1235        case 1903685202:  return getWindowStartElement();
1236        case -217026869:  return getWindowEndElement();
1237        case -1439500848:  return getOrientationElement();
1238        case -891993594:  return getStrandElement();
1239        default: return super.makeProperty(hash, name);
1240        }
1241
1242      }
1243
1244      @Override
1245      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1246        switch (hash) {
1247        case 1196021757: /*genomeAssembly*/ return new String[] {"CodeableConcept"};
1248        case -1499470472: /*chromosome*/ return new String[] {"CodeableConcept"};
1249        case 1349547969: /*sequence*/ return new String[] {"CodeableConcept", "string", "Reference"};
1250        case 1903685202: /*windowStart*/ return new String[] {"integer"};
1251        case -217026869: /*windowEnd*/ return new String[] {"integer"};
1252        case -1439500848: /*orientation*/ return new String[] {"code"};
1253        case -891993594: /*strand*/ return new String[] {"code"};
1254        default: return super.getTypesForProperty(hash, name);
1255        }
1256
1257      }
1258
1259      @Override
1260      public Base addChild(String name) throws FHIRException {
1261        if (name.equals("genomeAssembly")) {
1262          this.genomeAssembly = new CodeableConcept();
1263          return this.genomeAssembly;
1264        }
1265        else if (name.equals("chromosome")) {
1266          this.chromosome = new CodeableConcept();
1267          return this.chromosome;
1268        }
1269        else if (name.equals("sequenceCodeableConcept")) {
1270          this.sequence = new CodeableConcept();
1271          return this.sequence;
1272        }
1273        else if (name.equals("sequenceString")) {
1274          this.sequence = new StringType();
1275          return this.sequence;
1276        }
1277        else if (name.equals("sequenceReference")) {
1278          this.sequence = new Reference();
1279          return this.sequence;
1280        }
1281        else if (name.equals("windowStart")) {
1282          throw new FHIRException("Cannot call addChild on a primitive type MolecularSequence.relative.startingSequence.windowStart");
1283        }
1284        else if (name.equals("windowEnd")) {
1285          throw new FHIRException("Cannot call addChild on a primitive type MolecularSequence.relative.startingSequence.windowEnd");
1286        }
1287        else if (name.equals("orientation")) {
1288          throw new FHIRException("Cannot call addChild on a primitive type MolecularSequence.relative.startingSequence.orientation");
1289        }
1290        else if (name.equals("strand")) {
1291          throw new FHIRException("Cannot call addChild on a primitive type MolecularSequence.relative.startingSequence.strand");
1292        }
1293        else
1294          return super.addChild(name);
1295      }
1296
1297      public MolecularSequenceRelativeStartingSequenceComponent copy() {
1298        MolecularSequenceRelativeStartingSequenceComponent dst = new MolecularSequenceRelativeStartingSequenceComponent();
1299        copyValues(dst);
1300        return dst;
1301      }
1302
1303      public void copyValues(MolecularSequenceRelativeStartingSequenceComponent dst) {
1304        super.copyValues(dst);
1305        dst.genomeAssembly = genomeAssembly == null ? null : genomeAssembly.copy();
1306        dst.chromosome = chromosome == null ? null : chromosome.copy();
1307        dst.sequence = sequence == null ? null : sequence.copy();
1308        dst.windowStart = windowStart == null ? null : windowStart.copy();
1309        dst.windowEnd = windowEnd == null ? null : windowEnd.copy();
1310        dst.orientation = orientation == null ? null : orientation.copy();
1311        dst.strand = strand == null ? null : strand.copy();
1312      }
1313
1314      @Override
1315      public boolean equalsDeep(Base other_) {
1316        if (!super.equalsDeep(other_))
1317          return false;
1318        if (!(other_ instanceof MolecularSequenceRelativeStartingSequenceComponent))
1319          return false;
1320        MolecularSequenceRelativeStartingSequenceComponent o = (MolecularSequenceRelativeStartingSequenceComponent) other_;
1321        return compareDeep(genomeAssembly, o.genomeAssembly, true) && compareDeep(chromosome, o.chromosome, true)
1322           && compareDeep(sequence, o.sequence, true) && compareDeep(windowStart, o.windowStart, true) && compareDeep(windowEnd, o.windowEnd, true)
1323           && compareDeep(orientation, o.orientation, true) && compareDeep(strand, o.strand, true);
1324      }
1325
1326      @Override
1327      public boolean equalsShallow(Base other_) {
1328        if (!super.equalsShallow(other_))
1329          return false;
1330        if (!(other_ instanceof MolecularSequenceRelativeStartingSequenceComponent))
1331          return false;
1332        MolecularSequenceRelativeStartingSequenceComponent o = (MolecularSequenceRelativeStartingSequenceComponent) other_;
1333        return compareValues(windowStart, o.windowStart, true) && compareValues(windowEnd, o.windowEnd, true)
1334           && compareValues(orientation, o.orientation, true) && compareValues(strand, o.strand, true);
1335      }
1336
1337      public boolean isEmpty() {
1338        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(genomeAssembly, chromosome
1339          , sequence, windowStart, windowEnd, orientation, strand);
1340      }
1341
1342  public String fhirType() {
1343    return "MolecularSequence.relative.startingSequence";
1344
1345  }
1346
1347  }
1348
1349    @Block()
1350    public static class MolecularSequenceRelativeEditComponent extends BackboneElement implements IBaseBackboneElement {
1351        /**
1352         * Start position of the edit on the starting sequence. If the coordinate system is either 0-based or 1-based, then start position is inclusive.
1353         */
1354        @Child(name = "start", type = {IntegerType.class}, order=1, min=0, max=1, modifier=false, summary=true)
1355        @Description(shortDefinition="Start position of the edit on the starting sequence", formalDefinition="Start position of the edit on the starting sequence. If the coordinate system is either 0-based or 1-based, then start position is inclusive." )
1356        protected IntegerType start;
1357
1358        /**
1359         * End position of the edit on the starting sequence. If the coordinate system is 0-based then end is exclusive and does not include the last position. If the coordinate system is 1-base, then end is inclusive and includes the last position.
1360         */
1361        @Child(name = "end", type = {IntegerType.class}, order=2, min=0, max=1, modifier=false, summary=true)
1362        @Description(shortDefinition="End position of the edit on the starting sequence", formalDefinition="End position of the edit on the starting sequence. If the coordinate system is 0-based then end is exclusive and does not include the last position. If the coordinate system is 1-base, then end is inclusive and includes the last position." )
1363        protected IntegerType end;
1364
1365        /**
1366         * Allele that was observed. Nucleotide(s)/amino acids from start position of sequence to stop position of sequence on the positive (+) strand of the observed sequence. When the sequence type is DNA, it should be the sequence on the positive (+) strand. This will lay in the range between variant.start and variant.end.
1367         */
1368        @Child(name = "replacementSequence", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=true)
1369        @Description(shortDefinition="Allele that was observed", formalDefinition="Allele that was observed. Nucleotide(s)/amino acids from start position of sequence to stop position of sequence on the positive (+) strand of the observed sequence. When the sequence type is DNA, it should be the sequence on the positive (+) strand. This will lay in the range between variant.start and variant.end." )
1370        protected StringType replacementSequence;
1371
1372        /**
1373         * Allele in the starting sequence. Nucleotide(s)/amino acids from start position of sequence to stop position of sequence on the positive (+) strand of the starting sequence. When the sequence  type is DNA, it should be the sequence on the positive (+) strand. This will lay in the range between variant.start and variant.end.
1374         */
1375        @Child(name = "replacedSequence", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=true)
1376        @Description(shortDefinition="Allele in the starting sequence", formalDefinition="Allele in the starting sequence. Nucleotide(s)/amino acids from start position of sequence to stop position of sequence on the positive (+) strand of the starting sequence. When the sequence  type is DNA, it should be the sequence on the positive (+) strand. This will lay in the range between variant.start and variant.end." )
1377        protected StringType replacedSequence;
1378
1379        private static final long serialVersionUID = 550127909L;
1380
1381    /**
1382     * Constructor
1383     */
1384      public MolecularSequenceRelativeEditComponent() {
1385        super();
1386      }
1387
1388        /**
1389         * @return {@link #start} (Start position of the edit on the starting sequence. If the coordinate system is either 0-based or 1-based, then start position is inclusive.). This is the underlying object with id, value and extensions. The accessor "getStart" gives direct access to the value
1390         */
1391        public IntegerType getStartElement() { 
1392          if (this.start == null)
1393            if (Configuration.errorOnAutoCreate())
1394              throw new Error("Attempt to auto-create MolecularSequenceRelativeEditComponent.start");
1395            else if (Configuration.doAutoCreate())
1396              this.start = new IntegerType(); // bb
1397          return this.start;
1398        }
1399
1400        public boolean hasStartElement() { 
1401          return this.start != null && !this.start.isEmpty();
1402        }
1403
1404        public boolean hasStart() { 
1405          return this.start != null && !this.start.isEmpty();
1406        }
1407
1408        /**
1409         * @param value {@link #start} (Start position of the edit on the starting sequence. If the coordinate system is either 0-based or 1-based, then start position is inclusive.). This is the underlying object with id, value and extensions. The accessor "getStart" gives direct access to the value
1410         */
1411        public MolecularSequenceRelativeEditComponent setStartElement(IntegerType value) { 
1412          this.start = value;
1413          return this;
1414        }
1415
1416        /**
1417         * @return Start position of the edit on the starting sequence. If the coordinate system is either 0-based or 1-based, then start position is inclusive.
1418         */
1419        public int getStart() { 
1420          return this.start == null || this.start.isEmpty() ? 0 : this.start.getValue();
1421        }
1422
1423        /**
1424         * @param value Start position of the edit on the starting sequence. If the coordinate system is either 0-based or 1-based, then start position is inclusive.
1425         */
1426        public MolecularSequenceRelativeEditComponent setStart(int value) { 
1427            if (this.start == null)
1428              this.start = new IntegerType();
1429            this.start.setValue(value);
1430          return this;
1431        }
1432
1433        /**
1434         * @return {@link #end} (End position of the edit on the starting sequence. If the coordinate system is 0-based then end is exclusive and does not include the last position. If the coordinate system is 1-base, then end is inclusive and includes the last position.). This is the underlying object with id, value and extensions. The accessor "getEnd" gives direct access to the value
1435         */
1436        public IntegerType getEndElement() { 
1437          if (this.end == null)
1438            if (Configuration.errorOnAutoCreate())
1439              throw new Error("Attempt to auto-create MolecularSequenceRelativeEditComponent.end");
1440            else if (Configuration.doAutoCreate())
1441              this.end = new IntegerType(); // bb
1442          return this.end;
1443        }
1444
1445        public boolean hasEndElement() { 
1446          return this.end != null && !this.end.isEmpty();
1447        }
1448
1449        public boolean hasEnd() { 
1450          return this.end != null && !this.end.isEmpty();
1451        }
1452
1453        /**
1454         * @param value {@link #end} (End position of the edit on the starting sequence. If the coordinate system is 0-based then end is exclusive and does not include the last position. If the coordinate system is 1-base, then end is inclusive and includes the last position.). This is the underlying object with id, value and extensions. The accessor "getEnd" gives direct access to the value
1455         */
1456        public MolecularSequenceRelativeEditComponent setEndElement(IntegerType value) { 
1457          this.end = value;
1458          return this;
1459        }
1460
1461        /**
1462         * @return End position of the edit on the starting sequence. If the coordinate system is 0-based then end is exclusive and does not include the last position. If the coordinate system is 1-base, then end is inclusive and includes the last position.
1463         */
1464        public int getEnd() { 
1465          return this.end == null || this.end.isEmpty() ? 0 : this.end.getValue();
1466        }
1467
1468        /**
1469         * @param value End position of the edit on the starting sequence. If the coordinate system is 0-based then end is exclusive and does not include the last position. If the coordinate system is 1-base, then end is inclusive and includes the last position.
1470         */
1471        public MolecularSequenceRelativeEditComponent setEnd(int value) { 
1472            if (this.end == null)
1473              this.end = new IntegerType();
1474            this.end.setValue(value);
1475          return this;
1476        }
1477
1478        /**
1479         * @return {@link #replacementSequence} (Allele that was observed. Nucleotide(s)/amino acids from start position of sequence to stop position of sequence on the positive (+) strand of the observed sequence. When the sequence type is DNA, it should be the sequence on the positive (+) strand. This will lay in the range between variant.start and variant.end.). This is the underlying object with id, value and extensions. The accessor "getReplacementSequence" gives direct access to the value
1480         */
1481        public StringType getReplacementSequenceElement() { 
1482          if (this.replacementSequence == null)
1483            if (Configuration.errorOnAutoCreate())
1484              throw new Error("Attempt to auto-create MolecularSequenceRelativeEditComponent.replacementSequence");
1485            else if (Configuration.doAutoCreate())
1486              this.replacementSequence = new StringType(); // bb
1487          return this.replacementSequence;
1488        }
1489
1490        public boolean hasReplacementSequenceElement() { 
1491          return this.replacementSequence != null && !this.replacementSequence.isEmpty();
1492        }
1493
1494        public boolean hasReplacementSequence() { 
1495          return this.replacementSequence != null && !this.replacementSequence.isEmpty();
1496        }
1497
1498        /**
1499         * @param value {@link #replacementSequence} (Allele that was observed. Nucleotide(s)/amino acids from start position of sequence to stop position of sequence on the positive (+) strand of the observed sequence. When the sequence type is DNA, it should be the sequence on the positive (+) strand. This will lay in the range between variant.start and variant.end.). This is the underlying object with id, value and extensions. The accessor "getReplacementSequence" gives direct access to the value
1500         */
1501        public MolecularSequenceRelativeEditComponent setReplacementSequenceElement(StringType value) { 
1502          this.replacementSequence = value;
1503          return this;
1504        }
1505
1506        /**
1507         * @return Allele that was observed. Nucleotide(s)/amino acids from start position of sequence to stop position of sequence on the positive (+) strand of the observed sequence. When the sequence type is DNA, it should be the sequence on the positive (+) strand. This will lay in the range between variant.start and variant.end.
1508         */
1509        public String getReplacementSequence() { 
1510          return this.replacementSequence == null ? null : this.replacementSequence.getValue();
1511        }
1512
1513        /**
1514         * @param value Allele that was observed. Nucleotide(s)/amino acids from start position of sequence to stop position of sequence on the positive (+) strand of the observed sequence. When the sequence type is DNA, it should be the sequence on the positive (+) strand. This will lay in the range between variant.start and variant.end.
1515         */
1516        public MolecularSequenceRelativeEditComponent setReplacementSequence(String value) { 
1517          if (Utilities.noString(value))
1518            this.replacementSequence = null;
1519          else {
1520            if (this.replacementSequence == null)
1521              this.replacementSequence = new StringType();
1522            this.replacementSequence.setValue(value);
1523          }
1524          return this;
1525        }
1526
1527        /**
1528         * @return {@link #replacedSequence} (Allele in the starting sequence. Nucleotide(s)/amino acids from start position of sequence to stop position of sequence on the positive (+) strand of the starting sequence. When the sequence  type is DNA, it should be the sequence on the positive (+) strand. This will lay in the range between variant.start and variant.end.). This is the underlying object with id, value and extensions. The accessor "getReplacedSequence" gives direct access to the value
1529         */
1530        public StringType getReplacedSequenceElement() { 
1531          if (this.replacedSequence == null)
1532            if (Configuration.errorOnAutoCreate())
1533              throw new Error("Attempt to auto-create MolecularSequenceRelativeEditComponent.replacedSequence");
1534            else if (Configuration.doAutoCreate())
1535              this.replacedSequence = new StringType(); // bb
1536          return this.replacedSequence;
1537        }
1538
1539        public boolean hasReplacedSequenceElement() { 
1540          return this.replacedSequence != null && !this.replacedSequence.isEmpty();
1541        }
1542
1543        public boolean hasReplacedSequence() { 
1544          return this.replacedSequence != null && !this.replacedSequence.isEmpty();
1545        }
1546
1547        /**
1548         * @param value {@link #replacedSequence} (Allele in the starting sequence. Nucleotide(s)/amino acids from start position of sequence to stop position of sequence on the positive (+) strand of the starting sequence. When the sequence  type is DNA, it should be the sequence on the positive (+) strand. This will lay in the range between variant.start and variant.end.). This is the underlying object with id, value and extensions. The accessor "getReplacedSequence" gives direct access to the value
1549         */
1550        public MolecularSequenceRelativeEditComponent setReplacedSequenceElement(StringType value) { 
1551          this.replacedSequence = value;
1552          return this;
1553        }
1554
1555        /**
1556         * @return Allele in the starting sequence. Nucleotide(s)/amino acids from start position of sequence to stop position of sequence on the positive (+) strand of the starting sequence. When the sequence  type is DNA, it should be the sequence on the positive (+) strand. This will lay in the range between variant.start and variant.end.
1557         */
1558        public String getReplacedSequence() { 
1559          return this.replacedSequence == null ? null : this.replacedSequence.getValue();
1560        }
1561
1562        /**
1563         * @param value Allele in the starting sequence. Nucleotide(s)/amino acids from start position of sequence to stop position of sequence on the positive (+) strand of the starting sequence. When the sequence  type is DNA, it should be the sequence on the positive (+) strand. This will lay in the range between variant.start and variant.end.
1564         */
1565        public MolecularSequenceRelativeEditComponent setReplacedSequence(String value) { 
1566          if (Utilities.noString(value))
1567            this.replacedSequence = null;
1568          else {
1569            if (this.replacedSequence == null)
1570              this.replacedSequence = new StringType();
1571            this.replacedSequence.setValue(value);
1572          }
1573          return this;
1574        }
1575
1576        protected void listChildren(List<Property> children) {
1577          super.listChildren(children);
1578          children.add(new Property("start", "integer", "Start position of the edit on the starting sequence. If the coordinate system is either 0-based or 1-based, then start position is inclusive.", 0, 1, start));
1579          children.add(new Property("end", "integer", "End position of the edit on the starting sequence. If the coordinate system is 0-based then end is exclusive and does not include the last position. If the coordinate system is 1-base, then end is inclusive and includes the last position.", 0, 1, end));
1580          children.add(new Property("replacementSequence", "string", "Allele that was observed. Nucleotide(s)/amino acids from start position of sequence to stop position of sequence on the positive (+) strand of the observed sequence. When the sequence type is DNA, it should be the sequence on the positive (+) strand. This will lay in the range between variant.start and variant.end.", 0, 1, replacementSequence));
1581          children.add(new Property("replacedSequence", "string", "Allele in the starting sequence. Nucleotide(s)/amino acids from start position of sequence to stop position of sequence on the positive (+) strand of the starting sequence. When the sequence  type is DNA, it should be the sequence on the positive (+) strand. This will lay in the range between variant.start and variant.end.", 0, 1, replacedSequence));
1582        }
1583
1584        @Override
1585        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1586          switch (_hash) {
1587          case 109757538: /*start*/  return new Property("start", "integer", "Start position of the edit on the starting sequence. If the coordinate system is either 0-based or 1-based, then start position is inclusive.", 0, 1, start);
1588          case 100571: /*end*/  return new Property("end", "integer", "End position of the edit on the starting sequence. If the coordinate system is 0-based then end is exclusive and does not include the last position. If the coordinate system is 1-base, then end is inclusive and includes the last position.", 0, 1, end);
1589          case -1784940557: /*replacementSequence*/  return new Property("replacementSequence", "string", "Allele that was observed. Nucleotide(s)/amino acids from start position of sequence to stop position of sequence on the positive (+) strand of the observed sequence. When the sequence type is DNA, it should be the sequence on the positive (+) strand. This will lay in the range between variant.start and variant.end.", 0, 1, replacementSequence);
1590          case 1972719633: /*replacedSequence*/  return new Property("replacedSequence", "string", "Allele in the starting sequence. Nucleotide(s)/amino acids from start position of sequence to stop position of sequence on the positive (+) strand of the starting sequence. When the sequence  type is DNA, it should be the sequence on the positive (+) strand. This will lay in the range between variant.start and variant.end.", 0, 1, replacedSequence);
1591          default: return super.getNamedProperty(_hash, _name, _checkValid);
1592          }
1593
1594        }
1595
1596      @Override
1597      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1598        switch (hash) {
1599        case 109757538: /*start*/ return this.start == null ? new Base[0] : new Base[] {this.start}; // IntegerType
1600        case 100571: /*end*/ return this.end == null ? new Base[0] : new Base[] {this.end}; // IntegerType
1601        case -1784940557: /*replacementSequence*/ return this.replacementSequence == null ? new Base[0] : new Base[] {this.replacementSequence}; // StringType
1602        case 1972719633: /*replacedSequence*/ return this.replacedSequence == null ? new Base[0] : new Base[] {this.replacedSequence}; // StringType
1603        default: return super.getProperty(hash, name, checkValid);
1604        }
1605
1606      }
1607
1608      @Override
1609      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1610        switch (hash) {
1611        case 109757538: // start
1612          this.start = TypeConvertor.castToInteger(value); // IntegerType
1613          return value;
1614        case 100571: // end
1615          this.end = TypeConvertor.castToInteger(value); // IntegerType
1616          return value;
1617        case -1784940557: // replacementSequence
1618          this.replacementSequence = TypeConvertor.castToString(value); // StringType
1619          return value;
1620        case 1972719633: // replacedSequence
1621          this.replacedSequence = TypeConvertor.castToString(value); // StringType
1622          return value;
1623        default: return super.setProperty(hash, name, value);
1624        }
1625
1626      }
1627
1628      @Override
1629      public Base setProperty(String name, Base value) throws FHIRException {
1630        if (name.equals("start")) {
1631          this.start = TypeConvertor.castToInteger(value); // IntegerType
1632        } else if (name.equals("end")) {
1633          this.end = TypeConvertor.castToInteger(value); // IntegerType
1634        } else if (name.equals("replacementSequence")) {
1635          this.replacementSequence = TypeConvertor.castToString(value); // StringType
1636        } else if (name.equals("replacedSequence")) {
1637          this.replacedSequence = TypeConvertor.castToString(value); // StringType
1638        } else
1639          return super.setProperty(name, value);
1640        return value;
1641      }
1642
1643      @Override
1644      public Base makeProperty(int hash, String name) throws FHIRException {
1645        switch (hash) {
1646        case 109757538:  return getStartElement();
1647        case 100571:  return getEndElement();
1648        case -1784940557:  return getReplacementSequenceElement();
1649        case 1972719633:  return getReplacedSequenceElement();
1650        default: return super.makeProperty(hash, name);
1651        }
1652
1653      }
1654
1655      @Override
1656      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1657        switch (hash) {
1658        case 109757538: /*start*/ return new String[] {"integer"};
1659        case 100571: /*end*/ return new String[] {"integer"};
1660        case -1784940557: /*replacementSequence*/ return new String[] {"string"};
1661        case 1972719633: /*replacedSequence*/ return new String[] {"string"};
1662        default: return super.getTypesForProperty(hash, name);
1663        }
1664
1665      }
1666
1667      @Override
1668      public Base addChild(String name) throws FHIRException {
1669        if (name.equals("start")) {
1670          throw new FHIRException("Cannot call addChild on a primitive type MolecularSequence.relative.edit.start");
1671        }
1672        else if (name.equals("end")) {
1673          throw new FHIRException("Cannot call addChild on a primitive type MolecularSequence.relative.edit.end");
1674        }
1675        else if (name.equals("replacementSequence")) {
1676          throw new FHIRException("Cannot call addChild on a primitive type MolecularSequence.relative.edit.replacementSequence");
1677        }
1678        else if (name.equals("replacedSequence")) {
1679          throw new FHIRException("Cannot call addChild on a primitive type MolecularSequence.relative.edit.replacedSequence");
1680        }
1681        else
1682          return super.addChild(name);
1683      }
1684
1685      public MolecularSequenceRelativeEditComponent copy() {
1686        MolecularSequenceRelativeEditComponent dst = new MolecularSequenceRelativeEditComponent();
1687        copyValues(dst);
1688        return dst;
1689      }
1690
1691      public void copyValues(MolecularSequenceRelativeEditComponent dst) {
1692        super.copyValues(dst);
1693        dst.start = start == null ? null : start.copy();
1694        dst.end = end == null ? null : end.copy();
1695        dst.replacementSequence = replacementSequence == null ? null : replacementSequence.copy();
1696        dst.replacedSequence = replacedSequence == null ? null : replacedSequence.copy();
1697      }
1698
1699      @Override
1700      public boolean equalsDeep(Base other_) {
1701        if (!super.equalsDeep(other_))
1702          return false;
1703        if (!(other_ instanceof MolecularSequenceRelativeEditComponent))
1704          return false;
1705        MolecularSequenceRelativeEditComponent o = (MolecularSequenceRelativeEditComponent) other_;
1706        return compareDeep(start, o.start, true) && compareDeep(end, o.end, true) && compareDeep(replacementSequence, o.replacementSequence, true)
1707           && compareDeep(replacedSequence, o.replacedSequence, true);
1708      }
1709
1710      @Override
1711      public boolean equalsShallow(Base other_) {
1712        if (!super.equalsShallow(other_))
1713          return false;
1714        if (!(other_ instanceof MolecularSequenceRelativeEditComponent))
1715          return false;
1716        MolecularSequenceRelativeEditComponent o = (MolecularSequenceRelativeEditComponent) other_;
1717        return compareValues(start, o.start, true) && compareValues(end, o.end, true) && compareValues(replacementSequence, o.replacementSequence, true)
1718           && compareValues(replacedSequence, o.replacedSequence, true);
1719      }
1720
1721      public boolean isEmpty() {
1722        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(start, end, replacementSequence
1723          , replacedSequence);
1724      }
1725
1726  public String fhirType() {
1727    return "MolecularSequence.relative.edit";
1728
1729  }
1730
1731  }
1732
1733    /**
1734     * A unique identifier for this particular sequence instance.
1735     */
1736    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1737    @Description(shortDefinition="Unique ID for this particular sequence", formalDefinition="A unique identifier for this particular sequence instance." )
1738    protected List<Identifier> identifier;
1739
1740    /**
1741     * Amino Acid Sequence/ DNA Sequence / RNA Sequence.
1742     */
1743    @Child(name = "type", type = {CodeType.class}, order=1, min=0, max=1, modifier=false, summary=true)
1744    @Description(shortDefinition="aa | dna | rna", formalDefinition="Amino Acid Sequence/ DNA Sequence / RNA Sequence." )
1745    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/sequence-type")
1746    protected Enumeration<SequenceType> type;
1747
1748    /**
1749     * Indicates the subject this sequence is associated too.
1750     */
1751    @Child(name = "subject", type = {Patient.class, Group.class, Device.class, Location.class, Organization.class, Procedure.class, Practitioner.class, Medication.class, Substance.class, BiologicallyDerivedProduct.class, NutritionProduct.class}, order=2, min=0, max=1, modifier=false, summary=true)
1752    @Description(shortDefinition="Subject this sequence is associated too", formalDefinition="Indicates the subject this sequence is associated too." )
1753    protected Reference subject;
1754
1755    /**
1756     * Specimen used for sequencing.
1757     */
1758    @Child(name = "specimen", type = {Specimen.class}, order=3, min=0, max=1, modifier=false, summary=true)
1759    @Description(shortDefinition="Specimen used for sequencing", formalDefinition="Specimen used for sequencing." )
1760    protected Reference specimen;
1761
1762    /**
1763     * The method for sequencing, for example, chip information.
1764     */
1765    @Child(name = "device", type = {Device.class}, order=4, min=0, max=1, modifier=false, summary=true)
1766    @Description(shortDefinition="The method for sequencing", formalDefinition="The method for sequencing, for example, chip information." )
1767    protected Reference device;
1768
1769    /**
1770     * The organization or lab that should be responsible for this result.
1771     */
1772    @Child(name = "performer", type = {Organization.class}, order=5, min=0, max=1, modifier=false, summary=true)
1773    @Description(shortDefinition="Who should be responsible for test result", formalDefinition="The organization or lab that should be responsible for this result." )
1774    protected Reference performer;
1775
1776    /**
1777     * Sequence that was observed.
1778     */
1779    @Child(name = "literal", type = {StringType.class}, order=6, min=0, max=1, modifier=false, summary=true)
1780    @Description(shortDefinition="Sequence that was observed", formalDefinition="Sequence that was observed." )
1781    protected StringType literal;
1782
1783    /**
1784     * Sequence that was observed as file content. Can be an actual file contents, or referenced by a URL to an external system.
1785     */
1786    @Child(name = "formatted", type = {Attachment.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1787    @Description(shortDefinition="Embedded file or a link (URL) which contains content to represent the sequence", formalDefinition="Sequence that was observed as file content. Can be an actual file contents, or referenced by a URL to an external system." )
1788    protected List<Attachment> formatted;
1789
1790    /**
1791     * A sequence defined relative to another sequence.
1792     */
1793    @Child(name = "relative", type = {}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1794    @Description(shortDefinition="A sequence defined relative to another sequence", formalDefinition="A sequence defined relative to another sequence." )
1795    protected List<MolecularSequenceRelativeComponent> relative;
1796
1797    private static final long serialVersionUID = -191255113L;
1798
1799  /**
1800   * Constructor
1801   */
1802    public MolecularSequence() {
1803      super();
1804    }
1805
1806    /**
1807     * @return {@link #identifier} (A unique identifier for this particular sequence instance.)
1808     */
1809    public List<Identifier> getIdentifier() { 
1810      if (this.identifier == null)
1811        this.identifier = new ArrayList<Identifier>();
1812      return this.identifier;
1813    }
1814
1815    /**
1816     * @return Returns a reference to <code>this</code> for easy method chaining
1817     */
1818    public MolecularSequence setIdentifier(List<Identifier> theIdentifier) { 
1819      this.identifier = theIdentifier;
1820      return this;
1821    }
1822
1823    public boolean hasIdentifier() { 
1824      if (this.identifier == null)
1825        return false;
1826      for (Identifier item : this.identifier)
1827        if (!item.isEmpty())
1828          return true;
1829      return false;
1830    }
1831
1832    public Identifier addIdentifier() { //3
1833      Identifier t = new Identifier();
1834      if (this.identifier == null)
1835        this.identifier = new ArrayList<Identifier>();
1836      this.identifier.add(t);
1837      return t;
1838    }
1839
1840    public MolecularSequence addIdentifier(Identifier t) { //3
1841      if (t == null)
1842        return this;
1843      if (this.identifier == null)
1844        this.identifier = new ArrayList<Identifier>();
1845      this.identifier.add(t);
1846      return this;
1847    }
1848
1849    /**
1850     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist {3}
1851     */
1852    public Identifier getIdentifierFirstRep() { 
1853      if (getIdentifier().isEmpty()) {
1854        addIdentifier();
1855      }
1856      return getIdentifier().get(0);
1857    }
1858
1859    /**
1860     * @return {@link #type} (Amino Acid Sequence/ DNA Sequence / RNA Sequence.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
1861     */
1862    public Enumeration<SequenceType> getTypeElement() { 
1863      if (this.type == null)
1864        if (Configuration.errorOnAutoCreate())
1865          throw new Error("Attempt to auto-create MolecularSequence.type");
1866        else if (Configuration.doAutoCreate())
1867          this.type = new Enumeration<SequenceType>(new SequenceTypeEnumFactory()); // bb
1868      return this.type;
1869    }
1870
1871    public boolean hasTypeElement() { 
1872      return this.type != null && !this.type.isEmpty();
1873    }
1874
1875    public boolean hasType() { 
1876      return this.type != null && !this.type.isEmpty();
1877    }
1878
1879    /**
1880     * @param value {@link #type} (Amino Acid Sequence/ DNA Sequence / RNA Sequence.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
1881     */
1882    public MolecularSequence setTypeElement(Enumeration<SequenceType> value) { 
1883      this.type = value;
1884      return this;
1885    }
1886
1887    /**
1888     * @return Amino Acid Sequence/ DNA Sequence / RNA Sequence.
1889     */
1890    public SequenceType getType() { 
1891      return this.type == null ? null : this.type.getValue();
1892    }
1893
1894    /**
1895     * @param value Amino Acid Sequence/ DNA Sequence / RNA Sequence.
1896     */
1897    public MolecularSequence setType(SequenceType value) { 
1898      if (value == null)
1899        this.type = null;
1900      else {
1901        if (this.type == null)
1902          this.type = new Enumeration<SequenceType>(new SequenceTypeEnumFactory());
1903        this.type.setValue(value);
1904      }
1905      return this;
1906    }
1907
1908    /**
1909     * @return {@link #subject} (Indicates the subject this sequence is associated too.)
1910     */
1911    public Reference getSubject() { 
1912      if (this.subject == null)
1913        if (Configuration.errorOnAutoCreate())
1914          throw new Error("Attempt to auto-create MolecularSequence.subject");
1915        else if (Configuration.doAutoCreate())
1916          this.subject = new Reference(); // cc
1917      return this.subject;
1918    }
1919
1920    public boolean hasSubject() { 
1921      return this.subject != null && !this.subject.isEmpty();
1922    }
1923
1924    /**
1925     * @param value {@link #subject} (Indicates the subject this sequence is associated too.)
1926     */
1927    public MolecularSequence setSubject(Reference value) { 
1928      this.subject = value;
1929      return this;
1930    }
1931
1932    /**
1933     * @return {@link #specimen} (Specimen used for sequencing.)
1934     */
1935    public Reference getSpecimen() { 
1936      if (this.specimen == null)
1937        if (Configuration.errorOnAutoCreate())
1938          throw new Error("Attempt to auto-create MolecularSequence.specimen");
1939        else if (Configuration.doAutoCreate())
1940          this.specimen = new Reference(); // cc
1941      return this.specimen;
1942    }
1943
1944    public boolean hasSpecimen() { 
1945      return this.specimen != null && !this.specimen.isEmpty();
1946    }
1947
1948    /**
1949     * @param value {@link #specimen} (Specimen used for sequencing.)
1950     */
1951    public MolecularSequence setSpecimen(Reference value) { 
1952      this.specimen = value;
1953      return this;
1954    }
1955
1956    /**
1957     * @return {@link #device} (The method for sequencing, for example, chip information.)
1958     */
1959    public Reference getDevice() { 
1960      if (this.device == null)
1961        if (Configuration.errorOnAutoCreate())
1962          throw new Error("Attempt to auto-create MolecularSequence.device");
1963        else if (Configuration.doAutoCreate())
1964          this.device = new Reference(); // cc
1965      return this.device;
1966    }
1967
1968    public boolean hasDevice() { 
1969      return this.device != null && !this.device.isEmpty();
1970    }
1971
1972    /**
1973     * @param value {@link #device} (The method for sequencing, for example, chip information.)
1974     */
1975    public MolecularSequence setDevice(Reference value) { 
1976      this.device = value;
1977      return this;
1978    }
1979
1980    /**
1981     * @return {@link #performer} (The organization or lab that should be responsible for this result.)
1982     */
1983    public Reference getPerformer() { 
1984      if (this.performer == null)
1985        if (Configuration.errorOnAutoCreate())
1986          throw new Error("Attempt to auto-create MolecularSequence.performer");
1987        else if (Configuration.doAutoCreate())
1988          this.performer = new Reference(); // cc
1989      return this.performer;
1990    }
1991
1992    public boolean hasPerformer() { 
1993      return this.performer != null && !this.performer.isEmpty();
1994    }
1995
1996    /**
1997     * @param value {@link #performer} (The organization or lab that should be responsible for this result.)
1998     */
1999    public MolecularSequence setPerformer(Reference value) { 
2000      this.performer = value;
2001      return this;
2002    }
2003
2004    /**
2005     * @return {@link #literal} (Sequence that was observed.). This is the underlying object with id, value and extensions. The accessor "getLiteral" gives direct access to the value
2006     */
2007    public StringType getLiteralElement() { 
2008      if (this.literal == null)
2009        if (Configuration.errorOnAutoCreate())
2010          throw new Error("Attempt to auto-create MolecularSequence.literal");
2011        else if (Configuration.doAutoCreate())
2012          this.literal = new StringType(); // bb
2013      return this.literal;
2014    }
2015
2016    public boolean hasLiteralElement() { 
2017      return this.literal != null && !this.literal.isEmpty();
2018    }
2019
2020    public boolean hasLiteral() { 
2021      return this.literal != null && !this.literal.isEmpty();
2022    }
2023
2024    /**
2025     * @param value {@link #literal} (Sequence that was observed.). This is the underlying object with id, value and extensions. The accessor "getLiteral" gives direct access to the value
2026     */
2027    public MolecularSequence setLiteralElement(StringType value) { 
2028      this.literal = value;
2029      return this;
2030    }
2031
2032    /**
2033     * @return Sequence that was observed.
2034     */
2035    public String getLiteral() { 
2036      return this.literal == null ? null : this.literal.getValue();
2037    }
2038
2039    /**
2040     * @param value Sequence that was observed.
2041     */
2042    public MolecularSequence setLiteral(String value) { 
2043      if (Utilities.noString(value))
2044        this.literal = null;
2045      else {
2046        if (this.literal == null)
2047          this.literal = new StringType();
2048        this.literal.setValue(value);
2049      }
2050      return this;
2051    }
2052
2053    /**
2054     * @return {@link #formatted} (Sequence that was observed as file content. Can be an actual file contents, or referenced by a URL to an external system.)
2055     */
2056    public List<Attachment> getFormatted() { 
2057      if (this.formatted == null)
2058        this.formatted = new ArrayList<Attachment>();
2059      return this.formatted;
2060    }
2061
2062    /**
2063     * @return Returns a reference to <code>this</code> for easy method chaining
2064     */
2065    public MolecularSequence setFormatted(List<Attachment> theFormatted) { 
2066      this.formatted = theFormatted;
2067      return this;
2068    }
2069
2070    public boolean hasFormatted() { 
2071      if (this.formatted == null)
2072        return false;
2073      for (Attachment item : this.formatted)
2074        if (!item.isEmpty())
2075          return true;
2076      return false;
2077    }
2078
2079    public Attachment addFormatted() { //3
2080      Attachment t = new Attachment();
2081      if (this.formatted == null)
2082        this.formatted = new ArrayList<Attachment>();
2083      this.formatted.add(t);
2084      return t;
2085    }
2086
2087    public MolecularSequence addFormatted(Attachment t) { //3
2088      if (t == null)
2089        return this;
2090      if (this.formatted == null)
2091        this.formatted = new ArrayList<Attachment>();
2092      this.formatted.add(t);
2093      return this;
2094    }
2095
2096    /**
2097     * @return The first repetition of repeating field {@link #formatted}, creating it if it does not already exist {3}
2098     */
2099    public Attachment getFormattedFirstRep() { 
2100      if (getFormatted().isEmpty()) {
2101        addFormatted();
2102      }
2103      return getFormatted().get(0);
2104    }
2105
2106    /**
2107     * @return {@link #relative} (A sequence defined relative to another sequence.)
2108     */
2109    public List<MolecularSequenceRelativeComponent> getRelative() { 
2110      if (this.relative == null)
2111        this.relative = new ArrayList<MolecularSequenceRelativeComponent>();
2112      return this.relative;
2113    }
2114
2115    /**
2116     * @return Returns a reference to <code>this</code> for easy method chaining
2117     */
2118    public MolecularSequence setRelative(List<MolecularSequenceRelativeComponent> theRelative) { 
2119      this.relative = theRelative;
2120      return this;
2121    }
2122
2123    public boolean hasRelative() { 
2124      if (this.relative == null)
2125        return false;
2126      for (MolecularSequenceRelativeComponent item : this.relative)
2127        if (!item.isEmpty())
2128          return true;
2129      return false;
2130    }
2131
2132    public MolecularSequenceRelativeComponent addRelative() { //3
2133      MolecularSequenceRelativeComponent t = new MolecularSequenceRelativeComponent();
2134      if (this.relative == null)
2135        this.relative = new ArrayList<MolecularSequenceRelativeComponent>();
2136      this.relative.add(t);
2137      return t;
2138    }
2139
2140    public MolecularSequence addRelative(MolecularSequenceRelativeComponent t) { //3
2141      if (t == null)
2142        return this;
2143      if (this.relative == null)
2144        this.relative = new ArrayList<MolecularSequenceRelativeComponent>();
2145      this.relative.add(t);
2146      return this;
2147    }
2148
2149    /**
2150     * @return The first repetition of repeating field {@link #relative}, creating it if it does not already exist {3}
2151     */
2152    public MolecularSequenceRelativeComponent getRelativeFirstRep() { 
2153      if (getRelative().isEmpty()) {
2154        addRelative();
2155      }
2156      return getRelative().get(0);
2157    }
2158
2159      protected void listChildren(List<Property> children) {
2160        super.listChildren(children);
2161        children.add(new Property("identifier", "Identifier", "A unique identifier for this particular sequence instance.", 0, java.lang.Integer.MAX_VALUE, identifier));
2162        children.add(new Property("type", "code", "Amino Acid Sequence/ DNA Sequence / RNA Sequence.", 0, 1, type));
2163        children.add(new Property("subject", "Reference(Patient|Group|Device|Location|Organization|Procedure|Practitioner|Medication|Substance|BiologicallyDerivedProduct|NutritionProduct)", "Indicates the subject this sequence is associated too.", 0, 1, subject));
2164        children.add(new Property("specimen", "Reference(Specimen)", "Specimen used for sequencing.", 0, 1, specimen));
2165        children.add(new Property("device", "Reference(Device)", "The method for sequencing, for example, chip information.", 0, 1, device));
2166        children.add(new Property("performer", "Reference(Organization)", "The organization or lab that should be responsible for this result.", 0, 1, performer));
2167        children.add(new Property("literal", "string", "Sequence that was observed.", 0, 1, literal));
2168        children.add(new Property("formatted", "Attachment", "Sequence that was observed as file content. Can be an actual file contents, or referenced by a URL to an external system.", 0, java.lang.Integer.MAX_VALUE, formatted));
2169        children.add(new Property("relative", "", "A sequence defined relative to another sequence.", 0, java.lang.Integer.MAX_VALUE, relative));
2170      }
2171
2172      @Override
2173      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2174        switch (_hash) {
2175        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "A unique identifier for this particular sequence instance.", 0, java.lang.Integer.MAX_VALUE, identifier);
2176        case 3575610: /*type*/  return new Property("type", "code", "Amino Acid Sequence/ DNA Sequence / RNA Sequence.", 0, 1, type);
2177        case -1867885268: /*subject*/  return new Property("subject", "Reference(Patient|Group|Device|Location|Organization|Procedure|Practitioner|Medication|Substance|BiologicallyDerivedProduct|NutritionProduct)", "Indicates the subject this sequence is associated too.", 0, 1, subject);
2178        case -2132868344: /*specimen*/  return new Property("specimen", "Reference(Specimen)", "Specimen used for sequencing.", 0, 1, specimen);
2179        case -1335157162: /*device*/  return new Property("device", "Reference(Device)", "The method for sequencing, for example, chip information.", 0, 1, device);
2180        case 481140686: /*performer*/  return new Property("performer", "Reference(Organization)", "The organization or lab that should be responsible for this result.", 0, 1, performer);
2181        case 182460591: /*literal*/  return new Property("literal", "string", "Sequence that was observed.", 0, 1, literal);
2182        case 1811591356: /*formatted*/  return new Property("formatted", "Attachment", "Sequence that was observed as file content. Can be an actual file contents, or referenced by a URL to an external system.", 0, java.lang.Integer.MAX_VALUE, formatted);
2183        case -554435892: /*relative*/  return new Property("relative", "", "A sequence defined relative to another sequence.", 0, java.lang.Integer.MAX_VALUE, relative);
2184        default: return super.getNamedProperty(_hash, _name, _checkValid);
2185        }
2186
2187      }
2188
2189      @Override
2190      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2191        switch (hash) {
2192        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
2193        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // Enumeration<SequenceType>
2194        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
2195        case -2132868344: /*specimen*/ return this.specimen == null ? new Base[0] : new Base[] {this.specimen}; // Reference
2196        case -1335157162: /*device*/ return this.device == null ? new Base[0] : new Base[] {this.device}; // Reference
2197        case 481140686: /*performer*/ return this.performer == null ? new Base[0] : new Base[] {this.performer}; // Reference
2198        case 182460591: /*literal*/ return this.literal == null ? new Base[0] : new Base[] {this.literal}; // StringType
2199        case 1811591356: /*formatted*/ return this.formatted == null ? new Base[0] : this.formatted.toArray(new Base[this.formatted.size()]); // Attachment
2200        case -554435892: /*relative*/ return this.relative == null ? new Base[0] : this.relative.toArray(new Base[this.relative.size()]); // MolecularSequenceRelativeComponent
2201        default: return super.getProperty(hash, name, checkValid);
2202        }
2203
2204      }
2205
2206      @Override
2207      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2208        switch (hash) {
2209        case -1618432855: // identifier
2210          this.getIdentifier().add(TypeConvertor.castToIdentifier(value)); // Identifier
2211          return value;
2212        case 3575610: // type
2213          value = new SequenceTypeEnumFactory().fromType(TypeConvertor.castToCode(value));
2214          this.type = (Enumeration) value; // Enumeration<SequenceType>
2215          return value;
2216        case -1867885268: // subject
2217          this.subject = TypeConvertor.castToReference(value); // Reference
2218          return value;
2219        case -2132868344: // specimen
2220          this.specimen = TypeConvertor.castToReference(value); // Reference
2221          return value;
2222        case -1335157162: // device
2223          this.device = TypeConvertor.castToReference(value); // Reference
2224          return value;
2225        case 481140686: // performer
2226          this.performer = TypeConvertor.castToReference(value); // Reference
2227          return value;
2228        case 182460591: // literal
2229          this.literal = TypeConvertor.castToString(value); // StringType
2230          return value;
2231        case 1811591356: // formatted
2232          this.getFormatted().add(TypeConvertor.castToAttachment(value)); // Attachment
2233          return value;
2234        case -554435892: // relative
2235          this.getRelative().add((MolecularSequenceRelativeComponent) value); // MolecularSequenceRelativeComponent
2236          return value;
2237        default: return super.setProperty(hash, name, value);
2238        }
2239
2240      }
2241
2242      @Override
2243      public Base setProperty(String name, Base value) throws FHIRException {
2244        if (name.equals("identifier")) {
2245          this.getIdentifier().add(TypeConvertor.castToIdentifier(value));
2246        } else if (name.equals("type")) {
2247          value = new SequenceTypeEnumFactory().fromType(TypeConvertor.castToCode(value));
2248          this.type = (Enumeration) value; // Enumeration<SequenceType>
2249        } else if (name.equals("subject")) {
2250          this.subject = TypeConvertor.castToReference(value); // Reference
2251        } else if (name.equals("specimen")) {
2252          this.specimen = TypeConvertor.castToReference(value); // Reference
2253        } else if (name.equals("device")) {
2254          this.device = TypeConvertor.castToReference(value); // Reference
2255        } else if (name.equals("performer")) {
2256          this.performer = TypeConvertor.castToReference(value); // Reference
2257        } else if (name.equals("literal")) {
2258          this.literal = TypeConvertor.castToString(value); // StringType
2259        } else if (name.equals("formatted")) {
2260          this.getFormatted().add(TypeConvertor.castToAttachment(value));
2261        } else if (name.equals("relative")) {
2262          this.getRelative().add((MolecularSequenceRelativeComponent) value);
2263        } else
2264          return super.setProperty(name, value);
2265        return value;
2266      }
2267
2268      @Override
2269      public Base makeProperty(int hash, String name) throws FHIRException {
2270        switch (hash) {
2271        case -1618432855:  return addIdentifier(); 
2272        case 3575610:  return getTypeElement();
2273        case -1867885268:  return getSubject();
2274        case -2132868344:  return getSpecimen();
2275        case -1335157162:  return getDevice();
2276        case 481140686:  return getPerformer();
2277        case 182460591:  return getLiteralElement();
2278        case 1811591356:  return addFormatted(); 
2279        case -554435892:  return addRelative(); 
2280        default: return super.makeProperty(hash, name);
2281        }
2282
2283      }
2284
2285      @Override
2286      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2287        switch (hash) {
2288        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
2289        case 3575610: /*type*/ return new String[] {"code"};
2290        case -1867885268: /*subject*/ return new String[] {"Reference"};
2291        case -2132868344: /*specimen*/ return new String[] {"Reference"};
2292        case -1335157162: /*device*/ return new String[] {"Reference"};
2293        case 481140686: /*performer*/ return new String[] {"Reference"};
2294        case 182460591: /*literal*/ return new String[] {"string"};
2295        case 1811591356: /*formatted*/ return new String[] {"Attachment"};
2296        case -554435892: /*relative*/ return new String[] {};
2297        default: return super.getTypesForProperty(hash, name);
2298        }
2299
2300      }
2301
2302      @Override
2303      public Base addChild(String name) throws FHIRException {
2304        if (name.equals("identifier")) {
2305          return addIdentifier();
2306        }
2307        else if (name.equals("type")) {
2308          throw new FHIRException("Cannot call addChild on a primitive type MolecularSequence.type");
2309        }
2310        else if (name.equals("subject")) {
2311          this.subject = new Reference();
2312          return this.subject;
2313        }
2314        else if (name.equals("specimen")) {
2315          this.specimen = new Reference();
2316          return this.specimen;
2317        }
2318        else if (name.equals("device")) {
2319          this.device = new Reference();
2320          return this.device;
2321        }
2322        else if (name.equals("performer")) {
2323          this.performer = new Reference();
2324          return this.performer;
2325        }
2326        else if (name.equals("literal")) {
2327          throw new FHIRException("Cannot call addChild on a primitive type MolecularSequence.literal");
2328        }
2329        else if (name.equals("formatted")) {
2330          return addFormatted();
2331        }
2332        else if (name.equals("relative")) {
2333          return addRelative();
2334        }
2335        else
2336          return super.addChild(name);
2337      }
2338
2339  public String fhirType() {
2340    return "MolecularSequence";
2341
2342  }
2343
2344      public MolecularSequence copy() {
2345        MolecularSequence dst = new MolecularSequence();
2346        copyValues(dst);
2347        return dst;
2348      }
2349
2350      public void copyValues(MolecularSequence dst) {
2351        super.copyValues(dst);
2352        if (identifier != null) {
2353          dst.identifier = new ArrayList<Identifier>();
2354          for (Identifier i : identifier)
2355            dst.identifier.add(i.copy());
2356        };
2357        dst.type = type == null ? null : type.copy();
2358        dst.subject = subject == null ? null : subject.copy();
2359        dst.specimen = specimen == null ? null : specimen.copy();
2360        dst.device = device == null ? null : device.copy();
2361        dst.performer = performer == null ? null : performer.copy();
2362        dst.literal = literal == null ? null : literal.copy();
2363        if (formatted != null) {
2364          dst.formatted = new ArrayList<Attachment>();
2365          for (Attachment i : formatted)
2366            dst.formatted.add(i.copy());
2367        };
2368        if (relative != null) {
2369          dst.relative = new ArrayList<MolecularSequenceRelativeComponent>();
2370          for (MolecularSequenceRelativeComponent i : relative)
2371            dst.relative.add(i.copy());
2372        };
2373      }
2374
2375      protected MolecularSequence typedCopy() {
2376        return copy();
2377      }
2378
2379      @Override
2380      public boolean equalsDeep(Base other_) {
2381        if (!super.equalsDeep(other_))
2382          return false;
2383        if (!(other_ instanceof MolecularSequence))
2384          return false;
2385        MolecularSequence o = (MolecularSequence) other_;
2386        return compareDeep(identifier, o.identifier, true) && compareDeep(type, o.type, true) && compareDeep(subject, o.subject, true)
2387           && compareDeep(specimen, o.specimen, true) && compareDeep(device, o.device, true) && compareDeep(performer, o.performer, true)
2388           && compareDeep(literal, o.literal, true) && compareDeep(formatted, o.formatted, true) && compareDeep(relative, o.relative, true)
2389          ;
2390      }
2391
2392      @Override
2393      public boolean equalsShallow(Base other_) {
2394        if (!super.equalsShallow(other_))
2395          return false;
2396        if (!(other_ instanceof MolecularSequence))
2397          return false;
2398        MolecularSequence o = (MolecularSequence) other_;
2399        return compareValues(type, o.type, true) && compareValues(literal, o.literal, true);
2400      }
2401
2402      public boolean isEmpty() {
2403        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, type, subject
2404          , specimen, device, performer, literal, formatted, relative);
2405      }
2406
2407  @Override
2408  public ResourceType getResourceType() {
2409    return ResourceType.MolecularSequence;
2410   }
2411
2412 /**
2413   * Search parameter: <b>identifier</b>
2414   * <p>
2415   * Description: <b>The unique identity for a particular sequence</b><br>
2416   * Type: <b>token</b><br>
2417   * Path: <b>MolecularSequence.identifier</b><br>
2418   * </p>
2419   */
2420  @SearchParamDefinition(name="identifier", path="MolecularSequence.identifier", description="The unique identity for a particular sequence", type="token" )
2421  public static final String SP_IDENTIFIER = "identifier";
2422 /**
2423   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
2424   * <p>
2425   * Description: <b>The unique identity for a particular sequence</b><br>
2426   * Type: <b>token</b><br>
2427   * Path: <b>MolecularSequence.identifier</b><br>
2428   * </p>
2429   */
2430  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
2431
2432 /**
2433   * Search parameter: <b>patient</b>
2434   * <p>
2435   * Description: <b>The subject that the sequence is about</b><br>
2436   * Type: <b>reference</b><br>
2437   * Path: <b>MolecularSequence.subject</b><br>
2438   * </p>
2439   */
2440  @SearchParamDefinition(name="patient", path="MolecularSequence.subject", description="The subject that the sequence is about", type="reference", target={BiologicallyDerivedProduct.class, Device.class, Group.class, Location.class, Medication.class, NutritionProduct.class, Organization.class, Patient.class, Practitioner.class, Procedure.class, Substance.class } )
2441  public static final String SP_PATIENT = "patient";
2442 /**
2443   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
2444   * <p>
2445   * Description: <b>The subject that the sequence is about</b><br>
2446   * Type: <b>reference</b><br>
2447   * Path: <b>MolecularSequence.subject</b><br>
2448   * </p>
2449   */
2450  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
2451
2452/**
2453   * Constant for fluent queries to be used to add include statements. Specifies
2454   * the path value of "<b>MolecularSequence:patient</b>".
2455   */
2456  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("MolecularSequence:patient").toLocked();
2457
2458 /**
2459   * Search parameter: <b>subject</b>
2460   * <p>
2461   * Description: <b>The subject that the sequence is about</b><br>
2462   * Type: <b>reference</b><br>
2463   * Path: <b>MolecularSequence.subject</b><br>
2464   * </p>
2465   */
2466  @SearchParamDefinition(name="subject", path="MolecularSequence.subject", description="The subject that the sequence is about", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Base FHIR compartment definition for Patient") }, target={BiologicallyDerivedProduct.class, Device.class, Group.class, Location.class, Medication.class, NutritionProduct.class, Organization.class, Patient.class, Practitioner.class, Procedure.class, Substance.class } )
2467  public static final String SP_SUBJECT = "subject";
2468 /**
2469   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
2470   * <p>
2471   * Description: <b>The subject that the sequence is about</b><br>
2472   * Type: <b>reference</b><br>
2473   * Path: <b>MolecularSequence.subject</b><br>
2474   * </p>
2475   */
2476  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
2477
2478/**
2479   * Constant for fluent queries to be used to add include statements. Specifies
2480   * the path value of "<b>MolecularSequence:subject</b>".
2481   */
2482  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("MolecularSequence:subject").toLocked();
2483
2484 /**
2485   * Search parameter: <b>type</b>
2486   * <p>
2487   * Description: <b>Amino Acid Sequence/ DNA Sequence / RNA Sequence</b><br>
2488   * Type: <b>token</b><br>
2489   * Path: <b>MolecularSequence.type</b><br>
2490   * </p>
2491   */
2492  @SearchParamDefinition(name="type", path="MolecularSequence.type", description="Amino Acid Sequence/ DNA Sequence / RNA Sequence", type="token" )
2493  public static final String SP_TYPE = "type";
2494 /**
2495   * <b>Fluent Client</b> search parameter constant for <b>type</b>
2496   * <p>
2497   * Description: <b>Amino Acid Sequence/ DNA Sequence / RNA Sequence</b><br>
2498   * Type: <b>token</b><br>
2499   * Path: <b>MolecularSequence.type</b><br>
2500   * </p>
2501   */
2502  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_TYPE);
2503
2504
2505}