Search in sources :

Example 1 with Quantity

use of org.hl7.fhir.dstu3.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.dstu3.model.Quantity in project bunsen by cerner.

the class FhirEncodersTest method bigDecimal.

@Test
public void bigDecimal() {
    BigDecimal originalDecimal = ((Quantity) observation.getValue()).getValue();
    // Use compareTo since equals checks scale as well.
    Assert.assertTrue(originalDecimal.compareTo((BigDecimal) observationsDataset.select("valueQuantity.value").head().get(0)) == 0);
    Assert.assertEquals(originalDecimal.compareTo(((Quantity) decodedObservation.getValue()).getValue()), 0);
}
Also used : Quantity(org.hl7.fhir.dstu3.model.Quantity) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

Quantity (org.hl7.fhir.dstu3.model.Quantity)2 BigDecimal (java.math.BigDecimal)1 Identifier (org.hl7.fhir.dstu3.model.Identifier)1 Observation (org.hl7.fhir.dstu3.model.Observation)1 Test (org.junit.Test)1