001package org.hl7.fhir.dstu2016may.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
033import java.util.ArrayList;
034import java.util.Date;
035import java.util.List;
036
037import org.hl7.fhir.exceptions.FHIRException;
038
039import ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.Description;
041import ca.uhn.fhir.model.api.annotation.ResourceDef;
042import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
043/**
044 * Represents a request for a patient to employ a medical device. The device may be an implantable device, or an external assistive device, such as a walker.
045 */
046@ResourceDef(name="DeviceUseRequest", profile="http://hl7.org/fhir/Profile/DeviceUseRequest")
047public class DeviceUseRequest extends DomainResource {
048
049    public enum DeviceUseRequestStatus {
050        /**
051         * The request has been proposed.
052         */
053        PROPOSED, 
054        /**
055         * The request has been planned.
056         */
057        PLANNED, 
058        /**
059         * The request has been placed.
060         */
061        REQUESTED, 
062        /**
063         * The receiving system has received the request but not yet decided whether it will be performed.
064         */
065        RECEIVED, 
066        /**
067         * The receiving system has accepted the request but work has not yet commenced.
068         */
069        ACCEPTED, 
070        /**
071         * The work to fulfill the order is happening.
072         */
073        INPROGRESS, 
074        /**
075         * The work has been complete, the report(s) released, and no further work is planned.
076         */
077        COMPLETED, 
078        /**
079         * The request has been held by originating system/user request.
080         */
081        SUSPENDED, 
082        /**
083         * The receiving system has declined to fulfill the request.
084         */
085        REJECTED, 
086        /**
087         * The request was attempted, but due to some procedural error, it could not be completed.
088         */
089        ABORTED, 
090        /**
091         * added to help the parsers
092         */
093        NULL;
094        public static DeviceUseRequestStatus fromCode(String codeString) throws FHIRException {
095            if (codeString == null || "".equals(codeString))
096                return null;
097        if ("proposed".equals(codeString))
098          return PROPOSED;
099        if ("planned".equals(codeString))
100          return PLANNED;
101        if ("requested".equals(codeString))
102          return REQUESTED;
103        if ("received".equals(codeString))
104          return RECEIVED;
105        if ("accepted".equals(codeString))
106          return ACCEPTED;
107        if ("in-progress".equals(codeString))
108          return INPROGRESS;
109        if ("completed".equals(codeString))
110          return COMPLETED;
111        if ("suspended".equals(codeString))
112          return SUSPENDED;
113        if ("rejected".equals(codeString))
114          return REJECTED;
115        if ("aborted".equals(codeString))
116          return ABORTED;
117        throw new FHIRException("Unknown DeviceUseRequestStatus code '"+codeString+"'");
118        }
119        public String toCode() {
120          switch (this) {
121            case PROPOSED: return "proposed";
122            case PLANNED: return "planned";
123            case REQUESTED: return "requested";
124            case RECEIVED: return "received";
125            case ACCEPTED: return "accepted";
126            case INPROGRESS: return "in-progress";
127            case COMPLETED: return "completed";
128            case SUSPENDED: return "suspended";
129            case REJECTED: return "rejected";
130            case ABORTED: return "aborted";
131            default: return "?";
132          }
133        }
134        public String getSystem() {
135          switch (this) {
136            case PROPOSED: return "http://hl7.org/fhir/device-use-request-status";
137            case PLANNED: return "http://hl7.org/fhir/device-use-request-status";
138            case REQUESTED: return "http://hl7.org/fhir/device-use-request-status";
139            case RECEIVED: return "http://hl7.org/fhir/device-use-request-status";
140            case ACCEPTED: return "http://hl7.org/fhir/device-use-request-status";
141            case INPROGRESS: return "http://hl7.org/fhir/device-use-request-status";
142            case COMPLETED: return "http://hl7.org/fhir/device-use-request-status";
143            case SUSPENDED: return "http://hl7.org/fhir/device-use-request-status";
144            case REJECTED: return "http://hl7.org/fhir/device-use-request-status";
145            case ABORTED: return "http://hl7.org/fhir/device-use-request-status";
146            default: return "?";
147          }
148        }
149        public String getDefinition() {
150          switch (this) {
151            case PROPOSED: return "The request has been proposed.";
152            case PLANNED: return "The request has been planned.";
153            case REQUESTED: return "The request has been placed.";
154            case RECEIVED: return "The receiving system has received the request but not yet decided whether it will be performed.";
155            case ACCEPTED: return "The receiving system has accepted the request but work has not yet commenced.";
156            case INPROGRESS: return "The work to fulfill the order is happening.";
157            case COMPLETED: return "The work has been complete, the report(s) released, and no further work is planned.";
158            case SUSPENDED: return "The request has been held by originating system/user request.";
159            case REJECTED: return "The receiving system has declined to fulfill the request.";
160            case ABORTED: return "The request was attempted, but due to some procedural error, it could not be completed.";
161            default: return "?";
162          }
163        }
164        public String getDisplay() {
165          switch (this) {
166            case PROPOSED: return "Proposed";
167            case PLANNED: return "Planned";
168            case REQUESTED: return "Requested";
169            case RECEIVED: return "Received";
170            case ACCEPTED: return "Accepted";
171            case INPROGRESS: return "In Progress";
172            case COMPLETED: return "Completed";
173            case SUSPENDED: return "Suspended";
174            case REJECTED: return "Rejected";
175            case ABORTED: return "Aborted";
176            default: return "?";
177          }
178        }
179    }
180
181  public static class DeviceUseRequestStatusEnumFactory implements EnumFactory<DeviceUseRequestStatus> {
182    public DeviceUseRequestStatus fromCode(String codeString) throws IllegalArgumentException {
183      if (codeString == null || "".equals(codeString))
184            if (codeString == null || "".equals(codeString))
185                return null;
186        if ("proposed".equals(codeString))
187          return DeviceUseRequestStatus.PROPOSED;
188        if ("planned".equals(codeString))
189          return DeviceUseRequestStatus.PLANNED;
190        if ("requested".equals(codeString))
191          return DeviceUseRequestStatus.REQUESTED;
192        if ("received".equals(codeString))
193          return DeviceUseRequestStatus.RECEIVED;
194        if ("accepted".equals(codeString))
195          return DeviceUseRequestStatus.ACCEPTED;
196        if ("in-progress".equals(codeString))
197          return DeviceUseRequestStatus.INPROGRESS;
198        if ("completed".equals(codeString))
199          return DeviceUseRequestStatus.COMPLETED;
200        if ("suspended".equals(codeString))
201          return DeviceUseRequestStatus.SUSPENDED;
202        if ("rejected".equals(codeString))
203          return DeviceUseRequestStatus.REJECTED;
204        if ("aborted".equals(codeString))
205          return DeviceUseRequestStatus.ABORTED;
206        throw new IllegalArgumentException("Unknown DeviceUseRequestStatus code '"+codeString+"'");
207        }
208        public Enumeration<DeviceUseRequestStatus> fromType(Base code) throws FHIRException {
209          if (code == null || code.isEmpty())
210            return null;
211          String codeString = ((PrimitiveType) code).asStringValue();
212          if (codeString == null || "".equals(codeString))
213            return null;
214        if ("proposed".equals(codeString))
215          return new Enumeration<DeviceUseRequestStatus>(this, DeviceUseRequestStatus.PROPOSED);
216        if ("planned".equals(codeString))
217          return new Enumeration<DeviceUseRequestStatus>(this, DeviceUseRequestStatus.PLANNED);
218        if ("requested".equals(codeString))
219          return new Enumeration<DeviceUseRequestStatus>(this, DeviceUseRequestStatus.REQUESTED);
220        if ("received".equals(codeString))
221          return new Enumeration<DeviceUseRequestStatus>(this, DeviceUseRequestStatus.RECEIVED);
222        if ("accepted".equals(codeString))
223          return new Enumeration<DeviceUseRequestStatus>(this, DeviceUseRequestStatus.ACCEPTED);
224        if ("in-progress".equals(codeString))
225          return new Enumeration<DeviceUseRequestStatus>(this, DeviceUseRequestStatus.INPROGRESS);
226        if ("completed".equals(codeString))
227          return new Enumeration<DeviceUseRequestStatus>(this, DeviceUseRequestStatus.COMPLETED);
228        if ("suspended".equals(codeString))
229          return new Enumeration<DeviceUseRequestStatus>(this, DeviceUseRequestStatus.SUSPENDED);
230        if ("rejected".equals(codeString))
231          return new Enumeration<DeviceUseRequestStatus>(this, DeviceUseRequestStatus.REJECTED);
232        if ("aborted".equals(codeString))
233          return new Enumeration<DeviceUseRequestStatus>(this, DeviceUseRequestStatus.ABORTED);
234        throw new FHIRException("Unknown DeviceUseRequestStatus code '"+codeString+"'");
235        }
236    public String toCode(DeviceUseRequestStatus code) {
237      if (code == DeviceUseRequestStatus.PROPOSED)
238        return "proposed";
239      if (code == DeviceUseRequestStatus.PLANNED)
240        return "planned";
241      if (code == DeviceUseRequestStatus.REQUESTED)
242        return "requested";
243      if (code == DeviceUseRequestStatus.RECEIVED)
244        return "received";
245      if (code == DeviceUseRequestStatus.ACCEPTED)
246        return "accepted";
247      if (code == DeviceUseRequestStatus.INPROGRESS)
248        return "in-progress";
249      if (code == DeviceUseRequestStatus.COMPLETED)
250        return "completed";
251      if (code == DeviceUseRequestStatus.SUSPENDED)
252        return "suspended";
253      if (code == DeviceUseRequestStatus.REJECTED)
254        return "rejected";
255      if (code == DeviceUseRequestStatus.ABORTED)
256        return "aborted";
257      return "?";
258      }
259    public String toSystem(DeviceUseRequestStatus code) {
260      return code.getSystem();
261      }
262    }
263
264    public enum DeviceUseRequestPriority {
265        /**
266         * The request has a normal priority.
267         */
268        ROUTINE, 
269        /**
270         * The request should be done urgently.
271         */
272        URGENT, 
273        /**
274         * The request is time-critical.
275         */
276        STAT, 
277        /**
278         * The request should be acted on as soon as possible.
279         */
280        ASAP, 
281        /**
282         * added to help the parsers
283         */
284        NULL;
285        public static DeviceUseRequestPriority fromCode(String codeString) throws FHIRException {
286            if (codeString == null || "".equals(codeString))
287                return null;
288        if ("routine".equals(codeString))
289          return ROUTINE;
290        if ("urgent".equals(codeString))
291          return URGENT;
292        if ("stat".equals(codeString))
293          return STAT;
294        if ("asap".equals(codeString))
295          return ASAP;
296        throw new FHIRException("Unknown DeviceUseRequestPriority code '"+codeString+"'");
297        }
298        public String toCode() {
299          switch (this) {
300            case ROUTINE: return "routine";
301            case URGENT: return "urgent";
302            case STAT: return "stat";
303            case ASAP: return "asap";
304            default: return "?";
305          }
306        }
307        public String getSystem() {
308          switch (this) {
309            case ROUTINE: return "http://hl7.org/fhir/device-use-request-priority";
310            case URGENT: return "http://hl7.org/fhir/device-use-request-priority";
311            case STAT: return "http://hl7.org/fhir/device-use-request-priority";
312            case ASAP: return "http://hl7.org/fhir/device-use-request-priority";
313            default: return "?";
314          }
315        }
316        public String getDefinition() {
317          switch (this) {
318            case ROUTINE: return "The request has a normal priority.";
319            case URGENT: return "The request should be done urgently.";
320            case STAT: return "The request is time-critical.";
321            case ASAP: return "The request should be acted on as soon as possible.";
322            default: return "?";
323          }
324        }
325        public String getDisplay() {
326          switch (this) {
327            case ROUTINE: return "Routine";
328            case URGENT: return "Urgent";
329            case STAT: return "Stat";
330            case ASAP: return "ASAP";
331            default: return "?";
332          }
333        }
334    }
335
336  public static class DeviceUseRequestPriorityEnumFactory implements EnumFactory<DeviceUseRequestPriority> {
337    public DeviceUseRequestPriority fromCode(String codeString) throws IllegalArgumentException {
338      if (codeString == null || "".equals(codeString))
339            if (codeString == null || "".equals(codeString))
340                return null;
341        if ("routine".equals(codeString))
342          return DeviceUseRequestPriority.ROUTINE;
343        if ("urgent".equals(codeString))
344          return DeviceUseRequestPriority.URGENT;
345        if ("stat".equals(codeString))
346          return DeviceUseRequestPriority.STAT;
347        if ("asap".equals(codeString))
348          return DeviceUseRequestPriority.ASAP;
349        throw new IllegalArgumentException("Unknown DeviceUseRequestPriority code '"+codeString+"'");
350        }
351        public Enumeration<DeviceUseRequestPriority> fromType(Base code) throws FHIRException {
352          if (code == null || code.isEmpty())
353            return null;
354          String codeString = ((PrimitiveType) code).asStringValue();
355          if (codeString == null || "".equals(codeString))
356            return null;
357        if ("routine".equals(codeString))
358          return new Enumeration<DeviceUseRequestPriority>(this, DeviceUseRequestPriority.ROUTINE);
359        if ("urgent".equals(codeString))
360          return new Enumeration<DeviceUseRequestPriority>(this, DeviceUseRequestPriority.URGENT);
361        if ("stat".equals(codeString))
362          return new Enumeration<DeviceUseRequestPriority>(this, DeviceUseRequestPriority.STAT);
363        if ("asap".equals(codeString))
364          return new Enumeration<DeviceUseRequestPriority>(this, DeviceUseRequestPriority.ASAP);
365        throw new FHIRException("Unknown DeviceUseRequestPriority code '"+codeString+"'");
366        }
367    public String toCode(DeviceUseRequestPriority code) {
368      if (code == DeviceUseRequestPriority.ROUTINE)
369        return "routine";
370      if (code == DeviceUseRequestPriority.URGENT)
371        return "urgent";
372      if (code == DeviceUseRequestPriority.STAT)
373        return "stat";
374      if (code == DeviceUseRequestPriority.ASAP)
375        return "asap";
376      return "?";
377      }
378    public String toSystem(DeviceUseRequestPriority code) {
379      return code.getSystem();
380      }
381    }
382
383    /**
384     * Indicates the site on the subject's body where the device should be used ( i.e. the target site).
385     */
386    @Child(name = "bodySite", type = {CodeableConcept.class, BodySite.class}, order=0, min=0, max=1, modifier=false, summary=true)
387    @Description(shortDefinition="Target body site", formalDefinition="Indicates the site on the subject's body where the device should be used ( i.e. the target site)." )
388    protected Type bodySite;
389
390    /**
391     * The status of the request.
392     */
393    @Child(name = "status", type = {CodeType.class}, order=1, min=0, max=1, modifier=true, summary=true)
394    @Description(shortDefinition="proposed | planned | requested | received | accepted | in-progress | completed | suspended | rejected | aborted", formalDefinition="The status of the request." )
395    protected Enumeration<DeviceUseRequestStatus> status;
396
397    /**
398     * The details of the device  to be used.
399     */
400    @Child(name = "device", type = {Device.class}, order=2, min=1, max=1, modifier=false, summary=true)
401    @Description(shortDefinition="Device requested", formalDefinition="The details of the device  to be used." )
402    protected Reference device;
403
404    /**
405     * The actual object that is the target of the reference (The details of the device  to be used.)
406     */
407    protected Device deviceTarget;
408
409    /**
410     * An encounter that provides additional context in which this request is made.
411     */
412    @Child(name = "encounter", type = {Encounter.class}, order=3, min=0, max=1, modifier=false, summary=true)
413    @Description(shortDefinition="Encounter motivating request", formalDefinition="An encounter that provides additional context in which this request is made." )
414    protected Reference encounter;
415
416    /**
417     * The actual object that is the target of the reference (An encounter that provides additional context in which this request is made.)
418     */
419    protected Encounter encounterTarget;
420
421    /**
422     * Identifiers assigned to this order by the orderer or by the receiver.
423     */
424    @Child(name = "identifier", type = {Identifier.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
425    @Description(shortDefinition="Request identifier", formalDefinition="Identifiers assigned to this order by the orderer or by the receiver." )
426    protected List<Identifier> identifier;
427
428    /**
429     * Reason or justification for the use of this device.
430     */
431    @Child(name = "indication", type = {CodeableConcept.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
432    @Description(shortDefinition="Reason for request", formalDefinition="Reason or justification for the use of this device." )
433    protected List<CodeableConcept> indication;
434
435    /**
436     * Details about this request 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.
437     */
438    @Child(name = "notes", type = {StringType.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
439    @Description(shortDefinition="Notes or comments", formalDefinition="Details about this request 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." )
440    protected List<StringType> notes;
441
442    /**
443     * The proposed act must be performed if the indicated conditions occur, e.g.., shortness of breath, SpO2 less than x%.
444     */
445    @Child(name = "prnReason", type = {CodeableConcept.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
446    @Description(shortDefinition="PRN", formalDefinition="The proposed act must be performed if the indicated conditions occur, e.g.., shortness of breath, SpO2 less than x%." )
447    protected List<CodeableConcept> prnReason;
448
449    /**
450     * The time when the request was made.
451     */
452    @Child(name = "orderedOn", type = {DateTimeType.class}, order=8, min=0, max=1, modifier=false, summary=true)
453    @Description(shortDefinition="When ordered", formalDefinition="The time when the request was made." )
454    protected DateTimeType orderedOn;
455
456    /**
457     * The time at which the request was made/recorded.
458     */
459    @Child(name = "recordedOn", type = {DateTimeType.class}, order=9, min=0, max=1, modifier=false, summary=true)
460    @Description(shortDefinition="When recorded", formalDefinition="The time at which the request was made/recorded." )
461    protected DateTimeType recordedOn;
462
463    /**
464     * The patient who will use the device.
465     */
466    @Child(name = "subject", type = {Patient.class}, order=10, min=1, max=1, modifier=false, summary=true)
467    @Description(shortDefinition="Focus of request", formalDefinition="The patient who will use the device." )
468    protected Reference subject;
469
470    /**
471     * The actual object that is the target of the reference (The patient who will use the device.)
472     */
473    protected Patient subjectTarget;
474
475    /**
476     * The timing schedule for the use of the device The Schedule data type allows many different expressions, for example. "Every 8 hours"; "Three times a day"; "1/2 an hour before breakfast for 10 days from 23-Dec 2011:"; "15 Oct 2013, 17 Oct 2013 and 1 Nov 2013".
477     */
478    @Child(name = "timing", type = {Timing.class, Period.class, DateTimeType.class}, order=11, min=0, max=1, modifier=false, summary=true)
479    @Description(shortDefinition="Schedule for use", formalDefinition="The timing schedule for the use of the device The Schedule data type allows many different expressions, for example. \"Every 8 hours\"; \"Three times a day\"; \"1/2 an hour before breakfast for 10 days from 23-Dec 2011:\"; \"15 Oct 2013, 17 Oct 2013 and 1 Nov 2013\"." )
480    protected Type timing;
481
482    /**
483     * Characterizes how quickly the  use of device must be initiated. Includes concepts such as stat, urgent, routine.
484     */
485    @Child(name = "priority", type = {CodeType.class}, order=12, min=0, max=1, modifier=false, summary=true)
486    @Description(shortDefinition="routine | urgent | stat | asap", formalDefinition="Characterizes how quickly the  use of device must be initiated. Includes concepts such as stat, urgent, routine." )
487    protected Enumeration<DeviceUseRequestPriority> priority;
488
489    private static final long serialVersionUID = 1208477058L;
490
491  /**
492   * Constructor
493   */
494    public DeviceUseRequest() {
495      super();
496    }
497
498  /**
499   * Constructor
500   */
501    public DeviceUseRequest(Reference device, Reference subject) {
502      super();
503      this.device = device;
504      this.subject = subject;
505    }
506
507    /**
508     * @return {@link #bodySite} (Indicates the site on the subject's body where the device should be used ( i.e. the target site).)
509     */
510    public Type getBodySite() { 
511      return this.bodySite;
512    }
513
514    /**
515     * @return {@link #bodySite} (Indicates the site on the subject's body where the device should be used ( i.e. the target site).)
516     */
517    public CodeableConcept getBodySiteCodeableConcept() throws FHIRException { 
518      if (!(this.bodySite instanceof CodeableConcept))
519        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.bodySite.getClass().getName()+" was encountered");
520      return (CodeableConcept) this.bodySite;
521    }
522
523    public boolean hasBodySiteCodeableConcept() { 
524      return this.bodySite instanceof CodeableConcept;
525    }
526
527    /**
528     * @return {@link #bodySite} (Indicates the site on the subject's body where the device should be used ( i.e. the target site).)
529     */
530    public Reference getBodySiteReference() throws FHIRException { 
531      if (!(this.bodySite instanceof Reference))
532        throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.bodySite.getClass().getName()+" was encountered");
533      return (Reference) this.bodySite;
534    }
535
536    public boolean hasBodySiteReference() { 
537      return this.bodySite instanceof Reference;
538    }
539
540    public boolean hasBodySite() { 
541      return this.bodySite != null && !this.bodySite.isEmpty();
542    }
543
544    /**
545     * @param value {@link #bodySite} (Indicates the site on the subject's body where the device should be used ( i.e. the target site).)
546     */
547    public DeviceUseRequest setBodySite(Type value) { 
548      this.bodySite = value;
549      return this;
550    }
551
552    /**
553     * @return {@link #status} (The status of the request.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
554     */
555    public Enumeration<DeviceUseRequestStatus> getStatusElement() { 
556      if (this.status == null)
557        if (Configuration.errorOnAutoCreate())
558          throw new Error("Attempt to auto-create DeviceUseRequest.status");
559        else if (Configuration.doAutoCreate())
560          this.status = new Enumeration<DeviceUseRequestStatus>(new DeviceUseRequestStatusEnumFactory()); // bb
561      return this.status;
562    }
563
564    public boolean hasStatusElement() { 
565      return this.status != null && !this.status.isEmpty();
566    }
567
568    public boolean hasStatus() { 
569      return this.status != null && !this.status.isEmpty();
570    }
571
572    /**
573     * @param value {@link #status} (The status of the request.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
574     */
575    public DeviceUseRequest setStatusElement(Enumeration<DeviceUseRequestStatus> value) { 
576      this.status = value;
577      return this;
578    }
579
580    /**
581     * @return The status of the request.
582     */
583    public DeviceUseRequestStatus getStatus() { 
584      return this.status == null ? null : this.status.getValue();
585    }
586
587    /**
588     * @param value The status of the request.
589     */
590    public DeviceUseRequest setStatus(DeviceUseRequestStatus value) { 
591      if (value == null)
592        this.status = null;
593      else {
594        if (this.status == null)
595          this.status = new Enumeration<DeviceUseRequestStatus>(new DeviceUseRequestStatusEnumFactory());
596        this.status.setValue(value);
597      }
598      return this;
599    }
600
601    /**
602     * @return {@link #device} (The details of the device  to be used.)
603     */
604    public Reference getDevice() { 
605      if (this.device == null)
606        if (Configuration.errorOnAutoCreate())
607          throw new Error("Attempt to auto-create DeviceUseRequest.device");
608        else if (Configuration.doAutoCreate())
609          this.device = new Reference(); // cc
610      return this.device;
611    }
612
613    public boolean hasDevice() { 
614      return this.device != null && !this.device.isEmpty();
615    }
616
617    /**
618     * @param value {@link #device} (The details of the device  to be used.)
619     */
620    public DeviceUseRequest setDevice(Reference value) { 
621      this.device = value;
622      return this;
623    }
624
625    /**
626     * @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  to be used.)
627     */
628    public Device getDeviceTarget() { 
629      if (this.deviceTarget == null)
630        if (Configuration.errorOnAutoCreate())
631          throw new Error("Attempt to auto-create DeviceUseRequest.device");
632        else if (Configuration.doAutoCreate())
633          this.deviceTarget = new Device(); // aa
634      return this.deviceTarget;
635    }
636
637    /**
638     * @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  to be used.)
639     */
640    public DeviceUseRequest setDeviceTarget(Device value) { 
641      this.deviceTarget = value;
642      return this;
643    }
644
645    /**
646     * @return {@link #encounter} (An encounter that provides additional context in which this request is made.)
647     */
648    public Reference getEncounter() { 
649      if (this.encounter == null)
650        if (Configuration.errorOnAutoCreate())
651          throw new Error("Attempt to auto-create DeviceUseRequest.encounter");
652        else if (Configuration.doAutoCreate())
653          this.encounter = new Reference(); // cc
654      return this.encounter;
655    }
656
657    public boolean hasEncounter() { 
658      return this.encounter != null && !this.encounter.isEmpty();
659    }
660
661    /**
662     * @param value {@link #encounter} (An encounter that provides additional context in which this request is made.)
663     */
664    public DeviceUseRequest setEncounter(Reference value) { 
665      this.encounter = value;
666      return this;
667    }
668
669    /**
670     * @return {@link #encounter} 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. (An encounter that provides additional context in which this request is made.)
671     */
672    public Encounter getEncounterTarget() { 
673      if (this.encounterTarget == null)
674        if (Configuration.errorOnAutoCreate())
675          throw new Error("Attempt to auto-create DeviceUseRequest.encounter");
676        else if (Configuration.doAutoCreate())
677          this.encounterTarget = new Encounter(); // aa
678      return this.encounterTarget;
679    }
680
681    /**
682     * @param value {@link #encounter} 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. (An encounter that provides additional context in which this request is made.)
683     */
684    public DeviceUseRequest setEncounterTarget(Encounter value) { 
685      this.encounterTarget = value;
686      return this;
687    }
688
689    /**
690     * @return {@link #identifier} (Identifiers assigned to this order by the orderer or by the receiver.)
691     */
692    public List<Identifier> getIdentifier() { 
693      if (this.identifier == null)
694        this.identifier = new ArrayList<Identifier>();
695      return this.identifier;
696    }
697
698    public boolean hasIdentifier() { 
699      if (this.identifier == null)
700        return false;
701      for (Identifier item : this.identifier)
702        if (!item.isEmpty())
703          return true;
704      return false;
705    }
706
707    /**
708     * @return {@link #identifier} (Identifiers assigned to this order by the orderer or by the receiver.)
709     */
710    // syntactic sugar
711    public Identifier addIdentifier() { //3
712      Identifier t = new Identifier();
713      if (this.identifier == null)
714        this.identifier = new ArrayList<Identifier>();
715      this.identifier.add(t);
716      return t;
717    }
718
719    // syntactic sugar
720    public DeviceUseRequest addIdentifier(Identifier t) { //3
721      if (t == null)
722        return this;
723      if (this.identifier == null)
724        this.identifier = new ArrayList<Identifier>();
725      this.identifier.add(t);
726      return this;
727    }
728
729    /**
730     * @return {@link #indication} (Reason or justification for the use of this device.)
731     */
732    public List<CodeableConcept> getIndication() { 
733      if (this.indication == null)
734        this.indication = new ArrayList<CodeableConcept>();
735      return this.indication;
736    }
737
738    public boolean hasIndication() { 
739      if (this.indication == null)
740        return false;
741      for (CodeableConcept item : this.indication)
742        if (!item.isEmpty())
743          return true;
744      return false;
745    }
746
747    /**
748     * @return {@link #indication} (Reason or justification for the use of this device.)
749     */
750    // syntactic sugar
751    public CodeableConcept addIndication() { //3
752      CodeableConcept t = new CodeableConcept();
753      if (this.indication == null)
754        this.indication = new ArrayList<CodeableConcept>();
755      this.indication.add(t);
756      return t;
757    }
758
759    // syntactic sugar
760    public DeviceUseRequest addIndication(CodeableConcept t) { //3
761      if (t == null)
762        return this;
763      if (this.indication == null)
764        this.indication = new ArrayList<CodeableConcept>();
765      this.indication.add(t);
766      return this;
767    }
768
769    /**
770     * @return {@link #notes} (Details about this request 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.)
771     */
772    public List<StringType> getNotes() { 
773      if (this.notes == null)
774        this.notes = new ArrayList<StringType>();
775      return this.notes;
776    }
777
778    public boolean hasNotes() { 
779      if (this.notes == null)
780        return false;
781      for (StringType item : this.notes)
782        if (!item.isEmpty())
783          return true;
784      return false;
785    }
786
787    /**
788     * @return {@link #notes} (Details about this request 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.)
789     */
790    // syntactic sugar
791    public StringType addNotesElement() {//2 
792      StringType t = new StringType();
793      if (this.notes == null)
794        this.notes = new ArrayList<StringType>();
795      this.notes.add(t);
796      return t;
797    }
798
799    /**
800     * @param value {@link #notes} (Details about this request 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.)
801     */
802    public DeviceUseRequest addNotes(String value) { //1
803      StringType t = new StringType();
804      t.setValue(value);
805      if (this.notes == null)
806        this.notes = new ArrayList<StringType>();
807      this.notes.add(t);
808      return this;
809    }
810
811    /**
812     * @param value {@link #notes} (Details about this request 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.)
813     */
814    public boolean hasNotes(String value) { 
815      if (this.notes == null)
816        return false;
817      for (StringType v : this.notes)
818        if (v.equals(value)) // string
819          return true;
820      return false;
821    }
822
823    /**
824     * @return {@link #prnReason} (The proposed act must be performed if the indicated conditions occur, e.g.., shortness of breath, SpO2 less than x%.)
825     */
826    public List<CodeableConcept> getPrnReason() { 
827      if (this.prnReason == null)
828        this.prnReason = new ArrayList<CodeableConcept>();
829      return this.prnReason;
830    }
831
832    public boolean hasPrnReason() { 
833      if (this.prnReason == null)
834        return false;
835      for (CodeableConcept item : this.prnReason)
836        if (!item.isEmpty())
837          return true;
838      return false;
839    }
840
841    /**
842     * @return {@link #prnReason} (The proposed act must be performed if the indicated conditions occur, e.g.., shortness of breath, SpO2 less than x%.)
843     */
844    // syntactic sugar
845    public CodeableConcept addPrnReason() { //3
846      CodeableConcept t = new CodeableConcept();
847      if (this.prnReason == null)
848        this.prnReason = new ArrayList<CodeableConcept>();
849      this.prnReason.add(t);
850      return t;
851    }
852
853    // syntactic sugar
854    public DeviceUseRequest addPrnReason(CodeableConcept t) { //3
855      if (t == null)
856        return this;
857      if (this.prnReason == null)
858        this.prnReason = new ArrayList<CodeableConcept>();
859      this.prnReason.add(t);
860      return this;
861    }
862
863    /**
864     * @return {@link #orderedOn} (The time when the request was made.). This is the underlying object with id, value and extensions. The accessor "getOrderedOn" gives direct access to the value
865     */
866    public DateTimeType getOrderedOnElement() { 
867      if (this.orderedOn == null)
868        if (Configuration.errorOnAutoCreate())
869          throw new Error("Attempt to auto-create DeviceUseRequest.orderedOn");
870        else if (Configuration.doAutoCreate())
871          this.orderedOn = new DateTimeType(); // bb
872      return this.orderedOn;
873    }
874
875    public boolean hasOrderedOnElement() { 
876      return this.orderedOn != null && !this.orderedOn.isEmpty();
877    }
878
879    public boolean hasOrderedOn() { 
880      return this.orderedOn != null && !this.orderedOn.isEmpty();
881    }
882
883    /**
884     * @param value {@link #orderedOn} (The time when the request was made.). This is the underlying object with id, value and extensions. The accessor "getOrderedOn" gives direct access to the value
885     */
886    public DeviceUseRequest setOrderedOnElement(DateTimeType value) { 
887      this.orderedOn = value;
888      return this;
889    }
890
891    /**
892     * @return The time when the request was made.
893     */
894    public Date getOrderedOn() { 
895      return this.orderedOn == null ? null : this.orderedOn.getValue();
896    }
897
898    /**
899     * @param value The time when the request was made.
900     */
901    public DeviceUseRequest setOrderedOn(Date value) { 
902      if (value == null)
903        this.orderedOn = null;
904      else {
905        if (this.orderedOn == null)
906          this.orderedOn = new DateTimeType();
907        this.orderedOn.setValue(value);
908      }
909      return this;
910    }
911
912    /**
913     * @return {@link #recordedOn} (The time at which the request was made/recorded.). This is the underlying object with id, value and extensions. The accessor "getRecordedOn" gives direct access to the value
914     */
915    public DateTimeType getRecordedOnElement() { 
916      if (this.recordedOn == null)
917        if (Configuration.errorOnAutoCreate())
918          throw new Error("Attempt to auto-create DeviceUseRequest.recordedOn");
919        else if (Configuration.doAutoCreate())
920          this.recordedOn = new DateTimeType(); // bb
921      return this.recordedOn;
922    }
923
924    public boolean hasRecordedOnElement() { 
925      return this.recordedOn != null && !this.recordedOn.isEmpty();
926    }
927
928    public boolean hasRecordedOn() { 
929      return this.recordedOn != null && !this.recordedOn.isEmpty();
930    }
931
932    /**
933     * @param value {@link #recordedOn} (The time at which the request was made/recorded.). This is the underlying object with id, value and extensions. The accessor "getRecordedOn" gives direct access to the value
934     */
935    public DeviceUseRequest setRecordedOnElement(DateTimeType value) { 
936      this.recordedOn = value;
937      return this;
938    }
939
940    /**
941     * @return The time at which the request was made/recorded.
942     */
943    public Date getRecordedOn() { 
944      return this.recordedOn == null ? null : this.recordedOn.getValue();
945    }
946
947    /**
948     * @param value The time at which the request was made/recorded.
949     */
950    public DeviceUseRequest setRecordedOn(Date value) { 
951      if (value == null)
952        this.recordedOn = null;
953      else {
954        if (this.recordedOn == null)
955          this.recordedOn = new DateTimeType();
956        this.recordedOn.setValue(value);
957      }
958      return this;
959    }
960
961    /**
962     * @return {@link #subject} (The patient who will use the device.)
963     */
964    public Reference getSubject() { 
965      if (this.subject == null)
966        if (Configuration.errorOnAutoCreate())
967          throw new Error("Attempt to auto-create DeviceUseRequest.subject");
968        else if (Configuration.doAutoCreate())
969          this.subject = new Reference(); // cc
970      return this.subject;
971    }
972
973    public boolean hasSubject() { 
974      return this.subject != null && !this.subject.isEmpty();
975    }
976
977    /**
978     * @param value {@link #subject} (The patient who will use the device.)
979     */
980    public DeviceUseRequest setSubject(Reference value) { 
981      this.subject = value;
982      return this;
983    }
984
985    /**
986     * @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 will use the device.)
987     */
988    public Patient getSubjectTarget() { 
989      if (this.subjectTarget == null)
990        if (Configuration.errorOnAutoCreate())
991          throw new Error("Attempt to auto-create DeviceUseRequest.subject");
992        else if (Configuration.doAutoCreate())
993          this.subjectTarget = new Patient(); // aa
994      return this.subjectTarget;
995    }
996
997    /**
998     * @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 will use the device.)
999     */
1000    public DeviceUseRequest setSubjectTarget(Patient value) { 
1001      this.subjectTarget = value;
1002      return this;
1003    }
1004
1005    /**
1006     * @return {@link #timing} (The timing schedule for the use of the device The Schedule data type allows many different expressions, for example. "Every 8 hours"; "Three times a day"; "1/2 an hour before breakfast for 10 days from 23-Dec 2011:"; "15 Oct 2013, 17 Oct 2013 and 1 Nov 2013".)
1007     */
1008    public Type getTiming() { 
1009      return this.timing;
1010    }
1011
1012    /**
1013     * @return {@link #timing} (The timing schedule for the use of the device The Schedule data type allows many different expressions, for example. "Every 8 hours"; "Three times a day"; "1/2 an hour before breakfast for 10 days from 23-Dec 2011:"; "15 Oct 2013, 17 Oct 2013 and 1 Nov 2013".)
1014     */
1015    public Timing getTimingTiming() throws FHIRException { 
1016      if (!(this.timing instanceof Timing))
1017        throw new FHIRException("Type mismatch: the type Timing was expected, but "+this.timing.getClass().getName()+" was encountered");
1018      return (Timing) this.timing;
1019    }
1020
1021    public boolean hasTimingTiming() { 
1022      return this.timing instanceof Timing;
1023    }
1024
1025    /**
1026     * @return {@link #timing} (The timing schedule for the use of the device The Schedule data type allows many different expressions, for example. "Every 8 hours"; "Three times a day"; "1/2 an hour before breakfast for 10 days from 23-Dec 2011:"; "15 Oct 2013, 17 Oct 2013 and 1 Nov 2013".)
1027     */
1028    public Period getTimingPeriod() throws FHIRException { 
1029      if (!(this.timing instanceof Period))
1030        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.timing.getClass().getName()+" was encountered");
1031      return (Period) this.timing;
1032    }
1033
1034    public boolean hasTimingPeriod() { 
1035      return this.timing instanceof Period;
1036    }
1037
1038    /**
1039     * @return {@link #timing} (The timing schedule for the use of the device The Schedule data type allows many different expressions, for example. "Every 8 hours"; "Three times a day"; "1/2 an hour before breakfast for 10 days from 23-Dec 2011:"; "15 Oct 2013, 17 Oct 2013 and 1 Nov 2013".)
1040     */
1041    public DateTimeType getTimingDateTimeType() throws FHIRException { 
1042      if (!(this.timing instanceof DateTimeType))
1043        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.timing.getClass().getName()+" was encountered");
1044      return (DateTimeType) this.timing;
1045    }
1046
1047    public boolean hasTimingDateTimeType() { 
1048      return this.timing instanceof DateTimeType;
1049    }
1050
1051    public boolean hasTiming() { 
1052      return this.timing != null && !this.timing.isEmpty();
1053    }
1054
1055    /**
1056     * @param value {@link #timing} (The timing schedule for the use of the device The Schedule data type allows many different expressions, for example. "Every 8 hours"; "Three times a day"; "1/2 an hour before breakfast for 10 days from 23-Dec 2011:"; "15 Oct 2013, 17 Oct 2013 and 1 Nov 2013".)
1057     */
1058    public DeviceUseRequest setTiming(Type value) { 
1059      this.timing = value;
1060      return this;
1061    }
1062
1063    /**
1064     * @return {@link #priority} (Characterizes how quickly the  use of device must be initiated. Includes concepts such as stat, urgent, routine.). This is the underlying object with id, value and extensions. The accessor "getPriority" gives direct access to the value
1065     */
1066    public Enumeration<DeviceUseRequestPriority> getPriorityElement() { 
1067      if (this.priority == null)
1068        if (Configuration.errorOnAutoCreate())
1069          throw new Error("Attempt to auto-create DeviceUseRequest.priority");
1070        else if (Configuration.doAutoCreate())
1071          this.priority = new Enumeration<DeviceUseRequestPriority>(new DeviceUseRequestPriorityEnumFactory()); // bb
1072      return this.priority;
1073    }
1074
1075    public boolean hasPriorityElement() { 
1076      return this.priority != null && !this.priority.isEmpty();
1077    }
1078
1079    public boolean hasPriority() { 
1080      return this.priority != null && !this.priority.isEmpty();
1081    }
1082
1083    /**
1084     * @param value {@link #priority} (Characterizes how quickly the  use of device must be initiated. Includes concepts such as stat, urgent, routine.). This is the underlying object with id, value and extensions. The accessor "getPriority" gives direct access to the value
1085     */
1086    public DeviceUseRequest setPriorityElement(Enumeration<DeviceUseRequestPriority> value) { 
1087      this.priority = value;
1088      return this;
1089    }
1090
1091    /**
1092     * @return Characterizes how quickly the  use of device must be initiated. Includes concepts such as stat, urgent, routine.
1093     */
1094    public DeviceUseRequestPriority getPriority() { 
1095      return this.priority == null ? null : this.priority.getValue();
1096    }
1097
1098    /**
1099     * @param value Characterizes how quickly the  use of device must be initiated. Includes concepts such as stat, urgent, routine.
1100     */
1101    public DeviceUseRequest setPriority(DeviceUseRequestPriority value) { 
1102      if (value == null)
1103        this.priority = null;
1104      else {
1105        if (this.priority == null)
1106          this.priority = new Enumeration<DeviceUseRequestPriority>(new DeviceUseRequestPriorityEnumFactory());
1107        this.priority.setValue(value);
1108      }
1109      return this;
1110    }
1111
1112      protected void listChildren(List<Property> childrenList) {
1113        super.listChildren(childrenList);
1114        childrenList.add(new Property("bodySite[x]", "CodeableConcept|Reference(BodySite)", "Indicates the site on the subject's body where the device should be used ( i.e. the target site).", 0, java.lang.Integer.MAX_VALUE, bodySite));
1115        childrenList.add(new Property("status", "code", "The status of the request.", 0, java.lang.Integer.MAX_VALUE, status));
1116        childrenList.add(new Property("device", "Reference(Device)", "The details of the device  to be used.", 0, java.lang.Integer.MAX_VALUE, device));
1117        childrenList.add(new Property("encounter", "Reference(Encounter)", "An encounter that provides additional context in which this request is made.", 0, java.lang.Integer.MAX_VALUE, encounter));
1118        childrenList.add(new Property("identifier", "Identifier", "Identifiers assigned to this order by the orderer or by the receiver.", 0, java.lang.Integer.MAX_VALUE, identifier));
1119        childrenList.add(new Property("indication", "CodeableConcept", "Reason or justification for the use of this device.", 0, java.lang.Integer.MAX_VALUE, indication));
1120        childrenList.add(new Property("notes", "string", "Details about this request 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));
1121        childrenList.add(new Property("prnReason", "CodeableConcept", "The proposed act must be performed if the indicated conditions occur, e.g.., shortness of breath, SpO2 less than x%.", 0, java.lang.Integer.MAX_VALUE, prnReason));
1122        childrenList.add(new Property("orderedOn", "dateTime", "The time when the request was made.", 0, java.lang.Integer.MAX_VALUE, orderedOn));
1123        childrenList.add(new Property("recordedOn", "dateTime", "The time at which the request was made/recorded.", 0, java.lang.Integer.MAX_VALUE, recordedOn));
1124        childrenList.add(new Property("subject", "Reference(Patient)", "The patient who will use the device.", 0, java.lang.Integer.MAX_VALUE, subject));
1125        childrenList.add(new Property("timing[x]", "Timing|Period|dateTime", "The timing schedule for the use of the device The Schedule data type allows many different expressions, for example. \"Every 8 hours\"; \"Three times a day\"; \"1/2 an hour before breakfast for 10 days from 23-Dec 2011:\"; \"15 Oct 2013, 17 Oct 2013 and 1 Nov 2013\".", 0, java.lang.Integer.MAX_VALUE, timing));
1126        childrenList.add(new Property("priority", "code", "Characterizes how quickly the  use of device must be initiated. Includes concepts such as stat, urgent, routine.", 0, java.lang.Integer.MAX_VALUE, priority));
1127      }
1128
1129      @Override
1130      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1131        switch (hash) {
1132        case 1702620169: /*bodySite*/ return this.bodySite == null ? new Base[0] : new Base[] {this.bodySite}; // Type
1133        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<DeviceUseRequestStatus>
1134        case -1335157162: /*device*/ return this.device == null ? new Base[0] : new Base[] {this.device}; // Reference
1135        case 1524132147: /*encounter*/ return this.encounter == null ? new Base[0] : new Base[] {this.encounter}; // Reference
1136        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1137        case -597168804: /*indication*/ return this.indication == null ? new Base[0] : this.indication.toArray(new Base[this.indication.size()]); // CodeableConcept
1138        case 105008833: /*notes*/ return this.notes == null ? new Base[0] : this.notes.toArray(new Base[this.notes.size()]); // StringType
1139        case 1825472528: /*prnReason*/ return this.prnReason == null ? new Base[0] : this.prnReason.toArray(new Base[this.prnReason.size()]); // CodeableConcept
1140        case -391079124: /*orderedOn*/ return this.orderedOn == null ? new Base[0] : new Base[] {this.orderedOn}; // DateTimeType
1141        case 735397551: /*recordedOn*/ return this.recordedOn == null ? new Base[0] : new Base[] {this.recordedOn}; // DateTimeType
1142        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
1143        case -873664438: /*timing*/ return this.timing == null ? new Base[0] : new Base[] {this.timing}; // Type
1144        case -1165461084: /*priority*/ return this.priority == null ? new Base[0] : new Base[] {this.priority}; // Enumeration<DeviceUseRequestPriority>
1145        default: return super.getProperty(hash, name, checkValid);
1146        }
1147
1148      }
1149
1150      @Override
1151      public void setProperty(int hash, String name, Base value) throws FHIRException {
1152        switch (hash) {
1153        case 1702620169: // bodySite
1154          this.bodySite = (Type) value; // Type
1155          break;
1156        case -892481550: // status
1157          this.status = new DeviceUseRequestStatusEnumFactory().fromType(value); // Enumeration<DeviceUseRequestStatus>
1158          break;
1159        case -1335157162: // device
1160          this.device = castToReference(value); // Reference
1161          break;
1162        case 1524132147: // encounter
1163          this.encounter = castToReference(value); // Reference
1164          break;
1165        case -1618432855: // identifier
1166          this.getIdentifier().add(castToIdentifier(value)); // Identifier
1167          break;
1168        case -597168804: // indication
1169          this.getIndication().add(castToCodeableConcept(value)); // CodeableConcept
1170          break;
1171        case 105008833: // notes
1172          this.getNotes().add(castToString(value)); // StringType
1173          break;
1174        case 1825472528: // prnReason
1175          this.getPrnReason().add(castToCodeableConcept(value)); // CodeableConcept
1176          break;
1177        case -391079124: // orderedOn
1178          this.orderedOn = castToDateTime(value); // DateTimeType
1179          break;
1180        case 735397551: // recordedOn
1181          this.recordedOn = castToDateTime(value); // DateTimeType
1182          break;
1183        case -1867885268: // subject
1184          this.subject = castToReference(value); // Reference
1185          break;
1186        case -873664438: // timing
1187          this.timing = (Type) value; // Type
1188          break;
1189        case -1165461084: // priority
1190          this.priority = new DeviceUseRequestPriorityEnumFactory().fromType(value); // Enumeration<DeviceUseRequestPriority>
1191          break;
1192        default: super.setProperty(hash, name, value);
1193        }
1194
1195      }
1196
1197      @Override
1198      public void setProperty(String name, Base value) throws FHIRException {
1199        if (name.equals("bodySite[x]"))
1200          this.bodySite = (Type) value; // Type
1201        else if (name.equals("status"))
1202          this.status = new DeviceUseRequestStatusEnumFactory().fromType(value); // Enumeration<DeviceUseRequestStatus>
1203        else if (name.equals("device"))
1204          this.device = castToReference(value); // Reference
1205        else if (name.equals("encounter"))
1206          this.encounter = castToReference(value); // Reference
1207        else if (name.equals("identifier"))
1208          this.getIdentifier().add(castToIdentifier(value));
1209        else if (name.equals("indication"))
1210          this.getIndication().add(castToCodeableConcept(value));
1211        else if (name.equals("notes"))
1212          this.getNotes().add(castToString(value));
1213        else if (name.equals("prnReason"))
1214          this.getPrnReason().add(castToCodeableConcept(value));
1215        else if (name.equals("orderedOn"))
1216          this.orderedOn = castToDateTime(value); // DateTimeType
1217        else if (name.equals("recordedOn"))
1218          this.recordedOn = castToDateTime(value); // DateTimeType
1219        else if (name.equals("subject"))
1220          this.subject = castToReference(value); // Reference
1221        else if (name.equals("timing[x]"))
1222          this.timing = (Type) value; // Type
1223        else if (name.equals("priority"))
1224          this.priority = new DeviceUseRequestPriorityEnumFactory().fromType(value); // Enumeration<DeviceUseRequestPriority>
1225        else
1226          super.setProperty(name, value);
1227      }
1228
1229      @Override
1230      public Base makeProperty(int hash, String name) throws FHIRException {
1231        switch (hash) {
1232        case -806219817:  return getBodySite(); // Type
1233        case -892481550: throw new FHIRException("Cannot make property status as it is not a complex type"); // Enumeration<DeviceUseRequestStatus>
1234        case -1335157162:  return getDevice(); // Reference
1235        case 1524132147:  return getEncounter(); // Reference
1236        case -1618432855:  return addIdentifier(); // Identifier
1237        case -597168804:  return addIndication(); // CodeableConcept
1238        case 105008833: throw new FHIRException("Cannot make property notes as it is not a complex type"); // StringType
1239        case 1825472528:  return addPrnReason(); // CodeableConcept
1240        case -391079124: throw new FHIRException("Cannot make property orderedOn as it is not a complex type"); // DateTimeType
1241        case 735397551: throw new FHIRException("Cannot make property recordedOn as it is not a complex type"); // DateTimeType
1242        case -1867885268:  return getSubject(); // Reference
1243        case 164632566:  return getTiming(); // Type
1244        case -1165461084: throw new FHIRException("Cannot make property priority as it is not a complex type"); // Enumeration<DeviceUseRequestPriority>
1245        default: return super.makeProperty(hash, name);
1246        }
1247
1248      }
1249
1250      @Override
1251      public Base addChild(String name) throws FHIRException {
1252        if (name.equals("bodySiteCodeableConcept")) {
1253          this.bodySite = new CodeableConcept();
1254          return this.bodySite;
1255        }
1256        else if (name.equals("bodySiteReference")) {
1257          this.bodySite = new Reference();
1258          return this.bodySite;
1259        }
1260        else if (name.equals("status")) {
1261          throw new FHIRException("Cannot call addChild on a primitive type DeviceUseRequest.status");
1262        }
1263        else if (name.equals("device")) {
1264          this.device = new Reference();
1265          return this.device;
1266        }
1267        else if (name.equals("encounter")) {
1268          this.encounter = new Reference();
1269          return this.encounter;
1270        }
1271        else if (name.equals("identifier")) {
1272          return addIdentifier();
1273        }
1274        else if (name.equals("indication")) {
1275          return addIndication();
1276        }
1277        else if (name.equals("notes")) {
1278          throw new FHIRException("Cannot call addChild on a primitive type DeviceUseRequest.notes");
1279        }
1280        else if (name.equals("prnReason")) {
1281          return addPrnReason();
1282        }
1283        else if (name.equals("orderedOn")) {
1284          throw new FHIRException("Cannot call addChild on a primitive type DeviceUseRequest.orderedOn");
1285        }
1286        else if (name.equals("recordedOn")) {
1287          throw new FHIRException("Cannot call addChild on a primitive type DeviceUseRequest.recordedOn");
1288        }
1289        else if (name.equals("subject")) {
1290          this.subject = new Reference();
1291          return this.subject;
1292        }
1293        else if (name.equals("timingTiming")) {
1294          this.timing = new Timing();
1295          return this.timing;
1296        }
1297        else if (name.equals("timingPeriod")) {
1298          this.timing = new Period();
1299          return this.timing;
1300        }
1301        else if (name.equals("timingDateTime")) {
1302          this.timing = new DateTimeType();
1303          return this.timing;
1304        }
1305        else if (name.equals("priority")) {
1306          throw new FHIRException("Cannot call addChild on a primitive type DeviceUseRequest.priority");
1307        }
1308        else
1309          return super.addChild(name);
1310      }
1311
1312  public String fhirType() {
1313    return "DeviceUseRequest";
1314
1315  }
1316
1317      public DeviceUseRequest copy() {
1318        DeviceUseRequest dst = new DeviceUseRequest();
1319        copyValues(dst);
1320        dst.bodySite = bodySite == null ? null : bodySite.copy();
1321        dst.status = status == null ? null : status.copy();
1322        dst.device = device == null ? null : device.copy();
1323        dst.encounter = encounter == null ? null : encounter.copy();
1324        if (identifier != null) {
1325          dst.identifier = new ArrayList<Identifier>();
1326          for (Identifier i : identifier)
1327            dst.identifier.add(i.copy());
1328        };
1329        if (indication != null) {
1330          dst.indication = new ArrayList<CodeableConcept>();
1331          for (CodeableConcept i : indication)
1332            dst.indication.add(i.copy());
1333        };
1334        if (notes != null) {
1335          dst.notes = new ArrayList<StringType>();
1336          for (StringType i : notes)
1337            dst.notes.add(i.copy());
1338        };
1339        if (prnReason != null) {
1340          dst.prnReason = new ArrayList<CodeableConcept>();
1341          for (CodeableConcept i : prnReason)
1342            dst.prnReason.add(i.copy());
1343        };
1344        dst.orderedOn = orderedOn == null ? null : orderedOn.copy();
1345        dst.recordedOn = recordedOn == null ? null : recordedOn.copy();
1346        dst.subject = subject == null ? null : subject.copy();
1347        dst.timing = timing == null ? null : timing.copy();
1348        dst.priority = priority == null ? null : priority.copy();
1349        return dst;
1350      }
1351
1352      protected DeviceUseRequest typedCopy() {
1353        return copy();
1354      }
1355
1356      @Override
1357      public boolean equalsDeep(Base other) {
1358        if (!super.equalsDeep(other))
1359          return false;
1360        if (!(other instanceof DeviceUseRequest))
1361          return false;
1362        DeviceUseRequest o = (DeviceUseRequest) other;
1363        return compareDeep(bodySite, o.bodySite, true) && compareDeep(status, o.status, true) && compareDeep(device, o.device, true)
1364           && compareDeep(encounter, o.encounter, true) && compareDeep(identifier, o.identifier, true) && compareDeep(indication, o.indication, true)
1365           && compareDeep(notes, o.notes, true) && compareDeep(prnReason, o.prnReason, true) && compareDeep(orderedOn, o.orderedOn, true)
1366           && compareDeep(recordedOn, o.recordedOn, true) && compareDeep(subject, o.subject, true) && compareDeep(timing, o.timing, true)
1367           && compareDeep(priority, o.priority, true);
1368      }
1369
1370      @Override
1371      public boolean equalsShallow(Base other) {
1372        if (!super.equalsShallow(other))
1373          return false;
1374        if (!(other instanceof DeviceUseRequest))
1375          return false;
1376        DeviceUseRequest o = (DeviceUseRequest) other;
1377        return compareValues(status, o.status, true) && compareValues(notes, o.notes, true) && compareValues(orderedOn, o.orderedOn, true)
1378           && compareValues(recordedOn, o.recordedOn, true) && compareValues(priority, o.priority, true);
1379      }
1380
1381      public boolean isEmpty() {
1382        return super.isEmpty() && (bodySite == null || bodySite.isEmpty()) && (status == null || status.isEmpty())
1383           && (device == null || device.isEmpty()) && (encounter == null || encounter.isEmpty()) && (identifier == null || identifier.isEmpty())
1384           && (indication == null || indication.isEmpty()) && (notes == null || notes.isEmpty()) && (prnReason == null || prnReason.isEmpty())
1385           && (orderedOn == null || orderedOn.isEmpty()) && (recordedOn == null || recordedOn.isEmpty())
1386           && (subject == null || subject.isEmpty()) && (timing == null || timing.isEmpty()) && (priority == null || priority.isEmpty())
1387          ;
1388      }
1389
1390  @Override
1391  public ResourceType getResourceType() {
1392    return ResourceType.DeviceUseRequest;
1393   }
1394
1395 /**
1396   * Search parameter: <b>patient</b>
1397   * <p>
1398   * Description: <b>Search by subject - a patient</b><br>
1399   * Type: <b>reference</b><br>
1400   * Path: <b>DeviceUseRequest.subject</b><br>
1401   * </p>
1402   */
1403  @SearchParamDefinition(name="patient", path="DeviceUseRequest.subject", description="Search by subject - a patient", type="reference" )
1404  public static final String SP_PATIENT = "patient";
1405 /**
1406   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
1407   * <p>
1408   * Description: <b>Search by subject - a patient</b><br>
1409   * Type: <b>reference</b><br>
1410   * Path: <b>DeviceUseRequest.subject</b><br>
1411   * </p>
1412   */
1413  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
1414
1415/**
1416   * Constant for fluent queries to be used to add include statements. Specifies
1417   * the path value of "<b>DeviceUseRequest:patient</b>".
1418   */
1419  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("DeviceUseRequest:patient").toLocked();
1420
1421 /**
1422   * Search parameter: <b>subject</b>
1423   * <p>
1424   * Description: <b>Search by subject</b><br>
1425   * Type: <b>reference</b><br>
1426   * Path: <b>DeviceUseRequest.subject</b><br>
1427   * </p>
1428   */
1429  @SearchParamDefinition(name="subject", path="DeviceUseRequest.subject", description="Search by subject", type="reference" )
1430  public static final String SP_SUBJECT = "subject";
1431 /**
1432   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
1433   * <p>
1434   * Description: <b>Search by subject</b><br>
1435   * Type: <b>reference</b><br>
1436   * Path: <b>DeviceUseRequest.subject</b><br>
1437   * </p>
1438   */
1439  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
1440
1441/**
1442   * Constant for fluent queries to be used to add include statements. Specifies
1443   * the path value of "<b>DeviceUseRequest:subject</b>".
1444   */
1445  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("DeviceUseRequest:subject").toLocked();
1446
1447 /**
1448   * Search parameter: <b>device</b>
1449   * <p>
1450   * Description: <b>Device requested</b><br>
1451   * Type: <b>reference</b><br>
1452   * Path: <b>DeviceUseRequest.device</b><br>
1453   * </p>
1454   */
1455  @SearchParamDefinition(name="device", path="DeviceUseRequest.device", description="Device requested", type="reference" )
1456  public static final String SP_DEVICE = "device";
1457 /**
1458   * <b>Fluent Client</b> search parameter constant for <b>device</b>
1459   * <p>
1460   * Description: <b>Device requested</b><br>
1461   * Type: <b>reference</b><br>
1462   * Path: <b>DeviceUseRequest.device</b><br>
1463   * </p>
1464   */
1465  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam DEVICE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_DEVICE);
1466
1467/**
1468   * Constant for fluent queries to be used to add include statements. Specifies
1469   * the path value of "<b>DeviceUseRequest:device</b>".
1470   */
1471  public static final ca.uhn.fhir.model.api.Include INCLUDE_DEVICE = new ca.uhn.fhir.model.api.Include("DeviceUseRequest:device").toLocked();
1472
1473
1474}
1475