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.Child;
059import ca.uhn.fhir.model.api.annotation.Description;
060import ca.uhn.fhir.model.api.annotation.ResourceDef;
061import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
062import org.hl7.fhir.exceptions.FHIRException;
063import org.hl7.fhir.utilities.Utilities;
064/**
065 * A response to an order.
066 */
067@ResourceDef(name="OrderResponse", profile="http://hl7.org/fhir/Profile/OrderResponse")
068public class OrderResponse extends DomainResource {
069
070    public enum OrderStatus {
071        /**
072         * The order is known, but no processing has occurred at this time
073         */
074        PENDING, 
075        /**
076         * The order is undergoing initial processing to determine whether it will be accepted (usually this involves human review)
077         */
078        REVIEW, 
079        /**
080         * The order was rejected because of a workflow/business logic reason
081         */
082        REJECTED, 
083        /**
084         * The order was unable to be processed because of a technical error (i.e. unexpected error)
085         */
086        ERROR, 
087        /**
088         * The order has been accepted, and work is in progress.
089         */
090        ACCEPTED, 
091        /**
092         * Processing the order was halted at the initiators request.
093         */
094        CANCELLED, 
095        /**
096         * The order has been cancelled and replaced by another.
097         */
098        REPLACED, 
099        /**
100         * Processing the order was stopped because of some workflow/business logic reason.
101         */
102        ABORTED, 
103        /**
104         * The order has been completed.
105         */
106        COMPLETED, 
107        /**
108         * added to help the parsers
109         */
110        NULL;
111        public static OrderStatus fromCode(String codeString) throws FHIRException {
112            if (codeString == null || "".equals(codeString))
113                return null;
114        if ("pending".equals(codeString))
115          return PENDING;
116        if ("review".equals(codeString))
117          return REVIEW;
118        if ("rejected".equals(codeString))
119          return REJECTED;
120        if ("error".equals(codeString))
121          return ERROR;
122        if ("accepted".equals(codeString))
123          return ACCEPTED;
124        if ("cancelled".equals(codeString))
125          return CANCELLED;
126        if ("replaced".equals(codeString))
127          return REPLACED;
128        if ("aborted".equals(codeString))
129          return ABORTED;
130        if ("completed".equals(codeString))
131          return COMPLETED;
132        throw new FHIRException("Unknown OrderStatus code '"+codeString+"'");
133        }
134        public String toCode() {
135          switch (this) {
136            case PENDING: return "pending";
137            case REVIEW: return "review";
138            case REJECTED: return "rejected";
139            case ERROR: return "error";
140            case ACCEPTED: return "accepted";
141            case CANCELLED: return "cancelled";
142            case REPLACED: return "replaced";
143            case ABORTED: return "aborted";
144            case COMPLETED: return "completed";
145            default: return "?";
146          }
147        }
148        public String getSystem() {
149          switch (this) {
150            case PENDING: return "http://hl7.org/fhir/order-status";
151            case REVIEW: return "http://hl7.org/fhir/order-status";
152            case REJECTED: return "http://hl7.org/fhir/order-status";
153            case ERROR: return "http://hl7.org/fhir/order-status";
154            case ACCEPTED: return "http://hl7.org/fhir/order-status";
155            case CANCELLED: return "http://hl7.org/fhir/order-status";
156            case REPLACED: return "http://hl7.org/fhir/order-status";
157            case ABORTED: return "http://hl7.org/fhir/order-status";
158            case COMPLETED: return "http://hl7.org/fhir/order-status";
159            default: return "?";
160          }
161        }
162        public String getDefinition() {
163          switch (this) {
164            case PENDING: return "The order is known, but no processing has occurred at this time";
165            case REVIEW: return "The order is undergoing initial processing to determine whether it will be accepted (usually this involves human review)";
166            case REJECTED: return "The order was rejected because of a workflow/business logic reason";
167            case ERROR: return "The order was unable to be processed because of a technical error (i.e. unexpected error)";
168            case ACCEPTED: return "The order has been accepted, and work is in progress.";
169            case CANCELLED: return "Processing the order was halted at the initiators request.";
170            case REPLACED: return "The order has been cancelled and replaced by another.";
171            case ABORTED: return "Processing the order was stopped because of some workflow/business logic reason.";
172            case COMPLETED: return "The order has been completed.";
173            default: return "?";
174          }
175        }
176        public String getDisplay() {
177          switch (this) {
178            case PENDING: return "Pending";
179            case REVIEW: return "Review";
180            case REJECTED: return "Rejected";
181            case ERROR: return "Error";
182            case ACCEPTED: return "Accepted";
183            case CANCELLED: return "Cancelled";
184            case REPLACED: return "Replaced";
185            case ABORTED: return "Aborted";
186            case COMPLETED: return "Completed";
187            default: return "?";
188          }
189        }
190    }
191
192  public static class OrderStatusEnumFactory implements EnumFactory<OrderStatus> {
193    public OrderStatus fromCode(String codeString) throws IllegalArgumentException {
194      if (codeString == null || "".equals(codeString))
195            if (codeString == null || "".equals(codeString))
196                return null;
197        if ("pending".equals(codeString))
198          return OrderStatus.PENDING;
199        if ("review".equals(codeString))
200          return OrderStatus.REVIEW;
201        if ("rejected".equals(codeString))
202          return OrderStatus.REJECTED;
203        if ("error".equals(codeString))
204          return OrderStatus.ERROR;
205        if ("accepted".equals(codeString))
206          return OrderStatus.ACCEPTED;
207        if ("cancelled".equals(codeString))
208          return OrderStatus.CANCELLED;
209        if ("replaced".equals(codeString))
210          return OrderStatus.REPLACED;
211        if ("aborted".equals(codeString))
212          return OrderStatus.ABORTED;
213        if ("completed".equals(codeString))
214          return OrderStatus.COMPLETED;
215        throw new IllegalArgumentException("Unknown OrderStatus code '"+codeString+"'");
216        }
217        public Enumeration<OrderStatus> fromType(Base code) throws FHIRException {
218          if (code == null || code.isEmpty())
219            return null;
220          String codeString = ((PrimitiveType) code).asStringValue();
221          if (codeString == null || "".equals(codeString))
222            return null;
223        if ("pending".equals(codeString))
224          return new Enumeration<OrderStatus>(this, OrderStatus.PENDING);
225        if ("review".equals(codeString))
226          return new Enumeration<OrderStatus>(this, OrderStatus.REVIEW);
227        if ("rejected".equals(codeString))
228          return new Enumeration<OrderStatus>(this, OrderStatus.REJECTED);
229        if ("error".equals(codeString))
230          return new Enumeration<OrderStatus>(this, OrderStatus.ERROR);
231        if ("accepted".equals(codeString))
232          return new Enumeration<OrderStatus>(this, OrderStatus.ACCEPTED);
233        if ("cancelled".equals(codeString))
234          return new Enumeration<OrderStatus>(this, OrderStatus.CANCELLED);
235        if ("replaced".equals(codeString))
236          return new Enumeration<OrderStatus>(this, OrderStatus.REPLACED);
237        if ("aborted".equals(codeString))
238          return new Enumeration<OrderStatus>(this, OrderStatus.ABORTED);
239        if ("completed".equals(codeString))
240          return new Enumeration<OrderStatus>(this, OrderStatus.COMPLETED);
241        throw new FHIRException("Unknown OrderStatus code '"+codeString+"'");
242        }
243    public String toCode(OrderStatus code) {
244      if (code == OrderStatus.PENDING)
245        return "pending";
246      if (code == OrderStatus.REVIEW)
247        return "review";
248      if (code == OrderStatus.REJECTED)
249        return "rejected";
250      if (code == OrderStatus.ERROR)
251        return "error";
252      if (code == OrderStatus.ACCEPTED)
253        return "accepted";
254      if (code == OrderStatus.CANCELLED)
255        return "cancelled";
256      if (code == OrderStatus.REPLACED)
257        return "replaced";
258      if (code == OrderStatus.ABORTED)
259        return "aborted";
260      if (code == OrderStatus.COMPLETED)
261        return "completed";
262      return "?";
263      }
264    }
265
266    /**
267     * Identifiers assigned to this order. The identifiers are usually assigned by the system responding to the order, but they may be provided or added to by other systems.
268     */
269    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
270    @Description(shortDefinition="Identifiers assigned to this order by the orderer or by the receiver", formalDefinition="Identifiers assigned to this order. The identifiers are usually assigned by the system responding to the order, but they may be provided or added to by other systems." )
271    protected List<Identifier> identifier;
272
273    /**
274     * A reference to the order that this is in response to.
275     */
276    @Child(name = "request", type = {Order.class}, order=1, min=1, max=1, modifier=false, summary=true)
277    @Description(shortDefinition="The order that this is a response to", formalDefinition="A reference to the order that this is in response to." )
278    protected Reference request;
279
280    /**
281     * The actual object that is the target of the reference (A reference to the order that this is in response to.)
282     */
283    protected Order requestTarget;
284
285    /**
286     * The date and time at which this order response was made (created/posted).
287     */
288    @Child(name = "date", type = {DateTimeType.class}, order=2, min=0, max=1, modifier=false, summary=true)
289    @Description(shortDefinition="When the response was made", formalDefinition="The date and time at which this order response was made (created/posted)." )
290    protected DateTimeType date;
291
292    /**
293     * The person, organization, or device credited with making the response.
294     */
295    @Child(name = "who", type = {Practitioner.class, Organization.class, Device.class}, order=3, min=0, max=1, modifier=false, summary=true)
296    @Description(shortDefinition="Who made the response", formalDefinition="The person, organization, or device credited with making the response." )
297    protected Reference who;
298
299    /**
300     * The actual object that is the target of the reference (The person, organization, or device credited with making the response.)
301     */
302    protected Resource whoTarget;
303
304    /**
305     * What this response says about the status of the original order.
306     */
307    @Child(name = "orderStatus", type = {CodeType.class}, order=4, min=1, max=1, modifier=true, summary=true)
308    @Description(shortDefinition="pending | review | rejected | error | accepted | cancelled | replaced | aborted | completed", formalDefinition="What this response says about the status of the original order." )
309    protected Enumeration<OrderStatus> orderStatus;
310
311    /**
312     * Additional description about the response - e.g. a text description provided by a human user when making decisions about the order.
313     */
314    @Child(name = "description", type = {StringType.class}, order=5, min=0, max=1, modifier=false, summary=true)
315    @Description(shortDefinition="Additional description of the response", formalDefinition="Additional description about the response - e.g. a text description provided by a human user when making decisions about the order." )
316    protected StringType description;
317
318    /**
319     * Links to resources that provide details of the outcome of performing the order; e.g. Diagnostic Reports in a response that is made to an order that referenced a diagnostic order.
320     */
321    @Child(name = "fulfillment", type = {}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
322    @Description(shortDefinition="Details of the outcome of performing the order", formalDefinition="Links to resources that provide details of the outcome of performing the order; e.g. Diagnostic Reports in a response that is made to an order that referenced a diagnostic order." )
323    protected List<Reference> fulfillment;
324    /**
325     * The actual objects that are the target of the reference (Links to resources that provide details of the outcome of performing the order; e.g. Diagnostic Reports in a response that is made to an order that referenced a diagnostic order.)
326     */
327    protected List<Resource> fulfillmentTarget;
328
329
330    private static final long serialVersionUID = -856633109L;
331
332  /*
333   * Constructor
334   */
335    public OrderResponse() {
336      super();
337    }
338
339  /*
340   * Constructor
341   */
342    public OrderResponse(Reference request, Enumeration<OrderStatus> orderStatus) {
343      super();
344      this.request = request;
345      this.orderStatus = orderStatus;
346    }
347
348    /**
349     * @return {@link #identifier} (Identifiers assigned to this order. The identifiers are usually assigned by the system responding to the order, but they may be provided or added to by other systems.)
350     */
351    public List<Identifier> getIdentifier() { 
352      if (this.identifier == null)
353        this.identifier = new ArrayList<Identifier>();
354      return this.identifier;
355    }
356
357    public boolean hasIdentifier() { 
358      if (this.identifier == null)
359        return false;
360      for (Identifier item : this.identifier)
361        if (!item.isEmpty())
362          return true;
363      return false;
364    }
365
366    /**
367     * @return {@link #identifier} (Identifiers assigned to this order. The identifiers are usually assigned by the system responding to the order, but they may be provided or added to by other systems.)
368     */
369    // syntactic sugar
370    public Identifier addIdentifier() { //3
371      Identifier t = new Identifier();
372      if (this.identifier == null)
373        this.identifier = new ArrayList<Identifier>();
374      this.identifier.add(t);
375      return t;
376    }
377
378    // syntactic sugar
379    public OrderResponse addIdentifier(Identifier t) { //3
380      if (t == null)
381        return this;
382      if (this.identifier == null)
383        this.identifier = new ArrayList<Identifier>();
384      this.identifier.add(t);
385      return this;
386    }
387
388    /**
389     * @return {@link #request} (A reference to the order that this is in response to.)
390     */
391    public Reference getRequest() { 
392      if (this.request == null)
393        if (Configuration.errorOnAutoCreate())
394          throw new Error("Attempt to auto-create OrderResponse.request");
395        else if (Configuration.doAutoCreate())
396          this.request = new Reference(); // cc
397      return this.request;
398    }
399
400    public boolean hasRequest() { 
401      return this.request != null && !this.request.isEmpty();
402    }
403
404    /**
405     * @param value {@link #request} (A reference to the order that this is in response to.)
406     */
407    public OrderResponse setRequest(Reference value) { 
408      this.request = value;
409      return this;
410    }
411
412    /**
413     * @return {@link #request} 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. (A reference to the order that this is in response to.)
414     */
415    public Order getRequestTarget() { 
416      if (this.requestTarget == null)
417        if (Configuration.errorOnAutoCreate())
418          throw new Error("Attempt to auto-create OrderResponse.request");
419        else if (Configuration.doAutoCreate())
420          this.requestTarget = new Order(); // aa
421      return this.requestTarget;
422    }
423
424    /**
425     * @param value {@link #request} 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. (A reference to the order that this is in response to.)
426     */
427    public OrderResponse setRequestTarget(Order value) { 
428      this.requestTarget = value;
429      return this;
430    }
431
432    /**
433     * @return {@link #date} (The date and time at which this order response was made (created/posted).). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
434     */
435    public DateTimeType getDateElement() { 
436      if (this.date == null)
437        if (Configuration.errorOnAutoCreate())
438          throw new Error("Attempt to auto-create OrderResponse.date");
439        else if (Configuration.doAutoCreate())
440          this.date = new DateTimeType(); // bb
441      return this.date;
442    }
443
444    public boolean hasDateElement() { 
445      return this.date != null && !this.date.isEmpty();
446    }
447
448    public boolean hasDate() { 
449      return this.date != null && !this.date.isEmpty();
450    }
451
452    /**
453     * @param value {@link #date} (The date and time at which this order response was made (created/posted).). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
454     */
455    public OrderResponse setDateElement(DateTimeType value) { 
456      this.date = value;
457      return this;
458    }
459
460    /**
461     * @return The date and time at which this order response was made (created/posted).
462     */
463    public Date getDate() { 
464      return this.date == null ? null : this.date.getValue();
465    }
466
467    /**
468     * @param value The date and time at which this order response was made (created/posted).
469     */
470    public OrderResponse setDate(Date value) { 
471      if (value == null)
472        this.date = null;
473      else {
474        if (this.date == null)
475          this.date = new DateTimeType();
476        this.date.setValue(value);
477      }
478      return this;
479    }
480
481    /**
482     * @return {@link #who} (The person, organization, or device credited with making the response.)
483     */
484    public Reference getWho() { 
485      if (this.who == null)
486        if (Configuration.errorOnAutoCreate())
487          throw new Error("Attempt to auto-create OrderResponse.who");
488        else if (Configuration.doAutoCreate())
489          this.who = new Reference(); // cc
490      return this.who;
491    }
492
493    public boolean hasWho() { 
494      return this.who != null && !this.who.isEmpty();
495    }
496
497    /**
498     * @param value {@link #who} (The person, organization, or device credited with making the response.)
499     */
500    public OrderResponse setWho(Reference value) { 
501      this.who = value;
502      return this;
503    }
504
505    /**
506     * @return {@link #who} 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, organization, or device credited with making the response.)
507     */
508    public Resource getWhoTarget() { 
509      return this.whoTarget;
510    }
511
512    /**
513     * @param value {@link #who} 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, organization, or device credited with making the response.)
514     */
515    public OrderResponse setWhoTarget(Resource value) { 
516      this.whoTarget = value;
517      return this;
518    }
519
520    /**
521     * @return {@link #orderStatus} (What this response says about the status of the original order.). This is the underlying object with id, value and extensions. The accessor "getOrderStatus" gives direct access to the value
522     */
523    public Enumeration<OrderStatus> getOrderStatusElement() { 
524      if (this.orderStatus == null)
525        if (Configuration.errorOnAutoCreate())
526          throw new Error("Attempt to auto-create OrderResponse.orderStatus");
527        else if (Configuration.doAutoCreate())
528          this.orderStatus = new Enumeration<OrderStatus>(new OrderStatusEnumFactory()); // bb
529      return this.orderStatus;
530    }
531
532    public boolean hasOrderStatusElement() { 
533      return this.orderStatus != null && !this.orderStatus.isEmpty();
534    }
535
536    public boolean hasOrderStatus() { 
537      return this.orderStatus != null && !this.orderStatus.isEmpty();
538    }
539
540    /**
541     * @param value {@link #orderStatus} (What this response says about the status of the original order.). This is the underlying object with id, value and extensions. The accessor "getOrderStatus" gives direct access to the value
542     */
543    public OrderResponse setOrderStatusElement(Enumeration<OrderStatus> value) { 
544      this.orderStatus = value;
545      return this;
546    }
547
548    /**
549     * @return What this response says about the status of the original order.
550     */
551    public OrderStatus getOrderStatus() { 
552      return this.orderStatus == null ? null : this.orderStatus.getValue();
553    }
554
555    /**
556     * @param value What this response says about the status of the original order.
557     */
558    public OrderResponse setOrderStatus(OrderStatus value) { 
559        if (this.orderStatus == null)
560          this.orderStatus = new Enumeration<OrderStatus>(new OrderStatusEnumFactory());
561        this.orderStatus.setValue(value);
562      return this;
563    }
564
565    /**
566     * @return {@link #description} (Additional description about the response - e.g. a text description provided by a human user when making decisions about the order.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
567     */
568    public StringType getDescriptionElement() { 
569      if (this.description == null)
570        if (Configuration.errorOnAutoCreate())
571          throw new Error("Attempt to auto-create OrderResponse.description");
572        else if (Configuration.doAutoCreate())
573          this.description = new StringType(); // bb
574      return this.description;
575    }
576
577    public boolean hasDescriptionElement() { 
578      return this.description != null && !this.description.isEmpty();
579    }
580
581    public boolean hasDescription() { 
582      return this.description != null && !this.description.isEmpty();
583    }
584
585    /**
586     * @param value {@link #description} (Additional description about the response - e.g. a text description provided by a human user when making decisions about the order.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
587     */
588    public OrderResponse setDescriptionElement(StringType value) { 
589      this.description = value;
590      return this;
591    }
592
593    /**
594     * @return Additional description about the response - e.g. a text description provided by a human user when making decisions about the order.
595     */
596    public String getDescription() { 
597      return this.description == null ? null : this.description.getValue();
598    }
599
600    /**
601     * @param value Additional description about the response - e.g. a text description provided by a human user when making decisions about the order.
602     */
603    public OrderResponse setDescription(String value) { 
604      if (Utilities.noString(value))
605        this.description = null;
606      else {
607        if (this.description == null)
608          this.description = new StringType();
609        this.description.setValue(value);
610      }
611      return this;
612    }
613
614    /**
615     * @return {@link #fulfillment} (Links to resources that provide details of the outcome of performing the order; e.g. Diagnostic Reports in a response that is made to an order that referenced a diagnostic order.)
616     */
617    public List<Reference> getFulfillment() { 
618      if (this.fulfillment == null)
619        this.fulfillment = new ArrayList<Reference>();
620      return this.fulfillment;
621    }
622
623    public boolean hasFulfillment() { 
624      if (this.fulfillment == null)
625        return false;
626      for (Reference item : this.fulfillment)
627        if (!item.isEmpty())
628          return true;
629      return false;
630    }
631
632    /**
633     * @return {@link #fulfillment} (Links to resources that provide details of the outcome of performing the order; e.g. Diagnostic Reports in a response that is made to an order that referenced a diagnostic order.)
634     */
635    // syntactic sugar
636    public Reference addFulfillment() { //3
637      Reference t = new Reference();
638      if (this.fulfillment == null)
639        this.fulfillment = new ArrayList<Reference>();
640      this.fulfillment.add(t);
641      return t;
642    }
643
644    // syntactic sugar
645    public OrderResponse addFulfillment(Reference t) { //3
646      if (t == null)
647        return this;
648      if (this.fulfillment == null)
649        this.fulfillment = new ArrayList<Reference>();
650      this.fulfillment.add(t);
651      return this;
652    }
653
654    /**
655     * @return {@link #fulfillment} (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. Links to resources that provide details of the outcome of performing the order; e.g. Diagnostic Reports in a response that is made to an order that referenced a diagnostic order.)
656     */
657    public List<Resource> getFulfillmentTarget() { 
658      if (this.fulfillmentTarget == null)
659        this.fulfillmentTarget = new ArrayList<Resource>();
660      return this.fulfillmentTarget;
661    }
662
663      protected void listChildren(List<Property> childrenList) {
664        super.listChildren(childrenList);
665        childrenList.add(new Property("identifier", "Identifier", "Identifiers assigned to this order. The identifiers are usually assigned by the system responding to the order, but they may be provided or added to by other systems.", 0, java.lang.Integer.MAX_VALUE, identifier));
666        childrenList.add(new Property("request", "Reference(Order)", "A reference to the order that this is in response to.", 0, java.lang.Integer.MAX_VALUE, request));
667        childrenList.add(new Property("date", "dateTime", "The date and time at which this order response was made (created/posted).", 0, java.lang.Integer.MAX_VALUE, date));
668        childrenList.add(new Property("who", "Reference(Practitioner|Organization|Device)", "The person, organization, or device credited with making the response.", 0, java.lang.Integer.MAX_VALUE, who));
669        childrenList.add(new Property("orderStatus", "code", "What this response says about the status of the original order.", 0, java.lang.Integer.MAX_VALUE, orderStatus));
670        childrenList.add(new Property("description", "string", "Additional description about the response - e.g. a text description provided by a human user when making decisions about the order.", 0, java.lang.Integer.MAX_VALUE, description));
671        childrenList.add(new Property("fulfillment", "Reference(Any)", "Links to resources that provide details of the outcome of performing the order; e.g. Diagnostic Reports in a response that is made to an order that referenced a diagnostic order.", 0, java.lang.Integer.MAX_VALUE, fulfillment));
672      }
673
674      @Override
675      public void setProperty(String name, Base value) throws FHIRException {
676        if (name.equals("identifier"))
677          this.getIdentifier().add(castToIdentifier(value));
678        else if (name.equals("request"))
679          this.request = castToReference(value); // Reference
680        else if (name.equals("date"))
681          this.date = castToDateTime(value); // DateTimeType
682        else if (name.equals("who"))
683          this.who = castToReference(value); // Reference
684        else if (name.equals("orderStatus"))
685          this.orderStatus = new OrderStatusEnumFactory().fromType(value); // Enumeration<OrderStatus>
686        else if (name.equals("description"))
687          this.description = castToString(value); // StringType
688        else if (name.equals("fulfillment"))
689          this.getFulfillment().add(castToReference(value));
690        else
691          super.setProperty(name, value);
692      }
693
694      @Override
695      public Base addChild(String name) throws FHIRException {
696        if (name.equals("identifier")) {
697          return addIdentifier();
698        }
699        else if (name.equals("request")) {
700          this.request = new Reference();
701          return this.request;
702        }
703        else if (name.equals("date")) {
704          throw new FHIRException("Cannot call addChild on a primitive type OrderResponse.date");
705        }
706        else if (name.equals("who")) {
707          this.who = new Reference();
708          return this.who;
709        }
710        else if (name.equals("orderStatus")) {
711          throw new FHIRException("Cannot call addChild on a primitive type OrderResponse.orderStatus");
712        }
713        else if (name.equals("description")) {
714          throw new FHIRException("Cannot call addChild on a primitive type OrderResponse.description");
715        }
716        else if (name.equals("fulfillment")) {
717          return addFulfillment();
718        }
719        else
720          return super.addChild(name);
721      }
722
723  public String fhirType() {
724    return "OrderResponse";
725
726  }
727
728      public OrderResponse copy() {
729        OrderResponse dst = new OrderResponse();
730        copyValues(dst);
731        if (identifier != null) {
732          dst.identifier = new ArrayList<Identifier>();
733          for (Identifier i : identifier)
734            dst.identifier.add(i.copy());
735        };
736        dst.request = request == null ? null : request.copy();
737        dst.date = date == null ? null : date.copy();
738        dst.who = who == null ? null : who.copy();
739        dst.orderStatus = orderStatus == null ? null : orderStatus.copy();
740        dst.description = description == null ? null : description.copy();
741        if (fulfillment != null) {
742          dst.fulfillment = new ArrayList<Reference>();
743          for (Reference i : fulfillment)
744            dst.fulfillment.add(i.copy());
745        };
746        return dst;
747      }
748
749      protected OrderResponse typedCopy() {
750        return copy();
751      }
752
753      @Override
754      public boolean equalsDeep(Base other) {
755        if (!super.equalsDeep(other))
756          return false;
757        if (!(other instanceof OrderResponse))
758          return false;
759        OrderResponse o = (OrderResponse) other;
760        return compareDeep(identifier, o.identifier, true) && compareDeep(request, o.request, true) && compareDeep(date, o.date, true)
761           && compareDeep(who, o.who, true) && compareDeep(orderStatus, o.orderStatus, true) && compareDeep(description, o.description, true)
762           && compareDeep(fulfillment, o.fulfillment, true);
763      }
764
765      @Override
766      public boolean equalsShallow(Base other) {
767        if (!super.equalsShallow(other))
768          return false;
769        if (!(other instanceof OrderResponse))
770          return false;
771        OrderResponse o = (OrderResponse) other;
772        return compareValues(date, o.date, true) && compareValues(orderStatus, o.orderStatus, true) && compareValues(description, o.description, true)
773          ;
774      }
775
776      public boolean isEmpty() {
777        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (request == null || request.isEmpty())
778           && (date == null || date.isEmpty()) && (who == null || who.isEmpty()) && (orderStatus == null || orderStatus.isEmpty())
779           && (description == null || description.isEmpty()) && (fulfillment == null || fulfillment.isEmpty())
780          ;
781      }
782
783  @Override
784  public ResourceType getResourceType() {
785    return ResourceType.OrderResponse;
786   }
787
788  @SearchParamDefinition(name="date", path="OrderResponse.date", description="When the response was made", type="date" )
789  public static final String SP_DATE = "date";
790  @SearchParamDefinition(name="request", path="OrderResponse.request", description="The order that this is a response to", type="reference" )
791  public static final String SP_REQUEST = "request";
792  @SearchParamDefinition(name="identifier", path="OrderResponse.identifier", description="Identifiers assigned to this order by the orderer or by the receiver", type="token" )
793  public static final String SP_IDENTIFIER = "identifier";
794  @SearchParamDefinition(name="code", path="OrderResponse.orderStatus", description="pending | review | rejected | error | accepted | cancelled | replaced | aborted | completed", type="token" )
795  public static final String SP_CODE = "code";
796  @SearchParamDefinition(name="fulfillment", path="OrderResponse.fulfillment", description="Details of the outcome of performing the order", type="reference" )
797  public static final String SP_FULFILLMENT = "fulfillment";
798  @SearchParamDefinition(name="who", path="OrderResponse.who", description="Who made the response", type="reference" )
799  public static final String SP_WHO = "who";
800
801}
802