use of org.hl7.fhir.dstu2016may.model.DateType in project org.hl7.fhir.core by hapifhir.
the class PatientRenderer method describe.
public void describe(XhtmlNode x, ResourceWrapper pat) throws UnsupportedEncodingException, IOException {
Identifier id = null;
PropertyWrapper pw = getProperty(pat, "identifier");
for (BaseWrapper t : pw.getValues()) {
id = chooseId(id, (Identifier) t.getBase());
}
pw = getProperty(pat, "name");
HumanName n = null;
for (BaseWrapper t : pw.getValues()) {
n = chooseName(n, (HumanName) t.getBase());
}
String gender = null;
pw = getProperty(pat, "gender");
if (valued(pw)) {
pw.value().getBase().primitiveValue();
}
DateType dt = null;
pw = getProperty(pat, "birthDate");
if (valued(pw)) {
dt = (DateType) pw.value().getBase();
}
describe(x, n, gender, dt, id);
}
use of org.hl7.fhir.dstu2016may.model.DateType in project org.hl7.fhir.core by hapifhir.
the class QuestionnaireBuilder method convertType.
@SuppressWarnings("unchecked")
private DataType convertType(Base value, QuestionnaireItemType af, ValueSet vs, String path) throws FHIRException {
switch(af) {
// simple cases
case BOOLEAN:
if (value instanceof BooleanType)
return (DataType) value;
break;
case DECIMAL:
if (value instanceof DecimalType)
return (DataType) value;
break;
case INTEGER:
if (value instanceof IntegerType)
return (DataType) value;
break;
case DATE:
if (value instanceof DateType)
return (DataType) value;
break;
case DATETIME:
if (value instanceof DateTimeType)
return (DataType) value;
break;
case TIME:
if (value instanceof TimeType)
return (DataType) value;
break;
case STRING:
if (value instanceof StringType)
return (DataType) value;
else if (value instanceof UriType)
return new StringType(((UriType) value).asStringValue());
break;
case TEXT:
if (value instanceof StringType)
return (DataType) value;
break;
case QUANTITY:
if (value instanceof Quantity)
return (DataType) value;
break;
// ? QuestionnaireItemTypeAttachment: ...?
case CODING:
if (value instanceof Coding)
return (DataType) value;
else if (value instanceof Enumeration) {
Coding cc = new Coding();
cc.setCode(((Enumeration<Enum<?>>) value).asStringValue());
cc.setSystem(getSystemForCode(vs, cc.getCode(), path));
return cc;
} else if (value instanceof StringType) {
Coding cc = new Coding();
cc.setCode(((StringType) value).asStringValue());
cc.setSystem(getSystemForCode(vs, cc.getCode(), path));
return cc;
}
break;
case REFERENCE:
if (value instanceof Reference)
return (DataType) value;
else if (value instanceof StringType) {
Reference r = new Reference();
r.setReference(((StringType) value).asStringValue());
}
break;
default:
break;
}
throw new FHIRException("Unable to convert from '" + value.getClass().toString() + "' for Answer Format " + af.toCode() + ", path = " + path);
}
use of org.hl7.fhir.dstu2016may.model.DateType in project org.hl7.fhir.core by hapifhir.
the class FHIRPathEngine method funcToday.
private List<Base> funcToday(ExecutionContext context, List<Base> focus, ExpressionNode exp) {
List<Base> result = new ArrayList<Base>();
result.add(new DateType(new Date(), TemporalPrecisionEnum.DAY));
return result;
}
use of org.hl7.fhir.dstu2016may.model.DateType in project org.hl7.fhir.core by hapifhir.
the class FHIRPathEngine method processDateConstant.
private Base processDateConstant(Object appInfo, String value, ExpressionNode expr) throws PathEngineException {
String date = null;
String time = null;
String tz = null;
TemporalPrecisionEnum temp = null;
if (value.startsWith("T")) {
time = value.substring(1);
} else if (!value.contains("T")) {
date = value;
} else {
String[] p = value.split("T");
date = p[0];
if (p.length > 1) {
time = p[1];
}
}
if (time != null) {
int i = time.indexOf("-");
if (i == -1) {
i = time.indexOf("+");
}
if (i == -1) {
i = time.indexOf("Z");
}
if (i > -1) {
tz = time.substring(i);
time = time.substring(0, i);
}
if (time.length() == 2) {
time = time + ":00:00";
temp = TemporalPrecisionEnum.MINUTE;
} else if (time.length() == 5) {
temp = TemporalPrecisionEnum.MINUTE;
time = time + ":00";
} else if (time.contains(".")) {
temp = TemporalPrecisionEnum.MILLI;
} else {
temp = TemporalPrecisionEnum.SECOND;
}
}
if (date == null) {
if (tz != null) {
throw makeException(expr, I18nConstants.FHIRPATH_UNKNOWN_CONTEXT, value);
} else {
TimeType tt = new TimeType(time);
tt.setPrecision(temp);
return tt.noExtensions();
}
} else if (time != null) {
DateTimeType dt = new DateTimeType(date + "T" + time + (tz == null ? "" : tz));
dt.setPrecision(temp);
return dt.noExtensions();
} else {
return new DateType(date).noExtensions();
}
}
use of org.hl7.fhir.dstu2016may.model.DateType in project org.hl7.fhir.core by hapifhir.
the class DateTypeNullTest method copy.
@Test
@DisplayName("Test null value copy()")
void copy() {
DateType nullDate = new DateType();
DateType copyDate = nullDate.copy();
Assertions.assertNull(copyDate.getValue());
}
Aggregations