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