fix for dateOp
This commit is contained in:
parent
3b02eaedec
commit
9d0d095aa3
|
@ -2735,7 +2735,7 @@ public class FHIRPathEngine {
|
||||||
if (right.size() > 1) {
|
if (right.size() > 1) {
|
||||||
throw makeExceptionPlural(right.size(), expr, I18nConstants.FHIRPATH_RIGHT_VALUE, "+");
|
throw makeExceptionPlural(right.size(), expr, I18nConstants.FHIRPATH_RIGHT_VALUE, "+");
|
||||||
}
|
}
|
||||||
if (!right.get(0).isPrimitive() && !((left.get(0).isDateTime() || left.get(0).hasType("Date") || "0".equals(left.get(0).primitiveValue()) || left.get(0).hasType("Quantity")) && right.get(0).hasType("Quantity"))) {
|
if (!right.get(0).isPrimitive() && !((left.get(0).isDateTime() || left.get(0).hasType("date", "dateTime", "instant") || "0".equals(left.get(0).primitiveValue()) || left.get(0).hasType("Quantity")) && right.get(0).hasType("Quantity"))) {
|
||||||
throw makeException(expr, I18nConstants.FHIRPATH_RIGHT_VALUE_WRONG_TYPE, "+", right.get(0).fhirType());
|
throw makeException(expr, I18nConstants.FHIRPATH_RIGHT_VALUE_WRONG_TYPE, "+", right.get(0).fhirType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2748,8 +2748,8 @@ public class FHIRPathEngine {
|
||||||
result.add(new IntegerType(Integer.parseInt(l.primitiveValue()) + Integer.parseInt(r.primitiveValue())));
|
result.add(new IntegerType(Integer.parseInt(l.primitiveValue()) + Integer.parseInt(r.primitiveValue())));
|
||||||
} else if (l.hasType("decimal", "integer") && r.hasType("decimal", "integer")) {
|
} else if (l.hasType("decimal", "integer") && r.hasType("decimal", "integer")) {
|
||||||
result.add(new DecimalType(new BigDecimal(l.primitiveValue()).add(new BigDecimal(r.primitiveValue()))));
|
result.add(new DecimalType(new BigDecimal(l.primitiveValue()).add(new BigDecimal(r.primitiveValue()))));
|
||||||
} else if ((l.isDateTime() || l.hasType("Date")) && r.hasType("Quantity")) {
|
} else if ((l.isDateTime() || l.hasType("date")) && r.hasType("Quantity")) {
|
||||||
if (l.hasType("Date")) {
|
if (l.hasType("date")) {
|
||||||
BaseDateTimeType dt = l instanceof BaseDateTimeType ? (BaseDateTimeType) l : TypeConvertor.castToDateTime(l);
|
BaseDateTimeType dt = l instanceof BaseDateTimeType ? (BaseDateTimeType) l : TypeConvertor.castToDateTime(l);
|
||||||
Quantity qty = r instanceof Quantity ? (Quantity) r : TypeConvertor.castToQuantity(r);
|
Quantity qty = r instanceof Quantity ? (Quantity) r : TypeConvertor.castToQuantity(r);
|
||||||
result.add(dateAdd(dt, qty, false, expr));
|
result.add(dateAdd(dt, qty, false, expr));
|
||||||
|
@ -3001,7 +3001,7 @@ public class FHIRPathEngine {
|
||||||
if (right.size() > 1) {
|
if (right.size() > 1) {
|
||||||
throw makeExceptionPlural(right.size(), expr, I18nConstants.FHIRPATH_RIGHT_VALUE, "-");
|
throw makeExceptionPlural(right.size(), expr, I18nConstants.FHIRPATH_RIGHT_VALUE, "-");
|
||||||
}
|
}
|
||||||
if (!right.get(0).isPrimitive() && !((left.get(0).isDateTime() || left.get(0).hasType("Date") || "0".equals(left.get(0).primitiveValue()) || left.get(0).hasType("Quantity")) && right.get(0).hasType("Quantity"))) {
|
if (!right.get(0).isPrimitive() && !((left.get(0).isDateTime() || left.get(0).hasType("date", "dateTime") || "0".equals(left.get(0).primitiveValue()) || left.get(0).hasType("Quantity")) && right.get(0).hasType("Quantity"))) {
|
||||||
throw makeException(expr, I18nConstants.FHIRPATH_RIGHT_VALUE_WRONG_TYPE, "-", right.get(0).fhirType());
|
throw makeException(expr, I18nConstants.FHIRPATH_RIGHT_VALUE_WRONG_TYPE, "-", right.get(0).fhirType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3019,8 +3019,8 @@ public class FHIRPathEngine {
|
||||||
Quantity qty = (Quantity) r;
|
Quantity qty = (Quantity) r;
|
||||||
result.add(qty.copy().setValue(qty.getValue().abs()));
|
result.add(qty.copy().setValue(qty.getValue().abs()));
|
||||||
}
|
}
|
||||||
} else if ((l.isDateTime() || l.hasType("Date")) && r.hasType("Quantity")) {
|
} else if ((l.isDateTime() || l.hasType("date", "dateTime", "instant")) && r.hasType("Quantity")) {
|
||||||
if (l.hasType("Date")) {
|
if (l.hasType("date")) {
|
||||||
BaseDateTimeType dt = l instanceof BaseDateTimeType ? (BaseDateTimeType) l : TypeConvertor.castToDateTime(l);
|
BaseDateTimeType dt = l instanceof BaseDateTimeType ? (BaseDateTimeType) l : TypeConvertor.castToDateTime(l);
|
||||||
Quantity qty = r instanceof Quantity ? (Quantity) r : TypeConvertor.castToQuantity(r);
|
Quantity qty = r instanceof Quantity ? (Quantity) r : TypeConvertor.castToQuantity(r);
|
||||||
result.add(dateAdd(dt, qty, true, expr));
|
result.add(dateAdd(dt, qty, true, expr));
|
||||||
|
|
Loading…
Reference in New Issue