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