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