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