Search in sources :

Example 6 with GenericId

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

the class CareEntryPostprocessor method process.

/**
 * {@inheritDoc}
 */
@Override
public void process(String term, CareEntry rmObject, Map<FlatPathDto, String> values, Set<String> consumedPaths, Context<Map<FlatPathDto, String>> context) {
    Map<FlatPathDto, String> guidelineValues = FlatHelper.filter(values, term + "/_guideline_id", false);
    if (!guidelineValues.isEmpty()) {
        ObjectRef<GenericId> guidelineId = new ObjectRef<>();
        guidelineId.setId(new GenericId());
        setValue(term + "/_guideline_id", "type", guidelineValues, guidelineId::setType, String.class, consumedPaths);
        setValue(term + "/_guideline_id", "namespace", guidelineValues, guidelineId::setNamespace, String.class, consumedPaths);
        setValue(term + "/_guideline_id", "id", guidelineValues, s -> guidelineId.getId().setValue(s), String.class, consumedPaths);
        setValue(term + "/_guideline_id", "id_scheme", guidelineValues, s -> guidelineId.getId().setScheme(s), String.class, consumedPaths);
        rmObject.setGuidelineId(guidelineId);
    }
}
Also used : GenericId(com.nedap.archie.rm.support.identification.GenericId) FlatPathDto(org.ehrbase.webtemplate.path.flat.FlatPathDto) ObjectRef(com.nedap.archie.rm.support.identification.ObjectRef)

Example 7 with GenericId

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

the class DefaultValues method buildParticipation.

public static Participation buildParticipation(Collection<Map.Entry<String, String>> subValues) {
    Participation participation = new Participation();
    participation.setPerformer(new PartyIdentified());
    extractExact(subValues, "id", s -> {
        participation.getPerformer().setExternalRef(new PartyRef());
        participation.getPerformer().getExternalRef().setType("PARTY");
        GenericId id = new GenericId();
        id.setValue(s);
        participation.getPerformer().getExternalRef().setId(id);
    });
    extract(subValues, "name", ((PartyIdentified) participation.getPerformer())::setName);
    if (participation.getPerformer().getExternalRef() != null) {
        extract(subValues, "id_namespace", n -> participation.getPerformer().getExternalRef().setNamespace(n));
        extract(subValues, "id_scheme", ((GenericId) participation.getPerformer().getExternalRef().getId())::setScheme);
    }
    extract(subValues, "function", s -> participation.setFunction(new DvText(s)));
    extract(subValues, "mode", s -> {
        ParticipationMode participationMode = findEnumValueOrThrow(s, ParticipationMode.class);
        participation.setMode(new DvCodedText());
        participation.getMode().setValue(participationMode.getValue());
        participation.getMode().setDefiningCode(participationMode.toCodePhrase());
    });
    ((PartyIdentified) participation.getPerformer()).setIdentifiers(splitByIndex(filter(subValues.stream().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)), DefaultValuePath.PARTICIPATION.getPath() + "_" + "identifiers")).values().stream().map(DefaultValues::toDvIdentifier).collect(Collectors.toList()));
    return participation;
}
Also used : PartyRef(com.nedap.archie.rm.support.identification.PartyRef) Participation(com.nedap.archie.rm.generic.Participation) GenericId(com.nedap.archie.rm.support.identification.GenericId) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) ParticipationMode(org.ehrbase.client.classgenerator.shareddefinition.ParticipationMode) DvText(com.nedap.archie.rm.datavalues.DvText)

Example 8 with GenericId

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

the class AbstractValueInserter method buildPartyIdentified.

protected PartyIdentified buildPartyIdentified(DefaultValues defaultValues, DefaultValuePath<String> name, DefaultValuePath<String> id, PartyProxy partyProxy) {
    if (partyProxy == null || !PartyIdentified.class.isAssignableFrom(partyProxy.getClass())) {
        partyProxy = new PartyIdentified();
    }
    if (defaultValues.containsDefaultValue(name)) {
        ((PartyIdentified) partyProxy).setName(defaultValues.getDefaultValue(name));
    }
    if (defaultValues.containsDefaultValue(id)) {
        PartyRef partyRef = new PartyRef();
        partyRef.setNamespace(defaultValues.getDefaultValue(DefaultValuePath.ID_NAMESPACE));
        partyRef.setType("PARTY");
        partyRef.setId(new GenericId(defaultValues.getDefaultValue(id), defaultValues.getDefaultValue(DefaultValuePath.ID_SCHEME)));
        partyProxy.setExternalRef(partyRef);
    }
    addSchemeNamespace(partyProxy.getExternalRef(), defaultValues);
    return (PartyIdentified) partyProxy;
}
Also used : PartyRef(com.nedap.archie.rm.support.identification.PartyRef) GenericId(com.nedap.archie.rm.support.identification.GenericId) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified)

