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 RdfParser method composeInteger.
protected void composeInteger(Complex parent, String parentType, String name, IntegerType value, int index) {
if (value == null)
return;
Complex t = parent.predicate("fhir:" + parentType + "." + name);
t.predicate("fhir:value", ttlLiteral(value.asStringValue()));
composeElement(t, parentType, name, value, index);
}
use of org.hl7.fhir.dstu2016may.model.IntegerType in project org.hl7.fhir.core by hapifhir.
the class ProfileUtilities method genCardinality.
private void genCardinality(HierarchicalTableGenerator gen, ElementDefinition definition, Row row, boolean hasDef, UnusedTracker tracker, ElementDefinition fallback) {
IntegerType min = !hasDef ? new IntegerType() : definition.hasMinElement() ? definition.getMinElement() : new IntegerType();
StringType max = !hasDef ? new StringType() : definition.hasMaxElement() ? definition.getMaxElement() : new StringType();
if (min.isEmpty() && definition.getUserData(DERIVATION_POINTER) != null) {
ElementDefinition base = (ElementDefinition) definition.getUserData(DERIVATION_POINTER);
min = base.getMinElement().copy();
min.setUserData(DERIVATION_EQUALS, true);
}
if (max.isEmpty() && definition.getUserData(DERIVATION_POINTER) != null) {
ElementDefinition base = (ElementDefinition) definition.getUserData(DERIVATION_POINTER);
max = base.getMaxElement().copy();
max.setUserData(DERIVATION_EQUALS, true);
}
if (min.isEmpty() && fallback != null)
min = fallback.getMinElement();
if (max.isEmpty() && fallback != null)
max = fallback.getMaxElement();
if (!max.isEmpty())
tracker.used = !max.getValue().equals("0");
Cell cell = gen.new Cell(null, null, null, null, null);
row.getCells().add(cell);
if (!min.isEmpty() || !max.isEmpty()) {
cell.addPiece(checkForNoChange(min, gen.new Piece(null, !min.hasValue() ? "" : Integer.toString(min.getValue()), null)));
cell.addPiece(checkForNoChange(min, max, gen.new Piece(null, "..", null)));
cell.addPiece(checkForNoChange(min, gen.new Piece(null, !max.hasValue() ? "" : max.getValue(), null)));
}
}
use of org.hl7.fhir.dstu2016may.model.IntegerType in project org.hl7.fhir.core by hapifhir.
the class QuestionnaireBuilder method convertType.
@SuppressWarnings("unchecked")
private Type convertType(Base value, QuestionnaireItemType af, ValueSet vs, String path) throws FHIRException {
switch(af) {
// simple cases
case BOOLEAN:
if (value instanceof BooleanType)
return (Type) value;
case DECIMAL:
if (value instanceof DecimalType)
return (Type) value;
case INTEGER:
if (value instanceof IntegerType)
return (Type) value;
case DATE:
if (value instanceof DateType)
return (Type) value;
case DATETIME:
if (value instanceof DateTimeType)
return (Type) value;
case INSTANT:
if (value instanceof InstantType)
return (Type) value;
case TIME:
if (value instanceof TimeType)
return (Type) value;
case STRING:
if (value instanceof StringType)
return (Type) value;
else if (value instanceof UriType)
return new StringType(((UriType) value).asStringValue());
case TEXT:
if (value instanceof StringType)
return (Type) value;
case QUANTITY:
if (value instanceof Quantity)
return (Type) value;
// ? QuestionnaireItemTypeAttachment: ...?
case CHOICE:
case OPENCHOICE:
if (value instanceof Coding)
return (Type) 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;
}
case REFERENCE:
if (value instanceof Reference)
return (Type) value;
else if (value instanceof StringType) {
Reference r = new Reference();
r.setReference(((StringType) value).asStringValue());
}
}
throw new FHIRException("Unable to convert from '" + value.getClass().toString() + "' for Answer Format " + af.toCode() + ", path = " + path);
}
use of org.hl7.fhir.dstu2016may.model.IntegerType in project org.hl7.fhir.core by hapifhir.
the class QuestionnaireBuilder method convertType.
@SuppressWarnings("unchecked")
private Type convertType(Base value, QuestionnaireItemType af, ValueSet vs, String path) throws FHIRException {
switch(af) {
// simple cases
case BOOLEAN:
if (value instanceof BooleanType)
return (Type) value;
case DECIMAL:
if (value instanceof DecimalType)
return (Type) value;
case INTEGER:
if (value instanceof IntegerType)
return (Type) value;
case DATE:
if (value instanceof DateType)
return (Type) value;
case DATETIME:
if (value instanceof DateTimeType)
return (Type) value;
case TIME:
if (value instanceof TimeType)
return (Type) value;
case STRING:
if (value instanceof StringType)
return (Type) value;
else if (value instanceof UriType)
return new StringType(((UriType) value).asStringValue());
case TEXT:
if (value instanceof StringType)
return (Type) value;
case QUANTITY:
if (value instanceof Quantity)
return (Type) value;
// ? QuestionnaireItemTypeAttachment: ...?
case CHOICE:
case OPENCHOICE:
if (value instanceof Coding)
return (Type) 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;
}
case REFERENCE:
if (value instanceof Reference)
return (Type) value;
else if (value instanceof StringType) {
Reference r = new Reference();
r.setReference(((StringType) value).asStringValue());
}
}
throw new FHIRException("Unable to convert from '" + value.getClass().toString() + "' for Answer Format " + af.toCode() + ", path = " + path);
}
Aggregations