use of org.hl7.fhir.dstu2016may.model.IntegerType in project org.hl7.fhir.core by hapifhir.
the class OperationOutcomeUtilities method convertToIssue.
public static OperationOutcomeIssueComponent convertToIssue(ValidationMessage message, OperationOutcome op) {
OperationOutcomeIssueComponent issue = new OperationOutcome.OperationOutcomeIssueComponent();
issue.setUserData("source.vm", message);
issue.setCode(convert(message.getType()));
if (message.getLocation() != null) {
// message location has a fhirPath in it. We need to populate the expression
issue.addExpression(message.getLocation());
}
// pass through line/col if they're present
if (message.getLine() >= 0)
issue.addExtension().setUrl(ToolingExtensions.EXT_ISSUE_LINE).setValue(new IntegerType(message.getLine()));
if (message.getCol() >= 0)
issue.addExtension().setUrl(ToolingExtensions.EXT_ISSUE_COL).setValue(new IntegerType(message.getCol()));
issue.setSeverity(convert(message.getLevel()));
CodeableConcept c = new CodeableConcept();
c.setText(message.getMessage());
issue.setDetails(c);
if (message.getSource() != null) {
issue.getExtension().add(ToolingExtensions.makeIssueSource(message.getSource()));
}
issue.setUserData("source.msg", message);
return issue;
}
use of org.hl7.fhir.dstu2016may.model.IntegerType in project org.hl7.fhir.core by hapifhir.
the class ProfileUtilities method describeCardinality.
private String describeCardinality(ElementDefinition definition, ElementDefinition fallback, UnusedTracker tracker) {
IntegerType min = definition.hasMinElement() ? definition.getMinElement() : new IntegerType();
StringType max = definition.hasMaxElement() ? definition.getMaxElement() : new StringType();
if (min.isEmpty() && fallback != null)
min = fallback.getMinElement();
if (max.isEmpty() && fallback != null)
max = fallback.getMaxElement();
tracker.used = !max.isEmpty() && !max.getValue().equals("0");
if (min.isEmpty() && max.isEmpty())
return null;
else
return (!min.hasValue() ? "" : Integer.toString(min.getValue())) + ".." + (!max.hasValue() ? "" : max.getValue());
}
use of org.hl7.fhir.dstu2016may.model.IntegerType in project org.hl7.fhir.core by hapifhir.
the class FHIRPathEngine method opDiv.
private List<Base> opDiv(List<Base> left, List<Base> right, ExpressionNode expr) throws PathEngineException {
if (left.size() == 0 || right.size() == 0) {
return new ArrayList<Base>();
}
if (left.size() > 1) {
throw makeException(expr, I18nConstants.FHIRPATH_LEFT_VALUE_PLURAL, "div");
}
if (!left.get(0).isPrimitive() && !(left.get(0) instanceof Quantity)) {
throw makeException(expr, I18nConstants.FHIRPATH_LEFT_VALUE_WRONG_TYPE, "div", left.get(0).fhirType());
}
if (right.size() > 1) {
throw makeException(expr, I18nConstants.FHIRPATH_RIGHT_VALUE_PLURAL, "div");
}
if (!right.get(0).isPrimitive() && !(right.get(0) instanceof Quantity)) {
throw makeException(expr, I18nConstants.FHIRPATH_RIGHT_VALUE_WRONG_TYPE, "div", right.get(0).fhirType());
}
List<Base> result = new ArrayList<Base>();
Base l = left.get(0);
Base r = right.get(0);
if (l.hasType("integer") && r.hasType("integer")) {
int divisor = Integer.parseInt(r.primitiveValue());
if (divisor != 0) {
result.add(new IntegerType(Integer.parseInt(l.primitiveValue()) / divisor));
}
} else if (l.hasType("decimal", "integer") && r.hasType("decimal", "integer")) {
Decimal d1;
try {
d1 = new Decimal(l.primitiveValue());
Decimal d2 = new Decimal(r.primitiveValue());
result.add(new IntegerType(d1.divInt(d2).asDecimal()));
} catch (UcumException e) {
// just return nothing
}
} else {
throw makeException(expr, I18nConstants.FHIRPATH_OP_INCOMPATIBLE, "div", left.get(0).fhirType(), right.get(0).fhirType());
}
return result;
}
use of org.hl7.fhir.dstu2016may.model.IntegerType in project org.hl7.fhir.core by hapifhir.
the class FHIRPathEngine method funcToInteger.
private List<Base> funcToInteger(ExecutionContext context, List<Base> focus, ExpressionNode exp) {
String s = convertToString(focus);
List<Base> result = new ArrayList<Base>();
if (Utilities.isInteger(s)) {
result.add(new IntegerType(s).noExtensions());
} else if ("true".equals(s)) {
result.add(new IntegerType(1).noExtensions());
} else if ("false".equals(s)) {
result.add(new IntegerType(0).noExtensions());
}
return result;
}
use of org.hl7.fhir.dstu2016may.model.IntegerType in project org.hl7.fhir.core by hapifhir.
the class FHIRPathEngine method funcIndexOf.
private List<Base> funcIndexOf(ExecutionContext context, List<Base> focus, ExpressionNode exp) throws FHIRException {
List<Base> result = new ArrayList<Base>();
String sw = convertToString(execute(context, focus, exp.getParameters().get(0), true));
if (focus.size() == 0) {
result.add(new IntegerType(0).noExtensions());
} else if (Utilities.noString(sw)) {
result.add(new IntegerType(0).noExtensions());
} else {
String s = convertToString(focus.get(0));
if (s == null) {
result.add(new IntegerType(0).noExtensions());
} else {
result.add(new IntegerType(s.indexOf(sw)).noExtensions());
}
}
return result;
}
Aggregations