Search in sources :

Example 86 with DecimalType

use of org.hl7.fhir.dstu2016may.model.DecimalType in project beneficiary-fhir-data by CMSgov.

the class OutpatientClaimTransformerV2Test method shouldHaveNchBenePtbDdctblAmtFinancial.

@Test
public void shouldHaveNchBenePtbDdctblAmtFinancial() {
    BenefitComponent benefit = TransformerTestUtilsV2.findFinancial("https://bluebutton.cms.gov/resources/variables/nch_bene_ptb_ddctbl_amt", eob.getBenefitBalanceFirstRep().getFinancial());
    BenefitComponent compare = new BenefitComponent().setType(new CodeableConcept().setCoding(Arrays.asList(new Coding("https://bluebutton.cms.gov/resources/codesystem/benefit-balance", "https://bluebutton.cms.gov/resources/variables/nch_bene_ptb_ddctbl_amt", "NCH Beneficiary Part B Deductible Amount")))).setUsed(new Money().setValueElement(new DecimalType("112.00")).setCurrency(TransformerConstants.CODED_MONEY_USD));
    assertTrue(compare.equalsDeep(benefit));
}
Also used : Money(org.hl7.fhir.r4.model.Money) Coding(org.hl7.fhir.r4.model.Coding) DecimalType(org.hl7.fhir.r4.model.DecimalType) BenefitComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.BenefitComponent) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.jupiter.api.Test)

Example 87 with DecimalType

use of org.hl7.fhir.dstu2016may.model.DecimalType in project geoprism-registry by terraframe.

the class ListTypeFhirExporter method createFacility.

private Facility createFacility(Business row, Identifier identifier) {
    String code = row.getValue(DefaultAttribute.CODE.getName());
    Organization org = new Organization();
    org.setId(new IdType(org.getResourceType().name(), code));
    org.setName(row.getValue(DefaultAttribute.DISPLAY_LABEL.getName() + ListTypeVersion.DEFAULT_LOCALE));
    org.addIdentifier(identifier);
    Location location = new Location();
    location.setId(new IdType(location.getResourceType().name(), code));
    location.setName(row.getValue(DefaultAttribute.DISPLAY_LABEL.getName() + ListTypeVersion.DEFAULT_LOCALE));
    location.setManagingOrganization(new Reference(org.getIdElement()));
    location.addIdentifier(identifier);
    Geometry geometry = row.getObjectValue(RegistryConstants.GEOMETRY_ATTRIBUTE_NAME);
    if (geometry != null) {
        Point centroid = geometry.getCentroid();
        GeoJsonWriter writer = new GeoJsonWriter();
        String geojson = writer.write(geometry);
        Encoder encoder = Base64.getEncoder();
        // Create a location
        Attachment attachment = new Attachment();
        attachment.setContentType("application/json");
        attachment.setDataElement(new Base64BinaryType(encoder.encodeToString(geojson.getBytes())));
        attachment.setTitle("Geojson");
        Extension extension = new Extension("http://hl7.org/fhir/StructureDefinition/location-boundary-geojson");
        extension.setValue(attachment);
        location.setPosition(new LocationPositionComponent(new DecimalType(centroid.getX()), new DecimalType(centroid.getY())));
        location.addExtension(extension);
    }
    return new Facility(org, location);
}
Also used : GeoJsonWriter(com.vividsolutions.jts.io.geojson.GeoJsonWriter) Organization(org.hl7.fhir.r4.model.Organization) Reference(org.hl7.fhir.r4.model.Reference) Attachment(org.hl7.fhir.r4.model.Attachment) Point(com.vividsolutions.jts.geom.Point) IdType(org.hl7.fhir.r4.model.IdType) Geometry(com.vividsolutions.jts.geom.Geometry) Extension(org.hl7.fhir.r4.model.Extension) LocationPositionComponent(org.hl7.fhir.r4.model.Location.LocationPositionComponent) Encoder(java.util.Base64.Encoder) DecimalType(org.hl7.fhir.r4.model.DecimalType) Base64BinaryType(org.hl7.fhir.r4.model.Base64BinaryType) Location(org.hl7.fhir.r4.model.Location)

