View Javadoc
1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  
17  package ca.uhn.fhir.model.dstu.composite;
18  
19  /*
20   * #%L
21   * HAPI FHIR - Core Library
22   * %%
23   * Copyright (C) 2014 University Health Network
24   * %%
25   * Licensed under the Apache License, Version 2.0 (the "License");
26   * you may not use this file except in compliance with the License.
27   * You may obtain a copy of the License at
28   * 
29   *      http://www.apache.org/licenses/LICENSE-2.0
30   * 
31   * Unless required by applicable law or agreed to in writing, software
32   * distributed under the License is distributed on an "AS IS" BASIS,
33   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34   * See the License for the specific language governing permissions and
35   * limitations under the License.
36   * #L%
37   */
38  
39  import java.util.Date;
40  import java.util.List;
41  
42  import ca.uhn.fhir.model.api.BaseIdentifiableElement;
43  import ca.uhn.fhir.model.api.ICompositeDatatype;
44  import ca.uhn.fhir.model.api.IElement;
45  import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
46  import ca.uhn.fhir.model.api.annotation.Child;
47  import ca.uhn.fhir.model.api.annotation.DatatypeDef;
48  import ca.uhn.fhir.model.api.annotation.Description;
49  import ca.uhn.fhir.model.primitive.DateTimeDt;
50  
51  /**
52   * HAPI/FHIR <b>PeriodDt</b> Datatype
53   * (Time range defined by start and end date/time)
54   *
55   * <p>
56   * <b>Definition:</b>
57   * A time period defined by a start and end date and optionally time.
58   * </p> 
59   *
60   * <p>
61   * <b>Requirements:</b>
62   * 
63   * </p> 
64   */
65  @DatatypeDef(name="PeriodDt") 
66  public class PeriodDt
67          extends  BaseIdentifiableElement         implements ICompositeDatatype
68  {
69  
70  	/**
71  	 * Constructor
72  	 */
73  	public PeriodDt() {
74  		// nothing
75  	}
76  
77  
78  	@Child(name="start", type=DateTimeDt.class, order=0, min=0, max=1)	
79  	@Description(
80  		shortDefinition="Starting time with inclusive boundary",
81  		formalDefinition="The start of the period. The boundary is inclusive."
82  	)
83  	private DateTimeDt myStart;
84  	
85  	@Child(name="end", type=DateTimeDt.class, order=1, min=0, max=1)	
86  	@Description(
87  		shortDefinition="End time with inclusive boundary, if not ongoing",
88  		formalDefinition="The end of the period. If the end of the period is missing, it means that the period is ongoing"
89  	)
90  	private DateTimeDt myEnd;
91  	
92  
93  	@Override
94  	public boolean isEmpty() {
95  		return super.isBaseEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(  myStart,  myEnd);
96  	}
97  	
98  	@Override
99  	public <T extends IElement> List<T> getAllPopulatedChildElementsOfType(Class<T> theType) {
100 		return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(theType, myStart, myEnd);
101 	}
102 
103 	/**
104 	 * Gets the value(s) for <b>start</b> (Starting time with inclusive boundary).
105 	 * creating it if it does
106 	 * not exist. Will not return <code>null</code>.
107 	 *
108      * <p>
109      * <b>Definition:</b>
110      * The start of the period. The boundary is inclusive.
111      * </p> 
112 	 */
113 	public DateTimeDt getStart() {  
114 		if (myStart == null) {
115 			myStart = new DateTimeDt();
116 		}
117 		return myStart;
118 	}
119 
120 	/**
121 	 * Sets the value(s) for <b>start</b> (Starting time with inclusive boundary)
122 	 *
123      * <p>
124      * <b>Definition:</b>
125      * The start of the period. The boundary is inclusive.
126      * </p> 
127 	 */
128 	public PeriodDt setStart(DateTimeDt theValue) {
129 		myStart = theValue;
130 		return this;
131 	}
132 
133  	/**
134 	 * Sets the value for <b>start</b> (Starting time with inclusive boundary)
135 	 *
136      * <p>
137      * <b>Definition:</b>
138      * The start of the period. The boundary is inclusive.
139      * </p> 
140 	 */
141 	public PeriodDt setStartWithSecondsPrecision( Date theDate) {
142 		myStart = new DateTimeDt(theDate); 
143 		return this; 
144 	}
145 
146 	/**
147 	 * Sets the value for <b>start</b> (Starting time with inclusive boundary)
148 	 *
149      * <p>
150      * <b>Definition:</b>
151      * The start of the period. The boundary is inclusive.
152      * </p> 
153 	 */
154 	public PeriodDt setStart( Date theDate,  TemporalPrecisionEnum thePrecision) {
155 		myStart = new DateTimeDt(theDate, thePrecision); 
156 		return this; 
157 	}
158 
159  
160 	/**
161 	 * Gets the value(s) for <b>end</b> (End time with inclusive boundary, if not ongoing).
162 	 * creating it if it does
163 	 * not exist. Will not return <code>null</code>.
164 	 *
165      * <p>
166      * <b>Definition:</b>
167      * The end of the period. If the end of the period is missing, it means that the period is ongoing
168      * </p> 
169 	 */
170 	public DateTimeDt getEnd() {  
171 		if (myEnd == null) {
172 			myEnd = new DateTimeDt();
173 		}
174 		return myEnd;
175 	}
176 
177 	/**
178 	 * Sets the value(s) for <b>end</b> (End time with inclusive boundary, if not ongoing)
179 	 *
180      * <p>
181      * <b>Definition:</b>
182      * The end of the period. If the end of the period is missing, it means that the period is ongoing
183      * </p> 
184 	 */
185 	public PeriodDt setEnd(DateTimeDt theValue) {
186 		myEnd = theValue;
187 		return this;
188 	}
189 
190  	/**
191 	 * Sets the value for <b>end</b> (End time with inclusive boundary, if not ongoing)
192 	 *
193      * <p>
194      * <b>Definition:</b>
195      * The end of the period. If the end of the period is missing, it means that the period is ongoing
196      * </p> 
197 	 */
198 	public PeriodDt setEndWithSecondsPrecision( Date theDate) {
199 		myEnd = new DateTimeDt(theDate); 
200 		return this; 
201 	}
202 
203 	/**
204 	 * Sets the value for <b>end</b> (End time with inclusive boundary, if not ongoing)
205 	 *
206      * <p>
207      * <b>Definition:</b>
208      * The end of the period. If the end of the period is missing, it means that the period is ongoing
209      * </p> 
210 	 */
211 	public PeriodDt setEnd( Date theDate,  TemporalPrecisionEnum thePrecision) {
212 		myEnd = new DateTimeDt(theDate, thePrecision); 
213 		return this; 
214 	}
215 
216  
217 
218 
219 }