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.ArrayList;
034import java.util.Date;
035import java.util.List;
036
037import org.hl7.fhir.exceptions.FHIRException;
038import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
039import org.hl7.fhir.utilities.Utilities;
040
041import ca.uhn.fhir.model.api.annotation.Block;
042import ca.uhn.fhir.model.api.annotation.Child;
043import ca.uhn.fhir.model.api.annotation.Description;
044import ca.uhn.fhir.model.api.annotation.ResourceDef;
045import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
046/**
047 * A structured set of questions intended to guide the collection of answers. The questions are ordered and grouped into coherent subsets, corresponding to the structure of the grouping of the underlying questions.
048 */
049@ResourceDef(name="Questionnaire", profile="http://hl7.org/fhir/Profile/Questionnaire")
050public class Questionnaire extends DomainResource {
051
052    public enum QuestionnaireStatus {
053        /**
054         * This Questionnaire is not ready for official use.
055         */
056        DRAFT, 
057        /**
058         * This Questionnaire is ready for use.
059         */
060        PUBLISHED, 
061        /**
062         * This Questionnaire should no longer be used to gather data.
063         */
064        RETIRED, 
065        /**
066         * added to help the parsers
067         */
068        NULL;
069        public static QuestionnaireStatus fromCode(String codeString) throws FHIRException {
070            if (codeString == null || "".equals(codeString))
071                return null;
072        if ("draft".equals(codeString))
073          return DRAFT;
074        if ("published".equals(codeString))
075          return PUBLISHED;
076        if ("retired".equals(codeString))
077          return RETIRED;
078        throw new FHIRException("Unknown QuestionnaireStatus code '"+codeString+"'");
079        }
080        public String toCode() {
081          switch (this) {
082            case DRAFT: return "draft";
083            case PUBLISHED: return "published";
084            case RETIRED: return "retired";
085            default: return "?";
086          }
087        }
088        public String getSystem() {
089          switch (this) {
090            case DRAFT: return "http://hl7.org/fhir/questionnaire-status";
091            case PUBLISHED: return "http://hl7.org/fhir/questionnaire-status";
092            case RETIRED: return "http://hl7.org/fhir/questionnaire-status";
093            default: return "?";
094          }
095        }
096        public String getDefinition() {
097          switch (this) {
098            case DRAFT: return "This Questionnaire is not ready for official use.";
099            case PUBLISHED: return "This Questionnaire is ready for use.";
100            case RETIRED: return "This Questionnaire should no longer be used to gather data.";
101            default: return "?";
102          }
103        }
104        public String getDisplay() {
105          switch (this) {
106            case DRAFT: return "Draft";
107            case PUBLISHED: return "Published";
108            case RETIRED: return "Retired";
109            default: return "?";
110          }
111        }
112    }
113
114  public static class QuestionnaireStatusEnumFactory implements EnumFactory<QuestionnaireStatus> {
115    public QuestionnaireStatus fromCode(String codeString) throws IllegalArgumentException {
116      if (codeString == null || "".equals(codeString))
117            if (codeString == null || "".equals(codeString))
118                return null;
119        if ("draft".equals(codeString))
120          return QuestionnaireStatus.DRAFT;
121        if ("published".equals(codeString))
122          return QuestionnaireStatus.PUBLISHED;
123        if ("retired".equals(codeString))
124          return QuestionnaireStatus.RETIRED;
125        throw new IllegalArgumentException("Unknown QuestionnaireStatus code '"+codeString+"'");
126        }
127        public Enumeration<QuestionnaireStatus> fromType(Base code) throws FHIRException {
128          if (code == null || code.isEmpty())
129            return null;
130          String codeString = ((PrimitiveType) code).asStringValue();
131          if (codeString == null || "".equals(codeString))
132            return null;
133        if ("draft".equals(codeString))
134          return new Enumeration<QuestionnaireStatus>(this, QuestionnaireStatus.DRAFT);
135        if ("published".equals(codeString))
136          return new Enumeration<QuestionnaireStatus>(this, QuestionnaireStatus.PUBLISHED);
137        if ("retired".equals(codeString))
138          return new Enumeration<QuestionnaireStatus>(this, QuestionnaireStatus.RETIRED);
139        throw new FHIRException("Unknown QuestionnaireStatus code '"+codeString+"'");
140        }
141    public String toCode(QuestionnaireStatus code) {
142      if (code == QuestionnaireStatus.DRAFT)
143        return "draft";
144      if (code == QuestionnaireStatus.PUBLISHED)
145        return "published";
146      if (code == QuestionnaireStatus.RETIRED)
147        return "retired";
148      return "?";
149      }
150    public String toSystem(QuestionnaireStatus code) {
151      return code.getSystem();
152      }
153    }
154
155    public enum QuestionnaireItemType {
156        /**
157         * An item with no direct answer but which has descendant items that are questions
158         */
159        GROUP, 
160        /**
161         * Text for display that will not capture an answer or have descendants
162         */
163        DISPLAY, 
164        /**
165         * An item that defines a specific answer to be captured (and may have descendant items)
166         */
167        QUESTION, 
168        /**
169         * Question with a yes/no answer
170         */
171        BOOLEAN, 
172        /**
173         * Question with is a real number answer
174         */
175        DECIMAL, 
176        /**
177         * Question with an integer answer
178         */
179        INTEGER, 
180        /**
181         * Question with adate answer
182         */
183        DATE, 
184        /**
185         * Question with a date and time answer
186         */
187        DATETIME, 
188        /**
189         * Question with a system timestamp answer
190         */
191        INSTANT, 
192        /**
193         * Question with a time (hour/minute/second) answer independent of date.
194         */
195        TIME, 
196        /**
197         * Question with a short (few words to short sentence) free-text entry answer
198         */
199        STRING, 
200        /**
201         * Question with a long (potentially multi-paragraph) free-text entry (still captured as a string) answer
202         */
203        TEXT, 
204        /**
205         * Question with a url (website, FTP site, etc.) answer
206         */
207        URL, 
208        /**
209         * Question with a Coding drawn from a list of options as an answer
210         */
211        CHOICE, 
212        /**
213         * Answer is a Coding drawn from a list of options or a free-text entry captured as Coding.display
214         */
215        OPENCHOICE, 
216        /**
217         * Question with binary content such as a image, PDF, etc. as an answer
218         */
219        ATTACHMENT, 
220        /**
221         * Question with a reference to another resource (practitioner, organization, etc.) as an answer
222         */
223        REFERENCE, 
224        /**
225         * Question with a combination of a numeric value and unit, potentially with a comparator (<, >, etc.) as an answer.
226         */
227        QUANTITY, 
228        /**
229         * added to help the parsers
230         */
231        NULL;
232        public static QuestionnaireItemType fromCode(String codeString) throws FHIRException {
233            if (codeString == null || "".equals(codeString))
234                return null;
235        if ("group".equals(codeString))
236          return GROUP;
237        if ("display".equals(codeString))
238          return DISPLAY;
239        if ("question".equals(codeString))
240          return QUESTION;
241        if ("boolean".equals(codeString))
242          return BOOLEAN;
243        if ("decimal".equals(codeString))
244          return DECIMAL;
245        if ("integer".equals(codeString))
246          return INTEGER;
247        if ("date".equals(codeString))
248          return DATE;
249        if ("dateTime".equals(codeString))
250          return DATETIME;
251        if ("instant".equals(codeString))
252          return INSTANT;
253        if ("time".equals(codeString))
254          return TIME;
255        if ("string".equals(codeString))
256          return STRING;
257        if ("text".equals(codeString))
258          return TEXT;
259        if ("url".equals(codeString))
260          return URL;
261        if ("choice".equals(codeString))
262          return CHOICE;
263        if ("open-choice".equals(codeString))
264          return OPENCHOICE;
265        if ("attachment".equals(codeString))
266          return ATTACHMENT;
267        if ("reference".equals(codeString))
268          return REFERENCE;
269        if ("quantity".equals(codeString))
270          return QUANTITY;
271        throw new FHIRException("Unknown QuestionnaireItemType code '"+codeString+"'");
272        }
273        public String toCode() {
274          switch (this) {
275            case GROUP: return "group";
276            case DISPLAY: return "display";
277            case QUESTION: return "question";
278            case BOOLEAN: return "boolean";
279            case DECIMAL: return "decimal";
280            case INTEGER: return "integer";
281            case DATE: return "date";
282            case DATETIME: return "dateTime";
283            case INSTANT: return "instant";
284            case TIME: return "time";
285            case STRING: return "string";
286            case TEXT: return "text";
287            case URL: return "url";
288            case CHOICE: return "choice";
289            case OPENCHOICE: return "open-choice";
290            case ATTACHMENT: return "attachment";
291            case REFERENCE: return "reference";
292            case QUANTITY: return "quantity";
293            default: return "?";
294          }
295        }
296        public String getSystem() {
297          switch (this) {
298            case GROUP: return "http://hl7.org/fhir/item-type";
299            case DISPLAY: return "http://hl7.org/fhir/item-type";
300            case QUESTION: return "http://hl7.org/fhir/item-type";
301            case BOOLEAN: return "http://hl7.org/fhir/item-type";
302            case DECIMAL: return "http://hl7.org/fhir/item-type";
303            case INTEGER: return "http://hl7.org/fhir/item-type";
304            case DATE: return "http://hl7.org/fhir/item-type";
305            case DATETIME: return "http://hl7.org/fhir/item-type";
306            case INSTANT: return "http://hl7.org/fhir/item-type";
307            case TIME: return "http://hl7.org/fhir/item-type";
308            case STRING: return "http://hl7.org/fhir/item-type";
309            case TEXT: return "http://hl7.org/fhir/item-type";
310            case URL: return "http://hl7.org/fhir/item-type";
311            case CHOICE: return "http://hl7.org/fhir/item-type";
312            case OPENCHOICE: return "http://hl7.org/fhir/item-type";
313            case ATTACHMENT: return "http://hl7.org/fhir/item-type";
314            case REFERENCE: return "http://hl7.org/fhir/item-type";
315            case QUANTITY: return "http://hl7.org/fhir/item-type";
316            default: return "?";
317          }
318        }
319        public String getDefinition() {
320          switch (this) {
321            case GROUP: return "An item with no direct answer but which has descendant items that are questions";
322            case DISPLAY: return "Text for display that will not capture an answer or have descendants";
323            case QUESTION: return "An item that defines a specific answer to be captured (and may have descendant items)";
324            case BOOLEAN: return "Question with a yes/no answer";
325            case DECIMAL: return "Question with is a real number answer";
326            case INTEGER: return "Question with an integer answer";
327            case DATE: return "Question with adate answer";
328            case DATETIME: return "Question with a date and time answer";
329            case INSTANT: return "Question with a system timestamp answer";
330            case TIME: return "Question with a time (hour/minute/second) answer independent of date.";
331            case STRING: return "Question with a short (few words to short sentence) free-text entry answer";
332            case TEXT: return "Question with a long (potentially multi-paragraph) free-text entry (still captured as a string) answer";
333            case URL: return "Question with a url (website, FTP site, etc.) answer";
334            case CHOICE: return "Question with a Coding drawn from a list of options as an answer";
335            case OPENCHOICE: return "Answer is a Coding drawn from a list of options or a free-text entry captured as Coding.display";
336            case ATTACHMENT: return "Question with binary content such as a image, PDF, etc. as an answer";
337            case REFERENCE: return "Question with a reference to another resource (practitioner, organization, etc.) as an answer";
338            case QUANTITY: return "Question with a combination of a numeric value and unit, potentially with a comparator (<, >, etc.) as an answer.";
339            default: return "?";
340          }
341        }
342        public String getDisplay() {
343          switch (this) {
344            case GROUP: return "Group";
345            case DISPLAY: return "Display";
346            case QUESTION: return "Question";
347            case BOOLEAN: return "Boolean";
348            case DECIMAL: return "Decimal";
349            case INTEGER: return "Integer";
350            case DATE: return "Date";
351            case DATETIME: return "Date Time";
352            case INSTANT: return "Instant";
353            case TIME: return "Time";
354            case STRING: return "String";
355            case TEXT: return "Text";
356            case URL: return "Url";
357            case CHOICE: return "Choice";
358            case OPENCHOICE: return "Open Choice";
359            case ATTACHMENT: return "Attachment";
360            case REFERENCE: return "Reference";
361            case QUANTITY: return "Quantity";
362            default: return "?";
363          }
364        }
365    }
366
367  public static class QuestionnaireItemTypeEnumFactory implements EnumFactory<QuestionnaireItemType> {
368    public QuestionnaireItemType fromCode(String codeString) throws IllegalArgumentException {
369      if (codeString == null || "".equals(codeString))
370            if (codeString == null || "".equals(codeString))
371                return null;
372        if ("group".equals(codeString))
373          return QuestionnaireItemType.GROUP;
374        if ("display".equals(codeString))
375          return QuestionnaireItemType.DISPLAY;
376        if ("question".equals(codeString))
377          return QuestionnaireItemType.QUESTION;
378        if ("boolean".equals(codeString))
379          return QuestionnaireItemType.BOOLEAN;
380        if ("decimal".equals(codeString))
381          return QuestionnaireItemType.DECIMAL;
382        if ("integer".equals(codeString))
383          return QuestionnaireItemType.INTEGER;
384        if ("date".equals(codeString))
385          return QuestionnaireItemType.DATE;
386        if ("dateTime".equals(codeString))
387          return QuestionnaireItemType.DATETIME;
388        if ("instant".equals(codeString))
389          return QuestionnaireItemType.INSTANT;
390        if ("time".equals(codeString))
391          return QuestionnaireItemType.TIME;
392        if ("string".equals(codeString))
393          return QuestionnaireItemType.STRING;
394        if ("text".equals(codeString))
395          return QuestionnaireItemType.TEXT;
396        if ("url".equals(codeString))
397          return QuestionnaireItemType.URL;
398        if ("choice".equals(codeString))
399          return QuestionnaireItemType.CHOICE;
400        if ("open-choice".equals(codeString))
401          return QuestionnaireItemType.OPENCHOICE;
402        if ("attachment".equals(codeString))
403          return QuestionnaireItemType.ATTACHMENT;
404        if ("reference".equals(codeString))
405          return QuestionnaireItemType.REFERENCE;
406        if ("quantity".equals(codeString))
407          return QuestionnaireItemType.QUANTITY;
408        throw new IllegalArgumentException("Unknown QuestionnaireItemType code '"+codeString+"'");
409        }
410        public Enumeration<QuestionnaireItemType> fromType(Base code) throws FHIRException {
411          if (code == null || code.isEmpty())
412            return null;
413          String codeString = ((PrimitiveType) code).asStringValue();
414          if (codeString == null || "".equals(codeString))
415            return null;
416        if ("group".equals(codeString))
417          return new Enumeration<QuestionnaireItemType>(this, QuestionnaireItemType.GROUP);
418        if ("display".equals(codeString))
419          return new Enumeration<QuestionnaireItemType>(this, QuestionnaireItemType.DISPLAY);
420        if ("question".equals(codeString))
421          return new Enumeration<QuestionnaireItemType>(this, QuestionnaireItemType.QUESTION);
422        if ("boolean".equals(codeString))
423          return new Enumeration<QuestionnaireItemType>(this, QuestionnaireItemType.BOOLEAN);
424        if ("decimal".equals(codeString))
425          return new Enumeration<QuestionnaireItemType>(this, QuestionnaireItemType.DECIMAL);
426        if ("integer".equals(codeString))
427          return new Enumeration<QuestionnaireItemType>(this, QuestionnaireItemType.INTEGER);
428        if ("date".equals(codeString))
429          return new Enumeration<QuestionnaireItemType>(this, QuestionnaireItemType.DATE);
430        if ("dateTime".equals(codeString))
431          return new Enumeration<QuestionnaireItemType>(this, QuestionnaireItemType.DATETIME);
432        if ("instant".equals(codeString))
433          return new Enumeration<QuestionnaireItemType>(this, QuestionnaireItemType.INSTANT);
434        if ("time".equals(codeString))
435          return new Enumeration<QuestionnaireItemType>(this, QuestionnaireItemType.TIME);
436        if ("string".equals(codeString))
437          return new Enumeration<QuestionnaireItemType>(this, QuestionnaireItemType.STRING);
438        if ("text".equals(codeString))
439          return new Enumeration<QuestionnaireItemType>(this, QuestionnaireItemType.TEXT);
440        if ("url".equals(codeString))
441          return new Enumeration<QuestionnaireItemType>(this, QuestionnaireItemType.URL);
442        if ("choice".equals(codeString))
443          return new Enumeration<QuestionnaireItemType>(this, QuestionnaireItemType.CHOICE);
444        if ("open-choice".equals(codeString))
445          return new Enumeration<QuestionnaireItemType>(this, QuestionnaireItemType.OPENCHOICE);
446        if ("attachment".equals(codeString))
447          return new Enumeration<QuestionnaireItemType>(this, QuestionnaireItemType.ATTACHMENT);
448        if ("reference".equals(codeString))
449          return new Enumeration<QuestionnaireItemType>(this, QuestionnaireItemType.REFERENCE);
450        if ("quantity".equals(codeString))
451          return new Enumeration<QuestionnaireItemType>(this, QuestionnaireItemType.QUANTITY);
452        throw new FHIRException("Unknown QuestionnaireItemType code '"+codeString+"'");
453        }
454    public String toCode(QuestionnaireItemType code) {
455      if (code == QuestionnaireItemType.GROUP)
456        return "group";
457      if (code == QuestionnaireItemType.DISPLAY)
458        return "display";
459      if (code == QuestionnaireItemType.QUESTION)
460        return "question";
461      if (code == QuestionnaireItemType.BOOLEAN)
462        return "boolean";
463      if (code == QuestionnaireItemType.DECIMAL)
464        return "decimal";
465      if (code == QuestionnaireItemType.INTEGER)
466        return "integer";
467      if (code == QuestionnaireItemType.DATE)
468        return "date";
469      if (code == QuestionnaireItemType.DATETIME)
470        return "dateTime";
471      if (code == QuestionnaireItemType.INSTANT)
472        return "instant";
473      if (code == QuestionnaireItemType.TIME)
474        return "time";
475      if (code == QuestionnaireItemType.STRING)
476        return "string";
477      if (code == QuestionnaireItemType.TEXT)
478        return "text";
479      if (code == QuestionnaireItemType.URL)
480        return "url";
481      if (code == QuestionnaireItemType.CHOICE)
482        return "choice";
483      if (code == QuestionnaireItemType.OPENCHOICE)
484        return "open-choice";
485      if (code == QuestionnaireItemType.ATTACHMENT)
486        return "attachment";
487      if (code == QuestionnaireItemType.REFERENCE)
488        return "reference";
489      if (code == QuestionnaireItemType.QUANTITY)
490        return "quantity";
491      return "?";
492      }
493    public String toSystem(QuestionnaireItemType code) {
494      return code.getSystem();
495      }
496    }
497
498    @Block()
499    public static class QuestionnaireItemComponent extends BackboneElement implements IBaseBackboneElement {
500        /**
501         * An identifier that is unique within the Questionnaire allowing linkage to the equivalent item in a QuestionnaireResponse resource.
502         */
503        @Child(name = "linkId", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=false)
504        @Description(shortDefinition="To link questionnaire with questionnaire response", formalDefinition="An identifier that is unique within the Questionnaire allowing linkage to the equivalent item in a QuestionnaireResponse resource." )
505        protected StringType linkId;
506
507        /**
508         * Identifies a how this group of questions is known in a particular terminology such as LOINC.
509         */
510        @Child(name = "concept", type = {Coding.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
511        @Description(shortDefinition="Concept that represents this item within in a questionnaire", formalDefinition="Identifies a how this group of questions is known in a particular terminology such as LOINC." )
512        protected List<Coding> concept;
513
514        /**
515         * A short label for a particular group, question or set of display text within the questionnaire.
516         */
517        @Child(name = "prefix", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=false)
518        @Description(shortDefinition="E.g. \"1(a)\", \"2.5.3\"", formalDefinition="A short label for a particular group, question or set of display text within the questionnaire." )
519        protected StringType prefix;
520
521        /**
522         * The name of a section, the text of a question or text content for a text item.
523         */
524        @Child(name = "text", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=true)
525        @Description(shortDefinition="Primary text for the item", formalDefinition="The name of a section, the text of a question or text content for a text item." )
526        protected StringType text;
527
528        /**
529         * Identifies the type of questionnaire item this is - whether text for display, a grouping of other items or a particular type of data to be captured (string, integer, coded choice, etc.).
530         */
531        @Child(name = "type", type = {CodeType.class}, order=5, min=1, max=1, modifier=false, summary=false)
532        @Description(shortDefinition="group | display | boolean | decimal | integer | date | dateTime +", formalDefinition="Identifies the type of questionnaire item this is - whether text for display, a grouping of other items or a particular type of data to be captured (string, integer, coded choice, etc.)." )
533        protected Enumeration<QuestionnaireItemType> type;
534
535        /**
536         * If present, indicates that this item should only be enabled (displayed/allow answers to be captured) when the specified condition is true.
537         */
538        @Child(name = "enableWhen", type = {}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=true, summary=false)
539        @Description(shortDefinition="Only allow data when:", formalDefinition="If present, indicates that this item should only be enabled (displayed/allow answers to be captured) when the specified condition is true." )
540        protected List<QuestionnaireItemEnableWhenComponent> enableWhen;
541
542        /**
543         * If true, indicates that the item must be present in a "completed" QuestionnaireResponse.  If false, the item may be skipped when answering the questionnaire.
544         */
545        @Child(name = "required", type = {BooleanType.class}, order=7, min=0, max=1, modifier=false, summary=false)
546        @Description(shortDefinition="Whether the item must be included in data results", formalDefinition="If true, indicates that the item must be present in a \"completed\" QuestionnaireResponse.  If false, the item may be skipped when answering the questionnaire." )
547        protected BooleanType required;
548
549        /**
550         * Whether the item may occur multiple times in the instance, containing multiple sets of answers.
551         */
552        @Child(name = "repeats", type = {BooleanType.class}, order=8, min=0, max=1, modifier=false, summary=false)
553        @Description(shortDefinition="Whether the item may repeat", formalDefinition="Whether the item may occur multiple times in the instance, containing multiple sets of answers." )
554        protected BooleanType repeats;
555
556        /**
557         * If true, the value cannot be changed by a human respondent to the Questionnaire.
558         */
559        @Child(name = "readOnly", type = {BooleanType.class}, order=9, min=0, max=1, modifier=false, summary=false)
560        @Description(shortDefinition="Don't allow human editing", formalDefinition="If true, the value cannot be changed by a human respondent to the Questionnaire." )
561        protected BooleanType readOnly;
562
563        /**
564         * The maximum number of characters that are permitted in the answer to be considered a "valid" QuestionnaireResponse.
565         */
566        @Child(name = "maxLength", type = {IntegerType.class}, order=10, min=0, max=1, modifier=false, summary=false)
567        @Description(shortDefinition="No more than this many characters", formalDefinition="The maximum number of characters that are permitted in the answer to be considered a \"valid\" QuestionnaireResponse." )
568        protected IntegerType maxLength;
569
570        /**
571         * Reference to a value set containing a list of codes representing permitted answers for the question.
572         */
573        @Child(name = "options", type = {ValueSet.class}, order=11, min=0, max=1, modifier=false, summary=false)
574        @Description(shortDefinition="Valueset containing permitted answers", formalDefinition="Reference to a value set containing a list of codes representing permitted answers for the question." )
575        protected Reference options;
576
577        /**
578         * The actual object that is the target of the reference (Reference to a value set containing a list of codes representing permitted answers for the question.)
579         */
580        protected ValueSet optionsTarget;
581
582        /**
583         * For a "choice" question, identifies one of the permitted answers for the question.
584         */
585        @Child(name = "option", type = {}, order=12, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
586        @Description(shortDefinition="Permitted answer", formalDefinition="For a \"choice\" question, identifies one of the permitted answers for the question." )
587        protected List<QuestionnaireItemOptionComponent> option;
588
589        /**
590         * The value that should be pre-populated when rendering the questionnaire for user input.
591         */
592        @Child(name = "initial", type = {BooleanType.class, DecimalType.class, IntegerType.class, DateType.class, DateTimeType.class, InstantType.class, TimeType.class, StringType.class, UriType.class, Attachment.class, Coding.class, Quantity.class}, order=13, min=0, max=1, modifier=false, summary=false)
593        @Description(shortDefinition="Initial presumed answer for question", formalDefinition="The value that should be pre-populated when rendering the questionnaire for user input." )
594        protected Type initial;
595
596        /**
597         * Allows text, questions and other groups to be nested beneath a question or group.
598         */
599        @Child(name = "item", type = {QuestionnaireItemComponent.class}, order=14, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
600        @Description(shortDefinition="Nested questionnaire items", formalDefinition="Allows text, questions and other groups to be nested beneath a question or group." )
601        protected List<QuestionnaireItemComponent> item;
602
603        private static final long serialVersionUID = -1787693458L;
604
605    /**
606     * Constructor
607     */
608      public QuestionnaireItemComponent() {
609        super();
610      }
611
612    /**
613     * Constructor
614     */
615      public QuestionnaireItemComponent(Enumeration<QuestionnaireItemType> type) {
616        super();
617        this.type = type;
618      }
619
620        /**
621         * @return {@link #linkId} (An identifier that is unique within the Questionnaire allowing linkage to the equivalent item in a QuestionnaireResponse resource.). This is the underlying object with id, value and extensions. The accessor "getLinkId" gives direct access to the value
622         */
623        public StringType getLinkIdElement() { 
624          if (this.linkId == null)
625            if (Configuration.errorOnAutoCreate())
626              throw new Error("Attempt to auto-create QuestionnaireItemComponent.linkId");
627            else if (Configuration.doAutoCreate())
628              this.linkId = new StringType(); // bb
629          return this.linkId;
630        }
631
632        public boolean hasLinkIdElement() { 
633          return this.linkId != null && !this.linkId.isEmpty();
634        }
635
636        public boolean hasLinkId() { 
637          return this.linkId != null && !this.linkId.isEmpty();
638        }
639
640        /**
641         * @param value {@link #linkId} (An identifier that is unique within the Questionnaire allowing linkage to the equivalent item in a QuestionnaireResponse resource.). This is the underlying object with id, value and extensions. The accessor "getLinkId" gives direct access to the value
642         */
643        public QuestionnaireItemComponent setLinkIdElement(StringType value) { 
644          this.linkId = value;
645          return this;
646        }
647
648        /**
649         * @return An identifier that is unique within the Questionnaire allowing linkage to the equivalent item in a QuestionnaireResponse resource.
650         */
651        public String getLinkId() { 
652          return this.linkId == null ? null : this.linkId.getValue();
653        }
654
655        /**
656         * @param value An identifier that is unique within the Questionnaire allowing linkage to the equivalent item in a QuestionnaireResponse resource.
657         */
658        public QuestionnaireItemComponent setLinkId(String value) { 
659          if (Utilities.noString(value))
660            this.linkId = null;
661          else {
662            if (this.linkId == null)
663              this.linkId = new StringType();
664            this.linkId.setValue(value);
665          }
666          return this;
667        }
668
669        /**
670         * @return {@link #concept} (Identifies a how this group of questions is known in a particular terminology such as LOINC.)
671         */
672        public List<Coding> getConcept() { 
673          if (this.concept == null)
674            this.concept = new ArrayList<Coding>();
675          return this.concept;
676        }
677
678        public boolean hasConcept() { 
679          if (this.concept == null)
680            return false;
681          for (Coding item : this.concept)
682            if (!item.isEmpty())
683              return true;
684          return false;
685        }
686
687        /**
688         * @return {@link #concept} (Identifies a how this group of questions is known in a particular terminology such as LOINC.)
689         */
690    // syntactic sugar
691        public Coding addConcept() { //3
692          Coding t = new Coding();
693          if (this.concept == null)
694            this.concept = new ArrayList<Coding>();
695          this.concept.add(t);
696          return t;
697        }
698
699    // syntactic sugar
700        public QuestionnaireItemComponent addConcept(Coding t) { //3
701          if (t == null)
702            return this;
703          if (this.concept == null)
704            this.concept = new ArrayList<Coding>();
705          this.concept.add(t);
706          return this;
707        }
708
709        /**
710         * @return {@link #prefix} (A short label for a particular group, question or set of display text within the questionnaire.). This is the underlying object with id, value and extensions. The accessor "getPrefix" gives direct access to the value
711         */
712        public StringType getPrefixElement() { 
713          if (this.prefix == null)
714            if (Configuration.errorOnAutoCreate())
715              throw new Error("Attempt to auto-create QuestionnaireItemComponent.prefix");
716            else if (Configuration.doAutoCreate())
717              this.prefix = new StringType(); // bb
718          return this.prefix;
719        }
720
721        public boolean hasPrefixElement() { 
722          return this.prefix != null && !this.prefix.isEmpty();
723        }
724
725        public boolean hasPrefix() { 
726          return this.prefix != null && !this.prefix.isEmpty();
727        }
728
729        /**
730         * @param value {@link #prefix} (A short label for a particular group, question or set of display text within the questionnaire.). This is the underlying object with id, value and extensions. The accessor "getPrefix" gives direct access to the value
731         */
732        public QuestionnaireItemComponent setPrefixElement(StringType value) { 
733          this.prefix = value;
734          return this;
735        }
736
737        /**
738         * @return A short label for a particular group, question or set of display text within the questionnaire.
739         */
740        public String getPrefix() { 
741          return this.prefix == null ? null : this.prefix.getValue();
742        }
743
744        /**
745         * @param value A short label for a particular group, question or set of display text within the questionnaire.
746         */
747        public QuestionnaireItemComponent setPrefix(String value) { 
748          if (Utilities.noString(value))
749            this.prefix = null;
750          else {
751            if (this.prefix == null)
752              this.prefix = new StringType();
753            this.prefix.setValue(value);
754          }
755          return this;
756        }
757
758        /**
759         * @return {@link #text} (The name of a section, the text of a question or text content for a text item.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value
760         */
761        public StringType getTextElement() { 
762          if (this.text == null)
763            if (Configuration.errorOnAutoCreate())
764              throw new Error("Attempt to auto-create QuestionnaireItemComponent.text");
765            else if (Configuration.doAutoCreate())
766              this.text = new StringType(); // bb
767          return this.text;
768        }
769
770        public boolean hasTextElement() { 
771          return this.text != null && !this.text.isEmpty();
772        }
773
774        public boolean hasText() { 
775          return this.text != null && !this.text.isEmpty();
776        }
777
778        /**
779         * @param value {@link #text} (The name of a section, the text of a question or text content for a text item.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value
780         */
781        public QuestionnaireItemComponent setTextElement(StringType value) { 
782          this.text = value;
783          return this;
784        }
785
786        /**
787         * @return The name of a section, the text of a question or text content for a text item.
788         */
789        public String getText() { 
790          return this.text == null ? null : this.text.getValue();
791        }
792
793        /**
794         * @param value The name of a section, the text of a question or text content for a text item.
795         */
796        public QuestionnaireItemComponent setText(String value) { 
797          if (Utilities.noString(value))
798            this.text = null;
799          else {
800            if (this.text == null)
801              this.text = new StringType();
802            this.text.setValue(value);
803          }
804          return this;
805        }
806
807        /**
808         * @return {@link #type} (Identifies the type of questionnaire item this is - whether text for display, a grouping of other items or a particular type of data to be captured (string, integer, coded choice, etc.).). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
809         */
810        public Enumeration<QuestionnaireItemType> getTypeElement() { 
811          if (this.type == null)
812            if (Configuration.errorOnAutoCreate())
813              throw new Error("Attempt to auto-create QuestionnaireItemComponent.type");
814            else if (Configuration.doAutoCreate())
815              this.type = new Enumeration<QuestionnaireItemType>(new QuestionnaireItemTypeEnumFactory()); // bb
816          return this.type;
817        }
818
819        public boolean hasTypeElement() { 
820          return this.type != null && !this.type.isEmpty();
821        }
822
823        public boolean hasType() { 
824          return this.type != null && !this.type.isEmpty();
825        }
826
827        /**
828         * @param value {@link #type} (Identifies the type of questionnaire item this is - whether text for display, a grouping of other items or a particular type of data to be captured (string, integer, coded choice, etc.).). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
829         */
830        public QuestionnaireItemComponent setTypeElement(Enumeration<QuestionnaireItemType> value) { 
831          this.type = value;
832          return this;
833        }
834
835        /**
836         * @return Identifies the type of questionnaire item this is - whether text for display, a grouping of other items or a particular type of data to be captured (string, integer, coded choice, etc.).
837         */
838        public QuestionnaireItemType getType() { 
839          return this.type == null ? null : this.type.getValue();
840        }
841
842        /**
843         * @param value Identifies the type of questionnaire item this is - whether text for display, a grouping of other items or a particular type of data to be captured (string, integer, coded choice, etc.).
844         */
845        public QuestionnaireItemComponent setType(QuestionnaireItemType value) { 
846            if (this.type == null)
847              this.type = new Enumeration<QuestionnaireItemType>(new QuestionnaireItemTypeEnumFactory());
848            this.type.setValue(value);
849          return this;
850        }
851
852        /**
853         * @return {@link #enableWhen} (If present, indicates that this item should only be enabled (displayed/allow answers to be captured) when the specified condition is true.)
854         */
855        public List<QuestionnaireItemEnableWhenComponent> getEnableWhen() { 
856          if (this.enableWhen == null)
857            this.enableWhen = new ArrayList<QuestionnaireItemEnableWhenComponent>();
858          return this.enableWhen;
859        }
860
861        public boolean hasEnableWhen() { 
862          if (this.enableWhen == null)
863            return false;
864          for (QuestionnaireItemEnableWhenComponent item : this.enableWhen)
865            if (!item.isEmpty())
866              return true;
867          return false;
868        }
869
870        /**
871         * @return {@link #enableWhen} (If present, indicates that this item should only be enabled (displayed/allow answers to be captured) when the specified condition is true.)
872         */
873    // syntactic sugar
874        public QuestionnaireItemEnableWhenComponent addEnableWhen() { //3
875          QuestionnaireItemEnableWhenComponent t = new QuestionnaireItemEnableWhenComponent();
876          if (this.enableWhen == null)
877            this.enableWhen = new ArrayList<QuestionnaireItemEnableWhenComponent>();
878          this.enableWhen.add(t);
879          return t;
880        }
881
882    // syntactic sugar
883        public QuestionnaireItemComponent addEnableWhen(QuestionnaireItemEnableWhenComponent t) { //3
884          if (t == null)
885            return this;
886          if (this.enableWhen == null)
887            this.enableWhen = new ArrayList<QuestionnaireItemEnableWhenComponent>();
888          this.enableWhen.add(t);
889          return this;
890        }
891
892        /**
893         * @return {@link #required} (If true, indicates that the item must be present in a "completed" QuestionnaireResponse.  If false, the item may be skipped when answering the questionnaire.). This is the underlying object with id, value and extensions. The accessor "getRequired" gives direct access to the value
894         */
895        public BooleanType getRequiredElement() { 
896          if (this.required == null)
897            if (Configuration.errorOnAutoCreate())
898              throw new Error("Attempt to auto-create QuestionnaireItemComponent.required");
899            else if (Configuration.doAutoCreate())
900              this.required = new BooleanType(); // bb
901          return this.required;
902        }
903
904        public boolean hasRequiredElement() { 
905          return this.required != null && !this.required.isEmpty();
906        }
907
908        public boolean hasRequired() { 
909          return this.required != null && !this.required.isEmpty();
910        }
911
912        /**
913         * @param value {@link #required} (If true, indicates that the item must be present in a "completed" QuestionnaireResponse.  If false, the item may be skipped when answering the questionnaire.). This is the underlying object with id, value and extensions. The accessor "getRequired" gives direct access to the value
914         */
915        public QuestionnaireItemComponent setRequiredElement(BooleanType value) { 
916          this.required = value;
917          return this;
918        }
919
920        /**
921         * @return If true, indicates that the item must be present in a "completed" QuestionnaireResponse.  If false, the item may be skipped when answering the questionnaire.
922         */
923        public boolean getRequired() { 
924          return this.required == null || this.required.isEmpty() ? false : this.required.getValue();
925        }
926
927        /**
928         * @param value If true, indicates that the item must be present in a "completed" QuestionnaireResponse.  If false, the item may be skipped when answering the questionnaire.
929         */
930        public QuestionnaireItemComponent setRequired(boolean value) { 
931            if (this.required == null)
932              this.required = new BooleanType();
933            this.required.setValue(value);
934          return this;
935        }
936
937        /**
938         * @return {@link #repeats} (Whether the item may occur multiple times in the instance, containing multiple sets of answers.). This is the underlying object with id, value and extensions. The accessor "getRepeats" gives direct access to the value
939         */
940        public BooleanType getRepeatsElement() { 
941          if (this.repeats == null)
942            if (Configuration.errorOnAutoCreate())
943              throw new Error("Attempt to auto-create QuestionnaireItemComponent.repeats");
944            else if (Configuration.doAutoCreate())
945              this.repeats = new BooleanType(); // bb
946          return this.repeats;
947        }
948
949        public boolean hasRepeatsElement() { 
950          return this.repeats != null && !this.repeats.isEmpty();
951        }
952
953        public boolean hasRepeats() { 
954          return this.repeats != null && !this.repeats.isEmpty();
955        }
956
957        /**
958         * @param value {@link #repeats} (Whether the item may occur multiple times in the instance, containing multiple sets of answers.). This is the underlying object with id, value and extensions. The accessor "getRepeats" gives direct access to the value
959         */
960        public QuestionnaireItemComponent setRepeatsElement(BooleanType value) { 
961          this.repeats = value;
962          return this;
963        }
964
965        /**
966         * @return Whether the item may occur multiple times in the instance, containing multiple sets of answers.
967         */
968        public boolean getRepeats() { 
969          return this.repeats == null || this.repeats.isEmpty() ? false : this.repeats.getValue();
970        }
971
972        /**
973         * @param value Whether the item may occur multiple times in the instance, containing multiple sets of answers.
974         */
975        public QuestionnaireItemComponent setRepeats(boolean value) { 
976            if (this.repeats == null)
977              this.repeats = new BooleanType();
978            this.repeats.setValue(value);
979          return this;
980        }
981
982        /**
983         * @return {@link #readOnly} (If true, the value cannot be changed by a human respondent to the Questionnaire.). This is the underlying object with id, value and extensions. The accessor "getReadOnly" gives direct access to the value
984         */
985        public BooleanType getReadOnlyElement() { 
986          if (this.readOnly == null)
987            if (Configuration.errorOnAutoCreate())
988              throw new Error("Attempt to auto-create QuestionnaireItemComponent.readOnly");
989            else if (Configuration.doAutoCreate())
990              this.readOnly = new BooleanType(); // bb
991          return this.readOnly;
992        }
993
994        public boolean hasReadOnlyElement() { 
995          return this.readOnly != null && !this.readOnly.isEmpty();
996        }
997
998        public boolean hasReadOnly() { 
999          return this.readOnly != null && !this.readOnly.isEmpty();
1000        }
1001
1002        /**
1003         * @param value {@link #readOnly} (If true, the value cannot be changed by a human respondent to the Questionnaire.). This is the underlying object with id, value and extensions. The accessor "getReadOnly" gives direct access to the value
1004         */
1005        public QuestionnaireItemComponent setReadOnlyElement(BooleanType value) { 
1006          this.readOnly = value;
1007          return this;
1008        }
1009
1010        /**
1011         * @return If true, the value cannot be changed by a human respondent to the Questionnaire.
1012         */
1013        public boolean getReadOnly() { 
1014          return this.readOnly == null || this.readOnly.isEmpty() ? false : this.readOnly.getValue();
1015        }
1016
1017        /**
1018         * @param value If true, the value cannot be changed by a human respondent to the Questionnaire.
1019         */
1020        public QuestionnaireItemComponent setReadOnly(boolean value) { 
1021            if (this.readOnly == null)
1022              this.readOnly = new BooleanType();
1023            this.readOnly.setValue(value);
1024          return this;
1025        }
1026
1027        /**
1028         * @return {@link #maxLength} (The maximum number of characters that are permitted in the answer to be considered a "valid" QuestionnaireResponse.). This is the underlying object with id, value and extensions. The accessor "getMaxLength" gives direct access to the value
1029         */
1030        public IntegerType getMaxLengthElement() { 
1031          if (this.maxLength == null)
1032            if (Configuration.errorOnAutoCreate())
1033              throw new Error("Attempt to auto-create QuestionnaireItemComponent.maxLength");
1034            else if (Configuration.doAutoCreate())
1035              this.maxLength = new IntegerType(); // bb
1036          return this.maxLength;
1037        }
1038
1039        public boolean hasMaxLengthElement() { 
1040          return this.maxLength != null && !this.maxLength.isEmpty();
1041        }
1042
1043        public boolean hasMaxLength() { 
1044          return this.maxLength != null && !this.maxLength.isEmpty();
1045        }
1046
1047        /**
1048         * @param value {@link #maxLength} (The maximum number of characters that are permitted in the answer to be considered a "valid" QuestionnaireResponse.). This is the underlying object with id, value and extensions. The accessor "getMaxLength" gives direct access to the value
1049         */
1050        public QuestionnaireItemComponent setMaxLengthElement(IntegerType value) { 
1051          this.maxLength = value;
1052          return this;
1053        }
1054
1055        /**
1056         * @return The maximum number of characters that are permitted in the answer to be considered a "valid" QuestionnaireResponse.
1057         */
1058        public int getMaxLength() { 
1059          return this.maxLength == null || this.maxLength.isEmpty() ? 0 : this.maxLength.getValue();
1060        }
1061
1062        /**
1063         * @param value The maximum number of characters that are permitted in the answer to be considered a "valid" QuestionnaireResponse.
1064         */
1065        public QuestionnaireItemComponent setMaxLength(int value) { 
1066            if (this.maxLength == null)
1067              this.maxLength = new IntegerType();
1068            this.maxLength.setValue(value);
1069          return this;
1070        }
1071
1072        /**
1073         * @return {@link #options} (Reference to a value set containing a list of codes representing permitted answers for the question.)
1074         */
1075        public Reference getOptions() { 
1076          if (this.options == null)
1077            if (Configuration.errorOnAutoCreate())
1078              throw new Error("Attempt to auto-create QuestionnaireItemComponent.options");
1079            else if (Configuration.doAutoCreate())
1080              this.options = new Reference(); // cc
1081          return this.options;
1082        }
1083
1084        public boolean hasOptions() { 
1085          return this.options != null && !this.options.isEmpty();
1086        }
1087
1088        /**
1089         * @param value {@link #options} (Reference to a value set containing a list of codes representing permitted answers for the question.)
1090         */
1091        public QuestionnaireItemComponent setOptions(Reference value) { 
1092          this.options = value;
1093          return this;
1094        }
1095
1096        /**
1097         * @return {@link #options} 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. (Reference to a value set containing a list of codes representing permitted answers for the question.)
1098         */
1099        public ValueSet getOptionsTarget() { 
1100          if (this.optionsTarget == null)
1101            if (Configuration.errorOnAutoCreate())
1102              throw new Error("Attempt to auto-create QuestionnaireItemComponent.options");
1103            else if (Configuration.doAutoCreate())
1104              this.optionsTarget = new ValueSet(); // aa
1105          return this.optionsTarget;
1106        }
1107
1108        /**
1109         * @param value {@link #options} 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. (Reference to a value set containing a list of codes representing permitted answers for the question.)
1110         */
1111        public QuestionnaireItemComponent setOptionsTarget(ValueSet value) { 
1112          this.optionsTarget = value;
1113          return this;
1114        }
1115
1116        /**
1117         * @return {@link #option} (For a "choice" question, identifies one of the permitted answers for the question.)
1118         */
1119        public List<QuestionnaireItemOptionComponent> getOption() { 
1120          if (this.option == null)
1121            this.option = new ArrayList<QuestionnaireItemOptionComponent>();
1122          return this.option;
1123        }
1124
1125        public boolean hasOption() { 
1126          if (this.option == null)
1127            return false;
1128          for (QuestionnaireItemOptionComponent item : this.option)
1129            if (!item.isEmpty())
1130              return true;
1131          return false;
1132        }
1133
1134        /**
1135         * @return {@link #option} (For a "choice" question, identifies one of the permitted answers for the question.)
1136         */
1137    // syntactic sugar
1138        public QuestionnaireItemOptionComponent addOption() { //3
1139          QuestionnaireItemOptionComponent t = new QuestionnaireItemOptionComponent();
1140          if (this.option == null)
1141            this.option = new ArrayList<QuestionnaireItemOptionComponent>();
1142          this.option.add(t);
1143          return t;
1144        }
1145
1146    // syntactic sugar
1147        public QuestionnaireItemComponent addOption(QuestionnaireItemOptionComponent t) { //3
1148          if (t == null)
1149            return this;
1150          if (this.option == null)
1151            this.option = new ArrayList<QuestionnaireItemOptionComponent>();
1152          this.option.add(t);
1153          return this;
1154        }
1155
1156        /**
1157         * @return {@link #initial} (The value that should be pre-populated when rendering the questionnaire for user input.)
1158         */
1159        public Type getInitial() { 
1160          return this.initial;
1161        }
1162
1163        /**
1164         * @return {@link #initial} (The value that should be pre-populated when rendering the questionnaire for user input.)
1165         */
1166        public BooleanType getInitialBooleanType() throws FHIRException { 
1167          if (!(this.initial instanceof BooleanType))
1168            throw new FHIRException("Type mismatch: the type BooleanType was expected, but "+this.initial.getClass().getName()+" was encountered");
1169          return (BooleanType) this.initial;
1170        }
1171
1172        public boolean hasInitialBooleanType() { 
1173          return this.initial instanceof BooleanType;
1174        }
1175
1176        /**
1177         * @return {@link #initial} (The value that should be pre-populated when rendering the questionnaire for user input.)
1178         */
1179        public DecimalType getInitialDecimalType() throws FHIRException { 
1180          if (!(this.initial instanceof DecimalType))
1181            throw new FHIRException("Type mismatch: the type DecimalType was expected, but "+this.initial.getClass().getName()+" was encountered");
1182          return (DecimalType) this.initial;
1183        }
1184
1185        public boolean hasInitialDecimalType() { 
1186          return this.initial instanceof DecimalType;
1187        }
1188
1189        /**
1190         * @return {@link #initial} (The value that should be pre-populated when rendering the questionnaire for user input.)
1191         */
1192        public IntegerType getInitialIntegerType() throws FHIRException { 
1193          if (!(this.initial instanceof IntegerType))
1194            throw new FHIRException("Type mismatch: the type IntegerType was expected, but "+this.initial.getClass().getName()+" was encountered");
1195          return (IntegerType) this.initial;
1196        }
1197
1198        public boolean hasInitialIntegerType() { 
1199          return this.initial instanceof IntegerType;
1200        }
1201
1202        /**
1203         * @return {@link #initial} (The value that should be pre-populated when rendering the questionnaire for user input.)
1204         */
1205        public DateType getInitialDateType() throws FHIRException { 
1206          if (!(this.initial instanceof DateType))
1207            throw new FHIRException("Type mismatch: the type DateType was expected, but "+this.initial.getClass().getName()+" was encountered");
1208          return (DateType) this.initial;
1209        }
1210
1211        public boolean hasInitialDateType() { 
1212          return this.initial instanceof DateType;
1213        }
1214
1215        /**
1216         * @return {@link #initial} (The value that should be pre-populated when rendering the questionnaire for user input.)
1217         */
1218        public DateTimeType getInitialDateTimeType() throws FHIRException { 
1219          if (!(this.initial instanceof DateTimeType))
1220            throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.initial.getClass().getName()+" was encountered");
1221          return (DateTimeType) this.initial;
1222        }
1223
1224        public boolean hasInitialDateTimeType() { 
1225          return this.initial instanceof DateTimeType;
1226        }
1227
1228        /**
1229         * @return {@link #initial} (The value that should be pre-populated when rendering the questionnaire for user input.)
1230         */
1231        public InstantType getInitialInstantType() throws FHIRException { 
1232          if (!(this.initial instanceof InstantType))
1233            throw new FHIRException("Type mismatch: the type InstantType was expected, but "+this.initial.getClass().getName()+" was encountered");
1234          return (InstantType) this.initial;
1235        }
1236
1237        public boolean hasInitialInstantType() { 
1238          return this.initial instanceof InstantType;
1239        }
1240
1241        /**
1242         * @return {@link #initial} (The value that should be pre-populated when rendering the questionnaire for user input.)
1243         */
1244        public TimeType getInitialTimeType() throws FHIRException { 
1245          if (!(this.initial instanceof TimeType))
1246            throw new FHIRException("Type mismatch: the type TimeType was expected, but "+this.initial.getClass().getName()+" was encountered");
1247          return (TimeType) this.initial;
1248        }
1249
1250        public boolean hasInitialTimeType() { 
1251          return this.initial instanceof TimeType;
1252        }
1253
1254        /**
1255         * @return {@link #initial} (The value that should be pre-populated when rendering the questionnaire for user input.)
1256         */
1257        public StringType getInitialStringType() throws FHIRException { 
1258          if (!(this.initial instanceof StringType))
1259            throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.initial.getClass().getName()+" was encountered");
1260          return (StringType) this.initial;
1261        }
1262
1263        public boolean hasInitialStringType() { 
1264          return this.initial instanceof StringType;
1265        }
1266
1267        /**
1268         * @return {@link #initial} (The value that should be pre-populated when rendering the questionnaire for user input.)
1269         */
1270        public UriType getInitialUriType() throws FHIRException { 
1271          if (!(this.initial instanceof UriType))
1272            throw new FHIRException("Type mismatch: the type UriType was expected, but "+this.initial.getClass().getName()+" was encountered");
1273          return (UriType) this.initial;
1274        }
1275
1276        public boolean hasInitialUriType() { 
1277          return this.initial instanceof UriType;
1278        }
1279
1280        /**
1281         * @return {@link #initial} (The value that should be pre-populated when rendering the questionnaire for user input.)
1282         */
1283        public Attachment getInitialAttachment() throws FHIRException { 
1284          if (!(this.initial instanceof Attachment))
1285            throw new FHIRException("Type mismatch: the type Attachment was expected, but "+this.initial.getClass().getName()+" was encountered");
1286          return (Attachment) this.initial;
1287        }
1288
1289        public boolean hasInitialAttachment() { 
1290          return this.initial instanceof Attachment;
1291        }
1292
1293        /**
1294         * @return {@link #initial} (The value that should be pre-populated when rendering the questionnaire for user input.)
1295         */
1296        public Coding getInitialCoding() throws FHIRException { 
1297          if (!(this.initial instanceof Coding))
1298            throw new FHIRException("Type mismatch: the type Coding was expected, but "+this.initial.getClass().getName()+" was encountered");
1299          return (Coding) this.initial;
1300        }
1301
1302        public boolean hasInitialCoding() { 
1303          return this.initial instanceof Coding;
1304        }
1305
1306        /**
1307         * @return {@link #initial} (The value that should be pre-populated when rendering the questionnaire for user input.)
1308         */
1309        public Quantity getInitialQuantity() throws FHIRException { 
1310          if (!(this.initial instanceof Quantity))
1311            throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.initial.getClass().getName()+" was encountered");
1312          return (Quantity) this.initial;
1313        }
1314
1315        public boolean hasInitialQuantity() { 
1316          return this.initial instanceof Quantity;
1317        }
1318
1319        /**
1320         * @return {@link #initial} (The value that should be pre-populated when rendering the questionnaire for user input.)
1321         */
1322        public Reference getInitialReference() throws FHIRException { 
1323          if (!(this.initial instanceof Reference))
1324            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.initial.getClass().getName()+" was encountered");
1325          return (Reference) this.initial;
1326        }
1327
1328        public boolean hasInitialReference() { 
1329          return this.initial instanceof Reference;
1330        }
1331
1332        public boolean hasInitial() { 
1333          return this.initial != null && !this.initial.isEmpty();
1334        }
1335
1336        /**
1337         * @param value {@link #initial} (The value that should be pre-populated when rendering the questionnaire for user input.)
1338         */
1339        public QuestionnaireItemComponent setInitial(Type value) { 
1340          this.initial = value;
1341          return this;
1342        }
1343
1344        /**
1345         * @return {@link #item} (Allows text, questions and other groups to be nested beneath a question or group.)
1346         */
1347        public List<QuestionnaireItemComponent> getItem() { 
1348          if (this.item == null)
1349            this.item = new ArrayList<QuestionnaireItemComponent>();
1350          return this.item;
1351        }
1352
1353        public boolean hasItem() { 
1354          if (this.item == null)
1355            return false;
1356          for (QuestionnaireItemComponent item : this.item)
1357            if (!item.isEmpty())
1358              return true;
1359          return false;
1360        }
1361
1362        /**
1363         * @return {@link #item} (Allows text, questions and other groups to be nested beneath a question or group.)
1364         */
1365    // syntactic sugar
1366        public QuestionnaireItemComponent addItem() { //3
1367          QuestionnaireItemComponent t = new QuestionnaireItemComponent();
1368          if (this.item == null)
1369            this.item = new ArrayList<QuestionnaireItemComponent>();
1370          this.item.add(t);
1371          return t;
1372        }
1373
1374    // syntactic sugar
1375        public QuestionnaireItemComponent addItem(QuestionnaireItemComponent t) { //3
1376          if (t == null)
1377            return this;
1378          if (this.item == null)
1379            this.item = new ArrayList<QuestionnaireItemComponent>();
1380          this.item.add(t);
1381          return this;
1382        }
1383
1384        protected void listChildren(List<Property> childrenList) {
1385          super.listChildren(childrenList);
1386          childrenList.add(new Property("linkId", "string", "An identifier that is unique within the Questionnaire allowing linkage to the equivalent item in a QuestionnaireResponse resource.", 0, java.lang.Integer.MAX_VALUE, linkId));
1387          childrenList.add(new Property("concept", "Coding", "Identifies a how this group of questions is known in a particular terminology such as LOINC.", 0, java.lang.Integer.MAX_VALUE, concept));
1388          childrenList.add(new Property("prefix", "string", "A short label for a particular group, question or set of display text within the questionnaire.", 0, java.lang.Integer.MAX_VALUE, prefix));
1389          childrenList.add(new Property("text", "string", "The name of a section, the text of a question or text content for a text item.", 0, java.lang.Integer.MAX_VALUE, text));
1390          childrenList.add(new Property("type", "code", "Identifies the type of questionnaire item this is - whether text for display, a grouping of other items or a particular type of data to be captured (string, integer, coded choice, etc.).", 0, java.lang.Integer.MAX_VALUE, type));
1391          childrenList.add(new Property("enableWhen", "", "If present, indicates that this item should only be enabled (displayed/allow answers to be captured) when the specified condition is true.", 0, java.lang.Integer.MAX_VALUE, enableWhen));
1392          childrenList.add(new Property("required", "boolean", "If true, indicates that the item must be present in a \"completed\" QuestionnaireResponse.  If false, the item may be skipped when answering the questionnaire.", 0, java.lang.Integer.MAX_VALUE, required));
1393          childrenList.add(new Property("repeats", "boolean", "Whether the item may occur multiple times in the instance, containing multiple sets of answers.", 0, java.lang.Integer.MAX_VALUE, repeats));
1394          childrenList.add(new Property("readOnly", "boolean", "If true, the value cannot be changed by a human respondent to the Questionnaire.", 0, java.lang.Integer.MAX_VALUE, readOnly));
1395          childrenList.add(new Property("maxLength", "integer", "The maximum number of characters that are permitted in the answer to be considered a \"valid\" QuestionnaireResponse.", 0, java.lang.Integer.MAX_VALUE, maxLength));
1396          childrenList.add(new Property("options", "Reference(ValueSet)", "Reference to a value set containing a list of codes representing permitted answers for the question.", 0, java.lang.Integer.MAX_VALUE, options));
1397          childrenList.add(new Property("option", "", "For a \"choice\" question, identifies one of the permitted answers for the question.", 0, java.lang.Integer.MAX_VALUE, option));
1398          childrenList.add(new Property("initial[x]", "boolean|decimal|integer|date|dateTime|instant|time|string|uri|Attachment|Coding|Quantity|Reference(Any)", "The value that should be pre-populated when rendering the questionnaire for user input.", 0, java.lang.Integer.MAX_VALUE, initial));
1399          childrenList.add(new Property("item", "@Questionnaire.item", "Allows text, questions and other groups to be nested beneath a question or group.", 0, java.lang.Integer.MAX_VALUE, item));
1400        }
1401
1402      @Override
1403      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1404        switch (hash) {
1405        case -1102667083: /*linkId*/ return this.linkId == null ? new Base[0] : new Base[] {this.linkId}; // StringType
1406        case 951024232: /*concept*/ return this.concept == null ? new Base[0] : this.concept.toArray(new Base[this.concept.size()]); // Coding
1407        case -980110702: /*prefix*/ return this.prefix == null ? new Base[0] : new Base[] {this.prefix}; // StringType
1408        case 3556653: /*text*/ return this.text == null ? new Base[0] : new Base[] {this.text}; // StringType
1409        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // Enumeration<QuestionnaireItemType>
1410        case 1893321565: /*enableWhen*/ return this.enableWhen == null ? new Base[0] : this.enableWhen.toArray(new Base[this.enableWhen.size()]); // QuestionnaireItemEnableWhenComponent
1411        case -393139297: /*required*/ return this.required == null ? new Base[0] : new Base[] {this.required}; // BooleanType
1412        case 1094288952: /*repeats*/ return this.repeats == null ? new Base[0] : new Base[] {this.repeats}; // BooleanType
1413        case -867683742: /*readOnly*/ return this.readOnly == null ? new Base[0] : new Base[] {this.readOnly}; // BooleanType
1414        case -791400086: /*maxLength*/ return this.maxLength == null ? new Base[0] : new Base[] {this.maxLength}; // IntegerType
1415        case -1249474914: /*options*/ return this.options == null ? new Base[0] : new Base[] {this.options}; // Reference
1416        case -1010136971: /*option*/ return this.option == null ? new Base[0] : this.option.toArray(new Base[this.option.size()]); // QuestionnaireItemOptionComponent
1417        case 1948342084: /*initial*/ return this.initial == null ? new Base[0] : new Base[] {this.initial}; // Type
1418        case 3242771: /*item*/ return this.item == null ? new Base[0] : this.item.toArray(new Base[this.item.size()]); // QuestionnaireItemComponent
1419        default: return super.getProperty(hash, name, checkValid);
1420        }
1421
1422      }
1423
1424      @Override
1425      public void setProperty(int hash, String name, Base value) throws FHIRException {
1426        switch (hash) {
1427        case -1102667083: // linkId
1428          this.linkId = castToString(value); // StringType
1429          break;
1430        case 951024232: // concept
1431          this.getConcept().add(castToCoding(value)); // Coding
1432          break;
1433        case -980110702: // prefix
1434          this.prefix = castToString(value); // StringType
1435          break;
1436        case 3556653: // text
1437          this.text = castToString(value); // StringType
1438          break;
1439        case 3575610: // type
1440          this.type = new QuestionnaireItemTypeEnumFactory().fromType(value); // Enumeration<QuestionnaireItemType>
1441          break;
1442        case 1893321565: // enableWhen
1443          this.getEnableWhen().add((QuestionnaireItemEnableWhenComponent) value); // QuestionnaireItemEnableWhenComponent
1444          break;
1445        case -393139297: // required
1446          this.required = castToBoolean(value); // BooleanType
1447          break;
1448        case 1094288952: // repeats
1449          this.repeats = castToBoolean(value); // BooleanType
1450          break;
1451        case -867683742: // readOnly
1452          this.readOnly = castToBoolean(value); // BooleanType
1453          break;
1454        case -791400086: // maxLength
1455          this.maxLength = castToInteger(value); // IntegerType
1456          break;
1457        case -1249474914: // options
1458          this.options = castToReference(value); // Reference
1459          break;
1460        case -1010136971: // option
1461          this.getOption().add((QuestionnaireItemOptionComponent) value); // QuestionnaireItemOptionComponent
1462          break;
1463        case 1948342084: // initial
1464          this.initial = (Type) value; // Type
1465          break;
1466        case 3242771: // item
1467          this.getItem().add((QuestionnaireItemComponent) value); // QuestionnaireItemComponent
1468          break;
1469        default: super.setProperty(hash, name, value);
1470        }
1471
1472      }
1473
1474      @Override
1475      public void setProperty(String name, Base value) throws FHIRException {
1476        if (name.equals("linkId"))
1477          this.linkId = castToString(value); // StringType
1478        else if (name.equals("concept"))
1479          this.getConcept().add(castToCoding(value));
1480        else if (name.equals("prefix"))
1481          this.prefix = castToString(value); // StringType
1482        else if (name.equals("text"))
1483          this.text = castToString(value); // StringType
1484        else if (name.equals("type"))
1485          this.type = new QuestionnaireItemTypeEnumFactory().fromType(value); // Enumeration<QuestionnaireItemType>
1486        else if (name.equals("enableWhen"))
1487          this.getEnableWhen().add((QuestionnaireItemEnableWhenComponent) value);
1488        else if (name.equals("required"))
1489          this.required = castToBoolean(value); // BooleanType
1490        else if (name.equals("repeats"))
1491          this.repeats = castToBoolean(value); // BooleanType
1492        else if (name.equals("readOnly"))
1493          this.readOnly = castToBoolean(value); // BooleanType
1494        else if (name.equals("maxLength"))
1495          this.maxLength = castToInteger(value); // IntegerType
1496        else if (name.equals("options"))
1497          this.options = castToReference(value); // Reference
1498        else if (name.equals("option"))
1499          this.getOption().add((QuestionnaireItemOptionComponent) value);
1500        else if (name.equals("initial[x]"))
1501          this.initial = (Type) value; // Type
1502        else if (name.equals("item"))
1503          this.getItem().add((QuestionnaireItemComponent) value);
1504        else
1505          super.setProperty(name, value);
1506      }
1507
1508      @Override
1509      public Base makeProperty(int hash, String name) throws FHIRException {
1510        switch (hash) {
1511        case -1102667083: throw new FHIRException("Cannot make property linkId as it is not a complex type"); // StringType
1512        case 951024232:  return addConcept(); // Coding
1513        case -980110702: throw new FHIRException("Cannot make property prefix as it is not a complex type"); // StringType
1514        case 3556653: throw new FHIRException("Cannot make property text as it is not a complex type"); // StringType
1515        case 3575610: throw new FHIRException("Cannot make property type as it is not a complex type"); // Enumeration<QuestionnaireItemType>
1516        case 1893321565:  return addEnableWhen(); // QuestionnaireItemEnableWhenComponent
1517        case -393139297: throw new FHIRException("Cannot make property required as it is not a complex type"); // BooleanType
1518        case 1094288952: throw new FHIRException("Cannot make property repeats as it is not a complex type"); // BooleanType
1519        case -867683742: throw new FHIRException("Cannot make property readOnly as it is not a complex type"); // BooleanType
1520        case -791400086: throw new FHIRException("Cannot make property maxLength as it is not a complex type"); // IntegerType
1521        case -1249474914:  return getOptions(); // Reference
1522        case -1010136971:  return addOption(); // QuestionnaireItemOptionComponent
1523        case 871077564:  return getInitial(); // Type
1524        case 3242771:  return addItem(); // QuestionnaireItemComponent
1525        default: return super.makeProperty(hash, name);
1526        }
1527
1528      }
1529
1530      @Override
1531      public Base addChild(String name) throws FHIRException {
1532        if (name.equals("linkId")) {
1533          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.linkId");
1534        }
1535        else if (name.equals("concept")) {
1536          return addConcept();
1537        }
1538        else if (name.equals("prefix")) {
1539          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.prefix");
1540        }
1541        else if (name.equals("text")) {
1542          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.text");
1543        }
1544        else if (name.equals("type")) {
1545          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.type");
1546        }
1547        else if (name.equals("enableWhen")) {
1548          return addEnableWhen();
1549        }
1550        else if (name.equals("required")) {
1551          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.required");
1552        }
1553        else if (name.equals("repeats")) {
1554          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.repeats");
1555        }
1556        else if (name.equals("readOnly")) {
1557          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.readOnly");
1558        }
1559        else if (name.equals("maxLength")) {
1560          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.maxLength");
1561        }
1562        else if (name.equals("options")) {
1563          this.options = new Reference();
1564          return this.options;
1565        }
1566        else if (name.equals("option")) {
1567          return addOption();
1568        }
1569        else if (name.equals("initialBoolean")) {
1570          this.initial = new BooleanType();
1571          return this.initial;
1572        }
1573        else if (name.equals("initialDecimal")) {
1574          this.initial = new DecimalType();
1575          return this.initial;
1576        }
1577        else if (name.equals("initialInteger")) {
1578          this.initial = new IntegerType();
1579          return this.initial;
1580        }
1581        else if (name.equals("initialDate")) {
1582          this.initial = new DateType();
1583          return this.initial;
1584        }
1585        else if (name.equals("initialDateTime")) {
1586          this.initial = new DateTimeType();
1587          return this.initial;
1588        }
1589        else if (name.equals("initialInstant")) {
1590          this.initial = new InstantType();
1591          return this.initial;
1592        }
1593        else if (name.equals("initialTime")) {
1594          this.initial = new TimeType();
1595          return this.initial;
1596        }
1597        else if (name.equals("initialString")) {
1598          this.initial = new StringType();
1599          return this.initial;
1600        }
1601        else if (name.equals("initialUri")) {
1602          this.initial = new UriType();
1603          return this.initial;
1604        }
1605        else if (name.equals("initialAttachment")) {
1606          this.initial = new Attachment();
1607          return this.initial;
1608        }
1609        else if (name.equals("initialCoding")) {
1610          this.initial = new Coding();
1611          return this.initial;
1612        }
1613        else if (name.equals("initialQuantity")) {
1614          this.initial = new Quantity();
1615          return this.initial;
1616        }
1617        else if (name.equals("initialReference")) {
1618          this.initial = new Reference();
1619          return this.initial;
1620        }
1621        else if (name.equals("item")) {
1622          return addItem();
1623        }
1624        else
1625          return super.addChild(name);
1626      }
1627
1628      public QuestionnaireItemComponent copy() {
1629        QuestionnaireItemComponent dst = new QuestionnaireItemComponent();
1630        copyValues(dst);
1631        dst.linkId = linkId == null ? null : linkId.copy();
1632        if (concept != null) {
1633          dst.concept = new ArrayList<Coding>();
1634          for (Coding i : concept)
1635            dst.concept.add(i.copy());
1636        };
1637        dst.prefix = prefix == null ? null : prefix.copy();
1638        dst.text = text == null ? null : text.copy();
1639        dst.type = type == null ? null : type.copy();
1640        if (enableWhen != null) {
1641          dst.enableWhen = new ArrayList<QuestionnaireItemEnableWhenComponent>();
1642          for (QuestionnaireItemEnableWhenComponent i : enableWhen)
1643            dst.enableWhen.add(i.copy());
1644        };
1645        dst.required = required == null ? null : required.copy();
1646        dst.repeats = repeats == null ? null : repeats.copy();
1647        dst.readOnly = readOnly == null ? null : readOnly.copy();
1648        dst.maxLength = maxLength == null ? null : maxLength.copy();
1649        dst.options = options == null ? null : options.copy();
1650        if (option != null) {
1651          dst.option = new ArrayList<QuestionnaireItemOptionComponent>();
1652          for (QuestionnaireItemOptionComponent i : option)
1653            dst.option.add(i.copy());
1654        };
1655        dst.initial = initial == null ? null : initial.copy();
1656        if (item != null) {
1657          dst.item = new ArrayList<QuestionnaireItemComponent>();
1658          for (QuestionnaireItemComponent i : item)
1659            dst.item.add(i.copy());
1660        };
1661        return dst;
1662      }
1663
1664      @Override
1665      public boolean equalsDeep(Base other) {
1666        if (!super.equalsDeep(other))
1667          return false;
1668        if (!(other instanceof QuestionnaireItemComponent))
1669          return false;
1670        QuestionnaireItemComponent o = (QuestionnaireItemComponent) other;
1671        return compareDeep(linkId, o.linkId, true) && compareDeep(concept, o.concept, true) && compareDeep(prefix, o.prefix, true)
1672           && compareDeep(text, o.text, true) && compareDeep(type, o.type, true) && compareDeep(enableWhen, o.enableWhen, true)
1673           && compareDeep(required, o.required, true) && compareDeep(repeats, o.repeats, true) && compareDeep(readOnly, o.readOnly, true)
1674           && compareDeep(maxLength, o.maxLength, true) && compareDeep(options, o.options, true) && compareDeep(option, o.option, true)
1675           && compareDeep(initial, o.initial, true) && compareDeep(item, o.item, true);
1676      }
1677
1678      @Override
1679      public boolean equalsShallow(Base other) {
1680        if (!super.equalsShallow(other))
1681          return false;
1682        if (!(other instanceof QuestionnaireItemComponent))
1683          return false;
1684        QuestionnaireItemComponent o = (QuestionnaireItemComponent) other;
1685        return compareValues(linkId, o.linkId, true) && compareValues(prefix, o.prefix, true) && compareValues(text, o.text, true)
1686           && compareValues(type, o.type, true) && compareValues(required, o.required, true) && compareValues(repeats, o.repeats, true)
1687           && compareValues(readOnly, o.readOnly, true) && compareValues(maxLength, o.maxLength, true);
1688      }
1689
1690      public boolean isEmpty() {
1691        return super.isEmpty() && (linkId == null || linkId.isEmpty()) && (concept == null || concept.isEmpty())
1692           && (prefix == null || prefix.isEmpty()) && (text == null || text.isEmpty()) && (type == null || type.isEmpty())
1693           && (enableWhen == null || enableWhen.isEmpty()) && (required == null || required.isEmpty())
1694           && (repeats == null || repeats.isEmpty()) && (readOnly == null || readOnly.isEmpty()) && (maxLength == null || maxLength.isEmpty())
1695           && (options == null || options.isEmpty()) && (option == null || option.isEmpty()) && (initial == null || initial.isEmpty())
1696           && (item == null || item.isEmpty());
1697      }
1698
1699  public String fhirType() {
1700    return "Questionnaire.item";
1701
1702  }
1703
1704  }
1705
1706    @Block()
1707    public static class QuestionnaireItemEnableWhenComponent extends BackboneElement implements IBaseBackboneElement {
1708        /**
1709         * The linkId for the question whose answer (or lack of answer) governs whether this item is enabled.
1710         */
1711        @Child(name = "question", type = {StringType.class}, order=1, min=1, max=1, modifier=false, summary=false)
1712        @Description(shortDefinition="Question that determines whether item is enabled", formalDefinition="The linkId for the question whose answer (or lack of answer) governs whether this item is enabled." )
1713        protected StringType question;
1714
1715        /**
1716         * If present, indicates that this item should be enabled only if the specified question is answered or not answered.
1717         */
1718        @Child(name = "answered", type = {BooleanType.class}, order=2, min=0, max=1, modifier=false, summary=false)
1719        @Description(shortDefinition="Enable when answered or not", formalDefinition="If present, indicates that this item should be enabled only if the specified question is answered or not answered." )
1720        protected BooleanType answered;
1721
1722        /**
1723         * If present, then the answer for the referenced question must match this answer for all components present in the enableWhen.answer.
1724         */
1725        @Child(name = "answer", type = {BooleanType.class, DecimalType.class, IntegerType.class, DateType.class, DateTimeType.class, InstantType.class, TimeType.class, StringType.class, UriType.class, Attachment.class, Coding.class, Quantity.class}, order=3, min=0, max=1, modifier=false, summary=false)
1726        @Description(shortDefinition="Value question must have", formalDefinition="If present, then the answer for the referenced question must match this answer for all components present in the enableWhen.answer." )
1727        protected Type answer;
1728
1729        private static final long serialVersionUID = 903205698L;
1730
1731    /**
1732     * Constructor
1733     */
1734      public QuestionnaireItemEnableWhenComponent() {
1735        super();
1736      }
1737
1738    /**
1739     * Constructor
1740     */
1741      public QuestionnaireItemEnableWhenComponent(StringType question) {
1742        super();
1743        this.question = question;
1744      }
1745
1746        /**
1747         * @return {@link #question} (The linkId for the question whose answer (or lack of answer) governs whether this item is enabled.). This is the underlying object with id, value and extensions. The accessor "getQuestion" gives direct access to the value
1748         */
1749        public StringType getQuestionElement() { 
1750          if (this.question == null)
1751            if (Configuration.errorOnAutoCreate())
1752              throw new Error("Attempt to auto-create QuestionnaireItemEnableWhenComponent.question");
1753            else if (Configuration.doAutoCreate())
1754              this.question = new StringType(); // bb
1755          return this.question;
1756        }
1757
1758        public boolean hasQuestionElement() { 
1759          return this.question != null && !this.question.isEmpty();
1760        }
1761
1762        public boolean hasQuestion() { 
1763          return this.question != null && !this.question.isEmpty();
1764        }
1765
1766        /**
1767         * @param value {@link #question} (The linkId for the question whose answer (or lack of answer) governs whether this item is enabled.). This is the underlying object with id, value and extensions. The accessor "getQuestion" gives direct access to the value
1768         */
1769        public QuestionnaireItemEnableWhenComponent setQuestionElement(StringType value) { 
1770          this.question = value;
1771          return this;
1772        }
1773
1774        /**
1775         * @return The linkId for the question whose answer (or lack of answer) governs whether this item is enabled.
1776         */
1777        public String getQuestion() { 
1778          return this.question == null ? null : this.question.getValue();
1779        }
1780
1781        /**
1782         * @param value The linkId for the question whose answer (or lack of answer) governs whether this item is enabled.
1783         */
1784        public QuestionnaireItemEnableWhenComponent setQuestion(String value) { 
1785            if (this.question == null)
1786              this.question = new StringType();
1787            this.question.setValue(value);
1788          return this;
1789        }
1790
1791        /**
1792         * @return {@link #answered} (If present, indicates that this item should be enabled only if the specified question is answered or not answered.). This is the underlying object with id, value and extensions. The accessor "getAnswered" gives direct access to the value
1793         */
1794        public BooleanType getAnsweredElement() { 
1795          if (this.answered == null)
1796            if (Configuration.errorOnAutoCreate())
1797              throw new Error("Attempt to auto-create QuestionnaireItemEnableWhenComponent.answered");
1798            else if (Configuration.doAutoCreate())
1799              this.answered = new BooleanType(); // bb
1800          return this.answered;
1801        }
1802
1803        public boolean hasAnsweredElement() { 
1804          return this.answered != null && !this.answered.isEmpty();
1805        }
1806
1807        public boolean hasAnswered() { 
1808          return this.answered != null && !this.answered.isEmpty();
1809        }
1810
1811        /**
1812         * @param value {@link #answered} (If present, indicates that this item should be enabled only if the specified question is answered or not answered.). This is the underlying object with id, value and extensions. The accessor "getAnswered" gives direct access to the value
1813         */
1814        public QuestionnaireItemEnableWhenComponent setAnsweredElement(BooleanType value) { 
1815          this.answered = value;
1816          return this;
1817        }
1818
1819        /**
1820         * @return If present, indicates that this item should be enabled only if the specified question is answered or not answered.
1821         */
1822        public boolean getAnswered() { 
1823          return this.answered == null || this.answered.isEmpty() ? false : this.answered.getValue();
1824        }
1825
1826        /**
1827         * @param value If present, indicates that this item should be enabled only if the specified question is answered or not answered.
1828         */
1829        public QuestionnaireItemEnableWhenComponent setAnswered(boolean value) { 
1830            if (this.answered == null)
1831              this.answered = new BooleanType();
1832            this.answered.setValue(value);
1833          return this;
1834        }
1835
1836        /**
1837         * @return {@link #answer} (If present, then the answer for the referenced question must match this answer for all components present in the enableWhen.answer.)
1838         */
1839        public Type getAnswer() { 
1840          return this.answer;
1841        }
1842
1843        /**
1844         * @return {@link #answer} (If present, then the answer for the referenced question must match this answer for all components present in the enableWhen.answer.)
1845         */
1846        public BooleanType getAnswerBooleanType() throws FHIRException { 
1847          if (!(this.answer instanceof BooleanType))
1848            throw new FHIRException("Type mismatch: the type BooleanType was expected, but "+this.answer.getClass().getName()+" was encountered");
1849          return (BooleanType) this.answer;
1850        }
1851
1852        public boolean hasAnswerBooleanType() { 
1853          return this.answer instanceof BooleanType;
1854        }
1855
1856        /**
1857         * @return {@link #answer} (If present, then the answer for the referenced question must match this answer for all components present in the enableWhen.answer.)
1858         */
1859        public DecimalType getAnswerDecimalType() throws FHIRException { 
1860          if (!(this.answer instanceof DecimalType))
1861            throw new FHIRException("Type mismatch: the type DecimalType was expected, but "+this.answer.getClass().getName()+" was encountered");
1862          return (DecimalType) this.answer;
1863        }
1864
1865        public boolean hasAnswerDecimalType() { 
1866          return this.answer instanceof DecimalType;
1867        }
1868
1869        /**
1870         * @return {@link #answer} (If present, then the answer for the referenced question must match this answer for all components present in the enableWhen.answer.)
1871         */
1872        public IntegerType getAnswerIntegerType() throws FHIRException { 
1873          if (!(this.answer instanceof IntegerType))
1874            throw new FHIRException("Type mismatch: the type IntegerType was expected, but "+this.answer.getClass().getName()+" was encountered");
1875          return (IntegerType) this.answer;
1876        }
1877
1878        public boolean hasAnswerIntegerType() { 
1879          return this.answer instanceof IntegerType;
1880        }
1881
1882        /**
1883         * @return {@link #answer} (If present, then the answer for the referenced question must match this answer for all components present in the enableWhen.answer.)
1884         */
1885        public DateType getAnswerDateType() throws FHIRException { 
1886          if (!(this.answer instanceof DateType))
1887            throw new FHIRException("Type mismatch: the type DateType was expected, but "+this.answer.getClass().getName()+" was encountered");
1888          return (DateType) this.answer;
1889        }
1890
1891        public boolean hasAnswerDateType() { 
1892          return this.answer instanceof DateType;
1893        }
1894
1895        /**
1896         * @return {@link #answer} (If present, then the answer for the referenced question must match this answer for all components present in the enableWhen.answer.)
1897         */
1898        public DateTimeType getAnswerDateTimeType() throws FHIRException { 
1899          if (!(this.answer instanceof DateTimeType))
1900            throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.answer.getClass().getName()+" was encountered");
1901          return (DateTimeType) this.answer;
1902        }
1903
1904        public boolean hasAnswerDateTimeType() { 
1905          return this.answer instanceof DateTimeType;
1906        }
1907
1908        /**
1909         * @return {@link #answer} (If present, then the answer for the referenced question must match this answer for all components present in the enableWhen.answer.)
1910         */
1911        public InstantType getAnswerInstantType() throws FHIRException { 
1912          if (!(this.answer instanceof InstantType))
1913            throw new FHIRException("Type mismatch: the type InstantType was expected, but "+this.answer.getClass().getName()+" was encountered");
1914          return (InstantType) this.answer;
1915        }
1916
1917        public boolean hasAnswerInstantType() { 
1918          return this.answer instanceof InstantType;
1919        }
1920
1921        /**
1922         * @return {@link #answer} (If present, then the answer for the referenced question must match this answer for all components present in the enableWhen.answer.)
1923         */
1924        public TimeType getAnswerTimeType() throws FHIRException { 
1925          if (!(this.answer instanceof TimeType))
1926            throw new FHIRException("Type mismatch: the type TimeType was expected, but "+this.answer.getClass().getName()+" was encountered");
1927          return (TimeType) this.answer;
1928        }
1929
1930        public boolean hasAnswerTimeType() { 
1931          return this.answer instanceof TimeType;
1932        }
1933
1934        /**
1935         * @return {@link #answer} (If present, then the answer for the referenced question must match this answer for all components present in the enableWhen.answer.)
1936         */
1937        public StringType getAnswerStringType() throws FHIRException { 
1938          if (!(this.answer instanceof StringType))
1939            throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.answer.getClass().getName()+" was encountered");
1940          return (StringType) this.answer;
1941        }
1942
1943        public boolean hasAnswerStringType() { 
1944          return this.answer instanceof StringType;
1945        }
1946
1947        /**
1948         * @return {@link #answer} (If present, then the answer for the referenced question must match this answer for all components present in the enableWhen.answer.)
1949         */
1950        public UriType getAnswerUriType() throws FHIRException { 
1951          if (!(this.answer instanceof UriType))
1952            throw new FHIRException("Type mismatch: the type UriType was expected, but "+this.answer.getClass().getName()+" was encountered");
1953          return (UriType) this.answer;
1954        }
1955
1956        public boolean hasAnswerUriType() { 
1957          return this.answer instanceof UriType;
1958        }
1959
1960        /**
1961         * @return {@link #answer} (If present, then the answer for the referenced question must match this answer for all components present in the enableWhen.answer.)
1962         */
1963        public Attachment getAnswerAttachment() throws FHIRException { 
1964          if (!(this.answer instanceof Attachment))
1965            throw new FHIRException("Type mismatch: the type Attachment was expected, but "+this.answer.getClass().getName()+" was encountered");
1966          return (Attachment) this.answer;
1967        }
1968
1969        public boolean hasAnswerAttachment() { 
1970          return this.answer instanceof Attachment;
1971        }
1972
1973        /**
1974         * @return {@link #answer} (If present, then the answer for the referenced question must match this answer for all components present in the enableWhen.answer.)
1975         */
1976        public Coding getAnswerCoding() throws FHIRException { 
1977          if (!(this.answer instanceof Coding))
1978            throw new FHIRException("Type mismatch: the type Coding was expected, but "+this.answer.getClass().getName()+" was encountered");
1979          return (Coding) this.answer;
1980        }
1981
1982        public boolean hasAnswerCoding() { 
1983          return this.answer instanceof Coding;
1984        }
1985
1986        /**
1987         * @return {@link #answer} (If present, then the answer for the referenced question must match this answer for all components present in the enableWhen.answer.)
1988         */
1989        public Quantity getAnswerQuantity() throws FHIRException { 
1990          if (!(this.answer instanceof Quantity))
1991            throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.answer.getClass().getName()+" was encountered");
1992          return (Quantity) this.answer;
1993        }
1994
1995        public boolean hasAnswerQuantity() { 
1996          return this.answer instanceof Quantity;
1997        }
1998
1999        /**
2000         * @return {@link #answer} (If present, then the answer for the referenced question must match this answer for all components present in the enableWhen.answer.)
2001         */
2002        public Reference getAnswerReference() throws FHIRException { 
2003          if (!(this.answer instanceof Reference))
2004            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.answer.getClass().getName()+" was encountered");
2005          return (Reference) this.answer;
2006        }
2007
2008        public boolean hasAnswerReference() { 
2009          return this.answer instanceof Reference;
2010        }
2011
2012        public boolean hasAnswer() { 
2013          return this.answer != null && !this.answer.isEmpty();
2014        }
2015
2016        /**
2017         * @param value {@link #answer} (If present, then the answer for the referenced question must match this answer for all components present in the enableWhen.answer.)
2018         */
2019        public QuestionnaireItemEnableWhenComponent setAnswer(Type value) { 
2020          this.answer = value;
2021          return this;
2022        }
2023
2024        protected void listChildren(List<Property> childrenList) {
2025          super.listChildren(childrenList);
2026          childrenList.add(new Property("question", "string", "The linkId for the question whose answer (or lack of answer) governs whether this item is enabled.", 0, java.lang.Integer.MAX_VALUE, question));
2027          childrenList.add(new Property("answered", "boolean", "If present, indicates that this item should be enabled only if the specified question is answered or not answered.", 0, java.lang.Integer.MAX_VALUE, answered));
2028          childrenList.add(new Property("answer[x]", "boolean|decimal|integer|date|dateTime|instant|time|string|uri|Attachment|Coding|Quantity|Reference(Any)", "If present, then the answer for the referenced question must match this answer for all components present in the enableWhen.answer.", 0, java.lang.Integer.MAX_VALUE, answer));
2029        }
2030
2031      @Override
2032      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2033        switch (hash) {
2034        case -1165870106: /*question*/ return this.question == null ? new Base[0] : new Base[] {this.question}; // StringType
2035        case -499559203: /*answered*/ return this.answered == null ? new Base[0] : new Base[] {this.answered}; // BooleanType
2036        case -1412808770: /*answer*/ return this.answer == null ? new Base[0] : new Base[] {this.answer}; // Type
2037        default: return super.getProperty(hash, name, checkValid);
2038        }
2039
2040      }
2041
2042      @Override
2043      public void setProperty(int hash, String name, Base value) throws FHIRException {
2044        switch (hash) {
2045        case -1165870106: // question
2046          this.question = castToString(value); // StringType
2047          break;
2048        case -499559203: // answered
2049          this.answered = castToBoolean(value); // BooleanType
2050          break;
2051        case -1412808770: // answer
2052          this.answer = (Type) value; // Type
2053          break;
2054        default: super.setProperty(hash, name, value);
2055        }
2056
2057      }
2058
2059      @Override
2060      public void setProperty(String name, Base value) throws FHIRException {
2061        if (name.equals("question"))
2062          this.question = castToString(value); // StringType
2063        else if (name.equals("answered"))
2064          this.answered = castToBoolean(value); // BooleanType
2065        else if (name.equals("answer[x]"))
2066          this.answer = (Type) value; // Type
2067        else
2068          super.setProperty(name, value);
2069      }
2070
2071      @Override
2072      public Base makeProperty(int hash, String name) throws FHIRException {
2073        switch (hash) {
2074        case -1165870106: throw new FHIRException("Cannot make property question as it is not a complex type"); // StringType
2075        case -499559203: throw new FHIRException("Cannot make property answered as it is not a complex type"); // BooleanType
2076        case 1693524994:  return getAnswer(); // Type
2077        default: return super.makeProperty(hash, name);
2078        }
2079
2080      }
2081
2082      @Override
2083      public Base addChild(String name) throws FHIRException {
2084        if (name.equals("question")) {
2085          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.question");
2086        }
2087        else if (name.equals("answered")) {
2088          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.answered");
2089        }
2090        else if (name.equals("answerBoolean")) {
2091          this.answer = new BooleanType();
2092          return this.answer;
2093        }
2094        else if (name.equals("answerDecimal")) {
2095          this.answer = new DecimalType();
2096          return this.answer;
2097        }
2098        else if (name.equals("answerInteger")) {
2099          this.answer = new IntegerType();
2100          return this.answer;
2101        }
2102        else if (name.equals("answerDate")) {
2103          this.answer = new DateType();
2104          return this.answer;
2105        }
2106        else if (name.equals("answerDateTime")) {
2107          this.answer = new DateTimeType();
2108          return this.answer;
2109        }
2110        else if (name.equals("answerInstant")) {
2111          this.answer = new InstantType();
2112          return this.answer;
2113        }
2114        else if (name.equals("answerTime")) {
2115          this.answer = new TimeType();
2116          return this.answer;
2117        }
2118        else if (name.equals("answerString")) {
2119          this.answer = new StringType();
2120          return this.answer;
2121        }
2122        else if (name.equals("answerUri")) {
2123          this.answer = new UriType();
2124          return this.answer;
2125        }
2126        else if (name.equals("answerAttachment")) {
2127          this.answer = new Attachment();
2128          return this.answer;
2129        }
2130        else if (name.equals("answerCoding")) {
2131          this.answer = new Coding();
2132          return this.answer;
2133        }
2134        else if (name.equals("answerQuantity")) {
2135          this.answer = new Quantity();
2136          return this.answer;
2137        }
2138        else if (name.equals("answerReference")) {
2139          this.answer = new Reference();
2140          return this.answer;
2141        }
2142        else
2143          return super.addChild(name);
2144      }
2145
2146      public QuestionnaireItemEnableWhenComponent copy() {
2147        QuestionnaireItemEnableWhenComponent dst = new QuestionnaireItemEnableWhenComponent();
2148        copyValues(dst);
2149        dst.question = question == null ? null : question.copy();
2150        dst.answered = answered == null ? null : answered.copy();
2151        dst.answer = answer == null ? null : answer.copy();
2152        return dst;
2153      }
2154
2155      @Override
2156      public boolean equalsDeep(Base other) {
2157        if (!super.equalsDeep(other))
2158          return false;
2159        if (!(other instanceof QuestionnaireItemEnableWhenComponent))
2160          return false;
2161        QuestionnaireItemEnableWhenComponent o = (QuestionnaireItemEnableWhenComponent) other;
2162        return compareDeep(question, o.question, true) && compareDeep(answered, o.answered, true) && compareDeep(answer, o.answer, true)
2163          ;
2164      }
2165
2166      @Override
2167      public boolean equalsShallow(Base other) {
2168        if (!super.equalsShallow(other))
2169          return false;
2170        if (!(other instanceof QuestionnaireItemEnableWhenComponent))
2171          return false;
2172        QuestionnaireItemEnableWhenComponent o = (QuestionnaireItemEnableWhenComponent) other;
2173        return compareValues(question, o.question, true) && compareValues(answered, o.answered, true);
2174      }
2175
2176      public boolean isEmpty() {
2177        return super.isEmpty() && (question == null || question.isEmpty()) && (answered == null || answered.isEmpty())
2178           && (answer == null || answer.isEmpty());
2179      }
2180
2181  public String fhirType() {
2182    return "Questionnaire.item.enableWhen";
2183
2184  }
2185
2186  }
2187
2188    @Block()
2189    public static class QuestionnaireItemOptionComponent extends BackboneElement implements IBaseBackboneElement {
2190        /**
2191         * Identifies a specific answer that's allowed as the answer to a question.
2192         */
2193        @Child(name = "value", type = {IntegerType.class, DateType.class, TimeType.class, StringType.class, Coding.class}, order=1, min=1, max=1, modifier=false, summary=false)
2194        @Description(shortDefinition="Answer value", formalDefinition="Identifies a specific answer that's allowed as the answer to a question." )
2195        protected Type value;
2196
2197        private static final long serialVersionUID = -732981989L;
2198
2199    /**
2200     * Constructor
2201     */
2202      public QuestionnaireItemOptionComponent() {
2203        super();
2204      }
2205
2206    /**
2207     * Constructor
2208     */
2209      public QuestionnaireItemOptionComponent(Type value) {
2210        super();
2211        this.value = value;
2212      }
2213
2214        /**
2215         * @return {@link #value} (Identifies a specific answer that's allowed as the answer to a question.)
2216         */
2217        public Type getValue() { 
2218          return this.value;
2219        }
2220
2221        /**
2222         * @return {@link #value} (Identifies a specific answer that's allowed as the answer to a question.)
2223         */
2224        public IntegerType getValueIntegerType() throws FHIRException { 
2225          if (!(this.value instanceof IntegerType))
2226            throw new FHIRException("Type mismatch: the type IntegerType was expected, but "+this.value.getClass().getName()+" was encountered");
2227          return (IntegerType) this.value;
2228        }
2229
2230        public boolean hasValueIntegerType() { 
2231          return this.value instanceof IntegerType;
2232        }
2233
2234        /**
2235         * @return {@link #value} (Identifies a specific answer that's allowed as the answer to a question.)
2236         */
2237        public DateType getValueDateType() throws FHIRException { 
2238          if (!(this.value instanceof DateType))
2239            throw new FHIRException("Type mismatch: the type DateType was expected, but "+this.value.getClass().getName()+" was encountered");
2240          return (DateType) this.value;
2241        }
2242
2243        public boolean hasValueDateType() { 
2244          return this.value instanceof DateType;
2245        }
2246
2247        /**
2248         * @return {@link #value} (Identifies a specific answer that's allowed as the answer to a question.)
2249         */
2250        public TimeType getValueTimeType() throws FHIRException { 
2251          if (!(this.value instanceof TimeType))
2252            throw new FHIRException("Type mismatch: the type TimeType was expected, but "+this.value.getClass().getName()+" was encountered");
2253          return (TimeType) this.value;
2254        }
2255
2256        public boolean hasValueTimeType() { 
2257          return this.value instanceof TimeType;
2258        }
2259
2260        /**
2261         * @return {@link #value} (Identifies a specific answer that's allowed as the answer to a question.)
2262         */
2263        public StringType getValueStringType() throws FHIRException { 
2264          if (!(this.value instanceof StringType))
2265            throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.value.getClass().getName()+" was encountered");
2266          return (StringType) this.value;
2267        }
2268
2269        public boolean hasValueStringType() { 
2270          return this.value instanceof StringType;
2271        }
2272
2273        /**
2274         * @return {@link #value} (Identifies a specific answer that's allowed as the answer to a question.)
2275         */
2276        public Coding getValueCoding() throws FHIRException { 
2277          if (!(this.value instanceof Coding))
2278            throw new FHIRException("Type mismatch: the type Coding was expected, but "+this.value.getClass().getName()+" was encountered");
2279          return (Coding) this.value;
2280        }
2281
2282        public boolean hasValueCoding() { 
2283          return this.value instanceof Coding;
2284        }
2285
2286        public boolean hasValue() { 
2287          return this.value != null && !this.value.isEmpty();
2288        }
2289
2290        /**
2291         * @param value {@link #value} (Identifies a specific answer that's allowed as the answer to a question.)
2292         */
2293        public QuestionnaireItemOptionComponent setValue(Type value) { 
2294          this.value = value;
2295          return this;
2296        }
2297
2298        protected void listChildren(List<Property> childrenList) {
2299          super.listChildren(childrenList);
2300          childrenList.add(new Property("value[x]", "integer|date|time|string|Coding", "Identifies a specific answer that's allowed as the answer to a question.", 0, java.lang.Integer.MAX_VALUE, value));
2301        }
2302
2303      @Override
2304      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2305        switch (hash) {
2306        case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // Type
2307        default: return super.getProperty(hash, name, checkValid);
2308        }
2309
2310      }
2311
2312      @Override
2313      public void setProperty(int hash, String name, Base value) throws FHIRException {
2314        switch (hash) {
2315        case 111972721: // value
2316          this.value = (Type) value; // Type
2317          break;
2318        default: super.setProperty(hash, name, value);
2319        }
2320
2321      }
2322
2323      @Override
2324      public void setProperty(String name, Base value) throws FHIRException {
2325        if (name.equals("value[x]"))
2326          this.value = (Type) value; // Type
2327        else
2328          super.setProperty(name, value);
2329      }
2330
2331      @Override
2332      public Base makeProperty(int hash, String name) throws FHIRException {
2333        switch (hash) {
2334        case -1410166417:  return getValue(); // Type
2335        default: return super.makeProperty(hash, name);
2336        }
2337
2338      }
2339
2340      @Override
2341      public Base addChild(String name) throws FHIRException {
2342        if (name.equals("valueInteger")) {
2343          this.value = new IntegerType();
2344          return this.value;
2345        }
2346        else if (name.equals("valueDate")) {
2347          this.value = new DateType();
2348          return this.value;
2349        }
2350        else if (name.equals("valueTime")) {
2351          this.value = new TimeType();
2352          return this.value;
2353        }
2354        else if (name.equals("valueString")) {
2355          this.value = new StringType();
2356          return this.value;
2357        }
2358        else if (name.equals("valueCoding")) {
2359          this.value = new Coding();
2360          return this.value;
2361        }
2362        else
2363          return super.addChild(name);
2364      }
2365
2366      public QuestionnaireItemOptionComponent copy() {
2367        QuestionnaireItemOptionComponent dst = new QuestionnaireItemOptionComponent();
2368        copyValues(dst);
2369        dst.value = value == null ? null : value.copy();
2370        return dst;
2371      }
2372
2373      @Override
2374      public boolean equalsDeep(Base other) {
2375        if (!super.equalsDeep(other))
2376          return false;
2377        if (!(other instanceof QuestionnaireItemOptionComponent))
2378          return false;
2379        QuestionnaireItemOptionComponent o = (QuestionnaireItemOptionComponent) other;
2380        return compareDeep(value, o.value, true);
2381      }
2382
2383      @Override
2384      public boolean equalsShallow(Base other) {
2385        if (!super.equalsShallow(other))
2386          return false;
2387        if (!(other instanceof QuestionnaireItemOptionComponent))
2388          return false;
2389        QuestionnaireItemOptionComponent o = (QuestionnaireItemOptionComponent) other;
2390        return true;
2391      }
2392
2393      public boolean isEmpty() {
2394        return super.isEmpty() && (value == null || value.isEmpty());
2395      }
2396
2397  public String fhirType() {
2398    return "Questionnaire.item.option";
2399
2400  }
2401
2402  }
2403
2404    /**
2405     * An absolute URL that is used to identify this questionnaire when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this questionnaire is (or will be) published.
2406     */
2407    @Child(name = "url", type = {UriType.class}, order=0, min=0, max=1, modifier=false, summary=true)
2408    @Description(shortDefinition="Globally unique logical identifier for  questionnaire", formalDefinition="An absolute URL that is used to identify this questionnaire when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this questionnaire is (or will be) published." )
2409    protected UriType url;
2410
2411    /**
2412     * This records identifiers associated with this question set that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).
2413     */
2414    @Child(name = "identifier", type = {Identifier.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2415    @Description(shortDefinition="External identifiers for this questionnaire", formalDefinition="This records identifiers associated with this question set that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation)." )
2416    protected List<Identifier> identifier;
2417
2418    /**
2419     * The version number assigned by the publisher for business reasons.  It may remain the same when the resource is updated.
2420     */
2421    @Child(name = "version", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=true)
2422    @Description(shortDefinition="Logical identifier for this version of Questionnaire", formalDefinition="The version number assigned by the publisher for business reasons.  It may remain the same when the resource is updated." )
2423    protected StringType version;
2424
2425    /**
2426     * The lifecycle status of the questionnaire as a whole.
2427     */
2428    @Child(name = "status", type = {CodeType.class}, order=3, min=1, max=1, modifier=true, summary=true)
2429    @Description(shortDefinition="draft | published | retired", formalDefinition="The lifecycle status of the questionnaire as a whole." )
2430    protected Enumeration<QuestionnaireStatus> status;
2431
2432    /**
2433     * The date that this questionnaire was last changed.
2434     */
2435    @Child(name = "date", type = {DateTimeType.class}, order=4, min=0, max=1, modifier=false, summary=true)
2436    @Description(shortDefinition="Date this version was authored", formalDefinition="The date that this questionnaire was last changed." )
2437    protected DateTimeType date;
2438
2439    /**
2440     * Organization or person responsible for developing and maintaining the questionnaire.
2441     */
2442    @Child(name = "publisher", type = {StringType.class}, order=5, min=0, max=1, modifier=false, summary=true)
2443    @Description(shortDefinition="Organization/individual who designed the questionnaire", formalDefinition="Organization or person responsible for developing and maintaining the questionnaire." )
2444    protected StringType publisher;
2445
2446    /**
2447     * Contact details to assist a user in finding and communicating with the publisher.
2448     */
2449    @Child(name = "telecom", type = {ContactPoint.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2450    @Description(shortDefinition="Contact information of the publisher", formalDefinition="Contact details to assist a user in finding and communicating with the publisher." )
2451    protected List<ContactPoint> telecom;
2452
2453    /**
2454     * A code that identifies the questionnaire as falling into a particular group of like questionnaires; e.g. "Pediatric", "Admissions", "Research", "Demographic", "Opinion Survey", etc.
2455     */
2456    @Child(name = "useContext", type = {CodeableConcept.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2457    @Description(shortDefinition="Questionnaire intends to support these contexts", formalDefinition="A code that identifies the questionnaire as falling into a particular group of like questionnaires; e.g. \"Pediatric\", \"Admissions\", \"Research\", \"Demographic\", \"Opinion Survey\", etc." )
2458    protected List<CodeableConcept> useContext;
2459
2460    /**
2461     * The name or label associated with this questionnaire.
2462     */
2463    @Child(name = "title", type = {StringType.class}, order=8, min=0, max=1, modifier=false, summary=true)
2464    @Description(shortDefinition="Name for the questionnaire", formalDefinition="The name or label associated with this questionnaire." )
2465    protected StringType title;
2466
2467    /**
2468     * Identifies a how this question or group of questions is known in a particular terminology such as LOINC.
2469     */
2470    @Child(name = "concept", type = {Coding.class}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2471    @Description(shortDefinition="Concept that represents the overall questionnaire", formalDefinition="Identifies a how this question or group of questions is known in a particular terminology such as LOINC." )
2472    protected List<Coding> concept;
2473
2474    /**
2475     * Identifies the types of subjects that can be the subject of the questionnaire.
2476     */
2477    @Child(name = "subjectType", type = {CodeType.class}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2478    @Description(shortDefinition="Resource that can be subject of QuestionnaireResponse", formalDefinition="Identifies the types of subjects that can be the subject of the questionnaire." )
2479    protected List<CodeType> subjectType;
2480
2481    /**
2482     * The questions and groupings of questions that make up the questionnaire.
2483     */
2484    @Child(name = "item", type = {}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2485    @Description(shortDefinition="Questions and sections within the Questionnaire", formalDefinition="The questions and groupings of questions that make up the questionnaire." )
2486    protected List<QuestionnaireItemComponent> item;
2487
2488    private static final long serialVersionUID = 1271324566L;
2489
2490  /**
2491   * Constructor
2492   */
2493    public Questionnaire() {
2494      super();
2495    }
2496
2497  /**
2498   * Constructor
2499   */
2500    public Questionnaire(Enumeration<QuestionnaireStatus> status) {
2501      super();
2502      this.status = status;
2503    }
2504
2505    /**
2506     * @return {@link #url} (An absolute URL that is used to identify this questionnaire when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this questionnaire is (or will be) published.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value
2507     */
2508    public UriType getUrlElement() { 
2509      if (this.url == null)
2510        if (Configuration.errorOnAutoCreate())
2511          throw new Error("Attempt to auto-create Questionnaire.url");
2512        else if (Configuration.doAutoCreate())
2513          this.url = new UriType(); // bb
2514      return this.url;
2515    }
2516
2517    public boolean hasUrlElement() { 
2518      return this.url != null && !this.url.isEmpty();
2519    }
2520
2521    public boolean hasUrl() { 
2522      return this.url != null && !this.url.isEmpty();
2523    }
2524
2525    /**
2526     * @param value {@link #url} (An absolute URL that is used to identify this questionnaire when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this questionnaire is (or will be) published.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value
2527     */
2528    public Questionnaire setUrlElement(UriType value) { 
2529      this.url = value;
2530      return this;
2531    }
2532
2533    /**
2534     * @return An absolute URL that is used to identify this questionnaire when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this questionnaire is (or will be) published.
2535     */
2536    public String getUrl() { 
2537      return this.url == null ? null : this.url.getValue();
2538    }
2539
2540    /**
2541     * @param value An absolute URL that is used to identify this questionnaire when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this questionnaire is (or will be) published.
2542     */
2543    public Questionnaire setUrl(String value) { 
2544      if (Utilities.noString(value))
2545        this.url = null;
2546      else {
2547        if (this.url == null)
2548          this.url = new UriType();
2549        this.url.setValue(value);
2550      }
2551      return this;
2552    }
2553
2554    /**
2555     * @return {@link #identifier} (This records identifiers associated with this question set that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).)
2556     */
2557    public List<Identifier> getIdentifier() { 
2558      if (this.identifier == null)
2559        this.identifier = new ArrayList<Identifier>();
2560      return this.identifier;
2561    }
2562
2563    public boolean hasIdentifier() { 
2564      if (this.identifier == null)
2565        return false;
2566      for (Identifier item : this.identifier)
2567        if (!item.isEmpty())
2568          return true;
2569      return false;
2570    }
2571
2572    /**
2573     * @return {@link #identifier} (This records identifiers associated with this question set that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).)
2574     */
2575    // syntactic sugar
2576    public Identifier addIdentifier() { //3
2577      Identifier t = new Identifier();
2578      if (this.identifier == null)
2579        this.identifier = new ArrayList<Identifier>();
2580      this.identifier.add(t);
2581      return t;
2582    }
2583
2584    // syntactic sugar
2585    public Questionnaire addIdentifier(Identifier t) { //3
2586      if (t == null)
2587        return this;
2588      if (this.identifier == null)
2589        this.identifier = new ArrayList<Identifier>();
2590      this.identifier.add(t);
2591      return this;
2592    }
2593
2594    /**
2595     * @return {@link #version} (The version number assigned by the publisher for business reasons.  It may remain the same when the resource is updated.). This is the underlying object with id, value and extensions. The accessor "getVersion" gives direct access to the value
2596     */
2597    public StringType getVersionElement() { 
2598      if (this.version == null)
2599        if (Configuration.errorOnAutoCreate())
2600          throw new Error("Attempt to auto-create Questionnaire.version");
2601        else if (Configuration.doAutoCreate())
2602          this.version = new StringType(); // bb
2603      return this.version;
2604    }
2605
2606    public boolean hasVersionElement() { 
2607      return this.version != null && !this.version.isEmpty();
2608    }
2609
2610    public boolean hasVersion() { 
2611      return this.version != null && !this.version.isEmpty();
2612    }
2613
2614    /**
2615     * @param value {@link #version} (The version number assigned by the publisher for business reasons.  It may remain the same when the resource is updated.). This is the underlying object with id, value and extensions. The accessor "getVersion" gives direct access to the value
2616     */
2617    public Questionnaire setVersionElement(StringType value) { 
2618      this.version = value;
2619      return this;
2620    }
2621
2622    /**
2623     * @return The version number assigned by the publisher for business reasons.  It may remain the same when the resource is updated.
2624     */
2625    public String getVersion() { 
2626      return this.version == null ? null : this.version.getValue();
2627    }
2628
2629    /**
2630     * @param value The version number assigned by the publisher for business reasons.  It may remain the same when the resource is updated.
2631     */
2632    public Questionnaire setVersion(String value) { 
2633      if (Utilities.noString(value))
2634        this.version = null;
2635      else {
2636        if (this.version == null)
2637          this.version = new StringType();
2638        this.version.setValue(value);
2639      }
2640      return this;
2641    }
2642
2643    /**
2644     * @return {@link #status} (The lifecycle status of the questionnaire as a whole.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
2645     */
2646    public Enumeration<QuestionnaireStatus> getStatusElement() { 
2647      if (this.status == null)
2648        if (Configuration.errorOnAutoCreate())
2649          throw new Error("Attempt to auto-create Questionnaire.status");
2650        else if (Configuration.doAutoCreate())
2651          this.status = new Enumeration<QuestionnaireStatus>(new QuestionnaireStatusEnumFactory()); // bb
2652      return this.status;
2653    }
2654
2655    public boolean hasStatusElement() { 
2656      return this.status != null && !this.status.isEmpty();
2657    }
2658
2659    public boolean hasStatus() { 
2660      return this.status != null && !this.status.isEmpty();
2661    }
2662
2663    /**
2664     * @param value {@link #status} (The lifecycle status of the questionnaire as a whole.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
2665     */
2666    public Questionnaire setStatusElement(Enumeration<QuestionnaireStatus> value) { 
2667      this.status = value;
2668      return this;
2669    }
2670
2671    /**
2672     * @return The lifecycle status of the questionnaire as a whole.
2673     */
2674    public QuestionnaireStatus getStatus() { 
2675      return this.status == null ? null : this.status.getValue();
2676    }
2677
2678    /**
2679     * @param value The lifecycle status of the questionnaire as a whole.
2680     */
2681    public Questionnaire setStatus(QuestionnaireStatus value) { 
2682        if (this.status == null)
2683          this.status = new Enumeration<QuestionnaireStatus>(new QuestionnaireStatusEnumFactory());
2684        this.status.setValue(value);
2685      return this;
2686    }
2687
2688    /**
2689     * @return {@link #date} (The date that this questionnaire was last changed.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
2690     */
2691    public DateTimeType getDateElement() { 
2692      if (this.date == null)
2693        if (Configuration.errorOnAutoCreate())
2694          throw new Error("Attempt to auto-create Questionnaire.date");
2695        else if (Configuration.doAutoCreate())
2696          this.date = new DateTimeType(); // bb
2697      return this.date;
2698    }
2699
2700    public boolean hasDateElement() { 
2701      return this.date != null && !this.date.isEmpty();
2702    }
2703
2704    public boolean hasDate() { 
2705      return this.date != null && !this.date.isEmpty();
2706    }
2707
2708    /**
2709     * @param value {@link #date} (The date that this questionnaire was last changed.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
2710     */
2711    public Questionnaire setDateElement(DateTimeType value) { 
2712      this.date = value;
2713      return this;
2714    }
2715
2716    /**
2717     * @return The date that this questionnaire was last changed.
2718     */
2719    public Date getDate() { 
2720      return this.date == null ? null : this.date.getValue();
2721    }
2722
2723    /**
2724     * @param value The date that this questionnaire was last changed.
2725     */
2726    public Questionnaire setDate(Date value) { 
2727      if (value == null)
2728        this.date = null;
2729      else {
2730        if (this.date == null)
2731          this.date = new DateTimeType();
2732        this.date.setValue(value);
2733      }
2734      return this;
2735    }
2736
2737    /**
2738     * @return {@link #publisher} (Organization or person responsible for developing and maintaining the questionnaire.). This is the underlying object with id, value and extensions. The accessor "getPublisher" gives direct access to the value
2739     */
2740    public StringType getPublisherElement() { 
2741      if (this.publisher == null)
2742        if (Configuration.errorOnAutoCreate())
2743          throw new Error("Attempt to auto-create Questionnaire.publisher");
2744        else if (Configuration.doAutoCreate())
2745          this.publisher = new StringType(); // bb
2746      return this.publisher;
2747    }
2748
2749    public boolean hasPublisherElement() { 
2750      return this.publisher != null && !this.publisher.isEmpty();
2751    }
2752
2753    public boolean hasPublisher() { 
2754      return this.publisher != null && !this.publisher.isEmpty();
2755    }
2756
2757    /**
2758     * @param value {@link #publisher} (Organization or person responsible for developing and maintaining the questionnaire.). This is the underlying object with id, value and extensions. The accessor "getPublisher" gives direct access to the value
2759     */
2760    public Questionnaire setPublisherElement(StringType value) { 
2761      this.publisher = value;
2762      return this;
2763    }
2764
2765    /**
2766     * @return Organization or person responsible for developing and maintaining the questionnaire.
2767     */
2768    public String getPublisher() { 
2769      return this.publisher == null ? null : this.publisher.getValue();
2770    }
2771
2772    /**
2773     * @param value Organization or person responsible for developing and maintaining the questionnaire.
2774     */
2775    public Questionnaire setPublisher(String value) { 
2776      if (Utilities.noString(value))
2777        this.publisher = null;
2778      else {
2779        if (this.publisher == null)
2780          this.publisher = new StringType();
2781        this.publisher.setValue(value);
2782      }
2783      return this;
2784    }
2785
2786    /**
2787     * @return {@link #telecom} (Contact details to assist a user in finding and communicating with the publisher.)
2788     */
2789    public List<ContactPoint> getTelecom() { 
2790      if (this.telecom == null)
2791        this.telecom = new ArrayList<ContactPoint>();
2792      return this.telecom;
2793    }
2794
2795    public boolean hasTelecom() { 
2796      if (this.telecom == null)
2797        return false;
2798      for (ContactPoint item : this.telecom)
2799        if (!item.isEmpty())
2800          return true;
2801      return false;
2802    }
2803
2804    /**
2805     * @return {@link #telecom} (Contact details to assist a user in finding and communicating with the publisher.)
2806     */
2807    // syntactic sugar
2808    public ContactPoint addTelecom() { //3
2809      ContactPoint t = new ContactPoint();
2810      if (this.telecom == null)
2811        this.telecom = new ArrayList<ContactPoint>();
2812      this.telecom.add(t);
2813      return t;
2814    }
2815
2816    // syntactic sugar
2817    public Questionnaire addTelecom(ContactPoint t) { //3
2818      if (t == null)
2819        return this;
2820      if (this.telecom == null)
2821        this.telecom = new ArrayList<ContactPoint>();
2822      this.telecom.add(t);
2823      return this;
2824    }
2825
2826    /**
2827     * @return {@link #useContext} (A code that identifies the questionnaire as falling into a particular group of like questionnaires; e.g. "Pediatric", "Admissions", "Research", "Demographic", "Opinion Survey", etc.)
2828     */
2829    public List<CodeableConcept> getUseContext() { 
2830      if (this.useContext == null)
2831        this.useContext = new ArrayList<CodeableConcept>();
2832      return this.useContext;
2833    }
2834
2835    public boolean hasUseContext() { 
2836      if (this.useContext == null)
2837        return false;
2838      for (CodeableConcept item : this.useContext)
2839        if (!item.isEmpty())
2840          return true;
2841      return false;
2842    }
2843
2844    /**
2845     * @return {@link #useContext} (A code that identifies the questionnaire as falling into a particular group of like questionnaires; e.g. "Pediatric", "Admissions", "Research", "Demographic", "Opinion Survey", etc.)
2846     */
2847    // syntactic sugar
2848    public CodeableConcept addUseContext() { //3
2849      CodeableConcept t = new CodeableConcept();
2850      if (this.useContext == null)
2851        this.useContext = new ArrayList<CodeableConcept>();
2852      this.useContext.add(t);
2853      return t;
2854    }
2855
2856    // syntactic sugar
2857    public Questionnaire addUseContext(CodeableConcept t) { //3
2858      if (t == null)
2859        return this;
2860      if (this.useContext == null)
2861        this.useContext = new ArrayList<CodeableConcept>();
2862      this.useContext.add(t);
2863      return this;
2864    }
2865
2866    /**
2867     * @return {@link #title} (The name or label associated with this questionnaire.). This is the underlying object with id, value and extensions. The accessor "getTitle" gives direct access to the value
2868     */
2869    public StringType getTitleElement() { 
2870      if (this.title == null)
2871        if (Configuration.errorOnAutoCreate())
2872          throw new Error("Attempt to auto-create Questionnaire.title");
2873        else if (Configuration.doAutoCreate())
2874          this.title = new StringType(); // bb
2875      return this.title;
2876    }
2877
2878    public boolean hasTitleElement() { 
2879      return this.title != null && !this.title.isEmpty();
2880    }
2881
2882    public boolean hasTitle() { 
2883      return this.title != null && !this.title.isEmpty();
2884    }
2885
2886    /**
2887     * @param value {@link #title} (The name or label associated with this questionnaire.). This is the underlying object with id, value and extensions. The accessor "getTitle" gives direct access to the value
2888     */
2889    public Questionnaire setTitleElement(StringType value) { 
2890      this.title = value;
2891      return this;
2892    }
2893
2894    /**
2895     * @return The name or label associated with this questionnaire.
2896     */
2897    public String getTitle() { 
2898      return this.title == null ? null : this.title.getValue();
2899    }
2900
2901    /**
2902     * @param value The name or label associated with this questionnaire.
2903     */
2904    public Questionnaire setTitle(String value) { 
2905      if (Utilities.noString(value))
2906        this.title = null;
2907      else {
2908        if (this.title == null)
2909          this.title = new StringType();
2910        this.title.setValue(value);
2911      }
2912      return this;
2913    }
2914
2915    /**
2916     * @return {@link #concept} (Identifies a how this question or group of questions is known in a particular terminology such as LOINC.)
2917     */
2918    public List<Coding> getConcept() { 
2919      if (this.concept == null)
2920        this.concept = new ArrayList<Coding>();
2921      return this.concept;
2922    }
2923
2924    public boolean hasConcept() { 
2925      if (this.concept == null)
2926        return false;
2927      for (Coding item : this.concept)
2928        if (!item.isEmpty())
2929          return true;
2930      return false;
2931    }
2932
2933    /**
2934     * @return {@link #concept} (Identifies a how this question or group of questions is known in a particular terminology such as LOINC.)
2935     */
2936    // syntactic sugar
2937    public Coding addConcept() { //3
2938      Coding t = new Coding();
2939      if (this.concept == null)
2940        this.concept = new ArrayList<Coding>();
2941      this.concept.add(t);
2942      return t;
2943    }
2944
2945    // syntactic sugar
2946    public Questionnaire addConcept(Coding t) { //3
2947      if (t == null)
2948        return this;
2949      if (this.concept == null)
2950        this.concept = new ArrayList<Coding>();
2951      this.concept.add(t);
2952      return this;
2953    }
2954
2955    /**
2956     * @return {@link #subjectType} (Identifies the types of subjects that can be the subject of the questionnaire.)
2957     */
2958    public List<CodeType> getSubjectType() { 
2959      if (this.subjectType == null)
2960        this.subjectType = new ArrayList<CodeType>();
2961      return this.subjectType;
2962    }
2963
2964    public boolean hasSubjectType() { 
2965      if (this.subjectType == null)
2966        return false;
2967      for (CodeType item : this.subjectType)
2968        if (!item.isEmpty())
2969          return true;
2970      return false;
2971    }
2972
2973    /**
2974     * @return {@link #subjectType} (Identifies the types of subjects that can be the subject of the questionnaire.)
2975     */
2976    // syntactic sugar
2977    public CodeType addSubjectTypeElement() {//2 
2978      CodeType t = new CodeType();
2979      if (this.subjectType == null)
2980        this.subjectType = new ArrayList<CodeType>();
2981      this.subjectType.add(t);
2982      return t;
2983    }
2984
2985    /**
2986     * @param value {@link #subjectType} (Identifies the types of subjects that can be the subject of the questionnaire.)
2987     */
2988    public Questionnaire addSubjectType(String value) { //1
2989      CodeType t = new CodeType();
2990      t.setValue(value);
2991      if (this.subjectType == null)
2992        this.subjectType = new ArrayList<CodeType>();
2993      this.subjectType.add(t);
2994      return this;
2995    }
2996
2997    /**
2998     * @param value {@link #subjectType} (Identifies the types of subjects that can be the subject of the questionnaire.)
2999     */
3000    public boolean hasSubjectType(String value) { 
3001      if (this.subjectType == null)
3002        return false;
3003      for (CodeType v : this.subjectType)
3004        if (v.equals(value)) // code
3005          return true;
3006      return false;
3007    }
3008
3009    /**
3010     * @return {@link #item} (The questions and groupings of questions that make up the questionnaire.)
3011     */
3012    public List<QuestionnaireItemComponent> getItem() { 
3013      if (this.item == null)
3014        this.item = new ArrayList<QuestionnaireItemComponent>();
3015      return this.item;
3016    }
3017
3018    public boolean hasItem() { 
3019      if (this.item == null)
3020        return false;
3021      for (QuestionnaireItemComponent item : this.item)
3022        if (!item.isEmpty())
3023          return true;
3024      return false;
3025    }
3026
3027    /**
3028     * @return {@link #item} (The questions and groupings of questions that make up the questionnaire.)
3029     */
3030    // syntactic sugar
3031    public QuestionnaireItemComponent addItem() { //3
3032      QuestionnaireItemComponent t = new QuestionnaireItemComponent();
3033      if (this.item == null)
3034        this.item = new ArrayList<QuestionnaireItemComponent>();
3035      this.item.add(t);
3036      return t;
3037    }
3038
3039    // syntactic sugar
3040    public Questionnaire addItem(QuestionnaireItemComponent t) { //3
3041      if (t == null)
3042        return this;
3043      if (this.item == null)
3044        this.item = new ArrayList<QuestionnaireItemComponent>();
3045      this.item.add(t);
3046      return this;
3047    }
3048
3049      protected void listChildren(List<Property> childrenList) {
3050        super.listChildren(childrenList);
3051        childrenList.add(new Property("url", "uri", "An absolute URL that is used to identify this questionnaire when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this questionnaire is (or will be) published.", 0, java.lang.Integer.MAX_VALUE, url));
3052        childrenList.add(new Property("identifier", "Identifier", "This records identifiers associated with this question set that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).", 0, java.lang.Integer.MAX_VALUE, identifier));
3053        childrenList.add(new Property("version", "string", "The version number assigned by the publisher for business reasons.  It may remain the same when the resource is updated.", 0, java.lang.Integer.MAX_VALUE, version));
3054        childrenList.add(new Property("status", "code", "The lifecycle status of the questionnaire as a whole.", 0, java.lang.Integer.MAX_VALUE, status));
3055        childrenList.add(new Property("date", "dateTime", "The date that this questionnaire was last changed.", 0, java.lang.Integer.MAX_VALUE, date));
3056        childrenList.add(new Property("publisher", "string", "Organization or person responsible for developing and maintaining the questionnaire.", 0, java.lang.Integer.MAX_VALUE, publisher));
3057        childrenList.add(new Property("telecom", "ContactPoint", "Contact details to assist a user in finding and communicating with the publisher.", 0, java.lang.Integer.MAX_VALUE, telecom));
3058        childrenList.add(new Property("useContext", "CodeableConcept", "A code that identifies the questionnaire as falling into a particular group of like questionnaires; e.g. \"Pediatric\", \"Admissions\", \"Research\", \"Demographic\", \"Opinion Survey\", etc.", 0, java.lang.Integer.MAX_VALUE, useContext));
3059        childrenList.add(new Property("title", "string", "The name or label associated with this questionnaire.", 0, java.lang.Integer.MAX_VALUE, title));
3060        childrenList.add(new Property("concept", "Coding", "Identifies a how this question or group of questions is known in a particular terminology such as LOINC.", 0, java.lang.Integer.MAX_VALUE, concept));
3061        childrenList.add(new Property("subjectType", "code", "Identifies the types of subjects that can be the subject of the questionnaire.", 0, java.lang.Integer.MAX_VALUE, subjectType));
3062        childrenList.add(new Property("item", "", "The questions and groupings of questions that make up the questionnaire.", 0, java.lang.Integer.MAX_VALUE, item));
3063      }
3064
3065      @Override
3066      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
3067        switch (hash) {
3068        case 116079: /*url*/ return this.url == null ? new Base[0] : new Base[] {this.url}; // UriType
3069        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
3070        case 351608024: /*version*/ return this.version == null ? new Base[0] : new Base[] {this.version}; // StringType
3071        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<QuestionnaireStatus>
3072        case 3076014: /*date*/ return this.date == null ? new Base[0] : new Base[] {this.date}; // DateTimeType
3073        case 1447404028: /*publisher*/ return this.publisher == null ? new Base[0] : new Base[] {this.publisher}; // StringType
3074        case -1429363305: /*telecom*/ return this.telecom == null ? new Base[0] : this.telecom.toArray(new Base[this.telecom.size()]); // ContactPoint
3075        case -669707736: /*useContext*/ return this.useContext == null ? new Base[0] : this.useContext.toArray(new Base[this.useContext.size()]); // CodeableConcept
3076        case 110371416: /*title*/ return this.title == null ? new Base[0] : new Base[] {this.title}; // StringType
3077        case 951024232: /*concept*/ return this.concept == null ? new Base[0] : this.concept.toArray(new Base[this.concept.size()]); // Coding
3078        case -603200890: /*subjectType*/ return this.subjectType == null ? new Base[0] : this.subjectType.toArray(new Base[this.subjectType.size()]); // CodeType
3079        case 3242771: /*item*/ return this.item == null ? new Base[0] : this.item.toArray(new Base[this.item.size()]); // QuestionnaireItemComponent
3080        default: return super.getProperty(hash, name, checkValid);
3081        }
3082
3083      }
3084
3085      @Override
3086      public void setProperty(int hash, String name, Base value) throws FHIRException {
3087        switch (hash) {
3088        case 116079: // url
3089          this.url = castToUri(value); // UriType
3090          break;
3091        case -1618432855: // identifier
3092          this.getIdentifier().add(castToIdentifier(value)); // Identifier
3093          break;
3094        case 351608024: // version
3095          this.version = castToString(value); // StringType
3096          break;
3097        case -892481550: // status
3098          this.status = new QuestionnaireStatusEnumFactory().fromType(value); // Enumeration<QuestionnaireStatus>
3099          break;
3100        case 3076014: // date
3101          this.date = castToDateTime(value); // DateTimeType
3102          break;
3103        case 1447404028: // publisher
3104          this.publisher = castToString(value); // StringType
3105          break;
3106        case -1429363305: // telecom
3107          this.getTelecom().add(castToContactPoint(value)); // ContactPoint
3108          break;
3109        case -669707736: // useContext
3110          this.getUseContext().add(castToCodeableConcept(value)); // CodeableConcept
3111          break;
3112        case 110371416: // title
3113          this.title = castToString(value); // StringType
3114          break;
3115        case 951024232: // concept
3116          this.getConcept().add(castToCoding(value)); // Coding
3117          break;
3118        case -603200890: // subjectType
3119          this.getSubjectType().add(castToCode(value)); // CodeType
3120          break;
3121        case 3242771: // item
3122          this.getItem().add((QuestionnaireItemComponent) value); // QuestionnaireItemComponent
3123          break;
3124        default: super.setProperty(hash, name, value);
3125        }
3126
3127      }
3128
3129      @Override
3130      public void setProperty(String name, Base value) throws FHIRException {
3131        if (name.equals("url"))
3132          this.url = castToUri(value); // UriType
3133        else if (name.equals("identifier"))
3134          this.getIdentifier().add(castToIdentifier(value));
3135        else if (name.equals("version"))
3136          this.version = castToString(value); // StringType
3137        else if (name.equals("status"))
3138          this.status = new QuestionnaireStatusEnumFactory().fromType(value); // Enumeration<QuestionnaireStatus>
3139        else if (name.equals("date"))
3140          this.date = castToDateTime(value); // DateTimeType
3141        else if (name.equals("publisher"))
3142          this.publisher = castToString(value); // StringType
3143        else if (name.equals("telecom"))
3144          this.getTelecom().add(castToContactPoint(value));
3145        else if (name.equals("useContext"))
3146          this.getUseContext().add(castToCodeableConcept(value));
3147        else if (name.equals("title"))
3148          this.title = castToString(value); // StringType
3149        else if (name.equals("concept"))
3150          this.getConcept().add(castToCoding(value));
3151        else if (name.equals("subjectType"))
3152          this.getSubjectType().add(castToCode(value));
3153        else if (name.equals("item"))
3154          this.getItem().add((QuestionnaireItemComponent) value);
3155        else
3156          super.setProperty(name, value);
3157      }
3158
3159      @Override
3160      public Base makeProperty(int hash, String name) throws FHIRException {
3161        switch (hash) {
3162        case 116079: throw new FHIRException("Cannot make property url as it is not a complex type"); // UriType
3163        case -1618432855:  return addIdentifier(); // Identifier
3164        case 351608024: throw new FHIRException("Cannot make property version as it is not a complex type"); // StringType
3165        case -892481550: throw new FHIRException("Cannot make property status as it is not a complex type"); // Enumeration<QuestionnaireStatus>
3166        case 3076014: throw new FHIRException("Cannot make property date as it is not a complex type"); // DateTimeType
3167        case 1447404028: throw new FHIRException("Cannot make property publisher as it is not a complex type"); // StringType
3168        case -1429363305:  return addTelecom(); // ContactPoint
3169        case -669707736:  return addUseContext(); // CodeableConcept
3170        case 110371416: throw new FHIRException("Cannot make property title as it is not a complex type"); // StringType
3171        case 951024232:  return addConcept(); // Coding
3172        case -603200890: throw new FHIRException("Cannot make property subjectType as it is not a complex type"); // CodeType
3173        case 3242771:  return addItem(); // QuestionnaireItemComponent
3174        default: return super.makeProperty(hash, name);
3175        }
3176
3177      }
3178
3179      @Override
3180      public Base addChild(String name) throws FHIRException {
3181        if (name.equals("url")) {
3182          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.url");
3183        }
3184        else if (name.equals("identifier")) {
3185          return addIdentifier();
3186        }
3187        else if (name.equals("version")) {
3188          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.version");
3189        }
3190        else if (name.equals("status")) {
3191          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.status");
3192        }
3193        else if (name.equals("date")) {
3194          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.date");
3195        }
3196        else if (name.equals("publisher")) {
3197          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.publisher");
3198        }
3199        else if (name.equals("telecom")) {
3200          return addTelecom();
3201        }
3202        else if (name.equals("useContext")) {
3203          return addUseContext();
3204        }
3205        else if (name.equals("title")) {
3206          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.title");
3207        }
3208        else if (name.equals("concept")) {
3209          return addConcept();
3210        }
3211        else if (name.equals("subjectType")) {
3212          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.subjectType");
3213        }
3214        else if (name.equals("item")) {
3215          return addItem();
3216        }
3217        else
3218          return super.addChild(name);
3219      }
3220
3221  public String fhirType() {
3222    return "Questionnaire";
3223
3224  }
3225
3226      public Questionnaire copy() {
3227        Questionnaire dst = new Questionnaire();
3228        copyValues(dst);
3229        dst.url = url == null ? null : url.copy();
3230        if (identifier != null) {
3231          dst.identifier = new ArrayList<Identifier>();
3232          for (Identifier i : identifier)
3233            dst.identifier.add(i.copy());
3234        };
3235        dst.version = version == null ? null : version.copy();
3236        dst.status = status == null ? null : status.copy();
3237        dst.date = date == null ? null : date.copy();
3238        dst.publisher = publisher == null ? null : publisher.copy();
3239        if (telecom != null) {
3240          dst.telecom = new ArrayList<ContactPoint>();
3241          for (ContactPoint i : telecom)
3242            dst.telecom.add(i.copy());
3243        };
3244        if (useContext != null) {
3245          dst.useContext = new ArrayList<CodeableConcept>();
3246          for (CodeableConcept i : useContext)
3247            dst.useContext.add(i.copy());
3248        };
3249        dst.title = title == null ? null : title.copy();
3250        if (concept != null) {
3251          dst.concept = new ArrayList<Coding>();
3252          for (Coding i : concept)
3253            dst.concept.add(i.copy());
3254        };
3255        if (subjectType != null) {
3256          dst.subjectType = new ArrayList<CodeType>();
3257          for (CodeType i : subjectType)
3258            dst.subjectType.add(i.copy());
3259        };
3260        if (item != null) {
3261          dst.item = new ArrayList<QuestionnaireItemComponent>();
3262          for (QuestionnaireItemComponent i : item)
3263            dst.item.add(i.copy());
3264        };
3265        return dst;
3266      }
3267
3268      protected Questionnaire typedCopy() {
3269        return copy();
3270      }
3271
3272      @Override
3273      public boolean equalsDeep(Base other) {
3274        if (!super.equalsDeep(other))
3275          return false;
3276        if (!(other instanceof Questionnaire))
3277          return false;
3278        Questionnaire o = (Questionnaire) other;
3279        return compareDeep(url, o.url, true) && compareDeep(identifier, o.identifier, true) && compareDeep(version, o.version, true)
3280           && compareDeep(status, o.status, true) && compareDeep(date, o.date, true) && compareDeep(publisher, o.publisher, true)
3281           && compareDeep(telecom, o.telecom, true) && compareDeep(useContext, o.useContext, true) && compareDeep(title, o.title, true)
3282           && compareDeep(concept, o.concept, true) && compareDeep(subjectType, o.subjectType, true) && compareDeep(item, o.item, true)
3283          ;
3284      }
3285
3286      @Override
3287      public boolean equalsShallow(Base other) {
3288        if (!super.equalsShallow(other))
3289          return false;
3290        if (!(other instanceof Questionnaire))
3291          return false;
3292        Questionnaire o = (Questionnaire) other;
3293        return compareValues(url, o.url, true) && compareValues(version, o.version, true) && compareValues(status, o.status, true)
3294           && compareValues(date, o.date, true) && compareValues(publisher, o.publisher, true) && compareValues(title, o.title, true)
3295           && compareValues(subjectType, o.subjectType, true);
3296      }
3297
3298      public boolean isEmpty() {
3299        return super.isEmpty() && (url == null || url.isEmpty()) && (identifier == null || identifier.isEmpty())
3300           && (version == null || version.isEmpty()) && (status == null || status.isEmpty()) && (date == null || date.isEmpty())
3301           && (publisher == null || publisher.isEmpty()) && (telecom == null || telecom.isEmpty()) && (useContext == null || useContext.isEmpty())
3302           && (title == null || title.isEmpty()) && (concept == null || concept.isEmpty()) && (subjectType == null || subjectType.isEmpty())
3303           && (item == null || item.isEmpty());
3304      }
3305
3306  @Override
3307  public ResourceType getResourceType() {
3308    return ResourceType.Questionnaire;
3309   }
3310
3311 /**
3312   * Search parameter: <b>title</b>
3313   * <p>
3314   * Description: <b>All or part of the name of the questionnaire</b><br>
3315   * Type: <b>string</b><br>
3316   * Path: <b>Questionnaire.title</b><br>
3317   * </p>
3318   */
3319  @SearchParamDefinition(name="title", path="Questionnaire.title", description="All or part of the name of the questionnaire", type="string" )
3320  public static final String SP_TITLE = "title";
3321 /**
3322   * <b>Fluent Client</b> search parameter constant for <b>title</b>
3323   * <p>
3324   * Description: <b>All or part of the name of the questionnaire</b><br>
3325   * Type: <b>string</b><br>
3326   * Path: <b>Questionnaire.title</b><br>
3327   * </p>
3328   */
3329  public static final ca.uhn.fhir.rest.gclient.StringClientParam TITLE = new ca.uhn.fhir.rest.gclient.StringClientParam(SP_TITLE);
3330
3331 /**
3332   * Search parameter: <b>status</b>
3333   * <p>
3334   * Description: <b>The status of the questionnaire</b><br>
3335   * Type: <b>token</b><br>
3336   * Path: <b>Questionnaire.status</b><br>
3337   * </p>
3338   */
3339  @SearchParamDefinition(name="status", path="Questionnaire.status", description="The status of the questionnaire", type="token" )
3340  public static final String SP_STATUS = "status";
3341 /**
3342   * <b>Fluent Client</b> search parameter constant for <b>status</b>
3343   * <p>
3344   * Description: <b>The status of the questionnaire</b><br>
3345   * Type: <b>token</b><br>
3346   * Path: <b>Questionnaire.status</b><br>
3347   * </p>
3348   */
3349  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
3350
3351 /**
3352   * Search parameter: <b>context</b>
3353   * <p>
3354   * Description: <b>A use context assigned to the questionnaire</b><br>
3355   * Type: <b>token</b><br>
3356   * Path: <b>Questionnaire.useContext</b><br>
3357   * </p>
3358   */
3359  @SearchParamDefinition(name="context", path="Questionnaire.useContext", description="A use context assigned to the questionnaire", type="token" )
3360  public static final String SP_CONTEXT = "context";
3361 /**
3362   * <b>Fluent Client</b> search parameter constant for <b>context</b>
3363   * <p>
3364   * Description: <b>A use context assigned to the questionnaire</b><br>
3365   * Type: <b>token</b><br>
3366   * Path: <b>Questionnaire.useContext</b><br>
3367   * </p>
3368   */
3369  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CONTEXT = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CONTEXT);
3370
3371 /**
3372   * Search parameter: <b>code</b>
3373   * <p>
3374   * Description: <b>A code that corresponds to the questionnaire or one of its groups</b><br>
3375   * Type: <b>token</b><br>
3376   * Path: <b>Questionnaire.item.concept</b><br>
3377   * </p>
3378   */
3379  @SearchParamDefinition(name="code", path="Questionnaire.item.concept", description="A code that corresponds to the questionnaire or one of its groups", type="token" )
3380  public static final String SP_CODE = "code";
3381 /**
3382   * <b>Fluent Client</b> search parameter constant for <b>code</b>
3383   * <p>
3384   * Description: <b>A code that corresponds to the questionnaire or one of its groups</b><br>
3385   * Type: <b>token</b><br>
3386   * Path: <b>Questionnaire.item.concept</b><br>
3387   * </p>
3388   */
3389  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CODE);
3390
3391 /**
3392   * Search parameter: <b>date</b>
3393   * <p>
3394   * Description: <b>When the questionnaire was last changed</b><br>
3395   * Type: <b>date</b><br>
3396   * Path: <b>Questionnaire.date</b><br>
3397   * </p>
3398   */
3399  @SearchParamDefinition(name="date", path="Questionnaire.date", description="When the questionnaire was last changed", type="date" )
3400  public static final String SP_DATE = "date";
3401 /**
3402   * <b>Fluent Client</b> search parameter constant for <b>date</b>
3403   * <p>
3404   * Description: <b>When the questionnaire was last changed</b><br>
3405   * Type: <b>date</b><br>
3406   * Path: <b>Questionnaire.date</b><br>
3407   * </p>
3408   */
3409  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATE);
3410
3411 /**
3412   * Search parameter: <b>identifier</b>
3413   * <p>
3414   * Description: <b>An identifier for the questionnaire</b><br>
3415   * Type: <b>token</b><br>
3416   * Path: <b>Questionnaire.identifier</b><br>
3417   * </p>
3418   */
3419  @SearchParamDefinition(name="identifier", path="Questionnaire.identifier", description="An identifier for the questionnaire", type="token" )
3420  public static final String SP_IDENTIFIER = "identifier";
3421 /**
3422   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
3423   * <p>
3424   * Description: <b>An identifier for the questionnaire</b><br>
3425   * Type: <b>token</b><br>
3426   * Path: <b>Questionnaire.identifier</b><br>
3427   * </p>
3428   */
3429  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
3430
3431 /**
3432   * Search parameter: <b>version</b>
3433   * <p>
3434   * Description: <b>The business version of the questionnaire</b><br>
3435   * Type: <b>string</b><br>
3436   * Path: <b>Questionnaire.version</b><br>
3437   * </p>
3438   */
3439  @SearchParamDefinition(name="version", path="Questionnaire.version", description="The business version of the questionnaire", type="string" )
3440  public static final String SP_VERSION = "version";
3441 /**
3442   * <b>Fluent Client</b> search parameter constant for <b>version</b>
3443   * <p>
3444   * Description: <b>The business version of the questionnaire</b><br>
3445   * Type: <b>string</b><br>
3446   * Path: <b>Questionnaire.version</b><br>
3447   * </p>
3448   */
3449  public static final ca.uhn.fhir.rest.gclient.StringClientParam VERSION = new ca.uhn.fhir.rest.gclient.StringClientParam(SP_VERSION);
3450
3451 /**
3452   * Search parameter: <b>publisher</b>
3453   * <p>
3454   * Description: <b>The author of the questionnaire</b><br>
3455   * Type: <b>string</b><br>
3456   * Path: <b>Questionnaire.publisher</b><br>
3457   * </p>
3458   */
3459  @SearchParamDefinition(name="publisher", path="Questionnaire.publisher", description="The author of the questionnaire", type="string" )
3460  public static final String SP_PUBLISHER = "publisher";
3461 /**
3462   * <b>Fluent Client</b> search parameter constant for <b>publisher</b>
3463   * <p>
3464   * Description: <b>The author of the questionnaire</b><br>
3465   * Type: <b>string</b><br>
3466   * Path: <b>Questionnaire.publisher</b><br>
3467   * </p>
3468   */
3469  public static final ca.uhn.fhir.rest.gclient.StringClientParam PUBLISHER = new ca.uhn.fhir.rest.gclient.StringClientParam(SP_PUBLISHER);
3470
3471
3472}
3473