Search in sources :

Example 6 with TerminologyId

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

the class EntryAccess method retrieveInstanceInCompositionVersion.

public static List<I_EntryAccess> retrieveInstanceInCompositionVersion(I_DomainAccess domainAccess, I_CompositionAccess compositionHistoryAccess, int version) {
    Result<EntryHistoryRecord> entryHistoryRecords = domainAccess.getContext().selectFrom(ENTRY_HISTORY).where(ENTRY_HISTORY.COMPOSITION_ID.eq(compositionHistoryAccess.getId())).and(ENTRY_HISTORY.SYS_TRANSACTION.eq(compositionHistoryAccess.getSysTransaction())).fetch();
    // build the list of parameters to recreate the composition
    Map<SystemValue, Object> values = new HashMap<>();
    values.put(SystemValue.COMPOSER, new PersistedPartyProxy(domainAccess).retrieve(compositionHistoryAccess.getComposerId()));
    EventContext context = I_ContextAccess.retrieveHistoricalEventContext(domainAccess, compositionHistoryAccess.getId(), compositionHistoryAccess.getSysTransaction());
    if (context == null) {
        // unchanged context use the current one!
        // also optional handling of context, because persistent compositions don't have a context
        compositionHistoryAccess.getContextId().ifPresent(uuid -> I_ContextAccess.retrieveInstance(domainAccess, uuid).mapRmEventContext());
    }
    values.put(SystemValue.CONTEXT, context);
    values.put(SystemValue.LANGUAGE, new CodePhrase(new TerminologyId("ISO_639-1"), compositionHistoryAccess.getLanguageCode()));
    String territory2letters = domainAccess.getContext().fetchOne(TERRITORY, TERRITORY.CODE.eq(compositionHistoryAccess.getTerritoryCode())).getTwoletter();
    values.put(SystemValue.TERRITORY, new CodePhrase(new TerminologyId("ISO_3166-1"), territory2letters));
    values.put(SystemValue.FEEDER_AUDIT, new FeederAuditEncoding().fromDB(compositionHistoryAccess.getFeederAudit()));
    List<I_EntryAccess> content = new ArrayList<>();
    try {
        EntryAccess entryAccess = new EntryAccess(domainAccess);
        for (EntryHistoryRecord record : entryHistoryRecords) {
            // set the record UID in the composition
            UUID compositionId = compositionHistoryAccess.getId();
            values.put(SystemValue.UID, new ObjectVersionId(compositionId.toString() + "::" + domainAccess.getServerConfig().getNodename() + "::" + version));
            entryAccess.entryRecord = domainAccess.getContext().newRecord(ENTRY);
            entryAccess.entryRecord.from(record);
            entryAccess.composition = new RawJson().unmarshal(record.getEntry().data(), Composition.class);
            setCompositionAttributes(entryAccess.composition, values);
            buildArchetypeDetails(entryAccess);
            content.add(entryAccess);
        }
    } catch (Exception e) {
        throw new IllegalArgumentException(DB_INCONSISTENCY + e);
    }
    return content;
}
Also used : TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) I_EntryAccess(org.ehrbase.dao.access.interfaces.I_EntryAccess) Composition(com.nedap.archie.rm.composition.Composition) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) HashMap(java.util.HashMap) RawJson(org.ehrbase.serialisation.dbencoding.RawJson) EntryHistoryRecord(org.ehrbase.jooq.pg.tables.records.EntryHistoryRecord) ArrayList(java.util.ArrayList) ObjectVersionId(com.nedap.archie.rm.support.identification.ObjectVersionId) InternalServerException(org.ehrbase.api.exception.InternalServerException) PersistedPartyProxy(org.ehrbase.dao.access.jooq.party.PersistedPartyProxy) I_EntryAccess(org.ehrbase.dao.access.interfaces.I_EntryAccess) EventContext(com.nedap.archie.rm.composition.EventContext) FeederAuditEncoding(org.ehrbase.serialisation.dbencoding.rmobject.FeederAuditEncoding) UUID(java.util.UUID)

