Search in sources :

Example 6 with Observation

use of org.hl7.fhir.dstu3.model.Observation in project loinc2hpo by monarch-initiative.

the class ObservationWithInterpretationTest method testLowHemoglobinWithoutInterpretation.

/**
 * Low erythrocytes with L interpretation.
 */
@Test
public void testLowHemoglobinWithoutInterpretation() {
    Observation lowHb = lowHemoglobinObservation();
    Uberobservation uberobservation = new ObservationDtu3(lowHb);
    LoincId erysInBlood = new LoincId("789-8");
    Optional<LoincId> opt = uberobservation.getLoincId();
    assertTrue(opt.isPresent());
    assertEquals(erysInBlood, opt.get());
    Optional<Outcome> outcomeOpt = uberobservation.getOutcome();
    assertTrue(outcomeOpt.isPresent());
    assertEquals(Outcome.LOW(), outcomeOpt.get());
}
Also used : ObservationDtu3(org.monarchinitiative.loinc2hpofhir.fhir2hpo.ObservationDtu3) Outcome(org.monarchinitiative.loinc2hpocore.codesystems.Outcome) Observation(org.hl7.fhir.dstu3.model.Observation) LoincId(org.monarchinitiative.loinc2hpocore.loinc.LoincId) Uberobservation(org.monarchinitiative.loinc2hpofhir.fhir2hpo.Uberobservation) Test(org.junit.jupiter.api.Test)

Example 7 with Observation

use of org.hl7.fhir.dstu3.model.Observation 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 8 with Observation

use of org.hl7.fhir.dstu3.model.Observation in project bunsen by cerner.

the class ValueSetUdfsTest method setUp.

/**
 * Sets up Spark and loads test value sets.
 */
@BeforeClass
public static void setUp() throws IOException {
    // Create a local spark session using an in-memory metastore.
    // We must also use Hive and set the partition mode to non-strict to
    // support dynamic partitions.
    spark = SparkSession.builder().master("local[2]").appName("UdfsTest").enableHiveSupport().config("javax.jdo.option.ConnectionURL", "jdbc:derby:memory:metastore_db;create=true").config("hive.exec.dynamic.partition.mode", "nonstrict").config("spark.sql.warehouse.dir", Files.createTempDirectory("spark_warehouse").toString()).getOrCreate();
    spark.sql("create database " + ConceptMaps.MAPPING_DATABASE);
    Hierarchies withLoinc = Loinc.withLoincHierarchy(spark, Hierarchies.getEmpty(spark), "src/test/resources/LOINC_HIERARCHY_SAMPLE.CSV", "2.56");
    Hierarchies withLoincAndSnomed = Snomed.withRelationships(spark, withLoinc, "src/test/resources/SNOMED_RELATIONSHIP_SAMPLE.TXT", "20160901");
    ValueSets withGender = ValueSets.getEmpty(spark).withValueSetsFromDirectory("src/test/resources/xml/valuesets");
    BroadcastableValueSets valueSets = BroadcastableValueSets.newBuilder().addCode("bp", Loinc.LOINC_CODE_SYSTEM_URI, "8462-4").addCode("albumin", Loinc.LOINC_CODE_SYSTEM_URI, "14959-1").addReference("married", "urn:cerner:bunsen:valueset:married_maritalstatus").addDescendantsOf("leukocytes", Loinc.LOINC_CODE_SYSTEM_URI, "LP14419-3", Loinc.LOINC_HIERARCHY_URI).addDescendantsOf("diabetes", Snomed.SNOMED_CODE_SYSTEM_URI, "73211009", Snomed.SNOMED_HIERARCHY_URI).addDescendantsOf("blood_disorder", Snomed.SNOMED_CODE_SYSTEM_URI, "266992002", Snomed.SNOMED_HIERARCHY_URI).addDescendantsOf("disorder_history", Snomed.SNOMED_CODE_SYSTEM_URI, "312850006", Snomed.SNOMED_HIERARCHY_URI).build(spark, withGender, withLoincAndSnomed);
    ValueSetUdfs.pushUdf(spark, valueSets);
    Dataset<Observation> loincObservations = spark.createDataset(ImmutableList.of(// "is a" LP14419-3
    observation("leukocytes", "5821-4"), // Blood pressure
    observation("bp", "8462-4")), encoders.of(Observation.class));
    loincObservations.createOrReplaceTempView("test_loinc_obs");
    // Conditions include history of anemia, which includes a cycling ancestor
    // in our test data. This ensures that can be loaded correctly.
    Dataset<Condition> conditions = spark.createDataset(ImmutableList.of(// "is a" 73211009 (diabetes)
    condition("diabetes", "44054006"), // 312850006 (history of disorder)
    condition("history_of_anemia", "275538002")), encoders.of(Condition.class));
    conditions.createOrReplaceTempView("test_snomed_cond");
    Dataset<Patient> patients = spark.createDataset(ImmutableList.of(patient("married", "M"), patient("unmarried", "U")), encoders.of(Patient.class));
    patients.createOrReplaceTempView("test_valueset_patient");
}
Also used : Condition(org.hl7.fhir.dstu3.model.Condition) Hierarchies(com.cerner.bunsen.codes.Hierarchies) Observation(org.hl7.fhir.dstu3.model.Observation) BroadcastableValueSets(com.cerner.bunsen.codes.broadcast.BroadcastableValueSets) Patient(org.hl7.fhir.dstu3.model.Patient) BroadcastableValueSets(com.cerner.bunsen.codes.broadcast.BroadcastableValueSets) ValueSets(com.cerner.bunsen.codes.ValueSets) BeforeClass(org.junit.BeforeClass)

