Search in sources :

Example 6 with LoincId

use of org.monarchinitiative.loinc2hpocore.loinc.LoincId in project loinc2hpo by monarch-initiative.

the class Loinc2HpoAnnotation method fromAnnotationLine.

public static Loinc2HpoAnnotation fromAnnotationLine(String line) {
    String[] fields = line.split("\t");
    if (fields.length != EXPECTED_NUMBER_OF_FIELDS) {
        System.err.printf("Malformed line with %d fields: %s%n", fields.length, line);
    }
    LoincId loincId = new LoincId(fields[0]);
    LoincScale scale = LoincScale.fromString(fields[1]);
    TermId hpoId = TermId.of(fields[3]);
    String curation = fields[5];
    String comment = fields[6];
    String outcomeString = fields[2];
    Outcome outcome;
    if (scale.equals(LoincScale.NOMINAL)) {
        outcome = Outcome.nominal(outcomeString);
    } else {
        outcome = new Outcome(ShortCode.fromShortCode(outcomeString));
    }
    if (fields[4].equals(".")) {
        return new Loinc2HpoAnnotation(loincId, scale, outcome, hpoId, curation, comment);
    }
    TermId supplementalId = TermId.of(fields[4]);
    return new Loinc2HpoAnnotation(loincId, scale, outcome, hpoId, supplementalId, curation, comment);
}
Also used : Outcome(org.monarchinitiative.loinc2hpocore.codesystems.Outcome) LoincId(org.monarchinitiative.loinc2hpocore.loinc.LoincId) TermId(org.monarchinitiative.phenol.ontology.data.TermId)

Example 7 with LoincId

use of org.monarchinitiative.loinc2hpocore.loinc.LoincId in project loinc2hpo by monarch-initiative.

the class Dstu3ObservationTest method testGlucoseLow.

@Test
void testGlucoseLow() throws IOException {
    String jsonPath = "json/glucoseLow.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.LOW(), opt2.get());
    assertNotEquals(Outcome.NORMAL(), 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 8 with LoincId

use of org.monarchinitiative.loinc2hpocore.loinc.LoincId in project loinc2hpo by monarch-initiative.

the class ObservationWithCodedValueTest method testEcoliBloodCulture.

@Test
public void testEcoliBloodCulture() {
    Observation ecoliObservation = ecoliNoInterpretationBloodCulture();
    Uberobservation uberobservation = new ObservationDtu3(ecoliObservation);
    LoincId loincId = new LoincId("600-7");
    Optional<LoincId> loincOpt = uberobservation.getLoincId();
    assertTrue(loincOpt.isPresent());
    assertEquals(loincId, loincOpt.get());
    Optional<Outcome> outcomeOpt = uberobservation.getOutcome();
    assertTrue(outcomeOpt.isPresent());
    Outcome outcome = outcomeOpt.get();
    assertTrue(outcome.isNominal());
    assertEquals("112283007:http://snomed.info/sct:Escherichia coli", outcome.getOutcome());
}
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 9 with LoincId

use of org.monarchinitiative.loinc2hpocore.loinc.LoincId in project loinc2hpo by monarch-initiative.

the class AnnotationQcCommand method run.

@Override
public void run() {
    System.out.println(annotPath);
    Loinc2HpoAnnotationParser parser = new Loinc2HpoAnnotationParser(annotPath);
    List<Loinc2HpoAnnotation> entries = parser.getEntries();
    System.out.println("[INFO] Got " + entries.size() + " LOINC annotations.");
    Ontology ontology = OntologyLoader.loadOntology(new File(hpJsonPath));
    System.out.println("[INFO] Got " + ontology.countNonObsoleteTerms() + " HPO terms in hp.json.");
    checkValidityOfHpoTerms(entries, ontology);
    Map<LoincId, LoincAnnotation> mymap = parser.loincToHpoAnnotationMap();
    System.out.println("[INFO] " + mymap.size() + " annotated LOINC terms");
    checkValidityOfLoincAnnotations(mymap);
}
Also used : Ontology(org.monarchinitiative.phenol.ontology.data.Ontology) Loinc2HpoAnnotation(org.monarchinitiative.loinc2hpocore.annotation.Loinc2HpoAnnotation) LoincId(org.monarchinitiative.loinc2hpocore.loinc.LoincId) Loinc2HpoAnnotationParser(org.monarchinitiative.loinc2hpocore.io.Loinc2HpoAnnotationParser) LoincAnnotation(org.monarchinitiative.loinc2hpocore.annotation.LoincAnnotation) File(java.io.File)

Aggregations

LoincId (org.monarchinitiative.loinc2hpocore.loinc.LoincId)9 Outcome (org.monarchinitiative.loinc2hpocore.codesystems.Outcome)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 File (java.io.File)1 Loinc2HpoAnnotation (org.monarchinitiative.loinc2hpocore.annotation.Loinc2HpoAnnotation)1 LoincAnnotation (org.monarchinitiative.loinc2hpocore.annotation.LoincAnnotation)1 Loinc2HpoAnnotationParser (org.monarchinitiative.loinc2hpocore.io.Loinc2HpoAnnotationParser)1 Ontology (org.monarchinitiative.phenol.ontology.data.Ontology)1 TermId (org.monarchinitiative.phenol.ontology.data.TermId)1