001package org.hl7.fhir.r5.model;
002
003
004/*
005  Copyright (c) 2011+, HL7, Inc.
006  All rights reserved.
007  
008  Redistribution and use in source and binary forms, with or without modification, \
009  are permitted provided that the following conditions are met:
010  
011   * Redistributions of source code must retain the above copyright notice, this \
012     list of conditions and the following disclaimer.
013   * Redistributions in binary form must reproduce the above copyright notice, \
014     this list of conditions and the following disclaimer in the documentation \
015     and/or other materials provided with the distribution.
016   * Neither the name of HL7 nor the names of its contributors may be used to 
017     endorse or promote products derived from this software without specific 
018     prior written permission.
019  
020  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \
021  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \
022  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \
023  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \
024  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \
025  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \
026  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \
027  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \
028  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \
029  POSSIBILITY OF SUCH DAMAGE.
030  */
031
032// Generated on Fri, Jul 15, 2022 11:20+1000 for FHIR v5.0.0-snapshot2
033
034import java.util.ArrayList;
035import java.util.Date;
036import java.util.List;
037import org.hl7.fhir.utilities.Utilities;
038import org.hl7.fhir.r5.model.Enumerations.*;
039import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
040import org.hl7.fhir.exceptions.FHIRException;
041import org.hl7.fhir.instance.model.api.ICompositeType;
042import ca.uhn.fhir.model.api.annotation.ResourceDef;
043import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
044import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
045import ca.uhn.fhir.model.api.annotation.Child;
046import ca.uhn.fhir.model.api.annotation.ChildOrder;
047import ca.uhn.fhir.model.api.annotation.Description;
048import ca.uhn.fhir.model.api.annotation.Block;
049
050/**
051 * The SubscriptionStatus resource describes the state of a Subscription during notifications.
052 */
053@ResourceDef(name="SubscriptionStatus", profile="http://hl7.org/fhir/StructureDefinition/SubscriptionStatus")
054public class SubscriptionStatus extends DomainResource {
055
056    public enum SubscriptionNotificationType {
057        /**
058         * The status was generated as part of the setup or verification of a communications channel.
059         */
060        HANDSHAKE, 
061        /**
062         * The status was generated to perform a heartbeat notification to the subscriber.
063         */
064        HEARTBEAT, 
065        /**
066         * The status was generated for an event to the subscriber.
067         */
068        EVENTNOTIFICATION, 
069        /**
070         * The status was generated in response to a status query/request.
071         */
072        QUERYSTATUS, 
073        /**
074         * The status was generated in response to an event query/request.
075         */
076        QUERYEVENT, 
077        /**
078         * added to help the parsers with the generic types
079         */
080        NULL;
081        public static SubscriptionNotificationType fromCode(String codeString) throws FHIRException {
082            if (codeString == null || "".equals(codeString))
083                return null;
084        if ("handshake".equals(codeString))
085          return HANDSHAKE;
086        if ("heartbeat".equals(codeString))
087          return HEARTBEAT;
088        if ("event-notification".equals(codeString))
089          return EVENTNOTIFICATION;
090        if ("query-status".equals(codeString))
091          return QUERYSTATUS;
092        if ("query-event".equals(codeString))
093          return QUERYEVENT;
094        if (Configuration.isAcceptInvalidEnums())
095          return null;
096        else
097          throw new FHIRException("Unknown SubscriptionNotificationType code '"+codeString+"'");
098        }
099        public String toCode() {
100          switch (this) {
101            case HANDSHAKE: return "handshake";
102            case HEARTBEAT: return "heartbeat";
103            case EVENTNOTIFICATION: return "event-notification";
104            case QUERYSTATUS: return "query-status";
105            case QUERYEVENT: return "query-event";
106            case NULL: return null;
107            default: return "?";
108          }
109        }
110        public String getSystem() {
111          switch (this) {
112            case HANDSHAKE: return "http://hl7.org/fhir/subscription-notification-type";
113            case HEARTBEAT: return "http://hl7.org/fhir/subscription-notification-type";
114            case EVENTNOTIFICATION: return "http://hl7.org/fhir/subscription-notification-type";
115            case QUERYSTATUS: return "http://hl7.org/fhir/subscription-notification-type";
116            case QUERYEVENT: return "http://hl7.org/fhir/subscription-notification-type";
117            case NULL: return null;
118            default: return "?";
119          }
120        }
121        public String getDefinition() {
122          switch (this) {
123            case HANDSHAKE: return "The status was generated as part of the setup or verification of a communications channel.";
124            case HEARTBEAT: return "The status was generated to perform a heartbeat notification to the subscriber.";
125            case EVENTNOTIFICATION: return "The status was generated for an event to the subscriber.";
126            case QUERYSTATUS: return "The status was generated in response to a status query/request.";
127            case QUERYEVENT: return "The status was generated in response to an event query/request.";
128            case NULL: return null;
129            default: return "?";
130          }
131        }
132        public String getDisplay() {
133          switch (this) {
134            case HANDSHAKE: return "Handshake";
135            case HEARTBEAT: return "Heartbeat";
136            case EVENTNOTIFICATION: return "Event Notification";
137            case QUERYSTATUS: return "Query Status";
138            case QUERYEVENT: return "Query Event";
139            case NULL: return null;
140            default: return "?";
141          }
142        }
143    }
144
145  public static class SubscriptionNotificationTypeEnumFactory implements EnumFactory<SubscriptionNotificationType> {
146    public SubscriptionNotificationType fromCode(String codeString) throws IllegalArgumentException {
147      if (codeString == null || "".equals(codeString))
148            if (codeString == null || "".equals(codeString))
149                return null;
150        if ("handshake".equals(codeString))
151          return SubscriptionNotificationType.HANDSHAKE;
152        if ("heartbeat".equals(codeString))
153          return SubscriptionNotificationType.HEARTBEAT;
154        if ("event-notification".equals(codeString))
155          return SubscriptionNotificationType.EVENTNOTIFICATION;
156        if ("query-status".equals(codeString))
157          return SubscriptionNotificationType.QUERYSTATUS;
158        if ("query-event".equals(codeString))
159          return SubscriptionNotificationType.QUERYEVENT;
160        throw new IllegalArgumentException("Unknown SubscriptionNotificationType code '"+codeString+"'");
161        }
162        public Enumeration<SubscriptionNotificationType> fromType(Base code) throws FHIRException {
163          if (code == null)
164            return null;
165          if (code.isEmpty())
166            return new Enumeration<SubscriptionNotificationType>(this);
167          String codeString = ((PrimitiveType) code).asStringValue();
168          if (codeString == null || "".equals(codeString))
169            return null;
170        if ("handshake".equals(codeString))
171          return new Enumeration<SubscriptionNotificationType>(this, SubscriptionNotificationType.HANDSHAKE);
172        if ("heartbeat".equals(codeString))
173          return new Enumeration<SubscriptionNotificationType>(this, SubscriptionNotificationType.HEARTBEAT);
174        if ("event-notification".equals(codeString))
175          return new Enumeration<SubscriptionNotificationType>(this, SubscriptionNotificationType.EVENTNOTIFICATION);
176        if ("query-status".equals(codeString))
177          return new Enumeration<SubscriptionNotificationType>(this, SubscriptionNotificationType.QUERYSTATUS);
178        if ("query-event".equals(codeString))
179          return new Enumeration<SubscriptionNotificationType>(this, SubscriptionNotificationType.QUERYEVENT);
180        throw new FHIRException("Unknown SubscriptionNotificationType code '"+codeString+"'");
181        }
182    public String toCode(SubscriptionNotificationType code) {
183      if (code == SubscriptionNotificationType.HANDSHAKE)
184        return "handshake";
185      if (code == SubscriptionNotificationType.HEARTBEAT)
186        return "heartbeat";
187      if (code == SubscriptionNotificationType.EVENTNOTIFICATION)
188        return "event-notification";
189      if (code == SubscriptionNotificationType.QUERYSTATUS)
190        return "query-status";
191      if (code == SubscriptionNotificationType.QUERYEVENT)
192        return "query-event";
193      return "?";
194      }
195    public String toSystem(SubscriptionNotificationType code) {
196      return code.getSystem();
197      }
198    }
199
200    @Block()
201    public static class SubscriptionStatusNotificationEventComponent extends BackboneElement implements IBaseBackboneElement {
202        /**
203         * The sequential number of this event in this subscription context.
204         */
205        @Child(name = "eventNumber", type = {Integer64Type.class}, order=1, min=1, max=1, modifier=false, summary=false)
206        @Description(shortDefinition="Event number", formalDefinition="The sequential number of this event in this subscription context." )
207        protected Integer64Type eventNumber;
208
209        /**
210         * The actual time this event occured on the server.
211         */
212        @Child(name = "timestamp", type = {InstantType.class}, order=2, min=0, max=1, modifier=false, summary=false)
213        @Description(shortDefinition="The instant this event occurred", formalDefinition="The actual time this event occured on the server." )
214        protected InstantType timestamp;
215
216        /**
217         * The focus of this event. While this will usually be a reference to the focus resource of the event, it MAY contain a reference to a non-FHIR object.
218         */
219        @Child(name = "focus", type = {Reference.class}, order=3, min=0, max=1, modifier=false, summary=false)
220        @Description(shortDefinition="The focus of this event", formalDefinition="The focus of this event. While this will usually be a reference to the focus resource of the event, it MAY contain a reference to a non-FHIR object." )
221        protected Reference focus;
222
223        /**
224         * Additional context information for this event. Generally, this will contain references to additional resources included with the event (e.g., the Patient relevant to an Encounter), however it MAY refer to non-FHIR objects.
225         */
226        @Child(name = "additionalContext", type = {Reference.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
227        @Description(shortDefinition="Additional context for this event", formalDefinition="Additional context information for this event. Generally, this will contain references to additional resources included with the event (e.g., the Patient relevant to an Encounter), however it MAY refer to non-FHIR objects." )
228        protected List<Reference> additionalContext;
229
230        private static final long serialVersionUID = 855121922L;
231
232    /**
233     * Constructor
234     */
235      public SubscriptionStatusNotificationEventComponent() {
236        super();
237      }
238
239    /**
240     * Constructor
241     */
242      public SubscriptionStatusNotificationEventComponent(long eventNumber) {
243        super();
244        this.setEventNumber(eventNumber);
245      }
246
247        /**
248         * @return {@link #eventNumber} (The sequential number of this event in this subscription context.). This is the underlying object with id, value and extensions. The accessor "getEventNumber" gives direct access to the value
249         */
250        public Integer64Type getEventNumberElement() { 
251          if (this.eventNumber == null)
252            if (Configuration.errorOnAutoCreate())
253              throw new Error("Attempt to auto-create SubscriptionStatusNotificationEventComponent.eventNumber");
254            else if (Configuration.doAutoCreate())
255              this.eventNumber = new Integer64Type(); // bb
256          return this.eventNumber;
257        }
258
259        public boolean hasEventNumberElement() { 
260          return this.eventNumber != null && !this.eventNumber.isEmpty();
261        }
262
263        public boolean hasEventNumber() { 
264          return this.eventNumber != null && !this.eventNumber.isEmpty();
265        }
266
267        /**
268         * @param value {@link #eventNumber} (The sequential number of this event in this subscription context.). This is the underlying object with id, value and extensions. The accessor "getEventNumber" gives direct access to the value
269         */
270        public SubscriptionStatusNotificationEventComponent setEventNumberElement(Integer64Type value) { 
271          this.eventNumber = value;
272          return this;
273        }
274
275        /**
276         * @return The sequential number of this event in this subscription context.
277         */
278        public long getEventNumber() { 
279          return this.eventNumber == null || this.eventNumber.isEmpty() ? 0 : this.eventNumber.getValue();
280        }
281
282        /**
283         * @param value The sequential number of this event in this subscription context.
284         */
285        public SubscriptionStatusNotificationEventComponent setEventNumber(long value) { 
286              this.eventNumber = new Integer64Type();
287            this.eventNumber.setValue(value);
288          return this;
289        }
290
291        /**
292         * @return {@link #timestamp} (The actual time this event occured on the server.). This is the underlying object with id, value and extensions. The accessor "getTimestamp" gives direct access to the value
293         */
294        public InstantType getTimestampElement() { 
295          if (this.timestamp == null)
296            if (Configuration.errorOnAutoCreate())
297              throw new Error("Attempt to auto-create SubscriptionStatusNotificationEventComponent.timestamp");
298            else if (Configuration.doAutoCreate())
299              this.timestamp = new InstantType(); // bb
300          return this.timestamp;
301        }
302
303        public boolean hasTimestampElement() { 
304          return this.timestamp != null && !this.timestamp.isEmpty();
305        }
306
307        public boolean hasTimestamp() { 
308          return this.timestamp != null && !this.timestamp.isEmpty();
309        }
310
311        /**
312         * @param value {@link #timestamp} (The actual time this event occured on the server.). This is the underlying object with id, value and extensions. The accessor "getTimestamp" gives direct access to the value
313         */
314        public SubscriptionStatusNotificationEventComponent setTimestampElement(InstantType value) { 
315          this.timestamp = value;
316          return this;
317        }
318
319        /**
320         * @return The actual time this event occured on the server.
321         */
322        public Date getTimestamp() { 
323          return this.timestamp == null ? null : this.timestamp.getValue();
324        }
325
326        /**
327         * @param value The actual time this event occured on the server.
328         */
329        public SubscriptionStatusNotificationEventComponent setTimestamp(Date value) { 
330          if (value == null)
331            this.timestamp = null;
332          else {
333            if (this.timestamp == null)
334              this.timestamp = new InstantType();
335            this.timestamp.setValue(value);
336          }
337          return this;
338        }
339
340        /**
341         * @return {@link #focus} (The focus of this event. While this will usually be a reference to the focus resource of the event, it MAY contain a reference to a non-FHIR object.)
342         */
343        public Reference getFocus() { 
344          if (this.focus == null)
345            if (Configuration.errorOnAutoCreate())
346              throw new Error("Attempt to auto-create SubscriptionStatusNotificationEventComponent.focus");
347            else if (Configuration.doAutoCreate())
348              this.focus = new Reference(); // cc
349          return this.focus;
350        }
351
352        public boolean hasFocus() { 
353          return this.focus != null && !this.focus.isEmpty();
354        }
355
356        /**
357         * @param value {@link #focus} (The focus of this event. While this will usually be a reference to the focus resource of the event, it MAY contain a reference to a non-FHIR object.)
358         */
359        public SubscriptionStatusNotificationEventComponent setFocus(Reference value) { 
360          this.focus = value;
361          return this;
362        }
363
364        /**
365         * @return {@link #additionalContext} (Additional context information for this event. Generally, this will contain references to additional resources included with the event (e.g., the Patient relevant to an Encounter), however it MAY refer to non-FHIR objects.)
366         */
367        public List<Reference> getAdditionalContext() { 
368          if (this.additionalContext == null)
369            this.additionalContext = new ArrayList<Reference>();
370          return this.additionalContext;
371        }
372
373        /**
374         * @return Returns a reference to <code>this</code> for easy method chaining
375         */
376        public SubscriptionStatusNotificationEventComponent setAdditionalContext(List<Reference> theAdditionalContext) { 
377          this.additionalContext = theAdditionalContext;
378          return this;
379        }
380
381        public boolean hasAdditionalContext() { 
382          if (this.additionalContext == null)
383            return false;
384          for (Reference item : this.additionalContext)
385            if (!item.isEmpty())
386              return true;
387          return false;
388        }
389
390        public Reference addAdditionalContext() { //3
391          Reference t = new Reference();
392          if (this.additionalContext == null)
393            this.additionalContext = new ArrayList<Reference>();
394          this.additionalContext.add(t);
395          return t;
396        }
397
398        public SubscriptionStatusNotificationEventComponent addAdditionalContext(Reference t) { //3
399          if (t == null)
400            return this;
401          if (this.additionalContext == null)
402            this.additionalContext = new ArrayList<Reference>();
403          this.additionalContext.add(t);
404          return this;
405        }
406
407        /**
408         * @return The first repetition of repeating field {@link #additionalContext}, creating it if it does not already exist {3}
409         */
410        public Reference getAdditionalContextFirstRep() { 
411          if (getAdditionalContext().isEmpty()) {
412            addAdditionalContext();
413          }
414          return getAdditionalContext().get(0);
415        }
416
417        protected void listChildren(List<Property> children) {
418          super.listChildren(children);
419          children.add(new Property("eventNumber", "integer64", "The sequential number of this event in this subscription context.", 0, 1, eventNumber));
420          children.add(new Property("timestamp", "instant", "The actual time this event occured on the server.", 0, 1, timestamp));
421          children.add(new Property("focus", "Reference(Any)", "The focus of this event. While this will usually be a reference to the focus resource of the event, it MAY contain a reference to a non-FHIR object.", 0, 1, focus));
422          children.add(new Property("additionalContext", "Reference(Any)", "Additional context information for this event. Generally, this will contain references to additional resources included with the event (e.g., the Patient relevant to an Encounter), however it MAY refer to non-FHIR objects.", 0, java.lang.Integer.MAX_VALUE, additionalContext));
423        }
424
425        @Override
426        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
427          switch (_hash) {
428          case -35234173: /*eventNumber*/  return new Property("eventNumber", "integer64", "The sequential number of this event in this subscription context.", 0, 1, eventNumber);
429          case 55126294: /*timestamp*/  return new Property("timestamp", "instant", "The actual time this event occured on the server.", 0, 1, timestamp);
430          case 97604824: /*focus*/  return new Property("focus", "Reference(Any)", "The focus of this event. While this will usually be a reference to the focus resource of the event, it MAY contain a reference to a non-FHIR object.", 0, 1, focus);
431          case -908743800: /*additionalContext*/  return new Property("additionalContext", "Reference(Any)", "Additional context information for this event. Generally, this will contain references to additional resources included with the event (e.g., the Patient relevant to an Encounter), however it MAY refer to non-FHIR objects.", 0, java.lang.Integer.MAX_VALUE, additionalContext);
432          default: return super.getNamedProperty(_hash, _name, _checkValid);
433          }
434
435        }
436
437      @Override
438      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
439        switch (hash) {
440        case -35234173: /*eventNumber*/ return this.eventNumber == null ? new Base[0] : new Base[] {this.eventNumber}; // Integer64Type
441        case 55126294: /*timestamp*/ return this.timestamp == null ? new Base[0] : new Base[] {this.timestamp}; // InstantType
442        case 97604824: /*focus*/ return this.focus == null ? new Base[0] : new Base[] {this.focus}; // Reference
443        case -908743800: /*additionalContext*/ return this.additionalContext == null ? new Base[0] : this.additionalContext.toArray(new Base[this.additionalContext.size()]); // Reference
444        default: return super.getProperty(hash, name, checkValid);
445        }
446
447      }
448
449      @Override
450      public Base setProperty(int hash, String name, Base value) throws FHIRException {
451        switch (hash) {
452        case -35234173: // eventNumber
453          this.eventNumber = TypeConvertor.castToInteger64(value); // Integer64Type
454          return value;
455        case 55126294: // timestamp
456          this.timestamp = TypeConvertor.castToInstant(value); // InstantType
457          return value;
458        case 97604824: // focus
459          this.focus = TypeConvertor.castToReference(value); // Reference
460          return value;
461        case -908743800: // additionalContext
462          this.getAdditionalContext().add(TypeConvertor.castToReference(value)); // Reference
463          return value;
464        default: return super.setProperty(hash, name, value);
465        }
466
467      }
468
469      @Override
470      public Base setProperty(String name, Base value) throws FHIRException {
471        if (name.equals("eventNumber")) {
472          this.eventNumber = TypeConvertor.castToInteger64(value); // Integer64Type
473        } else if (name.equals("timestamp")) {
474          this.timestamp = TypeConvertor.castToInstant(value); // InstantType
475        } else if (name.equals("focus")) {
476          this.focus = TypeConvertor.castToReference(value); // Reference
477        } else if (name.equals("additionalContext")) {
478          this.getAdditionalContext().add(TypeConvertor.castToReference(value));
479        } else
480          return super.setProperty(name, value);
481        return value;
482      }
483
484      @Override
485      public Base makeProperty(int hash, String name) throws FHIRException {
486        switch (hash) {
487        case -35234173:  return getEventNumberElement();
488        case 55126294:  return getTimestampElement();
489        case 97604824:  return getFocus();
490        case -908743800:  return addAdditionalContext(); 
491        default: return super.makeProperty(hash, name);
492        }
493
494      }
495
496      @Override
497      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
498        switch (hash) {
499        case -35234173: /*eventNumber*/ return new String[] {"integer64"};
500        case 55126294: /*timestamp*/ return new String[] {"instant"};
501        case 97604824: /*focus*/ return new String[] {"Reference"};
502        case -908743800: /*additionalContext*/ return new String[] {"Reference"};
503        default: return super.getTypesForProperty(hash, name);
504        }
505
506      }
507
508      @Override
509      public Base addChild(String name) throws FHIRException {
510        if (name.equals("eventNumber")) {
511          throw new FHIRException("Cannot call addChild on a primitive type SubscriptionStatus.notificationEvent.eventNumber");
512        }
513        else if (name.equals("timestamp")) {
514          throw new FHIRException("Cannot call addChild on a primitive type SubscriptionStatus.notificationEvent.timestamp");
515        }
516        else if (name.equals("focus")) {
517          this.focus = new Reference();
518          return this.focus;
519        }
520        else if (name.equals("additionalContext")) {
521          return addAdditionalContext();
522        }
523        else
524          return super.addChild(name);
525      }
526
527      public SubscriptionStatusNotificationEventComponent copy() {
528        SubscriptionStatusNotificationEventComponent dst = new SubscriptionStatusNotificationEventComponent();
529        copyValues(dst);
530        return dst;
531      }
532
533      public void copyValues(SubscriptionStatusNotificationEventComponent dst) {
534        super.copyValues(dst);
535        dst.eventNumber = eventNumber == null ? null : eventNumber.copy();
536        dst.timestamp = timestamp == null ? null : timestamp.copy();
537        dst.focus = focus == null ? null : focus.copy();
538        if (additionalContext != null) {
539          dst.additionalContext = new ArrayList<Reference>();
540          for (Reference i : additionalContext)
541            dst.additionalContext.add(i.copy());
542        };
543      }
544
545      @Override
546      public boolean equalsDeep(Base other_) {
547        if (!super.equalsDeep(other_))
548          return false;
549        if (!(other_ instanceof SubscriptionStatusNotificationEventComponent))
550          return false;
551        SubscriptionStatusNotificationEventComponent o = (SubscriptionStatusNotificationEventComponent) other_;
552        return compareDeep(eventNumber, o.eventNumber, true) && compareDeep(timestamp, o.timestamp, true)
553           && compareDeep(focus, o.focus, true) && compareDeep(additionalContext, o.additionalContext, true)
554          ;
555      }
556
557      @Override
558      public boolean equalsShallow(Base other_) {
559        if (!super.equalsShallow(other_))
560          return false;
561        if (!(other_ instanceof SubscriptionStatusNotificationEventComponent))
562          return false;
563        SubscriptionStatusNotificationEventComponent o = (SubscriptionStatusNotificationEventComponent) other_;
564        return compareValues(eventNumber, o.eventNumber, true) && compareValues(timestamp, o.timestamp, true)
565          ;
566      }
567
568      public boolean isEmpty() {
569        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(eventNumber, timestamp, focus
570          , additionalContext);
571      }
572
573  public String fhirType() {
574    return "SubscriptionStatus.notificationEvent";
575
576  }
577
578  }
579
580    /**
581     * The status of the subscription, which marks the server state for managing the subscription.
582     */
583    @Child(name = "status", type = {CodeType.class}, order=0, min=0, max=1, modifier=false, summary=true)
584    @Description(shortDefinition="requested | active | error | off | entered-in-error", formalDefinition="The status of the subscription, which marks the server state for managing the subscription." )
585    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/subscription-status")
586    protected Enumeration<SubscriptionStatusCodes> status;
587
588    /**
589     * The type of event being conveyed with this notificaiton.
590     */
591    @Child(name = "type", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true)
592    @Description(shortDefinition="handshake | heartbeat | event-notification | query-status | query-event", formalDefinition="The type of event being conveyed with this notificaiton." )
593    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/subscription-notification-type")
594    protected Enumeration<SubscriptionNotificationType> type;
595
596    /**
597     * The total number of actual events which have been generated since the Subscription was created (inclusive of this notification) - regardless of how many have been successfully communicated.  This number is NOT incremented for handshake and heartbeat notifications.
598     */
599    @Child(name = "eventsSinceSubscriptionStart", type = {Integer64Type.class}, order=2, min=0, max=1, modifier=false, summary=true)
600    @Description(shortDefinition="Events since the Subscription was created", formalDefinition="The total number of actual events which have been generated since the Subscription was created (inclusive of this notification) - regardless of how many have been successfully communicated.  This number is NOT incremented for handshake and heartbeat notifications." )
601    protected Integer64Type eventsSinceSubscriptionStart;
602
603    /**
604     * Detailed information about events relevant to this subscription notification.
605     */
606    @Child(name = "notificationEvent", type = {}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
607    @Description(shortDefinition="Detailed information about any events relevant to this notification", formalDefinition="Detailed information about events relevant to this subscription notification." )
608    protected List<SubscriptionStatusNotificationEventComponent> notificationEvent;
609
610    /**
611     * The reference to the Subscription which generated this notification.
612     */
613    @Child(name = "subscription", type = {Subscription.class}, order=4, min=1, max=1, modifier=false, summary=true)
614    @Description(shortDefinition="Reference to the Subscription responsible for this notification", formalDefinition="The reference to the Subscription which generated this notification." )
615    protected Reference subscription;
616
617    /**
618     * The reference to the SubscriptionTopic for the Subscription which generated this notification.
619     */
620    @Child(name = "topic", type = {CanonicalType.class}, order=5, min=0, max=1, modifier=false, summary=true)
621    @Description(shortDefinition="Reference to the SubscriptionTopic this notification relates to", formalDefinition="The reference to the SubscriptionTopic for the Subscription which generated this notification." )
622    protected CanonicalType topic;
623
624    /**
625     * A record of errors that occurred when the server processed a notification.
626     */
627    @Child(name = "error", type = {CodeableConcept.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
628    @Description(shortDefinition="List of errors on the subscription", formalDefinition="A record of errors that occurred when the server processed a notification." )
629    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/subscription-error")
630    protected List<CodeableConcept> error;
631
632    private static final long serialVersionUID = -285503955L;
633
634  /**
635   * Constructor
636   */
637    public SubscriptionStatus() {
638      super();
639    }
640
641  /**
642   * Constructor
643   */
644    public SubscriptionStatus(SubscriptionNotificationType type, Reference subscription) {
645      super();
646      this.setType(type);
647      this.setSubscription(subscription);
648    }
649
650    /**
651     * @return {@link #status} (The status of the subscription, which marks the server state for managing the subscription.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
652     */
653    public Enumeration<SubscriptionStatusCodes> getStatusElement() { 
654      if (this.status == null)
655        if (Configuration.errorOnAutoCreate())
656          throw new Error("Attempt to auto-create SubscriptionStatus.status");
657        else if (Configuration.doAutoCreate())
658          this.status = new Enumeration<SubscriptionStatusCodes>(new SubscriptionStatusCodesEnumFactory()); // bb
659      return this.status;
660    }
661
662    public boolean hasStatusElement() { 
663      return this.status != null && !this.status.isEmpty();
664    }
665
666    public boolean hasStatus() { 
667      return this.status != null && !this.status.isEmpty();
668    }
669
670    /**
671     * @param value {@link #status} (The status of the subscription, which marks the server state for managing the subscription.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
672     */
673    public SubscriptionStatus setStatusElement(Enumeration<SubscriptionStatusCodes> value) { 
674      this.status = value;
675      return this;
676    }
677
678    /**
679     * @return The status of the subscription, which marks the server state for managing the subscription.
680     */
681    public SubscriptionStatusCodes getStatus() { 
682      return this.status == null ? null : this.status.getValue();
683    }
684
685    /**
686     * @param value The status of the subscription, which marks the server state for managing the subscription.
687     */
688    public SubscriptionStatus setStatus(SubscriptionStatusCodes value) { 
689      if (value == null)
690        this.status = null;
691      else {
692        if (this.status == null)
693          this.status = new Enumeration<SubscriptionStatusCodes>(new SubscriptionStatusCodesEnumFactory());
694        this.status.setValue(value);
695      }
696      return this;
697    }
698
699    /**
700     * @return {@link #type} (The type of event being conveyed with this notificaiton.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
701     */
702    public Enumeration<SubscriptionNotificationType> getTypeElement() { 
703      if (this.type == null)
704        if (Configuration.errorOnAutoCreate())
705          throw new Error("Attempt to auto-create SubscriptionStatus.type");
706        else if (Configuration.doAutoCreate())
707          this.type = new Enumeration<SubscriptionNotificationType>(new SubscriptionNotificationTypeEnumFactory()); // bb
708      return this.type;
709    }
710
711    public boolean hasTypeElement() { 
712      return this.type != null && !this.type.isEmpty();
713    }
714
715    public boolean hasType() { 
716      return this.type != null && !this.type.isEmpty();
717    }
718
719    /**
720     * @param value {@link #type} (The type of event being conveyed with this notificaiton.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
721     */
722    public SubscriptionStatus setTypeElement(Enumeration<SubscriptionNotificationType> value) { 
723      this.type = value;
724      return this;
725    }
726
727    /**
728     * @return The type of event being conveyed with this notificaiton.
729     */
730    public SubscriptionNotificationType getType() { 
731      return this.type == null ? null : this.type.getValue();
732    }
733
734    /**
735     * @param value The type of event being conveyed with this notificaiton.
736     */
737    public SubscriptionStatus setType(SubscriptionNotificationType value) { 
738        if (this.type == null)
739          this.type = new Enumeration<SubscriptionNotificationType>(new SubscriptionNotificationTypeEnumFactory());
740        this.type.setValue(value);
741      return this;
742    }
743
744    /**
745     * @return {@link #eventsSinceSubscriptionStart} (The total number of actual events which have been generated since the Subscription was created (inclusive of this notification) - regardless of how many have been successfully communicated.  This number is NOT incremented for handshake and heartbeat notifications.). This is the underlying object with id, value and extensions. The accessor "getEventsSinceSubscriptionStart" gives direct access to the value
746     */
747    public Integer64Type getEventsSinceSubscriptionStartElement() { 
748      if (this.eventsSinceSubscriptionStart == null)
749        if (Configuration.errorOnAutoCreate())
750          throw new Error("Attempt to auto-create SubscriptionStatus.eventsSinceSubscriptionStart");
751        else if (Configuration.doAutoCreate())
752          this.eventsSinceSubscriptionStart = new Integer64Type(); // bb
753      return this.eventsSinceSubscriptionStart;
754    }
755
756    public boolean hasEventsSinceSubscriptionStartElement() { 
757      return this.eventsSinceSubscriptionStart != null && !this.eventsSinceSubscriptionStart.isEmpty();
758    }
759
760    public boolean hasEventsSinceSubscriptionStart() { 
761      return this.eventsSinceSubscriptionStart != null && !this.eventsSinceSubscriptionStart.isEmpty();
762    }
763
764    /**
765     * @param value {@link #eventsSinceSubscriptionStart} (The total number of actual events which have been generated since the Subscription was created (inclusive of this notification) - regardless of how many have been successfully communicated.  This number is NOT incremented for handshake and heartbeat notifications.). This is the underlying object with id, value and extensions. The accessor "getEventsSinceSubscriptionStart" gives direct access to the value
766     */
767    public SubscriptionStatus setEventsSinceSubscriptionStartElement(Integer64Type value) { 
768      this.eventsSinceSubscriptionStart = value;
769      return this;
770    }
771
772    /**
773     * @return The total number of actual events which have been generated since the Subscription was created (inclusive of this notification) - regardless of how many have been successfully communicated.  This number is NOT incremented for handshake and heartbeat notifications.
774     */
775    public long getEventsSinceSubscriptionStart() { 
776      return this.eventsSinceSubscriptionStart == null || this.eventsSinceSubscriptionStart.isEmpty() ? 0 : this.eventsSinceSubscriptionStart.getValue();
777    }
778
779    /**
780     * @param value The total number of actual events which have been generated since the Subscription was created (inclusive of this notification) - regardless of how many have been successfully communicated.  This number is NOT incremented for handshake and heartbeat notifications.
781     */
782    public SubscriptionStatus setEventsSinceSubscriptionStart(long value) { 
783          this.eventsSinceSubscriptionStart = new Integer64Type();
784        this.eventsSinceSubscriptionStart.setValue(value);
785      return this;
786    }
787
788    /**
789     * @return {@link #notificationEvent} (Detailed information about events relevant to this subscription notification.)
790     */
791    public List<SubscriptionStatusNotificationEventComponent> getNotificationEvent() { 
792      if (this.notificationEvent == null)
793        this.notificationEvent = new ArrayList<SubscriptionStatusNotificationEventComponent>();
794      return this.notificationEvent;
795    }
796
797    /**
798     * @return Returns a reference to <code>this</code> for easy method chaining
799     */
800    public SubscriptionStatus setNotificationEvent(List<SubscriptionStatusNotificationEventComponent> theNotificationEvent) { 
801      this.notificationEvent = theNotificationEvent;
802      return this;
803    }
804
805    public boolean hasNotificationEvent() { 
806      if (this.notificationEvent == null)
807        return false;
808      for (SubscriptionStatusNotificationEventComponent item : this.notificationEvent)
809        if (!item.isEmpty())
810          return true;
811      return false;
812    }
813
814    public SubscriptionStatusNotificationEventComponent addNotificationEvent() { //3
815      SubscriptionStatusNotificationEventComponent t = new SubscriptionStatusNotificationEventComponent();
816      if (this.notificationEvent == null)
817        this.notificationEvent = new ArrayList<SubscriptionStatusNotificationEventComponent>();
818      this.notificationEvent.add(t);
819      return t;
820    }
821
822    public SubscriptionStatus addNotificationEvent(SubscriptionStatusNotificationEventComponent t) { //3
823      if (t == null)
824        return this;
825      if (this.notificationEvent == null)
826        this.notificationEvent = new ArrayList<SubscriptionStatusNotificationEventComponent>();
827      this.notificationEvent.add(t);
828      return this;
829    }
830
831    /**
832     * @return The first repetition of repeating field {@link #notificationEvent}, creating it if it does not already exist {3}
833     */
834    public SubscriptionStatusNotificationEventComponent getNotificationEventFirstRep() { 
835      if (getNotificationEvent().isEmpty()) {
836        addNotificationEvent();
837      }
838      return getNotificationEvent().get(0);
839    }
840
841    /**
842     * @return {@link #subscription} (The reference to the Subscription which generated this notification.)
843     */
844    public Reference getSubscription() { 
845      if (this.subscription == null)
846        if (Configuration.errorOnAutoCreate())
847          throw new Error("Attempt to auto-create SubscriptionStatus.subscription");
848        else if (Configuration.doAutoCreate())
849          this.subscription = new Reference(); // cc
850      return this.subscription;
851    }
852
853    public boolean hasSubscription() { 
854      return this.subscription != null && !this.subscription.isEmpty();
855    }
856
857    /**
858     * @param value {@link #subscription} (The reference to the Subscription which generated this notification.)
859     */
860    public SubscriptionStatus setSubscription(Reference value) { 
861      this.subscription = value;
862      return this;
863    }
864
865    /**
866     * @return {@link #topic} (The reference to the SubscriptionTopic for the Subscription which generated this notification.). This is the underlying object with id, value and extensions. The accessor "getTopic" gives direct access to the value
867     */
868    public CanonicalType getTopicElement() { 
869      if (this.topic == null)
870        if (Configuration.errorOnAutoCreate())
871          throw new Error("Attempt to auto-create SubscriptionStatus.topic");
872        else if (Configuration.doAutoCreate())
873          this.topic = new CanonicalType(); // bb
874      return this.topic;
875    }
876
877    public boolean hasTopicElement() { 
878      return this.topic != null && !this.topic.isEmpty();
879    }
880
881    public boolean hasTopic() { 
882      return this.topic != null && !this.topic.isEmpty();
883    }
884
885    /**
886     * @param value {@link #topic} (The reference to the SubscriptionTopic for the Subscription which generated this notification.). This is the underlying object with id, value and extensions. The accessor "getTopic" gives direct access to the value
887     */
888    public SubscriptionStatus setTopicElement(CanonicalType value) { 
889      this.topic = value;
890      return this;
891    }
892
893    /**
894     * @return The reference to the SubscriptionTopic for the Subscription which generated this notification.
895     */
896    public String getTopic() { 
897      return this.topic == null ? null : this.topic.getValue();
898    }
899
900    /**
901     * @param value The reference to the SubscriptionTopic for the Subscription which generated this notification.
902     */
903    public SubscriptionStatus setTopic(String value) { 
904      if (Utilities.noString(value))
905        this.topic = null;
906      else {
907        if (this.topic == null)
908          this.topic = new CanonicalType();
909        this.topic.setValue(value);
910      }
911      return this;
912    }
913
914    /**
915     * @return {@link #error} (A record of errors that occurred when the server processed a notification.)
916     */
917    public List<CodeableConcept> getError() { 
918      if (this.error == null)
919        this.error = new ArrayList<CodeableConcept>();
920      return this.error;
921    }
922
923    /**
924     * @return Returns a reference to <code>this</code> for easy method chaining
925     */
926    public SubscriptionStatus setError(List<CodeableConcept> theError) { 
927      this.error = theError;
928      return this;
929    }
930
931    public boolean hasError() { 
932      if (this.error == null)
933        return false;
934      for (CodeableConcept item : this.error)
935        if (!item.isEmpty())
936          return true;
937      return false;
938    }
939
940    public CodeableConcept addError() { //3
941      CodeableConcept t = new CodeableConcept();
942      if (this.error == null)
943        this.error = new ArrayList<CodeableConcept>();
944      this.error.add(t);
945      return t;
946    }
947
948    public SubscriptionStatus addError(CodeableConcept t) { //3
949      if (t == null)
950        return this;
951      if (this.error == null)
952        this.error = new ArrayList<CodeableConcept>();
953      this.error.add(t);
954      return this;
955    }
956
957    /**
958     * @return The first repetition of repeating field {@link #error}, creating it if it does not already exist {3}
959     */
960    public CodeableConcept getErrorFirstRep() { 
961      if (getError().isEmpty()) {
962        addError();
963      }
964      return getError().get(0);
965    }
966
967      protected void listChildren(List<Property> children) {
968        super.listChildren(children);
969        children.add(new Property("status", "code", "The status of the subscription, which marks the server state for managing the subscription.", 0, 1, status));
970        children.add(new Property("type", "code", "The type of event being conveyed with this notificaiton.", 0, 1, type));
971        children.add(new Property("eventsSinceSubscriptionStart", "integer64", "The total number of actual events which have been generated since the Subscription was created (inclusive of this notification) - regardless of how many have been successfully communicated.  This number is NOT incremented for handshake and heartbeat notifications.", 0, 1, eventsSinceSubscriptionStart));
972        children.add(new Property("notificationEvent", "", "Detailed information about events relevant to this subscription notification.", 0, java.lang.Integer.MAX_VALUE, notificationEvent));
973        children.add(new Property("subscription", "Reference(Subscription)", "The reference to the Subscription which generated this notification.", 0, 1, subscription));
974        children.add(new Property("topic", "canonical(SubscriptionTopic)", "The reference to the SubscriptionTopic for the Subscription which generated this notification.", 0, 1, topic));
975        children.add(new Property("error", "CodeableConcept", "A record of errors that occurred when the server processed a notification.", 0, java.lang.Integer.MAX_VALUE, error));
976      }
977
978      @Override
979      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
980        switch (_hash) {
981        case -892481550: /*status*/  return new Property("status", "code", "The status of the subscription, which marks the server state for managing the subscription.", 0, 1, status);
982        case 3575610: /*type*/  return new Property("type", "code", "The type of event being conveyed with this notificaiton.", 0, 1, type);
983        case 304566692: /*eventsSinceSubscriptionStart*/  return new Property("eventsSinceSubscriptionStart", "integer64", "The total number of actual events which have been generated since the Subscription was created (inclusive of this notification) - regardless of how many have been successfully communicated.  This number is NOT incremented for handshake and heartbeat notifications.", 0, 1, eventsSinceSubscriptionStart);
984        case -1595878289: /*notificationEvent*/  return new Property("notificationEvent", "", "Detailed information about events relevant to this subscription notification.", 0, java.lang.Integer.MAX_VALUE, notificationEvent);
985        case 341203229: /*subscription*/  return new Property("subscription", "Reference(Subscription)", "The reference to the Subscription which generated this notification.", 0, 1, subscription);
986        case 110546223: /*topic*/  return new Property("topic", "canonical(SubscriptionTopic)", "The reference to the SubscriptionTopic for the Subscription which generated this notification.", 0, 1, topic);
987        case 96784904: /*error*/  return new Property("error", "CodeableConcept", "A record of errors that occurred when the server processed a notification.", 0, java.lang.Integer.MAX_VALUE, error);
988        default: return super.getNamedProperty(_hash, _name, _checkValid);
989        }
990
991      }
992
993      @Override
994      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
995        switch (hash) {
996        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<SubscriptionStatusCodes>
997        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // Enumeration<SubscriptionNotificationType>
998        case 304566692: /*eventsSinceSubscriptionStart*/ return this.eventsSinceSubscriptionStart == null ? new Base[0] : new Base[] {this.eventsSinceSubscriptionStart}; // Integer64Type
999        case -1595878289: /*notificationEvent*/ return this.notificationEvent == null ? new Base[0] : this.notificationEvent.toArray(new Base[this.notificationEvent.size()]); // SubscriptionStatusNotificationEventComponent
1000        case 341203229: /*subscription*/ return this.subscription == null ? new Base[0] : new Base[] {this.subscription}; // Reference
1001        case 110546223: /*topic*/ return this.topic == null ? new Base[0] : new Base[] {this.topic}; // CanonicalType
1002        case 96784904: /*error*/ return this.error == null ? new Base[0] : this.error.toArray(new Base[this.error.size()]); // CodeableConcept
1003        default: return super.getProperty(hash, name, checkValid);
1004        }
1005
1006      }
1007
1008      @Override
1009      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1010        switch (hash) {
1011        case -892481550: // status
1012          value = new SubscriptionStatusCodesEnumFactory().fromType(TypeConvertor.castToCode(value));
1013          this.status = (Enumeration) value; // Enumeration<SubscriptionStatusCodes>
1014          return value;
1015        case 3575610: // type
1016          value = new SubscriptionNotificationTypeEnumFactory().fromType(TypeConvertor.castToCode(value));
1017          this.type = (Enumeration) value; // Enumeration<SubscriptionNotificationType>
1018          return value;
1019        case 304566692: // eventsSinceSubscriptionStart
1020          this.eventsSinceSubscriptionStart = TypeConvertor.castToInteger64(value); // Integer64Type
1021          return value;
1022        case -1595878289: // notificationEvent
1023          this.getNotificationEvent().add((SubscriptionStatusNotificationEventComponent) value); // SubscriptionStatusNotificationEventComponent
1024          return value;
1025        case 341203229: // subscription
1026          this.subscription = TypeConvertor.castToReference(value); // Reference
1027          return value;
1028        case 110546223: // topic
1029          this.topic = TypeConvertor.castToCanonical(value); // CanonicalType
1030          return value;
1031        case 96784904: // error
1032          this.getError().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
1033          return value;
1034        default: return super.setProperty(hash, name, value);
1035        }
1036
1037      }
1038
1039      @Override
1040      public Base setProperty(String name, Base value) throws FHIRException {
1041        if (name.equals("status")) {
1042          value = new SubscriptionStatusCodesEnumFactory().fromType(TypeConvertor.castToCode(value));
1043          this.status = (Enumeration) value; // Enumeration<SubscriptionStatusCodes>
1044        } else if (name.equals("type")) {
1045          value = new SubscriptionNotificationTypeEnumFactory().fromType(TypeConvertor.castToCode(value));
1046          this.type = (Enumeration) value; // Enumeration<SubscriptionNotificationType>
1047        } else if (name.equals("eventsSinceSubscriptionStart")) {
1048          this.eventsSinceSubscriptionStart = TypeConvertor.castToInteger64(value); // Integer64Type
1049        } else if (name.equals("notificationEvent")) {
1050          this.getNotificationEvent().add((SubscriptionStatusNotificationEventComponent) value);
1051        } else if (name.equals("subscription")) {
1052          this.subscription = TypeConvertor.castToReference(value); // Reference
1053        } else if (name.equals("topic")) {
1054          this.topic = TypeConvertor.castToCanonical(value); // CanonicalType
1055        } else if (name.equals("error")) {
1056          this.getError().add(TypeConvertor.castToCodeableConcept(value));
1057        } else
1058          return super.setProperty(name, value);
1059        return value;
1060      }
1061
1062      @Override
1063      public Base makeProperty(int hash, String name) throws FHIRException {
1064        switch (hash) {
1065        case -892481550:  return getStatusElement();
1066        case 3575610:  return getTypeElement();
1067        case 304566692:  return getEventsSinceSubscriptionStartElement();
1068        case -1595878289:  return addNotificationEvent(); 
1069        case 341203229:  return getSubscription();
1070        case 110546223:  return getTopicElement();
1071        case 96784904:  return addError(); 
1072        default: return super.makeProperty(hash, name);
1073        }
1074
1075      }
1076
1077      @Override
1078      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1079        switch (hash) {
1080        case -892481550: /*status*/ return new String[] {"code"};
1081        case 3575610: /*type*/ return new String[] {"code"};
1082        case 304566692: /*eventsSinceSubscriptionStart*/ return new String[] {"integer64"};
1083        case -1595878289: /*notificationEvent*/ return new String[] {};
1084        case 341203229: /*subscription*/ return new String[] {"Reference"};
1085        case 110546223: /*topic*/ return new String[] {"canonical"};
1086        case 96784904: /*error*/ return new String[] {"CodeableConcept"};
1087        default: return super.getTypesForProperty(hash, name);
1088        }
1089
1090      }
1091
1092      @Override
1093      public Base addChild(String name) throws FHIRException {
1094        if (name.equals("status")) {
1095          throw new FHIRException("Cannot call addChild on a primitive type SubscriptionStatus.status");
1096        }
1097        else if (name.equals("type")) {
1098          throw new FHIRException("Cannot call addChild on a primitive type SubscriptionStatus.type");
1099        }
1100        else if (name.equals("eventsSinceSubscriptionStart")) {
1101          throw new FHIRException("Cannot call addChild on a primitive type SubscriptionStatus.eventsSinceSubscriptionStart");
1102        }
1103        else if (name.equals("notificationEvent")) {
1104          return addNotificationEvent();
1105        }
1106        else if (name.equals("subscription")) {
1107          this.subscription = new Reference();
1108          return this.subscription;
1109        }
1110        else if (name.equals("topic")) {
1111          throw new FHIRException("Cannot call addChild on a primitive type SubscriptionStatus.topic");
1112        }
1113        else if (name.equals("error")) {
1114          return addError();
1115        }
1116        else
1117          return super.addChild(name);
1118      }
1119
1120  public String fhirType() {
1121    return "SubscriptionStatus";
1122
1123  }
1124
1125      public SubscriptionStatus copy() {
1126        SubscriptionStatus dst = new SubscriptionStatus();
1127        copyValues(dst);
1128        return dst;
1129      }
1130
1131      public void copyValues(SubscriptionStatus dst) {
1132        super.copyValues(dst);
1133        dst.status = status == null ? null : status.copy();
1134        dst.type = type == null ? null : type.copy();
1135        dst.eventsSinceSubscriptionStart = eventsSinceSubscriptionStart == null ? null : eventsSinceSubscriptionStart.copy();
1136        if (notificationEvent != null) {
1137          dst.notificationEvent = new ArrayList<SubscriptionStatusNotificationEventComponent>();
1138          for (SubscriptionStatusNotificationEventComponent i : notificationEvent)
1139            dst.notificationEvent.add(i.copy());
1140        };
1141        dst.subscription = subscription == null ? null : subscription.copy();
1142        dst.topic = topic == null ? null : topic.copy();
1143        if (error != null) {
1144          dst.error = new ArrayList<CodeableConcept>();
1145          for (CodeableConcept i : error)
1146            dst.error.add(i.copy());
1147        };
1148      }
1149
1150      protected SubscriptionStatus typedCopy() {
1151        return copy();
1152      }
1153
1154      @Override
1155      public boolean equalsDeep(Base other_) {
1156        if (!super.equalsDeep(other_))
1157          return false;
1158        if (!(other_ instanceof SubscriptionStatus))
1159          return false;
1160        SubscriptionStatus o = (SubscriptionStatus) other_;
1161        return compareDeep(status, o.status, true) && compareDeep(type, o.type, true) && compareDeep(eventsSinceSubscriptionStart, o.eventsSinceSubscriptionStart, true)
1162           && compareDeep(notificationEvent, o.notificationEvent, true) && compareDeep(subscription, o.subscription, true)
1163           && compareDeep(topic, o.topic, true) && compareDeep(error, o.error, true);
1164      }
1165
1166      @Override
1167      public boolean equalsShallow(Base other_) {
1168        if (!super.equalsShallow(other_))
1169          return false;
1170        if (!(other_ instanceof SubscriptionStatus))
1171          return false;
1172        SubscriptionStatus o = (SubscriptionStatus) other_;
1173        return compareValues(status, o.status, true) && compareValues(type, o.type, true) && compareValues(eventsSinceSubscriptionStart, o.eventsSinceSubscriptionStart, true)
1174           && compareValues(topic, o.topic, true);
1175      }
1176
1177      public boolean isEmpty() {
1178        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(status, type, eventsSinceSubscriptionStart
1179          , notificationEvent, subscription, topic, error);
1180      }
1181
1182  @Override
1183  public ResourceType getResourceType() {
1184    return ResourceType.SubscriptionStatus;
1185   }
1186
1187
1188}
1189