Example 7 with TerminologyId

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

the class AuditDetailsAccess method getAsAuditDetails.

@Override
public AuditDetails getAsAuditDetails() {
    String systemId = getSystemId().toString();
    PartyProxy party = new PersistedPartyProxy(this).retrieve(getCommitter());
    DvDateTime time = new DvDateTime(getTimeCommitted().toLocalDateTime());
    DvCodedText changeType = new DvCodedText(getChangeType().getLiteral(), new CodePhrase(new TerminologyId("openehr"), Integer.toString(I_ConceptAccess.ContributionChangeType.valueOf(getChangeType().getLiteral().toUpperCase()).getCode())));
    DvText description = new DvText(getDescription());
    return new AuditDetails(systemId, party, time, changeType, description);
}
Also used : TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) PartyProxy(com.nedap.archie.rm.generic.PartyProxy) PersistedPartyProxy(org.ehrbase.dao.access.jooq.party.PersistedPartyProxy) AuditDetails(com.nedap.archie.rm.generic.AuditDetails) PersistedPartyProxy(org.ehrbase.dao.access.jooq.party.PersistedPartyProxy) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) DvText(com.nedap.archie.rm.datavalues.DvText)

Example 8 with TerminologyId

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

the class UnflattenerTest method testUnflattenEhrbaseBloodPressureSimpleDeV0.

