001package org.hl7.fhir.r5.tools;
002
003
004/*
005  Copyright (c) 2011+, HL7, Inc.
006  All rights reserved.
007  
008  Redistribution and use in source and binary forms, with or without modification, \
009  are permitted provided that the following conditions are met:
010  
011   * Redistributions of source code must retain the above copyright notice, this \
012     list of conditions and the following disclaimer.
013   * Redistributions in binary form must reproduce the above copyright notice, \
014     this list of conditions and the following disclaimer in the documentation \
015     and/or other materials provided with the distribution.
016   * Neither the name of HL7 nor the names of its contributors may be used to 
017     endorse or promote products derived from this software without specific 
018     prior written permission.
019  
020  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \
021  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \
022  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \
023  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \
024  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \
025  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \
026  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \
027  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \
028  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \
029  POSSIBILITY OF SUCH DAMAGE.
030  */
031
032// Generated on Thu, Mar 23, 2023 19:59+1100 for FHIR v5.0.0
033
034import java.util.ArrayList;
035import java.util.Date;
036import java.util.List;
037import org.hl7.fhir.utilities.Utilities;
038import org.hl7.fhir.r5.tools.Enumerations.*;
039import org.hl7.fhir.exceptions.FHIRException;
040import org.hl7.fhir.r5.model.*;
041import org.hl7.fhir.instance.model.api.ICompositeType;
042import ca.uhn.fhir.model.api.annotation.Child;
043import ca.uhn.fhir.model.api.annotation.ChildOrder;
044import ca.uhn.fhir.model.api.annotation.DatatypeDef;
045import ca.uhn.fhir.model.api.annotation.Description;
046import ca.uhn.fhir.model.api.annotation.Block;
047
048/**
049 * This structure is defined to allow the FHIR Validator to validate a CDSHooks Services response body. TODO: This content will be moved to the CDS Hooks specification in the future
050 */
051@DatatypeDef(name="CDSHooksServices")
052public class CDSHooksServices extends CDSHooksElement implements ICompositeType {
053
054    @Block()
055    public static class CDSHooksServicesServicesComponent extends CDSHooksElement {
056        /**
057         * The hook this Services should be invoked on
058         */
059        @Child(name = "hook", type = {StringType.class}, order=1, min=1, max=1, modifier=false, summary=false)
060        @Description(shortDefinition="The hook this Services should be invoked on", formalDefinition="The hook this Services should be invoked on" )
061        protected StringType hook;
062
063        /**
064         * The human-friendly name of this Services (Recommended)
065         */
066        @Child(name = "title", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=false)
067        @Description(shortDefinition="The human-friendly name of this Services (Recommended)", formalDefinition="The human-friendly name of this Services (Recommended)" )
068        protected StringType title;
069
070        /**
071         * The {id} portion of the URL to this service which is available at ```{baseUrl}/cds-services/{id}```
072         */
073        @Child(name = "id", type = {CodeType.class}, order=3, min=1, max=1, modifier=false, summary=false)
074        @Description(shortDefinition="The URL to this service which is available at: {baseUrl}/cds-services/{id}", formalDefinition="The {id} portion of the URL to this service which is available at ```{baseUrl}/cds-services/{id}```" )
075        protected CodeType id;
076
077        /**
078         * The description of this Services
079         */
080        @Child(name = "description", type = {StringType.class}, order=4, min=1, max=1, modifier=false, summary=false)
081        @Description(shortDefinition="The description of this Services", formalDefinition="The description of this Services" )
082        protected StringType description;
083
084        /**
085         * Human-friendly description of any preconditions for the use of this CDS Services
086         */
087        @Child(name = "usageRequirements", type = {StringType.class}, order=5, min=0, max=1, modifier=false, summary=false)
088        @Description(shortDefinition="Human-friendly description of any preconditions for the use of this CDS Services", formalDefinition="Human-friendly description of any preconditions for the use of this CDS Services" )
089        protected StringType usageRequirements;
090
091        /**
092         * An object containing key/value pairs of FHIR queries that this Services is requesting the CDS Client to perform and provide on each Services call. The key is a string that describes the type of data being requested and the value is a string representing the FHIR query
093         */
094        @Child(name = "prefetch", type = {Base.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
095        @Description(shortDefinition="Key/value pairs of FHIR queries the CDS Client provides on each call", formalDefinition="An object containing key/value pairs of FHIR queries that this Services is requesting the CDS Client to perform and provide on each Services call. The key is a string that describes the type of data being requested and the value is a string representing the FHIR query" )
096        protected List<CDSHooksServicesServicesPrefetchComponent> prefetch;
097
098        private static final long serialVersionUID = 1456889325L;
099
100    /**
101     * Constructor
102     */
103      public CDSHooksServicesServicesComponent() {
104        super();
105      }
106
107    /**
108     * Constructor
109     */
110      public CDSHooksServicesServicesComponent(String hook, String id, String description) {
111        super();
112        this.setHook(hook);
113        this.setId(id);
114        this.setDescription(description);
115      }
116
117        /**
118         * @return {@link #hook} (The hook this Services should be invoked on). This is the underlying object with id, value and extensions. The accessor "getHook" gives direct access to the value
119         */
120        public StringType getHookElement() { 
121          if (this.hook == null)
122            if (Configuration.errorOnAutoCreate())
123              throw new Error("Attempt to auto-create CDSHooksServicesServicesComponent.hook");
124            else if (Configuration.doAutoCreate())
125              this.hook = new StringType(); // bb
126          return this.hook;
127        }
128
129        public boolean hasHookElement() { 
130          return this.hook != null && !this.hook.isEmpty();
131        }
132
133        public boolean hasHook() { 
134          return this.hook != null && !this.hook.isEmpty();
135        }
136
137        /**
138         * @param value {@link #hook} (The hook this Services should be invoked on). This is the underlying object with id, value and extensions. The accessor "getHook" gives direct access to the value
139         */
140        public CDSHooksServicesServicesComponent setHookElement(StringType value) { 
141          this.hook = value;
142          return this;
143        }
144
145        /**
146         * @return The hook this Services should be invoked on
147         */
148        public String getHook() { 
149          return this.hook == null ? null : this.hook.getValue();
150        }
151
152        /**
153         * @param value The hook this Services should be invoked on
154         */
155        public CDSHooksServicesServicesComponent setHook(String value) { 
156            if (this.hook == null)
157              this.hook = new StringType();
158            this.hook.setValue(value);
159          return this;
160        }
161
162        /**
163         * @return {@link #title} (The human-friendly name of this Services (Recommended)). This is the underlying object with id, value and extensions. The accessor "getTitle" gives direct access to the value
164         */
165        public StringType getTitleElement() { 
166          if (this.title == null)
167            if (Configuration.errorOnAutoCreate())
168              throw new Error("Attempt to auto-create CDSHooksServicesServicesComponent.title");
169            else if (Configuration.doAutoCreate())
170              this.title = new StringType(); // bb
171          return this.title;
172        }
173
174        public boolean hasTitleElement() { 
175          return this.title != null && !this.title.isEmpty();
176        }
177
178        public boolean hasTitle() { 
179          return this.title != null && !this.title.isEmpty();
180        }
181
182        /**
183         * @param value {@link #title} (The human-friendly name of this Services (Recommended)). This is the underlying object with id, value and extensions. The accessor "getTitle" gives direct access to the value
184         */
185        public CDSHooksServicesServicesComponent setTitleElement(StringType value) { 
186          this.title = value;
187          return this;
188        }
189
190        /**
191         * @return The human-friendly name of this Services (Recommended)
192         */
193        public String getTitle() { 
194          return this.title == null ? null : this.title.getValue();
195        }
196
197        /**
198         * @param value The human-friendly name of this Services (Recommended)
199         */
200        public CDSHooksServicesServicesComponent setTitle(String value) { 
201          if (Utilities.noString(value))
202            this.title = null;
203          else {
204            if (this.title == null)
205              this.title = new StringType();
206            this.title.setValue(value);
207          }
208          return this;
209        }
210
211        /**
212         * @return {@link #id} (The {id} portion of the URL to this service which is available at ```{baseUrl}/cds-services/{id}```). This is the underlying object with id, value and extensions. The accessor "getId" gives direct access to the value
213         */
214        public CodeType getIdElement() { 
215          if (this.id == null)
216            if (Configuration.errorOnAutoCreate())
217              throw new Error("Attempt to auto-create CDSHooksServicesServicesComponent.id");
218            else if (Configuration.doAutoCreate())
219              this.id = new CodeType(); // bb
220          return this.id;
221        }
222
223        public boolean hasIdElement() { 
224          return this.id != null && !this.id.isEmpty();
225        }
226
227        public boolean hasId() { 
228          return this.id != null && !this.id.isEmpty();
229        }
230
231        /**
232         * @param value {@link #id} (The {id} portion of the URL to this service which is available at ```{baseUrl}/cds-services/{id}```). This is the underlying object with id, value and extensions. The accessor "getId" gives direct access to the value
233         */
234        public CDSHooksServicesServicesComponent setIdElement(CodeType value) { 
235          this.id = value;
236          return this;
237        }
238
239        /**
240         * @return The {id} portion of the URL to this service which is available at ```{baseUrl}/cds-services/{id}```
241         */
242        public String getId() { 
243          return this.id == null ? null : this.id.getValue();
244        }
245
246        /**
247         * @param value The {id} portion of the URL to this service which is available at ```{baseUrl}/cds-services/{id}```
248         */
249        public CDSHooksServicesServicesComponent setId(String value) { 
250            if (this.id == null)
251              this.id = new CodeType();
252            this.id.setValue(value);
253          return this;
254        }
255
256        /**
257         * @return {@link #description} (The description of this Services). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
258         */
259        public StringType getDescriptionElement() { 
260          if (this.description == null)
261            if (Configuration.errorOnAutoCreate())
262              throw new Error("Attempt to auto-create CDSHooksServicesServicesComponent.description");
263            else if (Configuration.doAutoCreate())
264              this.description = new StringType(); // bb
265          return this.description;
266        }
267
268        public boolean hasDescriptionElement() { 
269          return this.description != null && !this.description.isEmpty();
270        }
271
272        public boolean hasDescription() { 
273          return this.description != null && !this.description.isEmpty();
274        }
275
276        /**
277         * @param value {@link #description} (The description of this Services). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
278         */
279        public CDSHooksServicesServicesComponent setDescriptionElement(StringType value) { 
280          this.description = value;
281          return this;
282        }
283
284        /**
285         * @return The description of this Services
286         */
287        public String getDescription() { 
288          return this.description == null ? null : this.description.getValue();
289        }
290
291        /**
292         * @param value The description of this Services
293         */
294        public CDSHooksServicesServicesComponent setDescription(String value) { 
295            if (this.description == null)
296              this.description = new StringType();
297            this.description.setValue(value);
298          return this;
299        }
300
301        /**
302         * @return {@link #usageRequirements} (Human-friendly description of any preconditions for the use of this CDS Services). This is the underlying object with id, value and extensions. The accessor "getUsageRequirements" gives direct access to the value
303         */
304        public StringType getUsageRequirementsElement() { 
305          if (this.usageRequirements == null)
306            if (Configuration.errorOnAutoCreate())
307              throw new Error("Attempt to auto-create CDSHooksServicesServicesComponent.usageRequirements");
308            else if (Configuration.doAutoCreate())
309              this.usageRequirements = new StringType(); // bb
310          return this.usageRequirements;
311        }
312
313        public boolean hasUsageRequirementsElement() { 
314          return this.usageRequirements != null && !this.usageRequirements.isEmpty();
315        }
316
317        public boolean hasUsageRequirements() { 
318          return this.usageRequirements != null && !this.usageRequirements.isEmpty();
319        }
320
321        /**
322         * @param value {@link #usageRequirements} (Human-friendly description of any preconditions for the use of this CDS Services). This is the underlying object with id, value and extensions. The accessor "getUsageRequirements" gives direct access to the value
323         */
324        public CDSHooksServicesServicesComponent setUsageRequirementsElement(StringType value) { 
325          this.usageRequirements = value;
326          return this;
327        }
328
329        /**
330         * @return Human-friendly description of any preconditions for the use of this CDS Services
331         */
332        public String getUsageRequirements() { 
333          return this.usageRequirements == null ? null : this.usageRequirements.getValue();
334        }
335
336        /**
337         * @param value Human-friendly description of any preconditions for the use of this CDS Services
338         */
339        public CDSHooksServicesServicesComponent setUsageRequirements(String value) { 
340          if (Utilities.noString(value))
341            this.usageRequirements = null;
342          else {
343            if (this.usageRequirements == null)
344              this.usageRequirements = new StringType();
345            this.usageRequirements.setValue(value);
346          }
347          return this;
348        }
349
350        /**
351         * @return {@link #prefetch} (An object containing key/value pairs of FHIR queries that this Services is requesting the CDS Client to perform and provide on each Services call. The key is a string that describes the type of data being requested and the value is a string representing the FHIR query)
352         */
353        public List<CDSHooksServicesServicesPrefetchComponent> getPrefetch() { 
354          if (this.prefetch == null)
355            this.prefetch = new ArrayList<CDSHooksServicesServicesPrefetchComponent>();
356          return this.prefetch;
357        }
358
359        /**
360         * @return Returns a reference to <code>this</code> for easy method chaining
361         */
362        public CDSHooksServicesServicesComponent setPrefetch(List<CDSHooksServicesServicesPrefetchComponent> thePrefetch) { 
363          this.prefetch = thePrefetch;
364          return this;
365        }
366
367        public boolean hasPrefetch() { 
368          if (this.prefetch == null)
369            return false;
370          for (CDSHooksServicesServicesPrefetchComponent item : this.prefetch)
371            if (!item.isEmpty())
372              return true;
373          return false;
374        }
375
376        public CDSHooksServicesServicesPrefetchComponent addPrefetch() { //3
377          CDSHooksServicesServicesPrefetchComponent t = new CDSHooksServicesServicesPrefetchComponent();
378          if (this.prefetch == null)
379            this.prefetch = new ArrayList<CDSHooksServicesServicesPrefetchComponent>();
380          this.prefetch.add(t);
381          return t;
382        }
383
384        public CDSHooksServicesServicesComponent addPrefetch(CDSHooksServicesServicesPrefetchComponent t) { //3
385          if (t == null)
386            return this;
387          if (this.prefetch == null)
388            this.prefetch = new ArrayList<CDSHooksServicesServicesPrefetchComponent>();
389          this.prefetch.add(t);
390          return this;
391        }
392
393        /**
394         * @return The first repetition of repeating field {@link #prefetch}, creating it if it does not already exist {3}
395         */
396        public CDSHooksServicesServicesPrefetchComponent getPrefetchFirstRep() { 
397          if (getPrefetch().isEmpty()) {
398            addPrefetch();
399          }
400          return getPrefetch().get(0);
401        }
402
403        protected void listChildren(List<Property> children) {
404          super.listChildren(children);
405          children.add(new Property("hook", "string", "The hook this Services should be invoked on", 0, 1, hook));
406          children.add(new Property("title", "string", "The human-friendly name of this Services (Recommended)", 0, 1, title));
407          children.add(new Property("id", "code", "The {id} portion of the URL to this service which is available at ```{baseUrl}/cds-services/{id}```", 0, 1, id));
408          children.add(new Property("description", "string", "The description of this Services", 0, 1, description));
409          children.add(new Property("usageRequirements", "string", "Human-friendly description of any preconditions for the use of this CDS Services", 0, 1, usageRequirements));
410          children.add(new Property("prefetch", "Base", "An object containing key/value pairs of FHIR queries that this Services is requesting the CDS Client to perform and provide on each Services call. The key is a string that describes the type of data being requested and the value is a string representing the FHIR query", 0, java.lang.Integer.MAX_VALUE, prefetch));
411        }
412
413        @Override
414        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
415          switch (_hash) {
416          case 3208483: /*hook*/  return new Property("hook", "string", "The hook this Services should be invoked on", 0, 1, hook);
417          case 110371416: /*title*/  return new Property("title", "string", "The human-friendly name of this Services (Recommended)", 0, 1, title);
418          case 3355: /*id*/  return new Property("id", "code", "The {id} portion of the URL to this service which is available at ```{baseUrl}/cds-services/{id}```", 0, 1, id);
419          case -1724546052: /*description*/  return new Property("description", "string", "The description of this Services", 0, 1, description);
420          case -512224047: /*usageRequirements*/  return new Property("usageRequirements", "string", "Human-friendly description of any preconditions for the use of this CDS Services", 0, 1, usageRequirements);
421          case -1288666633: /*prefetch*/  return new Property("prefetch", "Base", "An object containing key/value pairs of FHIR queries that this Services is requesting the CDS Client to perform and provide on each Services call. The key is a string that describes the type of data being requested and the value is a string representing the FHIR query", 0, java.lang.Integer.MAX_VALUE, prefetch);
422          default: return super.getNamedProperty(_hash, _name, _checkValid);
423          }
424
425        }
426
427      @Override
428      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
429        switch (hash) {
430        case 3208483: /*hook*/ return this.hook == null ? new Base[0] : new Base[] {this.hook}; // StringType
431        case 110371416: /*title*/ return this.title == null ? new Base[0] : new Base[] {this.title}; // StringType
432        case 3355: /*id*/ return this.id == null ? new Base[0] : new Base[] {this.id}; // CodeType
433        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // StringType
434        case -512224047: /*usageRequirements*/ return this.usageRequirements == null ? new Base[0] : new Base[] {this.usageRequirements}; // StringType
435        case -1288666633: /*prefetch*/ return this.prefetch == null ? new Base[0] : this.prefetch.toArray(new Base[this.prefetch.size()]); // CDSHooksServicesServicesPrefetchComponent
436        default: return super.getProperty(hash, name, checkValid);
437        }
438
439      }
440
441      @Override
442      public Base setProperty(int hash, String name, Base value) throws FHIRException {
443        switch (hash) {
444        case 3208483: // hook
445          this.hook = TypeConvertor.castToString(value); // StringType
446          return value;
447        case 110371416: // title
448          this.title = TypeConvertor.castToString(value); // StringType
449          return value;
450        case 3355: // id
451          this.id = TypeConvertor.castToCode(value); // CodeType
452          return value;
453        case -1724546052: // description
454          this.description = TypeConvertor.castToString(value); // StringType
455          return value;
456        case -512224047: // usageRequirements
457          this.usageRequirements = TypeConvertor.castToString(value); // StringType
458          return value;
459        case -1288666633: // prefetch
460          this.getPrefetch().add((CDSHooksServicesServicesPrefetchComponent) value); // CDSHooksServicesServicesPrefetchComponent
461          return value;
462        default: return super.setProperty(hash, name, value);
463        }
464
465      }
466
467      @Override
468      public Base setProperty(String name, Base value) throws FHIRException {
469        if (name.equals("hook")) {
470          this.hook = TypeConvertor.castToString(value); // StringType
471        } else if (name.equals("title")) {
472          this.title = TypeConvertor.castToString(value); // StringType
473        } else if (name.equals("id")) {
474          this.id = TypeConvertor.castToCode(value); // CodeType
475        } else if (name.equals("description")) {
476          this.description = TypeConvertor.castToString(value); // StringType
477        } else if (name.equals("usageRequirements")) {
478          this.usageRequirements = TypeConvertor.castToString(value); // StringType
479        } else if (name.equals("prefetch")) {
480          this.getPrefetch().add((CDSHooksServicesServicesPrefetchComponent) value); // CDSHooksServicesServicesPrefetchComponent
481        } else
482          return super.setProperty(name, value);
483        return value;
484      }
485
486      @Override
487      public Base makeProperty(int hash, String name) throws FHIRException {
488        switch (hash) {
489        case 3208483:  return getHookElement();
490        case 110371416:  return getTitleElement();
491        case 3355:  return getIdElement();
492        case -1724546052:  return getDescriptionElement();
493        case -512224047:  return getUsageRequirementsElement();
494        case -1288666633:  return addPrefetch(); 
495        default: return super.makeProperty(hash, name);
496        }
497
498      }
499
500      @Override
501      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
502        switch (hash) {
503        case 3208483: /*hook*/ return new String[] {"string"};
504        case 110371416: /*title*/ return new String[] {"string"};
505        case 3355: /*id*/ return new String[] {"code"};
506        case -1724546052: /*description*/ return new String[] {"string"};
507        case -512224047: /*usageRequirements*/ return new String[] {"string"};
508        case -1288666633: /*prefetch*/ return new String[] {"Base"};
509        default: return super.getTypesForProperty(hash, name);
510        }
511
512      }
513
514      @Override
515      public Base addChild(String name) throws FHIRException {
516        if (name.equals("hook")) {
517          throw new FHIRException("Cannot call addChild on a singleton property CDSHooksServices.services.hook");
518        }
519        else if (name.equals("title")) {
520          throw new FHIRException("Cannot call addChild on a singleton property CDSHooksServices.services.title");
521        }
522        else if (name.equals("id")) {
523          throw new FHIRException("Cannot call addChild on a singleton property CDSHooksServices.services.id");
524        }
525        else if (name.equals("description")) {
526          throw new FHIRException("Cannot call addChild on a singleton property CDSHooksServices.services.description");
527        }
528        else if (name.equals("usageRequirements")) {
529          throw new FHIRException("Cannot call addChild on a singleton property CDSHooksServices.services.usageRequirements");
530        }
531        else if (name.equals("prefetch")) {
532          throw new FHIRException("Cannot call addChild on an abstract type CDSHooksServices.services.prefetch");
533        }
534        else
535          return super.addChild(name);
536      }
537
538      public CDSHooksServicesServicesComponent copy() {
539        CDSHooksServicesServicesComponent dst = new CDSHooksServicesServicesComponent();
540        copyValues(dst);
541        return dst;
542      }
543
544      public void copyValues(CDSHooksServicesServicesComponent dst) {
545        super.copyValues(dst);
546        dst.hook = hook == null ? null : hook.copy();
547        dst.title = title == null ? null : title.copy();
548        dst.id = id == null ? null : id.copy();
549        dst.description = description == null ? null : description.copy();
550        dst.usageRequirements = usageRequirements == null ? null : usageRequirements.copy();
551        if (prefetch != null) {
552          dst.prefetch = new ArrayList<CDSHooksServicesServicesPrefetchComponent>();
553          for (CDSHooksServicesServicesPrefetchComponent i : prefetch)
554            dst.prefetch.add(i.copy());
555        };
556      }
557
558      @Override
559      public boolean equalsDeep(Base other_) {
560        if (!super.equalsDeep(other_))
561          return false;
562        if (!(other_ instanceof CDSHooksServicesServicesComponent))
563          return false;
564        CDSHooksServicesServicesComponent o = (CDSHooksServicesServicesComponent) other_;
565        return compareDeep(hook, o.hook, true) && compareDeep(title, o.title, true) && compareDeep(id, o.id, true)
566           && compareDeep(description, o.description, true) && compareDeep(usageRequirements, o.usageRequirements, true)
567           && compareDeep(prefetch, o.prefetch, true);
568      }
569
570      @Override
571      public boolean equalsShallow(Base other_) {
572        if (!super.equalsShallow(other_))
573          return false;
574        if (!(other_ instanceof CDSHooksServicesServicesComponent))
575          return false;
576        CDSHooksServicesServicesComponent o = (CDSHooksServicesServicesComponent) other_;
577        return compareValues(hook, o.hook, true) && compareValues(title, o.title, true) && compareValues(id, o.id, true)
578           && compareValues(description, o.description, true) && compareValues(usageRequirements, o.usageRequirements, true)
579          ;
580      }
581
582      public boolean isEmpty() {
583        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(hook, title, id, description
584          , usageRequirements, prefetch);
585      }
586
587  public String fhirType() {
588    return "CDSHooksServices.services";
589
590  }
591
592  }
593
594    @Block()
595    public static class CDSHooksServicesServicesPrefetchComponent extends LogicalBase {
596        /**
597         * Key of FHIR query - name for client to use when sending to Services
598         */
599        @Child(name = "key", type = {CodeType.class}, order=1, min=1, max=1, modifier=false, summary=false)
600        @Description(shortDefinition="Key of FHIR query - name for client to use when sending to Services", formalDefinition="Key of FHIR query - name for client to use when sending to Services" )
601        protected CodeType key;
602
603        /**
604         * Value of FHIR query - FHIR Query for client to perform
605         */
606        @Child(name = "value", type = {StringType.class}, order=2, min=1, max=1, modifier=false, summary=false)
607        @Description(shortDefinition="Value of FHIR query - FHIR Query for client to perform", formalDefinition="Value of FHIR query - FHIR Query for client to perform" )
608        protected StringType value;
609
610        private static final long serialVersionUID = -1496585526L;
611
612    /**
613     * Constructor
614     */
615      public CDSHooksServicesServicesPrefetchComponent() {
616        super();
617      }
618
619    /**
620     * Constructor
621     */
622      public CDSHooksServicesServicesPrefetchComponent(String key, String value) {
623        super();
624        this.setKey(key);
625        this.setValue(value);
626      }
627
628        /**
629         * @return {@link #key} (Key of FHIR query - name for client to use when sending to Services). This is the underlying object with id, value and extensions. The accessor "getKey" gives direct access to the value
630         */
631        public CodeType getKeyElement() { 
632          if (this.key == null)
633            if (Configuration.errorOnAutoCreate())
634              throw new Error("Attempt to auto-create CDSHooksServicesServicesPrefetchComponent.key");
635            else if (Configuration.doAutoCreate())
636              this.key = new CodeType(); // bb
637          return this.key;
638        }
639
640        public boolean hasKeyElement() { 
641          return this.key != null && !this.key.isEmpty();
642        }
643
644        public boolean hasKey() { 
645          return this.key != null && !this.key.isEmpty();
646        }
647
648        /**
649         * @param value {@link #key} (Key of FHIR query - name for client to use when sending to Services). This is the underlying object with id, value and extensions. The accessor "getKey" gives direct access to the value
650         */
651        public CDSHooksServicesServicesPrefetchComponent setKeyElement(CodeType value) { 
652          this.key = value;
653          return this;
654        }
655
656        /**
657         * @return Key of FHIR query - name for client to use when sending to Services
658         */
659        public String getKey() { 
660          return this.key == null ? null : this.key.getValue();
661        }
662
663        /**
664         * @param value Key of FHIR query - name for client to use when sending to Services
665         */
666        public CDSHooksServicesServicesPrefetchComponent setKey(String value) { 
667            if (this.key == null)
668              this.key = new CodeType();
669            this.key.setValue(value);
670          return this;
671        }
672
673        /**
674         * @return {@link #value} (Value of FHIR query - FHIR Query for client to perform). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value
675         */
676        public StringType getValueElement() { 
677          if (this.value == null)
678            if (Configuration.errorOnAutoCreate())
679              throw new Error("Attempt to auto-create CDSHooksServicesServicesPrefetchComponent.value");
680            else if (Configuration.doAutoCreate())
681              this.value = new StringType(); // bb
682          return this.value;
683        }
684
685        public boolean hasValueElement() { 
686          return this.value != null && !this.value.isEmpty();
687        }
688
689        public boolean hasValue() { 
690          return this.value != null && !this.value.isEmpty();
691        }
692
693        /**
694         * @param value {@link #value} (Value of FHIR query - FHIR Query for client to perform). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value
695         */
696        public CDSHooksServicesServicesPrefetchComponent setValueElement(StringType value) { 
697          this.value = value;
698          return this;
699        }
700
701        /**
702         * @return Value of FHIR query - FHIR Query for client to perform
703         */
704        public String getValue() { 
705          return this.value == null ? null : this.value.getValue();
706        }
707
708        /**
709         * @param value Value of FHIR query - FHIR Query for client to perform
710         */
711        public CDSHooksServicesServicesPrefetchComponent setValue(String value) { 
712            if (this.value == null)
713              this.value = new StringType();
714            this.value.setValue(value);
715          return this;
716        }
717
718        protected void listChildren(List<Property> children) {
719          super.listChildren(children);
720          children.add(new Property("key", "code", "Key of FHIR query - name for client to use when sending to Services", 0, 1, key));
721          children.add(new Property("value", "string", "Value of FHIR query - FHIR Query for client to perform", 0, 1, value));
722        }
723
724        @Override
725        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
726          switch (_hash) {
727          case 106079: /*key*/  return new Property("key", "code", "Key of FHIR query - name for client to use when sending to Services", 0, 1, key);
728          case 111972721: /*value*/  return new Property("value", "string", "Value of FHIR query - FHIR Query for client to perform", 0, 1, value);
729          default: return super.getNamedProperty(_hash, _name, _checkValid);
730          }
731
732        }
733
734      @Override
735      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
736        switch (hash) {
737        case 106079: /*key*/ return this.key == null ? new Base[0] : new Base[] {this.key}; // CodeType
738        case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // StringType
739        default: return super.getProperty(hash, name, checkValid);
740        }
741
742      }
743
744      @Override
745      public Base setProperty(int hash, String name, Base value) throws FHIRException {
746        switch (hash) {
747        case 106079: // key
748          this.key = TypeConvertor.castToCode(value); // CodeType
749          return value;
750        case 111972721: // value
751          this.value = TypeConvertor.castToString(value); // StringType
752          return value;
753        default: return super.setProperty(hash, name, value);
754        }
755
756      }
757
758      @Override
759      public Base setProperty(String name, Base value) throws FHIRException {
760        if (name.equals("key")) {
761          this.key = TypeConvertor.castToCode(value); // CodeType
762        } else if (name.equals("value")) {
763          this.value = TypeConvertor.castToString(value); // StringType
764        } else
765          return super.setProperty(name, value);
766        return value;
767      }
768
769      @Override
770      public Base makeProperty(int hash, String name) throws FHIRException {
771        switch (hash) {
772        case 106079:  return getKeyElement();
773        case 111972721:  return getValueElement();
774        default: return super.makeProperty(hash, name);
775        }
776
777      }
778
779      @Override
780      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
781        switch (hash) {
782        case 106079: /*key*/ return new String[] {"code"};
783        case 111972721: /*value*/ return new String[] {"string"};
784        default: return super.getTypesForProperty(hash, name);
785        }
786
787      }
788
789      @Override
790      public Base addChild(String name) throws FHIRException {
791        if (name.equals("key")) {
792          throw new FHIRException("Cannot call addChild on a singleton property CDSHooksServices.services.prefetch.key");
793        }
794        else if (name.equals("value")) {
795          throw new FHIRException("Cannot call addChild on a singleton property CDSHooksServices.services.prefetch.value");
796        }
797        else
798          return super.addChild(name);
799      }
800
801      public CDSHooksServicesServicesPrefetchComponent copy() {
802        CDSHooksServicesServicesPrefetchComponent dst = new CDSHooksServicesServicesPrefetchComponent();
803        copyValues(dst);
804        return dst;
805      }
806
807      public void copyValues(CDSHooksServicesServicesPrefetchComponent dst) {
808        super.copyValues(dst);
809        dst.key = key == null ? null : key.copy();
810        dst.value = value == null ? null : value.copy();
811      }
812
813      @Override
814      public boolean equalsDeep(Base other_) {
815        if (!super.equalsDeep(other_))
816          return false;
817        if (!(other_ instanceof CDSHooksServicesServicesPrefetchComponent))
818          return false;
819        CDSHooksServicesServicesPrefetchComponent o = (CDSHooksServicesServicesPrefetchComponent) other_;
820        return compareDeep(key, o.key, true) && compareDeep(value, o.value, true);
821      }
822
823      @Override
824      public boolean equalsShallow(Base other_) {
825        if (!super.equalsShallow(other_))
826          return false;
827        if (!(other_ instanceof CDSHooksServicesServicesPrefetchComponent))
828          return false;
829        CDSHooksServicesServicesPrefetchComponent o = (CDSHooksServicesServicesPrefetchComponent) other_;
830        return compareValues(key, o.key, true) && compareValues(value, o.value, true);
831      }
832
833      public boolean isEmpty() {
834        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(key, value);
835      }
836
837  public String fhirType() {
838    return "CDSHooksServices.services.prefetch";
839
840  }
841
842  }
843
844    /**
845     * A list of CDS services
846     */
847    @Child(name = "services", type = {CDSHooksElement.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
848    @Description(shortDefinition="A list of CDS services", formalDefinition="A list of CDS services" )
849    protected List<CDSHooksServicesServicesComponent> services;
850
851    private static final long serialVersionUID = 2018821345L;
852
853  /**
854   * Constructor
855   */
856    public CDSHooksServices() {
857      super();
858    }
859
860    /**
861     * @return {@link #services} (A list of CDS services)
862     */
863    public List<CDSHooksServicesServicesComponent> getServices() { 
864      if (this.services == null)
865        this.services = new ArrayList<CDSHooksServicesServicesComponent>();
866      return this.services;
867    }
868
869    /**
870     * @return Returns a reference to <code>this</code> for easy method chaining
871     */
872    public CDSHooksServices setServices(List<CDSHooksServicesServicesComponent> theServices) { 
873      this.services = theServices;
874      return this;
875    }
876
877    public boolean hasServices() { 
878      if (this.services == null)
879        return false;
880      for (CDSHooksServicesServicesComponent item : this.services)
881        if (!item.isEmpty())
882          return true;
883      return false;
884    }
885
886    public CDSHooksServicesServicesComponent addServices() { //3
887      CDSHooksServicesServicesComponent t = new CDSHooksServicesServicesComponent();
888      if (this.services == null)
889        this.services = new ArrayList<CDSHooksServicesServicesComponent>();
890      this.services.add(t);
891      return t;
892    }
893
894    public CDSHooksServices addServices(CDSHooksServicesServicesComponent t) { //3
895      if (t == null)
896        return this;
897      if (this.services == null)
898        this.services = new ArrayList<CDSHooksServicesServicesComponent>();
899      this.services.add(t);
900      return this;
901    }
902
903    /**
904     * @return The first repetition of repeating field {@link #services}, creating it if it does not already exist {3}
905     */
906    public CDSHooksServicesServicesComponent getServicesFirstRep() { 
907      if (getServices().isEmpty()) {
908        addServices();
909      }
910      return getServices().get(0);
911    }
912
913      protected void listChildren(List<Property> children) {
914        super.listChildren(children);
915        children.add(new Property("services", "http://hl7.org/fhir/tools/StructureDefinition/CDSHooksElement", "A list of CDS services", 0, java.lang.Integer.MAX_VALUE, services));
916      }
917
918      @Override
919      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
920        switch (_hash) {
921        case 1379209310: /*services*/  return new Property("services", "http://hl7.org/fhir/tools/StructureDefinition/CDSHooksElement", "A list of CDS services", 0, java.lang.Integer.MAX_VALUE, services);
922        default: return super.getNamedProperty(_hash, _name, _checkValid);
923        }
924
925      }
926
927      @Override
928      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
929        switch (hash) {
930        case 1379209310: /*services*/ return this.services == null ? new Base[0] : this.services.toArray(new Base[this.services.size()]); // CDSHooksServicesServicesComponent
931        default: return super.getProperty(hash, name, checkValid);
932        }
933
934      }
935
936      @Override
937      public Base setProperty(int hash, String name, Base value) throws FHIRException {
938        switch (hash) {
939        case 1379209310: // services
940          this.getServices().add((CDSHooksServicesServicesComponent) value); // CDSHooksServicesServicesComponent
941          return value;
942        default: return super.setProperty(hash, name, value);
943        }
944
945      }
946
947      @Override
948      public Base setProperty(String name, Base value) throws FHIRException {
949        if (name.equals("services")) {
950          this.getServices().add((CDSHooksServicesServicesComponent) value); // CDSHooksServicesServicesComponent
951        } else
952          return super.setProperty(name, value);
953        return value;
954      }
955
956      @Override
957      public Base makeProperty(int hash, String name) throws FHIRException {
958        switch (hash) {
959        case 1379209310:  return addServices(); 
960        default: return super.makeProperty(hash, name);
961        }
962
963      }
964
965      @Override
966      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
967        switch (hash) {
968        case 1379209310: /*services*/ return new String[] {"http://hl7.org/fhir/tools/StructureDefinition/CDSHooksElement"};
969        default: return super.getTypesForProperty(hash, name);
970        }
971
972      }
973
974      @Override
975      public Base addChild(String name) throws FHIRException {
976        if (name.equals("services")) {
977          throw new FHIRException("Cannot call addChild on an abstract type CDSHooksServices.services");
978        }
979        else
980          return super.addChild(name);
981      }
982
983  public String fhirType() {
984    return "CDSHooksServices";
985
986  }
987
988      public CDSHooksServices copy() {
989        CDSHooksServices dst = new CDSHooksServices();
990        copyValues(dst);
991        return dst;
992      }
993
994      public void copyValues(CDSHooksServices dst) {
995        super.copyValues(dst);
996        if (services != null) {
997          dst.services = new ArrayList<CDSHooksServicesServicesComponent>();
998          for (CDSHooksServicesServicesComponent i : services)
999            dst.services.add(i.copy());
1000        };
1001      }
1002
1003      protected CDSHooksServices typedCopy() {
1004        return copy();
1005      }
1006
1007      @Override
1008      public boolean equalsDeep(Base other_) {
1009        if (!super.equalsDeep(other_))
1010          return false;
1011        if (!(other_ instanceof CDSHooksServices))
1012          return false;
1013        CDSHooksServices o = (CDSHooksServices) other_;
1014        return compareDeep(services, o.services, true);
1015      }
1016
1017      @Override
1018      public boolean equalsShallow(Base other_) {
1019        if (!super.equalsShallow(other_))
1020          return false;
1021        if (!(other_ instanceof CDSHooksServices))
1022          return false;
1023        CDSHooksServices o = (CDSHooksServices) other_;
1024        return true;
1025      }
1026
1027      public boolean isEmpty() {
1028        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(services);
1029      }
1030
1031
1032}
1033