Search in sources :

Example 1 with TerminologyServiceException

use of org.ehrbase.fhirbridge.service.TerminologyServiceException in project fhir-bridge by ehrbase.

the class DvCodedTextParser method parseFHIRCoding.

public Optional<DvCodedText> parseFHIRCoding(Coding coding) {
    if (coding == null) {
        return Optional.empty();
    }
    if (!coding.hasSystem() || !coding.hasCode()) {
        throw new ConversionException("Coding must have a system and a code");
    }
    String display;
    if (coding.hasDisplay()) {
        display = coding.getDisplay();
    } else {
        try {
            display = getDisplay(coding.getSystem(), coding.getCode()).orElseThrow(() -> new ConversionException("Coding must have a display or TerminologyService must not be null"));
        } catch (TerminologyServiceException e) {
            throw new ConversionException("Cannot convert coding. Reason: " + e.getMessage(), e);
        }
    }
    CodePhrase codePhrase = new CodePhrase(new TerminologyId(coding.getSystem()), coding.getCode());
    return Optional.of(new DvCodedText(display, codePhrase));
}
Also used : TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) TerminologyServiceException(org.ehrbase.fhirbridge.service.TerminologyServiceException)

Aggregations

CodePhrase (com.nedap.archie.rm.datatypes.CodePhrase)1 DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)1 TerminologyId (com.nedap.archie.rm.support.identification.TerminologyId)1 TerminologyServiceException (org.ehrbase.fhirbridge.service.TerminologyServiceException)1