001package org.hl7.fhir.dstu2016may.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 Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
033import java.util.List;
034
035import org.hl7.fhir.exceptions.FHIRException;
036import org.hl7.fhir.instance.model.api.ICompositeType;
037import org.hl7.fhir.utilities.Utilities;
038
039import ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.DatatypeDef;
041import ca.uhn.fhir.model.api.annotation.Description;
042/**
043 * The parameters to the module. This collection specifies both the input and output parameters. Input parameters are provided by the caller as part of the $evaluate operation. Output parameters are included in the GuidanceResponse.
044 */
045@DatatypeDef(name="ParameterDefinition")
046public class ParameterDefinition extends Type implements ICompositeType {
047
048    /**
049     * The name of the parameter.
050     */
051    @Child(name = "name", type = {CodeType.class}, order=0, min=0, max=1, modifier=false, summary=true)
052    @Description(shortDefinition="Parameter name", formalDefinition="The name of the parameter." )
053    protected CodeType name;
054
055    /**
056     * Whether the parameter is input or output for the module.
057     */
058    @Child(name = "use", type = {CodeType.class}, order=1, min=1, max=1, modifier=false, summary=true)
059    @Description(shortDefinition="", formalDefinition="Whether the parameter is input or output for the module." )
060    protected CodeType use;
061
062    /**
063     * The minimum number of times this parameter SHALL appear in the request or response.
064     */
065    @Child(name = "min", type = {IntegerType.class}, order=2, min=0, max=1, modifier=false, summary=true)
066    @Description(shortDefinition="Minimum cardinality", formalDefinition="The minimum number of times this parameter SHALL appear in the request or response." )
067    protected IntegerType min;
068
069    /**
070     * The maximum number of times this element is permitted to appear in the request or response.
071     */
072    @Child(name = "max", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=true)
073    @Description(shortDefinition="Maximum cardinality (a number of *)", formalDefinition="The maximum number of times this element is permitted to appear in the request or response." )
074    protected StringType max;
075
076    /**
077     * A brief discussion of what the parameter is for and how it is used by the module.
078     */
079    @Child(name = "documentation", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=true)
080    @Description(shortDefinition="A brief description of the parameter", formalDefinition="A brief discussion of what the parameter is for and how it is used by the module." )
081    protected StringType documentation;
082
083    /**
084     * The type of the parameter.
085     */
086    @Child(name = "type", type = {CodeType.class}, order=5, min=1, max=1, modifier=false, summary=true)
087    @Description(shortDefinition="", formalDefinition="The type of the parameter." )
088    protected CodeType type;
089
090    /**
091     * If specified, this indicates a profile that the input data must conform to, or that the output data will conform to.
092     */
093    @Child(name = "profile", type = {StructureDefinition.class}, order=6, min=0, max=1, modifier=false, summary=true)
094    @Description(shortDefinition="The profile of the parameter, any", formalDefinition="If specified, this indicates a profile that the input data must conform to, or that the output data will conform to." )
095    protected Reference profile;
096
097    /**
098     * The actual object that is the target of the reference (If specified, this indicates a profile that the input data must conform to, or that the output data will conform to.)
099     */
100    protected StructureDefinition profileTarget;
101
102    private static final long serialVersionUID = -1284894445L;
103
104  /**
105   * Constructor
106   */
107    public ParameterDefinition() {
108      super();
109    }
110
111  /**
112   * Constructor
113   */
114    public ParameterDefinition(CodeType use, CodeType type) {
115      super();
116      this.use = use;
117      this.type = type;
118    }
119
120    /**
121     * @return {@link #name} (The name of the parameter.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
122     */
123    public CodeType getNameElement() { 
124      if (this.name == null)
125        if (Configuration.errorOnAutoCreate())
126          throw new Error("Attempt to auto-create ParameterDefinition.name");
127        else if (Configuration.doAutoCreate())
128          this.name = new CodeType(); // bb
129      return this.name;
130    }
131
132    public boolean hasNameElement() { 
133      return this.name != null && !this.name.isEmpty();
134    }
135
136    public boolean hasName() { 
137      return this.name != null && !this.name.isEmpty();
138    }
139
140    /**
141     * @param value {@link #name} (The name of the parameter.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
142     */
143    public ParameterDefinition setNameElement(CodeType value) { 
144      this.name = value;
145      return this;
146    }
147
148    /**
149     * @return The name of the parameter.
150     */
151    public String getName() { 
152      return this.name == null ? null : this.name.getValue();
153    }
154
155    /**
156     * @param value The name of the parameter.
157     */
158    public ParameterDefinition setName(String value) { 
159      if (Utilities.noString(value))
160        this.name = null;
161      else {
162        if (this.name == null)
163          this.name = new CodeType();
164        this.name.setValue(value);
165      }
166      return this;
167    }
168
169    /**
170     * @return {@link #use} (Whether the parameter is input or output for the module.). This is the underlying object with id, value and extensions. The accessor "getUse" gives direct access to the value
171     */
172    public CodeType getUseElement() { 
173      if (this.use == null)
174        if (Configuration.errorOnAutoCreate())
175          throw new Error("Attempt to auto-create ParameterDefinition.use");
176        else if (Configuration.doAutoCreate())
177          this.use = new CodeType(); // bb
178      return this.use;
179    }
180
181    public boolean hasUseElement() { 
182      return this.use != null && !this.use.isEmpty();
183    }
184
185    public boolean hasUse() { 
186      return this.use != null && !this.use.isEmpty();
187    }
188
189    /**
190     * @param value {@link #use} (Whether the parameter is input or output for the module.). This is the underlying object with id, value and extensions. The accessor "getUse" gives direct access to the value
191     */
192    public ParameterDefinition setUseElement(CodeType value) { 
193      this.use = value;
194      return this;
195    }
196
197    /**
198     * @return Whether the parameter is input or output for the module.
199     */
200    public String getUse() { 
201      return this.use == null ? null : this.use.getValue();
202    }
203
204    /**
205     * @param value Whether the parameter is input or output for the module.
206     */
207    public ParameterDefinition setUse(String value) { 
208        if (this.use == null)
209          this.use = new CodeType();
210        this.use.setValue(value);
211      return this;
212    }
213
214    /**
215     * @return {@link #min} (The minimum number of times this parameter SHALL appear in the request or response.). This is the underlying object with id, value and extensions. The accessor "getMin" gives direct access to the value
216     */
217    public IntegerType getMinElement() { 
218      if (this.min == null)
219        if (Configuration.errorOnAutoCreate())
220          throw new Error("Attempt to auto-create ParameterDefinition.min");
221        else if (Configuration.doAutoCreate())
222          this.min = new IntegerType(); // bb
223      return this.min;
224    }
225
226    public boolean hasMinElement() { 
227      return this.min != null && !this.min.isEmpty();
228    }
229
230    public boolean hasMin() { 
231      return this.min != null && !this.min.isEmpty();
232    }
233
234    /**
235     * @param value {@link #min} (The minimum number of times this parameter SHALL appear in the request or response.). This is the underlying object with id, value and extensions. The accessor "getMin" gives direct access to the value
236     */
237    public ParameterDefinition setMinElement(IntegerType value) { 
238      this.min = value;
239      return this;
240    }
241
242    /**
243     * @return The minimum number of times this parameter SHALL appear in the request or response.
244     */
245    public int getMin() { 
246      return this.min == null || this.min.isEmpty() ? 0 : this.min.getValue();
247    }
248
249    /**
250     * @param value The minimum number of times this parameter SHALL appear in the request or response.
251     */
252    public ParameterDefinition setMin(int value) { 
253        if (this.min == null)
254          this.min = new IntegerType();
255        this.min.setValue(value);
256      return this;
257    }
258
259    /**
260     * @return {@link #max} (The maximum number of times this element is permitted to appear in the request or response.). This is the underlying object with id, value and extensions. The accessor "getMax" gives direct access to the value
261     */
262    public StringType getMaxElement() { 
263      if (this.max == null)
264        if (Configuration.errorOnAutoCreate())
265          throw new Error("Attempt to auto-create ParameterDefinition.max");
266        else if (Configuration.doAutoCreate())
267          this.max = new StringType(); // bb
268      return this.max;
269    }
270
271    public boolean hasMaxElement() { 
272      return this.max != null && !this.max.isEmpty();
273    }
274
275    public boolean hasMax() { 
276      return this.max != null && !this.max.isEmpty();
277    }
278
279    /**
280     * @param value {@link #max} (The maximum number of times this element is permitted to appear in the request or response.). This is the underlying object with id, value and extensions. The accessor "getMax" gives direct access to the value
281     */
282    public ParameterDefinition setMaxElement(StringType value) { 
283      this.max = value;
284      return this;
285    }
286
287    /**
288     * @return The maximum number of times this element is permitted to appear in the request or response.
289     */
290    public String getMax() { 
291      return this.max == null ? null : this.max.getValue();
292    }
293
294    /**
295     * @param value The maximum number of times this element is permitted to appear in the request or response.
296     */
297    public ParameterDefinition setMax(String value) { 
298      if (Utilities.noString(value))
299        this.max = null;
300      else {
301        if (this.max == null)
302          this.max = new StringType();
303        this.max.setValue(value);
304      }
305      return this;
306    }
307
308    /**
309     * @return {@link #documentation} (A brief discussion of what the parameter is for and how it is used by the module.). This is the underlying object with id, value and extensions. The accessor "getDocumentation" gives direct access to the value
310     */
311    public StringType getDocumentationElement() { 
312      if (this.documentation == null)
313        if (Configuration.errorOnAutoCreate())
314          throw new Error("Attempt to auto-create ParameterDefinition.documentation");
315        else if (Configuration.doAutoCreate())
316          this.documentation = new StringType(); // bb
317      return this.documentation;
318    }
319
320    public boolean hasDocumentationElement() { 
321      return this.documentation != null && !this.documentation.isEmpty();
322    }
323
324    public boolean hasDocumentation() { 
325      return this.documentation != null && !this.documentation.isEmpty();
326    }
327
328    /**
329     * @param value {@link #documentation} (A brief discussion of what the parameter is for and how it is used by the module.). This is the underlying object with id, value and extensions. The accessor "getDocumentation" gives direct access to the value
330     */
331    public ParameterDefinition setDocumentationElement(StringType value) { 
332      this.documentation = value;
333      return this;
334    }
335
336    /**
337     * @return A brief discussion of what the parameter is for and how it is used by the module.
338     */
339    public String getDocumentation() { 
340      return this.documentation == null ? null : this.documentation.getValue();
341    }
342
343    /**
344     * @param value A brief discussion of what the parameter is for and how it is used by the module.
345     */
346    public ParameterDefinition setDocumentation(String value) { 
347      if (Utilities.noString(value))
348        this.documentation = null;
349      else {
350        if (this.documentation == null)
351          this.documentation = new StringType();
352        this.documentation.setValue(value);
353      }
354      return this;
355    }
356
357    /**
358     * @return {@link #type} (The type of the parameter.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
359     */
360    public CodeType getTypeElement() { 
361      if (this.type == null)
362        if (Configuration.errorOnAutoCreate())
363          throw new Error("Attempt to auto-create ParameterDefinition.type");
364        else if (Configuration.doAutoCreate())
365          this.type = new CodeType(); // bb
366      return this.type;
367    }
368
369    public boolean hasTypeElement() { 
370      return this.type != null && !this.type.isEmpty();
371    }
372
373    public boolean hasType() { 
374      return this.type != null && !this.type.isEmpty();
375    }
376
377    /**
378     * @param value {@link #type} (The type of the parameter.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
379     */
380    public ParameterDefinition setTypeElement(CodeType value) { 
381      this.type = value;
382      return this;
383    }
384
385    /**
386     * @return The type of the parameter.
387     */
388    public String getType() { 
389      return this.type == null ? null : this.type.getValue();
390    }
391
392    /**
393     * @param value The type of the parameter.
394     */
395    public ParameterDefinition setType(String value) { 
396        if (this.type == null)
397          this.type = new CodeType();
398        this.type.setValue(value);
399      return this;
400    }
401
402    /**
403     * @return {@link #profile} (If specified, this indicates a profile that the input data must conform to, or that the output data will conform to.)
404     */
405    public Reference getProfile() { 
406      if (this.profile == null)
407        if (Configuration.errorOnAutoCreate())
408          throw new Error("Attempt to auto-create ParameterDefinition.profile");
409        else if (Configuration.doAutoCreate())
410          this.profile = new Reference(); // cc
411      return this.profile;
412    }
413
414    public boolean hasProfile() { 
415      return this.profile != null && !this.profile.isEmpty();
416    }
417
418    /**
419     * @param value {@link #profile} (If specified, this indicates a profile that the input data must conform to, or that the output data will conform to.)
420     */
421    public ParameterDefinition setProfile(Reference value) { 
422      this.profile = value;
423      return this;
424    }
425
426    /**
427     * @return {@link #profile} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (If specified, this indicates a profile that the input data must conform to, or that the output data will conform to.)
428     */
429    public StructureDefinition getProfileTarget() { 
430      if (this.profileTarget == null)
431        if (Configuration.errorOnAutoCreate())
432          throw new Error("Attempt to auto-create ParameterDefinition.profile");
433        else if (Configuration.doAutoCreate())
434          this.profileTarget = new StructureDefinition(); // aa
435      return this.profileTarget;
436    }
437
438    /**
439     * @param value {@link #profile} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (If specified, this indicates a profile that the input data must conform to, or that the output data will conform to.)
440     */
441    public ParameterDefinition setProfileTarget(StructureDefinition value) { 
442      this.profileTarget = value;
443      return this;
444    }
445
446      protected void listChildren(List<Property> childrenList) {
447        super.listChildren(childrenList);
448        childrenList.add(new Property("name", "code", "The name of the parameter.", 0, java.lang.Integer.MAX_VALUE, name));
449        childrenList.add(new Property("use", "code", "Whether the parameter is input or output for the module.", 0, java.lang.Integer.MAX_VALUE, use));
450        childrenList.add(new Property("min", "integer", "The minimum number of times this parameter SHALL appear in the request or response.", 0, java.lang.Integer.MAX_VALUE, min));
451        childrenList.add(new Property("max", "string", "The maximum number of times this element is permitted to appear in the request or response.", 0, java.lang.Integer.MAX_VALUE, max));
452        childrenList.add(new Property("documentation", "string", "A brief discussion of what the parameter is for and how it is used by the module.", 0, java.lang.Integer.MAX_VALUE, documentation));
453        childrenList.add(new Property("type", "code", "The type of the parameter.", 0, java.lang.Integer.MAX_VALUE, type));
454        childrenList.add(new Property("profile", "Reference(StructureDefinition)", "If specified, this indicates a profile that the input data must conform to, or that the output data will conform to.", 0, java.lang.Integer.MAX_VALUE, profile));
455      }
456
457      @Override
458      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
459        switch (hash) {
460        case 3373707: /*name*/ return this.name == null ? new Base[0] : new Base[] {this.name}; // CodeType
461        case 116103: /*use*/ return this.use == null ? new Base[0] : new Base[] {this.use}; // CodeType
462        case 108114: /*min*/ return this.min == null ? new Base[0] : new Base[] {this.min}; // IntegerType
463        case 107876: /*max*/ return this.max == null ? new Base[0] : new Base[] {this.max}; // StringType
464        case 1587405498: /*documentation*/ return this.documentation == null ? new Base[0] : new Base[] {this.documentation}; // StringType
465        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeType
466        case -309425751: /*profile*/ return this.profile == null ? new Base[0] : new Base[] {this.profile}; // Reference
467        default: return super.getProperty(hash, name, checkValid);
468        }
469
470      }
471
472      @Override
473      public void setProperty(int hash, String name, Base value) throws FHIRException {
474        switch (hash) {
475        case 3373707: // name
476          this.name = castToCode(value); // CodeType
477          break;
478        case 116103: // use
479          this.use = castToCode(value); // CodeType
480          break;
481        case 108114: // min
482          this.min = castToInteger(value); // IntegerType
483          break;
484        case 107876: // max
485          this.max = castToString(value); // StringType
486          break;
487        case 1587405498: // documentation
488          this.documentation = castToString(value); // StringType
489          break;
490        case 3575610: // type
491          this.type = castToCode(value); // CodeType
492          break;
493        case -309425751: // profile
494          this.profile = castToReference(value); // Reference
495          break;
496        default: super.setProperty(hash, name, value);
497        }
498
499      }
500
501      @Override
502      public void setProperty(String name, Base value) throws FHIRException {
503        if (name.equals("name"))
504          this.name = castToCode(value); // CodeType
505        else if (name.equals("use"))
506          this.use = castToCode(value); // CodeType
507        else if (name.equals("min"))
508          this.min = castToInteger(value); // IntegerType
509        else if (name.equals("max"))
510          this.max = castToString(value); // StringType
511        else if (name.equals("documentation"))
512          this.documentation = castToString(value); // StringType
513        else if (name.equals("type"))
514          this.type = castToCode(value); // CodeType
515        else if (name.equals("profile"))
516          this.profile = castToReference(value); // Reference
517        else
518          super.setProperty(name, value);
519      }
520
521      @Override
522      public Base makeProperty(int hash, String name) throws FHIRException {
523        switch (hash) {
524        case 3373707: throw new FHIRException("Cannot make property name as it is not a complex type"); // CodeType
525        case 116103: throw new FHIRException("Cannot make property use as it is not a complex type"); // CodeType
526        case 108114: throw new FHIRException("Cannot make property min as it is not a complex type"); // IntegerType
527        case 107876: throw new FHIRException("Cannot make property max as it is not a complex type"); // StringType
528        case 1587405498: throw new FHIRException("Cannot make property documentation as it is not a complex type"); // StringType
529        case 3575610: throw new FHIRException("Cannot make property type as it is not a complex type"); // CodeType
530        case -309425751:  return getProfile(); // Reference
531        default: return super.makeProperty(hash, name);
532        }
533
534      }
535
536      @Override
537      public Base addChild(String name) throws FHIRException {
538        if (name.equals("name")) {
539          throw new FHIRException("Cannot call addChild on a primitive type ParameterDefinition.name");
540        }
541        else if (name.equals("use")) {
542          throw new FHIRException("Cannot call addChild on a primitive type ParameterDefinition.use");
543        }
544        else if (name.equals("min")) {
545          throw new FHIRException("Cannot call addChild on a primitive type ParameterDefinition.min");
546        }
547        else if (name.equals("max")) {
548          throw new FHIRException("Cannot call addChild on a primitive type ParameterDefinition.max");
549        }
550        else if (name.equals("documentation")) {
551          throw new FHIRException("Cannot call addChild on a primitive type ParameterDefinition.documentation");
552        }
553        else if (name.equals("type")) {
554          throw new FHIRException("Cannot call addChild on a primitive type ParameterDefinition.type");
555        }
556        else if (name.equals("profile")) {
557          this.profile = new Reference();
558          return this.profile;
559        }
560        else
561          return super.addChild(name);
562      }
563
564  public String fhirType() {
565    return "ParameterDefinition";
566
567  }
568
569      public ParameterDefinition copy() {
570        ParameterDefinition dst = new ParameterDefinition();
571        copyValues(dst);
572        dst.name = name == null ? null : name.copy();
573        dst.use = use == null ? null : use.copy();
574        dst.min = min == null ? null : min.copy();
575        dst.max = max == null ? null : max.copy();
576        dst.documentation = documentation == null ? null : documentation.copy();
577        dst.type = type == null ? null : type.copy();
578        dst.profile = profile == null ? null : profile.copy();
579        return dst;
580      }
581
582      protected ParameterDefinition typedCopy() {
583        return copy();
584      }
585
586      @Override
587      public boolean equalsDeep(Base other) {
588        if (!super.equalsDeep(other))
589          return false;
590        if (!(other instanceof ParameterDefinition))
591          return false;
592        ParameterDefinition o = (ParameterDefinition) other;
593        return compareDeep(name, o.name, true) && compareDeep(use, o.use, true) && compareDeep(min, o.min, true)
594           && compareDeep(max, o.max, true) && compareDeep(documentation, o.documentation, true) && compareDeep(type, o.type, true)
595           && compareDeep(profile, o.profile, true);
596      }
597
598      @Override
599      public boolean equalsShallow(Base other) {
600        if (!super.equalsShallow(other))
601          return false;
602        if (!(other instanceof ParameterDefinition))
603          return false;
604        ParameterDefinition o = (ParameterDefinition) other;
605        return compareValues(name, o.name, true) && compareValues(use, o.use, true) && compareValues(min, o.min, true)
606           && compareValues(max, o.max, true) && compareValues(documentation, o.documentation, true) && compareValues(type, o.type, true)
607          ;
608      }
609
610      public boolean isEmpty() {
611        return super.isEmpty() && (name == null || name.isEmpty()) && (use == null || use.isEmpty())
612           && (min == null || min.isEmpty()) && (max == null || max.isEmpty()) && (documentation == null || documentation.isEmpty())
613           && (type == null || type.isEmpty()) && (profile == null || profile.isEmpty());
614      }
615
616
617}
618