001package org.hl7.fhir.r5.model;
002
003
004/*
005 * #%L
006 * org.hl7.fhir.r5
007 * %%
008 * Copyright (C) 2014 - 2019 Health Level 7
009 * %%
010 * Licensed under the Apache License, Version 2.0 (the \"License\");
011 * you may not use this file except in compliance with the License.
012 * You may obtain a copy of the License at
013 * 
014 *      http://www.apache.org/licenses/LICENSE-2.0
015 * 
016 * Unless required by applicable law or agreed to in writing, software
017 * distributed under the License is distributed on an \"AS IS\" BASIS,
018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
019 * See the License for the specific language governing permissions and
020 * limitations under the License.
021 * #L%
022 */
023
024/*
025  Copyright (c) 2011+, HL7, Inc.
026  All rights reserved.
027  
028  Redistribution and use in source and binary forms, with or without modification, \
029  are permitted provided that the following conditions are met:
030  
031   * Redistributions of source code must retain the above copyright notice, this \
032     list of conditions and the following disclaimer.
033   * Redistributions in binary form must reproduce the above copyright notice, \
034     this list of conditions and the following disclaimer in the documentation \
035     and/or other materials provided with the distribution.
036   * Neither the name of HL7 nor the names of its contributors may be used to 
037     endorse or promote products derived from this software without specific 
038     prior written permission.
039  
040  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \
041  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \
042  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \
043  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \
044  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \
045  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \
046  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \
047  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \
048  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \
049  POSSIBILITY OF SUCH DAMAGE.
050  */
051
052// Generated on Tue, Dec 31, 2019 12:12+1100 for FHIR vcurrent
053
054import java.util.ArrayList;
055import java.util.Date;
056import java.util.List;
057import org.hl7.fhir.utilities.Utilities;
058import org.hl7.fhir.r5.model.Enumerations.*;
059import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
060import org.hl7.fhir.exceptions.FHIRException;
061import org.hl7.fhir.instance.model.api.ICompositeType;
062import ca.uhn.fhir.model.api.annotation.ResourceDef;
063import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
064import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
065import ca.uhn.fhir.model.api.annotation.Child;
066import ca.uhn.fhir.model.api.annotation.ChildOrder;
067import ca.uhn.fhir.model.api.annotation.Description;
068import ca.uhn.fhir.model.api.annotation.Block;
069
070/**
071 * A physical entity which is the primary unit of operational and/or administrative interest in a study.
072 */
073@ResourceDef(name="ResearchSubject", profile="http://hl7.org/fhir/StructureDefinition/ResearchSubject")
074public class ResearchSubject extends DomainResource {
075
076    public enum ResearchSubjectStatus {
077        /**
078         * An identified person that can be considered for inclusion in a study.
079         */
080        CANDIDATE, 
081        /**
082         * A person that has met the eligibility criteria for inclusion in a study.
083         */
084        ELIGIBLE, 
085        /**
086         * 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.
087         */
088        FOLLOWUP, 
089        /**
090         * 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.
091         */
092        INELIGIBLE, 
093        /**
094         * A person for whom registration was not completed.
095         */
096        NOTREGISTERED, 
097        /**
098         * 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.
099         */
100        OFFSTUDY, 
101        /**
102         * A person that is enrolled or registered on a study.
103         */
104        ONSTUDY, 
105        /**
106         * The person is receiving the treatment or participating in an activity (e.g. yoga, diet, etc.) that the study is evaluating.
107         */
108        ONSTUDYINTERVENTION, 
109        /**
110         * 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\".
111         */
112        ONSTUDYOBSERVATION, 
113        /**
114         * A person is pre-registered for a study.
115         */
116        PENDINGONSTUDY, 
117        /**
118         * A person that is potentially eligible for participation in the study.
119         */
120        POTENTIALCANDIDATE, 
121        /**
122         * A person who is being evaluated for eligibility for a study.
123         */
124        SCREENING, 
125        /**
126         * The person has withdrawn their participation in the study before registration.
127         */
128        WITHDRAWN, 
129        /**
130         * added to help the parsers with the generic types
131         */
132        NULL;
133        public static ResearchSubjectStatus fromCode(String codeString) throws FHIRException {
134            if (codeString == null || "".equals(codeString))
135                return null;
136        if ("candidate".equals(codeString))
137          return CANDIDATE;
138        if ("eligible".equals(codeString))
139          return ELIGIBLE;
140        if ("follow-up".equals(codeString))
141          return FOLLOWUP;
142        if ("ineligible".equals(codeString))
143          return INELIGIBLE;
144        if ("not-registered".equals(codeString))
145          return NOTREGISTERED;
146        if ("off-study".equals(codeString))
147          return OFFSTUDY;
148        if ("on-study".equals(codeString))
149          return ONSTUDY;
150        if ("on-study-intervention".equals(codeString))
151          return ONSTUDYINTERVENTION;
152        if ("on-study-observation".equals(codeString))
153          return ONSTUDYOBSERVATION;
154        if ("pending-on-study".equals(codeString))
155          return PENDINGONSTUDY;
156        if ("potential-candidate".equals(codeString))
157          return POTENTIALCANDIDATE;
158        if ("screening".equals(codeString))
159          return SCREENING;
160        if ("withdrawn".equals(codeString))
161          return WITHDRAWN;
162        if (Configuration.isAcceptInvalidEnums())
163          return null;
164        else
165          throw new FHIRException("Unknown ResearchSubjectStatus code '"+codeString+"'");
166        }
167        public String toCode() {
168          switch (this) {
169            case CANDIDATE: return "candidate";
170            case ELIGIBLE: return "eligible";
171            case FOLLOWUP: return "follow-up";
172            case INELIGIBLE: return "ineligible";
173            case NOTREGISTERED: return "not-registered";
174            case OFFSTUDY: return "off-study";
175            case ONSTUDY: return "on-study";
176            case ONSTUDYINTERVENTION: return "on-study-intervention";
177            case ONSTUDYOBSERVATION: return "on-study-observation";
178            case PENDINGONSTUDY: return "pending-on-study";
179            case POTENTIALCANDIDATE: return "potential-candidate";
180            case SCREENING: return "screening";
181            case WITHDRAWN: return "withdrawn";
182            default: return "?";
183          }
184        }
185        public String getSystem() {
186          switch (this) {
187            case CANDIDATE: return "http://hl7.org/fhir/research-subject-status";
188            case ELIGIBLE: return "http://hl7.org/fhir/research-subject-status";
189            case FOLLOWUP: return "http://hl7.org/fhir/research-subject-status";
190            case INELIGIBLE: return "http://hl7.org/fhir/research-subject-status";
191            case NOTREGISTERED: return "http://hl7.org/fhir/research-subject-status";
192            case OFFSTUDY: return "http://hl7.org/fhir/research-subject-status";
193            case ONSTUDY: return "http://hl7.org/fhir/research-subject-status";
194            case ONSTUDYINTERVENTION: return "http://hl7.org/fhir/research-subject-status";
195            case ONSTUDYOBSERVATION: return "http://hl7.org/fhir/research-subject-status";
196            case PENDINGONSTUDY: return "http://hl7.org/fhir/research-subject-status";
197            case POTENTIALCANDIDATE: return "http://hl7.org/fhir/research-subject-status";
198            case SCREENING: return "http://hl7.org/fhir/research-subject-status";
199            case WITHDRAWN: return "http://hl7.org/fhir/research-subject-status";
200            default: return "?";
201          }
202        }
203        public String getDefinition() {
204          switch (this) {
205            case CANDIDATE: return "An identified person that can be considered for inclusion in a study.";
206            case ELIGIBLE: return "A person that has met the eligibility criteria for inclusion in a study.";
207            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.";
208            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.";
209            case NOTREGISTERED: return "A person for whom registration was not completed.";
210            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.";
211            case ONSTUDY: return "A person that is enrolled or registered on a study.";
212            case ONSTUDYINTERVENTION: return "The person is receiving the treatment or participating in an activity (e.g. yoga, diet, etc.) that the study is evaluating.";
213            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\".";
214            case PENDINGONSTUDY: return "A person is pre-registered for a study.";
215            case POTENTIALCANDIDATE: return "A person that is potentially eligible for participation in the study.";
216            case SCREENING: return "A person who is being evaluated for eligibility for a study.";
217            case WITHDRAWN: return "The person has withdrawn their participation in the study before registration.";
218            default: return "?";
219          }
220        }
221        public String getDisplay() {
222          switch (this) {
223            case CANDIDATE: return "Candidate";
224            case ELIGIBLE: return "Eligible";
225            case FOLLOWUP: return "Follow-up";
226            case INELIGIBLE: return "Ineligible";
227            case NOTREGISTERED: return "Not Registered";
228            case OFFSTUDY: return "Off-study";
229            case ONSTUDY: return "On-study";
230            case ONSTUDYINTERVENTION: return "On-study-intervention";
231            case ONSTUDYOBSERVATION: return "On-study-observation";
232            case PENDINGONSTUDY: return "Pending on-study";
233            case POTENTIALCANDIDATE: return "Potential Candidate";
234            case SCREENING: return "Screening";
235            case WITHDRAWN: return "Withdrawn";
236            default: return "?";
237          }
238        }
239    }
240
241  public static class ResearchSubjectStatusEnumFactory implements EnumFactory<ResearchSubjectStatus> {
242    public ResearchSubjectStatus fromCode(String codeString) throws IllegalArgumentException {
243      if (codeString == null || "".equals(codeString))
244            if (codeString == null || "".equals(codeString))
245                return null;
246        if ("candidate".equals(codeString))
247          return ResearchSubjectStatus.CANDIDATE;
248        if ("eligible".equals(codeString))
249          return ResearchSubjectStatus.ELIGIBLE;
250        if ("follow-up".equals(codeString))
251          return ResearchSubjectStatus.FOLLOWUP;
252        if ("ineligible".equals(codeString))
253          return ResearchSubjectStatus.INELIGIBLE;
254        if ("not-registered".equals(codeString))
255          return ResearchSubjectStatus.NOTREGISTERED;
256        if ("off-study".equals(codeString))
257          return ResearchSubjectStatus.OFFSTUDY;
258        if ("on-study".equals(codeString))
259          return ResearchSubjectStatus.ONSTUDY;
260        if ("on-study-intervention".equals(codeString))
261          return ResearchSubjectStatus.ONSTUDYINTERVENTION;
262        if ("on-study-observation".equals(codeString))
263          return ResearchSubjectStatus.ONSTUDYOBSERVATION;
264        if ("pending-on-study".equals(codeString))
265          return ResearchSubjectStatus.PENDINGONSTUDY;
266        if ("potential-candidate".equals(codeString))
267          return ResearchSubjectStatus.POTENTIALCANDIDATE;
268        if ("screening".equals(codeString))
269          return ResearchSubjectStatus.SCREENING;
270        if ("withdrawn".equals(codeString))
271          return ResearchSubjectStatus.WITHDRAWN;
272        throw new IllegalArgumentException("Unknown ResearchSubjectStatus code '"+codeString+"'");
273        }
274        public Enumeration<ResearchSubjectStatus> fromType(Base code) throws FHIRException {
275          if (code == null)
276            return null;
277          if (code.isEmpty())
278            return new Enumeration<ResearchSubjectStatus>(this);
279          String codeString = ((PrimitiveType) code).asStringValue();
280          if (codeString == null || "".equals(codeString))
281            return null;
282        if ("candidate".equals(codeString))
283          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.CANDIDATE);
284        if ("eligible".equals(codeString))
285          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.ELIGIBLE);
286        if ("follow-up".equals(codeString))
287          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.FOLLOWUP);
288        if ("ineligible".equals(codeString))
289          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.INELIGIBLE);
290        if ("not-registered".equals(codeString))
291          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.NOTREGISTERED);
292        if ("off-study".equals(codeString))
293          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.OFFSTUDY);
294        if ("on-study".equals(codeString))
295          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.ONSTUDY);
296        if ("on-study-intervention".equals(codeString))
297          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.ONSTUDYINTERVENTION);
298        if ("on-study-observation".equals(codeString))
299          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.ONSTUDYOBSERVATION);
300        if ("pending-on-study".equals(codeString))
301          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.PENDINGONSTUDY);
302        if ("potential-candidate".equals(codeString))
303          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.POTENTIALCANDIDATE);
304        if ("screening".equals(codeString))
305          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.SCREENING);
306        if ("withdrawn".equals(codeString))
307          return new Enumeration<ResearchSubjectStatus>(this, ResearchSubjectStatus.WITHDRAWN);
308        throw new FHIRException("Unknown ResearchSubjectStatus code '"+codeString+"'");
309        }
310    public String toCode(ResearchSubjectStatus code) {
311      if (code == ResearchSubjectStatus.CANDIDATE)
312        return "candidate";
313      if (code == ResearchSubjectStatus.ELIGIBLE)
314        return "eligible";
315      if (code == ResearchSubjectStatus.FOLLOWUP)
316        return "follow-up";
317      if (code == ResearchSubjectStatus.INELIGIBLE)
318        return "ineligible";
319      if (code == ResearchSubjectStatus.NOTREGISTERED)
320        return "not-registered";
321      if (code == ResearchSubjectStatus.OFFSTUDY)
322        return "off-study";
323      if (code == ResearchSubjectStatus.ONSTUDY)
324        return "on-study";
325      if (code == ResearchSubjectStatus.ONSTUDYINTERVENTION)
326        return "on-study-intervention";
327      if (code == ResearchSubjectStatus.ONSTUDYOBSERVATION)
328        return "on-study-observation";
329      if (code == ResearchSubjectStatus.PENDINGONSTUDY)
330        return "pending-on-study";
331      if (code == ResearchSubjectStatus.POTENTIALCANDIDATE)
332        return "potential-candidate";
333      if (code == ResearchSubjectStatus.SCREENING)
334        return "screening";
335      if (code == ResearchSubjectStatus.WITHDRAWN)
336        return "withdrawn";
337      return "?";
338      }
339    public String toSystem(ResearchSubjectStatus code) {
340      return code.getSystem();
341      }
342    }
343
344    @Block()
345    public static class ResearchSubjectProgressComponent extends BackboneElement implements IBaseBackboneElement {
346        /**
347         * Identifies the aspect of the subject's journey that the state refers to.
348         */
349        @Child(name = "type", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=false)
350        @Description(shortDefinition="Kind of state that is being described", formalDefinition="Identifies the aspect of the subject's journey that the state refers to." )
351        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/research-subject-state-type")
352        protected CodeableConcept type;
353
354        /**
355         * The current state of the subject.
356         */
357        @Child(name = "state", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
358        @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." )
359        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/research-subject-state")
360        protected CodeableConcept state;
361
362        /**
363         * The milestones the subject has passed through.
364         */
365        @Child(name = "milestone", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=false)
366        @Description(shortDefinition="SignedUp | Screened | Randomized", formalDefinition="The milestones the subject has passed through." )
367        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/research-subject-milestone")
368        protected CodeableConcept milestone;
369
370        /**
371         * The reason for the state change.  If coded it should follow the formal subject state model.
372         */
373        @Child(name = "reason", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=false)
374        @Description(shortDefinition="State change reason", formalDefinition="The reason for the state change.  If coded it should follow the formal subject state model." )
375        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/state-change-reason")
376        protected CodeableConcept reason;
377
378        /**
379         * The date when the change in status occurred.
380         */
381        @Child(name = "startDate", type = {DateTimeType.class}, order=5, min=1, max=1, modifier=false, summary=false)
382        @Description(shortDefinition="State change date", formalDefinition="The date when the change in status occurred." )
383        protected DateTimeType startDate;
384
385        private static final long serialVersionUID = -29864900L;
386
387    /**
388     * Constructor
389     */
390      public ResearchSubjectProgressComponent() {
391        super();
392      }
393
394    /**
395     * Constructor
396     */
397      public ResearchSubjectProgressComponent(Date startDate) {
398        super();
399        this.setStartDate(startDate);
400      }
401
402        /**
403         * @return {@link #type} (Identifies the aspect of the subject's journey that the state refers to.)
404         */
405        public CodeableConcept getType() { 
406          if (this.type == null)
407            if (Configuration.errorOnAutoCreate())
408              throw new Error("Attempt to auto-create ResearchSubjectProgressComponent.type");
409            else if (Configuration.doAutoCreate())
410              this.type = new CodeableConcept(); // cc
411          return this.type;
412        }
413
414        public boolean hasType() { 
415          return this.type != null && !this.type.isEmpty();
416        }
417
418        /**
419         * @param value {@link #type} (Identifies the aspect of the subject's journey that the state refers to.)
420         */
421        public ResearchSubjectProgressComponent setType(CodeableConcept value) { 
422          this.type = value;
423          return this;
424        }
425
426        /**
427         * @return {@link #state} (The current state of the subject.)
428         */
429        public CodeableConcept getState() { 
430          if (this.state == null)
431            if (Configuration.errorOnAutoCreate())
432              throw new Error("Attempt to auto-create ResearchSubjectProgressComponent.state");
433            else if (Configuration.doAutoCreate())
434              this.state = new CodeableConcept(); // cc
435          return this.state;
436        }
437
438        public boolean hasState() { 
439          return this.state != null && !this.state.isEmpty();
440        }
441
442        /**
443         * @param value {@link #state} (The current state of the subject.)
444         */
445        public ResearchSubjectProgressComponent setState(CodeableConcept value) { 
446          this.state = value;
447          return this;
448        }
449
450        /**
451         * @return {@link #milestone} (The milestones the subject has passed through.)
452         */
453        public CodeableConcept getMilestone() { 
454          if (this.milestone == null)
455            if (Configuration.errorOnAutoCreate())
456              throw new Error("Attempt to auto-create ResearchSubjectProgressComponent.milestone");
457            else if (Configuration.doAutoCreate())
458              this.milestone = new CodeableConcept(); // cc
459          return this.milestone;
460        }
461
462        public boolean hasMilestone() { 
463          return this.milestone != null && !this.milestone.isEmpty();
464        }
465
466        /**
467         * @param value {@link #milestone} (The milestones the subject has passed through.)
468         */
469        public ResearchSubjectProgressComponent setMilestone(CodeableConcept value) { 
470          this.milestone = value;
471          return this;
472        }
473
474        /**
475         * @return {@link #reason} (The reason for the state change.  If coded it should follow the formal subject state model.)
476         */
477        public CodeableConcept getReason() { 
478          if (this.reason == null)
479            if (Configuration.errorOnAutoCreate())
480              throw new Error("Attempt to auto-create ResearchSubjectProgressComponent.reason");
481            else if (Configuration.doAutoCreate())
482              this.reason = new CodeableConcept(); // cc
483          return this.reason;
484        }
485
486        public boolean hasReason() { 
487          return this.reason != null && !this.reason.isEmpty();
488        }
489
490        /**
491         * @param value {@link #reason} (The reason for the state change.  If coded it should follow the formal subject state model.)
492         */
493        public ResearchSubjectProgressComponent setReason(CodeableConcept value) { 
494          this.reason = value;
495          return this;
496        }
497
498        /**
499         * @return {@link #startDate} (The date when the change in status occurred.). This is the underlying object with id, value and extensions. The accessor "getStartDate" gives direct access to the value
500         */
501        public DateTimeType getStartDateElement() { 
502          if (this.startDate == null)
503            if (Configuration.errorOnAutoCreate())
504              throw new Error("Attempt to auto-create ResearchSubjectProgressComponent.startDate");
505            else if (Configuration.doAutoCreate())
506              this.startDate = new DateTimeType(); // bb
507          return this.startDate;
508        }
509
510        public boolean hasStartDateElement() { 
511          return this.startDate != null && !this.startDate.isEmpty();
512        }
513
514        public boolean hasStartDate() { 
515          return this.startDate != null && !this.startDate.isEmpty();
516        }
517
518        /**
519         * @param value {@link #startDate} (The date when the change in status occurred.). This is the underlying object with id, value and extensions. The accessor "getStartDate" gives direct access to the value
520         */
521        public ResearchSubjectProgressComponent setStartDateElement(DateTimeType value) { 
522          this.startDate = value;
523          return this;
524        }
525
526        /**
527         * @return The date when the change in status occurred.
528         */
529        public Date getStartDate() { 
530          return this.startDate == null ? null : this.startDate.getValue();
531        }
532
533        /**
534         * @param value The date when the change in status occurred.
535         */
536        public ResearchSubjectProgressComponent setStartDate(Date value) { 
537            if (this.startDate == null)
538              this.startDate = new DateTimeType();
539            this.startDate.setValue(value);
540          return this;
541        }
542
543        protected void listChildren(List<Property> children) {
544          super.listChildren(children);
545          children.add(new Property("type", "CodeableConcept", "Identifies the aspect of the subject's journey that the state refers to.", 0, 1, type));
546          children.add(new Property("state", "CodeableConcept", "The current state of the subject.", 0, 1, state));
547          children.add(new Property("milestone", "CodeableConcept", "The milestones the subject has passed through.", 0, 1, milestone));
548          children.add(new Property("reason", "CodeableConcept", "The reason for the state change.  If coded it should follow the formal subject state model.", 0, 1, reason));
549          children.add(new Property("startDate", "dateTime", "The date when the change in status occurred.", 0, 1, startDate));
550        }
551
552        @Override
553        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
554          switch (_hash) {
555          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "Identifies the aspect of the subject's journey that the state refers to.", 0, 1, type);
556          case 109757585: /*state*/  return new Property("state", "CodeableConcept", "The current state of the subject.", 0, 1, state);
557          case -1065084560: /*milestone*/  return new Property("milestone", "CodeableConcept", "The milestones the subject has passed through.", 0, 1, milestone);
558          case -934964668: /*reason*/  return new Property("reason", "CodeableConcept", "The reason for the state change.  If coded it should follow the formal subject state model.", 0, 1, reason);
559          case -2129778896: /*startDate*/  return new Property("startDate", "dateTime", "The date when the change in status occurred.", 0, 1, startDate);
560          default: return super.getNamedProperty(_hash, _name, _checkValid);
561          }
562
563        }
564
565      @Override
566      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
567        switch (hash) {
568        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
569        case 109757585: /*state*/ return this.state == null ? new Base[0] : new Base[] {this.state}; // CodeableConcept
570        case -1065084560: /*milestone*/ return this.milestone == null ? new Base[0] : new Base[] {this.milestone}; // CodeableConcept
571        case -934964668: /*reason*/ return this.reason == null ? new Base[0] : new Base[] {this.reason}; // CodeableConcept
572        case -2129778896: /*startDate*/ return this.startDate == null ? new Base[0] : new Base[] {this.startDate}; // DateTimeType
573        default: return super.getProperty(hash, name, checkValid);
574        }
575
576      }
577
578      @Override
579      public Base setProperty(int hash, String name, Base value) throws FHIRException {
580        switch (hash) {
581        case 3575610: // type
582          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
583          return value;
584        case 109757585: // state
585          this.state = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
586          return value;
587        case -1065084560: // milestone
588          this.milestone = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
589          return value;
590        case -934964668: // reason
591          this.reason = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
592          return value;
593        case -2129778896: // startDate
594          this.startDate = TypeConvertor.castToDateTime(value); // DateTimeType
595          return value;
596        default: return super.setProperty(hash, name, value);
597        }
598
599      }
600
601      @Override
602      public Base setProperty(String name, Base value) throws FHIRException {
603        if (name.equals("type")) {
604          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
605        } else if (name.equals("state")) {
606          this.state = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
607        } else if (name.equals("milestone")) {
608          this.milestone = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
609        } else if (name.equals("reason")) {
610          this.reason = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
611        } else if (name.equals("startDate")) {
612          this.startDate = TypeConvertor.castToDateTime(value); // DateTimeType
613        } else
614          return super.setProperty(name, value);
615        return value;
616      }
617
618      @Override
619      public Base makeProperty(int hash, String name) throws FHIRException {
620        switch (hash) {
621        case 3575610:  return getType();
622        case 109757585:  return getState();
623        case -1065084560:  return getMilestone();
624        case -934964668:  return getReason();
625        case -2129778896:  return getStartDateElement();
626        default: return super.makeProperty(hash, name);
627        }
628
629      }
630
631      @Override
632      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
633        switch (hash) {
634        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
635        case 109757585: /*state*/ return new String[] {"CodeableConcept"};
636        case -1065084560: /*milestone*/ return new String[] {"CodeableConcept"};
637        case -934964668: /*reason*/ return new String[] {"CodeableConcept"};
638        case -2129778896: /*startDate*/ return new String[] {"dateTime"};
639        default: return super.getTypesForProperty(hash, name);
640        }
641
642      }
643
644      @Override
645      public Base addChild(String name) throws FHIRException {
646        if (name.equals("type")) {
647          this.type = new CodeableConcept();
648          return this.type;
649        }
650        else if (name.equals("state")) {
651          this.state = new CodeableConcept();
652          return this.state;
653        }
654        else if (name.equals("milestone")) {
655          this.milestone = new CodeableConcept();
656          return this.milestone;
657        }
658        else if (name.equals("reason")) {
659          this.reason = new CodeableConcept();
660          return this.reason;
661        }
662        else if (name.equals("startDate")) {
663          throw new FHIRException("Cannot call addChild on a primitive type ResearchSubject.progress.startDate");
664        }
665        else
666          return super.addChild(name);
667      }
668
669      public ResearchSubjectProgressComponent copy() {
670        ResearchSubjectProgressComponent dst = new ResearchSubjectProgressComponent();
671        copyValues(dst);
672        return dst;
673      }
674
675      public void copyValues(ResearchSubjectProgressComponent dst) {
676        super.copyValues(dst);
677        dst.type = type == null ? null : type.copy();
678        dst.state = state == null ? null : state.copy();
679        dst.milestone = milestone == null ? null : milestone.copy();
680        dst.reason = reason == null ? null : reason.copy();
681        dst.startDate = startDate == null ? null : startDate.copy();
682      }
683
684      @Override
685      public boolean equalsDeep(Base other_) {
686        if (!super.equalsDeep(other_))
687          return false;
688        if (!(other_ instanceof ResearchSubjectProgressComponent))
689          return false;
690        ResearchSubjectProgressComponent o = (ResearchSubjectProgressComponent) other_;
691        return compareDeep(type, o.type, true) && compareDeep(state, o.state, true) && compareDeep(milestone, o.milestone, true)
692           && compareDeep(reason, o.reason, true) && compareDeep(startDate, o.startDate, true);
693      }
694
695      @Override
696      public boolean equalsShallow(Base other_) {
697        if (!super.equalsShallow(other_))
698          return false;
699        if (!(other_ instanceof ResearchSubjectProgressComponent))
700          return false;
701        ResearchSubjectProgressComponent o = (ResearchSubjectProgressComponent) other_;
702        return compareValues(startDate, o.startDate, true);
703      }
704
705      public boolean isEmpty() {
706        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, state, milestone, reason
707          , startDate);
708      }
709
710  public String fhirType() {
711    return "ResearchSubject.progress";
712
713  }
714
715  }
716
717    /**
718     * Identifiers assigned to this research subject for a study.
719     */
720    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
721    @Description(shortDefinition="Business Identifier for research subject in a study", formalDefinition="Identifiers assigned to this research subject for a study." )
722    protected List<Identifier> identifier;
723
724    /**
725     * The current state of the subject.
726     */
727    @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true)
728    @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." )
729    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/research-subject-status")
730    protected Enumeration<ResearchSubjectStatus> status;
731
732    /**
733     * The current state (status) of the subject and resons for status change where appropriate.
734     */
735    @Child(name = "progress", type = {}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
736    @Description(shortDefinition="Subject status", formalDefinition="The current state (status) of the subject and resons for status change where appropriate." )
737    protected List<ResearchSubjectProgressComponent> progress;
738
739    /**
740     * The dates the subject began and ended their participation in the study.
741     */
742    @Child(name = "period", type = {Period.class}, order=3, min=0, max=1, modifier=false, summary=true)
743    @Description(shortDefinition="Start and end of participation", formalDefinition="The dates the subject began and ended their participation in the study." )
744    protected Period period;
745
746    /**
747     * Reference to the study the subject is participating in.
748     */
749    @Child(name = "study", type = {ResearchStudy.class}, order=4, min=1, max=1, modifier=false, summary=true)
750    @Description(shortDefinition="Study subject is part of", formalDefinition="Reference to the study the subject is participating in." )
751    protected Reference study;
752
753    /**
754     * The record of the person or animal who is involved in the study.
755     */
756    @Child(name = "individual", type = {Patient.class}, order=5, min=1, max=1, modifier=false, summary=true)
757    @Description(shortDefinition="Who is part of study", formalDefinition="The record of the person or animal who is involved in the study." )
758    protected Reference individual;
759
760    /**
761     * The name of the arm in the study the subject is expected to follow as part of this study.
762     */
763    @Child(name = "assignedArm", type = {StringType.class}, order=6, min=0, max=1, modifier=false, summary=false)
764    @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." )
765    protected StringType assignedArm;
766
767    /**
768     * The name of the arm in the study the subject actually followed as part of this study.
769     */
770    @Child(name = "actualArm", type = {StringType.class}, order=7, min=0, max=1, modifier=false, summary=false)
771    @Description(shortDefinition="What path was followed", formalDefinition="The name of the arm in the study the subject actually followed as part of this study." )
772    protected StringType actualArm;
773
774    /**
775     * A record of the patient's informed agreement to participate in the study.
776     */
777    @Child(name = "consent", type = {Consent.class}, order=8, min=0, max=1, modifier=false, summary=false)
778    @Description(shortDefinition="Agreement to participate in study", formalDefinition="A record of the patient's informed agreement to participate in the study." )
779    protected Reference consent;
780
781    private static final long serialVersionUID = 2110072351L;
782
783  /**
784   * Constructor
785   */
786    public ResearchSubject() {
787      super();
788    }
789
790  /**
791   * Constructor
792   */
793    public ResearchSubject(ResearchSubjectStatus status, Reference study, Reference individual) {
794      super();
795      this.setStatus(status);
796      this.setStudy(study);
797      this.setIndividual(individual);
798    }
799
800    /**
801     * @return {@link #identifier} (Identifiers assigned to this research subject for a study.)
802     */
803    public List<Identifier> getIdentifier() { 
804      if (this.identifier == null)
805        this.identifier = new ArrayList<Identifier>();
806      return this.identifier;
807    }
808
809    /**
810     * @return Returns a reference to <code>this</code> for easy method chaining
811     */
812    public ResearchSubject setIdentifier(List<Identifier> theIdentifier) { 
813      this.identifier = theIdentifier;
814      return this;
815    }
816
817    public boolean hasIdentifier() { 
818      if (this.identifier == null)
819        return false;
820      for (Identifier item : this.identifier)
821        if (!item.isEmpty())
822          return true;
823      return false;
824    }
825
826    public Identifier addIdentifier() { //3
827      Identifier t = new Identifier();
828      if (this.identifier == null)
829        this.identifier = new ArrayList<Identifier>();
830      this.identifier.add(t);
831      return t;
832    }
833
834    public ResearchSubject addIdentifier(Identifier t) { //3
835      if (t == null)
836        return this;
837      if (this.identifier == null)
838        this.identifier = new ArrayList<Identifier>();
839      this.identifier.add(t);
840      return this;
841    }
842
843    /**
844     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist {3}
845     */
846    public Identifier getIdentifierFirstRep() { 
847      if (getIdentifier().isEmpty()) {
848        addIdentifier();
849      }
850      return getIdentifier().get(0);
851    }
852
853    /**
854     * @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
855     */
856    public Enumeration<ResearchSubjectStatus> getStatusElement() { 
857      if (this.status == null)
858        if (Configuration.errorOnAutoCreate())
859          throw new Error("Attempt to auto-create ResearchSubject.status");
860        else if (Configuration.doAutoCreate())
861          this.status = new Enumeration<ResearchSubjectStatus>(new ResearchSubjectStatusEnumFactory()); // bb
862      return this.status;
863    }
864
865    public boolean hasStatusElement() { 
866      return this.status != null && !this.status.isEmpty();
867    }
868
869    public boolean hasStatus() { 
870      return this.status != null && !this.status.isEmpty();
871    }
872
873    /**
874     * @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
875     */
876    public ResearchSubject setStatusElement(Enumeration<ResearchSubjectStatus> value) { 
877      this.status = value;
878      return this;
879    }
880
881    /**
882     * @return The current state of the subject.
883     */
884    public ResearchSubjectStatus getStatus() { 
885      return this.status == null ? null : this.status.getValue();
886    }
887
888    /**
889     * @param value The current state of the subject.
890     */
891    public ResearchSubject setStatus(ResearchSubjectStatus value) { 
892        if (this.status == null)
893          this.status = new Enumeration<ResearchSubjectStatus>(new ResearchSubjectStatusEnumFactory());
894        this.status.setValue(value);
895      return this;
896    }
897
898    /**
899     * @return {@link #progress} (The current state (status) of the subject and resons for status change where appropriate.)
900     */
901    public List<ResearchSubjectProgressComponent> getProgress() { 
902      if (this.progress == null)
903        this.progress = new ArrayList<ResearchSubjectProgressComponent>();
904      return this.progress;
905    }
906
907    /**
908     * @return Returns a reference to <code>this</code> for easy method chaining
909     */
910    public ResearchSubject setProgress(List<ResearchSubjectProgressComponent> theProgress) { 
911      this.progress = theProgress;
912      return this;
913    }
914
915    public boolean hasProgress() { 
916      if (this.progress == null)
917        return false;
918      for (ResearchSubjectProgressComponent item : this.progress)
919        if (!item.isEmpty())
920          return true;
921      return false;
922    }
923
924    public ResearchSubjectProgressComponent addProgress() { //3
925      ResearchSubjectProgressComponent t = new ResearchSubjectProgressComponent();
926      if (this.progress == null)
927        this.progress = new ArrayList<ResearchSubjectProgressComponent>();
928      this.progress.add(t);
929      return t;
930    }
931
932    public ResearchSubject addProgress(ResearchSubjectProgressComponent t) { //3
933      if (t == null)
934        return this;
935      if (this.progress == null)
936        this.progress = new ArrayList<ResearchSubjectProgressComponent>();
937      this.progress.add(t);
938      return this;
939    }
940
941    /**
942     * @return The first repetition of repeating field {@link #progress}, creating it if it does not already exist {3}
943     */
944    public ResearchSubjectProgressComponent getProgressFirstRep() { 
945      if (getProgress().isEmpty()) {
946        addProgress();
947      }
948      return getProgress().get(0);
949    }
950
951    /**
952     * @return {@link #period} (The dates the subject began and ended their participation in the study.)
953     */
954    public Period getPeriod() { 
955      if (this.period == null)
956        if (Configuration.errorOnAutoCreate())
957          throw new Error("Attempt to auto-create ResearchSubject.period");
958        else if (Configuration.doAutoCreate())
959          this.period = new Period(); // cc
960      return this.period;
961    }
962
963    public boolean hasPeriod() { 
964      return this.period != null && !this.period.isEmpty();
965    }
966
967    /**
968     * @param value {@link #period} (The dates the subject began and ended their participation in the study.)
969     */
970    public ResearchSubject setPeriod(Period value) { 
971      this.period = value;
972      return this;
973    }
974
975    /**
976     * @return {@link #study} (Reference to the study the subject is participating in.)
977     */
978    public Reference getStudy() { 
979      if (this.study == null)
980        if (Configuration.errorOnAutoCreate())
981          throw new Error("Attempt to auto-create ResearchSubject.study");
982        else if (Configuration.doAutoCreate())
983          this.study = new Reference(); // cc
984      return this.study;
985    }
986
987    public boolean hasStudy() { 
988      return this.study != null && !this.study.isEmpty();
989    }
990
991    /**
992     * @param value {@link #study} (Reference to the study the subject is participating in.)
993     */
994    public ResearchSubject setStudy(Reference value) { 
995      this.study = value;
996      return this;
997    }
998
999    /**
1000     * @return {@link #individual} (The record of the person or animal who is involved in the study.)
1001     */
1002    public Reference getIndividual() { 
1003      if (this.individual == null)
1004        if (Configuration.errorOnAutoCreate())
1005          throw new Error("Attempt to auto-create ResearchSubject.individual");
1006        else if (Configuration.doAutoCreate())
1007          this.individual = new Reference(); // cc
1008      return this.individual;
1009    }
1010
1011    public boolean hasIndividual() { 
1012      return this.individual != null && !this.individual.isEmpty();
1013    }
1014
1015    /**
1016     * @param value {@link #individual} (The record of the person or animal who is involved in the study.)
1017     */
1018    public ResearchSubject setIndividual(Reference value) { 
1019      this.individual = value;
1020      return this;
1021    }
1022
1023    /**
1024     * @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
1025     */
1026    public StringType getAssignedArmElement() { 
1027      if (this.assignedArm == null)
1028        if (Configuration.errorOnAutoCreate())
1029          throw new Error("Attempt to auto-create ResearchSubject.assignedArm");
1030        else if (Configuration.doAutoCreate())
1031          this.assignedArm = new StringType(); // bb
1032      return this.assignedArm;
1033    }
1034
1035    public boolean hasAssignedArmElement() { 
1036      return this.assignedArm != null && !this.assignedArm.isEmpty();
1037    }
1038
1039    public boolean hasAssignedArm() { 
1040      return this.assignedArm != null && !this.assignedArm.isEmpty();
1041    }
1042
1043    /**
1044     * @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
1045     */
1046    public ResearchSubject setAssignedArmElement(StringType value) { 
1047      this.assignedArm = value;
1048      return this;
1049    }
1050
1051    /**
1052     * @return The name of the arm in the study the subject is expected to follow as part of this study.
1053     */
1054    public String getAssignedArm() { 
1055      return this.assignedArm == null ? null : this.assignedArm.getValue();
1056    }
1057
1058    /**
1059     * @param value The name of the arm in the study the subject is expected to follow as part of this study.
1060     */
1061    public ResearchSubject setAssignedArm(String value) { 
1062      if (Utilities.noString(value))
1063        this.assignedArm = null;
1064      else {
1065        if (this.assignedArm == null)
1066          this.assignedArm = new StringType();
1067        this.assignedArm.setValue(value);
1068      }
1069      return this;
1070    }
1071
1072    /**
1073     * @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
1074     */
1075    public StringType getActualArmElement() { 
1076      if (this.actualArm == null)
1077        if (Configuration.errorOnAutoCreate())
1078          throw new Error("Attempt to auto-create ResearchSubject.actualArm");
1079        else if (Configuration.doAutoCreate())
1080          this.actualArm = new StringType(); // bb
1081      return this.actualArm;
1082    }
1083
1084    public boolean hasActualArmElement() { 
1085      return this.actualArm != null && !this.actualArm.isEmpty();
1086    }
1087
1088    public boolean hasActualArm() { 
1089      return this.actualArm != null && !this.actualArm.isEmpty();
1090    }
1091
1092    /**
1093     * @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
1094     */
1095    public ResearchSubject setActualArmElement(StringType value) { 
1096      this.actualArm = value;
1097      return this;
1098    }
1099
1100    /**
1101     * @return The name of the arm in the study the subject actually followed as part of this study.
1102     */
1103    public String getActualArm() { 
1104      return this.actualArm == null ? null : this.actualArm.getValue();
1105    }
1106
1107    /**
1108     * @param value The name of the arm in the study the subject actually followed as part of this study.
1109     */
1110    public ResearchSubject setActualArm(String value) { 
1111      if (Utilities.noString(value))
1112        this.actualArm = null;
1113      else {
1114        if (this.actualArm == null)
1115          this.actualArm = new StringType();
1116        this.actualArm.setValue(value);
1117      }
1118      return this;
1119    }
1120
1121    /**
1122     * @return {@link #consent} (A record of the patient's informed agreement to participate in the study.)
1123     */
1124    public Reference getConsent() { 
1125      if (this.consent == null)
1126        if (Configuration.errorOnAutoCreate())
1127          throw new Error("Attempt to auto-create ResearchSubject.consent");
1128        else if (Configuration.doAutoCreate())
1129          this.consent = new Reference(); // cc
1130      return this.consent;
1131    }
1132
1133    public boolean hasConsent() { 
1134      return this.consent != null && !this.consent.isEmpty();
1135    }
1136
1137    /**
1138     * @param value {@link #consent} (A record of the patient's informed agreement to participate in the study.)
1139     */
1140    public ResearchSubject setConsent(Reference value) { 
1141      this.consent = value;
1142      return this;
1143    }
1144
1145      protected void listChildren(List<Property> children) {
1146        super.listChildren(children);
1147        children.add(new Property("identifier", "Identifier", "Identifiers assigned to this research subject for a study.", 0, java.lang.Integer.MAX_VALUE, identifier));
1148        children.add(new Property("status", "code", "The current state of the subject.", 0, 1, status));
1149        children.add(new Property("progress", "", "The current state (status) of the subject and resons for status change where appropriate.", 0, java.lang.Integer.MAX_VALUE, progress));
1150        children.add(new Property("period", "Period", "The dates the subject began and ended their participation in the study.", 0, 1, period));
1151        children.add(new Property("study", "Reference(ResearchStudy)", "Reference to the study the subject is participating in.", 0, 1, study));
1152        children.add(new Property("individual", "Reference(Patient)", "The record of the person or animal who is involved in the study.", 0, 1, individual));
1153        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));
1154        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));
1155        children.add(new Property("consent", "Reference(Consent)", "A record of the patient's informed agreement to participate in the study.", 0, 1, consent));
1156      }
1157
1158      @Override
1159      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1160        switch (_hash) {
1161        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Identifiers assigned to this research subject for a study.", 0, java.lang.Integer.MAX_VALUE, identifier);
1162        case -892481550: /*status*/  return new Property("status", "code", "The current state of the subject.", 0, 1, status);
1163        case -1001078227: /*progress*/  return new Property("progress", "", "The current state (status) of the subject and resons for status change where appropriate.", 0, java.lang.Integer.MAX_VALUE, progress);
1164        case -991726143: /*period*/  return new Property("period", "Period", "The dates the subject began and ended their participation in the study.", 0, 1, period);
1165        case 109776329: /*study*/  return new Property("study", "Reference(ResearchStudy)", "Reference to the study the subject is participating in.", 0, 1, study);
1166        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);
1167        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);
1168        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);
1169        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);
1170        default: return super.getNamedProperty(_hash, _name, _checkValid);
1171        }
1172
1173      }
1174
1175      @Override
1176      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1177        switch (hash) {
1178        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1179        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<ResearchSubjectStatus>
1180        case -1001078227: /*progress*/ return this.progress == null ? new Base[0] : this.progress.toArray(new Base[this.progress.size()]); // ResearchSubjectProgressComponent
1181        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
1182        case 109776329: /*study*/ return this.study == null ? new Base[0] : new Base[] {this.study}; // Reference
1183        case -46292327: /*individual*/ return this.individual == null ? new Base[0] : new Base[] {this.individual}; // Reference
1184        case 1741912494: /*assignedArm*/ return this.assignedArm == null ? new Base[0] : new Base[] {this.assignedArm}; // StringType
1185        case 528827886: /*actualArm*/ return this.actualArm == null ? new Base[0] : new Base[] {this.actualArm}; // StringType
1186        case 951500826: /*consent*/ return this.consent == null ? new Base[0] : new Base[] {this.consent}; // Reference
1187        default: return super.getProperty(hash, name, checkValid);
1188        }
1189
1190      }
1191
1192      @Override
1193      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1194        switch (hash) {
1195        case -1618432855: // identifier
1196          this.getIdentifier().add(TypeConvertor.castToIdentifier(value)); // Identifier
1197          return value;
1198        case -892481550: // status
1199          value = new ResearchSubjectStatusEnumFactory().fromType(TypeConvertor.castToCode(value));
1200          this.status = (Enumeration) value; // Enumeration<ResearchSubjectStatus>
1201          return value;
1202        case -1001078227: // progress
1203          this.getProgress().add((ResearchSubjectProgressComponent) value); // ResearchSubjectProgressComponent
1204          return value;
1205        case -991726143: // period
1206          this.period = TypeConvertor.castToPeriod(value); // Period
1207          return value;
1208        case 109776329: // study
1209          this.study = TypeConvertor.castToReference(value); // Reference
1210          return value;
1211        case -46292327: // individual
1212          this.individual = TypeConvertor.castToReference(value); // Reference
1213          return value;
1214        case 1741912494: // assignedArm
1215          this.assignedArm = TypeConvertor.castToString(value); // StringType
1216          return value;
1217        case 528827886: // actualArm
1218          this.actualArm = TypeConvertor.castToString(value); // StringType
1219          return value;
1220        case 951500826: // consent
1221          this.consent = TypeConvertor.castToReference(value); // Reference
1222          return value;
1223        default: return super.setProperty(hash, name, value);
1224        }
1225
1226      }
1227
1228      @Override
1229      public Base setProperty(String name, Base value) throws FHIRException {
1230        if (name.equals("identifier")) {
1231          this.getIdentifier().add(TypeConvertor.castToIdentifier(value));
1232        } else if (name.equals("status")) {
1233          value = new ResearchSubjectStatusEnumFactory().fromType(TypeConvertor.castToCode(value));
1234          this.status = (Enumeration) value; // Enumeration<ResearchSubjectStatus>
1235        } else if (name.equals("progress")) {
1236          this.getProgress().add((ResearchSubjectProgressComponent) value);
1237        } else if (name.equals("period")) {
1238          this.period = TypeConvertor.castToPeriod(value); // Period
1239        } else if (name.equals("study")) {
1240          this.study = TypeConvertor.castToReference(value); // Reference
1241        } else if (name.equals("individual")) {
1242          this.individual = TypeConvertor.castToReference(value); // Reference
1243        } else if (name.equals("assignedArm")) {
1244          this.assignedArm = TypeConvertor.castToString(value); // StringType
1245        } else if (name.equals("actualArm")) {
1246          this.actualArm = TypeConvertor.castToString(value); // StringType
1247        } else if (name.equals("consent")) {
1248          this.consent = TypeConvertor.castToReference(value); // Reference
1249        } else
1250          return super.setProperty(name, value);
1251        return value;
1252      }
1253
1254      @Override
1255      public Base makeProperty(int hash, String name) throws FHIRException {
1256        switch (hash) {
1257        case -1618432855:  return addIdentifier(); 
1258        case -892481550:  return getStatusElement();
1259        case -1001078227:  return addProgress(); 
1260        case -991726143:  return getPeriod();
1261        case 109776329:  return getStudy();
1262        case -46292327:  return getIndividual();
1263        case 1741912494:  return getAssignedArmElement();
1264        case 528827886:  return getActualArmElement();
1265        case 951500826:  return getConsent();
1266        default: return super.makeProperty(hash, name);
1267        }
1268
1269      }
1270
1271      @Override
1272      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1273        switch (hash) {
1274        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
1275        case -892481550: /*status*/ return new String[] {"code"};
1276        case -1001078227: /*progress*/ return new String[] {};
1277        case -991726143: /*period*/ return new String[] {"Period"};
1278        case 109776329: /*study*/ return new String[] {"Reference"};
1279        case -46292327: /*individual*/ return new String[] {"Reference"};
1280        case 1741912494: /*assignedArm*/ return new String[] {"string"};
1281        case 528827886: /*actualArm*/ return new String[] {"string"};
1282        case 951500826: /*consent*/ return new String[] {"Reference"};
1283        default: return super.getTypesForProperty(hash, name);
1284        }
1285
1286      }
1287
1288      @Override
1289      public Base addChild(String name) throws FHIRException {
1290        if (name.equals("identifier")) {
1291          return addIdentifier();
1292        }
1293        else if (name.equals("status")) {
1294          throw new FHIRException("Cannot call addChild on a primitive type ResearchSubject.status");
1295        }
1296        else if (name.equals("progress")) {
1297          return addProgress();
1298        }
1299        else if (name.equals("period")) {
1300          this.period = new Period();
1301          return this.period;
1302        }
1303        else if (name.equals("study")) {
1304          this.study = new Reference();
1305          return this.study;
1306        }
1307        else if (name.equals("individual")) {
1308          this.individual = new Reference();
1309          return this.individual;
1310        }
1311        else if (name.equals("assignedArm")) {
1312          throw new FHIRException("Cannot call addChild on a primitive type ResearchSubject.assignedArm");
1313        }
1314        else if (name.equals("actualArm")) {
1315          throw new FHIRException("Cannot call addChild on a primitive type ResearchSubject.actualArm");
1316        }
1317        else if (name.equals("consent")) {
1318          this.consent = new Reference();
1319          return this.consent;
1320        }
1321        else
1322          return super.addChild(name);
1323      }
1324
1325  public String fhirType() {
1326    return "ResearchSubject";
1327
1328  }
1329
1330      public ResearchSubject copy() {
1331        ResearchSubject dst = new ResearchSubject();
1332        copyValues(dst);
1333        return dst;
1334      }
1335
1336      public void copyValues(ResearchSubject dst) {
1337        super.copyValues(dst);
1338        if (identifier != null) {
1339          dst.identifier = new ArrayList<Identifier>();
1340          for (Identifier i : identifier)
1341            dst.identifier.add(i.copy());
1342        };
1343        dst.status = status == null ? null : status.copy();
1344        if (progress != null) {
1345          dst.progress = new ArrayList<ResearchSubjectProgressComponent>();
1346          for (ResearchSubjectProgressComponent i : progress)
1347            dst.progress.add(i.copy());
1348        };
1349        dst.period = period == null ? null : period.copy();
1350        dst.study = study == null ? null : study.copy();
1351        dst.individual = individual == null ? null : individual.copy();
1352        dst.assignedArm = assignedArm == null ? null : assignedArm.copy();
1353        dst.actualArm = actualArm == null ? null : actualArm.copy();
1354        dst.consent = consent == null ? null : consent.copy();
1355      }
1356
1357      protected ResearchSubject typedCopy() {
1358        return copy();
1359      }
1360
1361      @Override
1362      public boolean equalsDeep(Base other_) {
1363        if (!super.equalsDeep(other_))
1364          return false;
1365        if (!(other_ instanceof ResearchSubject))
1366          return false;
1367        ResearchSubject o = (ResearchSubject) other_;
1368        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(progress, o.progress, true)
1369           && compareDeep(period, o.period, true) && compareDeep(study, o.study, true) && compareDeep(individual, o.individual, true)
1370           && compareDeep(assignedArm, o.assignedArm, true) && compareDeep(actualArm, o.actualArm, true) && compareDeep(consent, o.consent, true)
1371          ;
1372      }
1373
1374      @Override
1375      public boolean equalsShallow(Base other_) {
1376        if (!super.equalsShallow(other_))
1377          return false;
1378        if (!(other_ instanceof ResearchSubject))
1379          return false;
1380        ResearchSubject o = (ResearchSubject) other_;
1381        return compareValues(status, o.status, true) && compareValues(assignedArm, o.assignedArm, true) && compareValues(actualArm, o.actualArm, true)
1382          ;
1383      }
1384
1385      public boolean isEmpty() {
1386        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, progress
1387          , period, study, individual, assignedArm, actualArm, consent);
1388      }
1389
1390  @Override
1391  public ResourceType getResourceType() {
1392    return ResourceType.ResearchSubject;
1393   }
1394
1395 /**
1396   * Search parameter: <b>date</b>
1397   * <p>
1398   * Description: <b>Start and end of participation</b><br>
1399   * Type: <b>date</b><br>
1400   * Path: <b>ResearchSubject.period</b><br>
1401   * </p>
1402   */
1403  @SearchParamDefinition(name="date", path="ResearchSubject.period", description="Start and end of participation", type="date" )
1404  public static final String SP_DATE = "date";
1405 /**
1406   * <b>Fluent Client</b> search parameter constant for <b>date</b>
1407   * <p>
1408   * Description: <b>Start and end of participation</b><br>
1409   * Type: <b>date</b><br>
1410   * Path: <b>ResearchSubject.period</b><br>
1411   * </p>
1412   */
1413  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATE);
1414
1415 /**
1416   * Search parameter: <b>identifier</b>
1417   * <p>
1418   * Description: <b>Business Identifier for research subject in a study</b><br>
1419   * Type: <b>token</b><br>
1420   * Path: <b>ResearchSubject.identifier</b><br>
1421   * </p>
1422   */
1423  @SearchParamDefinition(name="identifier", path="ResearchSubject.identifier", description="Business Identifier for research subject in a study", type="token" )
1424  public static final String SP_IDENTIFIER = "identifier";
1425 /**
1426   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
1427   * <p>
1428   * Description: <b>Business Identifier for research subject in a study</b><br>
1429   * Type: <b>token</b><br>
1430   * Path: <b>ResearchSubject.identifier</b><br>
1431   * </p>
1432   */
1433  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
1434
1435 /**
1436   * Search parameter: <b>individual</b>
1437   * <p>
1438   * Description: <b>Who is part of study</b><br>
1439   * Type: <b>reference</b><br>
1440   * Path: <b>ResearchSubject.individual</b><br>
1441   * </p>
1442   */
1443  @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 } )
1444  public static final String SP_INDIVIDUAL = "individual";
1445 /**
1446   * <b>Fluent Client</b> search parameter constant for <b>individual</b>
1447   * <p>
1448   * Description: <b>Who is part of study</b><br>
1449   * Type: <b>reference</b><br>
1450   * Path: <b>ResearchSubject.individual</b><br>
1451   * </p>
1452   */
1453  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam INDIVIDUAL = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_INDIVIDUAL);
1454
1455/**
1456   * Constant for fluent queries to be used to add include statements. Specifies
1457   * the path value of "<b>ResearchSubject:individual</b>".
1458   */
1459  public static final ca.uhn.fhir.model.api.Include INCLUDE_INDIVIDUAL = new ca.uhn.fhir.model.api.Include("ResearchSubject:individual").toLocked();
1460
1461 /**
1462   * Search parameter: <b>patient</b>
1463   * <p>
1464   * Description: <b>Who is part of study</b><br>
1465   * Type: <b>reference</b><br>
1466   * Path: <b>ResearchSubject.individual</b><br>
1467   * </p>
1468   */
1469  @SearchParamDefinition(name="patient", path="ResearchSubject.individual", description="Who is part of study", type="reference", target={Patient.class } )
1470  public static final String SP_PATIENT = "patient";
1471 /**
1472   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
1473   * <p>
1474   * Description: <b>Who is part of study</b><br>
1475   * Type: <b>reference</b><br>
1476   * Path: <b>ResearchSubject.individual</b><br>
1477   * </p>
1478   */
1479  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
1480
1481/**
1482   * Constant for fluent queries to be used to add include statements. Specifies
1483   * the path value of "<b>ResearchSubject:patient</b>".
1484   */
1485  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("ResearchSubject:patient").toLocked();
1486
1487 /**
1488   * Search parameter: <b>state</b>
1489   * <p>
1490   * 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>
1491   * Type: <b>token</b><br>
1492   * Path: <b>ResearchSubject.progress.state</b><br>
1493   * </p>
1494   */
1495  @SearchParamDefinition(name="state", path="ResearchSubject.progress.state", 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" )
1496  public static final String SP_STATE = "state";
1497 /**
1498   * <b>Fluent Client</b> search parameter constant for <b>state</b>
1499   * <p>
1500   * 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>
1501   * Type: <b>token</b><br>
1502   * Path: <b>ResearchSubject.progress.state</b><br>
1503   * </p>
1504   */
1505  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATE);
1506
1507 /**
1508   * Search parameter: <b>status</b>
1509   * <p>
1510   * 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>
1511   * Type: <b>token</b><br>
1512   * Path: <b>ResearchSubject.status</b><br>
1513   * </p>
1514   */
1515  @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" )
1516  public static final String SP_STATUS = "status";
1517 /**
1518   * <b>Fluent Client</b> search parameter constant for <b>status</b>
1519   * <p>
1520   * 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>
1521   * Type: <b>token</b><br>
1522   * Path: <b>ResearchSubject.status</b><br>
1523   * </p>
1524   */
1525  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
1526
1527 /**
1528   * Search parameter: <b>study</b>
1529   * <p>
1530   * Description: <b>Study subject is part of</b><br>
1531   * Type: <b>reference</b><br>
1532   * Path: <b>ResearchSubject.study</b><br>
1533   * </p>
1534   */
1535  @SearchParamDefinition(name="study", path="ResearchSubject.study", description="Study subject is part of", type="reference", target={ResearchStudy.class } )
1536  public static final String SP_STUDY = "study";
1537 /**
1538   * <b>Fluent Client</b> search parameter constant for <b>study</b>
1539   * <p>
1540   * Description: <b>Study subject is part of</b><br>
1541   * Type: <b>reference</b><br>
1542   * Path: <b>ResearchSubject.study</b><br>
1543   * </p>
1544   */
1545  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam STUDY = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_STUDY);
1546
1547/**
1548   * Constant for fluent queries to be used to add include statements. Specifies
1549   * the path value of "<b>ResearchSubject:study</b>".
1550   */
1551  public static final ca.uhn.fhir.model.api.Include INCLUDE_STUDY = new ca.uhn.fhir.model.api.Include("ResearchSubject:study").toLocked();
1552
1553
1554}
1555