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