Search in sources :

Example 1 with ShortCode

use of org.monarchinitiative.loinc2hpocore.codesystems.ShortCode 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 2 with ShortCode

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

the class FhirOutcomeCodeTest method abnormal.

@Test
public void abnormal() {
    ShortCode pos = ShortCode.POS;
    String fhirAbnormal = "A";
    assertEquals(pos, FhirOutcomeCode.fhir2shortcode(fhirAbnormal));
}
Also used : ShortCode(org.monarchinitiative.loinc2hpocore.codesystems.ShortCode) Test(org.junit.jupiter.api.Test)

Example 3 with ShortCode

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

the class FhirOutcomeCodeTest method criticallyAbnormal.

@Test
public void criticallyAbnormal() {
    ShortCode pos = ShortCode.POS;
    String fhirCriticallyAbnormal = "AA";
    assertEquals(pos, FhirOutcomeCode.fhir2shortcode(fhirCriticallyAbnormal));
}
Also used : ShortCode(org.monarchinitiative.loinc2hpocore.codesystems.ShortCode) Test(org.junit.jupiter.api.Test)

Example 4 with ShortCode

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

the class FhirOutcomeCodeTest method criticallyHigh.

@Test
public void criticallyHigh() {
    ShortCode high = ShortCode.H;
    String fhirOffScaleHigh = "HH";
    assertEquals(high, FhirOutcomeCode.fhir2shortcode(fhirOffScaleHigh));
}
Also used : ShortCode(org.monarchinitiative.loinc2hpocore.codesystems.ShortCode) Test(org.junit.jupiter.api.Test)

Example 5 with ShortCode

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

the class ObservationDtu3 method getOutcome.

@Override
public Optional<Outcome> getOutcome() {
    if (observation.hasInterpretation()) {
        List<String> codes = this.observation.getInterpretation().getCoding().stream().map(Coding::getCode).distinct().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) Coding(org.hl7.fhir.dstu3.model.Coding) Outcome(org.monarchinitiative.loinc2hpocore.codesystems.Outcome)

Aggregations

ShortCode (org.monarchinitiative.loinc2hpocore.codesystems.ShortCode)17 Test (org.junit.jupiter.api.Test)14 Outcome (org.monarchinitiative.loinc2hpocore.codesystems.Outcome)3 Collection (java.util.Collection)2 Coding (org.hl7.fhir.dstu3.model.Coding)1