@Test
public void testUnflattenEhrbaseBloodPressureSimpleDeV0() {
    Unflattener cut = new Unflattener(new TestDataTemplateProvider());
    EhrbaseBloodPressureSimpleDeV0Composition dto = buildEhrbaseBloodPressureSimpleDeV0();
    Composition rmObject = (Composition) cut.unflatten(dto);
    assertThat(rmObject).isNotNull();
    assertThat(rmObject.getContext().getParticipations()).extracting(p -> ((PartyIdentified) p.getPerformer()).getName(), p -> p.getFunction().getValue()).containsExactlyInAnyOrder(new Tuple("Test", "Pos1"), new Tuple("Test2", "Pos2"));
    assertThat(rmObject.getLanguage()).extracting(CodePhrase::getCodeString, c -> c.getTerminologyId().getValue()).containsExactly("de", "ISO_639-1");
    assertThat(rmObject.getArchetypeDetails().getTemplateId().getValue()).isEqualTo("ehrbase_blood_pressure_simple.de.v0");
    assertThat(rmObject.itemAtPath("/context/start_time/value")).isEqualTo(dto.getStartTimeValue());
    List<Object> observationList = rmObject.itemsAtPath("/content[openEHR-EHR-OBSERVATION.sample_blood_pressure.v1]");
    assertThat(observationList).size().isEqualTo(1);
    Observation observation = (Observation) observationList.get(0);
    DvCodedText expected = new DvCodedText("Fifth sound", new CodePhrase(new TerminologyId("local"), "at1012"));
    assertThat(observation.itemAtPath("/protocol[at0011]/items[at1010]/value")).isEqualTo(expected);
    assertThat(observation.getSubject()).isNotNull().extracting(Object::getClass).isEqualTo(PartySelf.class);
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) EhrbaseBloodPressureSimpleDeV0Composition(org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) LaborergebnisObservation(org.ehrbase.client.classgenerator.examples.befundderblutgasanalysecomposition.definition.LaborergebnisObservation) EhrbaseMultiOccurrenceDeV1Composition(org.ehrbase.client.classgenerator.examples.ehrbasemultioccurrencedev1composition.EhrbaseMultiOccurrenceDeV1Composition) GrosseLangeObservation(org.ehrbase.client.classgenerator.examples.korpergrossecomposition.definition.GrosseLangeObservation) Element(com.nedap.archie.rm.datastructures.Element) Duration(java.time.Duration) Locatable(com.nedap.archie.rm.archetyped.Locatable) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) URI(java.net.URI) ZoneOffset(java.time.ZoneOffset) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) DvQuantity(com.nedap.archie.rm.datavalues.quantity.DvQuantity) DvIdentifier(com.nedap.archie.rm.datavalues.DvIdentifier) PartySelf(com.nedap.archie.rm.generic.PartySelf) Tuple(org.assertj.core.groups.Tuple) KorpergrosseComposition(org.ehrbase.client.classgenerator.examples.korpergrossecomposition.KorpergrosseComposition) CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) CompositionTestDataCanonicalJson(org.ehrbase.test_data.composition.CompositionTestDataCanonicalJson) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) DvText(com.nedap.archie.rm.datavalues.DvText) TestDataTemplateProvider(org.ehrbase.client.templateprovider.TestDataTemplateProvider) Test(org.junit.Test) IOException(java.io.IOException) PointEvent(com.nedap.archie.rm.datastructures.PointEvent) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) WebTemplate(org.ehrbase.webtemplate.model.WebTemplate) IOUtils(org.apache.commons.io.IOUtils) KohlendioxidpartialdruckCluster(org.ehrbase.client.classgenerator.examples.befundderblutgasanalysecomposition.definition.KohlendioxidpartialdruckCluster) EpisodeOfCareComposition(org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.EpisodeOfCareComposition) Observation(com.nedap.archie.rm.composition.Observation) List(java.util.List) AlternativeEventsComposition(org.ehrbase.client.classgenerator.examples.alternativeeventscomposition.AlternativeEventsComposition) OffsetDateTime(java.time.OffsetDateTime) BefundDerBlutgasanalyseComposition(org.ehrbase.client.classgenerator.examples.befundderblutgasanalysecomposition.BefundDerBlutgasanalyseComposition) Assert.assertFalse(org.junit.Assert.assertFalse) Optional(java.util.Optional) TestData(org.ehrbase.client.TestData) IntervalEvent(com.nedap.archie.rm.datastructures.IntervalEvent) TestAllTypesEnV1Composition(org.ehrbase.client.classgenerator.examples.testalltypesenv1composition.TestAllTypesEnV1Composition) AdminEntry(com.nedap.archie.rm.composition.AdminEntry) DvURI(com.nedap.archie.rm.datavalues.DvURI) TestAllTypesEvaluation(org.ehrbase.client.classgenerator.examples.testalltypesenv1composition.definition.TestAllTypesEvaluation) CoronaAnamneseComposition(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.CoronaAnamneseComposition) TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) Composition(com.nedap.archie.rm.composition.Composition) EhrbaseBloodPressureSimpleDeV0Composition(org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition) EhrbaseMultiOccurrenceDeV1Composition(org.ehrbase.client.classgenerator.examples.ehrbasemultioccurrencedev1composition.EhrbaseMultiOccurrenceDeV1Composition) KorpergrosseComposition(org.ehrbase.client.classgenerator.examples.korpergrossecomposition.KorpergrosseComposition) EpisodeOfCareComposition(org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.EpisodeOfCareComposition) AlternativeEventsComposition(org.ehrbase.client.classgenerator.examples.alternativeeventscomposition.AlternativeEventsComposition) BefundDerBlutgasanalyseComposition(org.ehrbase.client.classgenerator.examples.befundderblutgasanalysecomposition.BefundDerBlutgasanalyseComposition) TestAllTypesEnV1Composition(org.ehrbase.client.classgenerator.examples.testalltypesenv1composition.TestAllTypesEnV1Composition) CoronaAnamneseComposition(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.CoronaAnamneseComposition) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) TestDataTemplateProvider(org.ehrbase.client.templateprovider.TestDataTemplateProvider) LaborergebnisObservation(org.ehrbase.client.classgenerator.examples.befundderblutgasanalysecomposition.definition.LaborergebnisObservation) GrosseLangeObservation(org.ehrbase.client.classgenerator.examples.korpergrossecomposition.definition.GrosseLangeObservation) Observation(com.nedap.archie.rm.composition.Observation) EhrbaseBloodPressureSimpleDeV0Composition(org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition) Tuple(org.assertj.core.groups.Tuple) Test(org.junit.Test)

