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