001package org.hl7.fhir.dstu3.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 Fri, Mar 16, 2018 15:21+1100 for FHIR v3.0.1
033
034import java.util.*;
035
036import org.hl7.fhir.utilities.Utilities;
037import ca.uhn.fhir.model.api.annotation.ResourceDef;
038import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
039import ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.ChildOrder;
041import ca.uhn.fhir.model.api.annotation.Description;
042import ca.uhn.fhir.model.api.annotation.Block;
043import org.hl7.fhir.instance.model.api.*;
044import org.hl7.fhir.exceptions.FHIRException;
045import org.hl7.fhir.exceptions.FHIRFormatError;
046/**
047 * A process where a researcher or organization plans and then executes a series of steps intended to increase the field of healthcare-related knowledge.  This includes studies of safety, efficacy, comparative effectiveness and other information about medications, devices, therapies and other interventional and investigative techniques.  A ResearchStudy involves the gathering of information about human or animal subjects.
048 */
049@ResourceDef(name="ResearchSubject", profile="http://hl7.org/fhir/StructureDefinition/ResearchSubject")
050public class ResearchSubject extends DomainResource {
051
052    public enum ResearchSubjectStatus {
053        /**
054         * The subject has been identified as a potential participant in the study but has not yet agreed to participate
055         */
056        CANDIDATE, 
057        /**
058         * The subject has agreed to participate in the study but has not yet begun performing any action within the study
059         */
060        ENROLLED, 
061        /**
062         * The subject is currently being monitored and/or subject to treatment as part of the study
063         */
064        ACTIVE, 
065        /**
066         * The subject has temporarily discontinued monitoring/treatment as part of the study
067         */
068        SUSPENDED, 
069        /**
070         * The subject has permanently ended participation in the study prior to completion of the intended monitoring/treatment
071         */
072        WITHDRAWN, 
073        /**
074         * All intended monitoring/treatment of the subject has been completed and their engagement with the study is now ended
075         */
076        COMPLETED, 
077        /**
078         * added to help the parsers with the generic types
079         */
080        NULL;
081        public static ResearchSubjectStatus fromCode(String codeString) throws FHIRException {
082            if (codeString == null || "".equals(codeString))
083                return null;
084        if ("candidate".equals(codeString))
085          return CANDIDATE;
086        if ("enrolled".equals(codeString))
087          return ENROLLED;
088        if ("active".equals(codeString))
089          return ACTIVE;
090        if ("suspended".equals(codeString))
091          return SUSPENDED;
092        if ("withdrawn".equals(codeString))
093          return WITHDRAWN;
094        if ("completed".equals(codeString))
095          return COMPLETED;
096        if (Configuration.isAcceptInvalidEnums())
097          return null;
098        else
099          throw new FHIRException("Unknown ResearchSubjectStatus code '"+codeString+"'");
100        }
101        public String toCode() {
102          switch (this) {
103            case CANDIDATE: return "candidate";
104            case ENROLLED: return "enrolled";
105            case ACTIVE: return "active";
106            case SUSPENDED: return "suspended";
107            case WITHDRAWN: return "withdrawn";
108            case COMPLETED: return "completed";
109            default: return "?";
110          }
111        }
112        public String getSystem() {
113          switch (this) {
114            case CANDIDATE: return "http://hl7.org/fhir/research-subject-status";
115            case ENROLLED: return "http://hl7.org/fhir/research-subject-status";
116            case ACTIVE: return "http://hl7.org/fhir/research-subject-status";
117            case SUSPENDED: return "http://hl7.org/fhir/research-subject-status";
118            case WITHDRAWN: return "http://hl7.org/fhir/research-subject-status";
119            case COMPLETED: return "http://hl7.org/fhir/research-subject-status";
120            default: return "?";
121          }
122        }
123        public String getDefinition() {
124          switch (this) {
125            case CANDIDATE: return "The subject has been identified as a potential participant in the study but has not yet agreed to participate";
126            case ENROLLED: return "The subject has agreed to participate in the study but has not yet begun performing any action within the study";
127            case ACTIVE: return "The subject is currently being monitored and/or subject to treatment as part of the study";
128            case SUSPENDED: return "The subject has temporarily discontinued monitoring/treatment as part of the study";
129            case WITHDRAWN: return "The subject has permanently ended participation in the study prior to completion of the intended monitoring/treatment";
130            case COMPLETED: return "All intended monitoring/treatment of the subject has been completed and their engagement with the study is now ended";
131            default: return "?";
132          }
133        }
134        public String getDisplay() {
135          switch (this) {
136            case CANDIDATE: return "Candidate";
137            case ENROLLED: return "Enrolled";
138            case ACTIVE: return "Active";
139            case SUSPENDED: return "Suspended";
140            case WITHDRAWN: return "Withdrawn";
141            case COMPLETED: return "Completed";
142            default: return "?";
143          }
144        }
145    }
146
147  public static class ResearchSubjectStatusEnumFactory implements EnumFactory<ResearchSubjectStatus> {
148    public ResearchSubjectStatus fromCode(String codeString) throws IllegalArgumentException {
149      if (codeString == null || "".equals(codeString))
150            if (codeString == null || "".equals(codeString))
151                return null;
152        if ("candidate".equals(codeString))
153          return ResearchSubjectStatus.CANDIDATE;
154        if ("enrolled".equals(codeString))
155          return ResearchSubjectStatus.ENROLLED;
156        if ("active".equals(codeString))
157          return ResearchSubjectStatus.ACTIVE;
158        if ("suspended".equals(codeString))
159          return ResearchSubjectStatus.SUSPENDED;
160        if ("withdrawn".equals(codeString))
161          return ResearchSubjectStatus.WITHDRAWN;
162        if ("completed".equals(codeString))
163          return ResearchSubjectStatus.COMPLETED;
164        throw new IllegalArgumentException("Unknown ResearchSubjectStatus code '"+codeString+"'");
165        }
166        public Enumeration<ResearchSubjectStatus> fromType(Base code) throws FHIRException {
167          if (code == null)
168            return null;
169          if (code.isEmpty())
170            return new Enumeration<ResearchSubjectStatus>(this);
171          String codeString = ((PrimitiveType) code).asStringValue();
172          if (codeString == null || "".equals(codeString))
173            return null;
174        if ("candidate".equals(codeString))
175          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.CANDIDATE);
176        if ("enrolled".equals(codeString))
177          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.ENROLLED);
178        if ("active".equals(codeString))
179          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.ACTIVE);
180        if ("suspended".equals(codeString))
181          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.SUSPENDED);
182        if ("withdrawn".equals(codeString))
183          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.WITHDRAWN);
184        if ("completed".equals(codeString))
185          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.COMPLETED);
186        throw new FHIRException("Unknown ResearchSubjectStatus code '"+codeString+"'");
187        }
188    public String toCode(ResearchSubjectStatus code) {
189      if (code == ResearchSubjectStatus.CANDIDATE)
190        return "candidate";
191      if (code == ResearchSubjectStatus.ENROLLED)
192        return "enrolled";
193      if (code == ResearchSubjectStatus.ACTIVE)
194        return "active";
195      if (code == ResearchSubjectStatus.SUSPENDED)
196        return "suspended";
197      if (code == ResearchSubjectStatus.WITHDRAWN)
198        return "withdrawn";
199      if (code == ResearchSubjectStatus.COMPLETED)
200        return "completed";
201      return "?";
202      }
203    public String toSystem(ResearchSubjectStatus code) {
204      return code.getSystem();
205      }
206    }
207
208    /**
209     * Identifiers assigned to this research study by the sponsor or other systems.
210     */
211    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=1, modifier=false, summary=true)
212    @Description(shortDefinition="Business Identifier for research subject", formalDefinition="Identifiers assigned to this research study by the sponsor or other systems." )
213    protected Identifier identifier;
214
215    /**
216     * The current state of the subject.
217     */
218    @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true)
219    @Description(shortDefinition="candidate | enrolled | active | suspended | withdrawn | completed", formalDefinition="The current state of the subject." )
220    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/research-subject-status")
221    protected Enumeration<ResearchSubjectStatus> status;
222
223    /**
224     * The dates the subject began and ended their participation in the study.
225     */
226    @Child(name = "period", type = {Period.class}, order=2, min=0, max=1, modifier=false, summary=true)
227    @Description(shortDefinition="Start and end of participation", formalDefinition="The dates the subject began and ended their participation in the study." )
228    protected Period period;
229
230    /**
231     * Reference to the study the subject is participating in.
232     */
233    @Child(name = "study", type = {ResearchStudy.class}, order=3, min=1, max=1, modifier=false, summary=true)
234    @Description(shortDefinition="Study subject is part of", formalDefinition="Reference to the study the subject is participating in." )
235    protected Reference study;
236
237    /**
238     * The actual object that is the target of the reference (Reference to the study the subject is participating in.)
239     */
240    protected ResearchStudy studyTarget;
241
242    /**
243     * The record of the person or animal who is involved in the study.
244     */
245    @Child(name = "individual", type = {Patient.class}, order=4, min=1, max=1, modifier=false, summary=true)
246    @Description(shortDefinition="Who is part of study", formalDefinition="The record of the person or animal who is involved in the study." )
247    protected Reference individual;
248
249    /**
250     * The actual object that is the target of the reference (The record of the person or animal who is involved in the study.)
251     */
252    protected Patient individualTarget;
253
254    /**
255     * The name of the arm in the study the subject is expected to follow as part of this study.
256     */
257    @Child(name = "assignedArm", type = {StringType.class}, order=5, min=0, max=1, modifier=false, summary=false)
258    @Description(shortDefinition="What path should be followed", formalDefinition="The name of the arm in the study the subject is expected to follow as part of this study." )
259    protected StringType assignedArm;
260
261    /**
262     * The name of the arm in the study the subject actually followed as part of this study.
263     */
264    @Child(name = "actualArm", type = {StringType.class}, order=6, min=0, max=1, modifier=false, summary=false)
265    @Description(shortDefinition="What path was followed", formalDefinition="The name of the arm in the study the subject actually followed as part of this study." )
266    protected StringType actualArm;
267
268    /**
269     * A record of the patient's informed agreement to participate in the study.
270     */
271    @Child(name = "consent", type = {Consent.class}, order=7, min=0, max=1, modifier=false, summary=false)
272    @Description(shortDefinition="Agreement to participate in study", formalDefinition="A record of the patient's informed agreement to participate in the study." )
273    protected Reference consent;
274
275    /**
276     * The actual object that is the target of the reference (A record of the patient's informed agreement to participate in the study.)
277     */
278    protected Consent consentTarget;
279
280    private static final long serialVersionUID = -1730128953L;
281
282  /**
283   * Constructor
284   */
285    public ResearchSubject() {
286      super();
287    }
288
289  /**
290   * Constructor
291   */
292    public ResearchSubject(Enumeration<ResearchSubjectStatus> status, Reference study, Reference individual) {
293      super();
294      this.status = status;
295      this.study = study;
296      this.individual = individual;
297    }
298
299    /**
300     * @return {@link #identifier} (Identifiers assigned to this research study by the sponsor or other systems.)
301     */
302    public Identifier getIdentifier() { 
303      if (this.identifier == null)
304        if (Configuration.errorOnAutoCreate())
305          throw new Error("Attempt to auto-create ResearchSubject.identifier");
306        else if (Configuration.doAutoCreate())
307          this.identifier = new Identifier(); // cc
308      return this.identifier;
309    }
310
311    public boolean hasIdentifier() { 
312      return this.identifier != null && !this.identifier.isEmpty();
313    }
314
315    /**
316     * @param value {@link #identifier} (Identifiers assigned to this research study by the sponsor or other systems.)
317     */
318    public ResearchSubject setIdentifier(Identifier value)  { 
319      this.identifier = value;
320      return this;
321    }
322
323    /**
324     * @return {@link #status} (The current state of the subject.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
325     */
326    public Enumeration<ResearchSubjectStatus> getStatusElement() { 
327      if (this.status == null)
328        if (Configuration.errorOnAutoCreate())
329          throw new Error("Attempt to auto-create ResearchSubject.status");
330        else if (Configuration.doAutoCreate())
331          this.status = new Enumeration<ResearchSubjectStatus>(new ResearchSubjectStatusEnumFactory()); // bb
332      return this.status;
333    }
334
335    public boolean hasStatusElement() { 
336      return this.status != null && !this.status.isEmpty();
337    }
338
339    public boolean hasStatus() { 
340      return this.status != null && !this.status.isEmpty();
341    }
342
343    /**
344     * @param value {@link #status} (The current state of the subject.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
345     */
346    public ResearchSubject setStatusElement(Enumeration<ResearchSubjectStatus> value) { 
347      this.status = value;
348      return this;
349    }
350
351    /**
352     * @return The current state of the subject.
353     */
354    public ResearchSubjectStatus getStatus() { 
355      return this.status == null ? null : this.status.getValue();
356    }
357
358    /**
359     * @param value The current state of the subject.
360     */
361    public ResearchSubject setStatus(ResearchSubjectStatus value) { 
362        if (this.status == null)
363          this.status = new Enumeration<ResearchSubjectStatus>(new ResearchSubjectStatusEnumFactory());
364        this.status.setValue(value);
365      return this;
366    }
367
368    /**
369     * @return {@link #period} (The dates the subject began and ended their participation in the study.)
370     */
371    public Period getPeriod() { 
372      if (this.period == null)
373        if (Configuration.errorOnAutoCreate())
374          throw new Error("Attempt to auto-create ResearchSubject.period");
375        else if (Configuration.doAutoCreate())
376          this.period = new Period(); // cc
377      return this.period;
378    }
379
380    public boolean hasPeriod() { 
381      return this.period != null && !this.period.isEmpty();
382    }
383
384    /**
385     * @param value {@link #period} (The dates the subject began and ended their participation in the study.)
386     */
387    public ResearchSubject setPeriod(Period value)  { 
388      this.period = value;
389      return this;
390    }
391
392    /**
393     * @return {@link #study} (Reference to the study the subject is participating in.)
394     */
395    public Reference getStudy() { 
396      if (this.study == null)
397        if (Configuration.errorOnAutoCreate())
398          throw new Error("Attempt to auto-create ResearchSubject.study");
399        else if (Configuration.doAutoCreate())
400          this.study = new Reference(); // cc
401      return this.study;
402    }
403
404    public boolean hasStudy() { 
405      return this.study != null && !this.study.isEmpty();
406    }
407
408    /**
409     * @param value {@link #study} (Reference to the study the subject is participating in.)
410     */
411    public ResearchSubject setStudy(Reference value)  { 
412      this.study = value;
413      return this;
414    }
415
416    /**
417     * @return {@link #study} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Reference to the study the subject is participating in.)
418     */
419    public ResearchStudy getStudyTarget() { 
420      if (this.studyTarget == null)
421        if (Configuration.errorOnAutoCreate())
422          throw new Error("Attempt to auto-create ResearchSubject.study");
423        else if (Configuration.doAutoCreate())
424          this.studyTarget = new ResearchStudy(); // aa
425      return this.studyTarget;
426    }
427
428    /**
429     * @param value {@link #study} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Reference to the study the subject is participating in.)
430     */
431    public ResearchSubject setStudyTarget(ResearchStudy value) { 
432      this.studyTarget = value;
433      return this;
434    }
435
436    /**
437     * @return {@link #individual} (The record of the person or animal who is involved in the study.)
438     */
439    public Reference getIndividual() { 
440      if (this.individual == null)
441        if (Configuration.errorOnAutoCreate())
442          throw new Error("Attempt to auto-create ResearchSubject.individual");
443        else if (Configuration.doAutoCreate())
444          this.individual = new Reference(); // cc
445      return this.individual;
446    }
447
448    public boolean hasIndividual() { 
449      return this.individual != null && !this.individual.isEmpty();
450    }
451
452    /**
453     * @param value {@link #individual} (The record of the person or animal who is involved in the study.)
454     */
455    public ResearchSubject setIndividual(Reference value)  { 
456      this.individual = value;
457      return this;
458    }
459
460    /**
461     * @return {@link #individual} 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 record of the person or animal who is involved in the study.)
462     */
463    public Patient getIndividualTarget() { 
464      if (this.individualTarget == null)
465        if (Configuration.errorOnAutoCreate())
466          throw new Error("Attempt to auto-create ResearchSubject.individual");
467        else if (Configuration.doAutoCreate())
468          this.individualTarget = new Patient(); // aa
469      return this.individualTarget;
470    }
471
472    /**
473     * @param value {@link #individual} 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 record of the person or animal who is involved in the study.)
474     */
475    public ResearchSubject setIndividualTarget(Patient value) { 
476      this.individualTarget = value;
477      return this;
478    }
479
480    /**
481     * @return {@link #assignedArm} (The name of the arm in the study the subject is expected to follow as part of this study.). This is the underlying object with id, value and extensions. The accessor "getAssignedArm" gives direct access to the value
482     */
483    public StringType getAssignedArmElement() { 
484      if (this.assignedArm == null)
485        if (Configuration.errorOnAutoCreate())
486          throw new Error("Attempt to auto-create ResearchSubject.assignedArm");
487        else if (Configuration.doAutoCreate())
488          this.assignedArm = new StringType(); // bb
489      return this.assignedArm;
490    }
491
492    public boolean hasAssignedArmElement() { 
493      return this.assignedArm != null && !this.assignedArm.isEmpty();
494    }
495
496    public boolean hasAssignedArm() { 
497      return this.assignedArm != null && !this.assignedArm.isEmpty();
498    }
499
500    /**
501     * @param value {@link #assignedArm} (The name of the arm in the study the subject is expected to follow as part of this study.). This is the underlying object with id, value and extensions. The accessor "getAssignedArm" gives direct access to the value
502     */
503    public ResearchSubject setAssignedArmElement(StringType value) { 
504      this.assignedArm = value;
505      return this;
506    }
507
508    /**
509     * @return The name of the arm in the study the subject is expected to follow as part of this study.
510     */
511    public String getAssignedArm() { 
512      return this.assignedArm == null ? null : this.assignedArm.getValue();
513    }
514
515    /**
516     * @param value The name of the arm in the study the subject is expected to follow as part of this study.
517     */
518    public ResearchSubject setAssignedArm(String value) { 
519      if (Utilities.noString(value))
520        this.assignedArm = null;
521      else {
522        if (this.assignedArm == null)
523          this.assignedArm = new StringType();
524        this.assignedArm.setValue(value);
525      }
526      return this;
527    }
528
529    /**
530     * @return {@link #actualArm} (The name of the arm in the study the subject actually followed as part of this study.). This is the underlying object with id, value and extensions. The accessor "getActualArm" gives direct access to the value
531     */
532    public StringType getActualArmElement() { 
533      if (this.actualArm == null)
534        if (Configuration.errorOnAutoCreate())
535          throw new Error("Attempt to auto-create ResearchSubject.actualArm");
536        else if (Configuration.doAutoCreate())
537          this.actualArm = new StringType(); // bb
538      return this.actualArm;
539    }
540
541    public boolean hasActualArmElement() { 
542      return this.actualArm != null && !this.actualArm.isEmpty();
543    }
544
545    public boolean hasActualArm() { 
546      return this.actualArm != null && !this.actualArm.isEmpty();
547    }
548
549    /**
550     * @param value {@link #actualArm} (The name of the arm in the study the subject actually followed as part of this study.). This is the underlying object with id, value and extensions. The accessor "getActualArm" gives direct access to the value
551     */
552    public ResearchSubject setActualArmElement(StringType value) { 
553      this.actualArm = value;
554      return this;
555    }
556
557    /**
558     * @return The name of the arm in the study the subject actually followed as part of this study.
559     */
560    public String getActualArm() { 
561      return this.actualArm == null ? null : this.actualArm.getValue();
562    }
563
564    /**
565     * @param value The name of the arm in the study the subject actually followed as part of this study.
566     */
567    public ResearchSubject setActualArm(String value) { 
568      if (Utilities.noString(value))
569        this.actualArm = null;
570      else {
571        if (this.actualArm == null)
572          this.actualArm = new StringType();
573        this.actualArm.setValue(value);
574      }
575      return this;
576    }
577
578    /**
579     * @return {@link #consent} (A record of the patient's informed agreement to participate in the study.)
580     */
581    public Reference getConsent() { 
582      if (this.consent == null)
583        if (Configuration.errorOnAutoCreate())
584          throw new Error("Attempt to auto-create ResearchSubject.consent");
585        else if (Configuration.doAutoCreate())
586          this.consent = new Reference(); // cc
587      return this.consent;
588    }
589
590    public boolean hasConsent() { 
591      return this.consent != null && !this.consent.isEmpty();
592    }
593
594    /**
595     * @param value {@link #consent} (A record of the patient's informed agreement to participate in the study.)
596     */
597    public ResearchSubject setConsent(Reference value)  { 
598      this.consent = value;
599      return this;
600    }
601
602    /**
603     * @return {@link #consent} 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. (A record of the patient's informed agreement to participate in the study.)
604     */
605    public Consent getConsentTarget() { 
606      if (this.consentTarget == null)
607        if (Configuration.errorOnAutoCreate())
608          throw new Error("Attempt to auto-create ResearchSubject.consent");
609        else if (Configuration.doAutoCreate())
610          this.consentTarget = new Consent(); // aa
611      return this.consentTarget;
612    }
613
614    /**
615     * @param value {@link #consent} 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. (A record of the patient's informed agreement to participate in the study.)
616     */
617    public ResearchSubject setConsentTarget(Consent value) { 
618      this.consentTarget = value;
619      return this;
620    }
621
622      protected void listChildren(List<Property> children) {
623        super.listChildren(children);
624        children.add(new Property("identifier", "Identifier", "Identifiers assigned to this research study by the sponsor or other systems.", 0, 1, identifier));
625        children.add(new Property("status", "code", "The current state of the subject.", 0, 1, status));
626        children.add(new Property("period", "Period", "The dates the subject began and ended their participation in the study.", 0, 1, period));
627        children.add(new Property("study", "Reference(ResearchStudy)", "Reference to the study the subject is participating in.", 0, 1, study));
628        children.add(new Property("individual", "Reference(Patient)", "The record of the person or animal who is involved in the study.", 0, 1, individual));
629        children.add(new Property("assignedArm", "string", "The name of the arm in the study the subject is expected to follow as part of this study.", 0, 1, assignedArm));
630        children.add(new Property("actualArm", "string", "The name of the arm in the study the subject actually followed as part of this study.", 0, 1, actualArm));
631        children.add(new Property("consent", "Reference(Consent)", "A record of the patient's informed agreement to participate in the study.", 0, 1, consent));
632      }
633
634      @Override
635      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
636        switch (_hash) {
637        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Identifiers assigned to this research study by the sponsor or other systems.", 0, 1, identifier);
638        case -892481550: /*status*/  return new Property("status", "code", "The current state of the subject.", 0, 1, status);
639        case -991726143: /*period*/  return new Property("period", "Period", "The dates the subject began and ended their participation in the study.", 0, 1, period);
640        case 109776329: /*study*/  return new Property("study", "Reference(ResearchStudy)", "Reference to the study the subject is participating in.", 0, 1, study);
641        case -46292327: /*individual*/  return new Property("individual", "Reference(Patient)", "The record of the person or animal who is involved in the study.", 0, 1, individual);
642        case 1741912494: /*assignedArm*/  return new Property("assignedArm", "string", "The name of the arm in the study the subject is expected to follow as part of this study.", 0, 1, assignedArm);
643        case 528827886: /*actualArm*/  return new Property("actualArm", "string", "The name of the arm in the study the subject actually followed as part of this study.", 0, 1, actualArm);
644        case 951500826: /*consent*/  return new Property("consent", "Reference(Consent)", "A record of the patient's informed agreement to participate in the study.", 0, 1, consent);
645        default: return super.getNamedProperty(_hash, _name, _checkValid);
646        }
647
648      }
649
650      @Override
651      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
652        switch (hash) {
653        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : new Base[] {this.identifier}; // Identifier
654        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<ResearchSubjectStatus>
655        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
656        case 109776329: /*study*/ return this.study == null ? new Base[0] : new Base[] {this.study}; // Reference
657        case -46292327: /*individual*/ return this.individual == null ? new Base[0] : new Base[] {this.individual}; // Reference
658        case 1741912494: /*assignedArm*/ return this.assignedArm == null ? new Base[0] : new Base[] {this.assignedArm}; // StringType
659        case 528827886: /*actualArm*/ return this.actualArm == null ? new Base[0] : new Base[] {this.actualArm}; // StringType
660        case 951500826: /*consent*/ return this.consent == null ? new Base[0] : new Base[] {this.consent}; // Reference
661        default: return super.getProperty(hash, name, checkValid);
662        }
663
664      }
665
666      @Override
667      public Base setProperty(int hash, String name, Base value) throws FHIRException {
668        switch (hash) {
669        case -1618432855: // identifier
670          this.identifier = castToIdentifier(value); // Identifier
671          return value;
672        case -892481550: // status
673          value = new ResearchSubjectStatusEnumFactory().fromType(castToCode(value));
674          this.status = (Enumeration) value; // Enumeration<ResearchSubjectStatus>
675          return value;
676        case -991726143: // period
677          this.period = castToPeriod(value); // Period
678          return value;
679        case 109776329: // study
680          this.study = castToReference(value); // Reference
681          return value;
682        case -46292327: // individual
683          this.individual = castToReference(value); // Reference
684          return value;
685        case 1741912494: // assignedArm
686          this.assignedArm = castToString(value); // StringType
687          return value;
688        case 528827886: // actualArm
689          this.actualArm = castToString(value); // StringType
690          return value;
691        case 951500826: // consent
692          this.consent = castToReference(value); // Reference
693          return value;
694        default: return super.setProperty(hash, name, value);
695        }
696
697      }
698
699      @Override
700      public Base setProperty(String name, Base value) throws FHIRException {
701        if (name.equals("identifier")) {
702          this.identifier = castToIdentifier(value); // Identifier
703        } else if (name.equals("status")) {
704          value = new ResearchSubjectStatusEnumFactory().fromType(castToCode(value));
705          this.status = (Enumeration) value; // Enumeration<ResearchSubjectStatus>
706        } else if (name.equals("period")) {
707          this.period = castToPeriod(value); // Period
708        } else if (name.equals("study")) {
709          this.study = castToReference(value); // Reference
710        } else if (name.equals("individual")) {
711          this.individual = castToReference(value); // Reference
712        } else if (name.equals("assignedArm")) {
713          this.assignedArm = castToString(value); // StringType
714        } else if (name.equals("actualArm")) {
715          this.actualArm = castToString(value); // StringType
716        } else if (name.equals("consent")) {
717          this.consent = castToReference(value); // Reference
718        } else
719          return super.setProperty(name, value);
720        return value;
721      }
722
723      @Override
724      public Base makeProperty(int hash, String name) throws FHIRException {
725        switch (hash) {
726        case -1618432855:  return getIdentifier(); 
727        case -892481550:  return getStatusElement();
728        case -991726143:  return getPeriod(); 
729        case 109776329:  return getStudy(); 
730        case -46292327:  return getIndividual(); 
731        case 1741912494:  return getAssignedArmElement();
732        case 528827886:  return getActualArmElement();
733        case 951500826:  return getConsent(); 
734        default: return super.makeProperty(hash, name);
735        }
736
737      }
738
739      @Override
740      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
741        switch (hash) {
742        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
743        case -892481550: /*status*/ return new String[] {"code"};
744        case -991726143: /*period*/ return new String[] {"Period"};
745        case 109776329: /*study*/ return new String[] {"Reference"};
746        case -46292327: /*individual*/ return new String[] {"Reference"};
747        case 1741912494: /*assignedArm*/ return new String[] {"string"};
748        case 528827886: /*actualArm*/ return new String[] {"string"};
749        case 951500826: /*consent*/ return new String[] {"Reference"};
750        default: return super.getTypesForProperty(hash, name);
751        }
752
753      }
754
755      @Override
756      public Base addChild(String name) throws FHIRException {
757        if (name.equals("identifier")) {
758          this.identifier = new Identifier();
759          return this.identifier;
760        }
761        else if (name.equals("status")) {
762          throw new FHIRException("Cannot call addChild on a primitive type ResearchSubject.status");
763        }
764        else if (name.equals("period")) {
765          this.period = new Period();
766          return this.period;
767        }
768        else if (name.equals("study")) {
769          this.study = new Reference();
770          return this.study;
771        }
772        else if (name.equals("individual")) {
773          this.individual = new Reference();
774          return this.individual;
775        }
776        else if (name.equals("assignedArm")) {
777          throw new FHIRException("Cannot call addChild on a primitive type ResearchSubject.assignedArm");
778        }
779        else if (name.equals("actualArm")) {
780          throw new FHIRException("Cannot call addChild on a primitive type ResearchSubject.actualArm");
781        }
782        else if (name.equals("consent")) {
783          this.consent = new Reference();
784          return this.consent;
785        }
786        else
787          return super.addChild(name);
788      }
789
790  public String fhirType() {
791    return "ResearchSubject";
792
793  }
794
795      public ResearchSubject copy() {
796        ResearchSubject dst = new ResearchSubject();
797        copyValues(dst);
798        dst.identifier = identifier == null ? null : identifier.copy();
799        dst.status = status == null ? null : status.copy();
800        dst.period = period == null ? null : period.copy();
801        dst.study = study == null ? null : study.copy();
802        dst.individual = individual == null ? null : individual.copy();
803        dst.assignedArm = assignedArm == null ? null : assignedArm.copy();
804        dst.actualArm = actualArm == null ? null : actualArm.copy();
805        dst.consent = consent == null ? null : consent.copy();
806        return dst;
807      }
808
809      protected ResearchSubject typedCopy() {
810        return copy();
811      }
812
813      @Override
814      public boolean equalsDeep(Base other_) {
815        if (!super.equalsDeep(other_))
816          return false;
817        if (!(other_ instanceof ResearchSubject))
818          return false;
819        ResearchSubject o = (ResearchSubject) other_;
820        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(period, o.period, true)
821           && compareDeep(study, o.study, true) && compareDeep(individual, o.individual, true) && compareDeep(assignedArm, o.assignedArm, true)
822           && compareDeep(actualArm, o.actualArm, true) && compareDeep(consent, o.consent, true);
823      }
824
825      @Override
826      public boolean equalsShallow(Base other_) {
827        if (!super.equalsShallow(other_))
828          return false;
829        if (!(other_ instanceof ResearchSubject))
830          return false;
831        ResearchSubject o = (ResearchSubject) other_;
832        return compareValues(status, o.status, true) && compareValues(assignedArm, o.assignedArm, true) && compareValues(actualArm, o.actualArm, true)
833          ;
834      }
835
836      public boolean isEmpty() {
837        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, period
838          , study, individual, assignedArm, actualArm, consent);
839      }
840
841  @Override
842  public ResourceType getResourceType() {
843    return ResourceType.ResearchSubject;
844   }
845
846 /**
847   * Search parameter: <b>date</b>
848   * <p>
849   * Description: <b>Start and end of participation</b><br>
850   * Type: <b>date</b><br>
851   * Path: <b>ResearchSubject.period</b><br>
852   * </p>
853   */
854  @SearchParamDefinition(name="date", path="ResearchSubject.period", description="Start and end of participation", type="date" )
855  public static final String SP_DATE = "date";
856 /**
857   * <b>Fluent Client</b> search parameter constant for <b>date</b>
858   * <p>
859   * Description: <b>Start and end of participation</b><br>
860   * Type: <b>date</b><br>
861   * Path: <b>ResearchSubject.period</b><br>
862   * </p>
863   */
864  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATE);
865
866 /**
867   * Search parameter: <b>identifier</b>
868   * <p>
869   * Description: <b>Business Identifier for research subject</b><br>
870   * Type: <b>token</b><br>
871   * Path: <b>ResearchSubject.identifier</b><br>
872   * </p>
873   */
874  @SearchParamDefinition(name="identifier", path="ResearchSubject.identifier", description="Business Identifier for research subject", type="token" )
875  public static final String SP_IDENTIFIER = "identifier";
876 /**
877   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
878   * <p>
879   * Description: <b>Business Identifier for research subject</b><br>
880   * Type: <b>token</b><br>
881   * Path: <b>ResearchSubject.identifier</b><br>
882   * </p>
883   */
884  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
885
886 /**
887   * Search parameter: <b>individual</b>
888   * <p>
889   * Description: <b>Who is part of study</b><br>
890   * Type: <b>reference</b><br>
891   * Path: <b>ResearchSubject.individual</b><br>
892   * </p>
893   */
894  @SearchParamDefinition(name="individual", path="ResearchSubject.individual", description="Who is part of study", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Patient.class } )
895  public static final String SP_INDIVIDUAL = "individual";
896 /**
897   * <b>Fluent Client</b> search parameter constant for <b>individual</b>
898   * <p>
899   * Description: <b>Who is part of study</b><br>
900   * Type: <b>reference</b><br>
901   * Path: <b>ResearchSubject.individual</b><br>
902   * </p>
903   */
904  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam INDIVIDUAL = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_INDIVIDUAL);
905
906/**
907   * Constant for fluent queries to be used to add include statements. Specifies
908   * the path value of "<b>ResearchSubject:individual</b>".
909   */
910  public static final ca.uhn.fhir.model.api.Include INCLUDE_INDIVIDUAL = new ca.uhn.fhir.model.api.Include("ResearchSubject:individual").toLocked();
911
912 /**
913   * Search parameter: <b>patient</b>
914   * <p>
915   * Description: <b>Who is part of study</b><br>
916   * Type: <b>reference</b><br>
917   * Path: <b>ResearchSubject.individual</b><br>
918   * </p>
919   */
920  @SearchParamDefinition(name="patient", path="ResearchSubject.individual", description="Who is part of study", type="reference", target={Patient.class } )
921  public static final String SP_PATIENT = "patient";
922 /**
923   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
924   * <p>
925   * Description: <b>Who is part of study</b><br>
926   * Type: <b>reference</b><br>
927   * Path: <b>ResearchSubject.individual</b><br>
928   * </p>
929   */
930  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
931
932/**
933   * Constant for fluent queries to be used to add include statements. Specifies
934   * the path value of "<b>ResearchSubject:patient</b>".
935   */
936  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("ResearchSubject:patient").toLocked();
937
938 /**
939   * Search parameter: <b>status</b>
940   * <p>
941   * Description: <b>candidate | enrolled | active | suspended | withdrawn | completed</b><br>
942   * Type: <b>token</b><br>
943   * Path: <b>ResearchSubject.status</b><br>
944   * </p>
945   */
946  @SearchParamDefinition(name="status", path="ResearchSubject.status", description="candidate | enrolled | active | suspended | withdrawn | completed", type="token" )
947  public static final String SP_STATUS = "status";
948 /**
949   * <b>Fluent Client</b> search parameter constant for <b>status</b>
950   * <p>
951   * Description: <b>candidate | enrolled | active | suspended | withdrawn | completed</b><br>
952   * Type: <b>token</b><br>
953   * Path: <b>ResearchSubject.status</b><br>
954   * </p>
955   */
956  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
957
958
959}
960