Example 88 with DecimalType

use of org.hl7.fhir.dstu2016may.model.DecimalType in project pathling by aehrc.

the class TestData method newQuestionnaireResponse.

/**
 * Returns a FHIR QuestionnaireResponse resource for testing purposes.
 */
public static QuestionnaireResponse newQuestionnaireResponse() {
    final QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
    questionnaireResponse.setId("QuestionnaireResponse/1");
    final QuestionnaireResponseItemComponent item = questionnaireResponse.addItem();
    final QuestionnaireResponseItemAnswerComponent answer1 = new QuestionnaireResponseItemAnswerComponent();
    answer1.setValue(new DecimalType(TEST_VERY_SMALL_DECIMAL_SCALE_6));
    final QuestionnaireResponseItemAnswerComponent answer2 = new QuestionnaireResponseItemAnswerComponent();
    answer2.setValue(new DecimalType(TEST_VERY_BIG_DECIMAL));
    item.addAnswer(answer1);
    item.addAnswer(answer2);
    return questionnaireResponse;
}
Also used : QuestionnaireResponseItemAnswerComponent(org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent) QuestionnaireResponseItemComponent(org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemComponent)

Example 89 with DecimalType

use of org.hl7.fhir.dstu2016may.model.DecimalType in project quality-measure-and-cohort-service by Alvearie.

the class R4ParameterDefinitionWithDefaultToCohortParameterConverter method toCohortParameter.

