001package org.hl7.fhir.dstu2016may.model;
002
003
004
005
006/*
007  Copyright (c) 2011+, HL7, Inc.
008  All rights reserved.
009  
010  Redistribution and use in source and binary forms, with or without modification, 
011  are permitted provided that the following conditions are met:
012  
013   * Redistributions of source code must retain the above copyright notice, this 
014     list of conditions and the following disclaimer.
015   * Redistributions in binary form must reproduce the above copyright notice, 
016     this list of conditions and the following disclaimer in the documentation 
017     and/or other materials provided with the distribution.
018   * Neither the name of HL7 nor the names of its contributors may be used to 
019     endorse or promote products derived from this software without specific 
020     prior written permission.
021  
022  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
023  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
024  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
025  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
026  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
027  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
028  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
029  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
030  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
031  POSSIBILITY OF SUCH DAMAGE.
032  
033*/
034
035// Generated on Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
036import java.util.ArrayList;
037import java.util.Date;
038import java.util.List;
039
040import org.hl7.fhir.exceptions.FHIRException;
041
042import ca.uhn.fhir.model.api.annotation.Child;
043import ca.uhn.fhir.model.api.annotation.Description;
044import ca.uhn.fhir.model.api.annotation.ResourceDef;
045import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
046/**
047 * A record of a device being used by a patient where the record is the result of a report from the patient or another clinician.
048 */
049@ResourceDef(name="DeviceUseStatement", profile="http://hl7.org/fhir/Profile/DeviceUseStatement")
050public class DeviceUseStatement extends DomainResource {
051
052    /**
053     * Indicates the site on the subject's body where the device was used ( i.e. the target site).
054     */
055    @Child(name = "bodySite", type = {CodeableConcept.class, BodySite.class}, order=0, min=0, max=1, modifier=false, summary=true)
056    @Description(shortDefinition="Target body site", formalDefinition="Indicates the site on the subject's body where the device was used ( i.e. the target site)." )
057    protected Type bodySite;
058
059    /**
060     * The time period over which the device was used.
061     */
062    @Child(name = "whenUsed", type = {Period.class}, order=1, min=0, max=1, modifier=false, summary=true)
063    @Description(shortDefinition="", formalDefinition="The time period over which the device was used." )
064    protected Period whenUsed;
065
066    /**
067     * The details of the device used.
068     */
069    @Child(name = "device", type = {Device.class}, order=2, min=1, max=1, modifier=false, summary=true)
070    @Description(shortDefinition="", formalDefinition="The details of the device used." )
071    protected Reference device;
072
073    /**
074     * The actual object that is the target of the reference (The details of the device used.)
075     */
076    protected Device deviceTarget;
077
078    /**
079     * An external identifier for this statement such as an IRI.
080     */
081    @Child(name = "identifier", type = {Identifier.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
082    @Description(shortDefinition="", formalDefinition="An external identifier for this statement such as an IRI." )
083    protected List<Identifier> identifier;
084
085    /**
086     * Reason or justification for the use of the device.
087     */
088    @Child(name = "indication", type = {CodeableConcept.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
089    @Description(shortDefinition="", formalDefinition="Reason or justification for the use of the device." )
090    protected List<CodeableConcept> indication;
091
092    /**
093     * Details about the device statement that were not represented at all or sufficiently in one of the attributes provided in a class. These may include for example a comment, an instruction, or a note associated with the statement.
094     */
095    @Child(name = "notes", type = {StringType.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
096    @Description(shortDefinition="", formalDefinition="Details about the device statement that were not represented at all or sufficiently in one of the attributes provided in a class. These may include for example a comment, an instruction, or a note associated with the statement." )
097    protected List<StringType> notes;
098
099    /**
100     * The time at which the statement was made/recorded.
101     */
102    @Child(name = "recordedOn", type = {DateTimeType.class}, order=6, min=0, max=1, modifier=false, summary=true)
103    @Description(shortDefinition="", formalDefinition="The time at which the statement was made/recorded." )
104    protected DateTimeType recordedOn;
105
106    /**
107     * The patient who used the device.
108     */
109    @Child(name = "subject", type = {Patient.class}, order=7, min=1, max=1, modifier=false, summary=true)
110    @Description(shortDefinition="", formalDefinition="The patient who used the device." )
111    protected Reference subject;
112
113    /**
114     * The actual object that is the target of the reference (The patient who used the device.)
115     */
116    protected Patient subjectTarget;
117
118    /**
119     * How often the device was used.
120     */
121    @Child(name = "timing", type = {Timing.class, Period.class, DateTimeType.class}, order=8, min=0, max=1, modifier=false, summary=true)
122    @Description(shortDefinition="", formalDefinition="How often the device was used." )
123    protected Type timing;
124
125    private static final long serialVersionUID = -1668571635L;
126
127  /**
128   * Constructor
129   */
130    public DeviceUseStatement() {
131      super();
132    }
133
134  /**
135   * Constructor
136   */
137    public DeviceUseStatement(Reference device, Reference subject) {
138      super();
139      this.device = device;
140      this.subject = subject;
141    }
142
143    /**
144     * @return {@link #bodySite} (Indicates the site on the subject's body where the device was used ( i.e. the target site).)
145     */
146    public Type getBodySite() { 
147      return this.bodySite;
148    }
149
150    /**
151     * @return {@link #bodySite} (Indicates the site on the subject's body where the device was used ( i.e. the target site).)
152     */
153    public CodeableConcept getBodySiteCodeableConcept() throws FHIRException { 
154      if (!(this.bodySite instanceof CodeableConcept))
155        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.bodySite.getClass().getName()+" was encountered");
156      return (CodeableConcept) this.bodySite;
157    }
158
159    public boolean hasBodySiteCodeableConcept() { 
160      return this.bodySite instanceof CodeableConcept;
161    }
162
163    /**
164     * @return {@link #bodySite} (Indicates the site on the subject's body where the device was used ( i.e. the target site).)
165     */
166    public Reference getBodySiteReference() throws FHIRException { 
167      if (!(this.bodySite instanceof Reference))
168        throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.bodySite.getClass().getName()+" was encountered");
169      return (Reference) this.bodySite;
170    }
171
172    public boolean hasBodySiteReference() { 
173      return this.bodySite instanceof Reference;
174    }
175
176    public boolean hasBodySite() { 
177      return this.bodySite != null && !this.bodySite.isEmpty();
178    }
179
180    /**
181     * @param value {@link #bodySite} (Indicates the site on the subject's body where the device was used ( i.e. the target site).)
182     */
183    public DeviceUseStatement setBodySite(Type value) { 
184      this.bodySite = value;
185      return this;
186    }
187
188    /**
189     * @return {@link #whenUsed} (The time period over which the device was used.)
190     */
191    public Period getWhenUsed() { 
192      if (this.whenUsed == null)
193        if (Configuration.errorOnAutoCreate())
194          throw new Error("Attempt to auto-create DeviceUseStatement.whenUsed");
195        else if (Configuration.doAutoCreate())
196          this.whenUsed = new Period(); // cc
197      return this.whenUsed;
198    }
199
200    public boolean hasWhenUsed() { 
201      return this.whenUsed != null && !this.whenUsed.isEmpty();
202    }
203
204    /**
205     * @param value {@link #whenUsed} (The time period over which the device was used.)
206     */
207    public DeviceUseStatement setWhenUsed(Period value) { 
208      this.whenUsed = value;
209      return this;
210    }
211
212    /**
213     * @return {@link #device} (The details of the device used.)
214     */
215    public Reference getDevice() { 
216      if (this.device == null)
217        if (Configuration.errorOnAutoCreate())
218          throw new Error("Attempt to auto-create DeviceUseStatement.device");
219        else if (Configuration.doAutoCreate())
220          this.device = new Reference(); // cc
221      return this.device;
222    }
223
224    public boolean hasDevice() { 
225      return this.device != null && !this.device.isEmpty();
226    }
227
228    /**
229     * @param value {@link #device} (The details of the device used.)
230     */
231    public DeviceUseStatement setDevice(Reference value) { 
232      this.device = value;
233      return this;
234    }
235
236    /**
237     * @return {@link #device} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The details of the device used.)
238     */
239    public Device getDeviceTarget() { 
240      if (this.deviceTarget == null)
241        if (Configuration.errorOnAutoCreate())
242          throw new Error("Attempt to auto-create DeviceUseStatement.device");
243        else if (Configuration.doAutoCreate())
244          this.deviceTarget = new Device(); // aa
245      return this.deviceTarget;
246    }
247
248    /**
249     * @param value {@link #device} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The details of the device used.)
250     */
251    public DeviceUseStatement setDeviceTarget(Device value) { 
252      this.deviceTarget = value;
253      return this;
254    }
255
256    /**
257     * @return {@link #identifier} (An external identifier for this statement such as an IRI.)
258     */
259    public List<Identifier> getIdentifier() { 
260      if (this.identifier == null)
261        this.identifier = new ArrayList<Identifier>();
262      return this.identifier;
263    }
264
265    public boolean hasIdentifier() { 
266      if (this.identifier == null)
267        return false;
268      for (Identifier item : this.identifier)
269        if (!item.isEmpty())
270          return true;
271      return false;
272    }
273
274    /**
275     * @return {@link #identifier} (An external identifier for this statement such as an IRI.)
276     */
277    // syntactic sugar
278    public Identifier addIdentifier() { //3
279      Identifier t = new Identifier();
280      if (this.identifier == null)
281        this.identifier = new ArrayList<Identifier>();
282      this.identifier.add(t);
283      return t;
284    }
285
286    // syntactic sugar
287    public DeviceUseStatement addIdentifier(Identifier t) { //3
288      if (t == null)
289        return this;
290      if (this.identifier == null)
291        this.identifier = new ArrayList<Identifier>();
292      this.identifier.add(t);
293      return this;
294    }
295
296    /**
297     * @return {@link #indication} (Reason or justification for the use of the device.)
298     */
299    public List<CodeableConcept> getIndication() { 
300      if (this.indication == null)
301        this.indication = new ArrayList<CodeableConcept>();
302      return this.indication;
303    }
304
305    public boolean hasIndication() { 
306      if (this.indication == null)
307        return false;
308      for (CodeableConcept item : this.indication)
309        if (!item.isEmpty())
310          return true;
311      return false;
312    }
313
314    /**
315     * @return {@link #indication} (Reason or justification for the use of the device.)
316     */
317    // syntactic sugar
318    public CodeableConcept addIndication() { //3
319      CodeableConcept t = new CodeableConcept();
320      if (this.indication == null)
321        this.indication = new ArrayList<CodeableConcept>();
322      this.indication.add(t);
323      return t;
324    }
325
326    // syntactic sugar
327    public DeviceUseStatement addIndication(CodeableConcept t) { //3
328      if (t == null)
329        return this;
330      if (this.indication == null)
331        this.indication = new ArrayList<CodeableConcept>();
332      this.indication.add(t);
333      return this;
334    }
335
336    /**
337     * @return {@link #notes} (Details about the device statement that were not represented at all or sufficiently in one of the attributes provided in a class. These may include for example a comment, an instruction, or a note associated with the statement.)
338     */
339    public List<StringType> getNotes() { 
340      if (this.notes == null)
341        this.notes = new ArrayList<StringType>();
342      return this.notes;
343    }
344
345    public boolean hasNotes() { 
346      if (this.notes == null)
347        return false;
348      for (StringType item : this.notes)
349        if (!item.isEmpty())
350          return true;
351      return false;
352    }
353
354    /**
355     * @return {@link #notes} (Details about the device statement that were not represented at all or sufficiently in one of the attributes provided in a class. These may include for example a comment, an instruction, or a note associated with the statement.)
356     */
357    // syntactic sugar
358    public StringType addNotesElement() {//2 
359      StringType t = new StringType();
360      if (this.notes == null)
361        this.notes = new ArrayList<StringType>();
362      this.notes.add(t);
363      return t;
364    }
365
366    /**
367     * @param value {@link #notes} (Details about the device statement that were not represented at all or sufficiently in one of the attributes provided in a class. These may include for example a comment, an instruction, or a note associated with the statement.)
368     */
369    public DeviceUseStatement addNotes(String value) { //1
370      StringType t = new StringType();
371      t.setValue(value);
372      if (this.notes == null)
373        this.notes = new ArrayList<StringType>();
374      this.notes.add(t);
375      return this;
376    }
377
378    /**
379     * @param value {@link #notes} (Details about the device statement that were not represented at all or sufficiently in one of the attributes provided in a class. These may include for example a comment, an instruction, or a note associated with the statement.)
380     */
381    public boolean hasNotes(String value) { 
382      if (this.notes == null)
383        return false;
384      for (StringType v : this.notes)
385        if (v.equals(value)) // string
386          return true;
387      return false;
388    }
389
390    /**
391     * @return {@link #recordedOn} (The time at which the statement was made/recorded.). This is the underlying object with id, value and extensions. The accessor "getRecordedOn" gives direct access to the value
392     */
393    public DateTimeType getRecordedOnElement() { 
394      if (this.recordedOn == null)
395        if (Configuration.errorOnAutoCreate())
396          throw new Error("Attempt to auto-create DeviceUseStatement.recordedOn");
397        else if (Configuration.doAutoCreate())
398          this.recordedOn = new DateTimeType(); // bb
399      return this.recordedOn;
400    }
401
402    public boolean hasRecordedOnElement() { 
403      return this.recordedOn != null && !this.recordedOn.isEmpty();
404    }
405
406    public boolean hasRecordedOn() { 
407      return this.recordedOn != null && !this.recordedOn.isEmpty();
408    }
409
410    /**
411     * @param value {@link #recordedOn} (The time at which the statement was made/recorded.). This is the underlying object with id, value and extensions. The accessor "getRecordedOn" gives direct access to the value
412     */
413    public DeviceUseStatement setRecordedOnElement(DateTimeType value) { 
414      this.recordedOn = value;
415      return this;
416    }
417
418    /**
419     * @return The time at which the statement was made/recorded.
420     */
421    public Date getRecordedOn() { 
422      return this.recordedOn == null ? null : this.recordedOn.getValue();
423    }
424
425    /**
426     * @param value The time at which the statement was made/recorded.
427     */
428    public DeviceUseStatement setRecordedOn(Date value) { 
429      if (value == null)
430        this.recordedOn = null;
431      else {
432        if (this.recordedOn == null)
433          this.recordedOn = new DateTimeType();
434        this.recordedOn.setValue(value);
435      }
436      return this;
437    }
438
439    /**
440     * @return {@link #subject} (The patient who used the device.)
441     */
442    public Reference getSubject() { 
443      if (this.subject == null)
444        if (Configuration.errorOnAutoCreate())
445          throw new Error("Attempt to auto-create DeviceUseStatement.subject");
446        else if (Configuration.doAutoCreate())
447          this.subject = new Reference(); // cc
448      return this.subject;
449    }
450
451    public boolean hasSubject() { 
452      return this.subject != null && !this.subject.isEmpty();
453    }
454
455    /**
456     * @param value {@link #subject} (The patient who used the device.)
457     */
458    public DeviceUseStatement setSubject(Reference value) { 
459      this.subject = value;
460      return this;
461    }
462
463    /**
464     * @return {@link #subject} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The patient who used the device.)
465     */
466    public Patient getSubjectTarget() { 
467      if (this.subjectTarget == null)
468        if (Configuration.errorOnAutoCreate())
469          throw new Error("Attempt to auto-create DeviceUseStatement.subject");
470        else if (Configuration.doAutoCreate())
471          this.subjectTarget = new Patient(); // aa
472      return this.subjectTarget;
473    }
474
475    /**
476     * @param value {@link #subject} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The patient who used the device.)
477     */
478    public DeviceUseStatement setSubjectTarget(Patient value) { 
479      this.subjectTarget = value;
480      return this;
481    }
482
483    /**
484     * @return {@link #timing} (How often the device was used.)
485     */
486    public Type getTiming() { 
487      return this.timing;
488    }
489
490    /**
491     * @return {@link #timing} (How often the device was used.)
492     */
493    public Timing getTimingTiming() throws FHIRException { 
494      if (!(this.timing instanceof Timing))
495        throw new FHIRException("Type mismatch: the type Timing was expected, but "+this.timing.getClass().getName()+" was encountered");
496      return (Timing) this.timing;
497    }
498
499    public boolean hasTimingTiming() { 
500      return this.timing instanceof Timing;
501    }
502
503    /**
504     * @return {@link #timing} (How often the device was used.)
505     */
506    public Period getTimingPeriod() throws FHIRException { 
507      if (!(this.timing instanceof Period))
508        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.timing.getClass().getName()+" was encountered");
509      return (Period) this.timing;
510    }
511
512    public boolean hasTimingPeriod() { 
513      return this.timing instanceof Period;
514    }
515
516    /**
517     * @return {@link #timing} (How often the device was used.)
518     */
519    public DateTimeType getTimingDateTimeType() throws FHIRException { 
520      if (!(this.timing instanceof DateTimeType))
521        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.timing.getClass().getName()+" was encountered");
522      return (DateTimeType) this.timing;
523    }
524
525    public boolean hasTimingDateTimeType() { 
526      return this.timing instanceof DateTimeType;
527    }
528
529    public boolean hasTiming() { 
530      return this.timing != null && !this.timing.isEmpty();
531    }
532
533    /**
534     * @param value {@link #timing} (How often the device was used.)
535     */
536    public DeviceUseStatement setTiming(Type value) { 
537      this.timing = value;
538      return this;
539    }
540
541      protected void listChildren(List<Property> childrenList) {
542        super.listChildren(childrenList);
543        childrenList.add(new Property("bodySite[x]", "CodeableConcept|Reference(BodySite)", "Indicates the site on the subject's body where the device was used ( i.e. the target site).", 0, java.lang.Integer.MAX_VALUE, bodySite));
544        childrenList.add(new Property("whenUsed", "Period", "The time period over which the device was used.", 0, java.lang.Integer.MAX_VALUE, whenUsed));
545        childrenList.add(new Property("device", "Reference(Device)", "The details of the device used.", 0, java.lang.Integer.MAX_VALUE, device));
546        childrenList.add(new Property("identifier", "Identifier", "An external identifier for this statement such as an IRI.", 0, java.lang.Integer.MAX_VALUE, identifier));
547        childrenList.add(new Property("indication", "CodeableConcept", "Reason or justification for the use of the device.", 0, java.lang.Integer.MAX_VALUE, indication));
548        childrenList.add(new Property("notes", "string", "Details about the device statement that were not represented at all or sufficiently in one of the attributes provided in a class. These may include for example a comment, an instruction, or a note associated with the statement.", 0, java.lang.Integer.MAX_VALUE, notes));
549        childrenList.add(new Property("recordedOn", "dateTime", "The time at which the statement was made/recorded.", 0, java.lang.Integer.MAX_VALUE, recordedOn));
550        childrenList.add(new Property("subject", "Reference(Patient)", "The patient who used the device.", 0, java.lang.Integer.MAX_VALUE, subject));
551        childrenList.add(new Property("timing[x]", "Timing|Period|dateTime", "How often the device was used.", 0, java.lang.Integer.MAX_VALUE, timing));
552      }
553
554      @Override
555      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
556        switch (hash) {
557        case 1702620169: /*bodySite*/ return this.bodySite == null ? new Base[0] : new Base[] {this.bodySite}; // Type
558        case 2042879511: /*whenUsed*/ return this.whenUsed == null ? new Base[0] : new Base[] {this.whenUsed}; // Period
559        case -1335157162: /*device*/ return this.device == null ? new Base[0] : new Base[] {this.device}; // Reference
560        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
561        case -597168804: /*indication*/ return this.indication == null ? new Base[0] : this.indication.toArray(new Base[this.indication.size()]); // CodeableConcept
562        case 105008833: /*notes*/ return this.notes == null ? new Base[0] : this.notes.toArray(new Base[this.notes.size()]); // StringType
563        case 735397551: /*recordedOn*/ return this.recordedOn == null ? new Base[0] : new Base[] {this.recordedOn}; // DateTimeType
564        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
565        case -873664438: /*timing*/ return this.timing == null ? new Base[0] : new Base[] {this.timing}; // Type
566        default: return super.getProperty(hash, name, checkValid);
567        }
568
569      }
570
571      @Override
572      public void setProperty(int hash, String name, Base value) throws FHIRException {
573        switch (hash) {
574        case 1702620169: // bodySite
575          this.bodySite = (Type) value; // Type
576          break;
577        case 2042879511: // whenUsed
578          this.whenUsed = castToPeriod(value); // Period
579          break;
580        case -1335157162: // device
581          this.device = castToReference(value); // Reference
582          break;
583        case -1618432855: // identifier
584          this.getIdentifier().add(castToIdentifier(value)); // Identifier
585          break;
586        case -597168804: // indication
587          this.getIndication().add(castToCodeableConcept(value)); // CodeableConcept
588          break;
589        case 105008833: // notes
590          this.getNotes().add(castToString(value)); // StringType
591          break;
592        case 735397551: // recordedOn
593          this.recordedOn = castToDateTime(value); // DateTimeType
594          break;
595        case -1867885268: // subject
596          this.subject = castToReference(value); // Reference
597          break;
598        case -873664438: // timing
599          this.timing = (Type) value; // Type
600          break;
601        default: super.setProperty(hash, name, value);
602        }
603
604      }
605
606      @Override
607      public void setProperty(String name, Base value) throws FHIRException {
608        if (name.equals("bodySite[x]"))
609          this.bodySite = (Type) value; // Type
610        else if (name.equals("whenUsed"))
611          this.whenUsed = castToPeriod(value); // Period
612        else if (name.equals("device"))
613          this.device = castToReference(value); // Reference
614        else if (name.equals("identifier"))
615          this.getIdentifier().add(castToIdentifier(value));
616        else if (name.equals("indication"))
617          this.getIndication().add(castToCodeableConcept(value));
618        else if (name.equals("notes"))
619          this.getNotes().add(castToString(value));
620        else if (name.equals("recordedOn"))
621          this.recordedOn = castToDateTime(value); // DateTimeType
622        else if (name.equals("subject"))
623          this.subject = castToReference(value); // Reference
624        else if (name.equals("timing[x]"))
625          this.timing = (Type) value; // Type
626        else
627          super.setProperty(name, value);
628      }
629
630      @Override
631      public Base makeProperty(int hash, String name) throws FHIRException {
632        switch (hash) {
633        case -806219817:  return getBodySite(); // Type
634        case 2042879511:  return getWhenUsed(); // Period
635        case -1335157162:  return getDevice(); // Reference
636        case -1618432855:  return addIdentifier(); // Identifier
637        case -597168804:  return addIndication(); // CodeableConcept
638        case 105008833: throw new FHIRException("Cannot make property notes as it is not a complex type"); // StringType
639        case 735397551: throw new FHIRException("Cannot make property recordedOn as it is not a complex type"); // DateTimeType
640        case -1867885268:  return getSubject(); // Reference
641        case 164632566:  return getTiming(); // Type
642        default: return super.makeProperty(hash, name);
643        }
644
645      }
646
647      @Override
648      public Base addChild(String name) throws FHIRException {
649        if (name.equals("bodySiteCodeableConcept")) {
650          this.bodySite = new CodeableConcept();
651          return this.bodySite;
652        }
653        else if (name.equals("bodySiteReference")) {
654          this.bodySite = new Reference();
655          return this.bodySite;
656        }
657        else if (name.equals("whenUsed")) {
658          this.whenUsed = new Period();
659          return this.whenUsed;
660        }
661        else if (name.equals("device")) {
662          this.device = new Reference();
663          return this.device;
664        }
665        else if (name.equals("identifier")) {
666          return addIdentifier();
667        }
668        else if (name.equals("indication")) {
669          return addIndication();
670        }
671        else if (name.equals("notes")) {
672          throw new FHIRException("Cannot call addChild on a primitive type DeviceUseStatement.notes");
673        }
674        else if (name.equals("recordedOn")) {
675          throw new FHIRException("Cannot call addChild on a primitive type DeviceUseStatement.recordedOn");
676        }
677        else if (name.equals("subject")) {
678          this.subject = new Reference();
679          return this.subject;
680        }
681        else if (name.equals("timingTiming")) {
682          this.timing = new Timing();
683          return this.timing;
684        }
685        else if (name.equals("timingPeriod")) {
686          this.timing = new Period();
687          return this.timing;
688        }
689        else if (name.equals("timingDateTime")) {
690          this.timing = new DateTimeType();
691          return this.timing;
692        }
693        else
694          return super.addChild(name);
695      }
696
697  public String fhirType() {
698    return "DeviceUseStatement";
699
700  }
701
702      public DeviceUseStatement copy() {
703        DeviceUseStatement dst = new DeviceUseStatement();
704        copyValues(dst);
705        dst.bodySite = bodySite == null ? null : bodySite.copy();
706        dst.whenUsed = whenUsed == null ? null : whenUsed.copy();
707        dst.device = device == null ? null : device.copy();
708        if (identifier != null) {
709          dst.identifier = new ArrayList<Identifier>();
710          for (Identifier i : identifier)
711            dst.identifier.add(i.copy());
712        };
713        if (indication != null) {
714          dst.indication = new ArrayList<CodeableConcept>();
715          for (CodeableConcept i : indication)
716            dst.indication.add(i.copy());
717        };
718        if (notes != null) {
719          dst.notes = new ArrayList<StringType>();
720          for (StringType i : notes)
721            dst.notes.add(i.copy());
722        };
723        dst.recordedOn = recordedOn == null ? null : recordedOn.copy();
724        dst.subject = subject == null ? null : subject.copy();
725        dst.timing = timing == null ? null : timing.copy();
726        return dst;
727      }
728
729      protected DeviceUseStatement typedCopy() {
730        return copy();
731      }
732
733      @Override
734      public boolean equalsDeep(Base other) {
735        if (!super.equalsDeep(other))
736          return false;
737        if (!(other instanceof DeviceUseStatement))
738          return false;
739        DeviceUseStatement o = (DeviceUseStatement) other;
740        return compareDeep(bodySite, o.bodySite, true) && compareDeep(whenUsed, o.whenUsed, true) && compareDeep(device, o.device, true)
741           && compareDeep(identifier, o.identifier, true) && compareDeep(indication, o.indication, true) && compareDeep(notes, o.notes, true)
742           && compareDeep(recordedOn, o.recordedOn, true) && compareDeep(subject, o.subject, true) && compareDeep(timing, o.timing, true)
743          ;
744      }
745
746      @Override
747      public boolean equalsShallow(Base other) {
748        if (!super.equalsShallow(other))
749          return false;
750        if (!(other instanceof DeviceUseStatement))
751          return false;
752        DeviceUseStatement o = (DeviceUseStatement) other;
753        return compareValues(notes, o.notes, true) && compareValues(recordedOn, o.recordedOn, true);
754      }
755
756      public boolean isEmpty() {
757        return super.isEmpty() && (bodySite == null || bodySite.isEmpty()) && (whenUsed == null || whenUsed.isEmpty())
758           && (device == null || device.isEmpty()) && (identifier == null || identifier.isEmpty()) && (indication == null || indication.isEmpty())
759           && (notes == null || notes.isEmpty()) && (recordedOn == null || recordedOn.isEmpty()) && (subject == null || subject.isEmpty())
760           && (timing == null || timing.isEmpty());
761      }
762
763  @Override
764  public ResourceType getResourceType() {
765    return ResourceType.DeviceUseStatement;
766   }
767
768 /**
769   * Search parameter: <b>patient</b>
770   * <p>
771   * Description: <b>Search by subject - a patient</b><br>
772   * Type: <b>reference</b><br>
773   * Path: <b>DeviceUseStatement.subject</b><br>
774   * </p>
775   */
776  @SearchParamDefinition(name="patient", path="DeviceUseStatement.subject", description="Search by subject - a patient", type="reference" )
777  public static final String SP_PATIENT = "patient";
778 /**
779   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
780   * <p>
781   * Description: <b>Search by subject - a patient</b><br>
782   * Type: <b>reference</b><br>
783   * Path: <b>DeviceUseStatement.subject</b><br>
784   * </p>
785   */
786  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
787
788/**
789   * Constant for fluent queries to be used to add include statements. Specifies
790   * the path value of "<b>DeviceUseStatement:patient</b>".
791   */
792  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("DeviceUseStatement:patient").toLocked();
793
794 /**
795   * Search parameter: <b>subject</b>
796   * <p>
797   * Description: <b>Search by subject</b><br>
798   * Type: <b>reference</b><br>
799   * Path: <b>DeviceUseStatement.subject</b><br>
800   * </p>
801   */
802  @SearchParamDefinition(name="subject", path="DeviceUseStatement.subject", description="Search by subject", type="reference" )
803  public static final String SP_SUBJECT = "subject";
804 /**
805   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
806   * <p>
807   * Description: <b>Search by subject</b><br>
808   * Type: <b>reference</b><br>
809   * Path: <b>DeviceUseStatement.subject</b><br>
810   * </p>
811   */
812  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
813
814/**
815   * Constant for fluent queries to be used to add include statements. Specifies
816   * the path value of "<b>DeviceUseStatement:subject</b>".
817   */
818  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("DeviceUseStatement:subject").toLocked();
819
820 /**
821   * Search parameter: <b>device</b>
822   * <p>
823   * Description: <b>Search by device</b><br>
824   * Type: <b>reference</b><br>
825   * Path: <b>DeviceUseStatement.device</b><br>
826   * </p>
827   */
828  @SearchParamDefinition(name="device", path="DeviceUseStatement.device", description="Search by device", type="reference" )
829  public static final String SP_DEVICE = "device";
830 /**
831   * <b>Fluent Client</b> search parameter constant for <b>device</b>
832   * <p>
833   * Description: <b>Search by device</b><br>
834   * Type: <b>reference</b><br>
835   * Path: <b>DeviceUseStatement.device</b><br>
836   * </p>
837   */
838  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam DEVICE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_DEVICE);
839
840/**
841   * Constant for fluent queries to be used to add include statements. Specifies
842   * the path value of "<b>DeviceUseStatement:device</b>".
843   */
844  public static final ca.uhn.fhir.model.api.Include INCLUDE_DEVICE = new ca.uhn.fhir.model.api.Include("DeviceUseStatement:device").toLocked();
845
846
847}