Search in sources :

Example 1 with DvIdentifier

use of com.nedap.archie.rm.datavalues.DvIdentifier in project fhir-bridge by ehrbase.

the class ReferenceToPartyIdentifiedConverter method convert.

@Override
public PartyIdentified convert(Reference source) {
    if (source == null) {
        return null;
    }
    PartyIdentified partyIdentified = new PartyIdentified();
    DvIdentifier identifier = new DvIdentifier();
    if (source.hasReference()) {
        identifier.setId(source.getReference());
    } else if (source.hasIdentifier()) {
        identifier.setAssigner(source.getIdentifier().getSystem());
        identifier.setId(source.getIdentifier().getValue());
    } else {
        throw new ConversionException("Reference should have either a reference or an identifier");
    }
    partyIdentified.addIdentifier(identifier);
    return partyIdentified;
}
Also used : ConversionException(org.ehrbase.fhirbridge.ehr.converter.ConversionException) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) DvIdentifier(com.nedap.archie.rm.datavalues.DvIdentifier)

Example 2 with DvIdentifier

use of com.nedap.archie.rm.datavalues.DvIdentifier in project fhir-bridge by ehrbase.

the class DvIdentifierParser method parseIdentifierIntoDvIdentifier.

public static DvIdentifier parseIdentifierIntoDvIdentifier(Identifier identifier) {
    DvIdentifier dvIdentifier = new DvIdentifier();
    setDvIdentifierAssinger(dvIdentifier, identifier);
    setDvIdentifierId(dvIdentifier, identifier);
    setDvIdentifierType(dvIdentifier, identifier);
    return dvIdentifier;
}
Also used : DvIdentifier(com.nedap.archie.rm.datavalues.DvIdentifier)

Example 3 with DvIdentifier

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

the class ContextAccess method mapRmEventContext.

/**
 * @throws InternalServerException on failure of decoding DvText or DvDateTime
 */
@Override
public EventContext mapRmEventContext() {
    // get the facility entry
    PartyIdentifiedRecord partyIdentifiedRecord = getContext().fetchOne(PARTY_IDENTIFIED, PARTY_IDENTIFIED.ID.eq(eventContextRecord.getFacility()));
    // facility identifiers
    PartyIdentified healthCareFacility = null;
    if (partyIdentifiedRecord != null) {
        List<DvIdentifier> identifiers = new ArrayList<>();
        getContext().fetch(IDENTIFIER, IDENTIFIER.PARTY.eq(partyIdentifiedRecord.getId())).forEach(record -> {
            DvIdentifier dvIdentifier = new DvIdentifier();
            dvIdentifier.setIssuer(record.getIssuer());
            dvIdentifier.setAssigner(record.getAssigner());
            dvIdentifier.setId(record.getIdValue());
            dvIdentifier.setType(record.getTypeName());
            identifiers.add(dvIdentifier);
        });
        // get PartyRef values from record
        healthCareFacility = getPartyIdentifiedFromRecord(partyIdentifiedRecord, identifiers);
    }
    List<Participation> participationList = new ArrayList<>();
    // get the participations
    getContext().fetch(PARTICIPATION, PARTICIPATION.EVENT_CONTEXT.eq(eventContextRecord.getId())).forEach(record -> {
        // retrieve performer
        PartyProxy performer = new PersistedPartyProxy(this).retrieve(record.getPerformer());
        DvInterval<DvDateTime> dvInterval = convertDvIntervalDvDateTimeFromRecord(record);
        DvCodedText mode = convertModeFromRecord(record);
        Participation participation = new Participation(performer, (DvText) new RecordedDvCodedText().fromDB(record, PARTICIPATION.FUNCTION), mode, dvInterval);
        participationList.add(participation);
    });
    DvCodedText concept = (DvCodedText) new RecordedDvCodedText().fromDB(eventContextRecord, EVENT_CONTEXT.SETTING);
    ItemStructure otherContext = null;
    if (eventContextRecord.getOtherContext() != null) {
        otherContext = new RawJson().unmarshal((eventContextRecord.getOtherContext().data()), ItemStructure.class);
    }
    return new EventContext(healthCareFacility, new RecordedDvDateTime().decodeDvDateTime(eventContextRecord.getStartTime(), eventContextRecord.getStartTimeTzid()), new RecordedDvDateTime().decodeDvDateTime(eventContextRecord.getEndTime(), eventContextRecord.getEndTimeTzid()), participationList.isEmpty() ? null : participationList, eventContextRecord.getLocation(), concept, otherContext);
}
Also used : Participation(com.nedap.archie.rm.generic.Participation) PartyIdentifiedRecord(org.ehrbase.jooq.pg.tables.records.PartyIdentifiedRecord) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) RecordedDvCodedText(org.ehrbase.service.RecordedDvCodedText) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) RawJson(org.ehrbase.serialisation.dbencoding.RawJson) ArrayList(java.util.ArrayList) ItemStructure(com.nedap.archie.rm.datastructures.ItemStructure) DvIdentifier(com.nedap.archie.rm.datavalues.DvIdentifier) PersistedPartyProxy(org.ehrbase.dao.access.jooq.party.PersistedPartyProxy) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) RecordedDvDateTime(org.ehrbase.service.RecordedDvDateTime) EventContext(com.nedap.archie.rm.composition.EventContext) RecordedDvDateTime(org.ehrbase.service.RecordedDvDateTime) RecordedDvCodedText(org.ehrbase.service.RecordedDvCodedText) PersistedPartyProxy(org.ehrbase.dao.access.jooq.party.PersistedPartyProxy) PartyProxy(com.nedap.archie.rm.generic.PartyProxy)