public static Parameter toCohortParameter(Extension extension) {
    Parameter parameter;
    Type extensionValue = extension.getValue();
    if (extensionValue instanceof Base64BinaryType) {
        parameter = new StringParameter(((Base64BinaryType) extensionValue).asStringValue());
    } else if (extensionValue instanceof BooleanType) {
        parameter = new BooleanParameter(((BooleanType) extensionValue).booleanValue());
    } else if (extensionValue instanceof DateType) {
        parameter = new DateParameter(((DateType) extensionValue).asStringValue());
    } else if (extensionValue instanceof DateTimeType) {
        parameter = convertDateTimeType((DateTimeType) extensionValue);
    } else if (extensionValue instanceof DecimalType) {
        parameter = new DecimalParameter(((DecimalType) extensionValue).getValueAsString());
    } else if (extensionValue instanceof InstantType) {
        parameter = new DatetimeParameter(((InstantType) extensionValue).getValueAsString());
    } else if (extensionValue instanceof IntegerType) {
        parameter = new IntegerParameter(((IntegerType) extensionValue).getValue());
    } else if (extensionValue instanceof StringType) {
        parameter = new StringParameter(((StringType) extensionValue).getValue());
    } else if (extensionValue instanceof TimeType) {
        parameter = new TimeParameter(((TimeType) extensionValue).asStringValue());
    } else if (extensionValue instanceof UriType) {
        parameter = new StringParameter(((UriType) extensionValue).getValue());
    } else if (extensionValue instanceof Coding) {
        parameter = convertCoding((Coding) extensionValue);
    } else if (extensionValue instanceof CodeableConcept) {
        parameter = convertCodeableConcept((CodeableConcept) extensionValue);
    } else if (extensionValue instanceof Period) {
        Period castValue = (Period) extensionValue;
        parameter = new IntervalParameter(convertDateTimeType(castValue.getStartElement()), true, convertDateTimeType(castValue.getEndElement()), true);
    } else if (extensionValue instanceof Quantity) {
        parameter = convertQuantity((Quantity) extensionValue);
    } else if (extensionValue instanceof Range) {
        Range castValue = (Range) extensionValue;
        parameter = new IntervalParameter(convertQuantity(castValue.getLow()), true, convertQuantity(castValue.getHigh()), true);
    } else if (extensionValue instanceof Ratio) {
        Ratio castValue = (Ratio) extensionValue;
        parameter = new RatioParameter().setDenominator(convertQuantity(castValue.getDenominator())).setNumerator(convertQuantity(castValue.getNumerator()));
    } else {
        throw new UnsupportedFhirTypeException(extensionValue);
    }
    return parameter;
}
Also used : IntegerParameter(com.ibm.cohort.cql.evaluation.parameters.IntegerParameter) StringType(org.hl7.fhir.r4.model.StringType) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) TimeType(org.hl7.fhir.r4.model.TimeType) UriType(org.hl7.fhir.r4.model.UriType) DateParameter(com.ibm.cohort.cql.evaluation.parameters.DateParameter) Coding(org.hl7.fhir.r4.model.Coding) DatetimeParameter(com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter) TimeParameter(com.ibm.cohort.cql.evaluation.parameters.TimeParameter) Ratio(org.hl7.fhir.r4.model.Ratio) InstantType(org.hl7.fhir.r4.model.InstantType) DateType(org.hl7.fhir.r4.model.DateType) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) UnsupportedFhirTypeException(com.ibm.cohort.engine.measure.parameter.UnsupportedFhirTypeException) StringParameter(com.ibm.cohort.cql.evaluation.parameters.StringParameter) BooleanType(org.hl7.fhir.r4.model.BooleanType) Period(org.hl7.fhir.r4.model.Period) Quantity(org.hl7.fhir.r4.model.Quantity) Range(org.hl7.fhir.r4.model.Range) BooleanParameter(com.ibm.cohort.cql.evaluation.parameters.BooleanParameter) IntegerType(org.hl7.fhir.r4.model.IntegerType) Type(org.hl7.fhir.r4.model.Type) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) Base64BinaryType(org.hl7.fhir.r4.model.Base64BinaryType) StringType(org.hl7.fhir.r4.model.StringType) DecimalType(org.hl7.fhir.r4.model.DecimalType) IntegerType(org.hl7.fhir.r4.model.IntegerType) DateType(org.hl7.fhir.r4.model.DateType) TimeType(org.hl7.fhir.r4.model.TimeType) BooleanType(org.hl7.fhir.r4.model.BooleanType) InstantType(org.hl7.fhir.r4.model.InstantType) UriType(org.hl7.fhir.r4.model.UriType) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) DecimalParameter(com.ibm.cohort.cql.evaluation.parameters.DecimalParameter) DatetimeParameter(com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) DecimalParameter(com.ibm.cohort.cql.evaluation.parameters.DecimalParameter) ConceptParameter(com.ibm.cohort.cql.evaluation.parameters.ConceptParameter) QuantityParameter(com.ibm.cohort.cql.evaluation.parameters.QuantityParameter) RatioParameter(com.ibm.cohort.cql.evaluation.parameters.RatioParameter) IntegerParameter(com.ibm.cohort.cql.evaluation.parameters.IntegerParameter) DateParameter(com.ibm.cohort.cql.evaluation.parameters.DateParameter) StringParameter(com.ibm.cohort.cql.evaluation.parameters.StringParameter) CodeParameter(com.ibm.cohort.cql.evaluation.parameters.CodeParameter) TimeParameter(com.ibm.cohort.cql.evaluation.parameters.TimeParameter) BooleanParameter(com.ibm.cohort.cql.evaluation.parameters.BooleanParameter) Parameter(com.ibm.cohort.cql.evaluation.parameters.Parameter) DecimalType(org.hl7.fhir.r4.model.DecimalType) RatioParameter(com.ibm.cohort.cql.evaluation.parameters.RatioParameter) Base64BinaryType(org.hl7.fhir.r4.model.Base64BinaryType) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 90 with DecimalType

use of org.hl7.fhir.dstu2016may.model.DecimalType in project kindling by HL7.

the class OldSpreadsheetParser method processValue.

