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