use of org.monarchinitiative.loinc2hpocore.codesystems.Outcome 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);
}
use of org.monarchinitiative.loinc2hpocore.codesystems.Outcome 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();
}
}
use of org.monarchinitiative.loinc2hpocore.codesystems.Outcome in project loinc2hpo by monarch-initiative.
the class ObservationDtu3 method getOutcomeFromCodedValue.
Optional<Outcome> getOutcomeFromCodedValue() {
CodeableConcept codeableConcept = this.observation.getValueCodeableConcept();
if (codeableConcept == null) {
// should never happen
LOGGER.error("Codable concept null in getOutcomeFromCodedValue");
}
List<Coding> codings = codeableConcept != null ? codeableConcept.getCoding() : List.of();
for (Coding coding : codings) {
String code = coding.getCode();
String system = coding.getSystem();
String display = coding.getDisplay();
String outcomeString = code + ":" + system + ":" + display;
Outcome outcome = Outcome.nominal(outcomeString);
return Optional.of(outcome);
}
return Optional.empty();
}
use of org.monarchinitiative.loinc2hpocore.codesystems.Outcome 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();
}
}
use of org.monarchinitiative.loinc2hpocore.codesystems.Outcome in project loinc2hpo by monarch-initiative.
the class ObservationR5 method getOutcomeFromCodedValue.
Optional<Outcome> getOutcomeFromCodedValue() {
CodeableConcept codeableConcept = this.observation.getValueCodeableConcept();
if (codeableConcept == null) {
// should never happen
LOGGER.error("Codable concept null in getOutcomeFromCodedValue");
}
List<Coding> codings = codeableConcept != null ? codeableConcept.getCoding() : List.of();
for (Coding coding : codings) {
String code = coding.getCode();
String system = coding.getSystem();
String display = coding.getDisplay();
String outcomeString = code + ":" + system + ":" + display;
Outcome outcome = Outcome.nominal(outcomeString);
return Optional.of(outcome);
}
return Optional.empty();
}
Aggregations