001package org.hl7.fhir.instance.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 Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
033import java.util.*;
034
035import org.hl7.fhir.exceptions.FHIRException;
036import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
037import org.hl7.fhir.utilities.Utilities;
038
039import ca.uhn.fhir.model.api.annotation.*;
040/**
041 * 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.
042 */
043@ResourceDef(name="Questionnaire", profile="http://hl7.org/fhir/Profile/Questionnaire")
044public class Questionnaire extends DomainResource {
045
046    public enum QuestionnaireStatus {
047        /**
048         * This Questionnaire is not ready for official use.
049         */
050        DRAFT, 
051        /**
052         * This Questionnaire is ready for use.
053         */
054        PUBLISHED, 
055        /**
056         * This Questionnaire should no longer be used to gather data.
057         */
058        RETIRED, 
059        /**
060         * added to help the parsers
061         */
062        NULL;
063        public static QuestionnaireStatus fromCode(String codeString) throws FHIRException {
064            if (codeString == null || "".equals(codeString))
065                return null;
066        if ("draft".equals(codeString))
067          return DRAFT;
068        if ("published".equals(codeString))
069          return PUBLISHED;
070        if ("retired".equals(codeString))
071          return RETIRED;
072        throw new FHIRException("Unknown QuestionnaireStatus code '"+codeString+"'");
073        }
074        public String toCode() {
075          switch (this) {
076            case DRAFT: return "draft";
077            case PUBLISHED: return "published";
078            case RETIRED: return "retired";
079            default: return "?";
080          }
081        }
082        public String getSystem() {
083          switch (this) {
084            case DRAFT: return "http://hl7.org/fhir/questionnaire-status";
085            case PUBLISHED: return "http://hl7.org/fhir/questionnaire-status";
086            case RETIRED: return "http://hl7.org/fhir/questionnaire-status";
087            default: return "?";
088          }
089        }
090        public String getDefinition() {
091          switch (this) {
092            case DRAFT: return "This Questionnaire is not ready for official use.";
093            case PUBLISHED: return "This Questionnaire is ready for use.";
094            case RETIRED: return "This Questionnaire should no longer be used to gather data.";
095            default: return "?";
096          }
097        }
098        public String getDisplay() {
099          switch (this) {
100            case DRAFT: return "Draft";
101            case PUBLISHED: return "Published";
102            case RETIRED: return "Retired";
103            default: return "?";
104          }
105        }
106    }
107
108  public static class QuestionnaireStatusEnumFactory implements EnumFactory<QuestionnaireStatus> {
109    public QuestionnaireStatus fromCode(String codeString) throws IllegalArgumentException {
110      if (codeString == null || "".equals(codeString))
111            if (codeString == null || "".equals(codeString))
112                return null;
113        if ("draft".equals(codeString))
114          return QuestionnaireStatus.DRAFT;
115        if ("published".equals(codeString))
116          return QuestionnaireStatus.PUBLISHED;
117        if ("retired".equals(codeString))
118          return QuestionnaireStatus.RETIRED;
119        throw new IllegalArgumentException("Unknown QuestionnaireStatus code '"+codeString+"'");
120        }
121        public Enumeration<QuestionnaireStatus> fromType(Base code) throws FHIRException {
122          if (code == null || code.isEmpty())
123            return null;
124          String codeString = ((PrimitiveType) code).asStringValue();
125          if (codeString == null || "".equals(codeString))
126            return null;
127        if ("draft".equals(codeString))
128          return new Enumeration<QuestionnaireStatus>(this, QuestionnaireStatus.DRAFT);
129        if ("published".equals(codeString))
130          return new Enumeration<QuestionnaireStatus>(this, QuestionnaireStatus.PUBLISHED);
131        if ("retired".equals(codeString))
132          return new Enumeration<QuestionnaireStatus>(this, QuestionnaireStatus.RETIRED);
133        throw new FHIRException("Unknown QuestionnaireStatus code '"+codeString+"'");
134        }
135    public String toCode(QuestionnaireStatus code) {
136      if (code == QuestionnaireStatus.DRAFT)
137        return "draft";
138      if (code == QuestionnaireStatus.PUBLISHED)
139        return "published";
140      if (code == QuestionnaireStatus.RETIRED)
141        return "retired";
142      return "?";
143      }
144    }
145
146    public enum AnswerFormat {
147        /**
148         * Answer is a yes/no answer.
149         */
150        BOOLEAN, 
151        /**
152         * Answer is a floating point number.
153         */
154        DECIMAL, 
155        /**
156         * Answer is an integer.
157         */
158        INTEGER, 
159        /**
160         * Answer is a date.
161         */
162        DATE, 
163        /**
164         * Answer is a date and time.
165         */
166        DATETIME, 
167        /**
168         * Answer is a system timestamp.
169         */
170        INSTANT, 
171        /**
172         * Answer is a time (hour/minute/second) independent of date.
173         */
174        TIME, 
175        /**
176         * Answer is a short (few words to short sentence) free-text entry.
177         */
178        STRING, 
179        /**
180         * Answer is a long (potentially multi-paragraph) free-text entry (still captured as a string).
181         */
182        TEXT, 
183        /**
184         * Answer is a url (website, FTP site, etc.).
185         */
186        URL, 
187        /**
188         * Answer is a Coding drawn from a list of options.
189         */
190        CHOICE, 
191        /**
192         * Answer is a Coding drawn from a list of options or a free-text entry.
193         */
194        OPENCHOICE, 
195        /**
196         * Answer is binary content such as a image, PDF, etc.
197         */
198        ATTACHMENT, 
199        /**
200         * Answer is a reference to another resource (practitioner, organization, etc.).
201         */
202        REFERENCE, 
203        /**
204         * Answer is a combination of a numeric value and unit, potentially with a comparator (<, >, etc.).
205         */
206        QUANTITY, 
207        /**
208         * added to help the parsers
209         */
210        NULL;
211        public static AnswerFormat fromCode(String codeString) throws FHIRException {
212            if (codeString == null || "".equals(codeString))
213                return null;
214        if ("boolean".equals(codeString))
215          return BOOLEAN;
216        if ("decimal".equals(codeString))
217          return DECIMAL;
218        if ("integer".equals(codeString))
219          return INTEGER;
220        if ("date".equals(codeString))
221          return DATE;
222        if ("dateTime".equals(codeString))
223          return DATETIME;
224        if ("instant".equals(codeString))
225          return INSTANT;
226        if ("time".equals(codeString))
227          return TIME;
228        if ("string".equals(codeString))
229          return STRING;
230        if ("text".equals(codeString))
231          return TEXT;
232        if ("url".equals(codeString))
233          return URL;
234        if ("choice".equals(codeString))
235          return CHOICE;
236        if ("open-choice".equals(codeString))
237          return OPENCHOICE;
238        if ("attachment".equals(codeString))
239          return ATTACHMENT;
240        if ("reference".equals(codeString))
241          return REFERENCE;
242        if ("quantity".equals(codeString))
243          return QUANTITY;
244        throw new FHIRException("Unknown AnswerFormat code '"+codeString+"'");
245        }
246        public String toCode() {
247          switch (this) {
248            case BOOLEAN: return "boolean";
249            case DECIMAL: return "decimal";
250            case INTEGER: return "integer";
251            case DATE: return "date";
252            case DATETIME: return "dateTime";
253            case INSTANT: return "instant";
254            case TIME: return "time";
255            case STRING: return "string";
256            case TEXT: return "text";
257            case URL: return "url";
258            case CHOICE: return "choice";
259            case OPENCHOICE: return "open-choice";
260            case ATTACHMENT: return "attachment";
261            case REFERENCE: return "reference";
262            case QUANTITY: return "quantity";
263            default: return "?";
264          }
265        }
266        public String getSystem() {
267          switch (this) {
268            case BOOLEAN: return "http://hl7.org/fhir/answer-format";
269            case DECIMAL: return "http://hl7.org/fhir/answer-format";
270            case INTEGER: return "http://hl7.org/fhir/answer-format";
271            case DATE: return "http://hl7.org/fhir/answer-format";
272            case DATETIME: return "http://hl7.org/fhir/answer-format";
273            case INSTANT: return "http://hl7.org/fhir/answer-format";
274            case TIME: return "http://hl7.org/fhir/answer-format";
275            case STRING: return "http://hl7.org/fhir/answer-format";
276            case TEXT: return "http://hl7.org/fhir/answer-format";
277            case URL: return "http://hl7.org/fhir/answer-format";
278            case CHOICE: return "http://hl7.org/fhir/answer-format";
279            case OPENCHOICE: return "http://hl7.org/fhir/answer-format";
280            case ATTACHMENT: return "http://hl7.org/fhir/answer-format";
281            case REFERENCE: return "http://hl7.org/fhir/answer-format";
282            case QUANTITY: return "http://hl7.org/fhir/answer-format";
283            default: return "?";
284          }
285        }
286        public String getDefinition() {
287          switch (this) {
288            case BOOLEAN: return "Answer is a yes/no answer.";
289            case DECIMAL: return "Answer is a floating point number.";
290            case INTEGER: return "Answer is an integer.";
291            case DATE: return "Answer is a date.";
292            case DATETIME: return "Answer is a date and time.";
293            case INSTANT: return "Answer is a system timestamp.";
294            case TIME: return "Answer is a time (hour/minute/second) independent of date.";
295            case STRING: return "Answer is a short (few words to short sentence) free-text entry.";
296            case TEXT: return "Answer is a long (potentially multi-paragraph) free-text entry (still captured as a string).";
297            case URL: return "Answer is a url (website, FTP site, etc.).";
298            case CHOICE: return "Answer is a Coding drawn from a list of options.";
299            case OPENCHOICE: return "Answer is a Coding drawn from a list of options or a free-text entry.";
300            case ATTACHMENT: return "Answer is binary content such as a image, PDF, etc.";
301            case REFERENCE: return "Answer is a reference to another resource (practitioner, organization, etc.).";
302            case QUANTITY: return "Answer is a combination of a numeric value and unit, potentially with a comparator (<, >, etc.).";
303            default: return "?";
304          }
305        }
306        public String getDisplay() {
307          switch (this) {
308            case BOOLEAN: return "Boolean";
309            case DECIMAL: return "Decimal";
310            case INTEGER: return "Integer";
311            case DATE: return "Date";
312            case DATETIME: return "Date Time";
313            case INSTANT: return "Instant";
314            case TIME: return "Time";
315            case STRING: return "String";
316            case TEXT: return "Text";
317            case URL: return "Url";
318            case CHOICE: return "Choice";
319            case OPENCHOICE: return "Open Choice";
320            case ATTACHMENT: return "Attachment";
321            case REFERENCE: return "Reference";
322            case QUANTITY: return "Quantity";
323            default: return "?";
324          }
325        }
326    }
327
328  public static class AnswerFormatEnumFactory implements EnumFactory<AnswerFormat> {
329    public AnswerFormat fromCode(String codeString) throws IllegalArgumentException {
330      if (codeString == null || "".equals(codeString))
331            if (codeString == null || "".equals(codeString))
332                return null;
333        if ("boolean".equals(codeString))
334          return AnswerFormat.BOOLEAN;
335        if ("decimal".equals(codeString))
336          return AnswerFormat.DECIMAL;
337        if ("integer".equals(codeString))
338          return AnswerFormat.INTEGER;
339        if ("date".equals(codeString))
340          return AnswerFormat.DATE;
341        if ("dateTime".equals(codeString))
342          return AnswerFormat.DATETIME;
343        if ("instant".equals(codeString))
344          return AnswerFormat.INSTANT;
345        if ("time".equals(codeString))
346          return AnswerFormat.TIME;
347        if ("string".equals(codeString))
348          return AnswerFormat.STRING;
349        if ("text".equals(codeString))
350          return AnswerFormat.TEXT;
351        if ("url".equals(codeString))
352          return AnswerFormat.URL;
353        if ("choice".equals(codeString))
354          return AnswerFormat.CHOICE;
355        if ("open-choice".equals(codeString))
356          return AnswerFormat.OPENCHOICE;
357        if ("attachment".equals(codeString))
358          return AnswerFormat.ATTACHMENT;
359        if ("reference".equals(codeString))
360          return AnswerFormat.REFERENCE;
361        if ("quantity".equals(codeString))
362          return AnswerFormat.QUANTITY;
363        throw new IllegalArgumentException("Unknown AnswerFormat code '"+codeString+"'");
364        }
365        public Enumeration<AnswerFormat> fromType(Base code) throws FHIRException {
366          if (code == null || code.isEmpty())
367            return null;
368          String codeString = ((PrimitiveType) code).asStringValue();
369          if (codeString == null || "".equals(codeString))
370            return null;
371        if ("boolean".equals(codeString))
372          return new Enumeration<AnswerFormat>(this, AnswerFormat.BOOLEAN);
373        if ("decimal".equals(codeString))
374          return new Enumeration<AnswerFormat>(this, AnswerFormat.DECIMAL);
375        if ("integer".equals(codeString))
376          return new Enumeration<AnswerFormat>(this, AnswerFormat.INTEGER);
377        if ("date".equals(codeString))
378          return new Enumeration<AnswerFormat>(this, AnswerFormat.DATE);
379        if ("dateTime".equals(codeString))
380          return new Enumeration<AnswerFormat>(this, AnswerFormat.DATETIME);
381        if ("instant".equals(codeString))
382          return new Enumeration<AnswerFormat>(this, AnswerFormat.INSTANT);
383        if ("time".equals(codeString))
384          return new Enumeration<AnswerFormat>(this, AnswerFormat.TIME);
385        if ("string".equals(codeString))
386          return new Enumeration<AnswerFormat>(this, AnswerFormat.STRING);
387        if ("text".equals(codeString))
388          return new Enumeration<AnswerFormat>(this, AnswerFormat.TEXT);
389        if ("url".equals(codeString))
390          return new Enumeration<AnswerFormat>(this, AnswerFormat.URL);
391        if ("choice".equals(codeString))
392          return new Enumeration<AnswerFormat>(this, AnswerFormat.CHOICE);
393        if ("open-choice".equals(codeString))
394          return new Enumeration<AnswerFormat>(this, AnswerFormat.OPENCHOICE);
395        if ("attachment".equals(codeString))
396          return new Enumeration<AnswerFormat>(this, AnswerFormat.ATTACHMENT);
397        if ("reference".equals(codeString))
398          return new Enumeration<AnswerFormat>(this, AnswerFormat.REFERENCE);
399        if ("quantity".equals(codeString))
400          return new Enumeration<AnswerFormat>(this, AnswerFormat.QUANTITY);
401        throw new FHIRException("Unknown AnswerFormat code '"+codeString+"'");
402        }
403    public String toCode(AnswerFormat code) {
404      if (code == AnswerFormat.BOOLEAN)
405        return "boolean";
406      if (code == AnswerFormat.DECIMAL)
407        return "decimal";
408      if (code == AnswerFormat.INTEGER)
409        return "integer";
410      if (code == AnswerFormat.DATE)
411        return "date";
412      if (code == AnswerFormat.DATETIME)
413        return "dateTime";
414      if (code == AnswerFormat.INSTANT)
415        return "instant";
416      if (code == AnswerFormat.TIME)
417        return "time";
418      if (code == AnswerFormat.STRING)
419        return "string";
420      if (code == AnswerFormat.TEXT)
421        return "text";
422      if (code == AnswerFormat.URL)
423        return "url";
424      if (code == AnswerFormat.CHOICE)
425        return "choice";
426      if (code == AnswerFormat.OPENCHOICE)
427        return "open-choice";
428      if (code == AnswerFormat.ATTACHMENT)
429        return "attachment";
430      if (code == AnswerFormat.REFERENCE)
431        return "reference";
432      if (code == AnswerFormat.QUANTITY)
433        return "quantity";
434      return "?";
435      }
436    }
437
438    @Block()
439    public static class GroupComponent extends BackboneElement implements IBaseBackboneElement {
440        /**
441         * An identifier that is unique within the Questionnaire allowing linkage to the equivalent group in a QuestionnaireResponse resource.
442         */
443        @Child(name = "linkId", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=false)
444        @Description(shortDefinition="To link questionnaire with questionnaire response", formalDefinition="An identifier that is unique within the Questionnaire allowing linkage to the equivalent group in a QuestionnaireResponse resource." )
445        protected StringType linkId;
446
447        /**
448         * The human-readable name for this section of the questionnaire.
449         */
450        @Child(name = "title", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=true)
451        @Description(shortDefinition="Name to be displayed for group", formalDefinition="The human-readable name for this section of the questionnaire." )
452        protected StringType title;
453
454        /**
455         * Identifies a how this group of questions is known in a particular terminology such as LOINC.
456         */
457        @Child(name = "concept", type = {Coding.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
458        @Description(shortDefinition="Concept that represents this section in a questionnaire", formalDefinition="Identifies a how this group of questions is known in a particular terminology such as LOINC." )
459        protected List<Coding> concept;
460
461        /**
462         * Additional text for the group, used for display purposes.
463         */
464        @Child(name = "text", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=false)
465        @Description(shortDefinition="Additional text for the group", formalDefinition="Additional text for the group, used for display purposes." )
466        protected StringType text;
467
468        /**
469         * If true, indicates that the group must be present and have required questions within it answered.  If false, the group may be skipped when answering the questionnaire.
470         */
471        @Child(name = "required", type = {BooleanType.class}, order=5, min=0, max=1, modifier=false, summary=false)
472        @Description(shortDefinition="Whether the group must be included in data results", formalDefinition="If true, indicates that the group must be present and have required questions within it answered.  If false, the group may be skipped when answering the questionnaire." )
473        protected BooleanType required;
474
475        /**
476         * Whether the group may occur multiple times in the instance, containing multiple sets of answers.
477         */
478        @Child(name = "repeats", type = {BooleanType.class}, order=6, min=0, max=1, modifier=false, summary=false)
479        @Description(shortDefinition="Whether the group may repeat", formalDefinition="Whether the group may occur multiple times in the instance, containing multiple sets of answers." )
480        protected BooleanType repeats;
481
482        /**
483         * A sub-group within a group. The ordering of groups within this group is relevant.
484         */
485        @Child(name = "group", type = {GroupComponent.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
486        @Description(shortDefinition="Nested questionnaire group", formalDefinition="A sub-group within a group. The ordering of groups within this group is relevant." )
487        protected List<GroupComponent> group;
488
489        /**
490         * Set of questions within this group. The order of questions within the group is relevant.
491         */
492        @Child(name = "question", type = {}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
493        @Description(shortDefinition="Questions in this group", formalDefinition="Set of questions within this group. The order of questions within the group is relevant." )
494        protected List<QuestionComponent> question;
495
496        private static final long serialVersionUID = 494129548L;
497
498    /*
499     * Constructor
500     */
501      public GroupComponent() {
502        super();
503      }
504
505        /**
506         * @return {@link #linkId} (An identifier that is unique within the Questionnaire allowing linkage to the equivalent group in a QuestionnaireResponse resource.). This is the underlying object with id, value and extensions. The accessor "getLinkId" gives direct access to the value
507         */
508        public StringType getLinkIdElement() { 
509          if (this.linkId == null)
510            if (Configuration.errorOnAutoCreate())
511              throw new Error("Attempt to auto-create GroupComponent.linkId");
512            else if (Configuration.doAutoCreate())
513              this.linkId = new StringType(); // bb
514          return this.linkId;
515        }
516
517        public boolean hasLinkIdElement() { 
518          return this.linkId != null && !this.linkId.isEmpty();
519        }
520
521        public boolean hasLinkId() { 
522          return this.linkId != null && !this.linkId.isEmpty();
523        }
524
525        /**
526         * @param value {@link #linkId} (An identifier that is unique within the Questionnaire allowing linkage to the equivalent group in a QuestionnaireResponse resource.). This is the underlying object with id, value and extensions. The accessor "getLinkId" gives direct access to the value
527         */
528        public GroupComponent setLinkIdElement(StringType value) { 
529          this.linkId = value;
530          return this;
531        }
532
533        /**
534         * @return An identifier that is unique within the Questionnaire allowing linkage to the equivalent group in a QuestionnaireResponse resource.
535         */
536        public String getLinkId() { 
537          return this.linkId == null ? null : this.linkId.getValue();
538        }
539
540        /**
541         * @param value An identifier that is unique within the Questionnaire allowing linkage to the equivalent group in a QuestionnaireResponse resource.
542         */
543        public GroupComponent setLinkId(String value) { 
544          if (Utilities.noString(value))
545            this.linkId = null;
546          else {
547            if (this.linkId == null)
548              this.linkId = new StringType();
549            this.linkId.setValue(value);
550          }
551          return this;
552        }
553
554        /**
555         * @return {@link #title} (The human-readable name for this section of the questionnaire.). This is the underlying object with id, value and extensions. The accessor "getTitle" gives direct access to the value
556         */
557        public StringType getTitleElement() { 
558          if (this.title == null)
559            if (Configuration.errorOnAutoCreate())
560              throw new Error("Attempt to auto-create GroupComponent.title");
561            else if (Configuration.doAutoCreate())
562              this.title = new StringType(); // bb
563          return this.title;
564        }
565
566        public boolean hasTitleElement() { 
567          return this.title != null && !this.title.isEmpty();
568        }
569
570        public boolean hasTitle() { 
571          return this.title != null && !this.title.isEmpty();
572        }
573
574        /**
575         * @param value {@link #title} (The human-readable name for this section of the questionnaire.). This is the underlying object with id, value and extensions. The accessor "getTitle" gives direct access to the value
576         */
577        public GroupComponent setTitleElement(StringType value) { 
578          this.title = value;
579          return this;
580        }
581
582        /**
583         * @return The human-readable name for this section of the questionnaire.
584         */
585        public String getTitle() { 
586          return this.title == null ? null : this.title.getValue();
587        }
588
589        /**
590         * @param value The human-readable name for this section of the questionnaire.
591         */
592        public GroupComponent setTitle(String value) { 
593          if (Utilities.noString(value))
594            this.title = null;
595          else {
596            if (this.title == null)
597              this.title = new StringType();
598            this.title.setValue(value);
599          }
600          return this;
601        }
602
603        /**
604         * @return {@link #concept} (Identifies a how this group of questions is known in a particular terminology such as LOINC.)
605         */
606        public List<Coding> getConcept() { 
607          if (this.concept == null)
608            this.concept = new ArrayList<Coding>();
609          return this.concept;
610        }
611
612        public boolean hasConcept() { 
613          if (this.concept == null)
614            return false;
615          for (Coding item : this.concept)
616            if (!item.isEmpty())
617              return true;
618          return false;
619        }
620
621        /**
622         * @return {@link #concept} (Identifies a how this group of questions is known in a particular terminology such as LOINC.)
623         */
624    // syntactic sugar
625        public Coding addConcept() { //3
626          Coding t = new Coding();
627          if (this.concept == null)
628            this.concept = new ArrayList<Coding>();
629          this.concept.add(t);
630          return t;
631        }
632
633    // syntactic sugar
634        public GroupComponent addConcept(Coding t) { //3
635          if (t == null)
636            return this;
637          if (this.concept == null)
638            this.concept = new ArrayList<Coding>();
639          this.concept.add(t);
640          return this;
641        }
642
643        /**
644         * @return {@link #text} (Additional text for the group, used for display purposes.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value
645         */
646        public StringType getTextElement() { 
647          if (this.text == null)
648            if (Configuration.errorOnAutoCreate())
649              throw new Error("Attempt to auto-create GroupComponent.text");
650            else if (Configuration.doAutoCreate())
651              this.text = new StringType(); // bb
652          return this.text;
653        }
654
655        public boolean hasTextElement() { 
656          return this.text != null && !this.text.isEmpty();
657        }
658
659        public boolean hasText() { 
660          return this.text != null && !this.text.isEmpty();
661        }
662
663        /**
664         * @param value {@link #text} (Additional text for the group, used for display purposes.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value
665         */
666        public GroupComponent setTextElement(StringType value) { 
667          this.text = value;
668          return this;
669        }
670
671        /**
672         * @return Additional text for the group, used for display purposes.
673         */
674        public String getText() { 
675          return this.text == null ? null : this.text.getValue();
676        }
677
678        /**
679         * @param value Additional text for the group, used for display purposes.
680         */
681        public GroupComponent setText(String value) { 
682          if (Utilities.noString(value))
683            this.text = null;
684          else {
685            if (this.text == null)
686              this.text = new StringType();
687            this.text.setValue(value);
688          }
689          return this;
690        }
691
692        /**
693         * @return {@link #required} (If true, indicates that the group must be present and have required questions within it answered.  If false, the group 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
694         */
695        public BooleanType getRequiredElement() { 
696          if (this.required == null)
697            if (Configuration.errorOnAutoCreate())
698              throw new Error("Attempt to auto-create GroupComponent.required");
699            else if (Configuration.doAutoCreate())
700              this.required = new BooleanType(); // bb
701          return this.required;
702        }
703
704        public boolean hasRequiredElement() { 
705          return this.required != null && !this.required.isEmpty();
706        }
707
708        public boolean hasRequired() { 
709          return this.required != null && !this.required.isEmpty();
710        }
711
712        /**
713         * @param value {@link #required} (If true, indicates that the group must be present and have required questions within it answered.  If false, the group 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
714         */
715        public GroupComponent setRequiredElement(BooleanType value) { 
716          this.required = value;
717          return this;
718        }
719
720        /**
721         * @return If true, indicates that the group must be present and have required questions within it answered.  If false, the group may be skipped when answering the questionnaire.
722         */
723        public boolean getRequired() { 
724          return this.required == null || this.required.isEmpty() ? false : this.required.getValue();
725        }
726
727        /**
728         * @param value If true, indicates that the group must be present and have required questions within it answered.  If false, the group may be skipped when answering the questionnaire.
729         */
730        public GroupComponent setRequired(boolean value) { 
731            if (this.required == null)
732              this.required = new BooleanType();
733            this.required.setValue(value);
734          return this;
735        }
736
737        /**
738         * @return {@link #repeats} (Whether the group 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
739         */
740        public BooleanType getRepeatsElement() { 
741          if (this.repeats == null)
742            if (Configuration.errorOnAutoCreate())
743              throw new Error("Attempt to auto-create GroupComponent.repeats");
744            else if (Configuration.doAutoCreate())
745              this.repeats = new BooleanType(); // bb
746          return this.repeats;
747        }
748
749        public boolean hasRepeatsElement() { 
750          return this.repeats != null && !this.repeats.isEmpty();
751        }
752
753        public boolean hasRepeats() { 
754          return this.repeats != null && !this.repeats.isEmpty();
755        }
756
757        /**
758         * @param value {@link #repeats} (Whether the group 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
759         */
760        public GroupComponent setRepeatsElement(BooleanType value) { 
761          this.repeats = value;
762          return this;
763        }
764
765        /**
766         * @return Whether the group may occur multiple times in the instance, containing multiple sets of answers.
767         */
768        public boolean getRepeats() { 
769          return this.repeats == null || this.repeats.isEmpty() ? false : this.repeats.getValue();
770        }
771
772        /**
773         * @param value Whether the group may occur multiple times in the instance, containing multiple sets of answers.
774         */
775        public GroupComponent setRepeats(boolean value) { 
776            if (this.repeats == null)
777              this.repeats = new BooleanType();
778            this.repeats.setValue(value);
779          return this;
780        }
781
782        /**
783         * @return {@link #group} (A sub-group within a group. The ordering of groups within this group is relevant.)
784         */
785        public List<GroupComponent> getGroup() { 
786          if (this.group == null)
787            this.group = new ArrayList<GroupComponent>();
788          return this.group;
789        }
790
791        public boolean hasGroup() { 
792          if (this.group == null)
793            return false;
794          for (GroupComponent item : this.group)
795            if (!item.isEmpty())
796              return true;
797          return false;
798        }
799
800        /**
801         * @return {@link #group} (A sub-group within a group. The ordering of groups within this group is relevant.)
802         */
803    // syntactic sugar
804        public GroupComponent addGroup() { //3
805          GroupComponent t = new GroupComponent();
806          if (this.group == null)
807            this.group = new ArrayList<GroupComponent>();
808          this.group.add(t);
809          return t;
810        }
811
812    // syntactic sugar
813        public GroupComponent addGroup(GroupComponent t) { //3
814          if (t == null)
815            return this;
816          if (this.group == null)
817            this.group = new ArrayList<GroupComponent>();
818          this.group.add(t);
819          return this;
820        }
821
822        /**
823         * @return {@link #question} (Set of questions within this group. The order of questions within the group is relevant.)
824         */
825        public List<QuestionComponent> getQuestion() { 
826          if (this.question == null)
827            this.question = new ArrayList<QuestionComponent>();
828          return this.question;
829        }
830
831        public boolean hasQuestion() { 
832          if (this.question == null)
833            return false;
834          for (QuestionComponent item : this.question)
835            if (!item.isEmpty())
836              return true;
837          return false;
838        }
839
840        /**
841         * @return {@link #question} (Set of questions within this group. The order of questions within the group is relevant.)
842         */
843    // syntactic sugar
844        public QuestionComponent addQuestion() { //3
845          QuestionComponent t = new QuestionComponent();
846          if (this.question == null)
847            this.question = new ArrayList<QuestionComponent>();
848          this.question.add(t);
849          return t;
850        }
851
852    // syntactic sugar
853        public GroupComponent addQuestion(QuestionComponent t) { //3
854          if (t == null)
855            return this;
856          if (this.question == null)
857            this.question = new ArrayList<QuestionComponent>();
858          this.question.add(t);
859          return this;
860        }
861
862        protected void listChildren(List<Property> childrenList) {
863          super.listChildren(childrenList);
864          childrenList.add(new Property("linkId", "string", "An identifier that is unique within the Questionnaire allowing linkage to the equivalent group in a QuestionnaireResponse resource.", 0, java.lang.Integer.MAX_VALUE, linkId));
865          childrenList.add(new Property("title", "string", "The human-readable name for this section of the questionnaire.", 0, java.lang.Integer.MAX_VALUE, title));
866          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));
867          childrenList.add(new Property("text", "string", "Additional text for the group, used for display purposes.", 0, java.lang.Integer.MAX_VALUE, text));
868          childrenList.add(new Property("required", "boolean", "If true, indicates that the group must be present and have required questions within it answered.  If false, the group may be skipped when answering the questionnaire.", 0, java.lang.Integer.MAX_VALUE, required));
869          childrenList.add(new Property("repeats", "boolean", "Whether the group may occur multiple times in the instance, containing multiple sets of answers.", 0, java.lang.Integer.MAX_VALUE, repeats));
870          childrenList.add(new Property("group", "@Questionnaire.group", "A sub-group within a group. The ordering of groups within this group is relevant.", 0, java.lang.Integer.MAX_VALUE, group));
871          childrenList.add(new Property("question", "", "Set of questions within this group. The order of questions within the group is relevant.", 0, java.lang.Integer.MAX_VALUE, question));
872        }
873
874      @Override
875      public void setProperty(String name, Base value) throws FHIRException {
876        if (name.equals("linkId"))
877          this.linkId = castToString(value); // StringType
878        else if (name.equals("title"))
879          this.title = castToString(value); // StringType
880        else if (name.equals("concept"))
881          this.getConcept().add(castToCoding(value));
882        else if (name.equals("text"))
883          this.text = castToString(value); // StringType
884        else if (name.equals("required"))
885          this.required = castToBoolean(value); // BooleanType
886        else if (name.equals("repeats"))
887          this.repeats = castToBoolean(value); // BooleanType
888        else if (name.equals("group"))
889          this.getGroup().add((GroupComponent) value);
890        else if (name.equals("question"))
891          this.getQuestion().add((QuestionComponent) value);
892        else
893          super.setProperty(name, value);
894      }
895
896      @Override
897      public Base addChild(String name) throws FHIRException {
898        if (name.equals("linkId")) {
899          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.linkId");
900        }
901        else if (name.equals("title")) {
902          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.title");
903        }
904        else if (name.equals("concept")) {
905          return addConcept();
906        }
907        else if (name.equals("text")) {
908          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.text");
909        }
910        else if (name.equals("required")) {
911          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.required");
912        }
913        else if (name.equals("repeats")) {
914          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.repeats");
915        }
916        else if (name.equals("group")) {
917          return addGroup();
918        }
919        else if (name.equals("question")) {
920          return addQuestion();
921        }
922        else
923          return super.addChild(name);
924      }
925
926      public GroupComponent copy() {
927        GroupComponent dst = new GroupComponent();
928        copyValues(dst);
929        dst.linkId = linkId == null ? null : linkId.copy();
930        dst.title = title == null ? null : title.copy();
931        if (concept != null) {
932          dst.concept = new ArrayList<Coding>();
933          for (Coding i : concept)
934            dst.concept.add(i.copy());
935        };
936        dst.text = text == null ? null : text.copy();
937        dst.required = required == null ? null : required.copy();
938        dst.repeats = repeats == null ? null : repeats.copy();
939        if (group != null) {
940          dst.group = new ArrayList<GroupComponent>();
941          for (GroupComponent i : group)
942            dst.group.add(i.copy());
943        };
944        if (question != null) {
945          dst.question = new ArrayList<QuestionComponent>();
946          for (QuestionComponent i : question)
947            dst.question.add(i.copy());
948        };
949        return dst;
950      }
951
952      @Override
953      public boolean equalsDeep(Base other) {
954        if (!super.equalsDeep(other))
955          return false;
956        if (!(other instanceof GroupComponent))
957          return false;
958        GroupComponent o = (GroupComponent) other;
959        return compareDeep(linkId, o.linkId, true) && compareDeep(title, o.title, true) && compareDeep(concept, o.concept, true)
960           && compareDeep(text, o.text, true) && compareDeep(required, o.required, true) && compareDeep(repeats, o.repeats, true)
961           && compareDeep(group, o.group, true) && compareDeep(question, o.question, true);
962      }
963
964      @Override
965      public boolean equalsShallow(Base other) {
966        if (!super.equalsShallow(other))
967          return false;
968        if (!(other instanceof GroupComponent))
969          return false;
970        GroupComponent o = (GroupComponent) other;
971        return compareValues(linkId, o.linkId, true) && compareValues(title, o.title, true) && compareValues(text, o.text, true)
972           && compareValues(required, o.required, true) && compareValues(repeats, o.repeats, true);
973      }
974
975      public boolean isEmpty() {
976        return super.isEmpty() && (linkId == null || linkId.isEmpty()) && (title == null || title.isEmpty())
977           && (concept == null || concept.isEmpty()) && (text == null || text.isEmpty()) && (required == null || required.isEmpty())
978           && (repeats == null || repeats.isEmpty()) && (group == null || group.isEmpty()) && (question == null || question.isEmpty())
979          ;
980      }
981
982  public String fhirType() {
983    return "Questionnaire.group";
984
985  }
986
987  }
988
989    @Block()
990    public static class QuestionComponent extends BackboneElement implements IBaseBackboneElement {
991        /**
992         * An identifier that is unique within the questionnaire allowing linkage to the equivalent group in a [[[QuestionnaireResponse]]] resource.
993         */
994        @Child(name = "linkId", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=false)
995        @Description(shortDefinition="To link questionnaire with questionnaire response", formalDefinition="An identifier that is unique within the questionnaire allowing linkage to the equivalent group in a [[[QuestionnaireResponse]]] resource." )
996        protected StringType linkId;
997
998        /**
999         * Identifies a how this question is known in a particular terminology such as LOINC.
1000         */
1001        @Child(name = "concept", type = {Coding.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1002        @Description(shortDefinition="Concept that represents this question on a questionnaire", formalDefinition="Identifies a how this question is known in a particular terminology such as LOINC." )
1003        protected List<Coding> concept;
1004
1005        /**
1006         * The actual question as shown to the user to prompt them for an answer.
1007         */
1008        @Child(name = "text", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=false)
1009        @Description(shortDefinition="Text of the question as it is shown to the user", formalDefinition="The actual question as shown to the user to prompt them for an answer." )
1010        protected StringType text;
1011
1012        /**
1013         * The expected format of the answer, e.g. the type of input (string, integer) or whether a (multiple) choice is expected.
1014         */
1015        @Child(name = "type", type = {CodeType.class}, order=4, min=0, max=1, modifier=false, summary=false)
1016        @Description(shortDefinition="boolean | decimal | integer | date | dateTime +", formalDefinition="The expected format of the answer, e.g. the type of input (string, integer) or whether a (multiple) choice is expected." )
1017        protected Enumeration<AnswerFormat> type;
1018
1019        /**
1020         * If true, indicates that the question must be answered and have required groups within it also present.  If false, the question and any contained groups may be skipped when answering the questionnaire.
1021         */
1022        @Child(name = "required", type = {BooleanType.class}, order=5, min=0, max=1, modifier=false, summary=false)
1023        @Description(shortDefinition="Whether the question must be answered in data results", formalDefinition="If true, indicates that the question must be answered and have required groups within it also present.  If false, the question and any contained groups may be skipped when answering the questionnaire." )
1024        protected BooleanType required;
1025
1026        /**
1027         * If true, the question may have more than one answer.
1028         */
1029        @Child(name = "repeats", type = {BooleanType.class}, order=6, min=0, max=1, modifier=false, summary=false)
1030        @Description(shortDefinition="Whether the question  can have multiple answers", formalDefinition="If true, the question may have more than one answer." )
1031        protected BooleanType repeats;
1032
1033        /**
1034         * Reference to a value set containing a list of codes representing permitted answers for the question.
1035         */
1036        @Child(name = "options", type = {ValueSet.class}, order=7, min=0, max=1, modifier=false, summary=false)
1037        @Description(shortDefinition="Valueset containing permitted answers", formalDefinition="Reference to a value set containing a list of codes representing permitted answers for the question." )
1038        protected Reference options;
1039
1040        /**
1041         * 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.)
1042         */
1043        protected ValueSet optionsTarget;
1044
1045        /**
1046         * For a "choice" question, identifies one of the permitted answers for the question.
1047         */
1048        @Child(name = "option", type = {Coding.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1049        @Description(shortDefinition="Permitted answer", formalDefinition="For a \"choice\" question, identifies one of the permitted answers for the question." )
1050        protected List<Coding> option;
1051
1052        /**
1053         * Nested group, containing nested question for this question. The order of groups within the question is relevant.
1054         */
1055        @Child(name = "group", type = {GroupComponent.class}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1056        @Description(shortDefinition="Nested questionnaire group", formalDefinition="Nested group, containing nested question for this question. The order of groups within the question is relevant." )
1057        protected List<GroupComponent> group;
1058
1059        private static final long serialVersionUID = -1078951042L;
1060
1061    /*
1062     * Constructor
1063     */
1064      public QuestionComponent() {
1065        super();
1066      }
1067
1068        /**
1069         * @return {@link #linkId} (An identifier that is unique within the questionnaire allowing linkage to the equivalent group in a [[[QuestionnaireResponse]]] resource.). This is the underlying object with id, value and extensions. The accessor "getLinkId" gives direct access to the value
1070         */
1071        public StringType getLinkIdElement() { 
1072          if (this.linkId == null)
1073            if (Configuration.errorOnAutoCreate())
1074              throw new Error("Attempt to auto-create QuestionComponent.linkId");
1075            else if (Configuration.doAutoCreate())
1076              this.linkId = new StringType(); // bb
1077          return this.linkId;
1078        }
1079
1080        public boolean hasLinkIdElement() { 
1081          return this.linkId != null && !this.linkId.isEmpty();
1082        }
1083
1084        public boolean hasLinkId() { 
1085          return this.linkId != null && !this.linkId.isEmpty();
1086        }
1087
1088        /**
1089         * @param value {@link #linkId} (An identifier that is unique within the questionnaire allowing linkage to the equivalent group in a [[[QuestionnaireResponse]]] resource.). This is the underlying object with id, value and extensions. The accessor "getLinkId" gives direct access to the value
1090         */
1091        public QuestionComponent setLinkIdElement(StringType value) { 
1092          this.linkId = value;
1093          return this;
1094        }
1095
1096        /**
1097         * @return An identifier that is unique within the questionnaire allowing linkage to the equivalent group in a [[[QuestionnaireResponse]]] resource.
1098         */
1099        public String getLinkId() { 
1100          return this.linkId == null ? null : this.linkId.getValue();
1101        }
1102
1103        /**
1104         * @param value An identifier that is unique within the questionnaire allowing linkage to the equivalent group in a [[[QuestionnaireResponse]]] resource.
1105         */
1106        public QuestionComponent setLinkId(String value) { 
1107          if (Utilities.noString(value))
1108            this.linkId = null;
1109          else {
1110            if (this.linkId == null)
1111              this.linkId = new StringType();
1112            this.linkId.setValue(value);
1113          }
1114          return this;
1115        }
1116
1117        /**
1118         * @return {@link #concept} (Identifies a how this question is known in a particular terminology such as LOINC.)
1119         */
1120        public List<Coding> getConcept() { 
1121          if (this.concept == null)
1122            this.concept = new ArrayList<Coding>();
1123          return this.concept;
1124        }
1125
1126        public boolean hasConcept() { 
1127          if (this.concept == null)
1128            return false;
1129          for (Coding item : this.concept)
1130            if (!item.isEmpty())
1131              return true;
1132          return false;
1133        }
1134
1135        /**
1136         * @return {@link #concept} (Identifies a how this question is known in a particular terminology such as LOINC.)
1137         */
1138    // syntactic sugar
1139        public Coding addConcept() { //3
1140          Coding t = new Coding();
1141          if (this.concept == null)
1142            this.concept = new ArrayList<Coding>();
1143          this.concept.add(t);
1144          return t;
1145        }
1146
1147    // syntactic sugar
1148        public QuestionComponent addConcept(Coding t) { //3
1149          if (t == null)
1150            return this;
1151          if (this.concept == null)
1152            this.concept = new ArrayList<Coding>();
1153          this.concept.add(t);
1154          return this;
1155        }
1156
1157        /**
1158         * @return {@link #text} (The actual question as shown to the user to prompt them for an answer.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value
1159         */
1160        public StringType getTextElement() { 
1161          if (this.text == null)
1162            if (Configuration.errorOnAutoCreate())
1163              throw new Error("Attempt to auto-create QuestionComponent.text");
1164            else if (Configuration.doAutoCreate())
1165              this.text = new StringType(); // bb
1166          return this.text;
1167        }
1168
1169        public boolean hasTextElement() { 
1170          return this.text != null && !this.text.isEmpty();
1171        }
1172
1173        public boolean hasText() { 
1174          return this.text != null && !this.text.isEmpty();
1175        }
1176
1177        /**
1178         * @param value {@link #text} (The actual question as shown to the user to prompt them for an answer.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value
1179         */
1180        public QuestionComponent setTextElement(StringType value) { 
1181          this.text = value;
1182          return this;
1183        }
1184
1185        /**
1186         * @return The actual question as shown to the user to prompt them for an answer.
1187         */
1188        public String getText() { 
1189          return this.text == null ? null : this.text.getValue();
1190        }
1191
1192        /**
1193         * @param value The actual question as shown to the user to prompt them for an answer.
1194         */
1195        public QuestionComponent setText(String value) { 
1196          if (Utilities.noString(value))
1197            this.text = null;
1198          else {
1199            if (this.text == null)
1200              this.text = new StringType();
1201            this.text.setValue(value);
1202          }
1203          return this;
1204        }
1205
1206        /**
1207         * @return {@link #type} (The expected format of the answer, e.g. the type of input (string, integer) or whether a (multiple) choice is expected.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
1208         */
1209        public Enumeration<AnswerFormat> getTypeElement() { 
1210          if (this.type == null)
1211            if (Configuration.errorOnAutoCreate())
1212              throw new Error("Attempt to auto-create QuestionComponent.type");
1213            else if (Configuration.doAutoCreate())
1214              this.type = new Enumeration<AnswerFormat>(new AnswerFormatEnumFactory()); // bb
1215          return this.type;
1216        }
1217
1218        public boolean hasTypeElement() { 
1219          return this.type != null && !this.type.isEmpty();
1220        }
1221
1222        public boolean hasType() { 
1223          return this.type != null && !this.type.isEmpty();
1224        }
1225
1226        /**
1227         * @param value {@link #type} (The expected format of the answer, e.g. the type of input (string, integer) or whether a (multiple) choice is expected.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
1228         */
1229        public QuestionComponent setTypeElement(Enumeration<AnswerFormat> value) { 
1230          this.type = value;
1231          return this;
1232        }
1233
1234        /**
1235         * @return The expected format of the answer, e.g. the type of input (string, integer) or whether a (multiple) choice is expected.
1236         */
1237        public AnswerFormat getType() { 
1238          return this.type == null ? null : this.type.getValue();
1239        }
1240
1241        /**
1242         * @param value The expected format of the answer, e.g. the type of input (string, integer) or whether a (multiple) choice is expected.
1243         */
1244        public QuestionComponent setType(AnswerFormat value) { 
1245          if (value == null)
1246            this.type = null;
1247          else {
1248            if (this.type == null)
1249              this.type = new Enumeration<AnswerFormat>(new AnswerFormatEnumFactory());
1250            this.type.setValue(value);
1251          }
1252          return this;
1253        }
1254
1255        /**
1256         * @return {@link #required} (If true, indicates that the question must be answered and have required groups within it also present.  If false, the question and any contained groups 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
1257         */
1258        public BooleanType getRequiredElement() { 
1259          if (this.required == null)
1260            if (Configuration.errorOnAutoCreate())
1261              throw new Error("Attempt to auto-create QuestionComponent.required");
1262            else if (Configuration.doAutoCreate())
1263              this.required = new BooleanType(); // bb
1264          return this.required;
1265        }
1266
1267        public boolean hasRequiredElement() { 
1268          return this.required != null && !this.required.isEmpty();
1269        }
1270
1271        public boolean hasRequired() { 
1272          return this.required != null && !this.required.isEmpty();
1273        }
1274
1275        /**
1276         * @param value {@link #required} (If true, indicates that the question must be answered and have required groups within it also present.  If false, the question and any contained groups 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
1277         */
1278        public QuestionComponent setRequiredElement(BooleanType value) { 
1279          this.required = value;
1280          return this;
1281        }
1282
1283        /**
1284         * @return If true, indicates that the question must be answered and have required groups within it also present.  If false, the question and any contained groups may be skipped when answering the questionnaire.
1285         */
1286        public boolean getRequired() { 
1287          return this.required == null || this.required.isEmpty() ? false : this.required.getValue();
1288        }
1289
1290        /**
1291         * @param value If true, indicates that the question must be answered and have required groups within it also present.  If false, the question and any contained groups may be skipped when answering the questionnaire.
1292         */
1293        public QuestionComponent setRequired(boolean value) { 
1294            if (this.required == null)
1295              this.required = new BooleanType();
1296            this.required.setValue(value);
1297          return this;
1298        }
1299
1300        /**
1301         * @return {@link #repeats} (If true, the question may have more than one answer.). This is the underlying object with id, value and extensions. The accessor "getRepeats" gives direct access to the value
1302         */
1303        public BooleanType getRepeatsElement() { 
1304          if (this.repeats == null)
1305            if (Configuration.errorOnAutoCreate())
1306              throw new Error("Attempt to auto-create QuestionComponent.repeats");
1307            else if (Configuration.doAutoCreate())
1308              this.repeats = new BooleanType(); // bb
1309          return this.repeats;
1310        }
1311
1312        public boolean hasRepeatsElement() { 
1313          return this.repeats != null && !this.repeats.isEmpty();
1314        }
1315
1316        public boolean hasRepeats() { 
1317          return this.repeats != null && !this.repeats.isEmpty();
1318        }
1319
1320        /**
1321         * @param value {@link #repeats} (If true, the question may have more than one answer.). This is the underlying object with id, value and extensions. The accessor "getRepeats" gives direct access to the value
1322         */
1323        public QuestionComponent setRepeatsElement(BooleanType value) { 
1324          this.repeats = value;
1325          return this;
1326        }
1327
1328        /**
1329         * @return If true, the question may have more than one answer.
1330         */
1331        public boolean getRepeats() { 
1332          return this.repeats == null || this.repeats.isEmpty() ? false : this.repeats.getValue();
1333        }
1334
1335        /**
1336         * @param value If true, the question may have more than one answer.
1337         */
1338        public QuestionComponent setRepeats(boolean value) { 
1339            if (this.repeats == null)
1340              this.repeats = new BooleanType();
1341            this.repeats.setValue(value);
1342          return this;
1343        }
1344
1345        /**
1346         * @return {@link #options} (Reference to a value set containing a list of codes representing permitted answers for the question.)
1347         */
1348        public Reference getOptions() { 
1349          if (this.options == null)
1350            if (Configuration.errorOnAutoCreate())
1351              throw new Error("Attempt to auto-create QuestionComponent.options");
1352            else if (Configuration.doAutoCreate())
1353              this.options = new Reference(); // cc
1354          return this.options;
1355        }
1356
1357        public boolean hasOptions() { 
1358          return this.options != null && !this.options.isEmpty();
1359        }
1360
1361        /**
1362         * @param value {@link #options} (Reference to a value set containing a list of codes representing permitted answers for the question.)
1363         */
1364        public QuestionComponent setOptions(Reference value) { 
1365          this.options = value;
1366          return this;
1367        }
1368
1369        /**
1370         * @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.)
1371         */
1372        public ValueSet getOptionsTarget() { 
1373          if (this.optionsTarget == null)
1374            if (Configuration.errorOnAutoCreate())
1375              throw new Error("Attempt to auto-create QuestionComponent.options");
1376            else if (Configuration.doAutoCreate())
1377              this.optionsTarget = new ValueSet(); // aa
1378          return this.optionsTarget;
1379        }
1380
1381        /**
1382         * @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.)
1383         */
1384        public QuestionComponent setOptionsTarget(ValueSet value) { 
1385          this.optionsTarget = value;
1386          return this;
1387        }
1388
1389        /**
1390         * @return {@link #option} (For a "choice" question, identifies one of the permitted answers for the question.)
1391         */
1392        public List<Coding> getOption() { 
1393          if (this.option == null)
1394            this.option = new ArrayList<Coding>();
1395          return this.option;
1396        }
1397
1398        public boolean hasOption() { 
1399          if (this.option == null)
1400            return false;
1401          for (Coding item : this.option)
1402            if (!item.isEmpty())
1403              return true;
1404          return false;
1405        }
1406
1407        /**
1408         * @return {@link #option} (For a "choice" question, identifies one of the permitted answers for the question.)
1409         */
1410    // syntactic sugar
1411        public Coding addOption() { //3
1412          Coding t = new Coding();
1413          if (this.option == null)
1414            this.option = new ArrayList<Coding>();
1415          this.option.add(t);
1416          return t;
1417        }
1418
1419    // syntactic sugar
1420        public QuestionComponent addOption(Coding t) { //3
1421          if (t == null)
1422            return this;
1423          if (this.option == null)
1424            this.option = new ArrayList<Coding>();
1425          this.option.add(t);
1426          return this;
1427        }
1428
1429        /**
1430         * @return {@link #group} (Nested group, containing nested question for this question. The order of groups within the question is relevant.)
1431         */
1432        public List<GroupComponent> getGroup() { 
1433          if (this.group == null)
1434            this.group = new ArrayList<GroupComponent>();
1435          return this.group;
1436        }
1437
1438        public boolean hasGroup() { 
1439          if (this.group == null)
1440            return false;
1441          for (GroupComponent item : this.group)
1442            if (!item.isEmpty())
1443              return true;
1444          return false;
1445        }
1446
1447        /**
1448         * @return {@link #group} (Nested group, containing nested question for this question. The order of groups within the question is relevant.)
1449         */
1450    // syntactic sugar
1451        public GroupComponent addGroup() { //3
1452          GroupComponent t = new GroupComponent();
1453          if (this.group == null)
1454            this.group = new ArrayList<GroupComponent>();
1455          this.group.add(t);
1456          return t;
1457        }
1458
1459    // syntactic sugar
1460        public QuestionComponent addGroup(GroupComponent t) { //3
1461          if (t == null)
1462            return this;
1463          if (this.group == null)
1464            this.group = new ArrayList<GroupComponent>();
1465          this.group.add(t);
1466          return this;
1467        }
1468
1469        protected void listChildren(List<Property> childrenList) {
1470          super.listChildren(childrenList);
1471          childrenList.add(new Property("linkId", "string", "An identifier that is unique within the questionnaire allowing linkage to the equivalent group in a [[[QuestionnaireResponse]]] resource.", 0, java.lang.Integer.MAX_VALUE, linkId));
1472          childrenList.add(new Property("concept", "Coding", "Identifies a how this question is known in a particular terminology such as LOINC.", 0, java.lang.Integer.MAX_VALUE, concept));
1473          childrenList.add(new Property("text", "string", "The actual question as shown to the user to prompt them for an answer.", 0, java.lang.Integer.MAX_VALUE, text));
1474          childrenList.add(new Property("type", "code", "The expected format of the answer, e.g. the type of input (string, integer) or whether a (multiple) choice is expected.", 0, java.lang.Integer.MAX_VALUE, type));
1475          childrenList.add(new Property("required", "boolean", "If true, indicates that the question must be answered and have required groups within it also present.  If false, the question and any contained groups may be skipped when answering the questionnaire.", 0, java.lang.Integer.MAX_VALUE, required));
1476          childrenList.add(new Property("repeats", "boolean", "If true, the question may have more than one answer.", 0, java.lang.Integer.MAX_VALUE, repeats));
1477          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));
1478          childrenList.add(new Property("option", "Coding", "For a \"choice\" question, identifies one of the permitted answers for the question.", 0, java.lang.Integer.MAX_VALUE, option));
1479          childrenList.add(new Property("group", "@Questionnaire.group", "Nested group, containing nested question for this question. The order of groups within the question is relevant.", 0, java.lang.Integer.MAX_VALUE, group));
1480        }
1481
1482      @Override
1483      public void setProperty(String name, Base value) throws FHIRException {
1484        if (name.equals("linkId"))
1485          this.linkId = castToString(value); // StringType
1486        else if (name.equals("concept"))
1487          this.getConcept().add(castToCoding(value));
1488        else if (name.equals("text"))
1489          this.text = castToString(value); // StringType
1490        else if (name.equals("type"))
1491          this.type = new AnswerFormatEnumFactory().fromType(value); // Enumeration<AnswerFormat>
1492        else if (name.equals("required"))
1493          this.required = castToBoolean(value); // BooleanType
1494        else if (name.equals("repeats"))
1495          this.repeats = castToBoolean(value); // BooleanType
1496        else if (name.equals("options"))
1497          this.options = castToReference(value); // Reference
1498        else if (name.equals("option"))
1499          this.getOption().add(castToCoding(value));
1500        else if (name.equals("group"))
1501          this.getGroup().add((GroupComponent) value);
1502        else
1503          super.setProperty(name, value);
1504      }
1505
1506      @Override
1507      public Base addChild(String name) throws FHIRException {
1508        if (name.equals("linkId")) {
1509          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.linkId");
1510        }
1511        else if (name.equals("concept")) {
1512          return addConcept();
1513        }
1514        else if (name.equals("text")) {
1515          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.text");
1516        }
1517        else if (name.equals("type")) {
1518          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.type");
1519        }
1520        else if (name.equals("required")) {
1521          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.required");
1522        }
1523        else if (name.equals("repeats")) {
1524          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.repeats");
1525        }
1526        else if (name.equals("options")) {
1527          this.options = new Reference();
1528          return this.options;
1529        }
1530        else if (name.equals("option")) {
1531          return addOption();
1532        }
1533        else if (name.equals("group")) {
1534          return addGroup();
1535        }
1536        else
1537          return super.addChild(name);
1538      }
1539
1540      public QuestionComponent copy() {
1541        QuestionComponent dst = new QuestionComponent();
1542        copyValues(dst);
1543        dst.linkId = linkId == null ? null : linkId.copy();
1544        if (concept != null) {
1545          dst.concept = new ArrayList<Coding>();
1546          for (Coding i : concept)
1547            dst.concept.add(i.copy());
1548        };
1549        dst.text = text == null ? null : text.copy();
1550        dst.type = type == null ? null : type.copy();
1551        dst.required = required == null ? null : required.copy();
1552        dst.repeats = repeats == null ? null : repeats.copy();
1553        dst.options = options == null ? null : options.copy();
1554        if (option != null) {
1555          dst.option = new ArrayList<Coding>();
1556          for (Coding i : option)
1557            dst.option.add(i.copy());
1558        };
1559        if (group != null) {
1560          dst.group = new ArrayList<GroupComponent>();
1561          for (GroupComponent i : group)
1562            dst.group.add(i.copy());
1563        };
1564        return dst;
1565      }
1566
1567      @Override
1568      public boolean equalsDeep(Base other) {
1569        if (!super.equalsDeep(other))
1570          return false;
1571        if (!(other instanceof QuestionComponent))
1572          return false;
1573        QuestionComponent o = (QuestionComponent) other;
1574        return compareDeep(linkId, o.linkId, true) && compareDeep(concept, o.concept, true) && compareDeep(text, o.text, true)
1575           && compareDeep(type, o.type, true) && compareDeep(required, o.required, true) && compareDeep(repeats, o.repeats, true)
1576           && compareDeep(options, o.options, true) && compareDeep(option, o.option, true) && compareDeep(group, o.group, true)
1577          ;
1578      }
1579
1580      @Override
1581      public boolean equalsShallow(Base other) {
1582        if (!super.equalsShallow(other))
1583          return false;
1584        if (!(other instanceof QuestionComponent))
1585          return false;
1586        QuestionComponent o = (QuestionComponent) other;
1587        return compareValues(linkId, o.linkId, true) && compareValues(text, o.text, true) && compareValues(type, o.type, true)
1588           && compareValues(required, o.required, true) && compareValues(repeats, o.repeats, true);
1589      }
1590
1591      public boolean isEmpty() {
1592        return super.isEmpty() && (linkId == null || linkId.isEmpty()) && (concept == null || concept.isEmpty())
1593           && (text == null || text.isEmpty()) && (type == null || type.isEmpty()) && (required == null || required.isEmpty())
1594           && (repeats == null || repeats.isEmpty()) && (options == null || options.isEmpty()) && (option == null || option.isEmpty())
1595           && (group == null || group.isEmpty());
1596      }
1597
1598  public String fhirType() {
1599    return "Questionnaire.group.question";
1600
1601  }
1602
1603  }
1604
1605    /**
1606     * 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).
1607     */
1608    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1609    @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)." )
1610    protected List<Identifier> identifier;
1611
1612    /**
1613     * The version number assigned by the publisher for business reasons.  It may remain the same when the resource is updated.
1614     */
1615    @Child(name = "version", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true)
1616    @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." )
1617    protected StringType version;
1618
1619    /**
1620     * The lifecycle status of the questionnaire as a whole.
1621     */
1622    @Child(name = "status", type = {CodeType.class}, order=2, min=1, max=1, modifier=true, summary=true)
1623    @Description(shortDefinition="draft | published | retired", formalDefinition="The lifecycle status of the questionnaire as a whole." )
1624    protected Enumeration<QuestionnaireStatus> status;
1625
1626    /**
1627     * The date that this questionnaire was last changed.
1628     */
1629    @Child(name = "date", type = {DateTimeType.class}, order=3, min=0, max=1, modifier=false, summary=true)
1630    @Description(shortDefinition="Date this version was authored", formalDefinition="The date that this questionnaire was last changed." )
1631    protected DateTimeType date;
1632
1633    /**
1634     * Organization or person responsible for developing and maintaining the questionnaire.
1635     */
1636    @Child(name = "publisher", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=true)
1637    @Description(shortDefinition="Organization/individual who designed the questionnaire", formalDefinition="Organization or person responsible for developing and maintaining the questionnaire." )
1638    protected StringType publisher;
1639
1640    /**
1641     * Contact details to assist a user in finding and communicating with the publisher.
1642     */
1643    @Child(name = "telecom", type = {ContactPoint.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1644    @Description(shortDefinition="Contact information of the publisher", formalDefinition="Contact details to assist a user in finding and communicating with the publisher." )
1645    protected List<ContactPoint> telecom;
1646
1647    /**
1648     * Identifies the types of subjects that can be the subject of the questionnaire.
1649     */
1650    @Child(name = "subjectType", type = {CodeType.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1651    @Description(shortDefinition="Resource that can be subject of QuestionnaireResponse", formalDefinition="Identifies the types of subjects that can be the subject of the questionnaire." )
1652    protected List<CodeType> subjectType;
1653
1654    /**
1655     * A collection of related questions (or further groupings of questions).
1656     */
1657    @Child(name = "group", type = {}, order=7, min=1, max=1, modifier=false, summary=true)
1658    @Description(shortDefinition="Grouped questions", formalDefinition="A collection of related questions (or further groupings of questions)." )
1659    protected GroupComponent group;
1660
1661    private static final long serialVersionUID = -1348292652L;
1662
1663  /*
1664   * Constructor
1665   */
1666    public Questionnaire() {
1667      super();
1668    }
1669
1670  /*
1671   * Constructor
1672   */
1673    public Questionnaire(Enumeration<QuestionnaireStatus> status, GroupComponent group) {
1674      super();
1675      this.status = status;
1676      this.group = group;
1677    }
1678
1679    /**
1680     * @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).)
1681     */
1682    public List<Identifier> getIdentifier() { 
1683      if (this.identifier == null)
1684        this.identifier = new ArrayList<Identifier>();
1685      return this.identifier;
1686    }
1687
1688    public boolean hasIdentifier() { 
1689      if (this.identifier == null)
1690        return false;
1691      for (Identifier item : this.identifier)
1692        if (!item.isEmpty())
1693          return true;
1694      return false;
1695    }
1696
1697    /**
1698     * @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).)
1699     */
1700    // syntactic sugar
1701    public Identifier addIdentifier() { //3
1702      Identifier t = new Identifier();
1703      if (this.identifier == null)
1704        this.identifier = new ArrayList<Identifier>();
1705      this.identifier.add(t);
1706      return t;
1707    }
1708
1709    // syntactic sugar
1710    public Questionnaire addIdentifier(Identifier t) { //3
1711      if (t == null)
1712        return this;
1713      if (this.identifier == null)
1714        this.identifier = new ArrayList<Identifier>();
1715      this.identifier.add(t);
1716      return this;
1717    }
1718
1719    /**
1720     * @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
1721     */
1722    public StringType getVersionElement() { 
1723      if (this.version == null)
1724        if (Configuration.errorOnAutoCreate())
1725          throw new Error("Attempt to auto-create Questionnaire.version");
1726        else if (Configuration.doAutoCreate())
1727          this.version = new StringType(); // bb
1728      return this.version;
1729    }
1730
1731    public boolean hasVersionElement() { 
1732      return this.version != null && !this.version.isEmpty();
1733    }
1734
1735    public boolean hasVersion() { 
1736      return this.version != null && !this.version.isEmpty();
1737    }
1738
1739    /**
1740     * @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
1741     */
1742    public Questionnaire setVersionElement(StringType value) { 
1743      this.version = value;
1744      return this;
1745    }
1746
1747    /**
1748     * @return The version number assigned by the publisher for business reasons.  It may remain the same when the resource is updated.
1749     */
1750    public String getVersion() { 
1751      return this.version == null ? null : this.version.getValue();
1752    }
1753
1754    /**
1755     * @param value The version number assigned by the publisher for business reasons.  It may remain the same when the resource is updated.
1756     */
1757    public Questionnaire setVersion(String value) { 
1758      if (Utilities.noString(value))
1759        this.version = null;
1760      else {
1761        if (this.version == null)
1762          this.version = new StringType();
1763        this.version.setValue(value);
1764      }
1765      return this;
1766    }
1767
1768    /**
1769     * @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
1770     */
1771    public Enumeration<QuestionnaireStatus> getStatusElement() { 
1772      if (this.status == null)
1773        if (Configuration.errorOnAutoCreate())
1774          throw new Error("Attempt to auto-create Questionnaire.status");
1775        else if (Configuration.doAutoCreate())
1776          this.status = new Enumeration<QuestionnaireStatus>(new QuestionnaireStatusEnumFactory()); // bb
1777      return this.status;
1778    }
1779
1780    public boolean hasStatusElement() { 
1781      return this.status != null && !this.status.isEmpty();
1782    }
1783
1784    public boolean hasStatus() { 
1785      return this.status != null && !this.status.isEmpty();
1786    }
1787
1788    /**
1789     * @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
1790     */
1791    public Questionnaire setStatusElement(Enumeration<QuestionnaireStatus> value) { 
1792      this.status = value;
1793      return this;
1794    }
1795
1796    /**
1797     * @return The lifecycle status of the questionnaire as a whole.
1798     */
1799    public QuestionnaireStatus getStatus() { 
1800      return this.status == null ? null : this.status.getValue();
1801    }
1802
1803    /**
1804     * @param value The lifecycle status of the questionnaire as a whole.
1805     */
1806    public Questionnaire setStatus(QuestionnaireStatus value) { 
1807        if (this.status == null)
1808          this.status = new Enumeration<QuestionnaireStatus>(new QuestionnaireStatusEnumFactory());
1809        this.status.setValue(value);
1810      return this;
1811    }
1812
1813    /**
1814     * @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
1815     */
1816    public DateTimeType getDateElement() { 
1817      if (this.date == null)
1818        if (Configuration.errorOnAutoCreate())
1819          throw new Error("Attempt to auto-create Questionnaire.date");
1820        else if (Configuration.doAutoCreate())
1821          this.date = new DateTimeType(); // bb
1822      return this.date;
1823    }
1824
1825    public boolean hasDateElement() { 
1826      return this.date != null && !this.date.isEmpty();
1827    }
1828
1829    public boolean hasDate() { 
1830      return this.date != null && !this.date.isEmpty();
1831    }
1832
1833    /**
1834     * @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
1835     */
1836    public Questionnaire setDateElement(DateTimeType value) { 
1837      this.date = value;
1838      return this;
1839    }
1840
1841    /**
1842     * @return The date that this questionnaire was last changed.
1843     */
1844    public Date getDate() { 
1845      return this.date == null ? null : this.date.getValue();
1846    }
1847
1848    /**
1849     * @param value The date that this questionnaire was last changed.
1850     */
1851    public Questionnaire setDate(Date value) { 
1852      if (value == null)
1853        this.date = null;
1854      else {
1855        if (this.date == null)
1856          this.date = new DateTimeType();
1857        this.date.setValue(value);
1858      }
1859      return this;
1860    }
1861
1862    /**
1863     * @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
1864     */
1865    public StringType getPublisherElement() { 
1866      if (this.publisher == null)
1867        if (Configuration.errorOnAutoCreate())
1868          throw new Error("Attempt to auto-create Questionnaire.publisher");
1869        else if (Configuration.doAutoCreate())
1870          this.publisher = new StringType(); // bb
1871      return this.publisher;
1872    }
1873
1874    public boolean hasPublisherElement() { 
1875      return this.publisher != null && !this.publisher.isEmpty();
1876    }
1877
1878    public boolean hasPublisher() { 
1879      return this.publisher != null && !this.publisher.isEmpty();
1880    }
1881
1882    /**
1883     * @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
1884     */
1885    public Questionnaire setPublisherElement(StringType value) { 
1886      this.publisher = value;
1887      return this;
1888    }
1889
1890    /**
1891     * @return Organization or person responsible for developing and maintaining the questionnaire.
1892     */
1893    public String getPublisher() { 
1894      return this.publisher == null ? null : this.publisher.getValue();
1895    }
1896
1897    /**
1898     * @param value Organization or person responsible for developing and maintaining the questionnaire.
1899     */
1900    public Questionnaire setPublisher(String value) { 
1901      if (Utilities.noString(value))
1902        this.publisher = null;
1903      else {
1904        if (this.publisher == null)
1905          this.publisher = new StringType();
1906        this.publisher.setValue(value);
1907      }
1908      return this;
1909    }
1910
1911    /**
1912     * @return {@link #telecom} (Contact details to assist a user in finding and communicating with the publisher.)
1913     */
1914    public List<ContactPoint> getTelecom() { 
1915      if (this.telecom == null)
1916        this.telecom = new ArrayList<ContactPoint>();
1917      return this.telecom;
1918    }
1919
1920    public boolean hasTelecom() { 
1921      if (this.telecom == null)
1922        return false;
1923      for (ContactPoint item : this.telecom)
1924        if (!item.isEmpty())
1925          return true;
1926      return false;
1927    }
1928
1929    /**
1930     * @return {@link #telecom} (Contact details to assist a user in finding and communicating with the publisher.)
1931     */
1932    // syntactic sugar
1933    public ContactPoint addTelecom() { //3
1934      ContactPoint t = new ContactPoint();
1935      if (this.telecom == null)
1936        this.telecom = new ArrayList<ContactPoint>();
1937      this.telecom.add(t);
1938      return t;
1939    }
1940
1941    // syntactic sugar
1942    public Questionnaire addTelecom(ContactPoint t) { //3
1943      if (t == null)
1944        return this;
1945      if (this.telecom == null)
1946        this.telecom = new ArrayList<ContactPoint>();
1947      this.telecom.add(t);
1948      return this;
1949    }
1950
1951    /**
1952     * @return {@link #subjectType} (Identifies the types of subjects that can be the subject of the questionnaire.)
1953     */
1954    public List<CodeType> getSubjectType() { 
1955      if (this.subjectType == null)
1956        this.subjectType = new ArrayList<CodeType>();
1957      return this.subjectType;
1958    }
1959
1960    public boolean hasSubjectType() { 
1961      if (this.subjectType == null)
1962        return false;
1963      for (CodeType item : this.subjectType)
1964        if (!item.isEmpty())
1965          return true;
1966      return false;
1967    }
1968
1969    /**
1970     * @return {@link #subjectType} (Identifies the types of subjects that can be the subject of the questionnaire.)
1971     */
1972    // syntactic sugar
1973    public CodeType addSubjectTypeElement() {//2 
1974      CodeType t = new CodeType();
1975      if (this.subjectType == null)
1976        this.subjectType = new ArrayList<CodeType>();
1977      this.subjectType.add(t);
1978      return t;
1979    }
1980
1981    /**
1982     * @param value {@link #subjectType} (Identifies the types of subjects that can be the subject of the questionnaire.)
1983     */
1984    public Questionnaire addSubjectType(String value) { //1
1985      CodeType t = new CodeType();
1986      t.setValue(value);
1987      if (this.subjectType == null)
1988        this.subjectType = new ArrayList<CodeType>();
1989      this.subjectType.add(t);
1990      return this;
1991    }
1992
1993    /**
1994     * @param value {@link #subjectType} (Identifies the types of subjects that can be the subject of the questionnaire.)
1995     */
1996    public boolean hasSubjectType(String value) { 
1997      if (this.subjectType == null)
1998        return false;
1999      for (CodeType v : this.subjectType)
2000        if (v.equals(value)) // code
2001          return true;
2002      return false;
2003    }
2004
2005    /**
2006     * @return {@link #group} (A collection of related questions (or further groupings of questions).)
2007     */
2008    public GroupComponent getGroup() { 
2009      if (this.group == null)
2010        if (Configuration.errorOnAutoCreate())
2011          throw new Error("Attempt to auto-create Questionnaire.group");
2012        else if (Configuration.doAutoCreate())
2013          this.group = new GroupComponent(); // cc
2014      return this.group;
2015    }
2016
2017    public boolean hasGroup() { 
2018      return this.group != null && !this.group.isEmpty();
2019    }
2020
2021    /**
2022     * @param value {@link #group} (A collection of related questions (or further groupings of questions).)
2023     */
2024    public Questionnaire setGroup(GroupComponent value) { 
2025      this.group = value;
2026      return this;
2027    }
2028
2029      protected void listChildren(List<Property> childrenList) {
2030        super.listChildren(childrenList);
2031        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));
2032        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));
2033        childrenList.add(new Property("status", "code", "The lifecycle status of the questionnaire as a whole.", 0, java.lang.Integer.MAX_VALUE, status));
2034        childrenList.add(new Property("date", "dateTime", "The date that this questionnaire was last changed.", 0, java.lang.Integer.MAX_VALUE, date));
2035        childrenList.add(new Property("publisher", "string", "Organization or person responsible for developing and maintaining the questionnaire.", 0, java.lang.Integer.MAX_VALUE, publisher));
2036        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));
2037        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));
2038        childrenList.add(new Property("group", "", "A collection of related questions (or further groupings of questions).", 0, java.lang.Integer.MAX_VALUE, group));
2039      }
2040
2041      @Override
2042      public void setProperty(String name, Base value) throws FHIRException {
2043        if (name.equals("identifier"))
2044          this.getIdentifier().add(castToIdentifier(value));
2045        else if (name.equals("version"))
2046          this.version = castToString(value); // StringType
2047        else if (name.equals("status"))
2048          this.status = new QuestionnaireStatusEnumFactory().fromType(value); // Enumeration<QuestionnaireStatus>
2049        else if (name.equals("date"))
2050          this.date = castToDateTime(value); // DateTimeType
2051        else if (name.equals("publisher"))
2052          this.publisher = castToString(value); // StringType
2053        else if (name.equals("telecom"))
2054          this.getTelecom().add(castToContactPoint(value));
2055        else if (name.equals("subjectType"))
2056          this.getSubjectType().add(castToCode(value));
2057        else if (name.equals("group"))
2058          this.group = (GroupComponent) value; // GroupComponent
2059        else
2060          super.setProperty(name, value);
2061      }
2062
2063      @Override
2064      public Base addChild(String name) throws FHIRException {
2065        if (name.equals("identifier")) {
2066          return addIdentifier();
2067        }
2068        else if (name.equals("version")) {
2069          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.version");
2070        }
2071        else if (name.equals("status")) {
2072          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.status");
2073        }
2074        else if (name.equals("date")) {
2075          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.date");
2076        }
2077        else if (name.equals("publisher")) {
2078          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.publisher");
2079        }
2080        else if (name.equals("telecom")) {
2081          return addTelecom();
2082        }
2083        else if (name.equals("subjectType")) {
2084          throw new FHIRException("Cannot call addChild on a primitive type Questionnaire.subjectType");
2085        }
2086        else if (name.equals("group")) {
2087          this.group = new GroupComponent();
2088          return this.group;
2089        }
2090        else
2091          return super.addChild(name);
2092      }
2093
2094  public String fhirType() {
2095    return "Questionnaire";
2096
2097  }
2098
2099      public Questionnaire copy() {
2100        Questionnaire dst = new Questionnaire();
2101        copyValues(dst);
2102        if (identifier != null) {
2103          dst.identifier = new ArrayList<Identifier>();
2104          for (Identifier i : identifier)
2105            dst.identifier.add(i.copy());
2106        };
2107        dst.version = version == null ? null : version.copy();
2108        dst.status = status == null ? null : status.copy();
2109        dst.date = date == null ? null : date.copy();
2110        dst.publisher = publisher == null ? null : publisher.copy();
2111        if (telecom != null) {
2112          dst.telecom = new ArrayList<ContactPoint>();
2113          for (ContactPoint i : telecom)
2114            dst.telecom.add(i.copy());
2115        };
2116        if (subjectType != null) {
2117          dst.subjectType = new ArrayList<CodeType>();
2118          for (CodeType i : subjectType)
2119            dst.subjectType.add(i.copy());
2120        };
2121        dst.group = group == null ? null : group.copy();
2122        return dst;
2123      }
2124
2125      protected Questionnaire typedCopy() {
2126        return copy();
2127      }
2128
2129      @Override
2130      public boolean equalsDeep(Base other) {
2131        if (!super.equalsDeep(other))
2132          return false;
2133        if (!(other instanceof Questionnaire))
2134          return false;
2135        Questionnaire o = (Questionnaire) other;
2136        return compareDeep(identifier, o.identifier, true) && compareDeep(version, o.version, true) && compareDeep(status, o.status, true)
2137           && compareDeep(date, o.date, true) && compareDeep(publisher, o.publisher, true) && compareDeep(telecom, o.telecom, true)
2138           && compareDeep(subjectType, o.subjectType, true) && compareDeep(group, o.group, true);
2139      }
2140
2141      @Override
2142      public boolean equalsShallow(Base other) {
2143        if (!super.equalsShallow(other))
2144          return false;
2145        if (!(other instanceof Questionnaire))
2146          return false;
2147        Questionnaire o = (Questionnaire) other;
2148        return compareValues(version, o.version, true) && compareValues(status, o.status, true) && compareValues(date, o.date, true)
2149           && compareValues(publisher, o.publisher, true) && compareValues(subjectType, o.subjectType, true);
2150      }
2151
2152      public boolean isEmpty() {
2153        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (version == null || version.isEmpty())
2154           && (status == null || status.isEmpty()) && (date == null || date.isEmpty()) && (publisher == null || publisher.isEmpty())
2155           && (telecom == null || telecom.isEmpty()) && (subjectType == null || subjectType.isEmpty())
2156           && (group == null || group.isEmpty());
2157      }
2158
2159  @Override
2160  public ResourceType getResourceType() {
2161    return ResourceType.Questionnaire;
2162   }
2163
2164  @SearchParamDefinition(name="date", path="Questionnaire.date", description="When the questionnaire was last changed", type="date" )
2165  public static final String SP_DATE = "date";
2166  @SearchParamDefinition(name="identifier", path="Questionnaire.identifier", description="An identifier for the questionnaire", type="token" )
2167  public static final String SP_IDENTIFIER = "identifier";
2168  @SearchParamDefinition(name="code", path="Questionnaire.group.concept", description="A code that corresponds to the questionnaire or one of its groups", type="token" )
2169  public static final String SP_CODE = "code";
2170  @SearchParamDefinition(name="publisher", path="Questionnaire.publisher", description="The author of the questionnaire", type="string" )
2171  public static final String SP_PUBLISHER = "publisher";
2172  @SearchParamDefinition(name="title", path="Questionnaire.group.title", description="All or part of the name of the questionnaire (title for the root group of the questionnaire)", type="string" )
2173  public static final String SP_TITLE = "title";
2174  @SearchParamDefinition(name="version", path="Questionnaire.version", description="The business version of the questionnaire", type="string" )
2175  public static final String SP_VERSION = "version";
2176  @SearchParamDefinition(name="status", path="Questionnaire.status", description="The status of the questionnaire", type="token" )
2177  public static final String SP_STATUS = "status";
2178
2179}
2180