Search in sources :

Example 21 with IntegerType

use of org.hl7.fhir.r4b.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());
}
Also used : IntegerType(org.hl7.fhir.dstu2.model.IntegerType) StringType(org.hl7.fhir.dstu2.model.StringType)

Example 22 with IntegerType

use of org.hl7.fhir.r4b.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);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 23 with IntegerType

use of org.hl7.fhir.r4b.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)));
    }
}
Also used : IntegerType(org.hl7.fhir.dstu2016may.model.IntegerType) StringType(org.hl7.fhir.dstu2016may.model.StringType) Piece(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece) ElementDefinition(org.hl7.fhir.dstu2016may.model.ElementDefinition) Cell(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)

Example 24 with IntegerType

use of org.hl7.fhir.r4b.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);
}
Also used : Enumeration(org.hl7.fhir.dstu2016may.model.Enumeration) StringType(org.hl7.fhir.dstu2016may.model.StringType) Reference(org.hl7.fhir.dstu2016may.model.Reference) BooleanType(org.hl7.fhir.dstu2016may.model.BooleanType) Quantity(org.hl7.fhir.dstu2016may.model.Quantity) FHIRException(org.hl7.fhir.exceptions.FHIRException) DateTimeType(org.hl7.fhir.dstu2016may.model.DateTimeType) TimeType(org.hl7.fhir.dstu2016may.model.TimeType) UriType(org.hl7.fhir.dstu2016may.model.UriType) IntegerType(org.hl7.fhir.dstu2016may.model.IntegerType) DateTimeType(org.hl7.fhir.dstu2016may.model.DateTimeType) Coding(org.hl7.fhir.dstu2016may.model.Coding) DecimalType(org.hl7.fhir.dstu2016may.model.DecimalType) InstantType(org.hl7.fhir.dstu2016may.model.InstantType) DateType(org.hl7.fhir.dstu2016may.model.DateType)

Example 25 with IntegerType

use of org.hl7.fhir.r4b.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);
}
Also used : Enumeration(org.hl7.fhir.dstu3.model.Enumeration) StringType(org.hl7.fhir.dstu3.model.StringType) Reference(org.hl7.fhir.dstu3.model.Reference) BooleanType(org.hl7.fhir.dstu3.model.BooleanType) Quantity(org.hl7.fhir.dstu3.model.Quantity) FHIRException(org.hl7.fhir.exceptions.FHIRException) TimeType(org.hl7.fhir.dstu3.model.TimeType) DateTimeType(org.hl7.fhir.dstu3.model.DateTimeType) UriType(org.hl7.fhir.dstu3.model.UriType) IntegerType(org.hl7.fhir.dstu3.model.IntegerType) DateTimeType(org.hl7.fhir.dstu3.model.DateTimeType) Coding(org.hl7.fhir.dstu3.model.Coding) DecimalType(org.hl7.fhir.dstu3.model.DecimalType) DateType(org.hl7.fhir.dstu3.model.DateType)

Aggregations

ArrayList (java.util.ArrayList)51 BigDecimal (java.math.BigDecimal)34 PathEngineException (org.hl7.fhir.exceptions.PathEngineException)28 IntegerType (org.hl7.fhir.r5.model.IntegerType)26 IntegerType (org.hl7.fhir.r4.model.IntegerType)23 IntegerType (org.hl7.fhir.r4b.model.IntegerType)23 UcumException (org.fhir.ucum.UcumException)19 Test (org.junit.jupiter.api.Test)13 Decimal (org.fhir.ucum.Decimal)12 FHIRException (org.hl7.fhir.exceptions.FHIRException)12 Base (org.hl7.fhir.r4b.model.Base)11 Base (org.hl7.fhir.r5.model.Base)11 IntegerType (org.hl7.fhir.dstu2.model.IntegerType)10 IntegerType (org.hl7.fhir.dstu2016may.model.IntegerType)10 StringType (org.hl7.fhir.r4.model.StringType)10 Patient (org.hl7.fhir.r4.model.Patient)9 Map (java.util.Map)7 ParserBase (org.hl7.fhir.dstu2016may.metamodel.ParserBase)7 DecimalType (org.hl7.fhir.r5.model.DecimalType)7 List (java.util.List)6