Search in sources :

Example 21 with PartyIdentified

use of com.nedap.archie.rm.generic.PartyIdentified in project openEHR_SDK by ehrbase.

the class DefaultRestCompositionEndpointIT method testSaveCompositionEntityProxy.

@Test
public void testSaveCompositionEntityProxy() {
    ehr = openEhrClient.ehrEndpoint().createEhr();
    EhrbaseBloodPressureSimpleDeV0Composition bloodPressureSimpleDeV0 = TestData.buildEhrbaseBloodPressureSimpleDeV0();
    ProxyEhrbaseBloodPressureSimpleDeV0Composition proxy = new ProxyEhrbaseBloodPressureSimpleDeV0Composition();
    proxy.dummy = "dummy";
    proxy.setStartTimeValue(OffsetDateTime.of(2019, 04, 03, 22, 00, 00, 00, ZoneOffset.UTC));
    proxy.setEndTimeValue(OffsetDateTime.now());
    proxy.setBloodPressureTrainingSample(new ArrayList<>());
    proxy.setLanguage(Language.DE);
    proxy.setTerritory(Territory.DE);
    proxy.setCategoryDefiningCode(org.ehrbase.client.classgenerator.shareddefinition.Category.EVENT);
    proxy.setSettingDefiningCode(Setting.NURSING_HOME_CARE);
    proxy.setComposer(new PartyIdentified(null, "Test", null));
    proxy.setParticipations(new ArrayList<>());
    proxy.getParticipations().add(new Participation(new PartyIdentified(null, "Test", null), new DvText("Pos1"), null, null));
    proxy.getParticipations().add(new Participation(new PartyIdentified(null, "Test2", null), new DvText("Pos2"), null, null));
    proxy.setBloodPressureTrainingSample(bloodPressureSimpleDeV0.getBloodPressureTrainingSample());
    openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(proxy);
    assertThat(proxy.getVersionUid()).isNotNull();
    assertThat(proxy.getVersionUid().getVersion()).isEqualTo(1L);
    proxy.setSettingDefiningCode(Setting.EMERGENCY_CARE);
    openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(proxy);
    assertThat(proxy.getVersionUid()).isNotNull();
    assertThat(proxy.getVersionUid().getVersion()).isEqualTo(2L);
    proxy.setVersionUid(new VersionUid(proxy.getVersionUid().getUuid(), proxy.getVersionUid().getSystem(), 1L));
    try {
        openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(proxy);
        fail();
    } catch (RuntimeException e) {
        assertThat(e.getClass()).isEqualTo(OptimisticLockException.class);
    }
}
Also used : Participation(com.nedap.archie.rm.generic.Participation) VersionUid(org.ehrbase.client.openehrclient.VersionUid) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) OptimisticLockException(org.ehrbase.client.exception.OptimisticLockException) EhrbaseBloodPressureSimpleDeV0Composition(org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition) DvText(com.nedap.archie.rm.datavalues.DvText) Test(org.junit.Test)

Example 22 with PartyIdentified

use of com.nedap.archie.rm.generic.PartyIdentified 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)

Example 23 with PartyIdentified

use of com.nedap.archie.rm.generic.PartyIdentified in project openEHR_SDK by ehrbase.

the class FlattenerTest method testFlattenEhrbaseBloodPressureSimpleDeV0.

