Search in sources :

Example 6 with DvCodedText

use of com.nedap.archie.rm.datavalues.DvCodedText 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 7 with DvCodedText

use of com.nedap.archie.rm.datavalues.DvCodedText 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 8 with DvCodedText

use of com.nedap.archie.rm.datavalues.DvCodedText in project ehrbase by ehrbase.

the class CompositionServiceImp method getOriginalVersionComposition.

@Override
public Optional<OriginalVersion<Composition>> getOriginalVersionComposition(UUID versionedObjectUid, int version) {
    // check for valid version parameter
    if ((version == 0) || I_CompositionAccess.getLastVersionNumber(getDataAccess(), versionedObjectUid) < version) {
        throw new ObjectNotFoundException("versioned_composition", "No VERSIONED_COMPOSITION with given version: " + version);
    }
    // retrieve requested object
    I_CompositionAccess compositionAccess = I_CompositionAccess.retrieveCompositionVersion(getDataAccess(), versionedObjectUid, version);
    if (compositionAccess == null) {
        return Optional.empty();
    }
    // create data for output, i.e. fields of the OriginalVersion<Composition>
    ObjectVersionId versionId = new ObjectVersionId(versionedObjectUid + "::" + getServerConfig().getNodename() + "::" + version);
    DvCodedText lifecycleState = new DvCodedText("complete", new CodePhrase(// TODO: once lifecycle state is supported, get it here dynamically
    "532"));
    AuditDetails commitAudit = compositionAccess.getAuditDetailsAccess().getAsAuditDetails();
    ObjectRef<HierObjectId> contribution = new ObjectRef<>(new HierObjectId(compositionAccess.getContributionId().toString()), "openehr", "contribution");
    List<UUID> attestationIdList = I_AttestationAccess.retrieveListOfAttestationsByRef(getDataAccess(), compositionAccess.getAttestationRef());
    List<Attestation> attestations = // as default, gets content if available in the following lines
    null;
    if (!attestationIdList.isEmpty()) {
        attestations = new ArrayList<>();
        for (UUID id : attestationIdList) {
            I_AttestationAccess a = new AttestationAccess(getDataAccess()).retrieveInstance(id);
            attestations.add(a.getAsAttestation());
        }
    }
    ObjectVersionId precedingVersionId = null;
    // check if there is a preceding version and set it, if available
    if (version > 1) {
        // in the current scope version is an int and therefore: preceding = current - 1
        precedingVersionId = new ObjectVersionId(versionedObjectUid + "::" + getServerConfig().getNodename() + "::" + (version - 1));
    }
    Optional<CompositionDto> compositionDto = retrieve(versionedObjectUid, version);
    Composition composition = null;
    if (compositionDto.isPresent()) {
        composition = compositionDto.get().getComposition();
    }
    OriginalVersion<Composition> versionComposition = new OriginalVersion<>(versionId, precedingVersionId, composition, lifecycleState, commitAudit, contribution, null, null, attestations);
    return Optional.of(versionComposition);
}
Also used : OriginalVersion(com.nedap.archie.rm.changecontrol.OriginalVersion) Composition(com.nedap.archie.rm.composition.Composition) VersionedComposition(com.nedap.archie.rm.ehr.VersionedComposition) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) I_AttestationAccess(org.ehrbase.dao.access.interfaces.I_AttestationAccess) I_AttestationAccess(org.ehrbase.dao.access.interfaces.I_AttestationAccess) AttestationAccess(org.ehrbase.dao.access.jooq.AttestationAccess) ObjectVersionId(com.nedap.archie.rm.support.identification.ObjectVersionId) Attestation(com.nedap.archie.rm.generic.Attestation) ObjectNotFoundException(org.ehrbase.api.exception.ObjectNotFoundException) CompositionDto(org.ehrbase.response.ehrscape.CompositionDto) I_CompositionAccess(org.ehrbase.dao.access.interfaces.I_CompositionAccess) AuditDetails(com.nedap.archie.rm.generic.AuditDetails) ObjectRef(com.nedap.archie.rm.support.identification.ObjectRef) UUID(java.util.UUID) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId)

Example 9 with DvCodedText

use of com.nedap.archie.rm.datavalues.DvCodedText 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 10 with DvCodedText

use of com.nedap.archie.rm.datavalues.DvCodedText 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

DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)74 CodePhrase (com.nedap.archie.rm.datatypes.CodePhrase)56 TerminologyId (com.nedap.archie.rm.support.identification.TerminologyId)50 Test (org.junit.jupiter.api.Test)25 DvText (com.nedap.archie.rm.datavalues.DvText)17 Test (org.junit.Test)15 Composition (com.nedap.archie.rm.composition.Composition)9 ArrayList (java.util.ArrayList)9 DvDateTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)8 PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)8 PartyProxy (com.nedap.archie.rm.generic.PartyProxy)7 HierObjectId (com.nedap.archie.rm.support.identification.HierObjectId)7 List (java.util.List)7 AbstractRMObjectValidatorTest (org.ehrbase.validation.webtemplate.AbstractRMObjectValidatorTest)7 IOException (java.io.IOException)6 PersistedPartyProxy (org.ehrbase.dao.access.jooq.party.PersistedPartyProxy)6 CanonicalJson (org.ehrbase.serialisation.jsonencoding.CanonicalJson)6 FlatPathDto (org.ehrbase.webtemplate.path.flat.FlatPathDto)6 EventContext (com.nedap.archie.rm.composition.EventContext)4 DvIdentifier (com.nedap.archie.rm.datavalues.DvIdentifier)4