Example 9 with TerminologyId

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

the class TermMappingTestOverwritten method testTermMappingFromJson.

@Override
@Test
public void testTermMappingFromJson() throws Exception {
    String template = this.getFileContent("/res/Demo Vitals.xml");
    String rawJson = this.getFileContent("/res/TmComposition.json");
    Composition unmarshal = new CanonicalJson().unmarshal(rawJson.replace("\"@class\"", "\"_type\""), Composition.class);
    String structuredJson = getFlatJson(template, FlatFormat.STRUCTURED).marshal(unmarshal);
    Composition actualComposition = getFlatJson(template, FlatFormat.STRUCTURED).unmarshal(structuredJson);
    List<TermMapping> termMappings = ((DvText) actualComposition.itemsAtPath("/content[openEHR-EHR-SECTION.ispek_dialog.v1]/items[openEHR-EHR-OBSERVATION.body_temperature-zn.v1]/data[at0002]/events/data/items[at0.63]/value").get(0)).getMappings();
    assertThat(termMappings).extracting(TermMapping::getMatch, t -> t.getTarget().getCodeString(), t -> t.getTarget().getTerminologyId().getValue(), TermMapping::getPurpose).containsExactlyInAnyOrder(new Tuple('=', "21794005", "SNOMED-CT", null), new Tuple('=', "W.11.7", "RTX", null));
    List<TermMapping> termMappings2 = ((DvText) actualComposition.itemsAtPath("/content[openEHR-EHR-SECTION.ispek_dialog.v1]/items[openEHR-EHR-OBSERVATION.body_temperature-zn.v1]/data[at0002]/events/state/items[at0041]/value").get(0)).getMappings();
    assertThat(termMappings2).extracting(TermMapping::getMatch, t -> t.getTarget().getCodeString(), t -> t.getTarget().getTerminologyId().getValue(), TermMapping::getPurpose).containsExactlyInAnyOrder(new Tuple('=', "99.1", "IAXA", new DvCodedText("Purpose 1", new CodePhrase(new TerminologyId("Purposes"), "p.0.63.1"))));
}
Also used : TermMapping(com.nedap.archie.rm.datavalues.TermMapping) Tuple(org.assertj.core.groups.Tuple) CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) Composition(com.nedap.archie.rm.composition.Composition) TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) DvText(com.nedap.archie.rm.datavalues.DvText) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Test(org.junit.jupiter.api.Test) TermMappingTest(care.better.platform.web.template.TermMappingTest) List(java.util.List) Helper.getFlatJson(org.ehrbase.conformance_test.extern.Helper.getFlatJson) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) TermMapping(com.nedap.archie.rm.datavalues.TermMapping) FlatFormat(org.ehrbase.serialisation.flatencoding.FlatFormat) TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) Composition(com.nedap.archie.rm.composition.Composition) CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) Tuple(org.assertj.core.groups.Tuple) DvText(com.nedap.archie.rm.datavalues.DvText) Test(org.junit.jupiter.api.Test) TermMappingTest(care.better.platform.web.template.TermMappingTest)

Example 10 with TerminologyId

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

the class CodeSetAccessTest method testCodeSetAccess.

@Test
public void testCodeSetAccess() throws Exception {
    TerminologyInterface simpleTerminologyInterface = new SimpleTerminologyInterface("en");
    CodeSetAccess codeSetAccess = simpleTerminologyInterface.codeSetForId(OpenEHRCodeSetIdentifiers.INTEGRITY_CHECK_ALGORITHMS);
    assertEquals("openehr_integrity_check_algorithms", codeSetAccess.id());
    assertEquals(2, codeSetAccess.allCodes().size());
    assertTrue(codeSetAccess.hasCode(new CodePhrase(new TerminologyId("openehr_integrity_check_algorithms"), "SHA-1")));
}
Also used : TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) TerminologyInterface(org.ehrbase.terminology.openehr.TerminologyInterface) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) CodeSetAccess(org.ehrbase.terminology.openehr.CodeSetAccess) Test(org.junit.Test)

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