001package org.hl7.fhir.r4.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Thu, Sep 13, 2018 09:04-0400 for FHIR v3.5.0
033
034import java.util.*;
035
036import org.hl7.fhir.utilities.Utilities;
037import ca.uhn.fhir.model.api.annotation.ResourceDef;
038import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
039import ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.ChildOrder;
041import ca.uhn.fhir.model.api.annotation.Description;
042import ca.uhn.fhir.model.api.annotation.Block;
043import org.hl7.fhir.instance.model.api.*;
044import org.hl7.fhir.exceptions.FHIRException;
045/**
046 * The subscription resource is used to define a push-based subscription from a server to another system. Once a subscription is registered with the server, the server checks every resource that is created or updated, and if the resource matches the given criteria, it sends a message on the defined "channel" so that another system can take an appropriate action.
047 */
048@ResourceDef(name="Subscription", profile="http://hl7.org/fhir/StructureDefinition/Subscription")
049public class Subscription extends DomainResource {
050
051    public enum SubscriptionStatus {
052        /**
053         * The client has requested the subscription, and the server has not yet set it up.
054         */
055        REQUESTED, 
056        /**
057         * The subscription is active.
058         */
059        ACTIVE, 
060        /**
061         * The server has an error executing the notification.
062         */
063        ERROR, 
064        /**
065         * Too many errors have occurred or the subscription has expired.
066         */
067        OFF, 
068        /**
069         * added to help the parsers with the generic types
070         */
071        NULL;
072        public static SubscriptionStatus fromCode(String codeString) throws FHIRException {
073            if (codeString == null || "".equals(codeString))
074                return null;
075        if ("requested".equals(codeString))
076          return REQUESTED;
077        if ("active".equals(codeString))
078          return ACTIVE;
079        if ("error".equals(codeString))
080          return ERROR;
081        if ("off".equals(codeString))
082          return OFF;
083        if (Configuration.isAcceptInvalidEnums())
084          return null;
085        else
086          throw new FHIRException("Unknown SubscriptionStatus code '"+codeString+"'");
087        }
088        public String toCode() {
089          switch (this) {
090            case REQUESTED: return "requested";
091            case ACTIVE: return "active";
092            case ERROR: return "error";
093            case OFF: return "off";
094            default: return "?";
095          }
096        }
097        public String getSystem() {
098          switch (this) {
099            case REQUESTED: return "http://hl7.org/fhir/subscription-status";
100            case ACTIVE: return "http://hl7.org/fhir/subscription-status";
101            case ERROR: return "http://hl7.org/fhir/subscription-status";
102            case OFF: return "http://hl7.org/fhir/subscription-status";
103            default: return "?";
104          }
105        }
106        public String getDefinition() {
107          switch (this) {
108            case REQUESTED: return "The client has requested the subscription, and the server has not yet set it up.";
109            case ACTIVE: return "The subscription is active.";
110            case ERROR: return "The server has an error executing the notification.";
111            case OFF: return "Too many errors have occurred or the subscription has expired.";
112            default: return "?";
113          }
114        }
115        public String getDisplay() {
116          switch (this) {
117            case REQUESTED: return "Requested";
118            case ACTIVE: return "Active";
119            case ERROR: return "Error";
120            case OFF: return "Off";
121            default: return "?";
122          }
123        }
124    }
125
126  public static class SubscriptionStatusEnumFactory implements EnumFactory<SubscriptionStatus> {
127    public SubscriptionStatus fromCode(String codeString) throws IllegalArgumentException {
128      if (codeString == null || "".equals(codeString))
129            if (codeString == null || "".equals(codeString))
130                return null;
131        if ("requested".equals(codeString))
132          return SubscriptionStatus.REQUESTED;
133        if ("active".equals(codeString))
134          return SubscriptionStatus.ACTIVE;
135        if ("error".equals(codeString))
136          return SubscriptionStatus.ERROR;
137        if ("off".equals(codeString))
138          return SubscriptionStatus.OFF;
139        throw new IllegalArgumentException("Unknown SubscriptionStatus code '"+codeString+"'");
140        }
141        public Enumeration<SubscriptionStatus> fromType(Base code) throws FHIRException {
142          if (code == null)
143            return null;
144          if (code.isEmpty())
145            return new Enumeration<SubscriptionStatus>(this);
146          String codeString = ((PrimitiveType) code).asStringValue();
147          if (codeString == null || "".equals(codeString))
148            return null;
149        if ("requested".equals(codeString))
150          return new Enumeration<SubscriptionStatus>(this, SubscriptionStatus.REQUESTED);
151        if ("active".equals(codeString))
152          return new Enumeration<SubscriptionStatus>(this, SubscriptionStatus.ACTIVE);
153        if ("error".equals(codeString))
154          return new Enumeration<SubscriptionStatus>(this, SubscriptionStatus.ERROR);
155        if ("off".equals(codeString))
156          return new Enumeration<SubscriptionStatus>(this, SubscriptionStatus.OFF);
157        throw new FHIRException("Unknown SubscriptionStatus code '"+codeString+"'");
158        }
159    public String toCode(SubscriptionStatus code) {
160      if (code == SubscriptionStatus.REQUESTED)
161        return "requested";
162      if (code == SubscriptionStatus.ACTIVE)
163        return "active";
164      if (code == SubscriptionStatus.ERROR)
165        return "error";
166      if (code == SubscriptionStatus.OFF)
167        return "off";
168      return "?";
169      }
170    public String toSystem(SubscriptionStatus code) {
171      return code.getSystem();
172      }
173    }
174
175    public enum SubscriptionChannelType {
176        /**
177         * The channel is executed by making a post to the URI. If a payload is included, the URL is interpreted as the service base, and an update (PUT) is made.
178         */
179        RESTHOOK, 
180        /**
181         * The channel is executed by sending a packet across a web socket connection maintained by the client. The URL identifies the websocket, and the client binds to this URL.
182         */
183        WEBSOCKET, 
184        /**
185         * The channel is executed by sending an email to the email addressed in the URI (which must be a mailto:).
186         */
187        EMAIL, 
188        /**
189         * The channel is executed by sending an SMS message to the phone number identified in the URL (tel:).
190         */
191        SMS, 
192        /**
193         * The channel is executed by sending a message (e.g. a Bundle with a MessageHeader resource etc.) to the application identified in the URI.
194         */
195        MESSAGE, 
196        /**
197         * added to help the parsers with the generic types
198         */
199        NULL;
200        public static SubscriptionChannelType fromCode(String codeString) throws FHIRException {
201            if (codeString == null || "".equals(codeString))
202                return null;
203        if ("rest-hook".equals(codeString))
204          return RESTHOOK;
205        if ("websocket".equals(codeString))
206          return WEBSOCKET;
207        if ("email".equals(codeString))
208          return EMAIL;
209        if ("sms".equals(codeString))
210          return SMS;
211        if ("message".equals(codeString))
212          return MESSAGE;
213        if (Configuration.isAcceptInvalidEnums())
214          return null;
215        else
216          throw new FHIRException("Unknown SubscriptionChannelType code '"+codeString+"'");
217        }
218        public String toCode() {
219          switch (this) {
220            case RESTHOOK: return "rest-hook";
221            case WEBSOCKET: return "websocket";
222            case EMAIL: return "email";
223            case SMS: return "sms";
224            case MESSAGE: return "message";
225            default: return "?";
226          }
227        }
228        public String getSystem() {
229          switch (this) {
230            case RESTHOOK: return "http://hl7.org/fhir/subscription-channel-type";
231            case WEBSOCKET: return "http://hl7.org/fhir/subscription-channel-type";
232            case EMAIL: return "http://hl7.org/fhir/subscription-channel-type";
233            case SMS: return "http://hl7.org/fhir/subscription-channel-type";
234            case MESSAGE: return "http://hl7.org/fhir/subscription-channel-type";
235            default: return "?";
236          }
237        }
238        public String getDefinition() {
239          switch (this) {
240            case RESTHOOK: return "The channel is executed by making a post to the URI. If a payload is included, the URL is interpreted as the service base, and an update (PUT) is made.";
241            case WEBSOCKET: return "The channel is executed by sending a packet across a web socket connection maintained by the client. The URL identifies the websocket, and the client binds to this URL.";
242            case EMAIL: return "The channel is executed by sending an email to the email addressed in the URI (which must be a mailto:).";
243            case SMS: return "The channel is executed by sending an SMS message to the phone number identified in the URL (tel:).";
244            case MESSAGE: return "The channel is executed by sending a message (e.g. a Bundle with a MessageHeader resource etc.) to the application identified in the URI.";
245            default: return "?";
246          }
247        }
248        public String getDisplay() {
249          switch (this) {
250            case RESTHOOK: return "Rest Hook";
251            case WEBSOCKET: return "Websocket";
252            case EMAIL: return "Email";
253            case SMS: return "SMS";
254            case MESSAGE: return "Message";
255            default: return "?";
256          }
257        }
258    }
259
260  public static class SubscriptionChannelTypeEnumFactory implements EnumFactory<SubscriptionChannelType> {
261    public SubscriptionChannelType fromCode(String codeString) throws IllegalArgumentException {
262      if (codeString == null || "".equals(codeString))
263            if (codeString == null || "".equals(codeString))
264                return null;
265        if ("rest-hook".equals(codeString))
266          return SubscriptionChannelType.RESTHOOK;
267        if ("websocket".equals(codeString))
268          return SubscriptionChannelType.WEBSOCKET;
269        if ("email".equals(codeString))
270          return SubscriptionChannelType.EMAIL;
271        if ("sms".equals(codeString))
272          return SubscriptionChannelType.SMS;
273        if ("message".equals(codeString))
274          return SubscriptionChannelType.MESSAGE;
275        throw new IllegalArgumentException("Unknown SubscriptionChannelType code '"+codeString+"'");
276        }
277        public Enumeration<SubscriptionChannelType> fromType(Base code) throws FHIRException {
278          if (code == null)
279            return null;
280          if (code.isEmpty())
281            return new Enumeration<SubscriptionChannelType>(this);
282          String codeString = ((PrimitiveType) code).asStringValue();
283          if (codeString == null || "".equals(codeString))
284            return null;
285        if ("rest-hook".equals(codeString))
286          return new Enumeration<SubscriptionChannelType>(this, SubscriptionChannelType.RESTHOOK);
287        if ("websocket".equals(codeString))
288          return new Enumeration<SubscriptionChannelType>(this, SubscriptionChannelType.WEBSOCKET);
289        if ("email".equals(codeString))
290          return new Enumeration<SubscriptionChannelType>(this, SubscriptionChannelType.EMAIL);
291        if ("sms".equals(codeString))
292          return new Enumeration<SubscriptionChannelType>(this, SubscriptionChannelType.SMS);
293        if ("message".equals(codeString))
294          return new Enumeration<SubscriptionChannelType>(this, SubscriptionChannelType.MESSAGE);
295        throw new FHIRException("Unknown SubscriptionChannelType code '"+codeString+"'");
296        }
297    public String toCode(SubscriptionChannelType code) {
298      if (code == SubscriptionChannelType.RESTHOOK)
299        return "rest-hook";
300      if (code == SubscriptionChannelType.WEBSOCKET)
301        return "websocket";
302      if (code == SubscriptionChannelType.EMAIL)
303        return "email";
304      if (code == SubscriptionChannelType.SMS)
305        return "sms";
306      if (code == SubscriptionChannelType.MESSAGE)
307        return "message";
308      return "?";
309      }
310    public String toSystem(SubscriptionChannelType code) {
311      return code.getSystem();
312      }
313    }
314
315    @Block()
316    public static class SubscriptionChannelComponent extends BackboneElement implements IBaseBackboneElement {
317        /**
318         * The type of channel to send notifications on.
319         */
320        @Child(name = "type", type = {CodeType.class}, order=1, min=1, max=1, modifier=false, summary=true)
321        @Description(shortDefinition="rest-hook | websocket | email | sms | message", formalDefinition="The type of channel to send notifications on." )
322        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/subscription-channel-type")
323        protected Enumeration<SubscriptionChannelType> type;
324
325        /**
326         * The url that describes the actual end-point to send messages to.
327         */
328        @Child(name = "endpoint", type = {UrlType.class}, order=2, min=0, max=1, modifier=false, summary=true)
329        @Description(shortDefinition="Where the channel points to", formalDefinition="The url that describes the actual end-point to send messages to." )
330        protected UrlType endpoint;
331
332        /**
333         * The mime type to send the payload in - either application/fhir+xml, or application/fhir+json. If the payload is not present, then there is no payload in the notification, just a notification.
334         */
335        @Child(name = "payload", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=true)
336        @Description(shortDefinition="MIME type to send, or omit for no payload", formalDefinition="The mime type to send the payload in - either application/fhir+xml, or application/fhir+json. If the payload is not present, then there is no payload in the notification, just a notification." )
337        protected StringType payload;
338
339        /**
340         * Additional headers / information to send as part of the notification.
341         */
342        @Child(name = "header", type = {StringType.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
343        @Description(shortDefinition="Usage depends on the channel type", formalDefinition="Additional headers / information to send as part of the notification." )
344        protected List<StringType> header;
345
346        private static final long serialVersionUID = -155848792L;
347
348    /**
349     * Constructor
350     */
351      public SubscriptionChannelComponent() {
352        super();
353      }
354
355    /**
356     * Constructor
357     */
358      public SubscriptionChannelComponent(Enumeration<SubscriptionChannelType> type) {
359        super();
360        this.type = type;
361      }
362
363        /**
364         * @return {@link #type} (The type of channel to send notifications on.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
365         */
366        public Enumeration<SubscriptionChannelType> getTypeElement() { 
367          if (this.type == null)
368            if (Configuration.errorOnAutoCreate())
369              throw new Error("Attempt to auto-create SubscriptionChannelComponent.type");
370            else if (Configuration.doAutoCreate())
371              this.type = new Enumeration<SubscriptionChannelType>(new SubscriptionChannelTypeEnumFactory()); // bb
372          return this.type;
373        }
374
375        public boolean hasTypeElement() { 
376          return this.type != null && !this.type.isEmpty();
377        }
378
379        public boolean hasType() { 
380          return this.type != null && !this.type.isEmpty();
381        }
382
383        /**
384         * @param value {@link #type} (The type of channel to send notifications on.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
385         */
386        public SubscriptionChannelComponent setTypeElement(Enumeration<SubscriptionChannelType> value) { 
387          this.type = value;
388          return this;
389        }
390
391        /**
392         * @return The type of channel to send notifications on.
393         */
394        public SubscriptionChannelType getType() { 
395          return this.type == null ? null : this.type.getValue();
396        }
397
398        /**
399         * @param value The type of channel to send notifications on.
400         */
401        public SubscriptionChannelComponent setType(SubscriptionChannelType value) { 
402            if (this.type == null)
403              this.type = new Enumeration<SubscriptionChannelType>(new SubscriptionChannelTypeEnumFactory());
404            this.type.setValue(value);
405          return this;
406        }
407
408        /**
409         * @return {@link #endpoint} (The url that describes the actual end-point to send messages to.). This is the underlying object with id, value and extensions. The accessor "getEndpoint" gives direct access to the value
410         */
411        public UrlType getEndpointElement() { 
412          if (this.endpoint == null)
413            if (Configuration.errorOnAutoCreate())
414              throw new Error("Attempt to auto-create SubscriptionChannelComponent.endpoint");
415            else if (Configuration.doAutoCreate())
416              this.endpoint = new UrlType(); // bb
417          return this.endpoint;
418        }
419
420        public boolean hasEndpointElement() { 
421          return this.endpoint != null && !this.endpoint.isEmpty();
422        }
423
424        public boolean hasEndpoint() { 
425          return this.endpoint != null && !this.endpoint.isEmpty();
426        }
427
428        /**
429         * @param value {@link #endpoint} (The url that describes the actual end-point to send messages to.). This is the underlying object with id, value and extensions. The accessor "getEndpoint" gives direct access to the value
430         */
431        public SubscriptionChannelComponent setEndpointElement(UrlType value) { 
432          this.endpoint = value;
433          return this;
434        }
435
436        /**
437         * @return The url that describes the actual end-point to send messages to.
438         */
439        public String getEndpoint() { 
440          return this.endpoint == null ? null : this.endpoint.getValue();
441        }
442
443        /**
444         * @param value The url that describes the actual end-point to send messages to.
445         */
446        public SubscriptionChannelComponent setEndpoint(String value) { 
447          if (Utilities.noString(value))
448            this.endpoint = null;
449          else {
450            if (this.endpoint == null)
451              this.endpoint = new UrlType();
452            this.endpoint.setValue(value);
453          }
454          return this;
455        }
456
457        /**
458         * @return {@link #payload} (The mime type to send the payload in - either application/fhir+xml, or application/fhir+json. If the payload is not present, then there is no payload in the notification, just a notification.). This is the underlying object with id, value and extensions. The accessor "getPayload" gives direct access to the value
459         */
460        public StringType getPayloadElement() { 
461          if (this.payload == null)
462            if (Configuration.errorOnAutoCreate())
463              throw new Error("Attempt to auto-create SubscriptionChannelComponent.payload");
464            else if (Configuration.doAutoCreate())
465              this.payload = new StringType(); // bb
466          return this.payload;
467        }
468
469        public boolean hasPayloadElement() { 
470          return this.payload != null && !this.payload.isEmpty();
471        }
472
473        public boolean hasPayload() { 
474          return this.payload != null && !this.payload.isEmpty();
475        }
476
477        /**
478         * @param value {@link #payload} (The mime type to send the payload in - either application/fhir+xml, or application/fhir+json. If the payload is not present, then there is no payload in the notification, just a notification.). This is the underlying object with id, value and extensions. The accessor "getPayload" gives direct access to the value
479         */
480        public SubscriptionChannelComponent setPayloadElement(StringType value) { 
481          this.payload = value;
482          return this;
483        }
484
485        /**
486         * @return The mime type to send the payload in - either application/fhir+xml, or application/fhir+json. If the payload is not present, then there is no payload in the notification, just a notification.
487         */
488        public String getPayload() { 
489          return this.payload == null ? null : this.payload.getValue();
490        }
491
492        /**
493         * @param value The mime type to send the payload in - either application/fhir+xml, or application/fhir+json. If the payload is not present, then there is no payload in the notification, just a notification.
494         */
495        public SubscriptionChannelComponent setPayload(String value) { 
496          if (Utilities.noString(value))
497            this.payload = null;
498          else {
499            if (this.payload == null)
500              this.payload = new StringType();
501            this.payload.setValue(value);
502          }
503          return this;
504        }
505
506        /**
507         * @return {@link #header} (Additional headers / information to send as part of the notification.)
508         */
509        public List<StringType> getHeader() { 
510          if (this.header == null)
511            this.header = new ArrayList<StringType>();
512          return this.header;
513        }
514
515        /**
516         * @return Returns a reference to <code>this</code> for easy method chaining
517         */
518        public SubscriptionChannelComponent setHeader(List<StringType> theHeader) { 
519          this.header = theHeader;
520          return this;
521        }
522
523        public boolean hasHeader() { 
524          if (this.header == null)
525            return false;
526          for (StringType item : this.header)
527            if (!item.isEmpty())
528              return true;
529          return false;
530        }
531
532        /**
533         * @return {@link #header} (Additional headers / information to send as part of the notification.)
534         */
535        public StringType addHeaderElement() {//2 
536          StringType t = new StringType();
537          if (this.header == null)
538            this.header = new ArrayList<StringType>();
539          this.header.add(t);
540          return t;
541        }
542
543        /**
544         * @param value {@link #header} (Additional headers / information to send as part of the notification.)
545         */
546        public SubscriptionChannelComponent addHeader(String value) { //1
547          StringType t = new StringType();
548          t.setValue(value);
549          if (this.header == null)
550            this.header = new ArrayList<StringType>();
551          this.header.add(t);
552          return this;
553        }
554
555        /**
556         * @param value {@link #header} (Additional headers / information to send as part of the notification.)
557         */
558        public boolean hasHeader(String value) { 
559          if (this.header == null)
560            return false;
561          for (StringType v : this.header)
562            if (v.getValue().equals(value)) // string
563              return true;
564          return false;
565        }
566
567        protected void listChildren(List<Property> children) {
568          super.listChildren(children);
569          children.add(new Property("type", "code", "The type of channel to send notifications on.", 0, 1, type));
570          children.add(new Property("endpoint", "url", "The url that describes the actual end-point to send messages to.", 0, 1, endpoint));
571          children.add(new Property("payload", "string", "The mime type to send the payload in - either application/fhir+xml, or application/fhir+json. If the payload is not present, then there is no payload in the notification, just a notification.", 0, 1, payload));
572          children.add(new Property("header", "string", "Additional headers / information to send as part of the notification.", 0, java.lang.Integer.MAX_VALUE, header));
573        }
574
575        @Override
576        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
577          switch (_hash) {
578          case 3575610: /*type*/  return new Property("type", "code", "The type of channel to send notifications on.", 0, 1, type);
579          case 1741102485: /*endpoint*/  return new Property("endpoint", "url", "The url that describes the actual end-point to send messages to.", 0, 1, endpoint);
580          case -786701938: /*payload*/  return new Property("payload", "string", "The mime type to send the payload in - either application/fhir+xml, or application/fhir+json. If the payload is not present, then there is no payload in the notification, just a notification.", 0, 1, payload);
581          case -1221270899: /*header*/  return new Property("header", "string", "Additional headers / information to send as part of the notification.", 0, java.lang.Integer.MAX_VALUE, header);
582          default: return super.getNamedProperty(_hash, _name, _checkValid);
583          }
584
585        }
586
587      @Override
588      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
589        switch (hash) {
590        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // Enumeration<SubscriptionChannelType>
591        case 1741102485: /*endpoint*/ return this.endpoint == null ? new Base[0] : new Base[] {this.endpoint}; // UrlType
592        case -786701938: /*payload*/ return this.payload == null ? new Base[0] : new Base[] {this.payload}; // StringType
593        case -1221270899: /*header*/ return this.header == null ? new Base[0] : this.header.toArray(new Base[this.header.size()]); // StringType
594        default: return super.getProperty(hash, name, checkValid);
595        }
596
597      }
598
599      @Override
600      public Base setProperty(int hash, String name, Base value) throws FHIRException {
601        switch (hash) {
602        case 3575610: // type
603          value = new SubscriptionChannelTypeEnumFactory().fromType(castToCode(value));
604          this.type = (Enumeration) value; // Enumeration<SubscriptionChannelType>
605          return value;
606        case 1741102485: // endpoint
607          this.endpoint = castToUrl(value); // UrlType
608          return value;
609        case -786701938: // payload
610          this.payload = castToString(value); // StringType
611          return value;
612        case -1221270899: // header
613          this.getHeader().add(castToString(value)); // StringType
614          return value;
615        default: return super.setProperty(hash, name, value);
616        }
617
618      }
619
620      @Override
621      public Base setProperty(String name, Base value) throws FHIRException {
622        if (name.equals("type")) {
623          value = new SubscriptionChannelTypeEnumFactory().fromType(castToCode(value));
624          this.type = (Enumeration) value; // Enumeration<SubscriptionChannelType>
625        } else if (name.equals("endpoint")) {
626          this.endpoint = castToUrl(value); // UrlType
627        } else if (name.equals("payload")) {
628          this.payload = castToString(value); // StringType
629        } else if (name.equals("header")) {
630          this.getHeader().add(castToString(value));
631        } else
632          return super.setProperty(name, value);
633        return value;
634      }
635
636      @Override
637      public Base makeProperty(int hash, String name) throws FHIRException {
638        switch (hash) {
639        case 3575610:  return getTypeElement();
640        case 1741102485:  return getEndpointElement();
641        case -786701938:  return getPayloadElement();
642        case -1221270899:  return addHeaderElement();
643        default: return super.makeProperty(hash, name);
644        }
645
646      }
647
648      @Override
649      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
650        switch (hash) {
651        case 3575610: /*type*/ return new String[] {"code"};
652        case 1741102485: /*endpoint*/ return new String[] {"url"};
653        case -786701938: /*payload*/ return new String[] {"string"};
654        case -1221270899: /*header*/ return new String[] {"string"};
655        default: return super.getTypesForProperty(hash, name);
656        }
657
658      }
659
660      @Override
661      public Base addChild(String name) throws FHIRException {
662        if (name.equals("type")) {
663          throw new FHIRException("Cannot call addChild on a primitive type Subscription.type");
664        }
665        else if (name.equals("endpoint")) {
666          throw new FHIRException("Cannot call addChild on a primitive type Subscription.endpoint");
667        }
668        else if (name.equals("payload")) {
669          throw new FHIRException("Cannot call addChild on a primitive type Subscription.payload");
670        }
671        else if (name.equals("header")) {
672          throw new FHIRException("Cannot call addChild on a primitive type Subscription.header");
673        }
674        else
675          return super.addChild(name);
676      }
677
678      public SubscriptionChannelComponent copy() {
679        SubscriptionChannelComponent dst = new SubscriptionChannelComponent();
680        copyValues(dst);
681        dst.type = type == null ? null : type.copy();
682        dst.endpoint = endpoint == null ? null : endpoint.copy();
683        dst.payload = payload == null ? null : payload.copy();
684        if (header != null) {
685          dst.header = new ArrayList<StringType>();
686          for (StringType i : header)
687            dst.header.add(i.copy());
688        };
689        return dst;
690      }
691
692      @Override
693      public boolean equalsDeep(Base other_) {
694        if (!super.equalsDeep(other_))
695          return false;
696        if (!(other_ instanceof SubscriptionChannelComponent))
697          return false;
698        SubscriptionChannelComponent o = (SubscriptionChannelComponent) other_;
699        return compareDeep(type, o.type, true) && compareDeep(endpoint, o.endpoint, true) && compareDeep(payload, o.payload, true)
700           && compareDeep(header, o.header, true);
701      }
702
703      @Override
704      public boolean equalsShallow(Base other_) {
705        if (!super.equalsShallow(other_))
706          return false;
707        if (!(other_ instanceof SubscriptionChannelComponent))
708          return false;
709        SubscriptionChannelComponent o = (SubscriptionChannelComponent) other_;
710        return compareValues(type, o.type, true) && compareValues(endpoint, o.endpoint, true) && compareValues(payload, o.payload, true)
711           && compareValues(header, o.header, true);
712      }
713
714      public boolean isEmpty() {
715        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, endpoint, payload
716          , header);
717      }
718
719  public String fhirType() {
720    return "Subscription.channel";
721
722  }
723
724  }
725
726    /**
727     * The status of the subscription, which marks the server state for managing the subscription.
728     */
729    @Child(name = "status", type = {CodeType.class}, order=0, min=1, max=1, modifier=true, summary=true)
730    @Description(shortDefinition="requested | active | error | off", formalDefinition="The status of the subscription, which marks the server state for managing the subscription." )
731    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/subscription-status")
732    protected Enumeration<SubscriptionStatus> status;
733
734    /**
735     * Contact details for a human to contact about the subscription. The primary use of this for system administrator troubleshooting.
736     */
737    @Child(name = "contact", type = {ContactPoint.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
738    @Description(shortDefinition="Contact details for source (e.g. troubleshooting)", formalDefinition="Contact details for a human to contact about the subscription. The primary use of this for system administrator troubleshooting." )
739    protected List<ContactPoint> contact;
740
741    /**
742     * The time for the server to turn the subscription off.
743     */
744    @Child(name = "end", type = {InstantType.class}, order=2, min=0, max=1, modifier=false, summary=true)
745    @Description(shortDefinition="When to automatically delete the subscription", formalDefinition="The time for the server to turn the subscription off." )
746    protected InstantType end;
747
748    /**
749     * A description of why this subscription is defined.
750     */
751    @Child(name = "reason", type = {StringType.class}, order=3, min=1, max=1, modifier=false, summary=true)
752    @Description(shortDefinition="Description of why this subscription was created", formalDefinition="A description of why this subscription is defined." )
753    protected StringType reason;
754
755    /**
756     * The rules that the server should use to determine when to generate notifications for this subscription.
757     */
758    @Child(name = "criteria", type = {StringType.class}, order=4, min=1, max=1, modifier=false, summary=true)
759    @Description(shortDefinition="Rule for server push", formalDefinition="The rules that the server should use to determine when to generate notifications for this subscription." )
760    protected StringType criteria;
761
762    /**
763     * A record of the last error that occurred when the server processed a notification.
764     */
765    @Child(name = "error", type = {StringType.class}, order=5, min=0, max=1, modifier=false, summary=true)
766    @Description(shortDefinition="Latest error note", formalDefinition="A record of the last error that occurred when the server processed a notification." )
767    protected StringType error;
768
769    /**
770     * Details where to send notifications when resources are received that meet the criteria.
771     */
772    @Child(name = "channel", type = {}, order=6, min=1, max=1, modifier=false, summary=true)
773    @Description(shortDefinition="The channel on which to report matches to the criteria", formalDefinition="Details where to send notifications when resources are received that meet the criteria." )
774    protected SubscriptionChannelComponent channel;
775
776    /**
777     * A tag to add to any resource that matches the criteria, after the subscription is processed.
778     */
779    @Child(name = "tag", type = {Coding.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
780    @Description(shortDefinition="A tag to add to matching resources", formalDefinition="A tag to add to any resource that matches the criteria, after the subscription is processed." )
781    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/subscription-tag")
782    protected List<Coding> tag;
783
784    private static final long serialVersionUID = 99986202L;
785
786  /**
787   * Constructor
788   */
789    public Subscription() {
790      super();
791    }
792
793  /**
794   * Constructor
795   */
796    public Subscription(Enumeration<SubscriptionStatus> status, StringType reason, StringType criteria, SubscriptionChannelComponent channel) {
797      super();
798      this.status = status;
799      this.reason = reason;
800      this.criteria = criteria;
801      this.channel = channel;
802    }
803
804    /**
805     * @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
806     */
807    public Enumeration<SubscriptionStatus> getStatusElement() { 
808      if (this.status == null)
809        if (Configuration.errorOnAutoCreate())
810          throw new Error("Attempt to auto-create Subscription.status");
811        else if (Configuration.doAutoCreate())
812          this.status = new Enumeration<SubscriptionStatus>(new SubscriptionStatusEnumFactory()); // bb
813      return this.status;
814    }
815
816    public boolean hasStatusElement() { 
817      return this.status != null && !this.status.isEmpty();
818    }
819
820    public boolean hasStatus() { 
821      return this.status != null && !this.status.isEmpty();
822    }
823
824    /**
825     * @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
826     */
827    public Subscription setStatusElement(Enumeration<SubscriptionStatus> value) { 
828      this.status = value;
829      return this;
830    }
831
832    /**
833     * @return The status of the subscription, which marks the server state for managing the subscription.
834     */
835    public SubscriptionStatus getStatus() { 
836      return this.status == null ? null : this.status.getValue();
837    }
838
839    /**
840     * @param value The status of the subscription, which marks the server state for managing the subscription.
841     */
842    public Subscription setStatus(SubscriptionStatus value) { 
843        if (this.status == null)
844          this.status = new Enumeration<SubscriptionStatus>(new SubscriptionStatusEnumFactory());
845        this.status.setValue(value);
846      return this;
847    }
848
849    /**
850     * @return {@link #contact} (Contact details for a human to contact about the subscription. The primary use of this for system administrator troubleshooting.)
851     */
852    public List<ContactPoint> getContact() { 
853      if (this.contact == null)
854        this.contact = new ArrayList<ContactPoint>();
855      return this.contact;
856    }
857
858    /**
859     * @return Returns a reference to <code>this</code> for easy method chaining
860     */
861    public Subscription setContact(List<ContactPoint> theContact) { 
862      this.contact = theContact;
863      return this;
864    }
865
866    public boolean hasContact() { 
867      if (this.contact == null)
868        return false;
869      for (ContactPoint item : this.contact)
870        if (!item.isEmpty())
871          return true;
872      return false;
873    }
874
875    public ContactPoint addContact() { //3
876      ContactPoint t = new ContactPoint();
877      if (this.contact == null)
878        this.contact = new ArrayList<ContactPoint>();
879      this.contact.add(t);
880      return t;
881    }
882
883    public Subscription addContact(ContactPoint t) { //3
884      if (t == null)
885        return this;
886      if (this.contact == null)
887        this.contact = new ArrayList<ContactPoint>();
888      this.contact.add(t);
889      return this;
890    }
891
892    /**
893     * @return The first repetition of repeating field {@link #contact}, creating it if it does not already exist
894     */
895    public ContactPoint getContactFirstRep() { 
896      if (getContact().isEmpty()) {
897        addContact();
898      }
899      return getContact().get(0);
900    }
901
902    /**
903     * @return {@link #end} (The time for the server to turn the subscription off.). This is the underlying object with id, value and extensions. The accessor "getEnd" gives direct access to the value
904     */
905    public InstantType getEndElement() { 
906      if (this.end == null)
907        if (Configuration.errorOnAutoCreate())
908          throw new Error("Attempt to auto-create Subscription.end");
909        else if (Configuration.doAutoCreate())
910          this.end = new InstantType(); // bb
911      return this.end;
912    }
913
914    public boolean hasEndElement() { 
915      return this.end != null && !this.end.isEmpty();
916    }
917
918    public boolean hasEnd() { 
919      return this.end != null && !this.end.isEmpty();
920    }
921
922    /**
923     * @param value {@link #end} (The time for the server to turn the subscription off.). This is the underlying object with id, value and extensions. The accessor "getEnd" gives direct access to the value
924     */
925    public Subscription setEndElement(InstantType value) { 
926      this.end = value;
927      return this;
928    }
929
930    /**
931     * @return The time for the server to turn the subscription off.
932     */
933    public Date getEnd() { 
934      return this.end == null ? null : this.end.getValue();
935    }
936
937    /**
938     * @param value The time for the server to turn the subscription off.
939     */
940    public Subscription setEnd(Date value) { 
941      if (value == null)
942        this.end = null;
943      else {
944        if (this.end == null)
945          this.end = new InstantType();
946        this.end.setValue(value);
947      }
948      return this;
949    }
950
951    /**
952     * @return {@link #reason} (A description of why this subscription is defined.). This is the underlying object with id, value and extensions. The accessor "getReason" gives direct access to the value
953     */
954    public StringType getReasonElement() { 
955      if (this.reason == null)
956        if (Configuration.errorOnAutoCreate())
957          throw new Error("Attempt to auto-create Subscription.reason");
958        else if (Configuration.doAutoCreate())
959          this.reason = new StringType(); // bb
960      return this.reason;
961    }
962
963    public boolean hasReasonElement() { 
964      return this.reason != null && !this.reason.isEmpty();
965    }
966
967    public boolean hasReason() { 
968      return this.reason != null && !this.reason.isEmpty();
969    }
970
971    /**
972     * @param value {@link #reason} (A description of why this subscription is defined.). This is the underlying object with id, value and extensions. The accessor "getReason" gives direct access to the value
973     */
974    public Subscription setReasonElement(StringType value) { 
975      this.reason = value;
976      return this;
977    }
978
979    /**
980     * @return A description of why this subscription is defined.
981     */
982    public String getReason() { 
983      return this.reason == null ? null : this.reason.getValue();
984    }
985
986    /**
987     * @param value A description of why this subscription is defined.
988     */
989    public Subscription setReason(String value) { 
990        if (this.reason == null)
991          this.reason = new StringType();
992        this.reason.setValue(value);
993      return this;
994    }
995
996    /**
997     * @return {@link #criteria} (The rules that the server should use to determine when to generate notifications for this subscription.). This is the underlying object with id, value and extensions. The accessor "getCriteria" gives direct access to the value
998     */
999    public StringType getCriteriaElement() { 
1000      if (this.criteria == null)
1001        if (Configuration.errorOnAutoCreate())
1002          throw new Error("Attempt to auto-create Subscription.criteria");
1003        else if (Configuration.doAutoCreate())
1004          this.criteria = new StringType(); // bb
1005      return this.criteria;
1006    }
1007
1008    public boolean hasCriteriaElement() { 
1009      return this.criteria != null && !this.criteria.isEmpty();
1010    }
1011
1012    public boolean hasCriteria() { 
1013      return this.criteria != null && !this.criteria.isEmpty();
1014    }
1015
1016    /**
1017     * @param value {@link #criteria} (The rules that the server should use to determine when to generate notifications for this subscription.). This is the underlying object with id, value and extensions. The accessor "getCriteria" gives direct access to the value
1018     */
1019    public Subscription setCriteriaElement(StringType value) { 
1020      this.criteria = value;
1021      return this;
1022    }
1023
1024    /**
1025     * @return The rules that the server should use to determine when to generate notifications for this subscription.
1026     */
1027    public String getCriteria() { 
1028      return this.criteria == null ? null : this.criteria.getValue();
1029    }
1030
1031    /**
1032     * @param value The rules that the server should use to determine when to generate notifications for this subscription.
1033     */
1034    public Subscription setCriteria(String value) { 
1035        if (this.criteria == null)
1036          this.criteria = new StringType();
1037        this.criteria.setValue(value);
1038      return this;
1039    }
1040
1041    /**
1042     * @return {@link #error} (A record of the last error that occurred when the server processed a notification.). This is the underlying object with id, value and extensions. The accessor "getError" gives direct access to the value
1043     */
1044    public StringType getErrorElement() { 
1045      if (this.error == null)
1046        if (Configuration.errorOnAutoCreate())
1047          throw new Error("Attempt to auto-create Subscription.error");
1048        else if (Configuration.doAutoCreate())
1049          this.error = new StringType(); // bb
1050      return this.error;
1051    }
1052
1053    public boolean hasErrorElement() { 
1054      return this.error != null && !this.error.isEmpty();
1055    }
1056
1057    public boolean hasError() { 
1058      return this.error != null && !this.error.isEmpty();
1059    }
1060
1061    /**
1062     * @param value {@link #error} (A record of the last error that occurred when the server processed a notification.). This is the underlying object with id, value and extensions. The accessor "getError" gives direct access to the value
1063     */
1064    public Subscription setErrorElement(StringType value) { 
1065      this.error = value;
1066      return this;
1067    }
1068
1069    /**
1070     * @return A record of the last error that occurred when the server processed a notification.
1071     */
1072    public String getError() { 
1073      return this.error == null ? null : this.error.getValue();
1074    }
1075
1076    /**
1077     * @param value A record of the last error that occurred when the server processed a notification.
1078     */
1079    public Subscription setError(String value) { 
1080      if (Utilities.noString(value))
1081        this.error = null;
1082      else {
1083        if (this.error == null)
1084          this.error = new StringType();
1085        this.error.setValue(value);
1086      }
1087      return this;
1088    }
1089
1090    /**
1091     * @return {@link #channel} (Details where to send notifications when resources are received that meet the criteria.)
1092     */
1093    public SubscriptionChannelComponent getChannel() { 
1094      if (this.channel == null)
1095        if (Configuration.errorOnAutoCreate())
1096          throw new Error("Attempt to auto-create Subscription.channel");
1097        else if (Configuration.doAutoCreate())
1098          this.channel = new SubscriptionChannelComponent(); // cc
1099      return this.channel;
1100    }
1101
1102    public boolean hasChannel() { 
1103      return this.channel != null && !this.channel.isEmpty();
1104    }
1105
1106    /**
1107     * @param value {@link #channel} (Details where to send notifications when resources are received that meet the criteria.)
1108     */
1109    public Subscription setChannel(SubscriptionChannelComponent value) { 
1110      this.channel = value;
1111      return this;
1112    }
1113
1114    /**
1115     * @return {@link #tag} (A tag to add to any resource that matches the criteria, after the subscription is processed.)
1116     */
1117    public List<Coding> getTag() { 
1118      if (this.tag == null)
1119        this.tag = new ArrayList<Coding>();
1120      return this.tag;
1121    }
1122
1123    /**
1124     * @return Returns a reference to <code>this</code> for easy method chaining
1125     */
1126    public Subscription setTag(List<Coding> theTag) { 
1127      this.tag = theTag;
1128      return this;
1129    }
1130
1131    public boolean hasTag() { 
1132      if (this.tag == null)
1133        return false;
1134      for (Coding item : this.tag)
1135        if (!item.isEmpty())
1136          return true;
1137      return false;
1138    }
1139
1140    public Coding addTag() { //3
1141      Coding t = new Coding();
1142      if (this.tag == null)
1143        this.tag = new ArrayList<Coding>();
1144      this.tag.add(t);
1145      return t;
1146    }
1147
1148    public Subscription addTag(Coding t) { //3
1149      if (t == null)
1150        return this;
1151      if (this.tag == null)
1152        this.tag = new ArrayList<Coding>();
1153      this.tag.add(t);
1154      return this;
1155    }
1156
1157    /**
1158     * @return The first repetition of repeating field {@link #tag}, creating it if it does not already exist
1159     */
1160    public Coding getTagFirstRep() { 
1161      if (getTag().isEmpty()) {
1162        addTag();
1163      }
1164      return getTag().get(0);
1165    }
1166
1167      protected void listChildren(List<Property> children) {
1168        super.listChildren(children);
1169        children.add(new Property("status", "code", "The status of the subscription, which marks the server state for managing the subscription.", 0, 1, status));
1170        children.add(new Property("contact", "ContactPoint", "Contact details for a human to contact about the subscription. The primary use of this for system administrator troubleshooting.", 0, java.lang.Integer.MAX_VALUE, contact));
1171        children.add(new Property("end", "instant", "The time for the server to turn the subscription off.", 0, 1, end));
1172        children.add(new Property("reason", "string", "A description of why this subscription is defined.", 0, 1, reason));
1173        children.add(new Property("criteria", "string", "The rules that the server should use to determine when to generate notifications for this subscription.", 0, 1, criteria));
1174        children.add(new Property("error", "string", "A record of the last error that occurred when the server processed a notification.", 0, 1, error));
1175        children.add(new Property("channel", "", "Details where to send notifications when resources are received that meet the criteria.", 0, 1, channel));
1176        children.add(new Property("tag", "Coding", "A tag to add to any resource that matches the criteria, after the subscription is processed.", 0, java.lang.Integer.MAX_VALUE, tag));
1177      }
1178
1179      @Override
1180      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1181        switch (_hash) {
1182        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);
1183        case 951526432: /*contact*/  return new Property("contact", "ContactPoint", "Contact details for a human to contact about the subscription. The primary use of this for system administrator troubleshooting.", 0, java.lang.Integer.MAX_VALUE, contact);
1184        case 100571: /*end*/  return new Property("end", "instant", "The time for the server to turn the subscription off.", 0, 1, end);
1185        case -934964668: /*reason*/  return new Property("reason", "string", "A description of why this subscription is defined.", 0, 1, reason);
1186        case 1952046943: /*criteria*/  return new Property("criteria", "string", "The rules that the server should use to determine when to generate notifications for this subscription.", 0, 1, criteria);
1187        case 96784904: /*error*/  return new Property("error", "string", "A record of the last error that occurred when the server processed a notification.", 0, 1, error);
1188        case 738950403: /*channel*/  return new Property("channel", "", "Details where to send notifications when resources are received that meet the criteria.", 0, 1, channel);
1189        case 114586: /*tag*/  return new Property("tag", "Coding", "A tag to add to any resource that matches the criteria, after the subscription is processed.", 0, java.lang.Integer.MAX_VALUE, tag);
1190        default: return super.getNamedProperty(_hash, _name, _checkValid);
1191        }
1192
1193      }
1194
1195      @Override
1196      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1197        switch (hash) {
1198        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<SubscriptionStatus>
1199        case 951526432: /*contact*/ return this.contact == null ? new Base[0] : this.contact.toArray(new Base[this.contact.size()]); // ContactPoint
1200        case 100571: /*end*/ return this.end == null ? new Base[0] : new Base[] {this.end}; // InstantType
1201        case -934964668: /*reason*/ return this.reason == null ? new Base[0] : new Base[] {this.reason}; // StringType
1202        case 1952046943: /*criteria*/ return this.criteria == null ? new Base[0] : new Base[] {this.criteria}; // StringType
1203        case 96784904: /*error*/ return this.error == null ? new Base[0] : new Base[] {this.error}; // StringType
1204        case 738950403: /*channel*/ return this.channel == null ? new Base[0] : new Base[] {this.channel}; // SubscriptionChannelComponent
1205        case 114586: /*tag*/ return this.tag == null ? new Base[0] : this.tag.toArray(new Base[this.tag.size()]); // Coding
1206        default: return super.getProperty(hash, name, checkValid);
1207        }
1208
1209      }
1210
1211      @Override
1212      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1213        switch (hash) {
1214        case -892481550: // status
1215          value = new SubscriptionStatusEnumFactory().fromType(castToCode(value));
1216          this.status = (Enumeration) value; // Enumeration<SubscriptionStatus>
1217          return value;
1218        case 951526432: // contact
1219          this.getContact().add(castToContactPoint(value)); // ContactPoint
1220          return value;
1221        case 100571: // end
1222          this.end = castToInstant(value); // InstantType
1223          return value;
1224        case -934964668: // reason
1225          this.reason = castToString(value); // StringType
1226          return value;
1227        case 1952046943: // criteria
1228          this.criteria = castToString(value); // StringType
1229          return value;
1230        case 96784904: // error
1231          this.error = castToString(value); // StringType
1232          return value;
1233        case 738950403: // channel
1234          this.channel = (SubscriptionChannelComponent) value; // SubscriptionChannelComponent
1235          return value;
1236        case 114586: // tag
1237          this.getTag().add(castToCoding(value)); // Coding
1238          return value;
1239        default: return super.setProperty(hash, name, value);
1240        }
1241
1242      }
1243
1244      @Override
1245      public Base setProperty(String name, Base value) throws FHIRException {
1246        if (name.equals("status")) {
1247          value = new SubscriptionStatusEnumFactory().fromType(castToCode(value));
1248          this.status = (Enumeration) value; // Enumeration<SubscriptionStatus>
1249        } else if (name.equals("contact")) {
1250          this.getContact().add(castToContactPoint(value));
1251        } else if (name.equals("end")) {
1252          this.end = castToInstant(value); // InstantType
1253        } else if (name.equals("reason")) {
1254          this.reason = castToString(value); // StringType
1255        } else if (name.equals("criteria")) {
1256          this.criteria = castToString(value); // StringType
1257        } else if (name.equals("error")) {
1258          this.error = castToString(value); // StringType
1259        } else if (name.equals("channel")) {
1260          this.channel = (SubscriptionChannelComponent) value; // SubscriptionChannelComponent
1261        } else if (name.equals("tag")) {
1262          this.getTag().add(castToCoding(value));
1263        } else
1264          return super.setProperty(name, value);
1265        return value;
1266      }
1267
1268      @Override
1269      public Base makeProperty(int hash, String name) throws FHIRException {
1270        switch (hash) {
1271        case -892481550:  return getStatusElement();
1272        case 951526432:  return addContact(); 
1273        case 100571:  return getEndElement();
1274        case -934964668:  return getReasonElement();
1275        case 1952046943:  return getCriteriaElement();
1276        case 96784904:  return getErrorElement();
1277        case 738950403:  return getChannel(); 
1278        case 114586:  return addTag(); 
1279        default: return super.makeProperty(hash, name);
1280        }
1281
1282      }
1283
1284      @Override
1285      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1286        switch (hash) {
1287        case -892481550: /*status*/ return new String[] {"code"};
1288        case 951526432: /*contact*/ return new String[] {"ContactPoint"};
1289        case 100571: /*end*/ return new String[] {"instant"};
1290        case -934964668: /*reason*/ return new String[] {"string"};
1291        case 1952046943: /*criteria*/ return new String[] {"string"};
1292        case 96784904: /*error*/ return new String[] {"string"};
1293        case 738950403: /*channel*/ return new String[] {};
1294        case 114586: /*tag*/ return new String[] {"Coding"};
1295        default: return super.getTypesForProperty(hash, name);
1296        }
1297
1298      }
1299
1300      @Override
1301      public Base addChild(String name) throws FHIRException {
1302        if (name.equals("status")) {
1303          throw new FHIRException("Cannot call addChild on a primitive type Subscription.status");
1304        }
1305        else if (name.equals("contact")) {
1306          return addContact();
1307        }
1308        else if (name.equals("end")) {
1309          throw new FHIRException("Cannot call addChild on a primitive type Subscription.end");
1310        }
1311        else if (name.equals("reason")) {
1312          throw new FHIRException("Cannot call addChild on a primitive type Subscription.reason");
1313        }
1314        else if (name.equals("criteria")) {
1315          throw new FHIRException("Cannot call addChild on a primitive type Subscription.criteria");
1316        }
1317        else if (name.equals("error")) {
1318          throw new FHIRException("Cannot call addChild on a primitive type Subscription.error");
1319        }
1320        else if (name.equals("channel")) {
1321          this.channel = new SubscriptionChannelComponent();
1322          return this.channel;
1323        }
1324        else if (name.equals("tag")) {
1325          return addTag();
1326        }
1327        else
1328          return super.addChild(name);
1329      }
1330
1331  public String fhirType() {
1332    return "Subscription";
1333
1334  }
1335
1336      public Subscription copy() {
1337        Subscription dst = new Subscription();
1338        copyValues(dst);
1339        dst.status = status == null ? null : status.copy();
1340        if (contact != null) {
1341          dst.contact = new ArrayList<ContactPoint>();
1342          for (ContactPoint i : contact)
1343            dst.contact.add(i.copy());
1344        };
1345        dst.end = end == null ? null : end.copy();
1346        dst.reason = reason == null ? null : reason.copy();
1347        dst.criteria = criteria == null ? null : criteria.copy();
1348        dst.error = error == null ? null : error.copy();
1349        dst.channel = channel == null ? null : channel.copy();
1350        if (tag != null) {
1351          dst.tag = new ArrayList<Coding>();
1352          for (Coding i : tag)
1353            dst.tag.add(i.copy());
1354        };
1355        return dst;
1356      }
1357
1358      protected Subscription typedCopy() {
1359        return copy();
1360      }
1361
1362      @Override
1363      public boolean equalsDeep(Base other_) {
1364        if (!super.equalsDeep(other_))
1365          return false;
1366        if (!(other_ instanceof Subscription))
1367          return false;
1368        Subscription o = (Subscription) other_;
1369        return compareDeep(status, o.status, true) && compareDeep(contact, o.contact, true) && compareDeep(end, o.end, true)
1370           && compareDeep(reason, o.reason, true) && compareDeep(criteria, o.criteria, true) && compareDeep(error, o.error, true)
1371           && compareDeep(channel, o.channel, true) && compareDeep(tag, o.tag, true);
1372      }
1373
1374      @Override
1375      public boolean equalsShallow(Base other_) {
1376        if (!super.equalsShallow(other_))
1377          return false;
1378        if (!(other_ instanceof Subscription))
1379          return false;
1380        Subscription o = (Subscription) other_;
1381        return compareValues(status, o.status, true) && compareValues(end, o.end, true) && compareValues(reason, o.reason, true)
1382           && compareValues(criteria, o.criteria, true) && compareValues(error, o.error, true);
1383      }
1384
1385      public boolean isEmpty() {
1386        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(status, contact, end, reason
1387          , criteria, error, channel, tag);
1388      }
1389
1390  @Override
1391  public ResourceType getResourceType() {
1392    return ResourceType.Subscription;
1393   }
1394
1395 /**
1396   * Search parameter: <b>payload</b>
1397   * <p>
1398   * Description: <b>The mime-type of the notification payload</b><br>
1399   * Type: <b>string</b><br>
1400   * Path: <b>Subscription.channel.payload</b><br>
1401   * </p>
1402   */
1403  @SearchParamDefinition(name="payload", path="Subscription.channel.payload", description="The mime-type of the notification payload", type="string" )
1404  public static final String SP_PAYLOAD = "payload";
1405 /**
1406   * <b>Fluent Client</b> search parameter constant for <b>payload</b>
1407   * <p>
1408   * Description: <b>The mime-type of the notification payload</b><br>
1409   * Type: <b>string</b><br>
1410   * Path: <b>Subscription.channel.payload</b><br>
1411   * </p>
1412   */
1413  public static final ca.uhn.fhir.rest.gclient.StringClientParam PAYLOAD = new ca.uhn.fhir.rest.gclient.StringClientParam(SP_PAYLOAD);
1414
1415 /**
1416   * Search parameter: <b>criteria</b>
1417   * <p>
1418   * Description: <b>The search rules used to determine when to send a notification</b><br>
1419   * Type: <b>string</b><br>
1420   * Path: <b>Subscription.criteria</b><br>
1421   * </p>
1422   */
1423  @SearchParamDefinition(name="criteria", path="Subscription.criteria", description="The search rules used to determine when to send a notification", type="string" )
1424  public static final String SP_CRITERIA = "criteria";
1425 /**
1426   * <b>Fluent Client</b> search parameter constant for <b>criteria</b>
1427   * <p>
1428   * Description: <b>The search rules used to determine when to send a notification</b><br>
1429   * Type: <b>string</b><br>
1430   * Path: <b>Subscription.criteria</b><br>
1431   * </p>
1432   */
1433  public static final ca.uhn.fhir.rest.gclient.StringClientParam CRITERIA = new ca.uhn.fhir.rest.gclient.StringClientParam(SP_CRITERIA);
1434
1435 /**
1436   * Search parameter: <b>add-tag</b>
1437   * <p>
1438   * Description: <b>A tag to be added to the resource matching the criteria</b><br>
1439   * Type: <b>token</b><br>
1440   * Path: <b>Subscription.tag</b><br>
1441   * </p>
1442   */
1443  @SearchParamDefinition(name="add-tag", path="Subscription.tag", description="A tag to be added to the resource matching the criteria", type="token" )
1444  public static final String SP_ADD_TAG = "add-tag";
1445 /**
1446   * <b>Fluent Client</b> search parameter constant for <b>add-tag</b>
1447   * <p>
1448   * Description: <b>A tag to be added to the resource matching the criteria</b><br>
1449   * Type: <b>token</b><br>
1450   * Path: <b>Subscription.tag</b><br>
1451   * </p>
1452   */
1453  public static final ca.uhn.fhir.rest.gclient.TokenClientParam ADD_TAG = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_ADD_TAG);
1454
1455 /**
1456   * Search parameter: <b>contact</b>
1457   * <p>
1458   * Description: <b>Contact details for the subscription</b><br>
1459   * Type: <b>token</b><br>
1460   * Path: <b>Subscription.contact</b><br>
1461   * </p>
1462   */
1463  @SearchParamDefinition(name="contact", path="Subscription.contact", description="Contact details for the subscription", type="token" )
1464  public static final String SP_CONTACT = "contact";
1465 /**
1466   * <b>Fluent Client</b> search parameter constant for <b>contact</b>
1467   * <p>
1468   * Description: <b>Contact details for the subscription</b><br>
1469   * Type: <b>token</b><br>
1470   * Path: <b>Subscription.contact</b><br>
1471   * </p>
1472   */
1473  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CONTACT = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CONTACT);
1474
1475 /**
1476   * Search parameter: <b>type</b>
1477   * <p>
1478   * Description: <b>The type of channel for the sent notifications</b><br>
1479   * Type: <b>token</b><br>
1480   * Path: <b>Subscription.channel.type</b><br>
1481   * </p>
1482   */
1483  @SearchParamDefinition(name="type", path="Subscription.channel.type", description="The type of channel for the sent notifications", type="token" )
1484  public static final String SP_TYPE = "type";
1485 /**
1486   * <b>Fluent Client</b> search parameter constant for <b>type</b>
1487   * <p>
1488   * Description: <b>The type of channel for the sent notifications</b><br>
1489   * Type: <b>token</b><br>
1490   * Path: <b>Subscription.channel.type</b><br>
1491   * </p>
1492   */
1493  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_TYPE);
1494
1495 /**
1496   * Search parameter: <b>url</b>
1497   * <p>
1498   * Description: <b>The uri that will receive the notifications</b><br>
1499   * Type: <b>uri</b><br>
1500   * Path: <b>Subscription.channel.endpoint</b><br>
1501   * </p>
1502   */
1503  @SearchParamDefinition(name="url", path="Subscription.channel.endpoint", description="The uri that will receive the notifications", type="uri" )
1504  public static final String SP_URL = "url";
1505 /**
1506   * <b>Fluent Client</b> search parameter constant for <b>url</b>
1507   * <p>
1508   * Description: <b>The uri that will receive the notifications</b><br>
1509   * Type: <b>uri</b><br>
1510   * Path: <b>Subscription.channel.endpoint</b><br>
1511   * </p>
1512   */
1513  public static final ca.uhn.fhir.rest.gclient.UriClientParam URL = new ca.uhn.fhir.rest.gclient.UriClientParam(SP_URL);
1514
1515 /**
1516   * Search parameter: <b>status</b>
1517   * <p>
1518   * Description: <b>The current state of the subscription</b><br>
1519   * Type: <b>token</b><br>
1520   * Path: <b>Subscription.status</b><br>
1521   * </p>
1522   */
1523  @SearchParamDefinition(name="status", path="Subscription.status", description="The current state of the subscription", type="token" )
1524  public static final String SP_STATUS = "status";
1525 /**
1526   * <b>Fluent Client</b> search parameter constant for <b>status</b>
1527   * <p>
1528   * Description: <b>The current state of the subscription</b><br>
1529   * Type: <b>token</b><br>
1530   * Path: <b>Subscription.status</b><br>
1531   * </p>
1532   */
1533  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
1534
1535
1536}
1537