001package org.hl7.fhir.r5.model;
002
003
004/*
005 * #%L
006 * org.hl7.fhir.r5
007 * %%
008 * Copyright (C) 2014 - 2019 Health Level 7
009 * %%
010 * Licensed under the Apache License, Version 2.0 (the \"License\");
011 * you may not use this file except in compliance with the License.
012 * You may obtain a copy of the License at
013 * 
014 *      http://www.apache.org/licenses/LICENSE-2.0
015 * 
016 * Unless required by applicable law or agreed to in writing, software
017 * distributed under the License is distributed on an \"AS IS\" BASIS,
018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
019 * See the License for the specific language governing permissions and
020 * limitations under the License.
021 * #L%
022 */
023
024/*
025  Copyright (c) 2011+, HL7, Inc.
026  All rights reserved.
027  
028  Redistribution and use in source and binary forms, with or without modification, \
029  are permitted provided that the following conditions are met:
030  
031   * Redistributions of source code must retain the above copyright notice, this \
032     list of conditions and the following disclaimer.
033   * Redistributions in binary form must reproduce the above copyright notice, \
034     this list of conditions and the following disclaimer in the documentation \
035     and/or other materials provided with the distribution.
036   * Neither the name of HL7 nor the names of its contributors may be used to 
037     endorse or promote products derived from this software without specific 
038     prior written permission.
039  
040  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \
041  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \
042  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \
043  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \
044  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \
045  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \
046  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \
047  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \
048  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \
049  POSSIBILITY OF SUCH DAMAGE.
050  */
051
052// Generated on Tue, Dec 31, 2019 12:12+1100 for FHIR vcurrent
053
054import java.util.ArrayList;
055import java.util.Date;
056import java.util.List;
057import org.hl7.fhir.utilities.Utilities;
058import org.hl7.fhir.r5.model.Enumerations.*;
059import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
060import org.hl7.fhir.exceptions.FHIRException;
061import org.hl7.fhir.instance.model.api.ICompositeType;
062import ca.uhn.fhir.model.api.annotation.ResourceDef;
063import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
064import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
065import ca.uhn.fhir.model.api.annotation.Child;
066import ca.uhn.fhir.model.api.annotation.ChildOrder;
067import ca.uhn.fhir.model.api.annotation.Description;
068import ca.uhn.fhir.model.api.annotation.Block;
069
070/**
071 * 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.
072 */
073@ResourceDef(name="DeviceUseStatement", profile="http://hl7.org/fhir/StructureDefinition/DeviceUseStatement")
074public class DeviceUseStatement extends DomainResource {
075
076    public enum DeviceUseStatementStatus {
077        /**
078         * The device is still being used.
079         */
080        ACTIVE, 
081        /**
082         * The device is no longer being used.
083         */
084        COMPLETED, 
085        /**
086         * The statement was recorded incorrectly.
087         */
088        ENTEREDINERROR, 
089        /**
090         * The device may be used at some time in the future.
091         */
092        INTENDED, 
093        /**
094         * Actions implied by the statement have been permanently halted, before all of them occurred.
095         */
096        STOPPED, 
097        /**
098         * Actions implied by the statement have been temporarily halted, but are expected to continue later. May also be called \"suspended\".
099         */
100        ONHOLD, 
101        /**
102         * added to help the parsers with the generic types
103         */
104        NULL;
105        public static DeviceUseStatementStatus fromCode(String codeString) throws FHIRException {
106            if (codeString == null || "".equals(codeString))
107                return null;
108        if ("active".equals(codeString))
109          return ACTIVE;
110        if ("completed".equals(codeString))
111          return COMPLETED;
112        if ("entered-in-error".equals(codeString))
113          return ENTEREDINERROR;
114        if ("intended".equals(codeString))
115          return INTENDED;
116        if ("stopped".equals(codeString))
117          return STOPPED;
118        if ("on-hold".equals(codeString))
119          return ONHOLD;
120        if (Configuration.isAcceptInvalidEnums())
121          return null;
122        else
123          throw new FHIRException("Unknown DeviceUseStatementStatus code '"+codeString+"'");
124        }
125        public String toCode() {
126          switch (this) {
127            case ACTIVE: return "active";
128            case COMPLETED: return "completed";
129            case ENTEREDINERROR: return "entered-in-error";
130            case INTENDED: return "intended";
131            case STOPPED: return "stopped";
132            case ONHOLD: return "on-hold";
133            default: return "?";
134          }
135        }
136        public String getSystem() {
137          switch (this) {
138            case ACTIVE: return "http://hl7.org/fhir/device-statement-status";
139            case COMPLETED: return "http://hl7.org/fhir/device-statement-status";
140            case ENTEREDINERROR: return "http://hl7.org/fhir/device-statement-status";
141            case INTENDED: return "http://hl7.org/fhir/device-statement-status";
142            case STOPPED: return "http://hl7.org/fhir/device-statement-status";
143            case ONHOLD: return "http://hl7.org/fhir/device-statement-status";
144            default: return "?";
145          }
146        }
147        public String getDefinition() {
148          switch (this) {
149            case ACTIVE: return "The device is still being used.";
150            case COMPLETED: return "The device is no longer being used.";
151            case ENTEREDINERROR: return "The statement was recorded incorrectly.";
152            case INTENDED: return "The device may be used at some time in the future.";
153            case STOPPED: return "Actions implied by the statement have been permanently halted, before all of them occurred.";
154            case ONHOLD: return "Actions implied by the statement have been temporarily halted, but are expected to continue later. May also be called \"suspended\".";
155            default: return "?";
156          }
157        }
158        public String getDisplay() {
159          switch (this) {
160            case ACTIVE: return "Active";
161            case COMPLETED: return "Completed";
162            case ENTEREDINERROR: return "Entered in Error";
163            case INTENDED: return "Intended";
164            case STOPPED: return "Stopped";
165            case ONHOLD: return "On Hold";
166            default: return "?";
167          }
168        }
169    }
170
171  public static class DeviceUseStatementStatusEnumFactory implements EnumFactory<DeviceUseStatementStatus> {
172    public DeviceUseStatementStatus fromCode(String codeString) throws IllegalArgumentException {
173      if (codeString == null || "".equals(codeString))
174            if (codeString == null || "".equals(codeString))
175                return null;
176        if ("active".equals(codeString))
177          return DeviceUseStatementStatus.ACTIVE;
178        if ("completed".equals(codeString))
179          return DeviceUseStatementStatus.COMPLETED;
180        if ("entered-in-error".equals(codeString))
181          return DeviceUseStatementStatus.ENTEREDINERROR;
182        if ("intended".equals(codeString))
183          return DeviceUseStatementStatus.INTENDED;
184        if ("stopped".equals(codeString))
185          return DeviceUseStatementStatus.STOPPED;
186        if ("on-hold".equals(codeString))
187          return DeviceUseStatementStatus.ONHOLD;
188        throw new IllegalArgumentException("Unknown DeviceUseStatementStatus code '"+codeString+"'");
189        }
190        public Enumeration<DeviceUseStatementStatus> fromType(Base code) throws FHIRException {
191          if (code == null)
192            return null;
193          if (code.isEmpty())
194            return new Enumeration<DeviceUseStatementStatus>(this);
195          String codeString = ((PrimitiveType) code).asStringValue();
196          if (codeString == null || "".equals(codeString))
197            return null;
198        if ("active".equals(codeString))
199          return new Enumeration<DeviceUseStatementStatus>(this, DeviceUseStatementStatus.ACTIVE);
200        if ("completed".equals(codeString))
201          return new Enumeration<DeviceUseStatementStatus>(this, DeviceUseStatementStatus.COMPLETED);
202        if ("entered-in-error".equals(codeString))
203          return new Enumeration<DeviceUseStatementStatus>(this, DeviceUseStatementStatus.ENTEREDINERROR);
204        if ("intended".equals(codeString))
205          return new Enumeration<DeviceUseStatementStatus>(this, DeviceUseStatementStatus.INTENDED);
206        if ("stopped".equals(codeString))
207          return new Enumeration<DeviceUseStatementStatus>(this, DeviceUseStatementStatus.STOPPED);
208        if ("on-hold".equals(codeString))
209          return new Enumeration<DeviceUseStatementStatus>(this, DeviceUseStatementStatus.ONHOLD);
210        throw new FHIRException("Unknown DeviceUseStatementStatus code '"+codeString+"'");
211        }
212    public String toCode(DeviceUseStatementStatus code) {
213      if (code == DeviceUseStatementStatus.ACTIVE)
214        return "active";
215      if (code == DeviceUseStatementStatus.COMPLETED)
216        return "completed";
217      if (code == DeviceUseStatementStatus.ENTEREDINERROR)
218        return "entered-in-error";
219      if (code == DeviceUseStatementStatus.INTENDED)
220        return "intended";
221      if (code == DeviceUseStatementStatus.STOPPED)
222        return "stopped";
223      if (code == DeviceUseStatementStatus.ONHOLD)
224        return "on-hold";
225      return "?";
226      }
227    public String toSystem(DeviceUseStatementStatus code) {
228      return code.getSystem();
229      }
230    }
231
232    /**
233     * An external identifier for this statement such as an IRI.
234     */
235    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
236    @Description(shortDefinition="External identifier for this record", formalDefinition="An external identifier for this statement such as an IRI." )
237    protected List<Identifier> identifier;
238
239    /**
240     * A plan, proposal or order that is fulfilled in whole or in part by this DeviceUseStatement.
241     */
242    @Child(name = "basedOn", type = {ServiceRequest.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
243    @Description(shortDefinition="Fulfills plan, proposal or order", formalDefinition="A plan, proposal or order that is fulfilled in whole or in part by this DeviceUseStatement." )
244    protected List<Reference> basedOn;
245
246    /**
247     * A code representing the patient or other source's judgment about the state of the device used that this statement is about.  Generally this will be active or completed.
248     */
249    @Child(name = "status", type = {CodeType.class}, order=2, min=1, max=1, modifier=true, summary=true)
250    @Description(shortDefinition="active | completed | entered-in-error +", formalDefinition="A code representing the patient or other source's judgment about the state of the device used that this statement is about.  Generally this will be active or completed." )
251    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/device-statement-status")
252    protected Enumeration<DeviceUseStatementStatus> status;
253
254    /**
255     * The patient who used the device.
256     */
257    @Child(name = "subject", type = {Patient.class, Group.class}, order=3, min=1, max=1, modifier=false, summary=true)
258    @Description(shortDefinition="Patient using device", formalDefinition="The patient who used the device." )
259    protected Reference subject;
260
261    /**
262     * Allows linking the DeviceUseStatement to the underlying Request, or to other information that supports or is used to derive the DeviceUseStatement.
263     */
264    @Child(name = "derivedFrom", type = {ServiceRequest.class, Procedure.class, Claim.class, Observation.class, QuestionnaireResponse.class, DocumentReference.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
265    @Description(shortDefinition="Supporting information", formalDefinition="Allows linking the DeviceUseStatement to the underlying Request, or to other information that supports or is used to derive the DeviceUseStatement." )
266    protected List<Reference> derivedFrom;
267
268    /**
269     * How often the device was used.
270     */
271    @Child(name = "timing", type = {Timing.class, Period.class, DateTimeType.class}, order=5, min=0, max=1, modifier=false, summary=true)
272    @Description(shortDefinition="How often  the device was used", formalDefinition="How often the device was used." )
273    protected DataType timing;
274
275    /**
276     * The time at which the statement was made/recorded.
277     */
278    @Child(name = "recordedOn", type = {DateTimeType.class}, order=6, min=0, max=1, modifier=false, summary=true)
279    @Description(shortDefinition="When statement was recorded", formalDefinition="The time at which the statement was made/recorded." )
280    protected DateTimeType recordedOn;
281
282    /**
283     * Who reported the device was being used by the patient.
284     */
285    @Child(name = "source", type = {Patient.class, Practitioner.class, PractitionerRole.class, RelatedPerson.class}, order=7, min=0, max=1, modifier=false, summary=true)
286    @Description(shortDefinition="Who made the statement", formalDefinition="Who reported the device was being used by the patient." )
287    protected Reference source;
288
289    /**
290     * The details of the device used.
291     */
292    @Child(name = "device", type = {Device.class}, order=8, min=1, max=1, modifier=false, summary=true)
293    @Description(shortDefinition="Reference to device used", formalDefinition="The details of the device used." )
294    protected Reference device;
295
296    /**
297     * Reason or justification for the use of the device. A coded concept, or another resource whose existence justifies this DeviceUseStatement.
298     */
299    @Child(name = "reason", type = {CodeableReference.class}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
300    @Description(shortDefinition="Why device was used", formalDefinition="Reason or justification for the use of the device. A coded concept, or another resource whose existence justifies this DeviceUseStatement." )
301    protected List<CodeableReference> reason;
302
303    /**
304     * Indicates the anotomic location on the subject's body where the device was used ( i.e. the target).
305     */
306    @Child(name = "bodySite", type = {CodeableConcept.class}, order=10, min=0, max=1, modifier=false, summary=true)
307    @Description(shortDefinition="Target body site", formalDefinition="Indicates the anotomic location on the subject's body where the device was used ( i.e. the target)." )
308    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/body-site")
309    protected CodeableConcept bodySite;
310
311    /**
312     * 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.
313     */
314    @Child(name = "note", type = {Annotation.class}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
315    @Description(shortDefinition="Addition details (comments, instructions)", 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." )
316    protected List<Annotation> note;
317
318    private static final long serialVersionUID = 2097046105L;
319
320  /**
321   * Constructor
322   */
323    public DeviceUseStatement() {
324      super();
325    }
326
327  /**
328   * Constructor
329   */
330    public DeviceUseStatement(DeviceUseStatementStatus status, Reference subject, Reference device) {
331      super();
332      this.setStatus(status);
333      this.setSubject(subject);
334      this.setDevice(device);
335    }
336
337    /**
338     * @return {@link #identifier} (An external identifier for this statement such as an IRI.)
339     */
340    public List<Identifier> getIdentifier() { 
341      if (this.identifier == null)
342        this.identifier = new ArrayList<Identifier>();
343      return this.identifier;
344    }
345
346    /**
347     * @return Returns a reference to <code>this</code> for easy method chaining
348     */
349    public DeviceUseStatement setIdentifier(List<Identifier> theIdentifier) { 
350      this.identifier = theIdentifier;
351      return this;
352    }
353
354    public boolean hasIdentifier() { 
355      if (this.identifier == null)
356        return false;
357      for (Identifier item : this.identifier)
358        if (!item.isEmpty())
359          return true;
360      return false;
361    }
362
363    public Identifier addIdentifier() { //3
364      Identifier t = new Identifier();
365      if (this.identifier == null)
366        this.identifier = new ArrayList<Identifier>();
367      this.identifier.add(t);
368      return t;
369    }
370
371    public DeviceUseStatement addIdentifier(Identifier t) { //3
372      if (t == null)
373        return this;
374      if (this.identifier == null)
375        this.identifier = new ArrayList<Identifier>();
376      this.identifier.add(t);
377      return this;
378    }
379
380    /**
381     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist {3}
382     */
383    public Identifier getIdentifierFirstRep() { 
384      if (getIdentifier().isEmpty()) {
385        addIdentifier();
386      }
387      return getIdentifier().get(0);
388    }
389
390    /**
391     * @return {@link #basedOn} (A plan, proposal or order that is fulfilled in whole or in part by this DeviceUseStatement.)
392     */
393    public List<Reference> getBasedOn() { 
394      if (this.basedOn == null)
395        this.basedOn = new ArrayList<Reference>();
396      return this.basedOn;
397    }
398
399    /**
400     * @return Returns a reference to <code>this</code> for easy method chaining
401     */
402    public DeviceUseStatement setBasedOn(List<Reference> theBasedOn) { 
403      this.basedOn = theBasedOn;
404      return this;
405    }
406
407    public boolean hasBasedOn() { 
408      if (this.basedOn == null)
409        return false;
410      for (Reference item : this.basedOn)
411        if (!item.isEmpty())
412          return true;
413      return false;
414    }
415
416    public Reference addBasedOn() { //3
417      Reference t = new Reference();
418      if (this.basedOn == null)
419        this.basedOn = new ArrayList<Reference>();
420      this.basedOn.add(t);
421      return t;
422    }
423
424    public DeviceUseStatement addBasedOn(Reference t) { //3
425      if (t == null)
426        return this;
427      if (this.basedOn == null)
428        this.basedOn = new ArrayList<Reference>();
429      this.basedOn.add(t);
430      return this;
431    }
432
433    /**
434     * @return The first repetition of repeating field {@link #basedOn}, creating it if it does not already exist {3}
435     */
436    public Reference getBasedOnFirstRep() { 
437      if (getBasedOn().isEmpty()) {
438        addBasedOn();
439      }
440      return getBasedOn().get(0);
441    }
442
443    /**
444     * @return {@link #status} (A code representing the patient or other source's judgment about the state of the device used that this statement is about.  Generally this will be active or completed.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
445     */
446    public Enumeration<DeviceUseStatementStatus> getStatusElement() { 
447      if (this.status == null)
448        if (Configuration.errorOnAutoCreate())
449          throw new Error("Attempt to auto-create DeviceUseStatement.status");
450        else if (Configuration.doAutoCreate())
451          this.status = new Enumeration<DeviceUseStatementStatus>(new DeviceUseStatementStatusEnumFactory()); // bb
452      return this.status;
453    }
454
455    public boolean hasStatusElement() { 
456      return this.status != null && !this.status.isEmpty();
457    }
458
459    public boolean hasStatus() { 
460      return this.status != null && !this.status.isEmpty();
461    }
462
463    /**
464     * @param value {@link #status} (A code representing the patient or other source's judgment about the state of the device used that this statement is about.  Generally this will be active or completed.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
465     */
466    public DeviceUseStatement setStatusElement(Enumeration<DeviceUseStatementStatus> value) { 
467      this.status = value;
468      return this;
469    }
470
471    /**
472     * @return A code representing the patient or other source's judgment about the state of the device used that this statement is about.  Generally this will be active or completed.
473     */
474    public DeviceUseStatementStatus getStatus() { 
475      return this.status == null ? null : this.status.getValue();
476    }
477
478    /**
479     * @param value A code representing the patient or other source's judgment about the state of the device used that this statement is about.  Generally this will be active or completed.
480     */
481    public DeviceUseStatement setStatus(DeviceUseStatementStatus value) { 
482        if (this.status == null)
483          this.status = new Enumeration<DeviceUseStatementStatus>(new DeviceUseStatementStatusEnumFactory());
484        this.status.setValue(value);
485      return this;
486    }
487
488    /**
489     * @return {@link #subject} (The patient who used the device.)
490     */
491    public Reference getSubject() { 
492      if (this.subject == null)
493        if (Configuration.errorOnAutoCreate())
494          throw new Error("Attempt to auto-create DeviceUseStatement.subject");
495        else if (Configuration.doAutoCreate())
496          this.subject = new Reference(); // cc
497      return this.subject;
498    }
499
500    public boolean hasSubject() { 
501      return this.subject != null && !this.subject.isEmpty();
502    }
503
504    /**
505     * @param value {@link #subject} (The patient who used the device.)
506     */
507    public DeviceUseStatement setSubject(Reference value) { 
508      this.subject = value;
509      return this;
510    }
511
512    /**
513     * @return {@link #derivedFrom} (Allows linking the DeviceUseStatement to the underlying Request, or to other information that supports or is used to derive the DeviceUseStatement.)
514     */
515    public List<Reference> getDerivedFrom() { 
516      if (this.derivedFrom == null)
517        this.derivedFrom = new ArrayList<Reference>();
518      return this.derivedFrom;
519    }
520
521    /**
522     * @return Returns a reference to <code>this</code> for easy method chaining
523     */
524    public DeviceUseStatement setDerivedFrom(List<Reference> theDerivedFrom) { 
525      this.derivedFrom = theDerivedFrom;
526      return this;
527    }
528
529    public boolean hasDerivedFrom() { 
530      if (this.derivedFrom == null)
531        return false;
532      for (Reference item : this.derivedFrom)
533        if (!item.isEmpty())
534          return true;
535      return false;
536    }
537
538    public Reference addDerivedFrom() { //3
539      Reference t = new Reference();
540      if (this.derivedFrom == null)
541        this.derivedFrom = new ArrayList<Reference>();
542      this.derivedFrom.add(t);
543      return t;
544    }
545
546    public DeviceUseStatement addDerivedFrom(Reference t) { //3
547      if (t == null)
548        return this;
549      if (this.derivedFrom == null)
550        this.derivedFrom = new ArrayList<Reference>();
551      this.derivedFrom.add(t);
552      return this;
553    }
554
555    /**
556     * @return The first repetition of repeating field {@link #derivedFrom}, creating it if it does not already exist {3}
557     */
558    public Reference getDerivedFromFirstRep() { 
559      if (getDerivedFrom().isEmpty()) {
560        addDerivedFrom();
561      }
562      return getDerivedFrom().get(0);
563    }
564
565    /**
566     * @return {@link #timing} (How often the device was used.)
567     */
568    public DataType getTiming() { 
569      return this.timing;
570    }
571
572    /**
573     * @return {@link #timing} (How often the device was used.)
574     */
575    public Timing getTimingTiming() throws FHIRException { 
576      if (this.timing == null)
577        this.timing = new Timing();
578      if (!(this.timing instanceof Timing))
579        throw new FHIRException("Type mismatch: the type Timing was expected, but "+this.timing.getClass().getName()+" was encountered");
580      return (Timing) this.timing;
581    }
582
583    public boolean hasTimingTiming() { 
584      return this != null && this.timing instanceof Timing;
585    }
586
587    /**
588     * @return {@link #timing} (How often the device was used.)
589     */
590    public Period getTimingPeriod() throws FHIRException { 
591      if (this.timing == null)
592        this.timing = new Period();
593      if (!(this.timing instanceof Period))
594        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.timing.getClass().getName()+" was encountered");
595      return (Period) this.timing;
596    }
597
598    public boolean hasTimingPeriod() { 
599      return this != null && this.timing instanceof Period;
600    }
601
602    /**
603     * @return {@link #timing} (How often the device was used.)
604     */
605    public DateTimeType getTimingDateTimeType() throws FHIRException { 
606      if (this.timing == null)
607        this.timing = new DateTimeType();
608      if (!(this.timing instanceof DateTimeType))
609        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.timing.getClass().getName()+" was encountered");
610      return (DateTimeType) this.timing;
611    }
612
613    public boolean hasTimingDateTimeType() { 
614      return this != null && this.timing instanceof DateTimeType;
615    }
616
617    public boolean hasTiming() { 
618      return this.timing != null && !this.timing.isEmpty();
619    }
620
621    /**
622     * @param value {@link #timing} (How often the device was used.)
623     */
624    public DeviceUseStatement setTiming(DataType value) { 
625      if (value != null && !(value instanceof Timing || value instanceof Period || value instanceof DateTimeType))
626        throw new Error("Not the right type for DeviceUseStatement.timing[x]: "+value.fhirType());
627      this.timing = value;
628      return this;
629    }
630
631    /**
632     * @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
633     */
634    public DateTimeType getRecordedOnElement() { 
635      if (this.recordedOn == null)
636        if (Configuration.errorOnAutoCreate())
637          throw new Error("Attempt to auto-create DeviceUseStatement.recordedOn");
638        else if (Configuration.doAutoCreate())
639          this.recordedOn = new DateTimeType(); // bb
640      return this.recordedOn;
641    }
642
643    public boolean hasRecordedOnElement() { 
644      return this.recordedOn != null && !this.recordedOn.isEmpty();
645    }
646
647    public boolean hasRecordedOn() { 
648      return this.recordedOn != null && !this.recordedOn.isEmpty();
649    }
650
651    /**
652     * @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
653     */
654    public DeviceUseStatement setRecordedOnElement(DateTimeType value) { 
655      this.recordedOn = value;
656      return this;
657    }
658
659    /**
660     * @return The time at which the statement was made/recorded.
661     */
662    public Date getRecordedOn() { 
663      return this.recordedOn == null ? null : this.recordedOn.getValue();
664    }
665
666    /**
667     * @param value The time at which the statement was made/recorded.
668     */
669    public DeviceUseStatement setRecordedOn(Date value) { 
670      if (value == null)
671        this.recordedOn = null;
672      else {
673        if (this.recordedOn == null)
674          this.recordedOn = new DateTimeType();
675        this.recordedOn.setValue(value);
676      }
677      return this;
678    }
679
680    /**
681     * @return {@link #source} (Who reported the device was being used by the patient.)
682     */
683    public Reference getSource() { 
684      if (this.source == null)
685        if (Configuration.errorOnAutoCreate())
686          throw new Error("Attempt to auto-create DeviceUseStatement.source");
687        else if (Configuration.doAutoCreate())
688          this.source = new Reference(); // cc
689      return this.source;
690    }
691
692    public boolean hasSource() { 
693      return this.source != null && !this.source.isEmpty();
694    }
695
696    /**
697     * @param value {@link #source} (Who reported the device was being used by the patient.)
698     */
699    public DeviceUseStatement setSource(Reference value) { 
700      this.source = value;
701      return this;
702    }
703
704    /**
705     * @return {@link #device} (The details of the device used.)
706     */
707    public Reference getDevice() { 
708      if (this.device == null)
709        if (Configuration.errorOnAutoCreate())
710          throw new Error("Attempt to auto-create DeviceUseStatement.device");
711        else if (Configuration.doAutoCreate())
712          this.device = new Reference(); // cc
713      return this.device;
714    }
715
716    public boolean hasDevice() { 
717      return this.device != null && !this.device.isEmpty();
718    }
719
720    /**
721     * @param value {@link #device} (The details of the device used.)
722     */
723    public DeviceUseStatement setDevice(Reference value) { 
724      this.device = value;
725      return this;
726    }
727
728    /**
729     * @return {@link #reason} (Reason or justification for the use of the device. A coded concept, or another resource whose existence justifies this DeviceUseStatement.)
730     */
731    public List<CodeableReference> getReason() { 
732      if (this.reason == null)
733        this.reason = new ArrayList<CodeableReference>();
734      return this.reason;
735    }
736
737    /**
738     * @return Returns a reference to <code>this</code> for easy method chaining
739     */
740    public DeviceUseStatement setReason(List<CodeableReference> theReason) { 
741      this.reason = theReason;
742      return this;
743    }
744
745    public boolean hasReason() { 
746      if (this.reason == null)
747        return false;
748      for (CodeableReference item : this.reason)
749        if (!item.isEmpty())
750          return true;
751      return false;
752    }
753
754    public CodeableReference addReason() { //3
755      CodeableReference t = new CodeableReference();
756      if (this.reason == null)
757        this.reason = new ArrayList<CodeableReference>();
758      this.reason.add(t);
759      return t;
760    }
761
762    public DeviceUseStatement addReason(CodeableReference t) { //3
763      if (t == null)
764        return this;
765      if (this.reason == null)
766        this.reason = new ArrayList<CodeableReference>();
767      this.reason.add(t);
768      return this;
769    }
770
771    /**
772     * @return The first repetition of repeating field {@link #reason}, creating it if it does not already exist {3}
773     */
774    public CodeableReference getReasonFirstRep() { 
775      if (getReason().isEmpty()) {
776        addReason();
777      }
778      return getReason().get(0);
779    }
780
781    /**
782     * @return {@link #bodySite} (Indicates the anotomic location on the subject's body where the device was used ( i.e. the target).)
783     */
784    public CodeableConcept getBodySite() { 
785      if (this.bodySite == null)
786        if (Configuration.errorOnAutoCreate())
787          throw new Error("Attempt to auto-create DeviceUseStatement.bodySite");
788        else if (Configuration.doAutoCreate())
789          this.bodySite = new CodeableConcept(); // cc
790      return this.bodySite;
791    }
792
793    public boolean hasBodySite() { 
794      return this.bodySite != null && !this.bodySite.isEmpty();
795    }
796
797    /**
798     * @param value {@link #bodySite} (Indicates the anotomic location on the subject's body where the device was used ( i.e. the target).)
799     */
800    public DeviceUseStatement setBodySite(CodeableConcept value) { 
801      this.bodySite = value;
802      return this;
803    }
804
805    /**
806     * @return {@link #note} (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.)
807     */
808    public List<Annotation> getNote() { 
809      if (this.note == null)
810        this.note = new ArrayList<Annotation>();
811      return this.note;
812    }
813
814    /**
815     * @return Returns a reference to <code>this</code> for easy method chaining
816     */
817    public DeviceUseStatement setNote(List<Annotation> theNote) { 
818      this.note = theNote;
819      return this;
820    }
821
822    public boolean hasNote() { 
823      if (this.note == null)
824        return false;
825      for (Annotation item : this.note)
826        if (!item.isEmpty())
827          return true;
828      return false;
829    }
830
831    public Annotation addNote() { //3
832      Annotation t = new Annotation();
833      if (this.note == null)
834        this.note = new ArrayList<Annotation>();
835      this.note.add(t);
836      return t;
837    }
838
839    public DeviceUseStatement addNote(Annotation t) { //3
840      if (t == null)
841        return this;
842      if (this.note == null)
843        this.note = new ArrayList<Annotation>();
844      this.note.add(t);
845      return this;
846    }
847
848    /**
849     * @return The first repetition of repeating field {@link #note}, creating it if it does not already exist {3}
850     */
851    public Annotation getNoteFirstRep() { 
852      if (getNote().isEmpty()) {
853        addNote();
854      }
855      return getNote().get(0);
856    }
857
858      protected void listChildren(List<Property> children) {
859        super.listChildren(children);
860        children.add(new Property("identifier", "Identifier", "An external identifier for this statement such as an IRI.", 0, java.lang.Integer.MAX_VALUE, identifier));
861        children.add(new Property("basedOn", "Reference(ServiceRequest)", "A plan, proposal or order that is fulfilled in whole or in part by this DeviceUseStatement.", 0, java.lang.Integer.MAX_VALUE, basedOn));
862        children.add(new Property("status", "code", "A code representing the patient or other source's judgment about the state of the device used that this statement is about.  Generally this will be active or completed.", 0, 1, status));
863        children.add(new Property("subject", "Reference(Patient|Group)", "The patient who used the device.", 0, 1, subject));
864        children.add(new Property("derivedFrom", "Reference(ServiceRequest|Procedure|Claim|Observation|QuestionnaireResponse|DocumentReference)", "Allows linking the DeviceUseStatement to the underlying Request, or to other information that supports or is used to derive the DeviceUseStatement.", 0, java.lang.Integer.MAX_VALUE, derivedFrom));
865        children.add(new Property("timing[x]", "Timing|Period|dateTime", "How often the device was used.", 0, 1, timing));
866        children.add(new Property("recordedOn", "dateTime", "The time at which the statement was made/recorded.", 0, 1, recordedOn));
867        children.add(new Property("source", "Reference(Patient|Practitioner|PractitionerRole|RelatedPerson)", "Who reported the device was being used by the patient.", 0, 1, source));
868        children.add(new Property("device", "Reference(Device)", "The details of the device used.", 0, 1, device));
869        children.add(new Property("reason", "CodeableReference(Condition|Observation|DiagnosticReport|DocumentReference)", "Reason or justification for the use of the device. A coded concept, or another resource whose existence justifies this DeviceUseStatement.", 0, java.lang.Integer.MAX_VALUE, reason));
870        children.add(new Property("bodySite", "CodeableConcept", "Indicates the anotomic location on the subject's body where the device was used ( i.e. the target).", 0, 1, bodySite));
871        children.add(new Property("note", "Annotation", "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, note));
872      }
873
874      @Override
875      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
876        switch (_hash) {
877        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "An external identifier for this statement such as an IRI.", 0, java.lang.Integer.MAX_VALUE, identifier);
878        case -332612366: /*basedOn*/  return new Property("basedOn", "Reference(ServiceRequest)", "A plan, proposal or order that is fulfilled in whole or in part by this DeviceUseStatement.", 0, java.lang.Integer.MAX_VALUE, basedOn);
879        case -892481550: /*status*/  return new Property("status", "code", "A code representing the patient or other source's judgment about the state of the device used that this statement is about.  Generally this will be active or completed.", 0, 1, status);
880        case -1867885268: /*subject*/  return new Property("subject", "Reference(Patient|Group)", "The patient who used the device.", 0, 1, subject);
881        case 1077922663: /*derivedFrom*/  return new Property("derivedFrom", "Reference(ServiceRequest|Procedure|Claim|Observation|QuestionnaireResponse|DocumentReference)", "Allows linking the DeviceUseStatement to the underlying Request, or to other information that supports or is used to derive the DeviceUseStatement.", 0, java.lang.Integer.MAX_VALUE, derivedFrom);
882        case 164632566: /*timing[x]*/  return new Property("timing[x]", "Timing|Period|dateTime", "How often the device was used.", 0, 1, timing);
883        case -873664438: /*timing*/  return new Property("timing[x]", "Timing|Period|dateTime", "How often the device was used.", 0, 1, timing);
884        case -497554124: /*timingTiming*/  return new Property("timing[x]", "Timing", "How often the device was used.", 0, 1, timing);
885        case -615615829: /*timingPeriod*/  return new Property("timing[x]", "Period", "How often the device was used.", 0, 1, timing);
886        case -1837458939: /*timingDateTime*/  return new Property("timing[x]", "dateTime", "How often the device was used.", 0, 1, timing);
887        case 735397551: /*recordedOn*/  return new Property("recordedOn", "dateTime", "The time at which the statement was made/recorded.", 0, 1, recordedOn);
888        case -896505829: /*source*/  return new Property("source", "Reference(Patient|Practitioner|PractitionerRole|RelatedPerson)", "Who reported the device was being used by the patient.", 0, 1, source);
889        case -1335157162: /*device*/  return new Property("device", "Reference(Device)", "The details of the device used.", 0, 1, device);
890        case -934964668: /*reason*/  return new Property("reason", "CodeableReference(Condition|Observation|DiagnosticReport|DocumentReference)", "Reason or justification for the use of the device. A coded concept, or another resource whose existence justifies this DeviceUseStatement.", 0, java.lang.Integer.MAX_VALUE, reason);
891        case 1702620169: /*bodySite*/  return new Property("bodySite", "CodeableConcept", "Indicates the anotomic location on the subject's body where the device was used ( i.e. the target).", 0, 1, bodySite);
892        case 3387378: /*note*/  return new Property("note", "Annotation", "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, note);
893        default: return super.getNamedProperty(_hash, _name, _checkValid);
894        }
895
896      }
897
898      @Override
899      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
900        switch (hash) {
901        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
902        case -332612366: /*basedOn*/ return this.basedOn == null ? new Base[0] : this.basedOn.toArray(new Base[this.basedOn.size()]); // Reference
903        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<DeviceUseStatementStatus>
904        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
905        case 1077922663: /*derivedFrom*/ return this.derivedFrom == null ? new Base[0] : this.derivedFrom.toArray(new Base[this.derivedFrom.size()]); // Reference
906        case -873664438: /*timing*/ return this.timing == null ? new Base[0] : new Base[] {this.timing}; // DataType
907        case 735397551: /*recordedOn*/ return this.recordedOn == null ? new Base[0] : new Base[] {this.recordedOn}; // DateTimeType
908        case -896505829: /*source*/ return this.source == null ? new Base[0] : new Base[] {this.source}; // Reference
909        case -1335157162: /*device*/ return this.device == null ? new Base[0] : new Base[] {this.device}; // Reference
910        case -934964668: /*reason*/ return this.reason == null ? new Base[0] : this.reason.toArray(new Base[this.reason.size()]); // CodeableReference
911        case 1702620169: /*bodySite*/ return this.bodySite == null ? new Base[0] : new Base[] {this.bodySite}; // CodeableConcept
912        case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
913        default: return super.getProperty(hash, name, checkValid);
914        }
915
916      }
917
918      @Override
919      public Base setProperty(int hash, String name, Base value) throws FHIRException {
920        switch (hash) {
921        case -1618432855: // identifier
922          this.getIdentifier().add(TypeConvertor.castToIdentifier(value)); // Identifier
923          return value;
924        case -332612366: // basedOn
925          this.getBasedOn().add(TypeConvertor.castToReference(value)); // Reference
926          return value;
927        case -892481550: // status
928          value = new DeviceUseStatementStatusEnumFactory().fromType(TypeConvertor.castToCode(value));
929          this.status = (Enumeration) value; // Enumeration<DeviceUseStatementStatus>
930          return value;
931        case -1867885268: // subject
932          this.subject = TypeConvertor.castToReference(value); // Reference
933          return value;
934        case 1077922663: // derivedFrom
935          this.getDerivedFrom().add(TypeConvertor.castToReference(value)); // Reference
936          return value;
937        case -873664438: // timing
938          this.timing = TypeConvertor.castToType(value); // DataType
939          return value;
940        case 735397551: // recordedOn
941          this.recordedOn = TypeConvertor.castToDateTime(value); // DateTimeType
942          return value;
943        case -896505829: // source
944          this.source = TypeConvertor.castToReference(value); // Reference
945          return value;
946        case -1335157162: // device
947          this.device = TypeConvertor.castToReference(value); // Reference
948          return value;
949        case -934964668: // reason
950          this.getReason().add(TypeConvertor.castToCodeableReference(value)); // CodeableReference
951          return value;
952        case 1702620169: // bodySite
953          this.bodySite = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
954          return value;
955        case 3387378: // note
956          this.getNote().add(TypeConvertor.castToAnnotation(value)); // Annotation
957          return value;
958        default: return super.setProperty(hash, name, value);
959        }
960
961      }
962
963      @Override
964      public Base setProperty(String name, Base value) throws FHIRException {
965        if (name.equals("identifier")) {
966          this.getIdentifier().add(TypeConvertor.castToIdentifier(value));
967        } else if (name.equals("basedOn")) {
968          this.getBasedOn().add(TypeConvertor.castToReference(value));
969        } else if (name.equals("status")) {
970          value = new DeviceUseStatementStatusEnumFactory().fromType(TypeConvertor.castToCode(value));
971          this.status = (Enumeration) value; // Enumeration<DeviceUseStatementStatus>
972        } else if (name.equals("subject")) {
973          this.subject = TypeConvertor.castToReference(value); // Reference
974        } else if (name.equals("derivedFrom")) {
975          this.getDerivedFrom().add(TypeConvertor.castToReference(value));
976        } else if (name.equals("timing[x]")) {
977          this.timing = TypeConvertor.castToType(value); // DataType
978        } else if (name.equals("recordedOn")) {
979          this.recordedOn = TypeConvertor.castToDateTime(value); // DateTimeType
980        } else if (name.equals("source")) {
981          this.source = TypeConvertor.castToReference(value); // Reference
982        } else if (name.equals("device")) {
983          this.device = TypeConvertor.castToReference(value); // Reference
984        } else if (name.equals("reason")) {
985          this.getReason().add(TypeConvertor.castToCodeableReference(value));
986        } else if (name.equals("bodySite")) {
987          this.bodySite = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
988        } else if (name.equals("note")) {
989          this.getNote().add(TypeConvertor.castToAnnotation(value));
990        } else
991          return super.setProperty(name, value);
992        return value;
993      }
994
995      @Override
996      public Base makeProperty(int hash, String name) throws FHIRException {
997        switch (hash) {
998        case -1618432855:  return addIdentifier(); 
999        case -332612366:  return addBasedOn(); 
1000        case -892481550:  return getStatusElement();
1001        case -1867885268:  return getSubject();
1002        case 1077922663:  return addDerivedFrom(); 
1003        case 164632566:  return getTiming();
1004        case -873664438:  return getTiming();
1005        case 735397551:  return getRecordedOnElement();
1006        case -896505829:  return getSource();
1007        case -1335157162:  return getDevice();
1008        case -934964668:  return addReason(); 
1009        case 1702620169:  return getBodySite();
1010        case 3387378:  return addNote(); 
1011        default: return super.makeProperty(hash, name);
1012        }
1013
1014      }
1015
1016      @Override
1017      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1018        switch (hash) {
1019        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
1020        case -332612366: /*basedOn*/ return new String[] {"Reference"};
1021        case -892481550: /*status*/ return new String[] {"code"};
1022        case -1867885268: /*subject*/ return new String[] {"Reference"};
1023        case 1077922663: /*derivedFrom*/ return new String[] {"Reference"};
1024        case -873664438: /*timing*/ return new String[] {"Timing", "Period", "dateTime"};
1025        case 735397551: /*recordedOn*/ return new String[] {"dateTime"};
1026        case -896505829: /*source*/ return new String[] {"Reference"};
1027        case -1335157162: /*device*/ return new String[] {"Reference"};
1028        case -934964668: /*reason*/ return new String[] {"CodeableReference"};
1029        case 1702620169: /*bodySite*/ return new String[] {"CodeableConcept"};
1030        case 3387378: /*note*/ return new String[] {"Annotation"};
1031        default: return super.getTypesForProperty(hash, name);
1032        }
1033
1034      }
1035
1036      @Override
1037      public Base addChild(String name) throws FHIRException {
1038        if (name.equals("identifier")) {
1039          return addIdentifier();
1040        }
1041        else if (name.equals("basedOn")) {
1042          return addBasedOn();
1043        }
1044        else if (name.equals("status")) {
1045          throw new FHIRException("Cannot call addChild on a primitive type DeviceUseStatement.status");
1046        }
1047        else if (name.equals("subject")) {
1048          this.subject = new Reference();
1049          return this.subject;
1050        }
1051        else if (name.equals("derivedFrom")) {
1052          return addDerivedFrom();
1053        }
1054        else if (name.equals("timingTiming")) {
1055          this.timing = new Timing();
1056          return this.timing;
1057        }
1058        else if (name.equals("timingPeriod")) {
1059          this.timing = new Period();
1060          return this.timing;
1061        }
1062        else if (name.equals("timingDateTime")) {
1063          this.timing = new DateTimeType();
1064          return this.timing;
1065        }
1066        else if (name.equals("recordedOn")) {
1067          throw new FHIRException("Cannot call addChild on a primitive type DeviceUseStatement.recordedOn");
1068        }
1069        else if (name.equals("source")) {
1070          this.source = new Reference();
1071          return this.source;
1072        }
1073        else if (name.equals("device")) {
1074          this.device = new Reference();
1075          return this.device;
1076        }
1077        else if (name.equals("reason")) {
1078          return addReason();
1079        }
1080        else if (name.equals("bodySite")) {
1081          this.bodySite = new CodeableConcept();
1082          return this.bodySite;
1083        }
1084        else if (name.equals("note")) {
1085          return addNote();
1086        }
1087        else
1088          return super.addChild(name);
1089      }
1090
1091  public String fhirType() {
1092    return "DeviceUseStatement";
1093
1094  }
1095
1096      public DeviceUseStatement copy() {
1097        DeviceUseStatement dst = new DeviceUseStatement();
1098        copyValues(dst);
1099        return dst;
1100      }
1101
1102      public void copyValues(DeviceUseStatement dst) {
1103        super.copyValues(dst);
1104        if (identifier != null) {
1105          dst.identifier = new ArrayList<Identifier>();
1106          for (Identifier i : identifier)
1107            dst.identifier.add(i.copy());
1108        };
1109        if (basedOn != null) {
1110          dst.basedOn = new ArrayList<Reference>();
1111          for (Reference i : basedOn)
1112            dst.basedOn.add(i.copy());
1113        };
1114        dst.status = status == null ? null : status.copy();
1115        dst.subject = subject == null ? null : subject.copy();
1116        if (derivedFrom != null) {
1117          dst.derivedFrom = new ArrayList<Reference>();
1118          for (Reference i : derivedFrom)
1119            dst.derivedFrom.add(i.copy());
1120        };
1121        dst.timing = timing == null ? null : timing.copy();
1122        dst.recordedOn = recordedOn == null ? null : recordedOn.copy();
1123        dst.source = source == null ? null : source.copy();
1124        dst.device = device == null ? null : device.copy();
1125        if (reason != null) {
1126          dst.reason = new ArrayList<CodeableReference>();
1127          for (CodeableReference i : reason)
1128            dst.reason.add(i.copy());
1129        };
1130        dst.bodySite = bodySite == null ? null : bodySite.copy();
1131        if (note != null) {
1132          dst.note = new ArrayList<Annotation>();
1133          for (Annotation i : note)
1134            dst.note.add(i.copy());
1135        };
1136      }
1137
1138      protected DeviceUseStatement typedCopy() {
1139        return copy();
1140      }
1141
1142      @Override
1143      public boolean equalsDeep(Base other_) {
1144        if (!super.equalsDeep(other_))
1145          return false;
1146        if (!(other_ instanceof DeviceUseStatement))
1147          return false;
1148        DeviceUseStatement o = (DeviceUseStatement) other_;
1149        return compareDeep(identifier, o.identifier, true) && compareDeep(basedOn, o.basedOn, true) && compareDeep(status, o.status, true)
1150           && compareDeep(subject, o.subject, true) && compareDeep(derivedFrom, o.derivedFrom, true) && compareDeep(timing, o.timing, true)
1151           && compareDeep(recordedOn, o.recordedOn, true) && compareDeep(source, o.source, true) && compareDeep(device, o.device, true)
1152           && compareDeep(reason, o.reason, true) && compareDeep(bodySite, o.bodySite, true) && compareDeep(note, o.note, true)
1153          ;
1154      }
1155
1156      @Override
1157      public boolean equalsShallow(Base other_) {
1158        if (!super.equalsShallow(other_))
1159          return false;
1160        if (!(other_ instanceof DeviceUseStatement))
1161          return false;
1162        DeviceUseStatement o = (DeviceUseStatement) other_;
1163        return compareValues(status, o.status, true) && compareValues(recordedOn, o.recordedOn, true);
1164      }
1165
1166      public boolean isEmpty() {
1167        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, basedOn, status
1168          , subject, derivedFrom, timing, recordedOn, source, device, reason, bodySite
1169          , note);
1170      }
1171
1172  @Override
1173  public ResourceType getResourceType() {
1174    return ResourceType.DeviceUseStatement;
1175   }
1176
1177 /**
1178   * Search parameter: <b>device</b>
1179   * <p>
1180   * Description: <b>Search by device</b><br>
1181   * Type: <b>reference</b><br>
1182   * Path: <b>DeviceUseStatement.device</b><br>
1183   * </p>
1184   */
1185  @SearchParamDefinition(name="device", path="DeviceUseStatement.device", description="Search by device", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Base FHIR compartment definition for Device") }, target={Device.class } )
1186  public static final String SP_DEVICE = "device";
1187 /**
1188   * <b>Fluent Client</b> search parameter constant for <b>device</b>
1189   * <p>
1190   * Description: <b>Search by device</b><br>
1191   * Type: <b>reference</b><br>
1192   * Path: <b>DeviceUseStatement.device</b><br>
1193   * </p>
1194   */
1195  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam DEVICE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_DEVICE);
1196
1197/**
1198   * Constant for fluent queries to be used to add include statements. Specifies
1199   * the path value of "<b>DeviceUseStatement:device</b>".
1200   */
1201  public static final ca.uhn.fhir.model.api.Include INCLUDE_DEVICE = new ca.uhn.fhir.model.api.Include("DeviceUseStatement:device").toLocked();
1202
1203 /**
1204   * Search parameter: <b>identifier</b>
1205   * <p>
1206   * Description: <b>Search by identifier</b><br>
1207   * Type: <b>token</b><br>
1208   * Path: <b>DeviceUseStatement.identifier</b><br>
1209   * </p>
1210   */
1211  @SearchParamDefinition(name="identifier", path="DeviceUseStatement.identifier", description="Search by identifier", type="token" )
1212  public static final String SP_IDENTIFIER = "identifier";
1213 /**
1214   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
1215   * <p>
1216   * Description: <b>Search by identifier</b><br>
1217   * Type: <b>token</b><br>
1218   * Path: <b>DeviceUseStatement.identifier</b><br>
1219   * </p>
1220   */
1221  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
1222
1223 /**
1224   * Search parameter: <b>subject</b>
1225   * <p>
1226   * Description: <b>Search by subject</b><br>
1227   * Type: <b>reference</b><br>
1228   * Path: <b>DeviceUseStatement.subject</b><br>
1229   * </p>
1230   */
1231  @SearchParamDefinition(name="subject", path="DeviceUseStatement.subject", description="Search by subject", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Base FHIR compartment definition for Patient") }, target={Group.class, Patient.class } )
1232  public static final String SP_SUBJECT = "subject";
1233 /**
1234   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
1235   * <p>
1236   * Description: <b>Search by subject</b><br>
1237   * Type: <b>reference</b><br>
1238   * Path: <b>DeviceUseStatement.subject</b><br>
1239   * </p>
1240   */
1241  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
1242
1243/**
1244   * Constant for fluent queries to be used to add include statements. Specifies
1245   * the path value of "<b>DeviceUseStatement:subject</b>".
1246   */
1247  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("DeviceUseStatement:subject").toLocked();
1248
1249 /**
1250   * Search parameter: <b>patient</b>
1251   * <p>
1252   * Description: <b>Multiple Resources: 
1253
1254* [AllergyIntolerance](allergyintolerance.html): Who the sensitivity is for
1255* [CarePlan](careplan.html): Who the care plan is for
1256* [CareTeam](careteam.html): Who care team is for
1257* [ClinicalImpression](clinicalimpression.html): Patient or group assessed
1258* [Composition](composition.html): Who and/or what the composition is about
1259* [Condition](condition.html): Who has the condition?
1260* [Consent](consent.html): Who the consent applies to
1261* [DetectedIssue](detectedissue.html): Associated patient
1262* [DeviceRequest](devicerequest.html): Individual the service is ordered for
1263* [DeviceUseStatement](deviceusestatement.html): Search by subject - a patient
1264* [DiagnosticReport](diagnosticreport.html): The subject of the report if a patient
1265* [DocumentManifest](documentmanifest.html): The subject of the set of documents
1266* [DocumentReference](documentreference.html): Who/what is the subject of the document
1267* [Encounter](encounter.html): The patient or group present at the encounter
1268* [EpisodeOfCare](episodeofcare.html): The patient who is the focus of this episode of care
1269* [FamilyMemberHistory](familymemberhistory.html): The identity of a subject to list family member history items for
1270* [Flag](flag.html): The identity of a subject to list flags for
1271* [Goal](goal.html): Who this goal is intended for
1272* [ImagingStudy](imagingstudy.html): Who the study is about
1273* [Immunization](immunization.html): The patient for the vaccination record
1274* [List](list.html): If all resources have the same subject
1275* [MedicationAdministration](medicationadministration.html): The identity of a patient to list administrations  for
1276* [MedicationDispense](medicationdispense.html): The identity of a patient to list dispenses  for
1277* [MedicationRequest](medicationrequest.html): Returns prescriptions for a specific patient
1278* [MedicationUsage](medicationusage.html): Returns statements for a specific patient.
1279* [NutritionOrder](nutritionorder.html): The identity of the person who requires the diet, formula or nutritional supplement
1280* [Observation](observation.html): The subject that the observation is about (if patient)
1281* [Procedure](procedure.html): Search by subject - a patient
1282* [RiskAssessment](riskassessment.html): Who/what does assessment apply to?
1283* [ServiceRequest](servicerequest.html): Search by subject - a patient
1284* [SupplyDelivery](supplydelivery.html): Patient for whom the item is supplied
1285* [VisionPrescription](visionprescription.html): The identity of a patient to list dispenses for
1286</b><br>
1287   * Type: <b>reference</b><br>
1288   * Path: <b>AllergyIntolerance.patient | CarePlan.subject.where(resolve() is Patient) | CareTeam.subject.where(resolve() is Patient) | ClinicalImpression.subject.where(resolve() is Patient) | Composition.subject.where(resolve() is Patient) | Condition.subject.where(resolve() is Patient) | Consent.patient | DetectedIssue.patient | DeviceRequest.subject.where(resolve() is Patient) | DeviceUseStatement.subject | DiagnosticReport.subject.where(resolve() is Patient) | DocumentManifest.subject.where(resolve() is Patient) | DocumentReference.subject.where(resolve() is Patient) | Encounter.subject.where(resolve() is Patient) | EpisodeOfCare.patient | FamilyMemberHistory.patient | Flag.subject.where(resolve() is Patient) | Goal.subject.where(resolve() is Patient) | ImagingStudy.subject.where(resolve() is Patient) | Immunization.patient | List.subject.where(resolve() is Patient) | MedicationAdministration.subject.where(resolve() is Patient) | MedicationDispense.subject.where(resolve() is Patient) | MedicationRequest.subject.where(resolve() is Patient) | MedicationUsage.subject.where(resolve() is Patient) | NutritionOrder.patient | Observation.subject.where(resolve() is Patient) | Procedure.subject.where(resolve() is Patient) | RiskAssessment.subject.where(resolve() is Patient) | ServiceRequest.subject.where(resolve() is Patient) | SupplyDelivery.patient | VisionPrescription.patient</b><br>
1289   * </p>
1290   */
1291  @SearchParamDefinition(name="patient", path="AllergyIntolerance.patient | CarePlan.subject.where(resolve() is Patient) | CareTeam.subject.where(resolve() is Patient) | ClinicalImpression.subject.where(resolve() is Patient) | Composition.subject.where(resolve() is Patient) | Condition.subject.where(resolve() is Patient) | Consent.patient | DetectedIssue.patient | DeviceRequest.subject.where(resolve() is Patient) | DeviceUseStatement.subject | DiagnosticReport.subject.where(resolve() is Patient) | DocumentManifest.subject.where(resolve() is Patient) | DocumentReference.subject.where(resolve() is Patient) | Encounter.subject.where(resolve() is Patient) | EpisodeOfCare.patient | FamilyMemberHistory.patient | Flag.subject.where(resolve() is Patient) | Goal.subject.where(resolve() is Patient) | ImagingStudy.subject.where(resolve() is Patient) | Immunization.patient | List.subject.where(resolve() is Patient) | MedicationAdministration.subject.where(resolve() is Patient) | MedicationDispense.subject.where(resolve() is Patient) | MedicationRequest.subject.where(resolve() is Patient) | MedicationUsage.subject.where(resolve() is Patient) | NutritionOrder.patient | Observation.subject.where(resolve() is Patient) | Procedure.subject.where(resolve() is Patient) | RiskAssessment.subject.where(resolve() is Patient) | ServiceRequest.subject.where(resolve() is Patient) | SupplyDelivery.patient | VisionPrescription.patient", description="Multiple Resources: \r\n\r\n* [AllergyIntolerance](allergyintolerance.html): Who the sensitivity is for\r\n* [CarePlan](careplan.html): Who the care plan is for\r\n* [CareTeam](careteam.html): Who care team is for\r\n* [ClinicalImpression](clinicalimpression.html): Patient or group assessed\r\n* [Composition](composition.html): Who and/or what the composition is about\r\n* [Condition](condition.html): Who has the condition?\r\n* [Consent](consent.html): Who the consent applies to\r\n* [DetectedIssue](detectedissue.html): Associated patient\r\n* [DeviceRequest](devicerequest.html): Individual the service is ordered for\r\n* [DeviceUseStatement](deviceusestatement.html): Search by subject - a patient\r\n* [DiagnosticReport](diagnosticreport.html): The subject of the report if a patient\r\n* [DocumentManifest](documentmanifest.html): The subject of the set of documents\r\n* [DocumentReference](documentreference.html): Who/what is the subject of the document\r\n* [Encounter](encounter.html): The patient or group present at the encounter\r\n* [EpisodeOfCare](episodeofcare.html): The patient who is the focus of this episode of care\r\n* [FamilyMemberHistory](familymemberhistory.html): The identity of a subject to list family member history items for\r\n* [Flag](flag.html): The identity of a subject to list flags for\r\n* [Goal](goal.html): Who this goal is intended for\r\n* [ImagingStudy](imagingstudy.html): Who the study is about\r\n* [Immunization](immunization.html): The patient for the vaccination record\r\n* [List](list.html): If all resources have the same subject\r\n* [MedicationAdministration](medicationadministration.html): The identity of a patient to list administrations  for\r\n* [MedicationDispense](medicationdispense.html): The identity of a patient to list dispenses  for\r\n* [MedicationRequest](medicationrequest.html): Returns prescriptions for a specific patient\r\n* [MedicationUsage](medicationusage.html): Returns statements for a specific patient.\r\n* [NutritionOrder](nutritionorder.html): The identity of the person who requires the diet, formula or nutritional supplement\r\n* [Observation](observation.html): The subject that the observation is about (if patient)\r\n* [Procedure](procedure.html): Search by subject - a patient\r\n* [RiskAssessment](riskassessment.html): Who/what does assessment apply to?\r\n* [ServiceRequest](servicerequest.html): Search by subject - a patient\r\n* [SupplyDelivery](supplydelivery.html): Patient for whom the item is supplied\r\n* [VisionPrescription](visionprescription.html): The identity of a patient to list dispenses for\r\n", type="reference", target={Group.class, Patient.class } )
1292  public static final String SP_PATIENT = "patient";
1293 /**
1294   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
1295   * <p>
1296   * Description: <b>Multiple Resources: 
1297
1298* [AllergyIntolerance](allergyintolerance.html): Who the sensitivity is for
1299* [CarePlan](careplan.html): Who the care plan is for
1300* [CareTeam](careteam.html): Who care team is for
1301* [ClinicalImpression](clinicalimpression.html): Patient or group assessed
1302* [Composition](composition.html): Who and/or what the composition is about
1303* [Condition](condition.html): Who has the condition?
1304* [Consent](consent.html): Who the consent applies to
1305* [DetectedIssue](detectedissue.html): Associated patient
1306* [DeviceRequest](devicerequest.html): Individual the service is ordered for
1307* [DeviceUseStatement](deviceusestatement.html): Search by subject - a patient
1308* [DiagnosticReport](diagnosticreport.html): The subject of the report if a patient
1309* [DocumentManifest](documentmanifest.html): The subject of the set of documents
1310* [DocumentReference](documentreference.html): Who/what is the subject of the document
1311* [Encounter](encounter.html): The patient or group present at the encounter
1312* [EpisodeOfCare](episodeofcare.html): The patient who is the focus of this episode of care
1313* [FamilyMemberHistory](familymemberhistory.html): The identity of a subject to list family member history items for
1314* [Flag](flag.html): The identity of a subject to list flags for
1315* [Goal](goal.html): Who this goal is intended for
1316* [ImagingStudy](imagingstudy.html): Who the study is about
1317* [Immunization](immunization.html): The patient for the vaccination record
1318* [List](list.html): If all resources have the same subject
1319* [MedicationAdministration](medicationadministration.html): The identity of a patient to list administrations  for
1320* [MedicationDispense](medicationdispense.html): The identity of a patient to list dispenses  for
1321* [MedicationRequest](medicationrequest.html): Returns prescriptions for a specific patient
1322* [MedicationUsage](medicationusage.html): Returns statements for a specific patient.
1323* [NutritionOrder](nutritionorder.html): The identity of the person who requires the diet, formula or nutritional supplement
1324* [Observation](observation.html): The subject that the observation is about (if patient)
1325* [Procedure](procedure.html): Search by subject - a patient
1326* [RiskAssessment](riskassessment.html): Who/what does assessment apply to?
1327* [ServiceRequest](servicerequest.html): Search by subject - a patient
1328* [SupplyDelivery](supplydelivery.html): Patient for whom the item is supplied
1329* [VisionPrescription](visionprescription.html): The identity of a patient to list dispenses for
1330</b><br>
1331   * Type: <b>reference</b><br>
1332   * Path: <b>AllergyIntolerance.patient | CarePlan.subject.where(resolve() is Patient) | CareTeam.subject.where(resolve() is Patient) | ClinicalImpression.subject.where(resolve() is Patient) | Composition.subject.where(resolve() is Patient) | Condition.subject.where(resolve() is Patient) | Consent.patient | DetectedIssue.patient | DeviceRequest.subject.where(resolve() is Patient) | DeviceUseStatement.subject | DiagnosticReport.subject.where(resolve() is Patient) | DocumentManifest.subject.where(resolve() is Patient) | DocumentReference.subject.where(resolve() is Patient) | Encounter.subject.where(resolve() is Patient) | EpisodeOfCare.patient | FamilyMemberHistory.patient | Flag.subject.where(resolve() is Patient) | Goal.subject.where(resolve() is Patient) | ImagingStudy.subject.where(resolve() is Patient) | Immunization.patient | List.subject.where(resolve() is Patient) | MedicationAdministration.subject.where(resolve() is Patient) | MedicationDispense.subject.where(resolve() is Patient) | MedicationRequest.subject.where(resolve() is Patient) | MedicationUsage.subject.where(resolve() is Patient) | NutritionOrder.patient | Observation.subject.where(resolve() is Patient) | Procedure.subject.where(resolve() is Patient) | RiskAssessment.subject.where(resolve() is Patient) | ServiceRequest.subject.where(resolve() is Patient) | SupplyDelivery.patient | VisionPrescription.patient</b><br>
1333   * </p>
1334   */
1335  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
1336
1337/**
1338   * Constant for fluent queries to be used to add include statements. Specifies
1339   * the path value of "<b>DeviceUseStatement:patient</b>".
1340   */
1341  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("DeviceUseStatement:patient").toLocked();
1342
1343
1344}
1345