Search in sources :

Example 1 with Quantity

use of org.hl7.fhir.r4.model.Quantity in project bunsen by cerner.

the class TestData method newObservation.

/**
 * Returns a FHIR Observation for testing purposes.
 */
public static Observation newObservation() {
    // Observation based on https://www.hl7.org/FHIR/observation-example-bloodpressure.json.html
    Observation observation = new Observation();
    observation.setId("blood-pressure");
    Identifier identifier = observation.addIdentifier();
    identifier.setSystem("urn:ietf:rfc:3986");
    identifier.setValue("urn:uuid:187e0c12-8dd2-67e2-99b2-bf273c878281");
    observation.setStatus(Observation.ObservationStatus.FINAL);
    Quantity quantity = new Quantity();
    quantity.setValue(new java.math.BigDecimal("123.45"));
    quantity.setUnit("mm[Hg]");
    observation.setValue(quantity);
    return observation;
}
Also used : Identifier(org.hl7.fhir.dstu3.model.Identifier) Observation(org.hl7.fhir.dstu3.model.Observation) Quantity(org.hl7.fhir.dstu3.model.Quantity)

Example 2 with Quantity

use of org.hl7.fhir.r4.model.Quantity in project beneficiary-fhir-data by CMSgov.

the class TransformerUtils method createExtensionQuantity.

/**
 * @param ccwVariable the {@link CcwCodebookInterface} being mapped
 * @param quantityValue the value to use for {@link Coding#getCode()} for the resulting {@link
 *     Coding}
 * @return the output {@link Extension}, with {@link Extension#getValue()} set to represent the
 *     specified input values
 */
static Extension createExtensionQuantity(CcwCodebookInterface ccwVariable, Optional<? extends Number> quantityValue) {
    if (!quantityValue.isPresent())
        throw new IllegalArgumentException();
    Quantity quantity;
    if (quantityValue.get() instanceof BigDecimal)
        quantity = new Quantity().setValue((BigDecimal) quantityValue.get());
    else
        throw new BadCodeMonkeyException();
    String extensionUrl = CCWUtils.calculateVariableReferenceUrl(ccwVariable);
    Extension extension = new Extension(extensionUrl, quantity);
    return extension;
}
Also used : IBaseExtension(org.hl7.fhir.instance.model.api.IBaseExtension) Extension(org.hl7.fhir.dstu3.model.Extension) BadCodeMonkeyException(gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException) SimpleQuantity(org.hl7.fhir.dstu3.model.SimpleQuantity) Quantity(org.hl7.fhir.dstu3.model.Quantity) BigDecimal(java.math.BigDecimal)

Example 3 with Quantity

use of org.hl7.fhir.r4.model.Quantity in project beneficiary-fhir-data by CMSgov.

the class TransformerUtils method addExtensionValueQuantity.

/**
 * Adds an {@link Extension} to the specified {@link DomainResource}. {@link Extension#getValue()}
 * will be set to a {@link Quantity} with the specified system and value.
 *
 * @param fhirElement the FHIR element to add the {@link Extension} to
 * @param extensionUrl the {@link Extension#getUrl()} to use
 * @param quantitySystem the {@link Quantity#getSystem()} to use
 * @param quantityValue the {@link Quantity#getValue()} to use
 */
static void addExtensionValueQuantity(IBaseHasExtensions fhirElement, String extensionUrl, String quantitySystem, BigDecimal quantityValue) {
    IBaseExtension<?, ?> extension = fhirElement.addExtension();
    extension.setUrl(extensionUrl);
    extension.setValue(new Quantity().setSystem(extensionUrl).setValue(quantityValue));
// CodeableConcept codeableConcept = new CodeableConcept();
// extension.setValue(codeableConcept);
// 
// Coding coding = codeableConcept.addCoding();
// coding.setSystem(codingSystem).setCode(codingCode);
}
Also used : SimpleQuantity(org.hl7.fhir.dstu3.model.SimpleQuantity) Quantity(org.hl7.fhir.dstu3.model.Quantity)

Example 4 with Quantity

use of org.hl7.fhir.r4.model.Quantity in project beneficiary-fhir-data by CMSgov.

the class TransformerUtilsV2 method createExtensionQuantity.

/**
 * @param ccwVariable the {@link CcwCodebookInterface} being mapped
 * @param quantityValue the value to use for {@link Coding#getCode()} for the resulting {@link
 *     Coding}
 * @return the output {@link Extension}, with {@link Extension#getValue()} set to represent the
 *     specified input values
 */
static Extension createExtensionQuantity(CcwCodebookInterface ccwVariable, Optional<? extends Number> quantityValue) {
    if (!quantityValue.isPresent()) {
        throw new IllegalArgumentException();
    }
    Quantity quantity;
    if (quantityValue.get() instanceof BigDecimal) {
        quantity = new Quantity().setValue((BigDecimal) quantityValue.get());
    } else {
        throw new BadCodeMonkeyException();
    }
    String extensionUrl = CCWUtils.calculateVariableReferenceUrl(ccwVariable);
    Extension extension = new Extension(extensionUrl, quantity);
    return extension;
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) BadCodeMonkeyException(gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException) SimpleQuantity(org.hl7.fhir.r4.model.SimpleQuantity) Quantity(org.hl7.fhir.r4.model.Quantity) BigDecimal(java.math.BigDecimal)

Example 5 with Quantity

use of org.hl7.fhir.r4.model.Quantity in project beneficiary-fhir-data by CMSgov.

the class OutpatientClaimTransformerV2Test method shouldHaveLineItemQuantity.

@Test
public void shouldHaveLineItemQuantity() {
    Quantity quantity = eob.getItemFirstRep().getQuantity();
    Quantity compare = new Quantity(77);
    assertTrue(compare.equalsDeep(quantity));
}
Also used : Quantity(org.hl7.fhir.r4.model.Quantity) Test(org.junit.jupiter.api.Test)

Aggregations

Quantity (org.hl7.fhir.r4.model.Quantity)58 ArrayList (java.util.ArrayList)47 BigDecimal (java.math.BigDecimal)39 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)37 Test (org.junit.Test)25 List (java.util.List)24 Test (org.junit.jupiter.api.Test)24 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)23 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)23 Quantity (org.hl7.fhir.dstu3.model.Quantity)22 NotImplementedException (org.apache.commons.lang3.NotImplementedException)19 FHIRException (org.hl7.fhir.exceptions.FHIRException)18 PathEngineException (org.hl7.fhir.exceptions.PathEngineException)18 Observation (org.hl7.fhir.r4.model.Observation)18 UcumException (org.fhir.ucum.UcumException)16 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)16 Resource (org.hl7.fhir.r4.model.Resource)16 Quantity (org.hl7.fhir.r5.model.Quantity)15 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)15 Coding (org.hl7.fhir.r4.model.Coding)13