Example 9 with GenericId

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

the class PartyIdentifiedRMUnmarshaller method handle.

@Override
public void handle(String currentTerm, PartyIdentified rmObject, Map<FlatPathDto, String> currentValues, Context<Map<FlatPathDto, String>> context, Set<String> consumedPaths) {
    setValue(currentTerm, "name", currentValues, rmObject::setName, String.class, consumedPaths);
    if (rmObject.getName() == null) {
        // betters implementation uses /name or  /_name instead of |name for subject
        setValue(currentTerm + "/name", null, currentValues, rmObject::setName, String.class, consumedPaths);
        if (rmObject.getName() == null) {
            setValue(currentTerm + "/_name", null, currentValues, rmObject::setName, String.class, consumedPaths);
        }
    }
    rmObject.setExternalRef(new PartyRef());
    rmObject.getExternalRef().setType("PARTY");
    rmObject.getExternalRef().setId(new GenericId());
    setValue(currentTerm, "id", currentValues, rmObject.getExternalRef().getId()::setValue, String.class, consumedPaths);
    setValue(currentTerm, "id_scheme", currentValues, ((GenericId) rmObject.getExternalRef().getId())::setScheme, String.class, consumedPaths);
    setValue(currentTerm, "id_namespace", currentValues, rmObject.getExternalRef()::setNamespace, String.class, consumedPaths);
    // remove if not set
    if (rmObject.getExternalRef().getId() == null || StringUtils.isBlank(rmObject.getExternalRef().getId().getValue())) {
        rmObject.setExternalRef(null);
    }
    Map<Integer, Map<String, String>> identifiers = extractMultiValued(currentTerm, "_identifier", currentValues);
    rmObject.setIdentifiers(identifiers.values().stream().map(DefaultValues::toDvIdentifier).collect(Collectors.toList()));
    consumeAllMatching(currentTerm + PATH_DIVIDER + "_identifier", currentValues, consumedPaths, false);
}
Also used : PartyRef(com.nedap.archie.rm.support.identification.PartyRef) GenericId(com.nedap.archie.rm.support.identification.GenericId) DefaultValues(org.ehrbase.serialisation.walker.defaultvalues.DefaultValues) Map(java.util.Map)

Example 10 with GenericId

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

the class ParticipationTestIT method testParticipation.

