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