Search in sources :

Example 6 with ShortCode

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

the class ObservationR5 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(org.hl7.fhir.r5.model.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 7 with ShortCode

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

the class FhirOutcomeCodeTest method low.

@Test
public void low() {
    ShortCode low = ShortCode.L;
    String fhirOffScaleLow = "L";
    assertEquals(low, FhirOutcomeCode.fhir2shortcode(fhirOffScaleLow));
}
Also used : ShortCode(org.monarchinitiative.loinc2hpocore.codesystems.ShortCode) Test(org.junit.jupiter.api.Test)

Example 8 with ShortCode

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

the class FhirOutcomeCodeTest method notDetected.

@Test
public void notDetected() {
    ShortCode neg = ShortCode.NEG;
    String fhirNotDetected = "ND";
    assertEquals(neg, FhirOutcomeCode.fhir2shortcode(fhirNotDetected));
}
Also used : ShortCode(org.monarchinitiative.loinc2hpocore.codesystems.ShortCode) Test(org.junit.jupiter.api.Test)

Example 9 with ShortCode

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

the class FhirOutcomeCodeTest method high.

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

Example 10 with ShortCode

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

the class FhirOutcomeCodeTest method criticalLow.

@Test
public void criticalLow() {
    ShortCode low = ShortCode.L;
    String fhirOffScaleLow = "LL";
    assertEquals(low, FhirOutcomeCode.fhir2shortcode(fhirOffScaleLow));
}
Also used : ShortCode(org.monarchinitiative.loinc2hpocore.codesystems.ShortCode) Test(org.junit.jupiter.api.Test)

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