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 Base makeProperty(int hash, String name) throws FHIRException {
787      switch (hash) {
788      case 3575610:
789        return getTypeElement();
790      case 1741102485:
791        return getEndpointElement();
792      case -786701938:
793        return getPayloadElement();
794      case -1221270899:
795        return addHeaderElement();
796      default:
797        return super.makeProperty(hash, name);
798      }
799
800    }
801
802    @Override
803    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
804      switch (hash) {
805      case 3575610:
806        /* type */ return new String[] { "code" };
807      case 1741102485:
808        /* endpoint */ return new String[] { "url" };
809      case -786701938:
810        /* payload */ return new String[] { "code" };
811      case -1221270899:
812        /* header */ return new String[] { "string" };
813      default:
814        return super.getTypesForProperty(hash, name);
815      }
816
817    }
818
819    @Override
820    public Base addChild(String name) throws FHIRException {
821      if (name.equals("type")) {
822        throw new FHIRException("Cannot call addChild on a singleton property Subscription.type");
823      } else if (name.equals("endpoint")) {
824        throw new FHIRException("Cannot call addChild on a singleton property Subscription.endpoint");
825      } else if (name.equals("payload")) {
826        throw new FHIRException("Cannot call addChild on a singleton property Subscription.payload");
827      } else if (name.equals("header")) {
828        throw new FHIRException("Cannot call addChild on a singleton property Subscription.header");
829      } else
830        return super.addChild(name);
831    }
832
833    public SubscriptionChannelComponent copy() {
834      SubscriptionChannelComponent dst = new SubscriptionChannelComponent();
835      copyValues(dst);
836      return dst;
837    }
838
839    public void copyValues(SubscriptionChannelComponent dst) {
840      super.copyValues(dst);
841      dst.type = type == null ? null : type.copy();
842      dst.endpoint = endpoint == null ? null : endpoint.copy();
843      dst.payload = payload == null ? null : payload.copy();
844      if (header != null) {
845        dst.header = new ArrayList<StringType>();
846        for (StringType i : header)
847          dst.header.add(i.copy());
848      }
849      ;
850    }
851
852    @Override
853    public boolean equalsDeep(Base other_) {
854      if (!super.equalsDeep(other_))
855        return false;
856      if (!(other_ instanceof SubscriptionChannelComponent))
857        return false;
858      SubscriptionChannelComponent o = (SubscriptionChannelComponent) other_;
859      return compareDeep(type, o.type, true) && compareDeep(endpoint, o.endpoint, true)
860          && compareDeep(payload, o.payload, true) && compareDeep(header, o.header, true);
861    }
862
863    @Override
864    public boolean equalsShallow(Base other_) {
865      if (!super.equalsShallow(other_))
866        return false;
867      if (!(other_ instanceof SubscriptionChannelComponent))
868        return false;
869      SubscriptionChannelComponent o = (SubscriptionChannelComponent) other_;
870      return compareValues(type, o.type, true) && compareValues(endpoint, o.endpoint, true)
871          && compareValues(payload, o.payload, true) && compareValues(header, o.header, true);
872    }
873
874    public boolean isEmpty() {
875      return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, endpoint, payload, header);
876    }
877
878    public String fhirType() {
879      return "Subscription.channel";
880
881    }
882
883  }
884
885  /**
886   * The status of the subscription, which marks the server state for managing the
887   * subscription.
888   */
889  @Child(name = "status", type = { CodeType.class }, order = 0, min = 1, max = 1, modifier = true, summary = true)
890  @Description(shortDefinition = "requested | active | error | off", formalDefinition = "The status of the subscription, which marks the server state for managing the subscription.")
891  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/subscription-status")
892  protected Enumeration<SubscriptionStatus> status;
893
894  /**
895   * Contact details for a human to contact about the subscription. The primary
896   * use of this for system administrator troubleshooting.
897   */
898  @Child(name = "contact", type = {
899      ContactPoint.class }, order = 1, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
900  @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.")
901  protected List<ContactPoint> contact;
902
903  /**
904   * The time for the server to turn the subscription off.
905   */
906  @Child(name = "end", type = { InstantType.class }, order = 2, min = 0, max = 1, modifier = false, summary = true)
907  @Description(shortDefinition = "When to automatically delete the subscription", formalDefinition = "The time for the server to turn the subscription off.")
908  protected InstantType end;
909
910  /**
911   * A description of why this subscription is defined.
912   */
913  @Child(name = "reason", type = { StringType.class }, order = 3, min = 1, max = 1, modifier = false, summary = true)
914  @Description(shortDefinition = "Description of why this subscription was created", formalDefinition = "A description of why this subscription is defined.")
915  protected StringType reason;
916
917  /**
918   * The rules that the server should use to determine when to generate
919   * notifications for this subscription.
920   */
921  @Child(name = "criteria", type = { StringType.class }, order = 4, min = 1, max = 1, modifier = false, summary = true)
922  @Description(shortDefinition = "Rule for server push", formalDefinition = "The rules that the server should use to determine when to generate notifications for this subscription.")
923  protected StringType criteria;
924
925  /**
926   * A record of the last error that occurred when the server processed a
927   * notification.
928   */
929  @Child(name = "error", type = { StringType.class }, order = 5, min = 0, max = 1, modifier = false, summary = true)
930  @Description(shortDefinition = "Latest error note", formalDefinition = "A record of the last error that occurred when the server processed a notification.")
931  protected StringType error;
932
933  /**
934   * Details where to send notifications when resources are received that meet the
935   * criteria.
936   */
937  @Child(name = "channel", type = {}, order = 6, min = 1, max = 1, modifier = false, summary = true)
938  @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.")
939  protected SubscriptionChannelComponent channel;
940
941  private static final long serialVersionUID = 1072504988L;
942
943  /**
944   * Constructor
945   */
946  public Subscription() {
947    super();
948  }
949
950  /**
951   * Constructor
952   */
953  public Subscription(Enumeration<SubscriptionStatus> status, StringType reason, StringType criteria,
954      SubscriptionChannelComponent channel) {
955    super();
956    this.status = status;
957    this.reason = reason;
958    this.criteria = criteria;
959    this.channel = channel;
960  }
961
962  /**
963   * @return {@link #status} (The status of the subscription, which marks the
964   *         server state for managing the subscription.). This is the underlying
965   *         object with id, value and extensions. The accessor "getStatus" gives
966   *         direct access to the value
967   */
968  public Enumeration<SubscriptionStatus> getStatusElement() {
969    if (this.status == null)
970      if (Configuration.errorOnAutoCreate())
971        throw new Error("Attempt to auto-create Subscription.status");
972      else if (Configuration.doAutoCreate())
973        this.status = new Enumeration<SubscriptionStatus>(new SubscriptionStatusEnumFactory()); // bb
974    return this.status;
975  }
976
977  public boolean hasStatusElement() {
978    return this.status != null && !this.status.isEmpty();
979  }
980
981  public boolean hasStatus() {
982    return this.status != null && !this.status.isEmpty();
983  }
984
985  /**
986   * @param value {@link #status} (The status of the subscription, which marks the
987   *              server state for managing the subscription.). This is the
988   *              underlying object with id, value and extensions. The accessor
989   *              "getStatus" gives direct access to the value
990   */
991  public Subscription setStatusElement(Enumeration<SubscriptionStatus> value) {
992    this.status = value;
993    return this;
994  }
995
996  /**
997   * @return The status of the subscription, which marks the server state for
998   *         managing the subscription.
999   */
1000  public SubscriptionStatus getStatus() {
1001    return this.status == null ? null : this.status.getValue();
1002  }
1003
1004  /**
1005   * @param value The status of the subscription, which marks the server state for
1006   *              managing the subscription.
1007   */
1008  public Subscription setStatus(SubscriptionStatus value) {
1009    if (this.status == null)
1010      this.status = new Enumeration<SubscriptionStatus>(new SubscriptionStatusEnumFactory());
1011    this.status.setValue(value);
1012    return this;
1013  }
1014
1015  /**
1016   * @return {@link #contact} (Contact details for a human to contact about the
1017   *         subscription. The primary use of this for system administrator
1018   *         troubleshooting.)
1019   */
1020  public List<ContactPoint> getContact() {
1021    if (this.contact == null)
1022      this.contact = new ArrayList<ContactPoint>();
1023    return this.contact;
1024  }
1025
1026  /**
1027   * @return Returns a reference to <code>this</code> for easy method chaining
1028   */
1029  public Subscription setContact(List<ContactPoint> theContact) {
1030    this.contact = theContact;
1031    return this;
1032  }
1033
1034  public boolean hasContact() {
1035    if (this.contact == null)
1036      return false;
1037    for (ContactPoint item : this.contact)
1038      if (!item.isEmpty())
1039        return true;
1040    return false;
1041  }
1042
1043  public ContactPoint addContact() { // 3
1044    ContactPoint t = new ContactPoint();
1045    if (this.contact == null)
1046      this.contact = new ArrayList<ContactPoint>();
1047    this.contact.add(t);
1048    return t;
1049  }
1050
1051  public Subscription addContact(ContactPoint t) { // 3
1052    if (t == null)
1053      return this;
1054    if (this.contact == null)
1055      this.contact = new ArrayList<ContactPoint>();
1056    this.contact.add(t);
1057    return this;
1058  }
1059
1060  /**
1061   * @return The first repetition of repeating field {@link #contact}, creating it
1062   *         if it does not already exist
1063   */
1064  public ContactPoint getContactFirstRep() {
1065    if (getContact().isEmpty()) {
1066      addContact();
1067    }
1068    return getContact().get(0);
1069  }
1070
1071  /**
1072   * @return {@link #end} (The time for the server to turn the subscription off.).
1073   *         This is the underlying object with id, value and extensions. The
1074   *         accessor "getEnd" gives direct access to the value
1075   */
1076  public InstantType getEndElement() {
1077    if (this.end == null)
1078      if (Configuration.errorOnAutoCreate())
1079        throw new Error("Attempt to auto-create Subscription.end");
1080      else if (Configuration.doAutoCreate())
1081        this.end = new InstantType(); // bb
1082    return this.end;
1083  }
1084
1085  public boolean hasEndElement() {
1086    return this.end != null && !this.end.isEmpty();
1087  }
1088
1089  public boolean hasEnd() {
1090    return this.end != null && !this.end.isEmpty();
1091  }
1092
1093  /**
1094   * @param value {@link #end} (The time for the server to turn the subscription
1095   *              off.). This is the underlying object with id, value and
1096   *              extensions. The accessor "getEnd" gives direct access to the
1097   *              value
1098   */
1099  public Subscription setEndElement(InstantType value) {
1100    this.end = value;
1101    return this;
1102  }
1103
1104  /**
1105   * @return The time for the server to turn the subscription off.
1106   */
1107  public Date getEnd() {
1108    return this.end == null ? null : this.end.getValue();
1109  }
1110
1111  /**
1112   * @param value The time for the server to turn the subscription off.
1113   */
1114  public Subscription setEnd(Date value) {
1115    if (value == null)
1116      this.end = null;
1117    else {
1118      if (this.end == null)
1119        this.end = new InstantType();
1120      this.end.setValue(value);
1121    }
1122    return this;
1123  }
1124
1125  /**
1126   * @return {@link #reason} (A description of why this subscription is defined.).
1127   *         This is the underlying object with id, value and extensions. The
1128   *         accessor "getReason" gives direct access to the value
1129   */
1130  public StringType getReasonElement() {
1131    if (this.reason == null)
1132      if (Configuration.errorOnAutoCreate())
1133        throw new Error("Attempt to auto-create Subscription.reason");
1134      else if (Configuration.doAutoCreate())
1135        this.reason = new StringType(); // bb
1136    return this.reason;
1137  }
1138
1139  public boolean hasReasonElement() {
1140    return this.reason != null && !this.reason.isEmpty();
1141  }
1142
1143  public boolean hasReason() {
1144    return this.reason != null && !this.reason.isEmpty();
1145  }
1146
1147  /**
1148   * @param value {@link #reason} (A description of why this subscription is
1149   *              defined.). This is the underlying object with id, value and
1150   *              extensions. The accessor "getReason" gives direct access to the
1151   *              value
1152   */
1153  public Subscription setReasonElement(StringType value) {
1154    this.reason = value;
1155    return this;
1156  }
1157
1158  /**
1159   * @return A description of why this subscription is defined.
1160   */
1161  public String getReason() {
1162    return this.reason == null ? null : this.reason.getValue();
1163  }
1164
1165  /**
1166   * @param value A description of why this subscription is defined.
1167   */
1168  public Subscription setReason(String value) {
1169    if (this.reason == null)
1170      this.reason = new StringType();
1171    this.reason.setValue(value);
1172    return this;
1173  }
1174
1175  /**
1176   * @return {@link #criteria} (The rules that the server should use to determine
1177   *         when to generate notifications for this subscription.). This is the
1178   *         underlying object with id, value and extensions. The accessor
1179   *         "getCriteria" gives direct access to the value
1180   */
1181  public StringType getCriteriaElement() {
1182    if (this.criteria == null)
1183      if (Configuration.errorOnAutoCreate())
1184        throw new Error("Attempt to auto-create Subscription.criteria");
1185      else if (Configuration.doAutoCreate())
1186        this.criteria = new StringType(); // bb
1187    return this.criteria;
1188  }
1189
1190  public boolean hasCriteriaElement() {
1191    return this.criteria != null && !this.criteria.isEmpty();
1192  }
1193
1194  public boolean hasCriteria() {
1195    return this.criteria != null && !this.criteria.isEmpty();
1196  }
1197
1198  /**
1199   * @param value {@link #criteria} (The rules that the server should use to
1200   *              determine when to generate notifications for this
1201   *              subscription.). This is the underlying object with id, value and
1202   *              extensions. The accessor "getCriteria" gives direct access to
1203   *              the value
1204   */
1205  public Subscription setCriteriaElement(StringType value) {
1206    this.criteria = value;
1207    return this;
1208  }
1209
1210  /**
1211   * @return The rules that the server should use to determine when to generate
1212   *         notifications for this subscription.
1213   */
1214  public String getCriteria() {
1215    return this.criteria == null ? null : this.criteria.getValue();
1216  }
1217
1218  /**
1219   * @param value The rules that the server should use to determine when to
1220   *              generate notifications for this subscription.
1221   */
1222  public Subscription setCriteria(String value) {
1223    if (this.criteria == null)
1224      this.criteria = new StringType();
1225    this.criteria.setValue(value);
1226    return this;
1227  }
1228
1229  /**
1230   * @return {@link #error} (A record of the last error that occurred when the
1231   *         server processed a notification.). This is the underlying object with
1232   *         id, value and extensions. The accessor "getError" gives direct access
1233   *         to the value
1234   */
1235  public StringType getErrorElement() {
1236    if (this.error == null)
1237      if (Configuration.errorOnAutoCreate())
1238        throw new Error("Attempt to auto-create Subscription.error");
1239      else if (Configuration.doAutoCreate())
1240        this.error = new StringType(); // bb
1241    return this.error;
1242  }
1243
1244  public boolean hasErrorElement() {
1245    return this.error != null && !this.error.isEmpty();
1246  }
1247
1248  public boolean hasError() {
1249    return this.error != null && !this.error.isEmpty();
1250  }
1251
1252  /**
1253   * @param value {@link #error} (A record of the last error that occurred when
1254   *              the server processed a notification.). This is the underlying
1255   *              object with id, value and extensions. The accessor "getError"
1256   *              gives direct access to the value
1257   */
1258  public Subscription setErrorElement(StringType value) {
1259    this.error = value;
1260    return this;
1261  }
1262
1263  /**
1264   * @return A record of the last error that occurred when the server processed a
1265   *         notification.
1266   */
1267  public String getError() {
1268    return this.error == null ? null : this.error.getValue();
1269  }
1270
1271  /**
1272   * @param value A record of the last error that occurred when the server
1273   *              processed a notification.
1274   */
1275  public Subscription setError(String value) {
1276    if (Utilities.noString(value))
1277      this.error = null;
1278    else {
1279      if (this.error == null)
1280        this.error = new StringType();
1281      this.error.setValue(value);
1282    }
1283    return this;
1284  }
1285
1286  /**
1287   * @return {@link #channel} (Details where to send notifications when resources
1288   *         are received that meet the criteria.)
1289   */
1290  public SubscriptionChannelComponent getChannel() {
1291    if (this.channel == null)
1292      if (Configuration.errorOnAutoCreate())
1293        throw new Error("Attempt to auto-create Subscription.channel");
1294      else if (Configuration.doAutoCreate())
1295        this.channel = new SubscriptionChannelComponent(); // cc
1296    return this.channel;
1297  }
1298
1299  public boolean hasChannel() {
1300    return this.channel != null && !this.channel.isEmpty();
1301  }
1302
1303  /**
1304   * @param value {@link #channel} (Details where to send notifications when
1305   *              resources are received that meet the criteria.)
1306   */
1307  public Subscription setChannel(SubscriptionChannelComponent value) {
1308    this.channel = value;
1309    return this;
1310  }
1311
1312  protected void listChildren(List<Property> children) {
1313    super.listChildren(children);
1314    children.add(new Property("status", "code",
1315        "The status of the subscription, which marks the server state for managing the subscription.", 0, 1, status));
1316    children.add(new Property("contact", "ContactPoint",
1317        "Contact details for a human to contact about the subscription. The primary use of this for system administrator troubleshooting.",
1318        0, java.lang.Integer.MAX_VALUE, contact));
1319    children.add(new Property("end", "instant", "The time for the server to turn the subscription off.", 0, 1, end));
1320    children.add(new Property("reason", "string", "A description of why this subscription is defined.", 0, 1, reason));
1321    children.add(new Property("criteria", "string",
1322        "The rules that the server should use to determine when to generate notifications for this subscription.", 0, 1,
1323        criteria));
1324    children.add(new Property("error", "string",
1325        "A record of the last error that occurred when the server processed a notification.", 0, 1, error));
1326    children.add(new Property("channel", "",
1327        "Details where to send notifications when resources are received that meet the criteria.", 0, 1, channel));
1328  }
1329
1330  @Override
1331  public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1332    switch (_hash) {
1333    case -892481550:
1334      /* status */ return new Property("status", "code",
1335          "The status of the subscription, which marks the server state for managing the subscription.", 0, 1, status);
1336    case 951526432:
1337      /* contact */ return new Property("contact", "ContactPoint",
1338          "Contact details for a human to contact about the subscription. The primary use of this for system administrator troubleshooting.",
1339          0, java.lang.Integer.MAX_VALUE, contact);
1340    case 100571:
1341      /* end */ return new Property("end", "instant", "The time for the server to turn the subscription off.", 0, 1,
1342          end);
1343    case -934964668:
1344      /* reason */ return new Property("reason", "string", "A description of why this subscription is defined.", 0, 1,
1345          reason);
1346    case 1952046943:
1347      /* criteria */ return new Property("criteria", "string",
1348          "The rules that the server should use to determine when to generate notifications for this subscription.", 0,
1349          1, criteria);
1350    case 96784904:
1351      /* error */ return new Property("error", "string",
1352          "A record of the last error that occurred when the server processed a notification.", 0, 1, error);
1353    case 738950403:
1354      /* channel */ return new Property("channel", "",
1355          "Details where to send notifications when resources are received that meet the criteria.", 0, 1, channel);
1356    default:
1357      return super.getNamedProperty(_hash, _name, _checkValid);
1358    }
1359
1360  }
1361
1362  @Override
1363  public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1364    switch (hash) {
1365    case -892481550:
1366      /* status */ return this.status == null ? new Base[0] : new Base[] { this.status }; // Enumeration<SubscriptionStatus>
1367    case 951526432:
1368      /* contact */ return this.contact == null ? new Base[0] : this.contact.toArray(new Base[this.contact.size()]); // ContactPoint
1369    case 100571:
1370      /* end */ return this.end == null ? new Base[0] : new Base[] { this.end }; // InstantType
1371    case -934964668:
1372      /* reason */ return this.reason == null ? new Base[0] : new Base[] { this.reason }; // StringType
1373    case 1952046943:
1374      /* criteria */ return this.criteria == null ? new Base[0] : new Base[] { this.criteria }; // StringType
1375    case 96784904:
1376      /* error */ return this.error == null ? new Base[0] : new Base[] { this.error }; // StringType
1377    case 738950403:
1378      /* channel */ return this.channel == null ? new Base[0] : new Base[] { this.channel }; // SubscriptionChannelComponent
1379    default:
1380      return super.getProperty(hash, name, checkValid);
1381    }
1382
1383  }
1384
1385  @Override
1386  public Base setProperty(int hash, String name, Base value) throws FHIRException {
1387    switch (hash) {
1388    case -892481550: // status
1389      value = new SubscriptionStatusEnumFactory().fromType(castToCode(value));
1390      this.status = (Enumeration) value; // Enumeration<SubscriptionStatus>
1391      return value;
1392    case 951526432: // contact
1393      this.getContact().add(castToContactPoint(value)); // ContactPoint
1394      return value;
1395    case 100571: // end
1396      this.end = castToInstant(value); // InstantType
1397      return value;
1398    case -934964668: // reason
1399      this.reason = castToString(value); // StringType
1400      return value;
1401    case 1952046943: // criteria
1402      this.criteria = castToString(value); // StringType
1403      return value;
1404    case 96784904: // error
1405      this.error = castToString(value); // StringType
1406      return value;
1407    case 738950403: // channel
1408      this.channel = (SubscriptionChannelComponent) value; // SubscriptionChannelComponent
1409      return value;
1410    default:
1411      return super.setProperty(hash, name, value);
1412    }
1413
1414  }
1415
1416  @Override
1417  public Base setProperty(String name, Base value) throws FHIRException {
1418    if (name.equals("status")) {
1419      value = new SubscriptionStatusEnumFactory().fromType(castToCode(value));
1420      this.status = (Enumeration) value; // Enumeration<SubscriptionStatus>
1421    } else if (name.equals("contact")) {
1422      this.getContact().add(castToContactPoint(value));
1423    } else if (name.equals("end")) {
1424      this.end = castToInstant(value); // InstantType
1425    } else if (name.equals("reason")) {
1426      this.reason = castToString(value); // StringType
1427    } else if (name.equals("criteria")) {
1428      this.criteria = castToString(value); // StringType
1429    } else if (name.equals("error")) {
1430      this.error = castToString(value); // StringType
1431    } else if (name.equals("channel")) {
1432      this.channel = (SubscriptionChannelComponent) value; // SubscriptionChannelComponent
1433    } else
1434      return super.setProperty(name, value);
1435    return value;
1436  }
1437
1438  @Override
1439  public Base makeProperty(int hash, String name) throws FHIRException {
1440    switch (hash) {
1441    case -892481550:
1442      return getStatusElement();
1443    case 951526432:
1444      return addContact();
1445    case 100571:
1446      return getEndElement();
1447    case -934964668:
1448      return getReasonElement();
1449    case 1952046943:
1450      return getCriteriaElement();
1451    case 96784904:
1452      return getErrorElement();
1453    case 738950403:
1454      return getChannel();
1455    default:
1456      return super.makeProperty(hash, name);
1457    }
1458
1459  }
1460
1461  @Override
1462  public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1463    switch (hash) {
1464    case -892481550:
1465      /* status */ return new String[] { "code" };
1466    case 951526432:
1467      /* contact */ return new String[] { "ContactPoint" };
1468    case 100571:
1469      /* end */ return new String[] { "instant" };
1470    case -934964668:
1471      /* reason */ return new String[] { "string" };
1472    case 1952046943:
1473      /* criteria */ return new String[] { "string" };
1474    case 96784904:
1475      /* error */ return new String[] { "string" };
1476    case 738950403:
1477      /* channel */ return new String[] {};
1478    default:
1479      return super.getTypesForProperty(hash, name);
1480    }
1481
1482  }
1483
1484  @Override
1485  public Base addChild(String name) throws FHIRException {
1486    if (name.equals("status")) {
1487      throw new FHIRException("Cannot call addChild on a singleton property Subscription.status");
1488    } else if (name.equals("contact")) {
1489      return addContact();
1490    } else if (name.equals("end")) {
1491      throw new FHIRException("Cannot call addChild on a singleton property Subscription.end");
1492    } else if (name.equals("reason")) {
1493      throw new FHIRException("Cannot call addChild on a singleton property Subscription.reason");
1494    } else if (name.equals("criteria")) {
1495      throw new FHIRException("Cannot call addChild on a singleton property Subscription.criteria");
1496    } else if (name.equals("error")) {
1497      throw new FHIRException("Cannot call addChild on a singleton property Subscription.error");
1498    } else if (name.equals("channel")) {
1499      this.channel = new SubscriptionChannelComponent();
1500      return this.channel;
1501    } else
1502      return super.addChild(name);
1503  }
1504
1505  public String fhirType() {
1506    return "Subscription";
1507
1508  }
1509
1510  public Subscription copy() {
1511    Subscription dst = new Subscription();
1512    copyValues(dst);
1513    return dst;
1514  }
1515
1516  public void copyValues(Subscription dst) {
1517    super.copyValues(dst);
1518    dst.status = status == null ? null : status.copy();
1519    if (contact != null) {
1520      dst.contact = new ArrayList<ContactPoint>();
1521      for (ContactPoint i : contact)
1522        dst.contact.add(i.copy());
1523    }
1524    ;
1525    dst.end = end == null ? null : end.copy();
1526    dst.reason = reason == null ? null : reason.copy();
1527    dst.criteria = criteria == null ? null : criteria.copy();
1528    dst.error = error == null ? null : error.copy();
1529    dst.channel = channel == null ? null : channel.copy();
1530  }
1531
1532  protected Subscription typedCopy() {
1533    return copy();
1534  }
1535
1536  @Override
1537  public boolean equalsDeep(Base other_) {
1538    if (!super.equalsDeep(other_))
1539      return false;
1540    if (!(other_ instanceof Subscription))
1541      return false;
1542    Subscription o = (Subscription) other_;
1543    return compareDeep(status, o.status, true) && compareDeep(contact, o.contact, true) && compareDeep(end, o.end, true)
1544        && compareDeep(reason, o.reason, true) && compareDeep(criteria, o.criteria, true)
1545        && compareDeep(error, o.error, true) && compareDeep(channel, o.channel, true);
1546  }
1547
1548  @Override
1549  public boolean equalsShallow(Base other_) {
1550    if (!super.equalsShallow(other_))
1551      return false;
1552    if (!(other_ instanceof Subscription))
1553      return false;
1554    Subscription o = (Subscription) other_;
1555    return compareValues(status, o.status, true) && compareValues(end, o.end, true)
1556        && compareValues(reason, o.reason, true) && compareValues(criteria, o.criteria, true)
1557        && compareValues(error, o.error, true);
1558  }
1559
1560  public boolean isEmpty() {
1561    return super.isEmpty()
1562        && ca.uhn.fhir.util.ElementUtil.isEmpty(status, contact, end, reason, criteria, error, channel);
1563  }
1564
1565  @Override
1566  public ResourceType getResourceType() {
1567    return ResourceType.Subscription;
1568  }
1569
1570  /**
1571   * Search parameter: <b>payload</b>
1572   * <p>
1573   * Description: <b>The mime-type of the notification payload</b><br>
1574   * Type: <b>token</b><br>
1575   * Path: <b>Subscription.channel.payload</b><br>
1576   * </p>
1577   */
1578  @SearchParamDefinition(name = "payload", path = "Subscription.channel.payload", description = "The mime-type of the notification payload", type = "token")
1579  public static final String SP_PAYLOAD = "payload";
1580  /**
1581   * <b>Fluent Client</b> search parameter constant for <b>payload</b>
1582   * <p>
1583   * Description: <b>The mime-type of the notification payload</b><br>
1584   * Type: <b>token</b><br>
1585   * Path: <b>Subscription.channel.payload</b><br>
1586   * </p>
1587   */
1588  public static final ca.uhn.fhir.rest.gclient.TokenClientParam PAYLOAD = new ca.uhn.fhir.rest.gclient.TokenClientParam(
1589      SP_PAYLOAD);
1590
1591  /**
1592   * Search parameter: <b>criteria</b>
1593   * <p>
1594   * Description: <b>The search rules used to determine when to send a
1595   * notification</b><br>
1596   * Type: <b>string</b><br>
1597   * Path: <b>Subscription.criteria</b><br>
1598   * </p>
1599   */
1600  @SearchParamDefinition(name = "criteria", path = "Subscription.criteria", description = "The search rules used to determine when to send a notification", type = "string")
1601  public static final String SP_CRITERIA = "criteria";
1602  /**
1603   * <b>Fluent Client</b> search parameter constant for <b>criteria</b>
1604   * <p>
1605   * Description: <b>The search rules used to determine when to send a
1606   * notification</b><br>
1607   * Type: <b>string</b><br>
1608   * Path: <b>Subscription.criteria</b><br>
1609   * </p>
1610   */
1611  public static final ca.uhn.fhir.rest.gclient.StringClientParam CRITERIA = new ca.uhn.fhir.rest.gclient.StringClientParam(
1612      SP_CRITERIA);
1613
1614  /**
1615   * Search parameter: <b>contact</b>
1616   * <p>
1617   * Description: <b>Contact details for the subscription</b><br>
1618   * Type: <b>token</b><br>
1619   * Path: <b>Subscription.contact</b><br>
1620   * </p>
1621   */
1622  @SearchParamDefinition(name = "contact", path = "Subscription.contact", description = "Contact details for the subscription", type = "token")
1623  public static final String SP_CONTACT = "contact";
1624  /**
1625   * <b>Fluent Client</b> search parameter constant for <b>contact</b>
1626   * <p>
1627   * Description: <b>Contact details for the subscription</b><br>
1628   * Type: <b>token</b><br>
1629   * Path: <b>Subscription.contact</b><br>
1630   * </p>
1631   */
1632  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CONTACT = new ca.uhn.fhir.rest.gclient.TokenClientParam(
1633      SP_CONTACT);
1634
1635  /**
1636   * Search parameter: <b>type</b>
1637   * <p>
1638   * Description: <b>The type of channel for the sent notifications</b><br>
1639   * Type: <b>token</b><br>
1640   * Path: <b>Subscription.channel.type</b><br>
1641   * </p>
1642   */
1643  @SearchParamDefinition(name = "type", path = "Subscription.channel.type", description = "The type of channel for the sent notifications", type = "token")
1644  public static final String SP_TYPE = "type";
1645  /**
1646   * <b>Fluent Client</b> search parameter constant for <b>type</b>
1647   * <p>
1648   * Description: <b>The type of channel for the sent notifications</b><br>
1649   * Type: <b>token</b><br>
1650   * Path: <b>Subscription.channel.type</b><br>
1651   * </p>
1652   */
1653  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(
1654      SP_TYPE);
1655
1656  /**
1657   * Search parameter: <b>url</b>
1658   * <p>
1659   * Description: <b>The uri that will receive the notifications</b><br>
1660   * Type: <b>uri</b><br>
1661   * Path: <b>Subscription.channel.endpoint</b><br>
1662   * </p>
1663   */
1664  @SearchParamDefinition(name = "url", path = "Subscription.channel.endpoint", description = "The uri that will receive the notifications", type = "uri")
1665  public static final String SP_URL = "url";
1666  /**
1667   * <b>Fluent Client</b> search parameter constant for <b>url</b>
1668   * <p>
1669   * Description: <b>The uri that will receive the notifications</b><br>
1670   * Type: <b>uri</b><br>
1671   * Path: <b>Subscription.channel.endpoint</b><br>
1672   * </p>
1673   */
1674  public static final ca.uhn.fhir.rest.gclient.UriClientParam URL = new ca.uhn.fhir.rest.gclient.UriClientParam(SP_URL);
1675
1676  /**
1677   * Search parameter: <b>status</b>
1678   * <p>
1679   * Description: <b>The current state of the subscription</b><br>
1680   * Type: <b>token</b><br>
1681   * Path: <b>Subscription.status</b><br>
1682   * </p>
1683   */
1684  @SearchParamDefinition(name = "status", path = "Subscription.status", description = "The current state of the subscription", type = "token")
1685  public static final String SP_STATUS = "status";
1686  /**
1687   * <b>Fluent Client</b> search parameter constant for <b>status</b>
1688   * <p>
1689   * Description: <b>The current state of the subscription</b><br>
1690   * Type: <b>token</b><br>
1691   * Path: <b>Subscription.status</b><br>
1692   * </p>
1693   */
1694  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(
1695      SP_STATUS);
1696
1697}