Search in sources :

Example 1 with TerminologyId

use of com.nedap.archie.rm.support.identification.TerminologyId 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)

Example 2 with TerminologyId

use of com.nedap.archie.rm.support.identification.TerminologyId in project ehrbase by ehrbase.

the class RecordedDvCodedTextTest method testToDB.

@Test
public void testToDB() {
    Record record = new EventContextRecord();
    DvCodedText dvCodedText = new DvCodedText("testvalue", new CodePhrase("en"), new CodePhrase("UTF-8"), new CodePhrase(new TerminologyId("terminology"), "1224"));
    TermMapping termMapping = new TermMapping(new CodePhrase(new TerminologyId("A"), "target"), Character.valueOf('>'), new DvCodedText("purpose", new CodePhrase(new TerminologyId("B"), "BBB")));
    List<TermMapping> termMappings = new ArrayList<>();
    termMappings.add(termMapping);
    dvCodedText.setMappings(termMappings);
    new RecordedDvCodedText().toDB(record, EventContext.EVENT_CONTEXT.SETTING, dvCodedText);
    DvCodedTextRecord dvCodedTextRecord = record.get(EventContext.EVENT_CONTEXT.SETTING);
    assertEquals(">", dvCodedTextRecord.getTermMapping()[0].split("|")[0]);
}
Also used : TermMapping(com.nedap.archie.rm.datavalues.TermMapping) TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) DvCodedTextRecord(org.ehrbase.jooq.pg.udt.records.DvCodedTextRecord) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) ArrayList(java.util.ArrayList) Record(org.jooq.Record) CodePhraseRecord(org.ehrbase.jooq.pg.udt.records.CodePhraseRecord) DvCodedTextRecord(org.ehrbase.jooq.pg.udt.records.DvCodedTextRecord) EventContextRecord(org.ehrbase.jooq.pg.tables.records.EventContextRecord) EventContextRecord(org.ehrbase.jooq.pg.tables.records.EventContextRecord) Test(org.junit.Test)

Example 3 with TerminologyId

use of com.nedap.archie.rm.support.identification.TerminologyId in project ehrbase by ehrbase.

the class WhereVisitorTest method testTerminologyWhereStatement.

@Test
public void testTerminologyWhereStatement() {
    FhirTerminologyServerR4AdaptorImpl mock = mock(FhirTerminologyServerR4AdaptorImpl.class);
    List<DvCodedText> result = new ArrayList<>();
    TerminologyId terminologyId = new TerminologyId("http://fhir.de/CodeSystem/dimdi/atc");
    result.add(new DvCodedText("Heparingruppe", new CodePhrase(terminologyId, "B01AB")));
    result.add(new DvCodedText("Heparin", new CodePhrase(terminologyId, "B01AB01")));
    result.add(new DvCodedText("Antithrombin III, Antithrombin alfa", new CodePhrase(terminologyId, "B01AB02")));
    result.add(new DvCodedText("Dalteparin", new CodePhrase(terminologyId, "B01AB04")));
    result.add(new DvCodedText("Nadroparin", new CodePhrase(terminologyId, "B01AB06")));
    when(mock.expandWithParameters("https: //www.netzwerk-universitaetsmedizin.de/fhir/ValueSet/anticoagulants-atc", "expand")).thenReturn(result);
    WhereVisitor cut = new WhereVisitor(mock);
    String aql = "select  a_a/data[at0002]/items[at0022] " + "from EHR e " + "contains COMPOSITION a " + "contains EVALUATION a_a[openEHR-EHR-EVALUATION.gender.v1] " + "WHERE a_a/data[at0002]/items[at0022]/value/defining_code/code_string matches{TERMINOLOGY('expand', 'hl7.org/fhir/R4', 'https: //www.netzwerk-universitaetsmedizin.de/fhir/ValueSet/anticoagulants-atc')}";
    ParseTree tree = QueryHelper.setupParseTree(aql);
    cut.visit(tree);
    List<Object> whereExpression = cut.getWhereExpression();
    assertThat(whereExpression).size().isEqualTo(13);
}
Also used : FhirTerminologyServerR4AdaptorImpl(org.ehrbase.service.FhirTerminologyServerR4AdaptorImpl) TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) ArrayList(java.util.ArrayList) ParseTree(org.antlr.v4.runtime.tree.ParseTree) Test(org.junit.Test)