private DataType processValue(Sheet sheet, int row, String column, String source, ElementDefn e) throws Exception {
    if (Utilities.noString(source))
        return null;
    if (e.getTypes().size() != 1)
        throw new Exception("Unable to process " + column + " unless a single type is specified (types = " + e.typeCode() + ") " + getLocation(row) + ", column = " + column);
    String type = e.typeCode();
    if (definitions != null) {
        if (definitions.getConstraints().containsKey(type))
            type = definitions.getConstraints().get(type).getBaseType();
    } else {
        StructureDefinition sd = context.fetchTypeDefinition(type);
        if (// not loaded yet?
        sd != null)
            type = sd.getType();
        if (type.equals("SimpleQuantity"))
            type = "Quantity";
    }
    if (source.startsWith("{")) {
        JsonParser json = new JsonParser();
        return json.parseType(source, type);
    } else if (source.startsWith("<")) {
        XmlParser xml = new XmlParser();
        return xml.parseType(source, type);
    } else {
        if (source.startsWith("\"") && source.endsWith("\""))
            source = source.substring(1, source.length() - 1);
        if (type.equals("string"))
            return new StringType(source);
        if (type.equals("boolean"))
            return new BooleanType(Boolean.valueOf(source));
        if (type.equals("integer"))
            return new IntegerType(Integer.valueOf(source));
        if (type.equals("integer64"))
            return new Integer64Type(Long.valueOf(source));
        if (type.equals("unsignedInt"))
            return new UnsignedIntType(Integer.valueOf(source));
        if (type.equals("positiveInt"))
            return new PositiveIntType(Integer.valueOf(source));
        if (type.equals("decimal"))
            return new DecimalType(new BigDecimal(source));
        if (type.equals("base64Binary"))
            return new Base64BinaryType(Base64.decode(source.toCharArray()));
        if (type.equals("instant"))
            return new InstantType(source);
        if (type.equals("uri"))
            return new UriType(source);
        if (type.equals("url"))
            return new UrlType(source);
        if (type.equals("canonical"))
            return new CanonicalType(source);
        if (type.equals("date"))
            return new DateType(source);
        if (type.equals("dateTime"))
            return new DateTimeType(source);
        if (type.equals("time"))
            return new TimeType(source);
        if (type.equals("code"))
            return new CodeType(source);
        if (type.equals("oid"))
            return new OidType(source);
        if (type.equals("uuid"))
            return new UuidType(source);
        if (type.equals("id"))
            return new IdType(source);
        if (type.startsWith("Reference(")) {
            Reference r = new Reference();
            r.setReference(source);
            return r;
        }
        if (type.equals("Period")) {
            if (source.contains("->")) {
                String[] parts = source.split("\\-\\>");
                Period p = new Period();
                p.setStartElement(new DateTimeType(parts[0].trim()));
                if (parts.length > 1)
                    p.setEndElement(new DateTimeType(parts[1].trim()));
                return p;
            } else
                throw new Exception("format not understood parsing " + source + " into a period");
        }
        if (type.equals("CodeableConcept")) {
            CodeableConcept cc = new CodeableConcept();
            if (source.contains(":")) {
                String[] parts = source.split("\\:");
                String system = "";
                if (parts[0].equalsIgnoreCase("SCT"))
                    system = "http://snomed.info/sct";
                else if (parts[0].equalsIgnoreCase("LOINC"))
                    system = "http://loinc.org";
                else if (parts[0].equalsIgnoreCase("AMTv2"))
                    system = "http://nehta.gov.au/amtv2";
                else
                    system = "http://hl7.org/fhir/" + parts[0];
                String code = parts[1];
                String display = parts.length > 2 ? parts[2] : null;
                cc.addCoding().setSystem(system).setCode(code).setDisplay(display);
            } else
                throw new Exception("format not understood parsing " + source + " into a codeable concept");
            return cc;
        }
        if (type.equals("Identifier")) {
            Identifier id = new Identifier();
            id.setSystem("urn:ietf:rfc:3986");
            id.setValue(source);
            return id;
        }
        if (type.equals("Quantity")) {
            int s = 0;
            if (source.startsWith("<=") || source.startsWith("=>"))
                s = 2;
            else if (source.startsWith("<") || source.startsWith(">"))
                s = 1;
            int i = s;
            while (i < source.length() && Character.isDigit(source.charAt(i))) i++;
            Quantity q = new Quantity();
            if (s > 0)
                q.setComparator(QuantityComparator.fromCode(source.substring(0, s)));
            if (i > s)
                q.setValue(new BigDecimal(source.substring(s, i)));
            if (i < source.length())
                q.setUnit(source.substring(i).trim());
            return q;
        }
        throw new Exception("Unable to process primitive value '" + source + "' provided for " + column + " - unhandled type " + type + " @ " + getLocation(row));
    }
}
Also used : StringType(org.hl7.fhir.r5.model.StringType) PositiveIntType(org.hl7.fhir.r5.model.PositiveIntType) CanonicalType(org.hl7.fhir.r5.model.CanonicalType) UriType(org.hl7.fhir.r5.model.UriType) TimeType(org.hl7.fhir.r5.model.TimeType) DateTimeType(org.hl7.fhir.r5.model.DateTimeType) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) Identifier(org.hl7.fhir.r5.model.Identifier) InstantType(org.hl7.fhir.r5.model.InstantType) DateType(org.hl7.fhir.r5.model.DateType) JsonParser(org.hl7.fhir.r5.formats.JsonParser) XmlParser(org.hl7.fhir.r5.formats.XmlParser) XLSXmlParser(org.hl7.fhir.utilities.xls.XLSXmlParser) OidType(org.hl7.fhir.r5.model.OidType) UuidType(org.hl7.fhir.r5.model.UuidType) Reference(org.hl7.fhir.r5.model.Reference) BooleanType(org.hl7.fhir.r5.model.BooleanType) Period(org.hl7.fhir.r5.model.Period) Quantity(org.hl7.fhir.r5.model.Quantity) Integer64Type(org.hl7.fhir.r5.model.Integer64Type) FHIRException(org.hl7.fhir.exceptions.FHIRException) BigDecimal(java.math.BigDecimal) IdType(org.hl7.fhir.r5.model.IdType) IntegerType(org.hl7.fhir.r5.model.IntegerType) DateTimeType(org.hl7.fhir.r5.model.DateTimeType) DecimalType(org.hl7.fhir.r5.model.DecimalType) CodeType(org.hl7.fhir.r5.model.CodeType) UnsignedIntType(org.hl7.fhir.r5.model.UnsignedIntType) Base64BinaryType(org.hl7.fhir.r5.model.Base64BinaryType) UrlType(org.hl7.fhir.r5.model.UrlType) CodeableConcept(org.hl7.fhir.r5.model.CodeableConcept)

Aggregations

DecimalType (org.hl7.fhir.r4.model.DecimalType)48 Test (org.junit.jupiter.api.Test)47 Coding (org.hl7.fhir.r4.model.Coding)44 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)42 Money (org.hl7.fhir.r4.model.Money)41 BigDecimal (java.math.BigDecimal)40 ArrayList (java.util.ArrayList)38 PathEngineException (org.hl7.fhir.exceptions.PathEngineException)36 BenefitComponent (org.hl7.fhir.r4.model.ExplanationOfBenefit.BenefitComponent)31 UcumException (org.fhir.ucum.UcumException)29 DecimalType (org.hl7.fhir.r4b.model.DecimalType)22 DecimalType (org.hl7.fhir.r5.model.DecimalType)20 FHIRException (org.hl7.fhir.exceptions.FHIRException)19 Decimal (org.fhir.ucum.Decimal)14 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)14 NotImplementedException (org.apache.commons.lang3.NotImplementedException)12 Pair (org.fhir.ucum.Pair)12 Base (org.hl7.fhir.r4b.model.Base)12 Base (org.hl7.fhir.r5.model.Base)12 AdjudicationComponent (org.hl7.fhir.r4.model.ExplanationOfBenefit.AdjudicationComponent)8