Example 9 with Observation

use of org.hl7.fhir.dstu3.model.Observation in project bunsen by cerner.

the class ValueSetUdfsTest method observation.

private static Observation observation(String id, String code) {
    Observation observation = new Observation();
    observation.setId(id);
    observation.setCode(codeable(Loinc.LOINC_CODE_SYSTEM_URI, code));
    return observation;
}
Also used : Observation(org.hl7.fhir.dstu3.model.Observation)

Example 10 with Observation

use of org.hl7.fhir.dstu3.model.Observation in project loinc2hpo by monarch-initiative.

the class ObservationDownloader method retrieveObservation.

static List<Observation> retrieveObservation(String loincCode) {
    List<Observation> results = new ArrayList<>();
    Bundle bundle = client.search().forResource(Observation.class).where(new TokenClientParam("code").exactly().systemAndCode(LOINC_SYSTEM, loincCode)).prettyPrint().returnBundle(Bundle.class).execute();
    while (true) {
        for (Bundle.BundleEntryComponent bundleEntryComponent : bundle.getEntry()) {
            Observation observation = (Observation) bundleEntryComponent.getResource();
            results.add(observation);
        }
        if (bundle.getLink(IBaseBundle.LINK_NEXT) != null) {
            bundle = client.loadPage().next(bundle).execute();
        } else {
            break;
        }
    }
    return results;
}
Also used : TokenClientParam(ca.uhn.fhir.rest.gclient.TokenClientParam) IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle) ArrayList(java.util.ArrayList)

Aggregations

Observation (org.hl7.fhir.dstu3.model.Observation)15 Outcome (org.monarchinitiative.loinc2hpocore.codesystems.Outcome)7 Test (org.junit.jupiter.api.Test)6 LoincId (org.monarchinitiative.loinc2hpocore.loinc.LoincId)6 ObservationDtu3 (org.monarchinitiative.loinc2hpofhir.fhir2hpo.ObservationDtu3)6 Uberobservation (org.monarchinitiative.loinc2hpofhir.fhir2hpo.Uberobservation)6 TermId (com.github.phenomics.ontolib.ontology.data.TermId)4 IBaseBundle (org.hl7.fhir.instance.model.api.IBaseBundle)4 BeforeClass (org.junit.BeforeClass)4 HpoOntology (com.github.phenomics.ontolib.formats.hpo.HpoOntology)3 HpoTerm (com.github.phenomics.ontolib.formats.hpo.HpoTerm)3 HpoOboParser (com.github.phenomics.ontolib.io.obo.hpo.HpoOboParser)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 TestBase.importDstu3Observation (fhir.TestBase.importDstu3Observation)3 File (java.io.File)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 Code (org.monarchinitiative.loinc2hpo.codesystems.Code)3 Test (org.junit.Test)2 ReferenceClientParam (ca.uhn.fhir.rest.gclient.ReferenceClientParam)1