001package org.hl7.fhir.instance.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
033import java.util.*;
034
035import org.hl7.fhir.exceptions.FHIRException;
036import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
037import org.hl7.fhir.utilities.Utilities;
038
039import ca.uhn.fhir.model.api.annotation.*;
040/**
041 * A structured set of questions and their answers. The questions are ordered and grouped into coherent subsets, corresponding to the structure of the grouping of the underlying questions.
042 */
043@ResourceDef(name="QuestionnaireResponse", profile="http://hl7.org/fhir/Profile/QuestionnaireResponse")
044public class QuestionnaireResponse extends DomainResource {
045
046    public enum QuestionnaireResponseStatus {
047        /**
048         * This QuestionnaireResponse has been partially filled out with answers, but changes or additions are still expected to be made to it.
049         */
050        INPROGRESS, 
051        /**
052         * This QuestionnaireResponse has been filled out with answers, and the current content is regarded as definitive.
053         */
054        COMPLETED, 
055        /**
056         * This QuestionnaireResponse has been filled out with answers, then marked as complete, yet changes or additions have been made to it afterwards.
057         */
058        AMENDED, 
059        /**
060         * added to help the parsers
061         */
062        NULL;
063        public static QuestionnaireResponseStatus fromCode(String codeString) throws FHIRException {
064            if (codeString == null || "".equals(codeString))
065                return null;
066        if ("in-progress".equals(codeString))
067          return INPROGRESS;
068        if ("completed".equals(codeString))
069          return COMPLETED;
070        if ("amended".equals(codeString))
071          return AMENDED;
072        throw new FHIRException("Unknown QuestionnaireResponseStatus code '"+codeString+"'");
073        }
074        public String toCode() {
075          switch (this) {
076            case INPROGRESS: return "in-progress";
077            case COMPLETED: return "completed";
078            case AMENDED: return "amended";
079            default: return "?";
080          }
081        }
082        public String getSystem() {
083          switch (this) {
084            case INPROGRESS: return "http://hl7.org/fhir/questionnaire-answers-status";
085            case COMPLETED: return "http://hl7.org/fhir/questionnaire-answers-status";
086            case AMENDED: return "http://hl7.org/fhir/questionnaire-answers-status";
087            default: return "?";
088          }
089        }
090        public String getDefinition() {
091          switch (this) {
092            case INPROGRESS: return "This QuestionnaireResponse has been partially filled out with answers, but changes or additions are still expected to be made to it.";
093            case COMPLETED: return "This QuestionnaireResponse has been filled out with answers, and the current content is regarded as definitive.";
094            case AMENDED: return "This QuestionnaireResponse has been filled out with answers, then marked as complete, yet changes or additions have been made to it afterwards.";
095            default: return "?";
096          }
097        }
098        public String getDisplay() {
099          switch (this) {
100            case INPROGRESS: return "In Progress";
101            case COMPLETED: return "Completed";
102            case AMENDED: return "Amended";
103            default: return "?";
104          }
105        }
106    }
107
108  public static class QuestionnaireResponseStatusEnumFactory implements EnumFactory<QuestionnaireResponseStatus> {
109    public QuestionnaireResponseStatus fromCode(String codeString) throws IllegalArgumentException {
110      if (codeString == null || "".equals(codeString))
111            if (codeString == null || "".equals(codeString))
112                return null;
113        if ("in-progress".equals(codeString))
114          return QuestionnaireResponseStatus.INPROGRESS;
115        if ("completed".equals(codeString))
116          return QuestionnaireResponseStatus.COMPLETED;
117        if ("amended".equals(codeString))
118          return QuestionnaireResponseStatus.AMENDED;
119        throw new IllegalArgumentException("Unknown QuestionnaireResponseStatus code '"+codeString+"'");
120        }
121        public Enumeration<QuestionnaireResponseStatus> fromType(Base code) throws FHIRException {
122          if (code == null || code.isEmpty())
123            return null;
124          String codeString = ((PrimitiveType) code).asStringValue();
125          if (codeString == null || "".equals(codeString))
126            return null;
127        if ("in-progress".equals(codeString))
128          return new Enumeration<QuestionnaireResponseStatus>(this, QuestionnaireResponseStatus.INPROGRESS);
129        if ("completed".equals(codeString))
130          return new Enumeration<QuestionnaireResponseStatus>(this, QuestionnaireResponseStatus.COMPLETED);
131        if ("amended".equals(codeString))
132          return new Enumeration<QuestionnaireResponseStatus>(this, QuestionnaireResponseStatus.AMENDED);
133        throw new FHIRException("Unknown QuestionnaireResponseStatus code '"+codeString+"'");
134        }
135    public String toCode(QuestionnaireResponseStatus code) {
136      if (code == QuestionnaireResponseStatus.INPROGRESS)
137        return "in-progress";
138      if (code == QuestionnaireResponseStatus.COMPLETED)
139        return "completed";
140      if (code == QuestionnaireResponseStatus.AMENDED)
141        return "amended";
142      return "?";
143      }
144    }
145
146    @Block()
147    public static class GroupComponent extends BackboneElement implements IBaseBackboneElement {
148        /**
149         * Identifies the group from the Questionnaire that corresponds to this group in the QuestionnaireResponse resource.
150         */
151        @Child(name = "linkId", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=false)
152        @Description(shortDefinition="Corresponding group within Questionnaire", formalDefinition="Identifies the group from the Questionnaire that corresponds to this group in the QuestionnaireResponse resource." )
153        protected StringType linkId;
154
155        /**
156         * Text that is displayed above the contents of the group.
157         */
158        @Child(name = "title", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=false)
159        @Description(shortDefinition="Name for this group", formalDefinition="Text that is displayed above the contents of the group." )
160        protected StringType title;
161
162        /**
163         * Additional text for the group, used for display purposes.
164         */
165        @Child(name = "text", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=false)
166        @Description(shortDefinition="Additional text for the group", formalDefinition="Additional text for the group, used for display purposes." )
167        protected StringType text;
168
169        /**
170         * More specific subject this section's answers are about, details the subject given in QuestionnaireResponse.
171         */
172        @Child(name = "subject", type = {}, order=4, min=0, max=1, modifier=false, summary=false)
173        @Description(shortDefinition="The subject this group's answers are about", formalDefinition="More specific subject this section's answers are about, details the subject given in QuestionnaireResponse." )
174        protected Reference subject;
175
176        /**
177         * The actual object that is the target of the reference (More specific subject this section's answers are about, details the subject given in QuestionnaireResponse.)
178         */
179        protected Resource subjectTarget;
180
181        /**
182         * A sub-group within a group. The ordering of groups within this group is relevant.
183         */
184        @Child(name = "group", type = {GroupComponent.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
185        @Description(shortDefinition="Nested questionnaire response group", formalDefinition="A sub-group within a group. The ordering of groups within this group is relevant." )
186        protected List<GroupComponent> group;
187
188        /**
189         * Set of questions within this group. The order of questions within the group is relevant.
190         */
191        @Child(name = "question", type = {}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
192        @Description(shortDefinition="Questions in this group", formalDefinition="Set of questions within this group. The order of questions within the group is relevant." )
193        protected List<QuestionComponent> question;
194
195        private static final long serialVersionUID = -1045990435L;
196
197    /*
198     * Constructor
199     */
200      public GroupComponent() {
201        super();
202      }
203
204        /**
205         * @return {@link #linkId} (Identifies the group from the Questionnaire that corresponds to this group in the QuestionnaireResponse resource.). This is the underlying object with id, value and extensions. The accessor "getLinkId" gives direct access to the value
206         */
207        public StringType getLinkIdElement() { 
208          if (this.linkId == null)
209            if (Configuration.errorOnAutoCreate())
210              throw new Error("Attempt to auto-create GroupComponent.linkId");
211            else if (Configuration.doAutoCreate())
212              this.linkId = new StringType(); // bb
213          return this.linkId;
214        }
215
216        public boolean hasLinkIdElement() { 
217          return this.linkId != null && !this.linkId.isEmpty();
218        }
219
220        public boolean hasLinkId() { 
221          return this.linkId != null && !this.linkId.isEmpty();
222        }
223
224        /**
225         * @param value {@link #linkId} (Identifies the group from the Questionnaire that corresponds to this group in the QuestionnaireResponse resource.). This is the underlying object with id, value and extensions. The accessor "getLinkId" gives direct access to the value
226         */
227        public GroupComponent setLinkIdElement(StringType value) { 
228          this.linkId = value;
229          return this;
230        }
231
232        /**
233         * @return Identifies the group from the Questionnaire that corresponds to this group in the QuestionnaireResponse resource.
234         */
235        public String getLinkId() { 
236          return this.linkId == null ? null : this.linkId.getValue();
237        }
238
239        /**
240         * @param value Identifies the group from the Questionnaire that corresponds to this group in the QuestionnaireResponse resource.
241         */
242        public GroupComponent setLinkId(String value) { 
243          if (Utilities.noString(value))
244            this.linkId = null;
245          else {
246            if (this.linkId == null)
247              this.linkId = new StringType();
248            this.linkId.setValue(value);
249          }
250          return this;
251        }
252
253        /**
254         * @return {@link #title} (Text that is displayed above the contents of the group.). This is the underlying object with id, value and extensions. The accessor "getTitle" gives direct access to the value
255         */
256        public StringType getTitleElement() { 
257          if (this.title == null)
258            if (Configuration.errorOnAutoCreate())
259              throw new Error("Attempt to auto-create GroupComponent.title");
260            else if (Configuration.doAutoCreate())
261              this.title = new StringType(); // bb
262          return this.title;
263        }
264
265        public boolean hasTitleElement() { 
266          return this.title != null && !this.title.isEmpty();
267        }
268
269        public boolean hasTitle() { 
270          return this.title != null && !this.title.isEmpty();
271        }
272
273        /**
274         * @param value {@link #title} (Text that is displayed above the contents of the group.). This is the underlying object with id, value and extensions. The accessor "getTitle" gives direct access to the value
275         */
276        public GroupComponent setTitleElement(StringType value) { 
277          this.title = value;
278          return this;
279        }
280
281        /**
282         * @return Text that is displayed above the contents of the group.
283         */
284        public String getTitle() { 
285          return this.title == null ? null : this.title.getValue();
286        }
287
288        /**
289         * @param value Text that is displayed above the contents of the group.
290         */
291        public GroupComponent setTitle(String value) { 
292          if (Utilities.noString(value))
293            this.title = null;
294          else {
295            if (this.title == null)
296              this.title = new StringType();
297            this.title.setValue(value);
298          }
299          return this;
300        }
301
302        /**
303         * @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
304         */
305        public StringType getTextElement() { 
306          if (this.text == null)
307            if (Configuration.errorOnAutoCreate())
308              throw new Error("Attempt to auto-create GroupComponent.text");
309            else if (Configuration.doAutoCreate())
310              this.text = new StringType(); // bb
311          return this.text;
312        }
313
314        public boolean hasTextElement() { 
315          return this.text != null && !this.text.isEmpty();
316        }
317
318        public boolean hasText() { 
319          return this.text != null && !this.text.isEmpty();
320        }
321
322        /**
323         * @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
324         */
325        public GroupComponent setTextElement(StringType value) { 
326          this.text = value;
327          return this;
328        }
329
330        /**
331         * @return Additional text for the group, used for display purposes.
332         */
333        public String getText() { 
334          return this.text == null ? null : this.text.getValue();
335        }
336
337        /**
338         * @param value Additional text for the group, used for display purposes.
339         */
340        public GroupComponent setText(String value) { 
341          if (Utilities.noString(value))
342            this.text = null;
343          else {
344            if (this.text == null)
345              this.text = new StringType();
346            this.text.setValue(value);
347          }
348          return this;
349        }
350
351        /**
352         * @return {@link #subject} (More specific subject this section's answers are about, details the subject given in QuestionnaireResponse.)
353         */
354        public Reference getSubject() { 
355          if (this.subject == null)
356            if (Configuration.errorOnAutoCreate())
357              throw new Error("Attempt to auto-create GroupComponent.subject");
358            else if (Configuration.doAutoCreate())
359              this.subject = new Reference(); // cc
360          return this.subject;
361        }
362
363        public boolean hasSubject() { 
364          return this.subject != null && !this.subject.isEmpty();
365        }
366
367        /**
368         * @param value {@link #subject} (More specific subject this section's answers are about, details the subject given in QuestionnaireResponse.)
369         */
370        public GroupComponent setSubject(Reference value) { 
371          this.subject = value;
372          return this;
373        }
374
375        /**
376         * @return {@link #subject} 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. (More specific subject this section's answers are about, details the subject given in QuestionnaireResponse.)
377         */
378        public Resource getSubjectTarget() { 
379          return this.subjectTarget;
380        }
381
382        /**
383         * @param value {@link #subject} 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. (More specific subject this section's answers are about, details the subject given in QuestionnaireResponse.)
384         */
385        public GroupComponent setSubjectTarget(Resource value) { 
386          this.subjectTarget = value;
387          return this;
388        }
389
390        /**
391         * @return {@link #group} (A sub-group within a group. The ordering of groups within this group is relevant.)
392         */
393        public List<GroupComponent> getGroup() { 
394          if (this.group == null)
395            this.group = new ArrayList<GroupComponent>();
396          return this.group;
397        }
398
399        public boolean hasGroup() { 
400          if (this.group == null)
401            return false;
402          for (GroupComponent item : this.group)
403            if (!item.isEmpty())
404              return true;
405          return false;
406        }
407
408        /**
409         * @return {@link #group} (A sub-group within a group. The ordering of groups within this group is relevant.)
410         */
411    // syntactic sugar
412        public GroupComponent addGroup() { //3
413          GroupComponent t = new GroupComponent();
414          if (this.group == null)
415            this.group = new ArrayList<GroupComponent>();
416          this.group.add(t);
417          return t;
418        }
419
420    // syntactic sugar
421        public GroupComponent addGroup(GroupComponent t) { //3
422          if (t == null)
423            return this;
424          if (this.group == null)
425            this.group = new ArrayList<GroupComponent>();
426          this.group.add(t);
427          return this;
428        }
429
430        /**
431         * @return {@link #question} (Set of questions within this group. The order of questions within the group is relevant.)
432         */
433        public List<QuestionComponent> getQuestion() { 
434          if (this.question == null)
435            this.question = new ArrayList<QuestionComponent>();
436          return this.question;
437        }
438
439        public boolean hasQuestion() { 
440          if (this.question == null)
441            return false;
442          for (QuestionComponent item : this.question)
443            if (!item.isEmpty())
444              return true;
445          return false;
446        }
447
448        /**
449         * @return {@link #question} (Set of questions within this group. The order of questions within the group is relevant.)
450         */
451    // syntactic sugar
452        public QuestionComponent addQuestion() { //3
453          QuestionComponent t = new QuestionComponent();
454          if (this.question == null)
455            this.question = new ArrayList<QuestionComponent>();
456          this.question.add(t);
457          return t;
458        }
459
460    // syntactic sugar
461        public GroupComponent addQuestion(QuestionComponent t) { //3
462          if (t == null)
463            return this;
464          if (this.question == null)
465            this.question = new ArrayList<QuestionComponent>();
466          this.question.add(t);
467          return this;
468        }
469
470        protected void listChildren(List<Property> childrenList) {
471          super.listChildren(childrenList);
472          childrenList.add(new Property("linkId", "string", "Identifies the group from the Questionnaire that corresponds to this group in the QuestionnaireResponse resource.", 0, java.lang.Integer.MAX_VALUE, linkId));
473          childrenList.add(new Property("title", "string", "Text that is displayed above the contents of the group.", 0, java.lang.Integer.MAX_VALUE, title));
474          childrenList.add(new Property("text", "string", "Additional text for the group, used for display purposes.", 0, java.lang.Integer.MAX_VALUE, text));
475          childrenList.add(new Property("subject", "Reference(Any)", "More specific subject this section's answers are about, details the subject given in QuestionnaireResponse.", 0, java.lang.Integer.MAX_VALUE, subject));
476          childrenList.add(new Property("group", "@QuestionnaireResponse.group", "A sub-group within a group. The ordering of groups within this group is relevant.", 0, java.lang.Integer.MAX_VALUE, group));
477          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));
478        }
479
480      @Override
481      public void setProperty(String name, Base value) throws FHIRException {
482        if (name.equals("linkId"))
483          this.linkId = castToString(value); // StringType
484        else if (name.equals("title"))
485          this.title = castToString(value); // StringType
486        else if (name.equals("text"))
487          this.text = castToString(value); // StringType
488        else if (name.equals("subject"))
489          this.subject = castToReference(value); // Reference
490        else if (name.equals("group"))
491          this.getGroup().add((GroupComponent) value);
492        else if (name.equals("question"))
493          this.getQuestion().add((QuestionComponent) value);
494        else
495          super.setProperty(name, value);
496      }
497
498      @Override
499      public Base addChild(String name) throws FHIRException {
500        if (name.equals("linkId")) {
501          throw new FHIRException("Cannot call addChild on a primitive type QuestionnaireResponse.linkId");
502        }
503        else if (name.equals("title")) {
504          throw new FHIRException("Cannot call addChild on a primitive type QuestionnaireResponse.title");
505        }
506        else if (name.equals("text")) {
507          throw new FHIRException("Cannot call addChild on a primitive type QuestionnaireResponse.text");
508        }
509        else if (name.equals("subject")) {
510          this.subject = new Reference();
511          return this.subject;
512        }
513        else if (name.equals("group")) {
514          return addGroup();
515        }
516        else if (name.equals("question")) {
517          return addQuestion();
518        }
519        else
520          return super.addChild(name);
521      }
522
523      public GroupComponent copy() {
524        GroupComponent dst = new GroupComponent();
525        copyValues(dst);
526        dst.linkId = linkId == null ? null : linkId.copy();
527        dst.title = title == null ? null : title.copy();
528        dst.text = text == null ? null : text.copy();
529        dst.subject = subject == null ? null : subject.copy();
530        if (group != null) {
531          dst.group = new ArrayList<GroupComponent>();
532          for (GroupComponent i : group)
533            dst.group.add(i.copy());
534        };
535        if (question != null) {
536          dst.question = new ArrayList<QuestionComponent>();
537          for (QuestionComponent i : question)
538            dst.question.add(i.copy());
539        };
540        return dst;
541      }
542
543      @Override
544      public boolean equalsDeep(Base other) {
545        if (!super.equalsDeep(other))
546          return false;
547        if (!(other instanceof GroupComponent))
548          return false;
549        GroupComponent o = (GroupComponent) other;
550        return compareDeep(linkId, o.linkId, true) && compareDeep(title, o.title, true) && compareDeep(text, o.text, true)
551           && compareDeep(subject, o.subject, true) && compareDeep(group, o.group, true) && compareDeep(question, o.question, true)
552          ;
553      }
554
555      @Override
556      public boolean equalsShallow(Base other) {
557        if (!super.equalsShallow(other))
558          return false;
559        if (!(other instanceof GroupComponent))
560          return false;
561        GroupComponent o = (GroupComponent) other;
562        return compareValues(linkId, o.linkId, true) && compareValues(title, o.title, true) && compareValues(text, o.text, true)
563          ;
564      }
565
566      public boolean isEmpty() {
567        return super.isEmpty() && (linkId == null || linkId.isEmpty()) && (title == null || title.isEmpty())
568           && (text == null || text.isEmpty()) && (subject == null || subject.isEmpty()) && (group == null || group.isEmpty())
569           && (question == null || question.isEmpty());
570      }
571
572  public String fhirType() {
573    return "QuestionnaireResponse.group";
574
575  }
576
577  }
578
579    @Block()
580    public static class QuestionComponent extends BackboneElement implements IBaseBackboneElement {
581        /**
582         * Identifies the question from the Questionnaire that corresponds to this question in the QuestionnaireResponse resource.
583         */
584        @Child(name = "linkId", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=false)
585        @Description(shortDefinition="Corresponding question within Questionnaire", formalDefinition="Identifies the question from the Questionnaire that corresponds to this question in the QuestionnaireResponse resource." )
586        protected StringType linkId;
587
588        /**
589         * The actual question as shown to the user to prompt them for an answer.
590         */
591        @Child(name = "text", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=false)
592        @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." )
593        protected StringType text;
594
595        /**
596         * The respondent's answer(s) to the question.
597         */
598        @Child(name = "answer", type = {}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
599        @Description(shortDefinition="The response(s) to the question", formalDefinition="The respondent's answer(s) to the question." )
600        protected List<QuestionAnswerComponent> answer;
601
602        private static final long serialVersionUID = -265263901L;
603
604    /*
605     * Constructor
606     */
607      public QuestionComponent() {
608        super();
609      }
610
611        /**
612         * @return {@link #linkId} (Identifies the question from the Questionnaire that corresponds to this question in the QuestionnaireResponse resource.). This is the underlying object with id, value and extensions. The accessor "getLinkId" gives direct access to the value
613         */
614        public StringType getLinkIdElement() { 
615          if (this.linkId == null)
616            if (Configuration.errorOnAutoCreate())
617              throw new Error("Attempt to auto-create QuestionComponent.linkId");
618            else if (Configuration.doAutoCreate())
619              this.linkId = new StringType(); // bb
620          return this.linkId;
621        }
622
623        public boolean hasLinkIdElement() { 
624          return this.linkId != null && !this.linkId.isEmpty();
625        }
626
627        public boolean hasLinkId() { 
628          return this.linkId != null && !this.linkId.isEmpty();
629        }
630
631        /**
632         * @param value {@link #linkId} (Identifies the question from the Questionnaire that corresponds to this question in the QuestionnaireResponse resource.). This is the underlying object with id, value and extensions. The accessor "getLinkId" gives direct access to the value
633         */
634        public QuestionComponent setLinkIdElement(StringType value) { 
635          this.linkId = value;
636          return this;
637        }
638
639        /**
640         * @return Identifies the question from the Questionnaire that corresponds to this question in the QuestionnaireResponse resource.
641         */
642        public String getLinkId() { 
643          return this.linkId == null ? null : this.linkId.getValue();
644        }
645
646        /**
647         * @param value Identifies the question from the Questionnaire that corresponds to this question in the QuestionnaireResponse resource.
648         */
649        public QuestionComponent setLinkId(String value) { 
650          if (Utilities.noString(value))
651            this.linkId = null;
652          else {
653            if (this.linkId == null)
654              this.linkId = new StringType();
655            this.linkId.setValue(value);
656          }
657          return this;
658        }
659
660        /**
661         * @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
662         */
663        public StringType getTextElement() { 
664          if (this.text == null)
665            if (Configuration.errorOnAutoCreate())
666              throw new Error("Attempt to auto-create QuestionComponent.text");
667            else if (Configuration.doAutoCreate())
668              this.text = new StringType(); // bb
669          return this.text;
670        }
671
672        public boolean hasTextElement() { 
673          return this.text != null && !this.text.isEmpty();
674        }
675
676        public boolean hasText() { 
677          return this.text != null && !this.text.isEmpty();
678        }
679
680        /**
681         * @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
682         */
683        public QuestionComponent setTextElement(StringType value) { 
684          this.text = value;
685          return this;
686        }
687
688        /**
689         * @return The actual question as shown to the user to prompt them for an answer.
690         */
691        public String getText() { 
692          return this.text == null ? null : this.text.getValue();
693        }
694
695        /**
696         * @param value The actual question as shown to the user to prompt them for an answer.
697         */
698        public QuestionComponent setText(String value) { 
699          if (Utilities.noString(value))
700            this.text = null;
701          else {
702            if (this.text == null)
703              this.text = new StringType();
704            this.text.setValue(value);
705          }
706          return this;
707        }
708
709        /**
710         * @return {@link #answer} (The respondent's answer(s) to the question.)
711         */
712        public List<QuestionAnswerComponent> getAnswer() { 
713          if (this.answer == null)
714            this.answer = new ArrayList<QuestionAnswerComponent>();
715          return this.answer;
716        }
717
718        public boolean hasAnswer() { 
719          if (this.answer == null)
720            return false;
721          for (QuestionAnswerComponent item : this.answer)
722            if (!item.isEmpty())
723              return true;
724          return false;
725        }
726
727        /**
728         * @return {@link #answer} (The respondent's answer(s) to the question.)
729         */
730    // syntactic sugar
731        public QuestionAnswerComponent addAnswer() { //3
732          QuestionAnswerComponent t = new QuestionAnswerComponent();
733          if (this.answer == null)
734            this.answer = new ArrayList<QuestionAnswerComponent>();
735          this.answer.add(t);
736          return t;
737        }
738
739    // syntactic sugar
740        public QuestionComponent addAnswer(QuestionAnswerComponent t) { //3
741          if (t == null)
742            return this;
743          if (this.answer == null)
744            this.answer = new ArrayList<QuestionAnswerComponent>();
745          this.answer.add(t);
746          return this;
747        }
748
749        protected void listChildren(List<Property> childrenList) {
750          super.listChildren(childrenList);
751          childrenList.add(new Property("linkId", "string", "Identifies the question from the Questionnaire that corresponds to this question in the QuestionnaireResponse resource.", 0, java.lang.Integer.MAX_VALUE, linkId));
752          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));
753          childrenList.add(new Property("answer", "", "The respondent's answer(s) to the question.", 0, java.lang.Integer.MAX_VALUE, answer));
754        }
755
756      @Override
757      public void setProperty(String name, Base value) throws FHIRException {
758        if (name.equals("linkId"))
759          this.linkId = castToString(value); // StringType
760        else if (name.equals("text"))
761          this.text = castToString(value); // StringType
762        else if (name.equals("answer"))
763          this.getAnswer().add((QuestionAnswerComponent) value);
764        else
765          super.setProperty(name, value);
766      }
767
768      @Override
769      public Base addChild(String name) throws FHIRException {
770        if (name.equals("linkId")) {
771          throw new FHIRException("Cannot call addChild on a primitive type QuestionnaireResponse.linkId");
772        }
773        else if (name.equals("text")) {
774          throw new FHIRException("Cannot call addChild on a primitive type QuestionnaireResponse.text");
775        }
776        else if (name.equals("answer")) {
777          return addAnswer();
778        }
779        else
780          return super.addChild(name);
781      }
782
783      public QuestionComponent copy() {
784        QuestionComponent dst = new QuestionComponent();
785        copyValues(dst);
786        dst.linkId = linkId == null ? null : linkId.copy();
787        dst.text = text == null ? null : text.copy();
788        if (answer != null) {
789          dst.answer = new ArrayList<QuestionAnswerComponent>();
790          for (QuestionAnswerComponent i : answer)
791            dst.answer.add(i.copy());
792        };
793        return dst;
794      }
795
796      @Override
797      public boolean equalsDeep(Base other) {
798        if (!super.equalsDeep(other))
799          return false;
800        if (!(other instanceof QuestionComponent))
801          return false;
802        QuestionComponent o = (QuestionComponent) other;
803        return compareDeep(linkId, o.linkId, true) && compareDeep(text, o.text, true) && compareDeep(answer, o.answer, true)
804          ;
805      }
806
807      @Override
808      public boolean equalsShallow(Base other) {
809        if (!super.equalsShallow(other))
810          return false;
811        if (!(other instanceof QuestionComponent))
812          return false;
813        QuestionComponent o = (QuestionComponent) other;
814        return compareValues(linkId, o.linkId, true) && compareValues(text, o.text, true);
815      }
816
817      public boolean isEmpty() {
818        return super.isEmpty() && (linkId == null || linkId.isEmpty()) && (text == null || text.isEmpty())
819           && (answer == null || answer.isEmpty());
820      }
821
822  public String fhirType() {
823    return "QuestionnaireResponse.group.question";
824
825  }
826
827  }
828
829    @Block()
830    public static class QuestionAnswerComponent extends BackboneElement implements IBaseBackboneElement {
831        /**
832         * The answer (or one of the answers) provided by the respondent to the question.
833         */
834        @Child(name = "value", type = {BooleanType.class, DecimalType.class, IntegerType.class, DateType.class, DateTimeType.class, InstantType.class, TimeType.class, StringType.class, UriType.class, Attachment.class, Coding.class, Quantity.class}, order=1, min=0, max=1, modifier=false, summary=false)
835        @Description(shortDefinition="Single-valued answer to the question", formalDefinition="The answer (or one of the answers) provided by the respondent to the question." )
836        protected Type value;
837
838        /**
839         * Nested group, containing nested question for this question. The order of groups within the question is relevant.
840         */
841        @Child(name = "group", type = {GroupComponent.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
842        @Description(shortDefinition="Nested questionnaire group", formalDefinition="Nested group, containing nested question for this question. The order of groups within the question is relevant." )
843        protected List<GroupComponent> group;
844
845        private static final long serialVersionUID = -1223680118L;
846
847    /*
848     * Constructor
849     */
850      public QuestionAnswerComponent() {
851        super();
852      }
853
854        /**
855         * @return {@link #value} (The answer (or one of the answers) provided by the respondent to the question.)
856         */
857        public Type getValue() { 
858          return this.value;
859        }
860
861        /**
862         * @return {@link #value} (The answer (or one of the answers) provided by the respondent to the question.)
863         */
864        public BooleanType getValueBooleanType() throws FHIRException { 
865          if (!(this.value instanceof BooleanType))
866            throw new FHIRException("Type mismatch: the type BooleanType was expected, but "+this.value.getClass().getName()+" was encountered");
867          return (BooleanType) this.value;
868        }
869
870        public boolean hasValueBooleanType() { 
871          return this.value instanceof BooleanType;
872        }
873
874        /**
875         * @return {@link #value} (The answer (or one of the answers) provided by the respondent to the question.)
876         */
877        public DecimalType getValueDecimalType() throws FHIRException { 
878          if (!(this.value instanceof DecimalType))
879            throw new FHIRException("Type mismatch: the type DecimalType was expected, but "+this.value.getClass().getName()+" was encountered");
880          return (DecimalType) this.value;
881        }
882
883        public boolean hasValueDecimalType() { 
884          return this.value instanceof DecimalType;
885        }
886
887        /**
888         * @return {@link #value} (The answer (or one of the answers) provided by the respondent to the question.)
889         */
890        public IntegerType getValueIntegerType() throws FHIRException { 
891          if (!(this.value instanceof IntegerType))
892            throw new FHIRException("Type mismatch: the type IntegerType was expected, but "+this.value.getClass().getName()+" was encountered");
893          return (IntegerType) this.value;
894        }
895
896        public boolean hasValueIntegerType() { 
897          return this.value instanceof IntegerType;
898        }
899
900        /**
901         * @return {@link #value} (The answer (or one of the answers) provided by the respondent to the question.)
902         */
903        public DateType getValueDateType() throws FHIRException { 
904          if (!(this.value instanceof DateType))
905            throw new FHIRException("Type mismatch: the type DateType was expected, but "+this.value.getClass().getName()+" was encountered");
906          return (DateType) this.value;
907        }
908
909        public boolean hasValueDateType() { 
910          return this.value instanceof DateType;
911        }
912
913        /**
914         * @return {@link #value} (The answer (or one of the answers) provided by the respondent to the question.)
915         */
916        public DateTimeType getValueDateTimeType() throws FHIRException { 
917          if (!(this.value instanceof DateTimeType))
918            throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.value.getClass().getName()+" was encountered");
919          return (DateTimeType) this.value;
920        }
921
922        public boolean hasValueDateTimeType() { 
923          return this.value instanceof DateTimeType;
924        }
925
926        /**
927         * @return {@link #value} (The answer (or one of the answers) provided by the respondent to the question.)
928         */
929        public InstantType getValueInstantType() throws FHIRException { 
930          if (!(this.value instanceof InstantType))
931            throw new FHIRException("Type mismatch: the type InstantType was expected, but "+this.value.getClass().getName()+" was encountered");
932          return (InstantType) this.value;
933        }
934
935        public boolean hasValueInstantType() { 
936          return this.value instanceof InstantType;
937        }
938
939        /**
940         * @return {@link #value} (The answer (or one of the answers) provided by the respondent to the question.)
941         */
942        public TimeType getValueTimeType() throws FHIRException { 
943          if (!(this.value instanceof TimeType))
944            throw new FHIRException("Type mismatch: the type TimeType was expected, but "+this.value.getClass().getName()+" was encountered");
945          return (TimeType) this.value;
946        }
947
948        public boolean hasValueTimeType() { 
949          return this.value instanceof TimeType;
950        }
951
952        /**
953         * @return {@link #value} (The answer (or one of the answers) provided by the respondent to the question.)
954         */
955        public StringType getValueStringType() throws FHIRException { 
956          if (!(this.value instanceof StringType))
957            throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.value.getClass().getName()+" was encountered");
958          return (StringType) this.value;
959        }
960
961        public boolean hasValueStringType() { 
962          return this.value instanceof StringType;
963        }
964
965        /**
966         * @return {@link #value} (The answer (or one of the answers) provided by the respondent to the question.)
967         */
968        public UriType getValueUriType() throws FHIRException { 
969          if (!(this.value instanceof UriType))
970            throw new FHIRException("Type mismatch: the type UriType was expected, but "+this.value.getClass().getName()+" was encountered");
971          return (UriType) this.value;
972        }
973
974        public boolean hasValueUriType() { 
975          return this.value instanceof UriType;
976        }
977
978        /**
979         * @return {@link #value} (The answer (or one of the answers) provided by the respondent to the question.)
980         */
981        public Attachment getValueAttachment() throws FHIRException { 
982          if (!(this.value instanceof Attachment))
983            throw new FHIRException("Type mismatch: the type Attachment was expected, but "+this.value.getClass().getName()+" was encountered");
984          return (Attachment) this.value;
985        }
986
987        public boolean hasValueAttachment() { 
988          return this.value instanceof Attachment;
989        }
990
991        /**
992         * @return {@link #value} (The answer (or one of the answers) provided by the respondent to the question.)
993         */
994        public Coding getValueCoding() throws FHIRException { 
995          if (!(this.value instanceof Coding))
996            throw new FHIRException("Type mismatch: the type Coding was expected, but "+this.value.getClass().getName()+" was encountered");
997          return (Coding) this.value;
998        }
999
1000        public boolean hasValueCoding() { 
1001          return this.value instanceof Coding;
1002        }
1003
1004        /**
1005         * @return {@link #value} (The answer (or one of the answers) provided by the respondent to the question.)
1006         */
1007        public Quantity getValueQuantity() throws FHIRException { 
1008          if (!(this.value instanceof Quantity))
1009            throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.value.getClass().getName()+" was encountered");
1010          return (Quantity) this.value;
1011        }
1012
1013        public boolean hasValueQuantity() { 
1014          return this.value instanceof Quantity;
1015        }
1016
1017        /**
1018         * @return {@link #value} (The answer (or one of the answers) provided by the respondent to the question.)
1019         */
1020        public Reference getValueReference() throws FHIRException { 
1021          if (!(this.value instanceof Reference))
1022            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.value.getClass().getName()+" was encountered");
1023          return (Reference) this.value;
1024        }
1025
1026        public boolean hasValueReference() { 
1027          return this.value instanceof Reference;
1028        }
1029
1030        public boolean hasValue() { 
1031          return this.value != null && !this.value.isEmpty();
1032        }
1033
1034        /**
1035         * @param value {@link #value} (The answer (or one of the answers) provided by the respondent to the question.)
1036         */
1037        public QuestionAnswerComponent setValue(Type value) { 
1038          this.value = value;
1039          return this;
1040        }
1041
1042        /**
1043         * @return {@link #group} (Nested group, containing nested question for this question. The order of groups within the question is relevant.)
1044         */
1045        public List<GroupComponent> getGroup() { 
1046          if (this.group == null)
1047            this.group = new ArrayList<GroupComponent>();
1048          return this.group;
1049        }
1050
1051        public boolean hasGroup() { 
1052          if (this.group == null)
1053            return false;
1054          for (GroupComponent item : this.group)
1055            if (!item.isEmpty())
1056              return true;
1057          return false;
1058        }
1059
1060        /**
1061         * @return {@link #group} (Nested group, containing nested question for this question. The order of groups within the question is relevant.)
1062         */
1063    // syntactic sugar
1064        public GroupComponent addGroup() { //3
1065          GroupComponent t = new GroupComponent();
1066          if (this.group == null)
1067            this.group = new ArrayList<GroupComponent>();
1068          this.group.add(t);
1069          return t;
1070        }
1071
1072    // syntactic sugar
1073        public QuestionAnswerComponent addGroup(GroupComponent t) { //3
1074          if (t == null)
1075            return this;
1076          if (this.group == null)
1077            this.group = new ArrayList<GroupComponent>();
1078          this.group.add(t);
1079          return this;
1080        }
1081
1082        protected void listChildren(List<Property> childrenList) {
1083          super.listChildren(childrenList);
1084          childrenList.add(new Property("value[x]", "boolean|decimal|integer|date|dateTime|instant|time|string|uri|Attachment|Coding|Quantity|Reference(Any)", "The answer (or one of the answers) provided by the respondent to the question.", 0, java.lang.Integer.MAX_VALUE, value));
1085          childrenList.add(new Property("group", "@QuestionnaireResponse.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));
1086        }
1087
1088      @Override
1089      public void setProperty(String name, Base value) throws FHIRException {
1090        if (name.equals("value[x]"))
1091          this.value = (Type) value; // Type
1092        else if (name.equals("group"))
1093          this.getGroup().add((GroupComponent) value);
1094        else
1095          super.setProperty(name, value);
1096      }
1097
1098      @Override
1099      public Base addChild(String name) throws FHIRException {
1100        if (name.equals("valueBoolean")) {
1101          this.value = new BooleanType();
1102          return this.value;
1103        }
1104        else if (name.equals("valueDecimal")) {
1105          this.value = new DecimalType();
1106          return this.value;
1107        }
1108        else if (name.equals("valueInteger")) {
1109          this.value = new IntegerType();
1110          return this.value;
1111        }
1112        else if (name.equals("valueDate")) {
1113          this.value = new DateType();
1114          return this.value;
1115        }
1116        else if (name.equals("valueDateTime")) {
1117          this.value = new DateTimeType();
1118          return this.value;
1119        }
1120        else if (name.equals("valueInstant")) {
1121          this.value = new InstantType();
1122          return this.value;
1123        }
1124        else if (name.equals("valueTime")) {
1125          this.value = new TimeType();
1126          return this.value;
1127        }
1128        else if (name.equals("valueString")) {
1129          this.value = new StringType();
1130          return this.value;
1131        }
1132        else if (name.equals("valueUri")) {
1133          this.value = new UriType();
1134          return this.value;
1135        }
1136        else if (name.equals("valueAttachment")) {
1137          this.value = new Attachment();
1138          return this.value;
1139        }
1140        else if (name.equals("valueCoding")) {
1141          this.value = new Coding();
1142          return this.value;
1143        }
1144        else if (name.equals("valueQuantity")) {
1145          this.value = new Quantity();
1146          return this.value;
1147        }
1148        else if (name.equals("valueReference")) {
1149          this.value = new Reference();
1150          return this.value;
1151        }
1152        else if (name.equals("group")) {
1153          return addGroup();
1154        }
1155        else
1156          return super.addChild(name);
1157      }
1158
1159      public QuestionAnswerComponent copy() {
1160        QuestionAnswerComponent dst = new QuestionAnswerComponent();
1161        copyValues(dst);
1162        dst.value = value == null ? null : value.copy();
1163        if (group != null) {
1164          dst.group = new ArrayList<GroupComponent>();
1165          for (GroupComponent i : group)
1166            dst.group.add(i.copy());
1167        };
1168        return dst;
1169      }
1170
1171      @Override
1172      public boolean equalsDeep(Base other) {
1173        if (!super.equalsDeep(other))
1174          return false;
1175        if (!(other instanceof QuestionAnswerComponent))
1176          return false;
1177        QuestionAnswerComponent o = (QuestionAnswerComponent) other;
1178        return compareDeep(value, o.value, true) && compareDeep(group, o.group, true);
1179      }
1180
1181      @Override
1182      public boolean equalsShallow(Base other) {
1183        if (!super.equalsShallow(other))
1184          return false;
1185        if (!(other instanceof QuestionAnswerComponent))
1186          return false;
1187        QuestionAnswerComponent o = (QuestionAnswerComponent) other;
1188        return true;
1189      }
1190
1191      public boolean isEmpty() {
1192        return super.isEmpty() && (value == null || value.isEmpty()) && (group == null || group.isEmpty())
1193          ;
1194      }
1195
1196  public String fhirType() {
1197    return "QuestionnaireResponse.group.question.answer";
1198
1199  }
1200
1201  }
1202
1203    /**
1204     * A business identifier assigned to a particular completed (or partially completed) questionnaire.
1205     */
1206    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=1, modifier=false, summary=true)
1207    @Description(shortDefinition="Unique id for this set of answers", formalDefinition="A business identifier assigned to a particular completed (or partially completed) questionnaire." )
1208    protected Identifier identifier;
1209
1210    /**
1211     * Indicates the Questionnaire resource that defines the form for which answers are being provided.
1212     */
1213    @Child(name = "questionnaire", type = {Questionnaire.class}, order=1, min=0, max=1, modifier=false, summary=true)
1214    @Description(shortDefinition="Form being answered", formalDefinition="Indicates the Questionnaire resource that defines the form for which answers are being provided." )
1215    protected Reference questionnaire;
1216
1217    /**
1218     * The actual object that is the target of the reference (Indicates the Questionnaire resource that defines the form for which answers are being provided.)
1219     */
1220    protected Questionnaire questionnaireTarget;
1221
1222    /**
1223     * The lifecycle status of the questionnaire response as a whole.
1224     */
1225    @Child(name = "status", type = {CodeType.class}, order=2, min=1, max=1, modifier=true, summary=true)
1226    @Description(shortDefinition="in-progress | completed | amended", formalDefinition="The lifecycle status of the questionnaire response as a whole." )
1227    protected Enumeration<QuestionnaireResponseStatus> status;
1228
1229    /**
1230     * The subject of the questionnaire response.  This could be a patient, organization, practitioner, device, etc.  This is who/what the answers apply to, but is not necessarily the source of information.
1231     */
1232    @Child(name = "subject", type = {}, order=3, min=0, max=1, modifier=false, summary=true)
1233    @Description(shortDefinition="The subject of the questions", formalDefinition="The subject of the questionnaire response.  This could be a patient, organization, practitioner, device, etc.  This is who/what the answers apply to, but is not necessarily the source of information." )
1234    protected Reference subject;
1235
1236    /**
1237     * The actual object that is the target of the reference (The subject of the questionnaire response.  This could be a patient, organization, practitioner, device, etc.  This is who/what the answers apply to, but is not necessarily the source of information.)
1238     */
1239    protected Resource subjectTarget;
1240
1241    /**
1242     * Person who received the answers to the questions in the QuestionnaireResponse and recorded them in the system.
1243     */
1244    @Child(name = "author", type = {Device.class, Practitioner.class, Patient.class, RelatedPerson.class}, order=4, min=0, max=1, modifier=false, summary=true)
1245    @Description(shortDefinition="Person who received and recorded the answers", formalDefinition="Person who received the answers to the questions in the QuestionnaireResponse and recorded them in the system." )
1246    protected Reference author;
1247
1248    /**
1249     * The actual object that is the target of the reference (Person who received the answers to the questions in the QuestionnaireResponse and recorded them in the system.)
1250     */
1251    protected Resource authorTarget;
1252
1253    /**
1254     * The date and/or time that this version of the questionnaire response was authored.
1255     */
1256    @Child(name = "authored", type = {DateTimeType.class}, order=5, min=0, max=1, modifier=false, summary=true)
1257    @Description(shortDefinition="Date this version was authored", formalDefinition="The date and/or time that this version of the questionnaire response was authored." )
1258    protected DateTimeType authored;
1259
1260    /**
1261     * The person who answered the questions about the subject.
1262     */
1263    @Child(name = "source", type = {Patient.class, Practitioner.class, RelatedPerson.class}, order=6, min=0, max=1, modifier=false, summary=true)
1264    @Description(shortDefinition="The person who answered the questions", formalDefinition="The person who answered the questions about the subject." )
1265    protected Reference source;
1266
1267    /**
1268     * The actual object that is the target of the reference (The person who answered the questions about the subject.)
1269     */
1270    protected Resource sourceTarget;
1271
1272    /**
1273     * Encounter during which this set of questionnaire response were collected. When there were multiple encounters, this is the one considered most relevant to the context of the answers.
1274     */
1275    @Child(name = "encounter", type = {Encounter.class}, order=7, min=0, max=1, modifier=false, summary=true)
1276    @Description(shortDefinition="Primary encounter during which the answers were collected", formalDefinition="Encounter during which this set of questionnaire response were collected. When there were multiple encounters, this is the one considered most relevant to the context of the answers." )
1277    protected Reference encounter;
1278
1279    /**
1280     * The actual object that is the target of the reference (Encounter during which this set of questionnaire response were collected. When there were multiple encounters, this is the one considered most relevant to the context of the answers.)
1281     */
1282    protected Encounter encounterTarget;
1283
1284    /**
1285     * A group of questions to a possibly similarly grouped set of questions in the questionnaire response.
1286     */
1287    @Child(name = "group", type = {}, order=8, min=0, max=1, modifier=false, summary=false)
1288    @Description(shortDefinition="Grouped questions", formalDefinition="A group of questions to a possibly similarly grouped set of questions in the questionnaire response." )
1289    protected GroupComponent group;
1290
1291    private static final long serialVersionUID = -1081988635L;
1292
1293  /*
1294   * Constructor
1295   */
1296    public QuestionnaireResponse() {
1297      super();
1298    }
1299
1300  /*
1301   * Constructor
1302   */
1303    public QuestionnaireResponse(Enumeration<QuestionnaireResponseStatus> status) {
1304      super();
1305      this.status = status;
1306    }
1307
1308    /**
1309     * @return {@link #identifier} (A business identifier assigned to a particular completed (or partially completed) questionnaire.)
1310     */
1311    public Identifier getIdentifier() { 
1312      if (this.identifier == null)
1313        if (Configuration.errorOnAutoCreate())
1314          throw new Error("Attempt to auto-create QuestionnaireResponse.identifier");
1315        else if (Configuration.doAutoCreate())
1316          this.identifier = new Identifier(); // cc
1317      return this.identifier;
1318    }
1319
1320    public boolean hasIdentifier() { 
1321      return this.identifier != null && !this.identifier.isEmpty();
1322    }
1323
1324    /**
1325     * @param value {@link #identifier} (A business identifier assigned to a particular completed (or partially completed) questionnaire.)
1326     */
1327    public QuestionnaireResponse setIdentifier(Identifier value) { 
1328      this.identifier = value;
1329      return this;
1330    }
1331
1332    /**
1333     * @return {@link #questionnaire} (Indicates the Questionnaire resource that defines the form for which answers are being provided.)
1334     */
1335    public Reference getQuestionnaire() { 
1336      if (this.questionnaire == null)
1337        if (Configuration.errorOnAutoCreate())
1338          throw new Error("Attempt to auto-create QuestionnaireResponse.questionnaire");
1339        else if (Configuration.doAutoCreate())
1340          this.questionnaire = new Reference(); // cc
1341      return this.questionnaire;
1342    }
1343
1344    public boolean hasQuestionnaire() { 
1345      return this.questionnaire != null && !this.questionnaire.isEmpty();
1346    }
1347
1348    /**
1349     * @param value {@link #questionnaire} (Indicates the Questionnaire resource that defines the form for which answers are being provided.)
1350     */
1351    public QuestionnaireResponse setQuestionnaire(Reference value) { 
1352      this.questionnaire = value;
1353      return this;
1354    }
1355
1356    /**
1357     * @return {@link #questionnaire} 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. (Indicates the Questionnaire resource that defines the form for which answers are being provided.)
1358     */
1359    public Questionnaire getQuestionnaireTarget() { 
1360      if (this.questionnaireTarget == null)
1361        if (Configuration.errorOnAutoCreate())
1362          throw new Error("Attempt to auto-create QuestionnaireResponse.questionnaire");
1363        else if (Configuration.doAutoCreate())
1364          this.questionnaireTarget = new Questionnaire(); // aa
1365      return this.questionnaireTarget;
1366    }
1367
1368    /**
1369     * @param value {@link #questionnaire} 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. (Indicates the Questionnaire resource that defines the form for which answers are being provided.)
1370     */
1371    public QuestionnaireResponse setQuestionnaireTarget(Questionnaire value) { 
1372      this.questionnaireTarget = value;
1373      return this;
1374    }
1375
1376    /**
1377     * @return {@link #status} (The lifecycle status of the questionnaire response as a whole.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1378     */
1379    public Enumeration<QuestionnaireResponseStatus> getStatusElement() { 
1380      if (this.status == null)
1381        if (Configuration.errorOnAutoCreate())
1382          throw new Error("Attempt to auto-create QuestionnaireResponse.status");
1383        else if (Configuration.doAutoCreate())
1384          this.status = new Enumeration<QuestionnaireResponseStatus>(new QuestionnaireResponseStatusEnumFactory()); // bb
1385      return this.status;
1386    }
1387
1388    public boolean hasStatusElement() { 
1389      return this.status != null && !this.status.isEmpty();
1390    }
1391
1392    public boolean hasStatus() { 
1393      return this.status != null && !this.status.isEmpty();
1394    }
1395
1396    /**
1397     * @param value {@link #status} (The lifecycle status of the questionnaire response as a whole.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1398     */
1399    public QuestionnaireResponse setStatusElement(Enumeration<QuestionnaireResponseStatus> value) { 
1400      this.status = value;
1401      return this;
1402    }
1403
1404    /**
1405     * @return The lifecycle status of the questionnaire response as a whole.
1406     */
1407    public QuestionnaireResponseStatus getStatus() { 
1408      return this.status == null ? null : this.status.getValue();
1409    }
1410
1411    /**
1412     * @param value The lifecycle status of the questionnaire response as a whole.
1413     */
1414    public QuestionnaireResponse setStatus(QuestionnaireResponseStatus value) { 
1415        if (this.status == null)
1416          this.status = new Enumeration<QuestionnaireResponseStatus>(new QuestionnaireResponseStatusEnumFactory());
1417        this.status.setValue(value);
1418      return this;
1419    }
1420
1421    /**
1422     * @return {@link #subject} (The subject of the questionnaire response.  This could be a patient, organization, practitioner, device, etc.  This is who/what the answers apply to, but is not necessarily the source of information.)
1423     */
1424    public Reference getSubject() { 
1425      if (this.subject == null)
1426        if (Configuration.errorOnAutoCreate())
1427          throw new Error("Attempt to auto-create QuestionnaireResponse.subject");
1428        else if (Configuration.doAutoCreate())
1429          this.subject = new Reference(); // cc
1430      return this.subject;
1431    }
1432
1433    public boolean hasSubject() { 
1434      return this.subject != null && !this.subject.isEmpty();
1435    }
1436
1437    /**
1438     * @param value {@link #subject} (The subject of the questionnaire response.  This could be a patient, organization, practitioner, device, etc.  This is who/what the answers apply to, but is not necessarily the source of information.)
1439     */
1440    public QuestionnaireResponse setSubject(Reference value) { 
1441      this.subject = value;
1442      return this;
1443    }
1444
1445    /**
1446     * @return {@link #subject} 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. (The subject of the questionnaire response.  This could be a patient, organization, practitioner, device, etc.  This is who/what the answers apply to, but is not necessarily the source of information.)
1447     */
1448    public Resource getSubjectTarget() { 
1449      return this.subjectTarget;
1450    }
1451
1452    /**
1453     * @param value {@link #subject} 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. (The subject of the questionnaire response.  This could be a patient, organization, practitioner, device, etc.  This is who/what the answers apply to, but is not necessarily the source of information.)
1454     */
1455    public QuestionnaireResponse setSubjectTarget(Resource value) { 
1456      this.subjectTarget = value;
1457      return this;
1458    }
1459
1460    /**
1461     * @return {@link #author} (Person who received the answers to the questions in the QuestionnaireResponse and recorded them in the system.)
1462     */
1463    public Reference getAuthor() { 
1464      if (this.author == null)
1465        if (Configuration.errorOnAutoCreate())
1466          throw new Error("Attempt to auto-create QuestionnaireResponse.author");
1467        else if (Configuration.doAutoCreate())
1468          this.author = new Reference(); // cc
1469      return this.author;
1470    }
1471
1472    public boolean hasAuthor() { 
1473      return this.author != null && !this.author.isEmpty();
1474    }
1475
1476    /**
1477     * @param value {@link #author} (Person who received the answers to the questions in the QuestionnaireResponse and recorded them in the system.)
1478     */
1479    public QuestionnaireResponse setAuthor(Reference value) { 
1480      this.author = value;
1481      return this;
1482    }
1483
1484    /**
1485     * @return {@link #author} 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. (Person who received the answers to the questions in the QuestionnaireResponse and recorded them in the system.)
1486     */
1487    public Resource getAuthorTarget() { 
1488      return this.authorTarget;
1489    }
1490
1491    /**
1492     * @param value {@link #author} 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. (Person who received the answers to the questions in the QuestionnaireResponse and recorded them in the system.)
1493     */
1494    public QuestionnaireResponse setAuthorTarget(Resource value) { 
1495      this.authorTarget = value;
1496      return this;
1497    }
1498
1499    /**
1500     * @return {@link #authored} (The date and/or time that this version of the questionnaire response was authored.). This is the underlying object with id, value and extensions. The accessor "getAuthored" gives direct access to the value
1501     */
1502    public DateTimeType getAuthoredElement() { 
1503      if (this.authored == null)
1504        if (Configuration.errorOnAutoCreate())
1505          throw new Error("Attempt to auto-create QuestionnaireResponse.authored");
1506        else if (Configuration.doAutoCreate())
1507          this.authored = new DateTimeType(); // bb
1508      return this.authored;
1509    }
1510
1511    public boolean hasAuthoredElement() { 
1512      return this.authored != null && !this.authored.isEmpty();
1513    }
1514
1515    public boolean hasAuthored() { 
1516      return this.authored != null && !this.authored.isEmpty();
1517    }
1518
1519    /**
1520     * @param value {@link #authored} (The date and/or time that this version of the questionnaire response was authored.). This is the underlying object with id, value and extensions. The accessor "getAuthored" gives direct access to the value
1521     */
1522    public QuestionnaireResponse setAuthoredElement(DateTimeType value) { 
1523      this.authored = value;
1524      return this;
1525    }
1526
1527    /**
1528     * @return The date and/or time that this version of the questionnaire response was authored.
1529     */
1530    public Date getAuthored() { 
1531      return this.authored == null ? null : this.authored.getValue();
1532    }
1533
1534    /**
1535     * @param value The date and/or time that this version of the questionnaire response was authored.
1536     */
1537    public QuestionnaireResponse setAuthored(Date value) { 
1538      if (value == null)
1539        this.authored = null;
1540      else {
1541        if (this.authored == null)
1542          this.authored = new DateTimeType();
1543        this.authored.setValue(value);
1544      }
1545      return this;
1546    }
1547
1548    /**
1549     * @return {@link #source} (The person who answered the questions about the subject.)
1550     */
1551    public Reference getSource() { 
1552      if (this.source == null)
1553        if (Configuration.errorOnAutoCreate())
1554          throw new Error("Attempt to auto-create QuestionnaireResponse.source");
1555        else if (Configuration.doAutoCreate())
1556          this.source = new Reference(); // cc
1557      return this.source;
1558    }
1559
1560    public boolean hasSource() { 
1561      return this.source != null && !this.source.isEmpty();
1562    }
1563
1564    /**
1565     * @param value {@link #source} (The person who answered the questions about the subject.)
1566     */
1567    public QuestionnaireResponse setSource(Reference value) { 
1568      this.source = value;
1569      return this;
1570    }
1571
1572    /**
1573     * @return {@link #source} 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. (The person who answered the questions about the subject.)
1574     */
1575    public Resource getSourceTarget() { 
1576      return this.sourceTarget;
1577    }
1578
1579    /**
1580     * @param value {@link #source} 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. (The person who answered the questions about the subject.)
1581     */
1582    public QuestionnaireResponse setSourceTarget(Resource value) { 
1583      this.sourceTarget = value;
1584      return this;
1585    }
1586
1587    /**
1588     * @return {@link #encounter} (Encounter during which this set of questionnaire response were collected. When there were multiple encounters, this is the one considered most relevant to the context of the answers.)
1589     */
1590    public Reference getEncounter() { 
1591      if (this.encounter == null)
1592        if (Configuration.errorOnAutoCreate())
1593          throw new Error("Attempt to auto-create QuestionnaireResponse.encounter");
1594        else if (Configuration.doAutoCreate())
1595          this.encounter = new Reference(); // cc
1596      return this.encounter;
1597    }
1598
1599    public boolean hasEncounter() { 
1600      return this.encounter != null && !this.encounter.isEmpty();
1601    }
1602
1603    /**
1604     * @param value {@link #encounter} (Encounter during which this set of questionnaire response were collected. When there were multiple encounters, this is the one considered most relevant to the context of the answers.)
1605     */
1606    public QuestionnaireResponse setEncounter(Reference value) { 
1607      this.encounter = value;
1608      return this;
1609    }
1610
1611    /**
1612     * @return {@link #encounter} 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. (Encounter during which this set of questionnaire response were collected. When there were multiple encounters, this is the one considered most relevant to the context of the answers.)
1613     */
1614    public Encounter getEncounterTarget() { 
1615      if (this.encounterTarget == null)
1616        if (Configuration.errorOnAutoCreate())
1617          throw new Error("Attempt to auto-create QuestionnaireResponse.encounter");
1618        else if (Configuration.doAutoCreate())
1619          this.encounterTarget = new Encounter(); // aa
1620      return this.encounterTarget;
1621    }
1622
1623    /**
1624     * @param value {@link #encounter} 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. (Encounter during which this set of questionnaire response were collected. When there were multiple encounters, this is the one considered most relevant to the context of the answers.)
1625     */
1626    public QuestionnaireResponse setEncounterTarget(Encounter value) { 
1627      this.encounterTarget = value;
1628      return this;
1629    }
1630
1631    /**
1632     * @return {@link #group} (A group of questions to a possibly similarly grouped set of questions in the questionnaire response.)
1633     */
1634    public GroupComponent getGroup() { 
1635      if (this.group == null)
1636        if (Configuration.errorOnAutoCreate())
1637          throw new Error("Attempt to auto-create QuestionnaireResponse.group");
1638        else if (Configuration.doAutoCreate())
1639          this.group = new GroupComponent(); // cc
1640      return this.group;
1641    }
1642
1643    public boolean hasGroup() { 
1644      return this.group != null && !this.group.isEmpty();
1645    }
1646
1647    /**
1648     * @param value {@link #group} (A group of questions to a possibly similarly grouped set of questions in the questionnaire response.)
1649     */
1650    public QuestionnaireResponse setGroup(GroupComponent value) { 
1651      this.group = value;
1652      return this;
1653    }
1654
1655      protected void listChildren(List<Property> childrenList) {
1656        super.listChildren(childrenList);
1657        childrenList.add(new Property("identifier", "Identifier", "A business identifier assigned to a particular completed (or partially completed) questionnaire.", 0, java.lang.Integer.MAX_VALUE, identifier));
1658        childrenList.add(new Property("questionnaire", "Reference(Questionnaire)", "Indicates the Questionnaire resource that defines the form for which answers are being provided.", 0, java.lang.Integer.MAX_VALUE, questionnaire));
1659        childrenList.add(new Property("status", "code", "The lifecycle status of the questionnaire response as a whole.", 0, java.lang.Integer.MAX_VALUE, status));
1660        childrenList.add(new Property("subject", "Reference(Any)", "The subject of the questionnaire response.  This could be a patient, organization, practitioner, device, etc.  This is who/what the answers apply to, but is not necessarily the source of information.", 0, java.lang.Integer.MAX_VALUE, subject));
1661        childrenList.add(new Property("author", "Reference(Device|Practitioner|Patient|RelatedPerson)", "Person who received the answers to the questions in the QuestionnaireResponse and recorded them in the system.", 0, java.lang.Integer.MAX_VALUE, author));
1662        childrenList.add(new Property("authored", "dateTime", "The date and/or time that this version of the questionnaire response was authored.", 0, java.lang.Integer.MAX_VALUE, authored));
1663        childrenList.add(new Property("source", "Reference(Patient|Practitioner|RelatedPerson)", "The person who answered the questions about the subject.", 0, java.lang.Integer.MAX_VALUE, source));
1664        childrenList.add(new Property("encounter", "Reference(Encounter)", "Encounter during which this set of questionnaire response were collected. When there were multiple encounters, this is the one considered most relevant to the context of the answers.", 0, java.lang.Integer.MAX_VALUE, encounter));
1665        childrenList.add(new Property("group", "", "A group of questions to a possibly similarly grouped set of questions in the questionnaire response.", 0, java.lang.Integer.MAX_VALUE, group));
1666      }
1667
1668      @Override
1669      public void setProperty(String name, Base value) throws FHIRException {
1670        if (name.equals("identifier"))
1671          this.identifier = castToIdentifier(value); // Identifier
1672        else if (name.equals("questionnaire"))
1673          this.questionnaire = castToReference(value); // Reference
1674        else if (name.equals("status"))
1675          this.status = new QuestionnaireResponseStatusEnumFactory().fromType(value); // Enumeration<QuestionnaireResponseStatus>
1676        else if (name.equals("subject"))
1677          this.subject = castToReference(value); // Reference
1678        else if (name.equals("author"))
1679          this.author = castToReference(value); // Reference
1680        else if (name.equals("authored"))
1681          this.authored = castToDateTime(value); // DateTimeType
1682        else if (name.equals("source"))
1683          this.source = castToReference(value); // Reference
1684        else if (name.equals("encounter"))
1685          this.encounter = castToReference(value); // Reference
1686        else if (name.equals("group"))
1687          this.group = (GroupComponent) value; // GroupComponent
1688        else
1689          super.setProperty(name, value);
1690      }
1691
1692      @Override
1693      public Base addChild(String name) throws FHIRException {
1694        if (name.equals("identifier")) {
1695          this.identifier = new Identifier();
1696          return this.identifier;
1697        }
1698        else if (name.equals("questionnaire")) {
1699          this.questionnaire = new Reference();
1700          return this.questionnaire;
1701        }
1702        else if (name.equals("status")) {
1703          throw new FHIRException("Cannot call addChild on a primitive type QuestionnaireResponse.status");
1704        }
1705        else if (name.equals("subject")) {
1706          this.subject = new Reference();
1707          return this.subject;
1708        }
1709        else if (name.equals("author")) {
1710          this.author = new Reference();
1711          return this.author;
1712        }
1713        else if (name.equals("authored")) {
1714          throw new FHIRException("Cannot call addChild on a primitive type QuestionnaireResponse.authored");
1715        }
1716        else if (name.equals("source")) {
1717          this.source = new Reference();
1718          return this.source;
1719        }
1720        else if (name.equals("encounter")) {
1721          this.encounter = new Reference();
1722          return this.encounter;
1723        }
1724        else if (name.equals("group")) {
1725          this.group = new GroupComponent();
1726          return this.group;
1727        }
1728        else
1729          return super.addChild(name);
1730      }
1731
1732  public String fhirType() {
1733    return "QuestionnaireResponse";
1734
1735  }
1736
1737      public QuestionnaireResponse copy() {
1738        QuestionnaireResponse dst = new QuestionnaireResponse();
1739        copyValues(dst);
1740        dst.identifier = identifier == null ? null : identifier.copy();
1741        dst.questionnaire = questionnaire == null ? null : questionnaire.copy();
1742        dst.status = status == null ? null : status.copy();
1743        dst.subject = subject == null ? null : subject.copy();
1744        dst.author = author == null ? null : author.copy();
1745        dst.authored = authored == null ? null : authored.copy();
1746        dst.source = source == null ? null : source.copy();
1747        dst.encounter = encounter == null ? null : encounter.copy();
1748        dst.group = group == null ? null : group.copy();
1749        return dst;
1750      }
1751
1752      protected QuestionnaireResponse typedCopy() {
1753        return copy();
1754      }
1755
1756      @Override
1757      public boolean equalsDeep(Base other) {
1758        if (!super.equalsDeep(other))
1759          return false;
1760        if (!(other instanceof QuestionnaireResponse))
1761          return false;
1762        QuestionnaireResponse o = (QuestionnaireResponse) other;
1763        return compareDeep(identifier, o.identifier, true) && compareDeep(questionnaire, o.questionnaire, true)
1764           && compareDeep(status, o.status, true) && compareDeep(subject, o.subject, true) && compareDeep(author, o.author, true)
1765           && compareDeep(authored, o.authored, true) && compareDeep(source, o.source, true) && compareDeep(encounter, o.encounter, true)
1766           && compareDeep(group, o.group, true);
1767      }
1768
1769      @Override
1770      public boolean equalsShallow(Base other) {
1771        if (!super.equalsShallow(other))
1772          return false;
1773        if (!(other instanceof QuestionnaireResponse))
1774          return false;
1775        QuestionnaireResponse o = (QuestionnaireResponse) other;
1776        return compareValues(status, o.status, true) && compareValues(authored, o.authored, true);
1777      }
1778
1779      public boolean isEmpty() {
1780        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (questionnaire == null || questionnaire.isEmpty())
1781           && (status == null || status.isEmpty()) && (subject == null || subject.isEmpty()) && (author == null || author.isEmpty())
1782           && (authored == null || authored.isEmpty()) && (source == null || source.isEmpty()) && (encounter == null || encounter.isEmpty())
1783           && (group == null || group.isEmpty());
1784      }
1785
1786  @Override
1787  public ResourceType getResourceType() {
1788    return ResourceType.QuestionnaireResponse;
1789   }
1790
1791  @SearchParamDefinition(name="authored", path="QuestionnaireResponse.authored", description="When the questionnaire was authored", type="date" )
1792  public static final String SP_AUTHORED = "authored";
1793  @SearchParamDefinition(name="questionnaire", path="QuestionnaireResponse.questionnaire", description="The questionnaire the answers are provided for", type="reference" )
1794  public static final String SP_QUESTIONNAIRE = "questionnaire";
1795  @SearchParamDefinition(name="subject", path="QuestionnaireResponse.subject", description="The subject of the questionnaire", type="reference" )
1796  public static final String SP_SUBJECT = "subject";
1797  @SearchParamDefinition(name="author", path="QuestionnaireResponse.author", description="The author of the questionnaire", type="reference" )
1798  public static final String SP_AUTHOR = "author";
1799  @SearchParamDefinition(name="patient", path="QuestionnaireResponse.subject", description="The patient that is the subject of the questionnaire", type="reference" )
1800  public static final String SP_PATIENT = "patient";
1801  @SearchParamDefinition(name="encounter", path="QuestionnaireResponse.encounter", description="Encounter during which questionnaire was authored", type="reference" )
1802  public static final String SP_ENCOUNTER = "encounter";
1803  @SearchParamDefinition(name="source", path="QuestionnaireResponse.source", description="The person who answered the questions", type="reference" )
1804  public static final String SP_SOURCE = "source";
1805  @SearchParamDefinition(name="status", path="QuestionnaireResponse.status", description="The status of the questionnaire response", type="token" )
1806  public static final String SP_STATUS = "status";
1807
1808}
1809