Example 4 with TerminologyId

use of com.nedap.archie.rm.support.identification.TerminologyId in project ehrbase by ehrbase.

the class FhirTerminologyServerR4AdaptorImpl method expandWithParameters.

@Override
public List<DvCodedText> expandWithParameters(final String valueSetId, String... operationParams) {
    // build URL
    String urlTsServer = props.getTsUrl();
    urlTsServer += "ValueSet/$" + operationParams[0] + "?url=" + valueSetId;
    String responseBody;
    try {
        responseBody = internalGet(urlTsServer);
    } catch (IOException e) {
        throw new InternalServerException("An error occurred while expanding ValueSet " + valueSetId, e);
    }
    DocumentContext jsonContext = JsonPath.parse(responseBody);
    List<String> codeList = jsonContext.read(props.getCodePath().replace("\\", ""));
    List<String> systemList = jsonContext.read(props.getSystemPath());
    List<String> displayList = jsonContext.read(props.getDisplayPath());
    List<DvCodedText> expansionList = new ArrayList<>();
    for (int i = 0; i < codeList.size(); i++) {
        TerminologyId termId = new TerminologyId(systemList.get(i));
        CodePhrase codePhrase = new CodePhrase(termId, codeList.get(i));
        DvCodedText codedText = new DvCodedText(displayList.get(i), codePhrase);
        expansionList.add(codedText);
    }
    return expansionList;
}
Also used : TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) InternalServerException(org.ehrbase.api.exception.InternalServerException) ArrayList(java.util.ArrayList) IOException(java.io.IOException) DocumentContext(com.jayway.jsonpath.DocumentContext)

Example 5 with TerminologyId

use of com.nedap.archie.rm.support.identification.TerminologyId in project ehrbase by ehrbase.

the class FhirTerminologyServerR4AdaptorImpl method expand.

@Override
public List<DvCodedText> expand(final String valueSetId) {
    String responseBody;
    try {
        responseBody = internalGet(valueSetId);
    } catch (IOException e) {
        throw new InternalServerException("An error occurred while expanding ValueSet: " + valueSetId, e);
    }
    DocumentContext jsonContext = JsonPath.parse(responseBody);
    List<String> codeList = jsonContext.read(props.getCodePath().replace("\\", ""));
    List<String> systemList = jsonContext.read(props.getSystemPath());
    List<String> displayList = jsonContext.read(props.getDisplayPath());
    List<DvCodedText> expansionList = new ArrayList<>();
    for (int i = 0; i < codeList.size(); i++) {
        TerminologyId termId = new TerminologyId(systemList.get(i));
        CodePhrase codePhrase = new CodePhrase(termId, codeList.get(i));
        DvCodedText codedText = new DvCodedText(displayList.get(i), codePhrase);
        expansionList.add(codedText);
    }
    return expansionList;
}
Also used : TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) InternalServerException(org.ehrbase.api.exception.InternalServerException) ArrayList(java.util.ArrayList) IOException(java.io.IOException) DocumentContext(com.jayway.jsonpath.DocumentContext)

Aggregations

TerminologyId (com.nedap.archie.rm.support.identification.TerminologyId)62 CodePhrase (com.nedap.archie.rm.datatypes.CodePhrase)60 DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)50 Test (org.junit.jupiter.api.Test)23 Test (org.junit.Test)13 DvText (com.nedap.archie.rm.datavalues.DvText)10 Composition (com.nedap.archie.rm.composition.Composition)8 ArrayList (java.util.ArrayList)7 AbstractRMObjectValidatorTest (org.ehrbase.validation.webtemplate.AbstractRMObjectValidatorTest)7 PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)6 DvDateTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)5 RMObject (com.nedap.archie.rm.RMObject)4 EventContext (com.nedap.archie.rm.composition.EventContext)4 PartyProxy (com.nedap.archie.rm.generic.PartyProxy)4 List (java.util.List)4 Locatable (com.nedap.archie.rm.archetyped.Locatable)3 Entry (com.nedap.archie.rm.composition.Entry)3 DvURI (com.nedap.archie.rm.datavalues.DvURI)3 DvOrdinal (com.nedap.archie.rm.datavalues.quantity.DvOrdinal)3 PartyRelated (com.nedap.archie.rm.generic.PartyRelated)3