Add a new date/time setter and update documentation
This commit is contained in:
parent
9d4a56bf47
commit
74b15e2295
|
@ -138,14 +138,22 @@ public abstract class BaseDateTimeDt extends BasePrimitive<Date> {
|
|||
|
||||
|
||||
/**
|
||||
* Gets the precision for this datatype using field values from {@link Calendar}, such as {@link Calendar#MONTH}. Default is {@link Calendar#DAY_OF_MONTH}
|
||||
* Gets the precision for this datatype (using the default for the given type if not set)
|
||||
*
|
||||
* @see #setPrecision(int)
|
||||
* @see #setPrecision(TemporalPrecisionEnum)
|
||||
*/
|
||||
public TemporalPrecisionEnum getPrecision() {
|
||||
if (myPrecision == null) {
|
||||
return getDefaultPrecisionForDatatype();
|
||||
}
|
||||
return myPrecision;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default precision for the given datatype
|
||||
*/
|
||||
protected abstract TemporalPrecisionEnum getDefaultPrecisionForDatatype();
|
||||
|
||||
/**
|
||||
* Returns the TimeZone associated with this dateTime's value. May return
|
||||
* <code>null</code> if no timezone was supplied.
|
||||
|
@ -337,11 +345,24 @@ public abstract class BaseDateTimeDt extends BasePrimitive<Date> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Date theValue) throws DataFormatException {
|
||||
public void setValue(Date theValue) {
|
||||
clearTimeZone();
|
||||
super.setValue(theValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of this date/time using the specified level of precision
|
||||
*
|
||||
* @param theValue The date value
|
||||
* @param thePrecision The precision
|
||||
* @throws DataFormatException
|
||||
*/
|
||||
public void setValue(Date theValue, TemporalPrecisionEnum thePrecision) throws DataFormatException {
|
||||
clearTimeZone();
|
||||
super.setValue(theValue);
|
||||
myPrecision = thePrecision;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueAsString(String theValue) throws DataFormatException {
|
||||
clearTimeZone();
|
||||
|
|
|
@ -76,4 +76,14 @@ public class DateDt extends BaseDateTimeDt {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default precision for this datatype
|
||||
*
|
||||
* @see #DEFAULT_PRECISION
|
||||
*/
|
||||
@Override
|
||||
protected TemporalPrecisionEnum getDefaultPrecisionForDatatype() {
|
||||
return DEFAULT_PRECISION;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -98,4 +98,15 @@ public class DateTimeDt extends BaseDateTimeDt {
|
|||
return new DateTimeDt(new Date(), TemporalPrecisionEnum.SECOND);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default precision for this datatype
|
||||
*
|
||||
* @see #DEFAULT_PRECISION
|
||||
*/
|
||||
@Override
|
||||
protected TemporalPrecisionEnum getDefaultPrecisionForDatatype() {
|
||||
return DEFAULT_PRECISION;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -160,4 +160,15 @@ public class InstantDt extends BaseDateTimeDt {
|
|||
return new InstantDt(new Date(), TemporalPrecisionEnum.MILLI);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default precision for this datatype
|
||||
*
|
||||
* @see #DEFAULT_PRECISION
|
||||
*/
|
||||
@Override
|
||||
protected TemporalPrecisionEnum getDefaultPrecisionForDatatype() {
|
||||
return DEFAULT_PRECISION;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -303,6 +303,17 @@
|
|||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${baseDir}/src/main/resources</directory>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>${baseDir}/target/generated-sources/tinder</directory>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>${baseDir}/target/generated-resources/tinder</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -29,6 +29,7 @@ import ca.uhn.fhir.model.api.Bundle;
|
|||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.dstu.composite.HumanNameDt;
|
||||
import ca.uhn.fhir.model.dstu.composite.IdentifierDt;
|
||||
import ca.uhn.fhir.model.dstu.resource.Organization;
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu.valueset.IdentifierUseEnum;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
|
@ -236,11 +237,13 @@ public class ServerFeaturesTest {
|
|||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
|
||||
Bundle bundle = servlet.getFhirContext().newXmlParser().parseBundle(responseContent);
|
||||
assertEquals(1,bundle.size());
|
||||
assertEquals(2,bundle.size());
|
||||
|
||||
assertEquals("http://absolute.com/Patient/123", bundle.getEntries().get(0).getId().getValue());
|
||||
assertEquals("http://absolute.com/Patient/123/_history/22", bundle.getEntries().get(0).getLinkSelf().getValue());
|
||||
|
||||
assertEquals("http://foo.com/Organization/222",bundle.getEntries().get(1).getId().getValue());
|
||||
assertEquals("http://foo.com/Organization/222/_history/333",bundle.getEntries().get(1).getLinkSelf().getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -370,6 +373,11 @@ public class ServerFeaturesTest {
|
|||
Patient p = new Patient();
|
||||
p.addIdentifier().setSystem("foo");
|
||||
p.setId("http://absolute.com/Patient/123/_history/22");
|
||||
|
||||
Organization o = new Organization();
|
||||
o.setId("http://foo.com/Organization/222/_history/333");
|
||||
p.getManagingOrganization().setResource(o);
|
||||
|
||||
return Collections.singletonList(p);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
package ca.uhn.fhir.example;
|
||||
|
||||
public class Example01 {
|
||||
|
||||
public static void main(String[] theArgs) {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package ca.uhn.fhir.example;
|
||||
|
||||
import ca.uhn.fhir.model.dstu.composite.HumanNameDt;
|
||||
import ca.uhn.fhir.model.dstu.composite.IdentifierDt;
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class Example01_CreateAPatient {
|
||||
|
||||
public static void main(String[] theArgs) {
|
||||
|
||||
Patient pat = new Patient();
|
||||
|
||||
IdentifierDt identifier = pat.addIdentifier();
|
||||
identifier.setSystem("http://acme.org/MRNs").setValue("7000135");
|
||||
|
||||
HumanNameDt name = pat.addName();
|
||||
name.addFamily("Simpson").addGiven("Homer").addGiven("J");
|
||||
|
||||
pat.getBirthDate().set
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue