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