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