Search in sources :

Example 1 with Outcome

use of org.monarchinitiative.loinc2hpocore.codesystems.Outcome in project loinc2hpo by monarch-initiative.

the class Dstu3ObservationTest method testGlucoseNormal.

@Test
void testGlucoseNormal() throws IOException {
    String jsonPath = "json/glucoseNormal.fhir";
    Observation glucoseAbnormal = importDstu3Observation(jsonPath);
    Uberobservation uberobservation = new ObservationDtu3(glucoseAbnormal);
    LoincId expectedLoincId = new LoincId("15074-8");
    Optional<LoincId> opt = uberobservation.getLoincId();
    assertTrue(opt.isPresent());
    assertEquals(expectedLoincId, opt.get());
    Optional<Outcome> opt2 = uberobservation.getOutcome();
    assertTrue(opt2.isPresent());
    assertEquals(Outcome.NORMAL(), opt2.get());
    assertNotEquals(Outcome.LOW(), opt2.get());
    assertNotEquals(Outcome.HIGH(), opt2.get());
}
Also used : ObservationDtu3(org.monarchinitiative.loinc2hpofhir.fhir2hpo.ObservationDtu3) Outcome(org.monarchinitiative.loinc2hpocore.codesystems.Outcome) Observation(org.hl7.fhir.dstu3.model.Observation) TestBase.importDstu3Observation(fhir.TestBase.importDstu3Observation) LoincId(org.monarchinitiative.loinc2hpocore.loinc.LoincId) Uberobservation(org.monarchinitiative.loinc2hpofhir.fhir2hpo.Uberobservation) Test(org.junit.jupiter.api.Test)

Example 2 with Outcome

use of org.monarchinitiative.loinc2hpocore.codesystems.Outcome in project loinc2hpo by monarch-initiative.

the class Dstu3ObservationTest method testGlucoseHigh.

@Test
void testGlucoseHigh() throws IOException {
    String jsonPath = "json/glucoseHigh.fhir";
    Observation glucoseHigh = importDstu3Observation(jsonPath);
    Uberobservation uberobservation = new ObservationDtu3(glucoseHigh);
    LoincId expectedLoincId = new LoincId("15074-8");
    Optional<LoincId> opt = uberobservation.getLoincId();
    assertTrue(opt.isPresent());
    assertEquals(expectedLoincId, opt.get());
    Optional<Outcome> opt2 = uberobservation.getOutcome();
    assertTrue(opt2.isPresent());
    assertEquals(Outcome.HIGH(), opt2.get());
    assertNotEquals(Outcome.LOW(), opt2.get());
    assertNotEquals(Outcome.NORMAL(), opt2.get());
}
Also used : ObservationDtu3(org.monarchinitiative.loinc2hpofhir.fhir2hpo.ObservationDtu3) Outcome(org.monarchinitiative.loinc2hpocore.codesystems.Outcome) Observation(org.hl7.fhir.dstu3.model.Observation) TestBase.importDstu3Observation(fhir.TestBase.importDstu3Observation) LoincId(org.monarchinitiative.loinc2hpocore.loinc.LoincId) Uberobservation(org.monarchinitiative.loinc2hpofhir.fhir2hpo.Uberobservation) Test(org.junit.jupiter.api.Test)

Example 3 with Outcome

use of org.monarchinitiative.loinc2hpocore.codesystems.Outcome in project loinc2hpo by monarch-initiative.

the class ObservationR4 method getOutcome.

@Override
public Optional<Outcome> getOutcome() {
    if (observation.hasInterpretation()) {
        List<String> codes = this.observation.getInterpretation().stream().distinct().map(CodeableConcept::getCoding).flatMap(Collection::stream).map(Coding::getCode).collect(Collectors.toList());
        if (codes.size() > 1) {
            LOGGER.error("Multiple interpretation codes returned");
            return Optional.empty();
        }
        ShortCode code = ShortCode.fromShortCode(codes.get(0));
        Outcome outcome = getOutcome(code, observation);
        return Optional.of(outcome);
    } else if (observation.hasValueCodeableConcept()) {
        return getOutcomeFromCodedValue();
    } else if (observation.hasValueQuantity()) {
        return getOutcomeFromValueQuantity();
    } else {
        LOGGER.error("Unable to handle observation {}", observation);
        return Optional.empty();
    }
}
Also used : ShortCode(org.monarchinitiative.loinc2hpocore.codesystems.ShortCode) Outcome(org.monarchinitiative.loinc2hpocore.codesystems.Outcome) Collection(java.util.Collection)

Example 4 with Outcome

use of org.monarchinitiative.loinc2hpocore.codesystems.Outcome in project loinc2hpo by monarch-initiative.

the class ObservationWithValueRangeTest method highHbWithReferenceRange.

/**
 * This observation does not have an Interpretation, but we can infer the value to be high
 * based on the reference range.
 */
@Test
public void highHbWithReferenceRange() {
    Observation observation = highHemoglobinWithValueRangeObservation();
    Uberobservation uberobservation = new ObservationDtu3(observation);
    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.HIGH(), 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 5 with Outcome

use of org.monarchinitiative.loinc2hpocore.codesystems.Outcome 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)

Aggregations

Outcome (org.monarchinitiative.loinc2hpocore.codesystems.Outcome)13 LoincId (org.monarchinitiative.loinc2hpocore.loinc.LoincId)7 Observation (org.hl7.fhir.dstu3.model.Observation)6 Test (org.junit.jupiter.api.Test)6 ObservationDtu3 (org.monarchinitiative.loinc2hpofhir.fhir2hpo.ObservationDtu3)6 Uberobservation (org.monarchinitiative.loinc2hpofhir.fhir2hpo.Uberobservation)6 TestBase.importDstu3Observation (fhir.TestBase.importDstu3Observation)3 ShortCode (org.monarchinitiative.loinc2hpocore.codesystems.ShortCode)3 Collection (java.util.Collection)2 Coding (org.hl7.fhir.dstu3.model.Coding)2 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)1 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)1 Coding (org.hl7.fhir.r4.model.Coding)1 CodeableConcept (org.hl7.fhir.r5.model.CodeableConcept)1 Coding (org.hl7.fhir.r5.model.Coding)1 TermId (org.monarchinitiative.phenol.ontology.data.TermId)1