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