@Test
@Ignore("see https://github.com/ehrbase/ehrbase/issues/710")
public void testParticipation() throws IOException {
    ehr = openEhrClient.ehrEndpoint().createEhr();
    Composition composition = new CanonicalJson().unmarshal(IOUtils.toString(CompositionTestDataCanonicalJson.PARTICIPATION_NO_CONTENT.getStream(), StandardCharsets.UTF_8), Composition.class);
    VersionUid versionUid = openEhrClient.compositionEndpoint(ehr).mergeRaw(composition);
    Optional<Composition> postedComposition = openEhrClient.compositionEndpoint(ehr).findRaw(versionUid.getUuid());
    assertThat(postedComposition.get()).isNotNull();
    // check the actual participation IDs and Names
    List<Participation> participations = postedComposition.get().getContext().getParticipations();
    List<String> names = participations.stream().map(p -> p.getPerformer()).map(p -> ((PartyIdentified) p).getName()).collect(Collectors.toList());
    assertThat(names).containsExactlyInAnyOrder("Dr. Marcus Johnson", "Zaza Markham");
    List<String> ids = participations.stream().map(p -> p.getPerformer()).map(p -> p.getExternalRef().getId().getValue()).collect(Collectors.toList());
    assertThat(ids).containsExactlyInAnyOrder("000", "123");
    // use the sames IDs, but change one name. This raises an exception for conflicting identity!
    ((PartyIdentified) composition.getContext().getParticipations().get(0).getPerformer()).setName("Dummy");
    try {
        openEhrClient.compositionEndpoint(ehr).mergeRaw(composition);
        fail("Didn't detect conflicting identity!");
    } catch (WrongStatusCodeException e) {
    // continue
    }
    // Now, keep the same names, but change an externalRef id
    composition = new CanonicalJson().unmarshal(IOUtils.toString(CompositionTestDataCanonicalJson.PARTICIPATION_NO_CONTENT.getStream(), StandardCharsets.UTF_8), Composition.class);
    composition.getContext().getParticipations().get(0).getPerformer().getExternalRef().setId(new GenericId("ABC", "HOSPITAL-NS"));
    versionUid = openEhrClient.compositionEndpoint(ehr).mergeRaw(composition);
    postedComposition = openEhrClient.compositionEndpoint(ehr).findRaw(versionUid.getUuid());
    assertThat(postedComposition.get()).isNotNull();
    // check the actual participation IDs and Names
    participations = postedComposition.get().getContext().getParticipations();
    names = participations.stream().map(p -> p.getPerformer()).map(p -> ((PartyIdentified) p).getName()).collect(Collectors.toList());
    assertThat(names).containsExactlyInAnyOrder("Dr. Marcus Johnson", "Zaza Markham");
    ids = participations.stream().map(p -> p.getPerformer()).map(p -> p.getExternalRef().getId().getValue()).collect(Collectors.toList());
    assertThat(ids).containsExactlyInAnyOrder("ABC", "123");
    // use the same name and id, but in another namespace
    composition = new CanonicalJson().unmarshal(IOUtils.toString(CompositionTestDataCanonicalJson.PARTICIPATION_NO_CONTENT.getStream(), StandardCharsets.UTF_8), Composition.class);
    composition.getContext().getParticipations().get(0).getPerformer().getExternalRef().setNamespace("ANOTHER_NAMESPACE");
    versionUid = openEhrClient.compositionEndpoint(ehr).mergeRaw(composition);
    postedComposition = openEhrClient.compositionEndpoint(ehr).findRaw(versionUid.getUuid());
    assertThat(postedComposition.get()).isNotNull();
    // check the actual participation IDs and Names
    participations = postedComposition.get().getContext().getParticipations();
    List<String> namespaces = participations.stream().map(p -> p.getPerformer()).map(p -> p.getExternalRef().getNamespace()).collect(Collectors.toList());
    assertThat(namespaces).containsExactlyInAnyOrder("ANOTHER_NAMESPACE", "ANOTHER-HOSPITAL-NS");
}
Also used : Language(org.ehrbase.client.classgenerator.shareddefinition.Language) org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.definition(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.definition) Composition(com.nedap.archie.rm.composition.Composition) VersionUid(org.ehrbase.client.openehrclient.VersionUid) URISyntaxException(java.net.URISyntaxException) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Containment(org.ehrbase.client.aql.containment.Containment) BefundObservationContainment(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.definition.BefundObservationContainment) VirologischerBefundCompositionContainment(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.VirologischerBefundCompositionContainment) Record2(org.ehrbase.client.aql.record.Record2) Record4(org.ehrbase.client.aql.record.Record4) Record3(org.ehrbase.client.aql.record.Record3) GenericId(com.nedap.archie.rm.support.identification.GenericId) After(org.junit.After) KulturClusterContainment(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.definition.KulturClusterContainment) EhrFields(org.ehrbase.client.aql.field.EhrFields) StandortschlusselDefiningCode(org.ehrbase.client.classgenerator.examples.patientenaufenthaltcomposition.definition.StandortschlusselDefiningCode) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) ProbeClusterContainment(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.definition.ProbeClusterContainment) OpenEhrClient(org.ehrbase.client.openehrclient.OpenEhrClient) UUID(java.util.UUID) AufnahmedatenAdminEntryContainment(org.ehrbase.client.classgenerator.examples.stationarerversorgungsfallcomposition.definition.AufnahmedatenAdminEntryContainment) Category(org.junit.experimental.categories.Category) EntlassungsdatenAdminEntryContainment(org.ehrbase.client.classgenerator.examples.stationarerversorgungsfallcomposition.definition.EntlassungsdatenAdminEntryContainment) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) Assertions.fail(org.assertj.core.api.Assertions.fail) Query(org.ehrbase.client.aql.query.Query) PatientenaufenthaltCompositionContainment(org.ehrbase.client.classgenerator.examples.patientenaufenthaltcomposition.PatientenaufenthaltCompositionContainment) Optional(java.util.Optional) TestData(org.ehrbase.client.TestData) CoronaAnamneseComposition(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.CoronaAnamneseComposition) NativeSelectAqlField(org.ehrbase.client.aql.field.NativeSelectAqlField) VersorgungsortAdminEntryContainment(org.ehrbase.client.classgenerator.examples.patientenaufenthaltcomposition.definition.VersorgungsortAdminEntryContainment) BeforeClass(org.junit.BeforeClass) StandortClusterContainment(org.ehrbase.client.classgenerator.examples.patientenaufenthaltcomposition.definition.StandortClusterContainment) CoronaAnamneseCompositionContainment(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.CoronaAnamneseCompositionContainment) ProVirusClusterContainment(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.definition.ProVirusClusterContainment) Condition(org.ehrbase.client.aql.condition.Condition) ContainmentExpression(org.ehrbase.client.aql.containment.ContainmentExpression) Parameter(org.ehrbase.client.aql.parameter.Parameter) TemporalAccessor(java.time.temporal.TemporalAccessor) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) Flattener(org.ehrbase.client.flattener.Flattener) EntityQuery(org.ehrbase.client.aql.query.EntityQuery) PartyProxy(com.nedap.archie.rm.generic.PartyProxy) Integration(org.ehrbase.client.Integration) Tuple(org.assertj.core.groups.Tuple) CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) CompositionTestDataCanonicalJson(org.ehrbase.test_data.composition.CompositionTestDataCanonicalJson) TestDataTemplateProvider(org.ehrbase.client.templateprovider.TestDataTemplateProvider) WrongStatusCodeException(org.ehrbase.client.exception.WrongStatusCodeException) Test(org.junit.Test) IOException(java.io.IOException) Participation(com.nedap.archie.rm.generic.Participation) VirologischerBefundComposition(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.VirologischerBefundComposition) Ignore(org.junit.Ignore) StationarerVersorgungsfallCompositionContainment(org.ehrbase.client.classgenerator.examples.stationarerversorgungsfallcomposition.StationarerVersorgungsfallCompositionContainment) AbteilungsfallClusterContainment(org.ehrbase.client.classgenerator.examples.patientenaufenthaltcomposition.definition.AbteilungsfallClusterContainment) Participation(com.nedap.archie.rm.generic.Participation) Composition(com.nedap.archie.rm.composition.Composition) CoronaAnamneseComposition(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.CoronaAnamneseComposition) VirologischerBefundComposition(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.VirologischerBefundComposition) CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) CompositionTestDataCanonicalJson(org.ehrbase.test_data.composition.CompositionTestDataCanonicalJson) VersionUid(org.ehrbase.client.openehrclient.VersionUid) GenericId(com.nedap.archie.rm.support.identification.GenericId) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) WrongStatusCodeException(org.ehrbase.client.exception.WrongStatusCodeException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

GenericId (com.nedap.archie.rm.support.identification.GenericId)18 PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)10 PartyRef (com.nedap.archie.rm.support.identification.PartyRef)8 ObjectId (com.nedap.archie.rm.support.identification.ObjectId)7 ObjectRef (com.nedap.archie.rm.support.identification.ObjectRef)7 Map (java.util.Map)7 Composition (com.nedap.archie.rm.composition.Composition)5 PartyProxy (com.nedap.archie.rm.generic.PartyProxy)5 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)5 Entry (com.nedap.archie.rm.composition.Entry)4 Participation (com.nedap.archie.rm.generic.Participation)4 OffsetDateTime (java.time.OffsetDateTime)4 Test (org.junit.Test)4 WorkflowIdTest (care.better.platform.web.template.WorkflowIdTest)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 Section (com.nedap.archie.rm.composition.Section)3 DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)3 DvText (com.nedap.archie.rm.datavalues.DvText)3 DvDateTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)3