use of org.monarchinitiative.loinc2hpo.exception.AmbiguousResultsFoundException in project loinc2hpo by monarch-initiative.
the class ObservationAnalysisFromCodedValues method getHPOforObservation.
@Override
public HpoTermId4LoincTest getHPOforObservation() throws AmbiguousResultsFoundException, UnrecognizedCodeException, AnnotationNotFoundException {
if (annotationMap.get(loincId) == null)
throw new AnnotationNotFoundException();
Set<HpoTermId4LoincTest> results = new HashSet<>();
codedValue.getCoding().stream().filter(p -> annotationMap.get(loincId).getCodes().contains(new Code(p))).forEach(p -> results.add(annotationMap.get(loincId).loincInterpretationToHPO(new Code(p))));
if (results.size() > 1) {
throw new AmbiguousResultsFoundException();
}
if (results.size() == 1) {
return results.iterator().next();
} else {
throw new UnrecognizedCodeException();
}
}
Aggregations