date adaption for dateOp #1655

This commit is contained in:
oliveregger 2024-06-25 20:46:07 +02:00
parent a63792d2b2
commit b70062f326
1 changed files with 10 additions and 4 deletions

View File

@ -2735,7 +2735,7 @@ public class FHIRPathEngine {
if (right.size() > 1) {
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") || left.get(0).hasType("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());
}
@ -2748,7 +2748,10 @@ public class FHIRPathEngine {
result.add(new IntegerType(Integer.parseInt(l.primitiveValue()) + Integer.parseInt(r.primitiveValue())));
} else if (l.hasType("decimal", "integer") && r.hasType("decimal", "integer")) {
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.hasType("date") && r.hasType("Quantity")) {
DateType dl = l instanceof DateType ? (DateType) l : new DateType(l.primitiveValue());
result.add(dateAdd(dl, (Quantity) r, false, expr));
} else if ((l.isDateTime() || l.hasType("dateTime")) && r.hasType("Quantity")) {
DateTimeType dl = l instanceof DateTimeType ? (DateTimeType) l : new DateTimeType(l.primitiveValue());
result.add(dateAdd(dl, (Quantity) r, false, expr));
} else {
@ -2995,7 +2998,7 @@ public class FHIRPathEngine {
if (right.size() > 1) {
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") || left.get(0).hasType("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());
}
@ -3013,7 +3016,10 @@ public class FHIRPathEngine {
Quantity qty = (Quantity) r;
result.add(qty.copy().setValue(qty.getValue().abs()));
}
} else if ((l.isDateTime() || l.hasType("Date")) && r.hasType("Quantity")) {
} else if (l.hasType("date") && r.hasType("Quantity")) {
DateType dl = l instanceof DateType ? (DateType) l : new DateType(l.primitiveValue());
result.add(dateAdd(dl, (Quantity) r, true, expr));
} else if ((l.isDateTime() || l.hasType("dateTime")) && r.hasType("Quantity")) {
DateTimeType dl = l instanceof DateTimeType ? (DateTimeType) l : new DateTimeType(l.primitiveValue());
result.add(dateAdd(dl, (Quantity) r, true, expr));
} else {