Search in sources :

Example 1 with AnnotationNotFoundException

use of org.monarchinitiative.loinc2hpo.exception.AnnotationNotFoundException 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();
    }
}
Also used : AmbiguousResultsFoundException(org.monarchinitiative.loinc2hpo.exception.AmbiguousResultsFoundException) Set(java.util.Set) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept) UnrecognizedCodeException(org.monarchinitiative.loinc2hpo.exception.UnrecognizedCodeException) Observation(org.hl7.fhir.dstu3.model.Observation) HashSet(java.util.HashSet) Logger(org.apache.logging.log4j.Logger) HpoTermId4LoincTest(org.monarchinitiative.loinc2hpo.loinc.HpoTermId4LoincTest) LoincId(org.monarchinitiative.loinc2hpo.loinc.LoincId) UniversalLoinc2HPOAnnotation(org.monarchinitiative.loinc2hpo.loinc.UniversalLoinc2HPOAnnotation) Loinc2HPOAnnotation(org.monarchinitiative.loinc2hpo.loinc.Loinc2HPOAnnotation) Map(java.util.Map) FHIRException(org.hl7.fhir.exceptions.FHIRException) Code(org.monarchinitiative.loinc2hpo.codesystems.Code) AnnotationNotFoundException(org.monarchinitiative.loinc2hpo.exception.AnnotationNotFoundException) LogManager(org.apache.logging.log4j.LogManager) UnrecognizedCodeException(org.monarchinitiative.loinc2hpo.exception.UnrecognizedCodeException) AnnotationNotFoundException(org.monarchinitiative.loinc2hpo.exception.AnnotationNotFoundException) AmbiguousResultsFoundException(org.monarchinitiative.loinc2hpo.exception.AmbiguousResultsFoundException) HpoTermId4LoincTest(org.monarchinitiative.loinc2hpo.loinc.HpoTermId4LoincTest) Code(org.monarchinitiative.loinc2hpo.codesystems.Code) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)1 Observation (org.hl7.fhir.dstu3.model.Observation)1 FHIRException (org.hl7.fhir.exceptions.FHIRException)1 Code (org.monarchinitiative.loinc2hpo.codesystems.Code)1 AmbiguousResultsFoundException (org.monarchinitiative.loinc2hpo.exception.AmbiguousResultsFoundException)1 AnnotationNotFoundException (org.monarchinitiative.loinc2hpo.exception.AnnotationNotFoundException)1 UnrecognizedCodeException (org.monarchinitiative.loinc2hpo.exception.UnrecognizedCodeException)1 HpoTermId4LoincTest (org.monarchinitiative.loinc2hpo.loinc.HpoTermId4LoincTest)1 Loinc2HPOAnnotation (org.monarchinitiative.loinc2hpo.loinc.Loinc2HPOAnnotation)1 LoincId (org.monarchinitiative.loinc2hpo.loinc.LoincId)1 UniversalLoinc2HPOAnnotation (org.monarchinitiative.loinc2hpo.loinc.UniversalLoinc2HPOAnnotation)1