@Test
public void testFlattenEhrbaseBloodPressureSimpleDeV0() {
    Flattener cut = new Flattener(new TestDataTemplateProvider());
    EhrbaseBloodPressureSimpleDeV0Composition bloodPressureSimpleDeV0 = TestData.buildEhrbaseBloodPressureSimpleDeV0();
    RMObject rmObject = new Unflattener(new TestDataTemplateProvider()).unflatten(bloodPressureSimpleDeV0);
    EhrbaseBloodPressureSimpleDeV0Composition actual = cut.flatten((Locatable) rmObject, EhrbaseBloodPressureSimpleDeV0Composition.class);
    assertThat(actual).isNotNull();
    assertThat(actual.getComposer()).isNotNull().extracting(Object::getClass).isEqualTo(PartyIdentified.class);
    PartyIdentified composer = (PartyIdentified) actual.getComposer();
    assertThat(composer.getName()).isEqualTo("Test");
    assertThat(actual.getParticipations()).extracting(p -> ((PartyIdentified) p.getPerformer()).getName(), p -> p.getFunction().getValue()).containsExactlyInAnyOrder(new Tuple("Test", "Pos1"), new Tuple("Test2", "Pos2"));
    assertThat(actual.getBloodPressureTrainingSample()).size().isEqualTo(1);
    assertThat(actual.getBloodPressureTrainingSample().get(0).getSubject()).isNotNull().extracting(Object::getClass).isEqualTo(PartySelf.class);
    assertThat(actual.getBloodPressureTrainingSample().get(0).getSystolicMagnitude()).isEqualTo(22d);
    assertThat(actual.getBloodPressureTrainingSample().get(0).getSystolicUnits()).isEqualTo("mm[Hg]");
    assertThat(actual.getBloodPressureTrainingSample().get(0).getKorotkoffSoundsDefiningCode()).isEqualTo(KorotkoffSoundsDefiningCode.FIFTH_SOUND);
    assertThat(actual.getBloodPressureTrainingSample().get(0).getMeanArterialPressureNullFlavourDefiningCode()).isNull();
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) MathFunction(org.ehrbase.client.classgenerator.shareddefinition.MathFunction) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) EpisodeofcareTeamElement(org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.definition.EpisodeofcareTeamElement) Duration(java.time.Duration) Locatable(com.nedap.archie.rm.archetyped.Locatable) URI(java.net.URI) ZoneOffset(java.time.ZoneOffset) LocationOfMeasurementDefiningCode(org.ehrbase.client.classgenerator.examples.ehrbasemultioccurrencedev1composition.definition.LocationOfMeasurementDefiningCode) TestData.buildEpisodeOfCareComposition(org.ehrbase.client.TestData.buildEpisodeOfCareComposition) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) IOUtils(org.apache.commons.io.IOUtils) EpisodeOfCareComposition(org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.EpisodeOfCareComposition) Observation(com.nedap.archie.rm.composition.Observation) List(java.util.List) OffsetDateTime(java.time.OffsetDateTime) BodyTemperatureLocationOfMeasurementChoice(org.ehrbase.client.classgenerator.examples.ehrbasemultioccurrencedev1composition.definition.BodyTemperatureLocationOfMeasurementChoice) Event(com.nedap.archie.rm.datastructures.Event) KorpergewichtBirthEnPointEvent(org.ehrbase.client.classgenerator.examples.alternativeeventscomposition.definition.KorpergewichtBirthEnPointEvent) TestData(org.ehrbase.client.TestData) CoronaAnamneseComposition(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.CoronaAnamneseComposition) BodyTemperatureObservation(org.ehrbase.client.classgenerator.examples.ehrbasemultioccurrencedev1composition.definition.BodyTemperatureObservation) BodyTemperatureLocationOfMeasurementDvText(org.ehrbase.client.classgenerator.examples.ehrbasemultioccurrencedev1composition.definition.BodyTemperatureLocationOfMeasurementDvText) KorpergewichtAnyEventEnIntervalEvent(org.ehrbase.client.classgenerator.examples.alternativeeventscomposition.definition.KorpergewichtAnyEventEnIntervalEvent) EhrbaseBloodPressureSimpleDeV0Composition(org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition) EhrbaseMultiOccurrenceDeV1Composition(org.ehrbase.client.classgenerator.examples.ehrbasemultioccurrencedev1composition.EhrbaseMultiOccurrenceDeV1Composition) GrosseLangeObservation(org.ehrbase.client.classgenerator.examples.korpergrossecomposition.definition.GrosseLangeObservation) TestData.buildAlternativeEventsComposition(org.ehrbase.client.TestData.buildAlternativeEventsComposition) ContentItem(com.nedap.archie.rm.composition.ContentItem) ItemStructure(com.nedap.archie.rm.datastructures.ItemStructure) KorpergewichtAnyEventEnPointEvent(org.ehrbase.client.classgenerator.examples.alternativeeventscomposition.definition.KorpergewichtAnyEventEnPointEvent) BodyTemperatureAnyEventPointEvent(org.ehrbase.client.classgenerator.examples.ehrbasemultioccurrencedev1composition.definition.BodyTemperatureAnyEventPointEvent) DvQuantity(com.nedap.archie.rm.datavalues.quantity.DvQuantity) 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) EpisodeofcareAdminEntry(org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.definition.EpisodeofcareAdminEntry) TestDataTemplateProvider(org.ehrbase.client.templateprovider.TestDataTemplateProvider) NullFlavour(org.ehrbase.client.classgenerator.shareddefinition.NullFlavour) BodyTemperatureLocationOfMeasurementDvCodedText(org.ehrbase.client.classgenerator.examples.ehrbasemultioccurrencedev1composition.definition.BodyTemperatureLocationOfMeasurementDvCodedText) IOException(java.io.IOException) Test(org.junit.Test) VorhandenDefiningCode(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.definition.VorhandenDefiningCode) KorotkoffSoundsDefiningCode(org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.definition.KorotkoffSoundsDefiningCode) PointEvent(com.nedap.archie.rm.datastructures.PointEvent) AlternativeEventsComposition(org.ehrbase.client.classgenerator.examples.alternativeeventscomposition.AlternativeEventsComposition) RMObject(com.nedap.archie.rm.RMObject) IntervalEvent(com.nedap.archie.rm.datastructures.IntervalEvent) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) EhrbaseBloodPressureSimpleDeV0Composition(org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition) Tuple(org.assertj.core.groups.Tuple) TestDataTemplateProvider(org.ehrbase.client.templateprovider.TestDataTemplateProvider) RMObject(com.nedap.archie.rm.RMObject) Test(org.junit.Test)