Example 4 with DvIdentifier

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

the class BaseServiceImp method getUserUuid.

/**
 * Get default user UUID, derived from authenticated user via Spring Security.<br> Internally
 * checks and retrieves the matching user UUID, if it already exists with given info.
 *
 * @return UUID of default user, derived from authenticated user.
 */
protected UUID getUserUuid() {
    var name = authenticationFacade.getAuthentication().getName();
    List<DvIdentifier> identifiers = new ArrayList<>();
    var identifier = new DvIdentifier();
    identifier.setId(name);
    identifier.setIssuer("EHRbase");
    identifier.setAssigner("EHRbase");
    identifier.setType("EHRbase Security Authentication User");
    identifiers.add(identifier);
    // for matching name + identifiers. So it will find already created parties for existing users.
    return new PersistedPartyProxy(getDataAccess()).getOrCreate("EHRbase Internal " + name, UUID.randomUUID().toString(), DEMOGRAPHIC, "User", PARTY, identifiers);
}
Also used : ArrayList(java.util.ArrayList) DvIdentifier(com.nedap.archie.rm.datavalues.DvIdentifier) PersistedPartyProxy(org.ehrbase.dao.access.jooq.party.PersistedPartyProxy)

Example 5 with DvIdentifier

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

the class UnflattenerTest method testUnflattenEpsiode.

@Test
public void testUnflattenEpsiode() {
    EpisodeOfCareComposition episode = buildEpisodeOfCareComposition();
    Unflattener cut = new Unflattener(new TestDataTemplateProvider());
    Composition actual = (Composition) cut.unflatten(episode);
    assertThat(actual).isNotNull();
    assertThat(actual.getContent()).size().isEqualTo(1);
    AdminEntry actualAdminEntry = (AdminEntry) actual.getContent().get(0);
    List<Object> identifiers = actualAdminEntry.itemsAtPath("/data[at0001]/items[at0002]/value");
    assertThat(identifiers).extracting(i -> ((DvIdentifier) i).getId()).containsExactlyInAnyOrder("123", "456");
    List<Object> uris = actualAdminEntry.itemsAtPath("/data[at0001]/items[at0013]/value");
    assertThat(uris).extracting(u -> ((DvURI) u).getValue()).containsExactlyInAnyOrder(URI.create("https://github.com/ehrbase"));
}
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) 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) AdminEntry(com.nedap.archie.rm.composition.AdminEntry) EpisodeOfCareComposition(org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.EpisodeOfCareComposition) TestDataTemplateProvider(org.ehrbase.client.templateprovider.TestDataTemplateProvider) DvIdentifier(com.nedap.archie.rm.datavalues.DvIdentifier) DvURI(com.nedap.archie.rm.datavalues.DvURI) Test(org.junit.Test)

Aggregations

DvIdentifier (com.nedap.archie.rm.datavalues.DvIdentifier)21 PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)10 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)6 Composition (com.nedap.archie.rm.composition.Composition)4 Observation (com.nedap.archie.rm.composition.Observation)3 DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)3 DvDateTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)3 PartySelf (com.nedap.archie.rm.generic.PartySelf)3 GenericId (com.nedap.archie.rm.support.identification.GenericId)3 IOException (java.io.IOException)3 StandardCharsets (java.nio.charset.StandardCharsets)3 OffsetDateTime (java.time.OffsetDateTime)3 ZoneOffset (java.time.ZoneOffset)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 IOUtils (org.apache.commons.io.IOUtils)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 Tuple (org.assertj.core.groups.Tuple)3 PersistedPartyProxy (org.ehrbase.dao.access.jooq.party.PersistedPartyProxy)3