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