001package org.hl7.fhir.r4b.model;
002
003
004/*
005  Copyright (c) 2011+, HL7, Inc.
006  All rights reserved.
007  
008  Redistribution and use in source and binary forms, with or without modification, \
009  are permitted provided that the following conditions are met:
010  
011   * Redistributions of source code must retain the above copyright notice, this \
012     list of conditions and the following disclaimer.
013   * Redistributions in binary form must reproduce the above copyright notice, \
014     this list of conditions and the following disclaimer in the documentation \
015     and/or other materials provided with the distribution.
016   * Neither the name of HL7 nor the names of its contributors may be used to 
017     endorse or promote products derived from this software without specific 
018     prior written permission.
019  
020  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \
021  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \
022  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \
023  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \
024  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \
025  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \
026  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \
027  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \
028  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \
029  POSSIBILITY OF SUCH DAMAGE.
030  */
031
032// Generated on Fri, Dec 31, 2021 05:58+1100 for FHIR v4.3.0-snapshot1
033
034import java.util.ArrayList;
035import java.util.Date;
036import java.util.List;
037import org.hl7.fhir.utilities.Utilities;
038import org.hl7.fhir.r4b.model.Enumerations.*;
039import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
040import org.hl7.fhir.exceptions.FHIRException;
041import org.hl7.fhir.instance.model.api.ICompositeType;
042import ca.uhn.fhir.model.api.annotation.ResourceDef;
043import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
044import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
045import ca.uhn.fhir.model.api.annotation.Child;
046import ca.uhn.fhir.model.api.annotation.ChildOrder;
047import ca.uhn.fhir.model.api.annotation.Description;
048import ca.uhn.fhir.model.api.annotation.Block;
049
050/**
051 * A physical entity which is the primary unit of operational and/or administrative interest in a study.
052 */
053@ResourceDef(name="ResearchSubject", profile="http://hl7.org/fhir/StructureDefinition/ResearchSubject")
054public class ResearchSubject extends DomainResource {
055
056    public enum ResearchSubjectStatus {
057        /**
058         * An identified person that can be considered for inclusion in a study.
059         */
060        CANDIDATE, 
061        /**
062         * A person that has met the eligibility criteria for inclusion in a study.
063         */
064        ELIGIBLE, 
065        /**
066         * A person is no longer receiving study intervention and/or being evaluated with tests and procedures according to the protocol, but they are being monitored on a protocol-prescribed schedule.
067         */
068        FOLLOWUP, 
069        /**
070         * A person who did not meet one or more criteria required for participation in a study is considered to have failed screening or\nis ineligible for the study.
071         */
072        INELIGIBLE, 
073        /**
074         * A person for whom registration was not completed.
075         */
076        NOTREGISTERED, 
077        /**
078         * A person that has ended their participation on a study either because their treatment/observation is complete or through not\nresponding, withdrawal, non-compliance and/or adverse event.
079         */
080        OFFSTUDY, 
081        /**
082         * A person that is enrolled or registered on a study.
083         */
084        ONSTUDY, 
085        /**
086         * The person is receiving the treatment or participating in an activity (e.g. yoga, diet, etc.) that the study is evaluating.
087         */
088        ONSTUDYINTERVENTION, 
089        /**
090         * The subject is being evaluated via tests and assessments according to the study calendar, but is not receiving any intervention. Note that this state is study-dependent and might not exist in all studies.  A synonym for this is \"short-term follow-up\".
091         */
092        ONSTUDYOBSERVATION, 
093        /**
094         * A person is pre-registered for a study.
095         */
096        PENDINGONSTUDY, 
097        /**
098         * A person that is potentially eligible for participation in the study.
099         */
100        POTENTIALCANDIDATE, 
101        /**
102         * A person who is being evaluated for eligibility for a study.
103         */
104        SCREENING, 
105        /**
106         * The person has withdrawn their participation in the study before registration.
107         */
108        WITHDRAWN, 
109        /**
110         * added to help the parsers with the generic types
111         */
112        NULL;
113        public static ResearchSubjectStatus fromCode(String codeString) throws FHIRException {
114            if (codeString == null || "".equals(codeString))
115                return null;
116        if ("candidate".equals(codeString))
117          return CANDIDATE;
118        if ("eligible".equals(codeString))
119          return ELIGIBLE;
120        if ("follow-up".equals(codeString))
121          return FOLLOWUP;
122        if ("ineligible".equals(codeString))
123          return INELIGIBLE;
124        if ("not-registered".equals(codeString))
125          return NOTREGISTERED;
126        if ("off-study".equals(codeString))
127          return OFFSTUDY;
128        if ("on-study".equals(codeString))
129          return ONSTUDY;
130        if ("on-study-intervention".equals(codeString))
131          return ONSTUDYINTERVENTION;
132        if ("on-study-observation".equals(codeString))
133          return ONSTUDYOBSERVATION;
134        if ("pending-on-study".equals(codeString))
135          return PENDINGONSTUDY;
136        if ("potential-candidate".equals(codeString))
137          return POTENTIALCANDIDATE;
138        if ("screening".equals(codeString))
139          return SCREENING;
140        if ("withdrawn".equals(codeString))
141          return WITHDRAWN;
142        if (Configuration.isAcceptInvalidEnums())
143          return null;
144        else
145          throw new FHIRException("Unknown ResearchSubjectStatus code '"+codeString+"'");
146        }
147        public String toCode() {
148          switch (this) {
149            case CANDIDATE: return "candidate";
150            case ELIGIBLE: return "eligible";
151            case FOLLOWUP: return "follow-up";
152            case INELIGIBLE: return "ineligible";
153            case NOTREGISTERED: return "not-registered";
154            case OFFSTUDY: return "off-study";
155            case ONSTUDY: return "on-study";
156            case ONSTUDYINTERVENTION: return "on-study-intervention";
157            case ONSTUDYOBSERVATION: return "on-study-observation";
158            case PENDINGONSTUDY: return "pending-on-study";
159            case POTENTIALCANDIDATE: return "potential-candidate";
160            case SCREENING: return "screening";
161            case WITHDRAWN: return "withdrawn";
162            case NULL: return null;
163            default: return "?";
164          }
165        }
166        public String getSystem() {
167          switch (this) {
168            case CANDIDATE: return "http://hl7.org/fhir/research-subject-status";
169            case ELIGIBLE: return "http://hl7.org/fhir/research-subject-status";
170            case FOLLOWUP: return "http://hl7.org/fhir/research-subject-status";
171            case INELIGIBLE: return "http://hl7.org/fhir/research-subject-status";
172            case NOTREGISTERED: return "http://hl7.org/fhir/research-subject-status";
173            case OFFSTUDY: return "http://hl7.org/fhir/research-subject-status";
174            case ONSTUDY: return "http://hl7.org/fhir/research-subject-status";
175            case ONSTUDYINTERVENTION: return "http://hl7.org/fhir/research-subject-status";
176            case ONSTUDYOBSERVATION: return "http://hl7.org/fhir/research-subject-status";
177            case PENDINGONSTUDY: return "http://hl7.org/fhir/research-subject-status";
178            case POTENTIALCANDIDATE: return "http://hl7.org/fhir/research-subject-status";
179            case SCREENING: return "http://hl7.org/fhir/research-subject-status";
180            case WITHDRAWN: return "http://hl7.org/fhir/research-subject-status";
181            case NULL: return null;
182            default: return "?";
183          }
184        }
185        public String getDefinition() {
186          switch (this) {
187            case CANDIDATE: return "An identified person that can be considered for inclusion in a study.";
188            case ELIGIBLE: return "A person that has met the eligibility criteria for inclusion in a study.";
189            case FOLLOWUP: return "A person is no longer receiving study intervention and/or being evaluated with tests and procedures according to the protocol, but they are being monitored on a protocol-prescribed schedule.";
190            case INELIGIBLE: return "A person who did not meet one or more criteria required for participation in a study is considered to have failed screening or\nis ineligible for the study.";
191            case NOTREGISTERED: return "A person for whom registration was not completed.";
192            case OFFSTUDY: return "A person that has ended their participation on a study either because their treatment/observation is complete or through not\nresponding, withdrawal, non-compliance and/or adverse event.";
193            case ONSTUDY: return "A person that is enrolled or registered on a study.";
194            case ONSTUDYINTERVENTION: return "The person is receiving the treatment or participating in an activity (e.g. yoga, diet, etc.) that the study is evaluating.";
195            case ONSTUDYOBSERVATION: return "The subject is being evaluated via tests and assessments according to the study calendar, but is not receiving any intervention. Note that this state is study-dependent and might not exist in all studies.  A synonym for this is \"short-term follow-up\".";
196            case PENDINGONSTUDY: return "A person is pre-registered for a study.";
197            case POTENTIALCANDIDATE: return "A person that is potentially eligible for participation in the study.";
198            case SCREENING: return "A person who is being evaluated for eligibility for a study.";
199            case WITHDRAWN: return "The person has withdrawn their participation in the study before registration.";
200            case NULL: return null;
201            default: return "?";
202          }
203        }
204        public String getDisplay() {
205          switch (this) {
206            case CANDIDATE: return "Candidate";
207            case ELIGIBLE: return "Eligible";
208            case FOLLOWUP: return "Follow-up";
209            case INELIGIBLE: return "Ineligible";
210            case NOTREGISTERED: return "Not Registered";
211            case OFFSTUDY: return "Off-study";
212            case ONSTUDY: return "On-study";
213            case ONSTUDYINTERVENTION: return "On-study-intervention";
214            case ONSTUDYOBSERVATION: return "On-study-observation";
215            case PENDINGONSTUDY: return "Pending on-study";
216            case POTENTIALCANDIDATE: return "Potential Candidate";
217            case SCREENING: return "Screening";
218            case WITHDRAWN: return "Withdrawn";
219            case NULL: return null;
220            default: return "?";
221          }
222        }
223    }
224
225  public static class ResearchSubjectStatusEnumFactory implements EnumFactory<ResearchSubjectStatus> {
226    public ResearchSubjectStatus fromCode(String codeString) throws IllegalArgumentException {
227      if (codeString == null || "".equals(codeString))
228            if (codeString == null || "".equals(codeString))
229                return null;
230        if ("candidate".equals(codeString))
231          return ResearchSubjectStatus.CANDIDATE;
232        if ("eligible".equals(codeString))
233          return ResearchSubjectStatus.ELIGIBLE;
234        if ("follow-up".equals(codeString))
235          return ResearchSubjectStatus.FOLLOWUP;
236        if ("ineligible".equals(codeString))
237          return ResearchSubjectStatus.INELIGIBLE;
238        if ("not-registered".equals(codeString))
239          return ResearchSubjectStatus.NOTREGISTERED;
240        if ("off-study".equals(codeString))
241          return ResearchSubjectStatus.OFFSTUDY;
242        if ("on-study".equals(codeString))
243          return ResearchSubjectStatus.ONSTUDY;
244        if ("on-study-intervention".equals(codeString))
245          return ResearchSubjectStatus.ONSTUDYINTERVENTION;
246        if ("on-study-observation".equals(codeString))
247          return ResearchSubjectStatus.ONSTUDYOBSERVATION;
248        if ("pending-on-study".equals(codeString))
249          return ResearchSubjectStatus.PENDINGONSTUDY;
250        if ("potential-candidate".equals(codeString))
251          return ResearchSubjectStatus.POTENTIALCANDIDATE;
252        if ("screening".equals(codeString))
253          return ResearchSubjectStatus.SCREENING;
254        if ("withdrawn".equals(codeString))
255          return ResearchSubjectStatus.WITHDRAWN;
256        throw new IllegalArgumentException("Unknown ResearchSubjectStatus code '"+codeString+"'");
257        }
258        public Enumeration<ResearchSubjectStatus> fromType(Base code) throws FHIRException {
259          if (code == null)
260            return null;
261          if (code.isEmpty())
262            return new Enumeration<ResearchSubjectStatus>(this);
263          String codeString = ((PrimitiveType) code).asStringValue();
264          if (codeString == null || "".equals(codeString))
265            return null;
266        if ("candidate".equals(codeString))
267          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.CANDIDATE);
268        if ("eligible".equals(codeString))
269          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.ELIGIBLE);
270        if ("follow-up".equals(codeString))
271          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.FOLLOWUP);
272        if ("ineligible".equals(codeString))
273          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.INELIGIBLE);
274        if ("not-registered".equals(codeString))
275          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.NOTREGISTERED);
276        if ("off-study".equals(codeString))
277          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.OFFSTUDY);
278        if ("on-study".equals(codeString))
279          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.ONSTUDY);
280        if ("on-study-intervention".equals(codeString))
281          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.ONSTUDYINTERVENTION);
282        if ("on-study-observation".equals(codeString))
283          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.ONSTUDYOBSERVATION);
284        if ("pending-on-study".equals(codeString))
285          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.PENDINGONSTUDY);
286        if ("potential-candidate".equals(codeString))
287          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.POTENTIALCANDIDATE);
288        if ("screening".equals(codeString))
289          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.SCREENING);
290        if ("withdrawn".equals(codeString))
291          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.WITHDRAWN);
292        throw new FHIRException("Unknown ResearchSubjectStatus code '"+codeString+"'");
293        }
294    public String toCode(ResearchSubjectStatus code) {
295      if (code == ResearchSubjectStatus.CANDIDATE)
296        return "candidate";
297      if (code == ResearchSubjectStatus.ELIGIBLE)
298        return "eligible";
299      if (code == ResearchSubjectStatus.FOLLOWUP)
300        return "follow-up";
301      if (code == ResearchSubjectStatus.INELIGIBLE)
302        return "ineligible";
303      if (code == ResearchSubjectStatus.NOTREGISTERED)
304        return "not-registered";
305      if (code == ResearchSubjectStatus.OFFSTUDY)
306        return "off-study";
307      if (code == ResearchSubjectStatus.ONSTUDY)
308        return "on-study";
309      if (code == ResearchSubjectStatus.ONSTUDYINTERVENTION)
310        return "on-study-intervention";
311      if (code == ResearchSubjectStatus.ONSTUDYOBSERVATION)
312        return "on-study-observation";
313      if (code == ResearchSubjectStatus.PENDINGONSTUDY)
314        return "pending-on-study";
315      if (code == ResearchSubjectStatus.POTENTIALCANDIDATE)
316        return "potential-candidate";
317      if (code == ResearchSubjectStatus.SCREENING)
318        return "screening";
319      if (code == ResearchSubjectStatus.WITHDRAWN)
320        return "withdrawn";
321      return "?";
322      }
323    public String toSystem(ResearchSubjectStatus code) {
324      return code.getSystem();
325      }
326    }
327
328    /**
329     * Identifiers assigned to this research subject for a study.
330     */
331    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
332    @Description(shortDefinition="Business Identifier for research subject in a study", formalDefinition="Identifiers assigned to this research subject for a study." )
333    protected List<Identifier> identifier;
334
335    /**
336     * The current state of the subject.
337     */
338    @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true)
339    @Description(shortDefinition="candidate | eligible | follow-up | ineligible | not-registered | off-study | on-study | on-study-intervention | on-study-observation | pending-on-study | potential-candidate | screening | withdrawn", formalDefinition="The current state of the subject." )
340    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/research-subject-status")
341    protected Enumeration<ResearchSubjectStatus> status;
342
343    /**
344     * The dates the subject began and ended their participation in the study.
345     */
346    @Child(name = "period", type = {Period.class}, order=2, min=0, max=1, modifier=false, summary=true)
347    @Description(shortDefinition="Start and end of participation", formalDefinition="The dates the subject began and ended their participation in the study." )
348    protected Period period;
349
350    /**
351     * Reference to the study the subject is participating in.
352     */
353    @Child(name = "study", type = {ResearchStudy.class}, order=3, min=1, max=1, modifier=false, summary=true)
354    @Description(shortDefinition="Study subject is part of", formalDefinition="Reference to the study the subject is participating in." )
355    protected Reference study;
356
357    /**
358     * The record of the person or animal who is involved in the study.
359     */
360    @Child(name = "individual", type = {Patient.class}, order=4, min=1, max=1, modifier=false, summary=true)
361    @Description(shortDefinition="Who is part of study", formalDefinition="The record of the person or animal who is involved in the study." )
362    protected Reference individual;
363
364    /**
365     * The name of the arm in the study the subject is expected to follow as part of this study.
366     */
367    @Child(name = "assignedArm", type = {StringType.class}, order=5, min=0, max=1, modifier=false, summary=false)
368    @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." )
369    protected StringType assignedArm;
370
371    /**
372     * The name of the arm in the study the subject actually followed as part of this study.
373     */
374    @Child(name = "actualArm", type = {StringType.class}, order=6, min=0, max=1, modifier=false, summary=false)
375    @Description(shortDefinition="What path was followed", formalDefinition="The name of the arm in the study the subject actually followed as part of this study." )
376    protected StringType actualArm;
377
378    /**
379     * A record of the patient's informed agreement to participate in the study.
380     */
381    @Child(name = "consent", type = {Consent.class}, order=7, min=0, max=1, modifier=false, summary=false)
382    @Description(shortDefinition="Agreement to participate in study", formalDefinition="A record of the patient's informed agreement to participate in the study." )
383    protected Reference consent;
384
385    private static final long serialVersionUID = 2129823357L;
386
387  /**
388   * Constructor
389   */
390    public ResearchSubject() {
391      super();
392    }
393
394  /**
395   * Constructor
396   */
397    public ResearchSubject(ResearchSubjectStatus status, Reference study, Reference individual) {
398      super();
399      this.setStatus(status);
400      this.setStudy(study);
401      this.setIndividual(individual);
402    }
403
404    /**
405     * @return {@link #identifier} (Identifiers assigned to this research subject for a study.)
406     */
407    public List<Identifier> getIdentifier() { 
408      if (this.identifier == null)
409        this.identifier = new ArrayList<Identifier>();
410      return this.identifier;
411    }
412
413    /**
414     * @return Returns a reference to <code>this</code> for easy method chaining
415     */
416    public ResearchSubject setIdentifier(List<Identifier> theIdentifier) { 
417      this.identifier = theIdentifier;
418      return this;
419    }
420
421    public boolean hasIdentifier() { 
422      if (this.identifier == null)
423        return false;
424      for (Identifier item : this.identifier)
425        if (!item.isEmpty())
426          return true;
427      return false;
428    }
429
430    public Identifier addIdentifier() { //3
431      Identifier t = new Identifier();
432      if (this.identifier == null)
433        this.identifier = new ArrayList<Identifier>();
434      this.identifier.add(t);
435      return t;
436    }
437
438    public ResearchSubject addIdentifier(Identifier t) { //3
439      if (t == null)
440        return this;
441      if (this.identifier == null)
442        this.identifier = new ArrayList<Identifier>();
443      this.identifier.add(t);
444      return this;
445    }
446
447    /**
448     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist {3}
449     */
450    public Identifier getIdentifierFirstRep() { 
451      if (getIdentifier().isEmpty()) {
452        addIdentifier();
453      }
454      return getIdentifier().get(0);
455    }
456
457    /**
458     * @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
459     */
460    public Enumeration<ResearchSubjectStatus> getStatusElement() { 
461      if (this.status == null)
462        if (Configuration.errorOnAutoCreate())
463          throw new Error("Attempt to auto-create ResearchSubject.status");
464        else if (Configuration.doAutoCreate())
465          this.status = new Enumeration<ResearchSubjectStatus>(new ResearchSubjectStatusEnumFactory()); // bb
466      return this.status;
467    }
468
469    public boolean hasStatusElement() { 
470      return this.status != null && !this.status.isEmpty();
471    }
472
473    public boolean hasStatus() { 
474      return this.status != null && !this.status.isEmpty();
475    }
476
477    /**
478     * @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
479     */
480    public ResearchSubject setStatusElement(Enumeration<ResearchSubjectStatus> value) { 
481      this.status = value;
482      return this;
483    }
484
485    /**
486     * @return The current state of the subject.
487     */
488    public ResearchSubjectStatus getStatus() { 
489      return this.status == null ? null : this.status.getValue();
490    }
491
492    /**
493     * @param value The current state of the subject.
494     */
495    public ResearchSubject setStatus(ResearchSubjectStatus value) { 
496        if (this.status == null)
497          this.status = new Enumeration<ResearchSubjectStatus>(new ResearchSubjectStatusEnumFactory());
498        this.status.setValue(value);
499      return this;
500    }
501
502    /**
503     * @return {@link #period} (The dates the subject began and ended their participation in the study.)
504     */
505    public Period getPeriod() { 
506      if (this.period == null)
507        if (Configuration.errorOnAutoCreate())
508          throw new Error("Attempt to auto-create ResearchSubject.period");
509        else if (Configuration.doAutoCreate())
510          this.period = new Period(); // cc
511      return this.period;
512    }
513
514    public boolean hasPeriod() { 
515      return this.period != null && !this.period.isEmpty();
516    }
517
518    /**
519     * @param value {@link #period} (The dates the subject began and ended their participation in the study.)
520     */
521    public ResearchSubject setPeriod(Period value) { 
522      this.period = value;
523      return this;
524    }
525
526    /**
527     * @return {@link #study} (Reference to the study the subject is participating in.)
528     */
529    public Reference getStudy() { 
530      if (this.study == null)
531        if (Configuration.errorOnAutoCreate())
532          throw new Error("Attempt to auto-create ResearchSubject.study");
533        else if (Configuration.doAutoCreate())
534          this.study = new Reference(); // cc
535      return this.study;
536    }
537
538    public boolean hasStudy() { 
539      return this.study != null && !this.study.isEmpty();
540    }
541
542    /**
543     * @param value {@link #study} (Reference to the study the subject is participating in.)
544     */
545    public ResearchSubject setStudy(Reference value) { 
546      this.study = value;
547      return this;
548    }
549
550    /**
551     * @return {@link #individual} (The record of the person or animal who is involved in the study.)
552     */
553    public Reference getIndividual() { 
554      if (this.individual == null)
555        if (Configuration.errorOnAutoCreate())
556          throw new Error("Attempt to auto-create ResearchSubject.individual");
557        else if (Configuration.doAutoCreate())
558          this.individual = new Reference(); // cc
559      return this.individual;
560    }
561
562    public boolean hasIndividual() { 
563      return this.individual != null && !this.individual.isEmpty();
564    }
565
566    /**
567     * @param value {@link #individual} (The record of the person or animal who is involved in the study.)
568     */
569    public ResearchSubject setIndividual(Reference value) { 
570      this.individual = value;
571      return this;
572    }
573
574    /**
575     * @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
576     */
577    public StringType getAssignedArmElement() { 
578      if (this.assignedArm == null)
579        if (Configuration.errorOnAutoCreate())
580          throw new Error("Attempt to auto-create ResearchSubject.assignedArm");
581        else if (Configuration.doAutoCreate())
582          this.assignedArm = new StringType(); // bb
583      return this.assignedArm;
584    }
585
586    public boolean hasAssignedArmElement() { 
587      return this.assignedArm != null && !this.assignedArm.isEmpty();
588    }
589
590    public boolean hasAssignedArm() { 
591      return this.assignedArm != null && !this.assignedArm.isEmpty();
592    }
593
594    /**
595     * @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
596     */
597    public ResearchSubject setAssignedArmElement(StringType value) { 
598      this.assignedArm = value;
599      return this;
600    }
601
602    /**
603     * @return The name of the arm in the study the subject is expected to follow as part of this study.
604     */
605    public String getAssignedArm() { 
606      return this.assignedArm == null ? null : this.assignedArm.getValue();
607    }
608
609    /**
610     * @param value The name of the arm in the study the subject is expected to follow as part of this study.
611     */
612    public ResearchSubject setAssignedArm(String value) { 
613      if (Utilities.noString(value))
614        this.assignedArm = null;
615      else {
616        if (this.assignedArm == null)
617          this.assignedArm = new StringType();
618        this.assignedArm.setValue(value);
619      }
620      return this;
621    }
622
623    /**
624     * @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
625     */
626    public StringType getActualArmElement() { 
627      if (this.actualArm == null)
628        if (Configuration.errorOnAutoCreate())
629          throw new Error("Attempt to auto-create ResearchSubject.actualArm");
630        else if (Configuration.doAutoCreate())
631          this.actualArm = new StringType(); // bb
632      return this.actualArm;
633    }
634
635    public boolean hasActualArmElement() { 
636      return this.actualArm != null && !this.actualArm.isEmpty();
637    }
638
639    public boolean hasActualArm() { 
640      return this.actualArm != null && !this.actualArm.isEmpty();
641    }
642
643    /**
644     * @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
645     */
646    public ResearchSubject setActualArmElement(StringType value) { 
647      this.actualArm = value;
648      return this;
649    }
650
651    /**
652     * @return The name of the arm in the study the subject actually followed as part of this study.
653     */
654    public String getActualArm() { 
655      return this.actualArm == null ? null : this.actualArm.getValue();
656    }
657
658    /**
659     * @param value The name of the arm in the study the subject actually followed as part of this study.
660     */
661    public ResearchSubject setActualArm(String value) { 
662      if (Utilities.noString(value))
663        this.actualArm = null;
664      else {
665        if (this.actualArm == null)
666          this.actualArm = new StringType();
667        this.actualArm.setValue(value);
668      }
669      return this;
670    }
671
672    /**
673     * @return {@link #consent} (A record of the patient's informed agreement to participate in the study.)
674     */
675    public Reference getConsent() { 
676      if (this.consent == null)
677        if (Configuration.errorOnAutoCreate())
678          throw new Error("Attempt to auto-create ResearchSubject.consent");
679        else if (Configuration.doAutoCreate())
680          this.consent = new Reference(); // cc
681      return this.consent;
682    }
683
684    public boolean hasConsent() { 
685      return this.consent != null && !this.consent.isEmpty();
686    }
687
688    /**
689     * @param value {@link #consent} (A record of the patient's informed agreement to participate in the study.)
690     */
691    public ResearchSubject setConsent(Reference value) { 
692      this.consent = value;
693      return this;
694    }
695
696      protected void listChildren(List<Property> children) {
697        super.listChildren(children);
698        children.add(new Property("identifier", "Identifier", "Identifiers assigned to this research subject for a study.", 0, java.lang.Integer.MAX_VALUE, identifier));
699        children.add(new Property("status", "code", "The current state of the subject.", 0, 1, status));
700        children.add(new Property("period", "Period", "The dates the subject began and ended their participation in the study.", 0, 1, period));
701        children.add(new Property("study", "Reference(ResearchStudy)", "Reference to the study the subject is participating in.", 0, 1, study));
702        children.add(new Property("individual", "Reference(Patient)", "The record of the person or animal who is involved in the study.", 0, 1, individual));
703        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));
704        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));
705        children.add(new Property("consent", "Reference(Consent)", "A record of the patient's informed agreement to participate in the study.", 0, 1, consent));
706      }
707
708      @Override
709      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
710        switch (_hash) {
711        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Identifiers assigned to this research subject for a study.", 0, java.lang.Integer.MAX_VALUE, identifier);
712        case -892481550: /*status*/  return new Property("status", "code", "The current state of the subject.", 0, 1, status);
713        case -991726143: /*period*/  return new Property("period", "Period", "The dates the subject began and ended their participation in the study.", 0, 1, period);
714        case 109776329: /*study*/  return new Property("study", "Reference(ResearchStudy)", "Reference to the study the subject is participating in.", 0, 1, study);
715        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);
716        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);
717        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);
718        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);
719        default: return super.getNamedProperty(_hash, _name, _checkValid);
720        }
721
722      }
723
724      @Override
725      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
726        switch (hash) {
727        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
728        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<ResearchSubjectStatus>
729        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
730        case 109776329: /*study*/ return this.study == null ? new Base[0] : new Base[] {this.study}; // Reference
731        case -46292327: /*individual*/ return this.individual == null ? new Base[0] : new Base[] {this.individual}; // Reference
732        case 1741912494: /*assignedArm*/ return this.assignedArm == null ? new Base[0] : new Base[] {this.assignedArm}; // StringType
733        case 528827886: /*actualArm*/ return this.actualArm == null ? new Base[0] : new Base[] {this.actualArm}; // StringType
734        case 951500826: /*consent*/ return this.consent == null ? new Base[0] : new Base[] {this.consent}; // Reference
735        default: return super.getProperty(hash, name, checkValid);
736        }
737
738      }
739
740      @Override
741      public Base setProperty(int hash, String name, Base value) throws FHIRException {
742        switch (hash) {
743        case -1618432855: // identifier
744          this.getIdentifier().add(TypeConvertor.castToIdentifier(value)); // Identifier
745          return value;
746        case -892481550: // status
747          value = new ResearchSubjectStatusEnumFactory().fromType(TypeConvertor.castToCode(value));
748          this.status = (Enumeration) value; // Enumeration<ResearchSubjectStatus>
749          return value;
750        case -991726143: // period
751          this.period = TypeConvertor.castToPeriod(value); // Period
752          return value;
753        case 109776329: // study
754          this.study = TypeConvertor.castToReference(value); // Reference
755          return value;
756        case -46292327: // individual
757          this.individual = TypeConvertor.castToReference(value); // Reference
758          return value;
759        case 1741912494: // assignedArm
760          this.assignedArm = TypeConvertor.castToString(value); // StringType
761          return value;
762        case 528827886: // actualArm
763          this.actualArm = TypeConvertor.castToString(value); // StringType
764          return value;
765        case 951500826: // consent
766          this.consent = TypeConvertor.castToReference(value); // Reference
767          return value;
768        default: return super.setProperty(hash, name, value);
769        }
770
771      }
772
773      @Override
774      public Base setProperty(String name, Base value) throws FHIRException {
775        if (name.equals("identifier")) {
776          this.getIdentifier().add(TypeConvertor.castToIdentifier(value));
777        } else if (name.equals("status")) {
778          value = new ResearchSubjectStatusEnumFactory().fromType(TypeConvertor.castToCode(value));
779          this.status = (Enumeration) value; // Enumeration<ResearchSubjectStatus>
780        } else if (name.equals("period")) {
781          this.period = TypeConvertor.castToPeriod(value); // Period
782        } else if (name.equals("study")) {
783          this.study = TypeConvertor.castToReference(value); // Reference
784        } else if (name.equals("individual")) {
785          this.individual = TypeConvertor.castToReference(value); // Reference
786        } else if (name.equals("assignedArm")) {
787          this.assignedArm = TypeConvertor.castToString(value); // StringType
788        } else if (name.equals("actualArm")) {
789          this.actualArm = TypeConvertor.castToString(value); // StringType
790        } else if (name.equals("consent")) {
791          this.consent = TypeConvertor.castToReference(value); // Reference
792        } else
793          return super.setProperty(name, value);
794        return value;
795      }
796
797      @Override
798      public Base makeProperty(int hash, String name) throws FHIRException {
799        switch (hash) {
800        case -1618432855:  return addIdentifier(); 
801        case -892481550:  return getStatusElement();
802        case -991726143:  return getPeriod();
803        case 109776329:  return getStudy();
804        case -46292327:  return getIndividual();
805        case 1741912494:  return getAssignedArmElement();
806        case 528827886:  return getActualArmElement();
807        case 951500826:  return getConsent();
808        default: return super.makeProperty(hash, name);
809        }
810
811      }
812
813      @Override
814      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
815        switch (hash) {
816        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
817        case -892481550: /*status*/ return new String[] {"code"};
818        case -991726143: /*period*/ return new String[] {"Period"};
819        case 109776329: /*study*/ return new String[] {"Reference"};
820        case -46292327: /*individual*/ return new String[] {"Reference"};
821        case 1741912494: /*assignedArm*/ return new String[] {"string"};
822        case 528827886: /*actualArm*/ return new String[] {"string"};
823        case 951500826: /*consent*/ return new String[] {"Reference"};
824        default: return super.getTypesForProperty(hash, name);
825        }
826
827      }
828
829      @Override
830      public Base addChild(String name) throws FHIRException {
831        if (name.equals("identifier")) {
832          return addIdentifier();
833        }
834        else if (name.equals("status")) {
835          throw new FHIRException("Cannot call addChild on a primitive type ResearchSubject.status");
836        }
837        else if (name.equals("period")) {
838          this.period = new Period();
839          return this.period;
840        }
841        else if (name.equals("study")) {
842          this.study = new Reference();
843          return this.study;
844        }
845        else if (name.equals("individual")) {
846          this.individual = new Reference();
847          return this.individual;
848        }
849        else if (name.equals("assignedArm")) {
850          throw new FHIRException("Cannot call addChild on a primitive type ResearchSubject.assignedArm");
851        }
852        else if (name.equals("actualArm")) {
853          throw new FHIRException("Cannot call addChild on a primitive type ResearchSubject.actualArm");
854        }
855        else if (name.equals("consent")) {
856          this.consent = new Reference();
857          return this.consent;
858        }
859        else
860          return super.addChild(name);
861      }
862
863  public String fhirType() {
864    return "ResearchSubject";
865
866  }
867
868      public ResearchSubject copy() {
869        ResearchSubject dst = new ResearchSubject();
870        copyValues(dst);
871        return dst;
872      }
873
874      public void copyValues(ResearchSubject dst) {
875        super.copyValues(dst);
876        if (identifier != null) {
877          dst.identifier = new ArrayList<Identifier>();
878          for (Identifier i : identifier)
879            dst.identifier.add(i.copy());
880        };
881        dst.status = status == null ? null : status.copy();
882        dst.period = period == null ? null : period.copy();
883        dst.study = study == null ? null : study.copy();
884        dst.individual = individual == null ? null : individual.copy();
885        dst.assignedArm = assignedArm == null ? null : assignedArm.copy();
886        dst.actualArm = actualArm == null ? null : actualArm.copy();
887        dst.consent = consent == null ? null : consent.copy();
888      }
889
890      protected ResearchSubject typedCopy() {
891        return copy();
892      }
893
894      @Override
895      public boolean equalsDeep(Base other_) {
896        if (!super.equalsDeep(other_))
897          return false;
898        if (!(other_ instanceof ResearchSubject))
899          return false;
900        ResearchSubject o = (ResearchSubject) other_;
901        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(period, o.period, true)
902           && compareDeep(study, o.study, true) && compareDeep(individual, o.individual, true) && compareDeep(assignedArm, o.assignedArm, true)
903           && compareDeep(actualArm, o.actualArm, true) && compareDeep(consent, o.consent, true);
904      }
905
906      @Override
907      public boolean equalsShallow(Base other_) {
908        if (!super.equalsShallow(other_))
909          return false;
910        if (!(other_ instanceof ResearchSubject))
911          return false;
912        ResearchSubject o = (ResearchSubject) other_;
913        return compareValues(status, o.status, true) && compareValues(assignedArm, o.assignedArm, true) && compareValues(actualArm, o.actualArm, true)
914          ;
915      }
916
917      public boolean isEmpty() {
918        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, period
919          , study, individual, assignedArm, actualArm, consent);
920      }
921
922  @Override
923  public ResourceType getResourceType() {
924    return ResourceType.ResearchSubject;
925   }
926
927 /**
928   * Search parameter: <b>date</b>
929   * <p>
930   * Description: <b>Start and end of participation</b><br>
931   * Type: <b>date</b><br>
932   * Path: <b>ResearchSubject.period</b><br>
933   * </p>
934   */
935  @SearchParamDefinition(name="date", path="ResearchSubject.period", description="Start and end of participation", type="date" )
936  public static final String SP_DATE = "date";
937 /**
938   * <b>Fluent Client</b> search parameter constant for <b>date</b>
939   * <p>
940   * Description: <b>Start and end of participation</b><br>
941   * Type: <b>date</b><br>
942   * Path: <b>ResearchSubject.period</b><br>
943   * </p>
944   */
945  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATE);
946
947 /**
948   * Search parameter: <b>identifier</b>
949   * <p>
950   * Description: <b>Business Identifier for research subject in a study</b><br>
951   * Type: <b>token</b><br>
952   * Path: <b>ResearchSubject.identifier</b><br>
953   * </p>
954   */
955  @SearchParamDefinition(name="identifier", path="ResearchSubject.identifier", description="Business Identifier for research subject in a study", type="token" )
956  public static final String SP_IDENTIFIER = "identifier";
957 /**
958   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
959   * <p>
960   * Description: <b>Business Identifier for research subject in a study</b><br>
961   * Type: <b>token</b><br>
962   * Path: <b>ResearchSubject.identifier</b><br>
963   * </p>
964   */
965  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
966
967 /**
968   * Search parameter: <b>individual</b>
969   * <p>
970   * Description: <b>Who is part of study</b><br>
971   * Type: <b>reference</b><br>
972   * Path: <b>ResearchSubject.individual</b><br>
973   * </p>
974   */
975  @SearchParamDefinition(name="individual", path="ResearchSubject.individual", description="Who is part of study", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Base FHIR compartment definition for Patient") }, target={Patient.class } )
976  public static final String SP_INDIVIDUAL = "individual";
977 /**
978   * <b>Fluent Client</b> search parameter constant for <b>individual</b>
979   * <p>
980   * Description: <b>Who is part of study</b><br>
981   * Type: <b>reference</b><br>
982   * Path: <b>ResearchSubject.individual</b><br>
983   * </p>
984   */
985  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam INDIVIDUAL = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_INDIVIDUAL);
986
987/**
988   * Constant for fluent queries to be used to add include statements. Specifies
989   * the path value of "<b>ResearchSubject:individual</b>".
990   */
991  public static final ca.uhn.fhir.model.api.Include INCLUDE_INDIVIDUAL = new ca.uhn.fhir.model.api.Include("ResearchSubject:individual").toLocked();
992
993 /**
994   * Search parameter: <b>patient</b>
995   * <p>
996   * Description: <b>Who is part of study</b><br>
997   * Type: <b>reference</b><br>
998   * Path: <b>ResearchSubject.individual</b><br>
999   * </p>
1000   */
1001  @SearchParamDefinition(name="patient", path="ResearchSubject.individual", description="Who is part of study", type="reference", target={Patient.class } )
1002  public static final String SP_PATIENT = "patient";
1003 /**
1004   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
1005   * <p>
1006   * Description: <b>Who is part of study</b><br>
1007   * Type: <b>reference</b><br>
1008   * Path: <b>ResearchSubject.individual</b><br>
1009   * </p>
1010   */
1011  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
1012
1013/**
1014   * Constant for fluent queries to be used to add include statements. Specifies
1015   * the path value of "<b>ResearchSubject:patient</b>".
1016   */
1017  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("ResearchSubject:patient").toLocked();
1018
1019 /**
1020   * Search parameter: <b>status</b>
1021   * <p>
1022   * Description: <b>candidate | eligible | follow-up | ineligible | not-registered | off-study | on-study | on-study-intervention | on-study-observation | pending-on-study | potential-candidate | screening | withdrawn</b><br>
1023   * Type: <b>token</b><br>
1024   * Path: <b>ResearchSubject.status</b><br>
1025   * </p>
1026   */
1027  @SearchParamDefinition(name="status", path="ResearchSubject.status", description="candidate | eligible | follow-up | ineligible | not-registered | off-study | on-study | on-study-intervention | on-study-observation | pending-on-study | potential-candidate | screening | withdrawn", type="token" )
1028  public static final String SP_STATUS = "status";
1029 /**
1030   * <b>Fluent Client</b> search parameter constant for <b>status</b>
1031   * <p>
1032   * Description: <b>candidate | eligible | follow-up | ineligible | not-registered | off-study | on-study | on-study-intervention | on-study-observation | pending-on-study | potential-candidate | screening | withdrawn</b><br>
1033   * Type: <b>token</b><br>
1034   * Path: <b>ResearchSubject.status</b><br>
1035   * </p>
1036   */
1037  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
1038
1039 /**
1040   * Search parameter: <b>study</b>
1041   * <p>
1042   * Description: <b>Study subject is part of</b><br>
1043   * Type: <b>reference</b><br>
1044   * Path: <b>ResearchSubject.study</b><br>
1045   * </p>
1046   */
1047  @SearchParamDefinition(name="study", path="ResearchSubject.study", description="Study subject is part of", type="reference", target={ResearchStudy.class } )
1048  public static final String SP_STUDY = "study";
1049 /**
1050   * <b>Fluent Client</b> search parameter constant for <b>study</b>
1051   * <p>
1052   * Description: <b>Study subject is part of</b><br>
1053   * Type: <b>reference</b><br>
1054   * Path: <b>ResearchSubject.study</b><br>
1055   * </p>
1056   */
1057  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam STUDY = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_STUDY);
1058
1059/**
1060   * Constant for fluent queries to be used to add include statements. Specifies
1061   * the path value of "<b>ResearchSubject:study</b>".
1062   */
1063  public static final ca.uhn.fhir.model.api.Include INCLUDE_STUDY = new ca.uhn.fhir.model.api.Include("ResearchSubject:study").toLocked();
1064
1065
1066}
1067