Example 24 with PartyIdentified

use of com.nedap.archie.rm.generic.PartyIdentified in project openEHR_SDK by ehrbase.

the class EventContextUnmarshalPostprocessor method process.

/**
 * {@inheritDoc}
 */
@Override
public void process(String term, EventContext rmObject, Map<FlatPathDto, String> values, Set<String> consumedPaths, Context<Map<FlatPathDto, String>> context) {
    setValue(term + PATH_DIVIDER + "_location", null, values, rmObject::setLocation, String.class, consumedPaths);
    setValue(term + PATH_DIVIDER + "_end_time", null, values, s -> {
        if (s != null) {
            rmObject.setEndTime(new DvDateTime(s));
        }
    }, String.class, consumedPaths);
    Map<FlatPathDto, String> health_care_facilityValues = FlatHelper.filter(values, term + "/_health_care_facility", false);
    if (!health_care_facilityValues.isEmpty()) {
        rmObject.setHealthCareFacility(new PartyIdentified());
        handleRmAttribute(term, rmObject.getHealthCareFacility(), health_care_facilityValues, consumedPaths, context, "health_care_facility");
    }
    Map<Integer, Map<String, String>> other = extractMultiValued(term, "_participation", values);
    other.values().stream().map(Map::entrySet).map(s -> s.stream().collect(Collectors.toMap(e -> "ctx/" + DefaultValuePath.PARTICIPATION.getPath() + "_" + e.getKey().replace("identifiers_", "identifiers|"), e -> StringUtils.wrap(e.getValue(), '"'))).entrySet()).map(DefaultValues::buildParticipation).forEach(rmObject::addParticipation);
    consumeAllMatching(term + PATH_DIVIDER + "_participation", values, consumedPaths, false);
    // Strange Path with value true if setting = other care (238)
    consumedPaths.add(term + "/" + "setting|238");
    // Strange Path with value true if setting != other care (238)
    consumedPaths.add(term + "/" + "setting|");
    if (rmObject.getSetting() != null && (rmObject.getSetting().getDefiningCode().getTerminologyId() == null || rmObject.getSetting().getDefiningCode().getTerminologyId().getValue() == null)) {
        rmObject.getSetting().getDefiningCode().setTerminologyId(new TerminologyId("openehr"));
    }
}
Also used : Context(org.ehrbase.serialisation.walker.Context) FlatHelper(org.ehrbase.serialisation.walker.FlatHelper) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) DefaultValuePath(org.ehrbase.serialisation.walker.defaultvalues.DefaultValuePath) FlatPathDto(org.ehrbase.webtemplate.path.flat.FlatPathDto) Set(java.util.Set) DefaultValues(org.ehrbase.serialisation.walker.defaultvalues.DefaultValues) StringUtils(org.apache.commons.lang3.StringUtils) Collectors(java.util.stream.Collectors) EventContext(com.nedap.archie.rm.composition.EventContext) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) PATH_DIVIDER(org.ehrbase.webtemplate.parser.OPTParser.PATH_DIVIDER) FlatHelper.extractMultiValued(org.ehrbase.serialisation.walker.FlatHelper.extractMultiValued) Map(java.util.Map) FlatHelper.consumeAllMatching(org.ehrbase.serialisation.walker.FlatHelper.consumeAllMatching) TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) FlatPathDto(org.ehrbase.webtemplate.path.flat.FlatPathDto) Map(java.util.Map) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)

Example 25 with PartyIdentified

use of com.nedap.archie.rm.generic.PartyIdentified in project openEHR_SDK by ehrbase.

the class ParticipationConfig method buildChildValues.

/**
 * {@inheritDoc}
 */
