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.Block;
038import ca.uhn.fhir.model.api.annotation.Child;
039import ca.uhn.fhir.model.api.annotation.Description;
040import ca.uhn.fhir.model.api.annotation.ResourceDef;
041import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
042import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
043import org.hl7.fhir.exceptions.FHIRException;
044
045/**
046 * A record of a request for a diagnostic investigation service to be performed.
047 */
048@ResourceDef(name = "DiagnosticOrder", profile = "http://hl7.org/fhir/Profile/DiagnosticOrder")
049public class DiagnosticOrder extends DomainResource {
050
051  public enum DiagnosticOrderStatus {
052    /**
053     * The request has been proposed.
054     */
055    PROPOSED,
056    /**
057     * The request is in preliminary form prior to being sent.
058     */
059    DRAFT,
060    /**
061     * The request has been planned.
062     */
063    PLANNED,
064    /**
065     * The request has been placed.
066     */
067    REQUESTED,
068    /**
069     * The receiving system has received the order, but not yet decided whether it
070     * will be performed.
071     */
072    RECEIVED,
073    /**
074     * The receiving system has accepted the order, but work has not yet commenced.
075     */
076    ACCEPTED,
077    /**
078     * The work to fulfill the order is happening.
079     */
080    INPROGRESS,
081    /**
082     * The work is complete, and the outcomes are being reviewed for approval.
083     */
084    REVIEW,
085    /**
086     * The work has been completed, the report(s) released, and no further work is
087     * planned.
088     */
089    COMPLETED,
090    /**
091     * The request has been withdrawn.
092     */
093    CANCELLED,
094    /**
095     * The request has been held by originating system/user request.
096     */
097    SUSPENDED,
098    /**
099     * The receiving system has declined to fulfill the request.
100     */
101    REJECTED,
102    /**
103     * The diagnostic investigation was attempted, but due to some procedural error,
104     * it could not be completed.
105     */
106    FAILED,
107    /**
108     * added to help the parsers
109     */
110    NULL;
111
112    public static DiagnosticOrderStatus fromCode(String codeString) throws FHIRException {
113      if (codeString == null || "".equals(codeString))
114        return null;
115      if ("proposed".equals(codeString))
116        return PROPOSED;
117      if ("draft".equals(codeString))
118        return DRAFT;
119      if ("planned".equals(codeString))
120        return PLANNED;
121      if ("requested".equals(codeString))
122        return REQUESTED;
123      if ("received".equals(codeString))
124        return RECEIVED;
125      if ("accepted".equals(codeString))
126        return ACCEPTED;
127      if ("in-progress".equals(codeString))
128        return INPROGRESS;
129      if ("review".equals(codeString))
130        return REVIEW;
131      if ("completed".equals(codeString))
132        return COMPLETED;
133      if ("cancelled".equals(codeString))
134        return CANCELLED;
135      if ("suspended".equals(codeString))
136        return SUSPENDED;
137      if ("rejected".equals(codeString))
138        return REJECTED;
139      if ("failed".equals(codeString))
140        return FAILED;
141      throw new FHIRException("Unknown DiagnosticOrderStatus code '" + codeString + "'");
142    }
143
144    public String toCode() {
145      switch (this) {
146      case PROPOSED:
147        return "proposed";
148      case DRAFT:
149        return "draft";
150      case PLANNED:
151        return "planned";
152      case REQUESTED:
153        return "requested";
154      case RECEIVED:
155        return "received";
156      case ACCEPTED:
157        return "accepted";
158      case INPROGRESS:
159        return "in-progress";
160      case REVIEW:
161        return "review";
162      case COMPLETED:
163        return "completed";
164      case CANCELLED:
165        return "cancelled";
166      case SUSPENDED:
167        return "suspended";
168      case REJECTED:
169        return "rejected";
170      case FAILED:
171        return "failed";
172      case NULL:
173        return null;
174      default:
175        return "?";
176      }
177    }
178
179    public String getSystem() {
180      switch (this) {
181      case PROPOSED:
182        return "http://hl7.org/fhir/diagnostic-order-status";
183      case DRAFT:
184        return "http://hl7.org/fhir/diagnostic-order-status";
185      case PLANNED:
186        return "http://hl7.org/fhir/diagnostic-order-status";
187      case REQUESTED:
188        return "http://hl7.org/fhir/diagnostic-order-status";
189      case RECEIVED:
190        return "http://hl7.org/fhir/diagnostic-order-status";
191      case ACCEPTED:
192        return "http://hl7.org/fhir/diagnostic-order-status";
193      case INPROGRESS:
194        return "http://hl7.org/fhir/diagnostic-order-status";
195      case REVIEW:
196        return "http://hl7.org/fhir/diagnostic-order-status";
197      case COMPLETED:
198        return "http://hl7.org/fhir/diagnostic-order-status";
199      case CANCELLED:
200        return "http://hl7.org/fhir/diagnostic-order-status";
201      case SUSPENDED:
202        return "http://hl7.org/fhir/diagnostic-order-status";
203      case REJECTED:
204        return "http://hl7.org/fhir/diagnostic-order-status";
205      case FAILED:
206        return "http://hl7.org/fhir/diagnostic-order-status";
207      case NULL:
208        return null;
209      default:
210        return "?";
211      }
212    }
213
214    public String getDefinition() {
215      switch (this) {
216      case PROPOSED:
217        return "The request has been proposed.";
218      case DRAFT:
219        return "The request is in preliminary form prior to being sent.";
220      case PLANNED:
221        return "The request has been planned.";
222      case REQUESTED:
223        return "The request has been placed.";
224      case RECEIVED:
225        return "The receiving system has received the order, but not yet decided whether it will be performed.";
226      case ACCEPTED:
227        return "The receiving system has accepted the order, but work has not yet commenced.";
228      case INPROGRESS:
229        return "The work to fulfill the order is happening.";
230      case REVIEW:
231        return "The work is complete, and the outcomes are being reviewed for approval.";
232      case COMPLETED:
233        return "The work has been completed, the report(s) released, and no further work is planned.";
234      case CANCELLED:
235        return "The request has been withdrawn.";
236      case SUSPENDED:
237        return "The request has been held by originating system/user request.";
238      case REJECTED:
239        return "The receiving system has declined to fulfill the request.";
240      case FAILED:
241        return "The diagnostic investigation was attempted, but due to some procedural error, it could not be completed.";
242      case NULL:
243        return null;
244      default:
245        return "?";
246      }
247    }
248
249    public String getDisplay() {
250      switch (this) {
251      case PROPOSED:
252        return "Proposed";
253      case DRAFT:
254        return "Draft";
255      case PLANNED:
256        return "Planned";
257      case REQUESTED:
258        return "Requested";
259      case RECEIVED:
260        return "Received";
261      case ACCEPTED:
262        return "Accepted";
263      case INPROGRESS:
264        return "In-Progress";
265      case REVIEW:
266        return "Review";
267      case COMPLETED:
268        return "Completed";
269      case CANCELLED:
270        return "Cancelled";
271      case SUSPENDED:
272        return "Suspended";
273      case REJECTED:
274        return "Rejected";
275      case FAILED:
276        return "Failed";
277      case NULL:
278        return null;
279      default:
280        return "?";
281      }
282    }
283  }
284
285  public static class DiagnosticOrderStatusEnumFactory implements EnumFactory<DiagnosticOrderStatus> {
286    public DiagnosticOrderStatus fromCode(String codeString) throws IllegalArgumentException {
287      if (codeString == null || "".equals(codeString))
288        if (codeString == null || "".equals(codeString))
289          return null;
290      if ("proposed".equals(codeString))
291        return DiagnosticOrderStatus.PROPOSED;
292      if ("draft".equals(codeString))
293        return DiagnosticOrderStatus.DRAFT;
294      if ("planned".equals(codeString))
295        return DiagnosticOrderStatus.PLANNED;
296      if ("requested".equals(codeString))
297        return DiagnosticOrderStatus.REQUESTED;
298      if ("received".equals(codeString))
299        return DiagnosticOrderStatus.RECEIVED;
300      if ("accepted".equals(codeString))
301        return DiagnosticOrderStatus.ACCEPTED;
302      if ("in-progress".equals(codeString))
303        return DiagnosticOrderStatus.INPROGRESS;
304      if ("review".equals(codeString))
305        return DiagnosticOrderStatus.REVIEW;
306      if ("completed".equals(codeString))
307        return DiagnosticOrderStatus.COMPLETED;
308      if ("cancelled".equals(codeString))
309        return DiagnosticOrderStatus.CANCELLED;
310      if ("suspended".equals(codeString))
311        return DiagnosticOrderStatus.SUSPENDED;
312      if ("rejected".equals(codeString))
313        return DiagnosticOrderStatus.REJECTED;
314      if ("failed".equals(codeString))
315        return DiagnosticOrderStatus.FAILED;
316      throw new IllegalArgumentException("Unknown DiagnosticOrderStatus code '" + codeString + "'");
317    }
318
319    public Enumeration<DiagnosticOrderStatus> fromType(Base code) throws FHIRException {
320      if (code == null || code.isEmpty())
321        return null;
322      String codeString = ((PrimitiveType) code).asStringValue();
323      if (codeString == null || "".equals(codeString))
324        return null;
325      if ("proposed".equals(codeString))
326        return new Enumeration<DiagnosticOrderStatus>(this, DiagnosticOrderStatus.PROPOSED);
327      if ("draft".equals(codeString))
328        return new Enumeration<DiagnosticOrderStatus>(this, DiagnosticOrderStatus.DRAFT);
329      if ("planned".equals(codeString))
330        return new Enumeration<DiagnosticOrderStatus>(this, DiagnosticOrderStatus.PLANNED);
331      if ("requested".equals(codeString))
332        return new Enumeration<DiagnosticOrderStatus>(this, DiagnosticOrderStatus.REQUESTED);
333      if ("received".equals(codeString))
334        return new Enumeration<DiagnosticOrderStatus>(this, DiagnosticOrderStatus.RECEIVED);
335      if ("accepted".equals(codeString))
336        return new Enumeration<DiagnosticOrderStatus>(this, DiagnosticOrderStatus.ACCEPTED);
337      if ("in-progress".equals(codeString))
338        return new Enumeration<DiagnosticOrderStatus>(this, DiagnosticOrderStatus.INPROGRESS);
339      if ("review".equals(codeString))
340        return new Enumeration<DiagnosticOrderStatus>(this, DiagnosticOrderStatus.REVIEW);
341      if ("completed".equals(codeString))
342        return new Enumeration<DiagnosticOrderStatus>(this, DiagnosticOrderStatus.COMPLETED);
343      if ("cancelled".equals(codeString))
344        return new Enumeration<DiagnosticOrderStatus>(this, DiagnosticOrderStatus.CANCELLED);
345      if ("suspended".equals(codeString))
346        return new Enumeration<DiagnosticOrderStatus>(this, DiagnosticOrderStatus.SUSPENDED);
347      if ("rejected".equals(codeString))
348        return new Enumeration<DiagnosticOrderStatus>(this, DiagnosticOrderStatus.REJECTED);
349      if ("failed".equals(codeString))
350        return new Enumeration<DiagnosticOrderStatus>(this, DiagnosticOrderStatus.FAILED);
351      throw new FHIRException("Unknown DiagnosticOrderStatus code '" + codeString + "'");
352    }
353
354    public String toCode(DiagnosticOrderStatus code) {
355      if (code == DiagnosticOrderStatus.PROPOSED)
356        return "proposed";
357      if (code == DiagnosticOrderStatus.DRAFT)
358        return "draft";
359      if (code == DiagnosticOrderStatus.PLANNED)
360        return "planned";
361      if (code == DiagnosticOrderStatus.REQUESTED)
362        return "requested";
363      if (code == DiagnosticOrderStatus.RECEIVED)
364        return "received";
365      if (code == DiagnosticOrderStatus.ACCEPTED)
366        return "accepted";
367      if (code == DiagnosticOrderStatus.INPROGRESS)
368        return "in-progress";
369      if (code == DiagnosticOrderStatus.REVIEW)
370        return "review";
371      if (code == DiagnosticOrderStatus.COMPLETED)
372        return "completed";
373      if (code == DiagnosticOrderStatus.CANCELLED)
374        return "cancelled";
375      if (code == DiagnosticOrderStatus.SUSPENDED)
376        return "suspended";
377      if (code == DiagnosticOrderStatus.REJECTED)
378        return "rejected";
379      if (code == DiagnosticOrderStatus.FAILED)
380        return "failed";
381      return "?";
382    }
383  }
384
385  public enum DiagnosticOrderPriority {
386    /**
387     * The order has a normal priority .
388     */
389    ROUTINE,
390    /**
391     * The order should be urgently.
392     */
393    URGENT,
394    /**
395     * The order is time-critical.
396     */
397    STAT,
398    /**
399     * The order should be acted on as soon as possible.
400     */
401    ASAP,
402    /**
403     * added to help the parsers
404     */
405    NULL;
406
407    public static DiagnosticOrderPriority fromCode(String codeString) throws FHIRException {
408      if (codeString == null || "".equals(codeString))
409        return null;
410      if ("routine".equals(codeString))
411        return ROUTINE;
412      if ("urgent".equals(codeString))
413        return URGENT;
414      if ("stat".equals(codeString))
415        return STAT;
416      if ("asap".equals(codeString))
417        return ASAP;
418      throw new FHIRException("Unknown DiagnosticOrderPriority code '" + codeString + "'");
419    }
420
421    public String toCode() {
422      switch (this) {
423      case ROUTINE:
424        return "routine";
425      case URGENT:
426        return "urgent";
427      case STAT:
428        return "stat";
429      case ASAP:
430        return "asap";
431      case NULL:
432        return null;
433      default:
434        return "?";
435      }
436    }
437
438    public String getSystem() {
439      switch (this) {
440      case ROUTINE:
441        return "http://hl7.org/fhir/diagnostic-order-priority";
442      case URGENT:
443        return "http://hl7.org/fhir/diagnostic-order-priority";
444      case STAT:
445        return "http://hl7.org/fhir/diagnostic-order-priority";
446      case ASAP:
447        return "http://hl7.org/fhir/diagnostic-order-priority";
448      case NULL:
449        return null;
450      default:
451        return "?";
452      }
453    }
454
455    public String getDefinition() {
456      switch (this) {
457      case ROUTINE:
458        return "The order has a normal priority .";
459      case URGENT:
460        return "The order should be urgently.";
461      case STAT:
462        return "The order is time-critical.";
463      case ASAP:
464        return "The order should be acted on as soon as possible.";
465      case NULL:
466        return null;
467      default:
468        return "?";
469      }
470    }
471
472    public String getDisplay() {
473      switch (this) {
474      case ROUTINE:
475        return "Routine";
476      case URGENT:
477        return "Urgent";
478      case STAT:
479        return "Stat";
480      case ASAP:
481        return "ASAP";
482      case NULL:
483        return null;
484      default:
485        return "?";
486      }
487    }
488  }
489
490  public static class DiagnosticOrderPriorityEnumFactory implements EnumFactory<DiagnosticOrderPriority> {
491    public DiagnosticOrderPriority fromCode(String codeString) throws IllegalArgumentException {
492      if (codeString == null || "".equals(codeString))
493        if (codeString == null || "".equals(codeString))
494          return null;
495      if ("routine".equals(codeString))
496        return DiagnosticOrderPriority.ROUTINE;
497      if ("urgent".equals(codeString))
498        return DiagnosticOrderPriority.URGENT;
499      if ("stat".equals(codeString))
500        return DiagnosticOrderPriority.STAT;
501      if ("asap".equals(codeString))
502        return DiagnosticOrderPriority.ASAP;
503      throw new IllegalArgumentException("Unknown DiagnosticOrderPriority code '" + codeString + "'");
504    }
505
506    public Enumeration<DiagnosticOrderPriority> fromType(Base code) throws FHIRException {
507      if (code == null || code.isEmpty())
508        return null;
509      String codeString = ((PrimitiveType) code).asStringValue();
510      if (codeString == null || "".equals(codeString))
511        return null;
512      if ("routine".equals(codeString))
513        return new Enumeration<DiagnosticOrderPriority>(this, DiagnosticOrderPriority.ROUTINE);
514      if ("urgent".equals(codeString))
515        return new Enumeration<DiagnosticOrderPriority>(this, DiagnosticOrderPriority.URGENT);
516      if ("stat".equals(codeString))
517        return new Enumeration<DiagnosticOrderPriority>(this, DiagnosticOrderPriority.STAT);
518      if ("asap".equals(codeString))
519        return new Enumeration<DiagnosticOrderPriority>(this, DiagnosticOrderPriority.ASAP);
520      throw new FHIRException("Unknown DiagnosticOrderPriority code '" + codeString + "'");
521    }
522
523    public String toCode(DiagnosticOrderPriority code) {
524      if (code == DiagnosticOrderPriority.ROUTINE)
525        return "routine";
526      if (code == DiagnosticOrderPriority.URGENT)
527        return "urgent";
528      if (code == DiagnosticOrderPriority.STAT)
529        return "stat";
530      if (code == DiagnosticOrderPriority.ASAP)
531        return "asap";
532      return "?";
533    }
534  }
535
536  @Block()
537  public static class DiagnosticOrderEventComponent extends BackboneElement implements IBaseBackboneElement {
538    /**
539     * The status for the event.
540     */
541    @Child(name = "status", type = { CodeType.class }, order = 1, min = 1, max = 1, modifier = false, summary = true)
542    @Description(shortDefinition = "proposed | draft | planned | requested | received | accepted | in-progress | review | completed | cancelled | suspended | rejected | failed", formalDefinition = "The status for the event.")
543    protected Enumeration<DiagnosticOrderStatus> status;
544
545    /**
546     * Additional information about the event that occurred - e.g. if the status
547     * remained unchanged.
548     */
549    @Child(name = "description", type = {
550        CodeableConcept.class }, order = 2, min = 0, max = 1, modifier = false, summary = true)
551    @Description(shortDefinition = "More information about the event and its context", formalDefinition = "Additional information about the event that occurred - e.g. if the status remained unchanged.")
552    protected CodeableConcept description;
553
554    /**
555     * The date/time at which the event occurred.
556     */
557    @Child(name = "dateTime", type = {
558        DateTimeType.class }, order = 3, min = 1, max = 1, modifier = false, summary = true)
559    @Description(shortDefinition = "The date at which the event happened", formalDefinition = "The date/time at which the event occurred.")
560    protected DateTimeType dateTime;
561
562    /**
563     * The person responsible for performing or recording the action.
564     */
565    @Child(name = "actor", type = { Practitioner.class,
566        Device.class }, order = 4, min = 0, max = 1, modifier = false, summary = false)
567    @Description(shortDefinition = "Who recorded or did this", formalDefinition = "The person responsible for performing or recording the action.")
568    protected Reference actor;
569
570    /**
571     * The actual object that is the target of the reference (The person responsible
572     * for performing or recording the action.)
573     */
574    protected Resource actorTarget;
575
576    private static final long serialVersionUID = -370793723L;
577
578    /*
579     * Constructor
580     */
581    public DiagnosticOrderEventComponent() {
582      super();
583    }
584
585    /*
586     * Constructor
587     */
588    public DiagnosticOrderEventComponent(Enumeration<DiagnosticOrderStatus> status, DateTimeType dateTime) {
589      super();
590      this.status = status;
591      this.dateTime = dateTime;
592    }
593
594    /**
595     * @return {@link #status} (The status for the event.). This is the underlying
596     *         object with id, value and extensions. The accessor "getStatus" gives
597     *         direct access to the value
598     */
599    public Enumeration<DiagnosticOrderStatus> getStatusElement() {
600      if (this.status == null)
601        if (Configuration.errorOnAutoCreate())
602          throw new Error("Attempt to auto-create DiagnosticOrderEventComponent.status");
603        else if (Configuration.doAutoCreate())
604          this.status = new Enumeration<DiagnosticOrderStatus>(new DiagnosticOrderStatusEnumFactory()); // bb
605      return this.status;
606    }
607
608    public boolean hasStatusElement() {
609      return this.status != null && !this.status.isEmpty();
610    }
611
612    public boolean hasStatus() {
613      return this.status != null && !this.status.isEmpty();
614    }
615
616    /**
617     * @param value {@link #status} (The status for the event.). This is the
618     *              underlying object with id, value and extensions. The accessor
619     *              "getStatus" gives direct access to the value
620     */
621    public DiagnosticOrderEventComponent setStatusElement(Enumeration<DiagnosticOrderStatus> value) {
622      this.status = value;
623      return this;
624    }
625
626    /**
627     * @return The status for the event.
628     */
629    public DiagnosticOrderStatus getStatus() {
630      return this.status == null ? null : this.status.getValue();
631    }
632
633    /**
634     * @param value The status for the event.
635     */
636    public DiagnosticOrderEventComponent setStatus(DiagnosticOrderStatus value) {
637      if (this.status == null)
638        this.status = new Enumeration<DiagnosticOrderStatus>(new DiagnosticOrderStatusEnumFactory());
639      this.status.setValue(value);
640      return this;
641    }
642
643    /**
644     * @return {@link #description} (Additional information about the event that
645     *         occurred - e.g. if the status remained unchanged.)
646     */
647    public CodeableConcept getDescription() {
648      if (this.description == null)
649        if (Configuration.errorOnAutoCreate())
650          throw new Error("Attempt to auto-create DiagnosticOrderEventComponent.description");
651        else if (Configuration.doAutoCreate())
652          this.description = new CodeableConcept(); // cc
653      return this.description;
654    }
655
656    public boolean hasDescription() {
657      return this.description != null && !this.description.isEmpty();
658    }
659
660    /**
661     * @param value {@link #description} (Additional information about the event
662     *              that occurred - e.g. if the status remained unchanged.)
663     */
664    public DiagnosticOrderEventComponent setDescription(CodeableConcept value) {
665      this.description = value;
666      return this;
667    }
668
669    /**
670     * @return {@link #dateTime} (The date/time at which the event occurred.). This
671     *         is the underlying object with id, value and extensions. The accessor
672     *         "getDateTime" gives direct access to the value
673     */
674    public DateTimeType getDateTimeElement() {
675      if (this.dateTime == null)
676        if (Configuration.errorOnAutoCreate())
677          throw new Error("Attempt to auto-create DiagnosticOrderEventComponent.dateTime");
678        else if (Configuration.doAutoCreate())
679          this.dateTime = new DateTimeType(); // bb
680      return this.dateTime;
681    }
682
683    public boolean hasDateTimeElement() {
684      return this.dateTime != null && !this.dateTime.isEmpty();
685    }
686
687    public boolean hasDateTime() {
688      return this.dateTime != null && !this.dateTime.isEmpty();
689    }
690
691    /**
692     * @param value {@link #dateTime} (The date/time at which the event occurred.).
693     *              This is the underlying object with id, value and extensions. The
694     *              accessor "getDateTime" gives direct access to the value
695     */
696    public DiagnosticOrderEventComponent setDateTimeElement(DateTimeType value) {
697      this.dateTime = value;
698      return this;
699    }
700
701    /**
702     * @return The date/time at which the event occurred.
703     */
704    public Date getDateTime() {
705      return this.dateTime == null ? null : this.dateTime.getValue();
706    }
707
708    /**
709     * @param value The date/time at which the event occurred.
710     */
711    public DiagnosticOrderEventComponent setDateTime(Date value) {
712      if (this.dateTime == null)
713        this.dateTime = new DateTimeType();
714      this.dateTime.setValue(value);
715      return this;
716    }
717
718    /**
719     * @return {@link #actor} (The person responsible for performing or recording
720     *         the action.)
721     */
722    public Reference getActor() {
723      if (this.actor == null)
724        if (Configuration.errorOnAutoCreate())
725          throw new Error("Attempt to auto-create DiagnosticOrderEventComponent.actor");
726        else if (Configuration.doAutoCreate())
727          this.actor = new Reference(); // cc
728      return this.actor;
729    }
730
731    public boolean hasActor() {
732      return this.actor != null && !this.actor.isEmpty();
733    }
734
735    /**
736     * @param value {@link #actor} (The person responsible for performing or
737     *              recording the action.)
738     */
739    public DiagnosticOrderEventComponent setActor(Reference value) {
740      this.actor = value;
741      return this;
742    }
743
744    /**
745     * @return {@link #actor} The actual object that is the target of the reference.
746     *         The reference library doesn't populate this, but you can use it to
747     *         hold the resource if you resolve it. (The person responsible for
748     *         performing or recording the action.)
749     */
750    public Resource getActorTarget() {
751      return this.actorTarget;
752    }
753
754    /**
755     * @param value {@link #actor} The actual object that is the target of the
756     *              reference. The reference library doesn't use these, but you can
757     *              use it to hold the resource if you resolve it. (The person
758     *              responsible for performing or recording the action.)
759     */
760    public DiagnosticOrderEventComponent setActorTarget(Resource value) {
761      this.actorTarget = value;
762      return this;
763    }
764
765    protected void listChildren(List<Property> childrenList) {
766      super.listChildren(childrenList);
767      childrenList
768          .add(new Property("status", "code", "The status for the event.", 0, java.lang.Integer.MAX_VALUE, status));
769      childrenList.add(new Property("description", "CodeableConcept",
770          "Additional information about the event that occurred - e.g. if the status remained unchanged.", 0,
771          java.lang.Integer.MAX_VALUE, description));
772      childrenList.add(new Property("dateTime", "dateTime", "The date/time at which the event occurred.", 0,
773          java.lang.Integer.MAX_VALUE, dateTime));
774      childrenList.add(new Property("actor", "Reference(Practitioner|Device)",
775          "The person responsible for performing or recording the action.", 0, java.lang.Integer.MAX_VALUE, actor));
776    }
777
778    @Override
779    public void setProperty(String name, Base value) throws FHIRException {
780      if (name.equals("status"))
781        this.status = new DiagnosticOrderStatusEnumFactory().fromType(value); // Enumeration<DiagnosticOrderStatus>
782      else if (name.equals("description"))
783        this.description = castToCodeableConcept(value); // CodeableConcept
784      else if (name.equals("dateTime"))
785        this.dateTime = castToDateTime(value); // DateTimeType
786      else if (name.equals("actor"))
787        this.actor = castToReference(value); // Reference
788      else
789        super.setProperty(name, value);
790    }
791
792    @Override
793    public Base addChild(String name) throws FHIRException {
794      if (name.equals("status")) {
795        throw new FHIRException("Cannot call addChild on a singleton property DiagnosticOrder.status");
796      } else if (name.equals("description")) {
797        this.description = new CodeableConcept();
798        return this.description;
799      } else if (name.equals("dateTime")) {
800        throw new FHIRException("Cannot call addChild on a singleton property DiagnosticOrder.dateTime");
801      } else if (name.equals("actor")) {
802        this.actor = new Reference();
803        return this.actor;
804      } else
805        return super.addChild(name);
806    }
807
808    public DiagnosticOrderEventComponent copy() {
809      DiagnosticOrderEventComponent dst = new DiagnosticOrderEventComponent();
810      copyValues(dst);
811      dst.status = status == null ? null : status.copy();
812      dst.description = description == null ? null : description.copy();
813      dst.dateTime = dateTime == null ? null : dateTime.copy();
814      dst.actor = actor == null ? null : actor.copy();
815      return dst;
816    }
817
818    @Override
819    public boolean equalsDeep(Base other) {
820      if (!super.equalsDeep(other))
821        return false;
822      if (!(other instanceof DiagnosticOrderEventComponent))
823        return false;
824      DiagnosticOrderEventComponent o = (DiagnosticOrderEventComponent) other;
825      return compareDeep(status, o.status, true) && compareDeep(description, o.description, true)
826          && compareDeep(dateTime, o.dateTime, true) && compareDeep(actor, o.actor, true);
827    }
828
829    @Override
830    public boolean equalsShallow(Base other) {
831      if (!super.equalsShallow(other))
832        return false;
833      if (!(other instanceof DiagnosticOrderEventComponent))
834        return false;
835      DiagnosticOrderEventComponent o = (DiagnosticOrderEventComponent) other;
836      return compareValues(status, o.status, true) && compareValues(dateTime, o.dateTime, true);
837    }
838
839    public boolean isEmpty() {
840      return super.isEmpty() && (status == null || status.isEmpty()) && (description == null || description.isEmpty())
841          && (dateTime == null || dateTime.isEmpty()) && (actor == null || actor.isEmpty());
842    }
843
844    public String fhirType() {
845      return "DiagnosticOrder.event";
846
847    }
848
849  }
850
851  @Block()
852  public static class DiagnosticOrderItemComponent extends BackboneElement implements IBaseBackboneElement {
853    /**
854     * A code that identifies a particular diagnostic investigation, or panel of
855     * investigations, that have been requested.
856     */
857    @Child(name = "code", type = {
858        CodeableConcept.class }, order = 1, min = 1, max = 1, modifier = false, summary = true)
859    @Description(shortDefinition = "Code to indicate the item (test or panel) being ordered", formalDefinition = "A code that identifies a particular diagnostic investigation, or panel of investigations, that have been requested.")
860    protected CodeableConcept code;
861
862    /**
863     * If the item is related to a specific specimen.
864     */
865    @Child(name = "specimen", type = {
866        Specimen.class }, order = 2, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
867    @Description(shortDefinition = "If this item relates to specific specimens", formalDefinition = "If the item is related to a specific specimen.")
868    protected List<Reference> specimen;
869    /**
870     * The actual objects that are the target of the reference (If the item is
871     * related to a specific specimen.)
872     */
873    protected List<Specimen> specimenTarget;
874
875    /**
876     * Anatomical location where the request test should be performed. This is the
877     * target site.
878     */
879    @Child(name = "bodySite", type = {
880        CodeableConcept.class }, order = 3, min = 0, max = 1, modifier = false, summary = false)
881    @Description(shortDefinition = "Location of requested test (if applicable)", formalDefinition = "Anatomical location where the request test should be performed.  This is the target site.")
882    protected CodeableConcept bodySite;
883
884    /**
885     * The status of this individual item within the order.
886     */
887    @Child(name = "status", type = { CodeType.class }, order = 4, min = 0, max = 1, modifier = false, summary = true)
888    @Description(shortDefinition = "proposed | draft | planned | requested | received | accepted | in-progress | review | completed | cancelled | suspended | rejected | failed", formalDefinition = "The status of this individual item within the order.")
889    protected Enumeration<DiagnosticOrderStatus> status;
890
891    /**
892     * A summary of the events of interest that have occurred as this item of the
893     * request is processed.
894     */
895    @Child(name = "event", type = {
896        DiagnosticOrderEventComponent.class }, order = 5, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
897    @Description(shortDefinition = "Events specific to this item", formalDefinition = "A summary of the events of interest that have occurred as this item of the request is processed.")
898    protected List<DiagnosticOrderEventComponent> event;
899
900    private static final long serialVersionUID = 381238192L;
901
902    /*
903     * Constructor
904     */
905    public DiagnosticOrderItemComponent() {
906      super();
907    }
908
909    /*
910     * Constructor
911     */
912    public DiagnosticOrderItemComponent(CodeableConcept code) {
913      super();
914      this.code = code;
915    }
916
917    /**
918     * @return {@link #code} (A code that identifies a particular diagnostic
919     *         investigation, or panel of investigations, that have been requested.)
920     */
921    public CodeableConcept getCode() {
922      if (this.code == null)
923        if (Configuration.errorOnAutoCreate())
924          throw new Error("Attempt to auto-create DiagnosticOrderItemComponent.code");
925        else if (Configuration.doAutoCreate())
926          this.code = new CodeableConcept(); // cc
927      return this.code;
928    }
929
930    public boolean hasCode() {
931      return this.code != null && !this.code.isEmpty();
932    }
933
934    /**
935     * @param value {@link #code} (A code that identifies a particular diagnostic
936     *              investigation, or panel of investigations, that have been
937     *              requested.)
938     */
939    public DiagnosticOrderItemComponent setCode(CodeableConcept value) {
940      this.code = value;
941      return this;
942    }
943
944    /**
945     * @return {@link #specimen} (If the item is related to a specific specimen.)
946     */
947    public List<Reference> getSpecimen() {
948      if (this.specimen == null)
949        this.specimen = new ArrayList<Reference>();
950      return this.specimen;
951    }
952
953    public boolean hasSpecimen() {
954      if (this.specimen == null)
955        return false;
956      for (Reference item : this.specimen)
957        if (!item.isEmpty())
958          return true;
959      return false;
960    }
961
962    /**
963     * @return {@link #specimen} (If the item is related to a specific specimen.)
964     */
965    // syntactic sugar
966    public Reference addSpecimen() { // 3
967      Reference t = new Reference();
968      if (this.specimen == null)
969        this.specimen = new ArrayList<Reference>();
970      this.specimen.add(t);
971      return t;
972    }
973
974    // syntactic sugar
975    public DiagnosticOrderItemComponent addSpecimen(Reference t) { // 3
976      if (t == null)
977        return this;
978      if (this.specimen == null)
979        this.specimen = new ArrayList<Reference>();
980      this.specimen.add(t);
981      return this;
982    }
983
984    /**
985     * @return {@link #specimen} (The actual objects that are the target of the
986     *         reference. The reference library doesn't populate this, but you can
987     *         use this to hold the resources if you resolvethemt. If the item is
988     *         related to a specific specimen.)
989     */
990    public List<Specimen> getSpecimenTarget() {
991      if (this.specimenTarget == null)
992        this.specimenTarget = new ArrayList<Specimen>();
993      return this.specimenTarget;
994    }
995
996    // syntactic sugar
997    /**
998     * @return {@link #specimen} (Add an actual object that is the target of the
999     *         reference. The reference library doesn't use these, but you can use
1000     *         this to hold the resources if you resolvethemt. If the item is
1001     *         related to a specific specimen.)
1002     */
1003    public Specimen addSpecimenTarget() {
1004      Specimen r = new Specimen();
1005      if (this.specimenTarget == null)
1006        this.specimenTarget = new ArrayList<Specimen>();
1007      this.specimenTarget.add(r);
1008      return r;
1009    }
1010
1011    /**
1012     * @return {@link #bodySite} (Anatomical location where the request test should
1013     *         be performed. This is the target site.)
1014     */
1015    public CodeableConcept getBodySite() {
1016      if (this.bodySite == null)
1017        if (Configuration.errorOnAutoCreate())
1018          throw new Error("Attempt to auto-create DiagnosticOrderItemComponent.bodySite");
1019        else if (Configuration.doAutoCreate())
1020          this.bodySite = new CodeableConcept(); // cc
1021      return this.bodySite;
1022    }
1023
1024    public boolean hasBodySite() {
1025      return this.bodySite != null && !this.bodySite.isEmpty();
1026    }
1027
1028    /**
1029     * @param value {@link #bodySite} (Anatomical location where the request test
1030     *              should be performed. This is the target site.)
1031     */
1032    public DiagnosticOrderItemComponent setBodySite(CodeableConcept value) {
1033      this.bodySite = value;
1034      return this;
1035    }
1036
1037    /**
1038     * @return {@link #status} (The status of this individual item within the
1039     *         order.). This is the underlying object with id, value and extensions.
1040     *         The accessor "getStatus" gives direct access to the value
1041     */
1042    public Enumeration<DiagnosticOrderStatus> getStatusElement() {
1043      if (this.status == null)
1044        if (Configuration.errorOnAutoCreate())
1045          throw new Error("Attempt to auto-create DiagnosticOrderItemComponent.status");
1046        else if (Configuration.doAutoCreate())
1047          this.status = new Enumeration<DiagnosticOrderStatus>(new DiagnosticOrderStatusEnumFactory()); // bb
1048      return this.status;
1049    }
1050
1051    public boolean hasStatusElement() {
1052      return this.status != null && !this.status.isEmpty();
1053    }
1054
1055    public boolean hasStatus() {
1056      return this.status != null && !this.status.isEmpty();
1057    }
1058
1059    /**
1060     * @param value {@link #status} (The status of this individual item within the
1061     *              order.). This is the underlying object with id, value and
1062     *              extensions. The accessor "getStatus" gives direct access to the
1063     *              value
1064     */
1065    public DiagnosticOrderItemComponent setStatusElement(Enumeration<DiagnosticOrderStatus> value) {
1066      this.status = value;
1067      return this;
1068    }
1069
1070    /**
1071     * @return The status of this individual item within the order.
1072     */
1073    public DiagnosticOrderStatus getStatus() {
1074      return this.status == null ? null : this.status.getValue();
1075    }
1076
1077    /**
1078     * @param value The status of this individual item within the order.
1079     */
1080    public DiagnosticOrderItemComponent setStatus(DiagnosticOrderStatus value) {
1081      if (value == null)
1082        this.status = null;
1083      else {
1084        if (this.status == null)
1085          this.status = new Enumeration<DiagnosticOrderStatus>(new DiagnosticOrderStatusEnumFactory());
1086        this.status.setValue(value);
1087      }
1088      return this;
1089    }
1090
1091    /**
1092     * @return {@link #event} (A summary of the events of interest that have
1093     *         occurred as this item of the request is processed.)
1094     */
1095    public List<DiagnosticOrderEventComponent> getEvent() {
1096      if (this.event == null)
1097        this.event = new ArrayList<DiagnosticOrderEventComponent>();
1098      return this.event;
1099    }
1100
1101    public boolean hasEvent() {
1102      if (this.event == null)
1103        return false;
1104      for (DiagnosticOrderEventComponent item : this.event)
1105        if (!item.isEmpty())
1106          return true;
1107      return false;
1108    }
1109
1110    /**
1111     * @return {@link #event} (A summary of the events of interest that have
1112     *         occurred as this item of the request is processed.)
1113     */
1114    // syntactic sugar
1115    public DiagnosticOrderEventComponent addEvent() { // 3
1116      DiagnosticOrderEventComponent t = new DiagnosticOrderEventComponent();
1117      if (this.event == null)
1118        this.event = new ArrayList<DiagnosticOrderEventComponent>();
1119      this.event.add(t);
1120      return t;
1121    }
1122
1123    // syntactic sugar
1124    public DiagnosticOrderItemComponent addEvent(DiagnosticOrderEventComponent t) { // 3
1125      if (t == null)
1126        return this;
1127      if (this.event == null)
1128        this.event = new ArrayList<DiagnosticOrderEventComponent>();
1129      this.event.add(t);
1130      return this;
1131    }
1132
1133    protected void listChildren(List<Property> childrenList) {
1134      super.listChildren(childrenList);
1135      childrenList.add(new Property("code", "CodeableConcept",
1136          "A code that identifies a particular diagnostic investigation, or panel of investigations, that have been requested.",
1137          0, java.lang.Integer.MAX_VALUE, code));
1138      childrenList.add(new Property("specimen", "Reference(Specimen)", "If the item is related to a specific specimen.",
1139          0, java.lang.Integer.MAX_VALUE, specimen));
1140      childrenList.add(new Property("bodySite", "CodeableConcept",
1141          "Anatomical location where the request test should be performed.  This is the target site.", 0,
1142          java.lang.Integer.MAX_VALUE, bodySite));
1143      childrenList.add(new Property("status", "code", "The status of this individual item within the order.", 0,
1144          java.lang.Integer.MAX_VALUE, status));
1145      childrenList.add(new Property("event", "@DiagnosticOrder.event",
1146          "A summary of the events of interest that have occurred as this item of the request is processed.", 0,
1147          java.lang.Integer.MAX_VALUE, event));
1148    }
1149
1150    @Override
1151    public void setProperty(String name, Base value) throws FHIRException {
1152      if (name.equals("code"))
1153        this.code = castToCodeableConcept(value); // CodeableConcept
1154      else if (name.equals("specimen"))
1155        this.getSpecimen().add(castToReference(value));
1156      else if (name.equals("bodySite"))
1157        this.bodySite = castToCodeableConcept(value); // CodeableConcept
1158      else if (name.equals("status"))
1159        this.status = new DiagnosticOrderStatusEnumFactory().fromType(value); // Enumeration<DiagnosticOrderStatus>
1160      else if (name.equals("event"))
1161        this.getEvent().add((DiagnosticOrderEventComponent) value);
1162      else
1163        super.setProperty(name, value);
1164    }
1165
1166    @Override
1167    public Base addChild(String name) throws FHIRException {
1168      if (name.equals("code")) {
1169        this.code = new CodeableConcept();
1170        return this.code;
1171      } else if (name.equals("specimen")) {
1172        return addSpecimen();
1173      } else if (name.equals("bodySite")) {
1174        this.bodySite = new CodeableConcept();
1175        return this.bodySite;
1176      } else if (name.equals("status")) {
1177        throw new FHIRException("Cannot call addChild on a singleton property DiagnosticOrder.status");
1178      } else if (name.equals("event")) {
1179        return addEvent();
1180      } else
1181        return super.addChild(name);
1182    }
1183
1184    public DiagnosticOrderItemComponent copy() {
1185      DiagnosticOrderItemComponent dst = new DiagnosticOrderItemComponent();
1186      copyValues(dst);
1187      dst.code = code == null ? null : code.copy();
1188      if (specimen != null) {
1189        dst.specimen = new ArrayList<Reference>();
1190        for (Reference i : specimen)
1191          dst.specimen.add(i.copy());
1192      }
1193      ;
1194      dst.bodySite = bodySite == null ? null : bodySite.copy();
1195      dst.status = status == null ? null : status.copy();
1196      if (event != null) {
1197        dst.event = new ArrayList<DiagnosticOrderEventComponent>();
1198        for (DiagnosticOrderEventComponent i : event)
1199          dst.event.add(i.copy());
1200      }
1201      ;
1202      return dst;
1203    }
1204
1205    @Override
1206    public boolean equalsDeep(Base other) {
1207      if (!super.equalsDeep(other))
1208        return false;
1209      if (!(other instanceof DiagnosticOrderItemComponent))
1210        return false;
1211      DiagnosticOrderItemComponent o = (DiagnosticOrderItemComponent) other;
1212      return compareDeep(code, o.code, true) && compareDeep(specimen, o.specimen, true)
1213          && compareDeep(bodySite, o.bodySite, true) && compareDeep(status, o.status, true)
1214          && compareDeep(event, o.event, true);
1215    }
1216
1217    @Override
1218    public boolean equalsShallow(Base other) {
1219      if (!super.equalsShallow(other))
1220        return false;
1221      if (!(other instanceof DiagnosticOrderItemComponent))
1222        return false;
1223      DiagnosticOrderItemComponent o = (DiagnosticOrderItemComponent) other;
1224      return compareValues(status, o.status, true);
1225    }
1226
1227    public boolean isEmpty() {
1228      return super.isEmpty() && (code == null || code.isEmpty()) && (specimen == null || specimen.isEmpty())
1229          && (bodySite == null || bodySite.isEmpty()) && (status == null || status.isEmpty())
1230          && (event == null || event.isEmpty());
1231    }
1232
1233    public String fhirType() {
1234      return "DiagnosticOrder.item";
1235
1236    }
1237
1238  }
1239
1240  /**
1241   * Who or what the investigation is to be performed on. This is usually a human
1242   * patient, but diagnostic tests can also be requested on animals, groups of
1243   * humans or animals, devices such as dialysis machines, or even locations
1244   * (typically for environmental scans).
1245   */
1246  @Child(name = "subject", type = { Patient.class, Group.class, Location.class,
1247      Device.class }, order = 0, min = 1, max = 1, modifier = false, summary = true)
1248  @Description(shortDefinition = "Who and/or what test is about", formalDefinition = "Who or what the investigation is to be performed on. This is usually a human patient, but diagnostic tests can also be requested on animals, groups of humans or animals, devices such as dialysis machines, or even locations (typically for environmental scans).")
1249  protected Reference subject;
1250
1251  /**
1252   * The actual object that is the target of the reference (Who or what the
1253   * investigation is to be performed on. This is usually a human patient, but
1254   * diagnostic tests can also be requested on animals, groups of humans or
1255   * animals, devices such as dialysis machines, or even locations (typically for
1256   * environmental scans).)
1257   */
1258  protected Resource subjectTarget;
1259
1260  /**
1261   * The practitioner that holds legal responsibility for ordering the
1262   * investigation.
1263   */
1264  @Child(name = "orderer", type = { Practitioner.class }, order = 1, min = 0, max = 1, modifier = false, summary = true)
1265  @Description(shortDefinition = "Who ordered the test", formalDefinition = "The practitioner that holds legal responsibility for ordering the investigation.")
1266  protected Reference orderer;
1267
1268  /**
1269   * The actual object that is the target of the reference (The practitioner that
1270   * holds legal responsibility for ordering the investigation.)
1271   */
1272  protected Practitioner ordererTarget;
1273
1274  /**
1275   * Identifiers assigned to this order instance by the orderer and/or the
1276   * receiver and/or order fulfiller.
1277   */
1278  @Child(name = "identifier", type = {
1279      Identifier.class }, order = 2, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
1280  @Description(shortDefinition = "Identifiers assigned to this order", formalDefinition = "Identifiers assigned to this order instance by the orderer and/or  the receiver and/or order fulfiller.")
1281  protected List<Identifier> identifier;
1282
1283  /**
1284   * An encounter that provides additional information about the healthcare
1285   * context in which this request is made.
1286   */
1287  @Child(name = "encounter", type = { Encounter.class }, order = 3, min = 0, max = 1, modifier = false, summary = true)
1288  @Description(shortDefinition = "The encounter that this diagnostic order is associated with", formalDefinition = "An encounter that provides additional information about the healthcare context in which this request is made.")
1289  protected Reference encounter;
1290
1291  /**
1292   * The actual object that is the target of the reference (An encounter that
1293   * provides additional information about the healthcare context in which this
1294   * request is made.)
1295   */
1296  protected Encounter encounterTarget;
1297
1298  /**
1299   * An explanation or justification for why this diagnostic investigation is
1300   * being requested. This is often for billing purposes. May relate to the
1301   * resources referred to in supportingInformation.
1302   */
1303  @Child(name = "reason", type = {
1304      CodeableConcept.class }, order = 4, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
1305  @Description(shortDefinition = "Explanation/Justification for test", formalDefinition = "An explanation or justification for why this diagnostic investigation is being requested.   This is often for billing purposes.  May relate to the resources referred to in supportingInformation.")
1306  protected List<CodeableConcept> reason;
1307
1308  /**
1309   * Additional clinical information about the patient or specimen that may
1310   * influence test interpretations. This includes observations explicitly
1311   * requested by the producer(filler) to provide context or supporting
1312   * information needed to complete the order.
1313   */
1314  @Child(name = "supportingInformation", type = { Observation.class, Condition.class,
1315      DocumentReference.class }, order = 5, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
1316  @Description(shortDefinition = "Additional clinical information", formalDefinition = "Additional clinical information about the patient or specimen that may influence test interpretations.  This includes observations explicitly requested by the producer(filler) to provide context or supporting information needed to complete the order.")
1317  protected List<Reference> supportingInformation;
1318  /**
1319   * The actual objects that are the target of the reference (Additional clinical
1320   * information about the patient or specimen that may influence test
1321   * interpretations. This includes observations explicitly requested by the
1322   * producer(filler) to provide context or supporting information needed to
1323   * complete the order.)
1324   */
1325  protected List<Resource> supportingInformationTarget;
1326
1327  /**
1328   * One or more specimens that the diagnostic investigation is about.
1329   */
1330  @Child(name = "specimen", type = {
1331      Specimen.class }, order = 6, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
1332  @Description(shortDefinition = "If the whole order relates to specific specimens", formalDefinition = "One or more specimens that the diagnostic investigation is about.")
1333  protected List<Reference> specimen;
1334  /**
1335   * The actual objects that are the target of the reference (One or more
1336   * specimens that the diagnostic investigation is about.)
1337   */
1338  protected List<Specimen> specimenTarget;
1339
1340  /**
1341   * The status of the order.
1342   */
1343  @Child(name = "status", type = { CodeType.class }, order = 7, min = 0, max = 1, modifier = true, summary = true)
1344  @Description(shortDefinition = "proposed | draft | planned | requested | received | accepted | in-progress | review | completed | cancelled | suspended | rejected | failed", formalDefinition = "The status of the order.")
1345  protected Enumeration<DiagnosticOrderStatus> status;
1346
1347  /**
1348   * The clinical priority associated with this order.
1349   */
1350  @Child(name = "priority", type = { CodeType.class }, order = 8, min = 0, max = 1, modifier = false, summary = true)
1351  @Description(shortDefinition = "routine | urgent | stat | asap", formalDefinition = "The clinical priority associated with this order.")
1352  protected Enumeration<DiagnosticOrderPriority> priority;
1353
1354  /**
1355   * A summary of the events of interest that have occurred as the request is
1356   * processed; e.g. when the order was made, various processing steps (specimens
1357   * received), when it was completed.
1358   */
1359  @Child(name = "event", type = {}, order = 9, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
1360  @Description(shortDefinition = "A list of events of interest in the lifecycle", formalDefinition = "A summary of the events of interest that have occurred as the request is processed; e.g. when the order was made, various processing steps (specimens received), when it was completed.")
1361  protected List<DiagnosticOrderEventComponent> event;
1362
1363  /**
1364   * The specific diagnostic investigations that are requested as part of this
1365   * request. Sometimes, there can only be one item per request, but in most
1366   * contexts, more than one investigation can be requested.
1367   */
1368  @Child(name = "item", type = {}, order = 10, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
1369  @Description(shortDefinition = "The items the orderer requested", formalDefinition = "The specific diagnostic investigations that are requested as part of this request. Sometimes, there can only be one item per request, but in most contexts, more than one investigation can be requested.")
1370  protected List<DiagnosticOrderItemComponent> item;
1371
1372  /**
1373   * Any other notes associated with this patient, specimen or order (e.g.
1374   * "patient hates needles").
1375   */
1376  @Child(name = "note", type = {
1377      Annotation.class }, order = 11, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
1378  @Description(shortDefinition = "Other notes and comments", formalDefinition = "Any other notes associated with this patient, specimen or order (e.g. \"patient hates needles\").")
1379  protected List<Annotation> note;
1380
1381  private static final long serialVersionUID = 700891227L;
1382
1383  /*
1384   * Constructor
1385   */
1386  public DiagnosticOrder() {
1387    super();
1388  }
1389
1390  /*
1391   * Constructor
1392   */
1393  public DiagnosticOrder(Reference subject) {
1394    super();
1395    this.subject = subject;
1396  }
1397
1398  /**
1399   * @return {@link #subject} (Who or what the investigation is to be performed
1400   *         on. This is usually a human patient, but diagnostic tests can also be
1401   *         requested on animals, groups of humans or animals, devices such as
1402   *         dialysis machines, or even locations (typically for environmental
1403   *         scans).)
1404   */
1405  public Reference getSubject() {
1406    if (this.subject == null)
1407      if (Configuration.errorOnAutoCreate())
1408        throw new Error("Attempt to auto-create DiagnosticOrder.subject");
1409      else if (Configuration.doAutoCreate())
1410        this.subject = new Reference(); // cc
1411    return this.subject;
1412  }
1413
1414  public boolean hasSubject() {
1415    return this.subject != null && !this.subject.isEmpty();
1416  }
1417
1418  /**
1419   * @param value {@link #subject} (Who or what the investigation is to be
1420   *              performed on. This is usually a human patient, but diagnostic
1421   *              tests can also be requested on animals, groups of humans or
1422   *              animals, devices such as dialysis machines, or even locations
1423   *              (typically for environmental scans).)
1424   */
1425  public DiagnosticOrder setSubject(Reference value) {
1426    this.subject = value;
1427    return this;
1428  }
1429
1430  /**
1431   * @return {@link #subject} The actual object that is the target of the
1432   *         reference. The reference library doesn't populate this, but you can
1433   *         use it to hold the resource if you resolve it. (Who or what the
1434   *         investigation is to be performed on. This is usually a human patient,
1435   *         but diagnostic tests can also be requested on animals, groups of
1436   *         humans or animals, devices such as dialysis machines, or even
1437   *         locations (typically for environmental scans).)
1438   */
1439  public Resource getSubjectTarget() {
1440    return this.subjectTarget;
1441  }
1442
1443  /**
1444   * @param value {@link #subject} The actual object that is the target of the
1445   *              reference. The reference library doesn't use these, but you can
1446   *              use it to hold the resource if you resolve it. (Who or what the
1447   *              investigation is to be performed on. This is usually a human
1448   *              patient, but diagnostic tests can also be requested on animals,
1449   *              groups of humans or animals, devices such as dialysis machines,
1450   *              or even locations (typically for environmental scans).)
1451   */
1452  public DiagnosticOrder setSubjectTarget(Resource value) {
1453    this.subjectTarget = value;
1454    return this;
1455  }
1456
1457  /**
1458   * @return {@link #orderer} (The practitioner that holds legal responsibility
1459   *         for ordering the investigation.)
1460   */
1461  public Reference getOrderer() {
1462    if (this.orderer == null)
1463      if (Configuration.errorOnAutoCreate())
1464        throw new Error("Attempt to auto-create DiagnosticOrder.orderer");
1465      else if (Configuration.doAutoCreate())
1466        this.orderer = new Reference(); // cc
1467    return this.orderer;
1468  }
1469
1470  public boolean hasOrderer() {
1471    return this.orderer != null && !this.orderer.isEmpty();
1472  }
1473
1474  /**
1475   * @param value {@link #orderer} (The practitioner that holds legal
1476   *              responsibility for ordering the investigation.)
1477   */
1478  public DiagnosticOrder setOrderer(Reference value) {
1479    this.orderer = value;
1480    return this;
1481  }
1482
1483  /**
1484   * @return {@link #orderer} The actual object that is the target of the
1485   *         reference. The reference library doesn't populate this, but you can
1486   *         use it to hold the resource if you resolve it. (The practitioner that
1487   *         holds legal responsibility for ordering the investigation.)
1488   */
1489  public Practitioner getOrdererTarget() {
1490    if (this.ordererTarget == null)
1491      if (Configuration.errorOnAutoCreate())
1492        throw new Error("Attempt to auto-create DiagnosticOrder.orderer");
1493      else if (Configuration.doAutoCreate())
1494        this.ordererTarget = new Practitioner(); // aa
1495    return this.ordererTarget;
1496  }
1497
1498  /**
1499   * @param value {@link #orderer} The actual object that is the target of the
1500   *              reference. The reference library doesn't use these, but you can
1501   *              use it to hold the resource if you resolve it. (The practitioner
1502   *              that holds legal responsibility for ordering the investigation.)
1503   */
1504  public DiagnosticOrder setOrdererTarget(Practitioner value) {
1505    this.ordererTarget = value;
1506    return this;
1507  }
1508
1509  /**
1510   * @return {@link #identifier} (Identifiers assigned to this order instance by
1511   *         the orderer and/or the receiver and/or order fulfiller.)
1512   */
1513  public List<Identifier> getIdentifier() {
1514    if (this.identifier == null)
1515      this.identifier = new ArrayList<Identifier>();
1516    return this.identifier;
1517  }
1518
1519  public boolean hasIdentifier() {
1520    if (this.identifier == null)
1521      return false;
1522    for (Identifier item : this.identifier)
1523      if (!item.isEmpty())
1524        return true;
1525    return false;
1526  }
1527
1528  /**
1529   * @return {@link #identifier} (Identifiers assigned to this order instance by
1530   *         the orderer and/or the receiver and/or order fulfiller.)
1531   */
1532  // syntactic sugar
1533  public Identifier addIdentifier() { // 3
1534    Identifier t = new Identifier();
1535    if (this.identifier == null)
1536      this.identifier = new ArrayList<Identifier>();
1537    this.identifier.add(t);
1538    return t;
1539  }
1540
1541  // syntactic sugar
1542  public DiagnosticOrder addIdentifier(Identifier t) { // 3
1543    if (t == null)
1544      return this;
1545    if (this.identifier == null)
1546      this.identifier = new ArrayList<Identifier>();
1547    this.identifier.add(t);
1548    return this;
1549  }
1550
1551  /**
1552   * @return {@link #encounter} (An encounter that provides additional information
1553   *         about the healthcare context in which this request is made.)
1554   */
1555  public Reference getEncounter() {
1556    if (this.encounter == null)
1557      if (Configuration.errorOnAutoCreate())
1558        throw new Error("Attempt to auto-create DiagnosticOrder.encounter");
1559      else if (Configuration.doAutoCreate())
1560        this.encounter = new Reference(); // cc
1561    return this.encounter;
1562  }
1563
1564  public boolean hasEncounter() {
1565    return this.encounter != null && !this.encounter.isEmpty();
1566  }
1567
1568  /**
1569   * @param value {@link #encounter} (An encounter that provides additional
1570   *              information about the healthcare context in which this request
1571   *              is made.)
1572   */
1573  public DiagnosticOrder setEncounter(Reference value) {
1574    this.encounter = value;
1575    return this;
1576  }
1577
1578  /**
1579   * @return {@link #encounter} The actual object that is the target of the
1580   *         reference. The reference library doesn't populate this, but you can
1581   *         use it to hold the resource if you resolve it. (An encounter that
1582   *         provides additional information about the healthcare context in which
1583   *         this request is made.)
1584   */
1585  public Encounter getEncounterTarget() {
1586    if (this.encounterTarget == null)
1587      if (Configuration.errorOnAutoCreate())
1588        throw new Error("Attempt to auto-create DiagnosticOrder.encounter");
1589      else if (Configuration.doAutoCreate())
1590        this.encounterTarget = new Encounter(); // aa
1591    return this.encounterTarget;
1592  }
1593
1594  /**
1595   * @param value {@link #encounter} The actual object that is the target of the
1596   *              reference. The reference library doesn't use these, but you can
1597   *              use it to hold the resource if you resolve it. (An encounter
1598   *              that provides additional information about the healthcare
1599   *              context in which this request is made.)
1600   */
1601  public DiagnosticOrder setEncounterTarget(Encounter value) {
1602    this.encounterTarget = value;
1603    return this;
1604  }
1605
1606  /**
1607   * @return {@link #reason} (An explanation or justification for why this
1608   *         diagnostic investigation is being requested. This is often for
1609   *         billing purposes. May relate to the resources referred to in
1610   *         supportingInformation.)
1611   */
1612  public List<CodeableConcept> getReason() {
1613    if (this.reason == null)
1614      this.reason = new ArrayList<CodeableConcept>();
1615    return this.reason;
1616  }
1617
1618  public boolean hasReason() {
1619    if (this.reason == null)
1620      return false;
1621    for (CodeableConcept item : this.reason)
1622      if (!item.isEmpty())
1623        return true;
1624    return false;
1625  }
1626
1627  /**
1628   * @return {@link #reason} (An explanation or justification for why this
1629   *         diagnostic investigation is being requested. This is often for
1630   *         billing purposes. May relate to the resources referred to in
1631   *         supportingInformation.)
1632   */
1633  // syntactic sugar
1634  public CodeableConcept addReason() { // 3
1635    CodeableConcept t = new CodeableConcept();
1636    if (this.reason == null)
1637      this.reason = new ArrayList<CodeableConcept>();
1638    this.reason.add(t);
1639    return t;
1640  }
1641
1642  // syntactic sugar
1643  public DiagnosticOrder addReason(CodeableConcept t) { // 3
1644    if (t == null)
1645      return this;
1646    if (this.reason == null)
1647      this.reason = new ArrayList<CodeableConcept>();
1648    this.reason.add(t);
1649    return this;
1650  }
1651
1652  /**
1653   * @return {@link #supportingInformation} (Additional clinical information about
1654   *         the patient or specimen that may influence test interpretations. This
1655   *         includes observations explicitly requested by the producer(filler) to
1656   *         provide context or supporting information needed to complete the
1657   *         order.)
1658   */
1659  public List<Reference> getSupportingInformation() {
1660    if (this.supportingInformation == null)
1661      this.supportingInformation = new ArrayList<Reference>();
1662    return this.supportingInformation;
1663  }
1664
1665  public boolean hasSupportingInformation() {
1666    if (this.supportingInformation == null)
1667      return false;
1668    for (Reference item : this.supportingInformation)
1669      if (!item.isEmpty())
1670        return true;
1671    return false;
1672  }
1673
1674  /**
1675   * @return {@link #supportingInformation} (Additional clinical information about
1676   *         the patient or specimen that may influence test interpretations. This
1677   *         includes observations explicitly requested by the producer(filler) to
1678   *         provide context or supporting information needed to complete the
1679   *         order.)
1680   */
1681  // syntactic sugar
1682  public Reference addSupportingInformation() { // 3
1683    Reference t = new Reference();
1684    if (this.supportingInformation == null)
1685      this.supportingInformation = new ArrayList<Reference>();
1686    this.supportingInformation.add(t);
1687    return t;
1688  }
1689
1690  // syntactic sugar
1691  public DiagnosticOrder addSupportingInformation(Reference t) { // 3
1692    if (t == null)
1693      return this;
1694    if (this.supportingInformation == null)
1695      this.supportingInformation = new ArrayList<Reference>();
1696    this.supportingInformation.add(t);
1697    return this;
1698  }
1699
1700  /**
1701   * @return {@link #supportingInformation} (The actual objects that are the
1702   *         target of the reference. The reference library doesn't populate this,
1703   *         but you can use this to hold the resources if you resolvethemt.
1704   *         Additional clinical information about the patient or specimen that
1705   *         may influence test interpretations. This includes observations
1706   *         explicitly requested by the producer(filler) to provide context or
1707   *         supporting information needed to complete the order.)
1708   */
1709  public List<Resource> getSupportingInformationTarget() {
1710    if (this.supportingInformationTarget == null)
1711      this.supportingInformationTarget = new ArrayList<Resource>();
1712    return this.supportingInformationTarget;
1713  }
1714
1715  /**
1716   * @return {@link #specimen} (One or more specimens that the diagnostic
1717   *         investigation is about.)
1718   */
1719  public List<Reference> getSpecimen() {
1720    if (this.specimen == null)
1721      this.specimen = new ArrayList<Reference>();
1722    return this.specimen;
1723  }
1724
1725  public boolean hasSpecimen() {
1726    if (this.specimen == null)
1727      return false;
1728    for (Reference item : this.specimen)
1729      if (!item.isEmpty())
1730        return true;
1731    return false;
1732  }
1733
1734  /**
1735   * @return {@link #specimen} (One or more specimens that the diagnostic
1736   *         investigation is about.)
1737   */
1738  // syntactic sugar
1739  public Reference addSpecimen() { // 3
1740    Reference t = new Reference();
1741    if (this.specimen == null)
1742      this.specimen = new ArrayList<Reference>();
1743    this.specimen.add(t);
1744    return t;
1745  }
1746
1747  // syntactic sugar
1748  public DiagnosticOrder addSpecimen(Reference t) { // 3
1749    if (t == null)
1750      return this;
1751    if (this.specimen == null)
1752      this.specimen = new ArrayList<Reference>();
1753    this.specimen.add(t);
1754    return this;
1755  }
1756
1757  /**
1758   * @return {@link #specimen} (The actual objects that are the target of the
1759   *         reference. The reference library doesn't populate this, but you can
1760   *         use this to hold the resources if you resolvethemt. One or more
1761   *         specimens that the diagnostic investigation is about.)
1762   */
1763  public List<Specimen> getSpecimenTarget() {
1764    if (this.specimenTarget == null)
1765      this.specimenTarget = new ArrayList<Specimen>();
1766    return this.specimenTarget;
1767  }
1768
1769  // syntactic sugar
1770  /**
1771   * @return {@link #specimen} (Add an actual object that is the target of the
1772   *         reference. The reference library doesn't use these, but you can use
1773   *         this to hold the resources if you resolvethemt. One or more specimens
1774   *         that the diagnostic investigation is about.)
1775   */
1776  public Specimen addSpecimenTarget() {
1777    Specimen r = new Specimen();
1778    if (this.specimenTarget == null)
1779      this.specimenTarget = new ArrayList<Specimen>();
1780    this.specimenTarget.add(r);
1781    return r;
1782  }
1783
1784  /**
1785   * @return {@link #status} (The status of the order.). This is the underlying
1786   *         object with id, value and extensions. The accessor "getStatus" gives
1787   *         direct access to the value
1788   */
1789  public Enumeration<DiagnosticOrderStatus> getStatusElement() {
1790    if (this.status == null)
1791      if (Configuration.errorOnAutoCreate())
1792        throw new Error("Attempt to auto-create DiagnosticOrder.status");
1793      else if (Configuration.doAutoCreate())
1794        this.status = new Enumeration<DiagnosticOrderStatus>(new DiagnosticOrderStatusEnumFactory()); // bb
1795    return this.status;
1796  }
1797
1798  public boolean hasStatusElement() {
1799    return this.status != null && !this.status.isEmpty();
1800  }
1801
1802  public boolean hasStatus() {
1803    return this.status != null && !this.status.isEmpty();
1804  }
1805
1806  /**
1807   * @param value {@link #status} (The status of the order.). This is the
1808   *              underlying object with id, value and extensions. The accessor
1809   *              "getStatus" gives direct access to the value
1810   */
1811  public DiagnosticOrder setStatusElement(Enumeration<DiagnosticOrderStatus> value) {
1812    this.status = value;
1813    return this;
1814  }
1815
1816  /**
1817   * @return The status of the order.
1818   */
1819  public DiagnosticOrderStatus getStatus() {
1820    return this.status == null ? null : this.status.getValue();
1821  }
1822
1823  /**
1824   * @param value The status of the order.
1825   */
1826  public DiagnosticOrder setStatus(DiagnosticOrderStatus value) {
1827    if (value == null)
1828      this.status = null;
1829    else {
1830      if (this.status == null)
1831        this.status = new Enumeration<DiagnosticOrderStatus>(new DiagnosticOrderStatusEnumFactory());
1832      this.status.setValue(value);
1833    }
1834    return this;
1835  }
1836
1837  /**
1838   * @return {@link #priority} (The clinical priority associated with this
1839   *         order.). This is the underlying object with id, value and extensions.
1840   *         The accessor "getPriority" gives direct access to the value
1841   */
1842  public Enumeration<DiagnosticOrderPriority> getPriorityElement() {
1843    if (this.priority == null)
1844      if (Configuration.errorOnAutoCreate())
1845        throw new Error("Attempt to auto-create DiagnosticOrder.priority");
1846      else if (Configuration.doAutoCreate())
1847        this.priority = new Enumeration<DiagnosticOrderPriority>(new DiagnosticOrderPriorityEnumFactory()); // bb
1848    return this.priority;
1849  }
1850
1851  public boolean hasPriorityElement() {
1852    return this.priority != null && !this.priority.isEmpty();
1853  }
1854
1855  public boolean hasPriority() {
1856    return this.priority != null && !this.priority.isEmpty();
1857  }
1858
1859  /**
1860   * @param value {@link #priority} (The clinical priority associated with this
1861   *              order.). This is the underlying object with id, value and
1862   *              extensions. The accessor "getPriority" gives direct access to
1863   *              the value
1864   */
1865  public DiagnosticOrder setPriorityElement(Enumeration<DiagnosticOrderPriority> value) {
1866    this.priority = value;
1867    return this;
1868  }
1869
1870  /**
1871   * @return The clinical priority associated with this order.
1872   */
1873  public DiagnosticOrderPriority getPriority() {
1874    return this.priority == null ? null : this.priority.getValue();
1875  }
1876
1877  /**
1878   * @param value The clinical priority associated with this order.
1879   */
1880  public DiagnosticOrder setPriority(DiagnosticOrderPriority value) {
1881    if (value == null)
1882      this.priority = null;
1883    else {
1884      if (this.priority == null)
1885        this.priority = new Enumeration<DiagnosticOrderPriority>(new DiagnosticOrderPriorityEnumFactory());
1886      this.priority.setValue(value);
1887    }
1888    return this;
1889  }
1890
1891  /**
1892   * @return {@link #event} (A summary of the events of interest that have
1893   *         occurred as the request is processed; e.g. when the order was made,
1894   *         various processing steps (specimens received), when it was
1895   *         completed.)
1896   */
1897  public List<DiagnosticOrderEventComponent> getEvent() {
1898    if (this.event == null)
1899      this.event = new ArrayList<DiagnosticOrderEventComponent>();
1900    return this.event;
1901  }
1902
1903  public boolean hasEvent() {
1904    if (this.event == null)
1905      return false;
1906    for (DiagnosticOrderEventComponent item : this.event)
1907      if (!item.isEmpty())
1908        return true;
1909    return false;
1910  }
1911
1912  /**
1913   * @return {@link #event} (A summary of the events of interest that have
1914   *         occurred as the request is processed; e.g. when the order was made,
1915   *         various processing steps (specimens received), when it was
1916   *         completed.)
1917   */
1918  // syntactic sugar
1919  public DiagnosticOrderEventComponent addEvent() { // 3
1920    DiagnosticOrderEventComponent t = new DiagnosticOrderEventComponent();
1921    if (this.event == null)
1922      this.event = new ArrayList<DiagnosticOrderEventComponent>();
1923    this.event.add(t);
1924    return t;
1925  }
1926
1927  // syntactic sugar
1928  public DiagnosticOrder addEvent(DiagnosticOrderEventComponent t) { // 3
1929    if (t == null)
1930      return this;
1931    if (this.event == null)
1932      this.event = new ArrayList<DiagnosticOrderEventComponent>();
1933    this.event.add(t);
1934    return this;
1935  }
1936
1937  /**
1938   * @return {@link #item} (The specific diagnostic investigations that are
1939   *         requested as part of this request. Sometimes, there can only be one
1940   *         item per request, but in most contexts, more than one investigation
1941   *         can be requested.)
1942   */
1943  public List<DiagnosticOrderItemComponent> getItem() {
1944    if (this.item == null)
1945      this.item = new ArrayList<DiagnosticOrderItemComponent>();
1946    return this.item;
1947  }
1948
1949  public boolean hasItem() {
1950    if (this.item == null)
1951      return false;
1952    for (DiagnosticOrderItemComponent item : this.item)
1953      if (!item.isEmpty())
1954        return true;
1955    return false;
1956  }
1957
1958  /**
1959   * @return {@link #item} (The specific diagnostic investigations that are
1960   *         requested as part of this request. Sometimes, there can only be one
1961   *         item per request, but in most contexts, more than one investigation
1962   *         can be requested.)
1963   */
1964  // syntactic sugar
1965  public DiagnosticOrderItemComponent addItem() { // 3
1966    DiagnosticOrderItemComponent t = new DiagnosticOrderItemComponent();
1967    if (this.item == null)
1968      this.item = new ArrayList<DiagnosticOrderItemComponent>();
1969    this.item.add(t);
1970    return t;
1971  }
1972
1973  // syntactic sugar
1974  public DiagnosticOrder addItem(DiagnosticOrderItemComponent t) { // 3
1975    if (t == null)
1976      return this;
1977    if (this.item == null)
1978      this.item = new ArrayList<DiagnosticOrderItemComponent>();
1979    this.item.add(t);
1980    return this;
1981  }
1982
1983  /**
1984   * @return {@link #note} (Any other notes associated with this patient, specimen
1985   *         or order (e.g. "patient hates needles").)
1986   */
1987  public List<Annotation> getNote() {
1988    if (this.note == null)
1989      this.note = new ArrayList<Annotation>();
1990    return this.note;
1991  }
1992
1993  public boolean hasNote() {
1994    if (this.note == null)
1995      return false;
1996    for (Annotation item : this.note)
1997      if (!item.isEmpty())
1998        return true;
1999    return false;
2000  }
2001
2002  /**
2003   * @return {@link #note} (Any other notes associated with this patient, specimen
2004   *         or order (e.g. "patient hates needles").)
2005   */
2006  // syntactic sugar
2007  public Annotation addNote() { // 3
2008    Annotation t = new Annotation();
2009    if (this.note == null)
2010      this.note = new ArrayList<Annotation>();
2011    this.note.add(t);
2012    return t;
2013  }
2014
2015  // syntactic sugar
2016  public DiagnosticOrder addNote(Annotation t) { // 3
2017    if (t == null)
2018      return this;
2019    if (this.note == null)
2020      this.note = new ArrayList<Annotation>();
2021    this.note.add(t);
2022    return this;
2023  }
2024
2025  protected void listChildren(List<Property> childrenList) {
2026    super.listChildren(childrenList);
2027    childrenList.add(new Property("subject", "Reference(Patient|Group|Location|Device)",
2028        "Who or what the investigation is to be performed on. This is usually a human patient, but diagnostic tests can also be requested on animals, groups of humans or animals, devices such as dialysis machines, or even locations (typically for environmental scans).",
2029        0, java.lang.Integer.MAX_VALUE, subject));
2030    childrenList.add(new Property("orderer", "Reference(Practitioner)",
2031        "The practitioner that holds legal responsibility for ordering the investigation.", 0,
2032        java.lang.Integer.MAX_VALUE, orderer));
2033    childrenList.add(new Property("identifier", "Identifier",
2034        "Identifiers assigned to this order instance by the orderer and/or  the receiver and/or order fulfiller.", 0,
2035        java.lang.Integer.MAX_VALUE, identifier));
2036    childrenList.add(new Property("encounter", "Reference(Encounter)",
2037        "An encounter that provides additional information about the healthcare context in which this request is made.",
2038        0, java.lang.Integer.MAX_VALUE, encounter));
2039    childrenList.add(new Property("reason", "CodeableConcept",
2040        "An explanation or justification for why this diagnostic investigation is being requested.   This is often for billing purposes.  May relate to the resources referred to in supportingInformation.",
2041        0, java.lang.Integer.MAX_VALUE, reason));
2042    childrenList.add(new Property("supportingInformation", "Reference(Observation|Condition|DocumentReference)",
2043        "Additional clinical information about the patient or specimen that may influence test interpretations.  This includes observations explicitly requested by the producer(filler) to provide context or supporting information needed to complete the order.",
2044        0, java.lang.Integer.MAX_VALUE, supportingInformation));
2045    childrenList.add(new Property("specimen", "Reference(Specimen)",
2046        "One or more specimens that the diagnostic investigation is about.", 0, java.lang.Integer.MAX_VALUE, specimen));
2047    childrenList
2048        .add(new Property("status", "code", "The status of the order.", 0, java.lang.Integer.MAX_VALUE, status));
2049    childrenList.add(new Property("priority", "code", "The clinical priority associated with this order.", 0,
2050        java.lang.Integer.MAX_VALUE, priority));
2051    childrenList.add(new Property("event", "",
2052        "A summary of the events of interest that have occurred as the request is processed; e.g. when the order was made, various processing steps (specimens received), when it was completed.",
2053        0, java.lang.Integer.MAX_VALUE, event));
2054    childrenList.add(new Property("item", "",
2055        "The specific diagnostic investigations that are requested as part of this request. Sometimes, there can only be one item per request, but in most contexts, more than one investigation can be requested.",
2056        0, java.lang.Integer.MAX_VALUE, item));
2057    childrenList.add(new Property("note", "Annotation",
2058        "Any other notes associated with this patient, specimen or order (e.g. \"patient hates needles\").", 0,
2059        java.lang.Integer.MAX_VALUE, note));
2060  }
2061
2062  @Override
2063  public void setProperty(String name, Base value) throws FHIRException {
2064    if (name.equals("subject"))
2065      this.subject = castToReference(value); // Reference
2066    else if (name.equals("orderer"))
2067      this.orderer = castToReference(value); // Reference
2068    else if (name.equals("identifier"))
2069      this.getIdentifier().add(castToIdentifier(value));
2070    else if (name.equals("encounter"))
2071      this.encounter = castToReference(value); // Reference
2072    else if (name.equals("reason"))
2073      this.getReason().add(castToCodeableConcept(value));
2074    else if (name.equals("supportingInformation"))
2075      this.getSupportingInformation().add(castToReference(value));
2076    else if (name.equals("specimen"))
2077      this.getSpecimen().add(castToReference(value));
2078    else if (name.equals("status"))
2079      this.status = new DiagnosticOrderStatusEnumFactory().fromType(value); // Enumeration<DiagnosticOrderStatus>
2080    else if (name.equals("priority"))
2081      this.priority = new DiagnosticOrderPriorityEnumFactory().fromType(value); // Enumeration<DiagnosticOrderPriority>
2082    else if (name.equals("event"))
2083      this.getEvent().add((DiagnosticOrderEventComponent) value);
2084    else if (name.equals("item"))
2085      this.getItem().add((DiagnosticOrderItemComponent) value);
2086    else if (name.equals("note"))
2087      this.getNote().add(castToAnnotation(value));
2088    else
2089      super.setProperty(name, value);
2090  }
2091
2092  @Override
2093  public Base addChild(String name) throws FHIRException {
2094    if (name.equals("subject")) {
2095      this.subject = new Reference();
2096      return this.subject;
2097    } else if (name.equals("orderer")) {
2098      this.orderer = new Reference();
2099      return this.orderer;
2100    } else if (name.equals("identifier")) {
2101      return addIdentifier();
2102    } else if (name.equals("encounter")) {
2103      this.encounter = new Reference();
2104      return this.encounter;
2105    } else if (name.equals("reason")) {
2106      return addReason();
2107    } else if (name.equals("supportingInformation")) {
2108      return addSupportingInformation();
2109    } else if (name.equals("specimen")) {
2110      return addSpecimen();
2111    } else if (name.equals("status")) {
2112      throw new FHIRException("Cannot call addChild on a singleton property DiagnosticOrder.status");
2113    } else if (name.equals("priority")) {
2114      throw new FHIRException("Cannot call addChild on a singleton property DiagnosticOrder.priority");
2115    } else if (name.equals("event")) {
2116      return addEvent();
2117    } else if (name.equals("item")) {
2118      return addItem();
2119    } else if (name.equals("note")) {
2120      return addNote();
2121    } else
2122      return super.addChild(name);
2123  }
2124
2125  public String fhirType() {
2126    return "DiagnosticOrder";
2127
2128  }
2129
2130  public DiagnosticOrder copy() {
2131    DiagnosticOrder dst = new DiagnosticOrder();
2132    copyValues(dst);
2133    dst.subject = subject == null ? null : subject.copy();
2134    dst.orderer = orderer == null ? null : orderer.copy();
2135    if (identifier != null) {
2136      dst.identifier = new ArrayList<Identifier>();
2137      for (Identifier i : identifier)
2138        dst.identifier.add(i.copy());
2139    }
2140    ;
2141    dst.encounter = encounter == null ? null : encounter.copy();
2142    if (reason != null) {
2143      dst.reason = new ArrayList<CodeableConcept>();
2144      for (CodeableConcept i : reason)
2145        dst.reason.add(i.copy());
2146    }
2147    ;
2148    if (supportingInformation != null) {
2149      dst.supportingInformation = new ArrayList<Reference>();
2150      for (Reference i : supportingInformation)
2151        dst.supportingInformation.add(i.copy());
2152    }
2153    ;
2154    if (specimen != null) {
2155      dst.specimen = new ArrayList<Reference>();
2156      for (Reference i : specimen)
2157        dst.specimen.add(i.copy());
2158    }
2159    ;
2160    dst.status = status == null ? null : status.copy();
2161    dst.priority = priority == null ? null : priority.copy();
2162    if (event != null) {
2163      dst.event = new ArrayList<DiagnosticOrderEventComponent>();
2164      for (DiagnosticOrderEventComponent i : event)
2165        dst.event.add(i.copy());
2166    }
2167    ;
2168    if (item != null) {
2169      dst.item = new ArrayList<DiagnosticOrderItemComponent>();
2170      for (DiagnosticOrderItemComponent i : item)
2171        dst.item.add(i.copy());
2172    }
2173    ;
2174    if (note != null) {
2175      dst.note = new ArrayList<Annotation>();
2176      for (Annotation i : note)
2177        dst.note.add(i.copy());
2178    }
2179    ;
2180    return dst;
2181  }
2182
2183  protected DiagnosticOrder typedCopy() {
2184    return copy();
2185  }
2186
2187  @Override
2188  public boolean equalsDeep(Base other) {
2189    if (!super.equalsDeep(other))
2190      return false;
2191    if (!(other instanceof DiagnosticOrder))
2192      return false;
2193    DiagnosticOrder o = (DiagnosticOrder) other;
2194    return compareDeep(subject, o.subject, true) && compareDeep(orderer, o.orderer, true)
2195        && compareDeep(identifier, o.identifier, true) && compareDeep(encounter, o.encounter, true)
2196        && compareDeep(reason, o.reason, true) && compareDeep(supportingInformation, o.supportingInformation, true)
2197        && compareDeep(specimen, o.specimen, true) && compareDeep(status, o.status, true)
2198        && compareDeep(priority, o.priority, true) && compareDeep(event, o.event, true)
2199        && compareDeep(item, o.item, true) && compareDeep(note, o.note, true);
2200  }
2201
2202  @Override
2203  public boolean equalsShallow(Base other) {
2204    if (!super.equalsShallow(other))
2205      return false;
2206    if (!(other instanceof DiagnosticOrder))
2207      return false;
2208    DiagnosticOrder o = (DiagnosticOrder) other;
2209    return compareValues(status, o.status, true) && compareValues(priority, o.priority, true);
2210  }
2211
2212  public boolean isEmpty() {
2213    return super.isEmpty() && (subject == null || subject.isEmpty()) && (orderer == null || orderer.isEmpty())
2214        && (identifier == null || identifier.isEmpty()) && (encounter == null || encounter.isEmpty())
2215        && (reason == null || reason.isEmpty()) && (supportingInformation == null || supportingInformation.isEmpty())
2216        && (specimen == null || specimen.isEmpty()) && (status == null || status.isEmpty())
2217        && (priority == null || priority.isEmpty()) && (event == null || event.isEmpty())
2218        && (item == null || item.isEmpty()) && (note == null || note.isEmpty());
2219  }
2220
2221  @Override
2222  public ResourceType getResourceType() {
2223    return ResourceType.DiagnosticOrder;
2224  }
2225
2226  @SearchParamDefinition(name = "item-past-status", path = "DiagnosticOrder.item.event.status", description = "proposed | draft | planned | requested | received | accepted | in-progress | review | completed | cancelled | suspended | rejected | failed", type = "token")
2227  public static final String SP_ITEMPASTSTATUS = "item-past-status";
2228  @SearchParamDefinition(name = "identifier", path = "DiagnosticOrder.identifier", description = "Identifiers assigned to this order", type = "token")
2229  public static final String SP_IDENTIFIER = "identifier";
2230  @SearchParamDefinition(name = "bodysite", path = "DiagnosticOrder.item.bodySite", description = "Location of requested test (if applicable)", type = "token")
2231  public static final String SP_BODYSITE = "bodysite";
2232  @SearchParamDefinition(name = "code", path = "DiagnosticOrder.item.code", description = "Code to indicate the item (test or panel) being ordered", type = "token")
2233  public static final String SP_CODE = "code";
2234  @SearchParamDefinition(name = "event-date", path = "DiagnosticOrder.event.dateTime", description = "The date at which the event happened", type = "date")
2235  public static final String SP_EVENTDATE = "event-date";
2236  @SearchParamDefinition(name = "event-status-date", path = "null", description = "A combination of past-status and date", type = "composite")
2237  public static final String SP_EVENTSTATUSDATE = "event-status-date";
2238  @SearchParamDefinition(name = "subject", path = "DiagnosticOrder.subject", description = "Who and/or what test is about", type = "reference")
2239  public static final String SP_SUBJECT = "subject";
2240  @SearchParamDefinition(name = "encounter", path = "DiagnosticOrder.encounter", description = "The encounter that this diagnostic order is associated with", type = "reference")
2241  public static final String SP_ENCOUNTER = "encounter";
2242  @SearchParamDefinition(name = "actor", path = "DiagnosticOrder.event.actor | DiagnosticOrder.item.event.actor", description = "Who recorded or did this", type = "reference")
2243  public static final String SP_ACTOR = "actor";
2244  @SearchParamDefinition(name = "item-date", path = "DiagnosticOrder.item.event.dateTime", description = "The date at which the event happened", type = "date")
2245  public static final String SP_ITEMDATE = "item-date";
2246  @SearchParamDefinition(name = "item-status-date", path = "null", description = "A combination of item-past-status and item-date", type = "composite")
2247  public static final String SP_ITEMSTATUSDATE = "item-status-date";
2248  @SearchParamDefinition(name = "event-status", path = "DiagnosticOrder.event.status", description = "proposed | draft | planned | requested | received | accepted | in-progress | review | completed | cancelled | suspended | rejected | failed", type = "token")
2249  public static final String SP_EVENTSTATUS = "event-status";
2250  @SearchParamDefinition(name = "item-status", path = "DiagnosticOrder.item.status", description = "proposed | draft | planned | requested | received | accepted | in-progress | review | completed | cancelled | suspended | rejected | failed", type = "token")
2251  public static final String SP_ITEMSTATUS = "item-status";
2252  @SearchParamDefinition(name = "patient", path = "DiagnosticOrder.subject", description = "Who and/or what test is about", type = "reference")
2253  public static final String SP_PATIENT = "patient";
2254  @SearchParamDefinition(name = "orderer", path = "DiagnosticOrder.orderer", description = "Who ordered the test", type = "reference")
2255  public static final String SP_ORDERER = "orderer";
2256  @SearchParamDefinition(name = "specimen", path = "DiagnosticOrder.specimen | DiagnosticOrder.item.specimen", description = "If the whole order relates to specific specimens", type = "reference")
2257  public static final String SP_SPECIMEN = "specimen";
2258  @SearchParamDefinition(name = "status", path = "DiagnosticOrder.status", description = "proposed | draft | planned | requested | received | accepted | in-progress | review | completed | cancelled | suspended | rejected | failed", type = "token")
2259  public static final String SP_STATUS = "status";
2260
2261}