@Override
public Map<String, Object> buildChildValues(String currentTerm, Participation rmObject, Context<Map<String, Object>> context) {
    Map<String, Object> result = new HashMap<>();
    addValue(result, currentTerm, "id", Optional.of(rmObject).map(Participation::getPerformer).map(PartyProxy::getExternalRef).map(ObjectRef::getId).map(ObjectId::getValue).orElse(null));
    addValue(result, currentTerm, "id_namespace", Optional.of(rmObject).map(Participation::getPerformer).map(PartyProxy::getExternalRef).map(ObjectRef::getNamespace).orElse(null));
    addValue(result, currentTerm, "id_scheme", Optional.of(rmObject).map(Participation::getPerformer).map(PartyProxy::getExternalRef).map(PartyRef::getId).filter(cls -> GenericId.class.isAssignableFrom(cls.getClass())).map(GenericId.class::cast).map(GenericId::getScheme).orElse(null));
    addValue(result, currentTerm, "name", Optional.of(rmObject).map(Participation::getPerformer).filter(p -> PartyIdentified.class.isAssignableFrom(p.getClass())).map(PartyIdentified.class::cast).map(PartyIdentified::getName).orElse(null));
    addValue(result, currentTerm, "mode", Optional.of(rmObject).map(Participation::getMode).map(DvText::getValue).orElse(null));
    addValue(result, currentTerm, "function", Optional.of(rmObject).map(Participation::getFunction).map(DvText::getValue).orElse(null));
    List<DvIdentifier> dvIdentifiers = Optional.of(rmObject).map(Participation::getPerformer).filter(p -> PartyIdentified.class.isAssignableFrom(p.getClass())).map(PartyIdentified.class::cast).map(PartyIdentified::getIdentifiers).orElse(Collections.emptyList());
    IntStream.range(0, dvIdentifiers.size()).forEach(i -> {
        DvIdentifier identifier = dvIdentifiers.get(i);
        addValue(result, currentTerm, "identifiers_id:" + i, identifier.getId());
        addValue(result, currentTerm, "identifiers_issuer:" + i, identifier.getIssuer());
        addValue(result, currentTerm, "identifiers_assigner:" + i, identifier.getAssigner());
        addValue(result, currentTerm, "identifiers_type:" + i, identifier.getType());
    });
    return result;
}
Also used : DvIdentifier(com.nedap.archie.rm.datavalues.DvIdentifier) PartyProxy(com.nedap.archie.rm.generic.PartyProxy) IntStream(java.util.stream.IntStream) ObjectRef(com.nedap.archie.rm.support.identification.ObjectRef) Context(org.ehrbase.serialisation.walker.Context) java.util(java.util) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) PartyRef(com.nedap.archie.rm.support.identification.PartyRef) DvText(com.nedap.archie.rm.datavalues.DvText) GenericId(com.nedap.archie.rm.support.identification.GenericId) Participation(com.nedap.archie.rm.generic.Participation) ObjectId(com.nedap.archie.rm.support.identification.ObjectId) Participation(com.nedap.archie.rm.generic.Participation) GenericId(com.nedap.archie.rm.support.identification.GenericId) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) ObjectId(com.nedap.archie.rm.support.identification.ObjectId) DvText(com.nedap.archie.rm.datavalues.DvText) DvIdentifier(com.nedap.archie.rm.datavalues.DvIdentifier) PartyProxy(com.nedap.archie.rm.generic.PartyProxy) ObjectRef(com.nedap.archie.rm.support.identification.ObjectRef)

Aggregations

PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)41 DvDateTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)12 PartySelf (com.nedap.archie.rm.generic.PartySelf)12 Participation (com.nedap.archie.rm.generic.Participation)11 GenericId (com.nedap.archie.rm.support.identification.GenericId)11 DvIdentifier (com.nedap.archie.rm.datavalues.DvIdentifier)10 Test (org.junit.Test)10 Composition (com.nedap.archie.rm.composition.Composition)9 DvText (com.nedap.archie.rm.datavalues.DvText)9 EhrbaseBloodPressureSimpleDeV0Composition (org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition)9 PartyProxy (com.nedap.archie.rm.generic.PartyProxy)8 IOException (java.io.IOException)8 StandardCharsets (java.nio.charset.StandardCharsets)8 IOUtils (org.apache.commons.io.IOUtils)8 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)8 Tuple (org.assertj.core.groups.Tuple)8 DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)7 PartyRef (com.nedap.archie.rm.support.identification.PartyRef)6 Optional (java.util.Optional)6 TestData (org.ehrbase.client.TestData)6