Search in sources :

Example 1 with CompositionEndpoint

use of org.ehrbase.client.openehrclient.CompositionEndpoint in project openEHR_SDK by ehrbase.

the class DefaultRestCompositionEndpointIT method testDeleteCompositionInvalidPrecedingVersionUid.

@Test
public void testDeleteCompositionInvalidPrecedingVersionUid() {
    ehr = openEhrClient.ehrEndpoint().createEhr();
    CompositionEndpoint compositionEndpoint = openEhrClient.compositionEndpoint(ehr);
    EhrbaseBloodPressureSimpleDeV0Composition composition = TestData.buildEhrbaseBloodPressureSimpleDeV0();
    composition = compositionEndpoint.mergeCompositionEntity(composition);
    composition = compositionEndpoint.mergeCompositionEntity(composition);
    VersionUid precedingVersionUid = new VersionUid(composition.getVersionUid().getUuid(), composition.getVersionUid().getSystem(), 1);
    assertThrows(WrongStatusCodeException.class, () -> compositionEndpoint.delete(precedingVersionUid));
}
Also used : CompositionEndpoint(org.ehrbase.client.openehrclient.CompositionEndpoint) VersionUid(org.ehrbase.client.openehrclient.VersionUid) EhrbaseBloodPressureSimpleDeV0Composition(org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition) Test(org.junit.Test)

Example 2 with CompositionEndpoint

use of org.ehrbase.client.openehrclient.CompositionEndpoint in project openEHR_SDK by ehrbase.

the class DefaultRestCompositionEndpointIT method testDeleteCompositionUnknownPrecedingVersionUid.

@Test
public void testDeleteCompositionUnknownPrecedingVersionUid() {
    ehr = openEhrClient.ehrEndpoint().createEhr();
    CompositionEndpoint compositionEndpoint = openEhrClient.compositionEndpoint(ehr);
    VersionUid precedingVersionUid = new VersionUid("bdd8e4f3-b587-479f-a2ff-d4143ef9ea06::local.ehrbase.org::1");
    assertThatNoException().isThrownBy(() -> compositionEndpoint.delete(precedingVersionUid));
}
Also used : CompositionEndpoint(org.ehrbase.client.openehrclient.CompositionEndpoint) VersionUid(org.ehrbase.client.openehrclient.VersionUid) Test(org.junit.Test)

Example 3 with CompositionEndpoint

use of org.ehrbase.client.openehrclient.CompositionEndpoint in project openEHR_SDK by ehrbase.

the class DefaultRestCompositionEndpointIT method testEhrbaseMultiOccurrenceDeV1.

@Test
public void testEhrbaseMultiOccurrenceDeV1() {
    ehr = openEhrClient.ehrEndpoint().createEhr();
    EhrbaseMultiOccurrenceDeV1Composition bloodPressureSimpleDeV0 = TestData.buildEhrbaseMultiOccurrenceDeV1();
    CompositionEndpoint compositionEndpoint = openEhrClient.compositionEndpoint(ehr);
    EhrbaseMultiOccurrenceDeV1Composition version1 = compositionEndpoint.mergeCompositionEntity(bloodPressureSimpleDeV0);
    Optional<EhrbaseMultiOccurrenceDeV1Composition> actual = compositionEndpoint.find(version1.getVersionUid().getUuid(), EhrbaseMultiOccurrenceDeV1Composition.class);
    assertTrue(actual.isPresent());
    BodyTemperatureObservation bodyTemperature1 = actual.get().getBodyTemperature().get(0);
    assertThat(bodyTemperature1.getAnyEvent()).extracting(e -> ((BodyTemperatureAnyEventPointEvent) e).getTemperatureMagnitude()).containsExactlyInAnyOrder(11d, 22d);
    BodyTemperatureLocationOfMeasurementChoice locationOfMeasurement1 = bodyTemperature1.getLocationOfMeasurement();
    assertThat(locationOfMeasurement1.getClass()).isEqualTo(BodyTemperatureLocationOfMeasurementDvCodedText.class);
    assertThat(((BodyTemperatureLocationOfMeasurementDvCodedText) locationOfMeasurement1).getLocationOfMeasurementDefiningCode()).isEqualTo(LocationOfMeasurementDefiningCode.FOREHEAD);
    BodyTemperatureObservation bodyTemperature2 = actual.get().getBodyTemperature().get(1);
    BodyTemperatureLocationOfMeasurementChoice locationOfMeasurement2 = bodyTemperature2.getLocationOfMeasurement();
    assertThat(locationOfMeasurement2.getClass()).isEqualTo(BodyTemperatureLocationOfMeasurementDvText.class);
    assertThat(((BodyTemperatureLocationOfMeasurementDvText) locationOfMeasurement2).getLocationOfMeasurementValue()).isEqualTo("location");
}
Also used : EhrbaseMultiOccurrenceDeV1Composition(org.ehrbase.client.classgenerator.examples.ehrbasemultioccurrencedev1composition.EhrbaseMultiOccurrenceDeV1Composition) Language(org.ehrbase.client.classgenerator.shareddefinition.Language) 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) GECCOSerologischerBefundComposition(org.ehrbase.client.classgenerator.examples.geccoserologischerbefundcomposition.GECCOSerologischerBefundComposition) EpisodeofcareTeamElement(org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.definition.EpisodeofcareTeamElement) Assertions.assertThatNoException(org.assertj.core.api.Assertions.assertThatNoException) BefundJedesEreignisPointEvent(org.ehrbase.client.classgenerator.examples.geccoserologischerbefundcomposition.definition.BefundJedesEreignisPointEvent) After(org.junit.After) URI(java.net.URI) ZoneOffset(java.time.ZoneOffset) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) MethodInterceptor(net.sf.cglib.proxy.MethodInterceptor) ProAnalytQuantitativesErgebnisDvCount(org.ehrbase.client.classgenerator.examples.geccoserologischerbefundcomposition.definition.ProAnalytQuantitativesErgebnisDvCount) org.ehrbase.client.classgenerator.examples.ehrbasemultioccurrencedev1composition.definition(org.ehrbase.client.classgenerator.examples.ehrbasemultioccurrencedev1composition.definition) OpenEhrClient(org.ehrbase.client.openehrclient.OpenEhrClient) UUID(java.util.UUID) Category(org.junit.experimental.categories.Category) StandardCharsets(java.nio.charset.StandardCharsets) AnforderungDefiningCode(org.ehrbase.client.classgenerator.examples.geccoserologischerbefundcomposition.definition.AnforderungDefiningCode) IOUtils(org.apache.commons.io.IOUtils) EpisodeOfCareComposition(org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.EpisodeOfCareComposition) ParticipationMode(org.ehrbase.client.classgenerator.shareddefinition.ParticipationMode) LabortestBezeichnungDefiningCode(org.ehrbase.client.classgenerator.examples.geccoserologischerbefundcomposition.definition.LabortestBezeichnungDefiningCode) OffsetDateTime(java.time.OffsetDateTime) OptimisticLockException(org.ehrbase.client.exception.OptimisticLockException) Optional(java.util.Optional) TestData(org.ehrbase.client.TestData) DefaultRestClientTestHelper.setupDefaultRestClientWithDefaultProvider(org.ehrbase.client.openehrclient.defaultrestclient.DefaultRestClientTestHelper.setupDefaultRestClientWithDefaultProvider) Territory(org.ehrbase.client.classgenerator.shareddefinition.Territory) BeforeClass(org.junit.BeforeClass) EhrbaseBloodPressureSimpleDeV0Composition(org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition) EhrbaseMultiOccurrenceDeV1Composition(org.ehrbase.client.classgenerator.examples.ehrbasemultioccurrencedev1composition.EhrbaseMultiOccurrenceDeV1Composition) ArrayList(java.util.ArrayList) ProVirusCluster(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.definition.ProVirusCluster) Flattener(org.ehrbase.client.flattener.Flattener) ClientException(org.ehrbase.client.exception.ClientException) Enhancer(net.sf.cglib.proxy.Enhancer) BefundObservation(org.ehrbase.client.classgenerator.examples.geccoserologischerbefundcomposition.definition.BefundObservation) PartySelf(com.nedap.archie.rm.generic.PartySelf) Integration(org.ehrbase.client.Integration) Tuple(org.assertj.core.groups.Tuple) CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) CompositionTestDataCanonicalJson(org.ehrbase.test_data.composition.CompositionTestDataCanonicalJson) DvText(com.nedap.archie.rm.datavalues.DvText) EpisodeofcareAdminEntry(org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.definition.EpisodeofcareAdminEntry) TestDataTemplateProvider(org.ehrbase.client.templateprovider.TestDataTemplateProvider) DefaultValuePath(org.ehrbase.serialisation.walker.defaultvalues.DefaultValuePath) WrongStatusCodeException(org.ehrbase.client.exception.WrongStatusCodeException) Test(org.junit.Test) IOException(java.io.IOException) Participation(com.nedap.archie.rm.generic.Participation) DefaultValues(org.ehrbase.serialisation.walker.defaultvalues.DefaultValues) KorotkoffSoundsDefiningCode(org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.definition.KorotkoffSoundsDefiningCode) VirologischerBefundComposition(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.VirologischerBefundComposition) VirusnachweistestDefiningCode(org.ehrbase.client.classgenerator.examples.geccoserologischerbefundcomposition.definition.VirusnachweistestDefiningCode) CompositionEndpoint(org.ehrbase.client.openehrclient.CompositionEndpoint) Assert(org.junit.Assert) Collections(java.util.Collections) Setting(org.ehrbase.client.classgenerator.shareddefinition.Setting) CompositionEndpoint(org.ehrbase.client.openehrclient.CompositionEndpoint) Test(org.junit.Test)

Example 4 with CompositionEndpoint

use of org.ehrbase.client.openehrclient.CompositionEndpoint in project openEHR_SDK by ehrbase.

the class DefaultRestCompositionEndpointIT method testFind.

@Test
public void testFind() {
    ehr = openEhrClient.ehrEndpoint().createEhr();
    EhrbaseBloodPressureSimpleDeV0Composition bloodPressureSimpleDeV0 = TestData.buildEhrbaseBloodPressureSimpleDeV0();
    CompositionEndpoint compositionEndpoint = openEhrClient.compositionEndpoint(ehr);
    EhrbaseBloodPressureSimpleDeV0Composition version1 = compositionEndpoint.mergeCompositionEntity(bloodPressureSimpleDeV0);
    Optional<EhrbaseBloodPressureSimpleDeV0Composition> actual = compositionEndpoint.find(version1.getVersionUid().getUuid(), EhrbaseBloodPressureSimpleDeV0Composition.class);
    assertTrue(actual.isPresent());
    assertThat(actual.get().getComposer()).isNotNull().extracting(Object::getClass).isEqualTo(PartyIdentified.class);
    PartyIdentified composer = (PartyIdentified) actual.get().getComposer();
    assertThat(composer.getName()).isEqualTo("Test");
    assertThat(actual.get().getBloodPressureTrainingSample()).size().isEqualTo(1);
    assertThat(actual.get().getBloodPressureTrainingSample().get(0).getSubject()).isNotNull().extracting(Object::getClass).isEqualTo(PartySelf.class);
    assertThat(actual.get().getBloodPressureTrainingSample().get(0).getSystolicMagnitude()).isEqualTo(22d);
    assertThat(actual.get().getBloodPressureTrainingSample().get(0).getSystolicUnits()).isEqualTo("mm[Hg]");
    assertThat(actual.get().getBloodPressureTrainingSample().get(0).getKorotkoffSoundsDefiningCode()).isEqualTo(KorotkoffSoundsDefiningCode.FIFTH_SOUND);
}
Also used : CompositionEndpoint(org.ehrbase.client.openehrclient.CompositionEndpoint) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) EhrbaseBloodPressureSimpleDeV0Composition(org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition) Test(org.junit.Test)

Example 5 with CompositionEndpoint

use of org.ehrbase.client.openehrclient.CompositionEndpoint in project openEHR_SDK by ehrbase.

the class DefaultRestCompositionEndpointIT method testEpisodeOfCare.

@Test
public void testEpisodeOfCare() {
    ehr = openEhrClient.ehrEndpoint().createEhr();
    EpisodeOfCareComposition bloodPressureSimpleDeV0 = TestData.buildEpisodeOfCareComposition();
    CompositionEndpoint compositionEndpoint = openEhrClient.compositionEndpoint(ehr);
    EpisodeOfCareComposition version1 = compositionEndpoint.mergeCompositionEntity(bloodPressureSimpleDeV0);
    Optional<EpisodeOfCareComposition> actual = compositionEndpoint.find(version1.getVersionUid().getUuid(), EpisodeOfCareComposition.class);
    assertTrue(actual.isPresent());
    assertThat(actual.get().getVersionUid()).extracting(v -> v.getUuid().toString(), VersionUid::getVersion).containsExactly(version1.getVersionUid().getUuid().toString(), 1L);
    assertThat(actual.get().getFeederAudit()).isNotNull().extracting(feederAudit -> feederAudit.getFeederSystemAudit().getSystemId(), feederAudit1 -> feederAudit1.getOriginatingSystemAudit().getSystemId()).containsExactly("System 1", "System 2");
    assertThat(actual.get().getEpisodeofcare()).size().isEqualTo(1);
    EpisodeofcareAdminEntry episodeofcareAdminEntry = actual.get().getEpisodeofcare().get(0);
    assertThat(episodeofcareAdminEntry.getIdentifier()).extracting(e -> e.getValue().getId()).containsExactlyInAnyOrder("123", "456");
    assertThat(episodeofcareAdminEntry.getTeam()).extracting(EpisodeofcareTeamElement::getValue).containsExactlyInAnyOrder(URI.create("https://github.com/ehrbase"));
}
Also used : Language(org.ehrbase.client.classgenerator.shareddefinition.Language) 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) GECCOSerologischerBefundComposition(org.ehrbase.client.classgenerator.examples.geccoserologischerbefundcomposition.GECCOSerologischerBefundComposition) EpisodeofcareTeamElement(org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.definition.EpisodeofcareTeamElement) Assertions.assertThatNoException(org.assertj.core.api.Assertions.assertThatNoException) BefundJedesEreignisPointEvent(org.ehrbase.client.classgenerator.examples.geccoserologischerbefundcomposition.definition.BefundJedesEreignisPointEvent) After(org.junit.After) URI(java.net.URI) ZoneOffset(java.time.ZoneOffset) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) MethodInterceptor(net.sf.cglib.proxy.MethodInterceptor) ProAnalytQuantitativesErgebnisDvCount(org.ehrbase.client.classgenerator.examples.geccoserologischerbefundcomposition.definition.ProAnalytQuantitativesErgebnisDvCount) org.ehrbase.client.classgenerator.examples.ehrbasemultioccurrencedev1composition.definition(org.ehrbase.client.classgenerator.examples.ehrbasemultioccurrencedev1composition.definition) OpenEhrClient(org.ehrbase.client.openehrclient.OpenEhrClient) UUID(java.util.UUID) Category(org.junit.experimental.categories.Category) StandardCharsets(java.nio.charset.StandardCharsets) AnforderungDefiningCode(org.ehrbase.client.classgenerator.examples.geccoserologischerbefundcomposition.definition.AnforderungDefiningCode) IOUtils(org.apache.commons.io.IOUtils) EpisodeOfCareComposition(org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.EpisodeOfCareComposition) ParticipationMode(org.ehrbase.client.classgenerator.shareddefinition.ParticipationMode) LabortestBezeichnungDefiningCode(org.ehrbase.client.classgenerator.examples.geccoserologischerbefundcomposition.definition.LabortestBezeichnungDefiningCode) OffsetDateTime(java.time.OffsetDateTime) OptimisticLockException(org.ehrbase.client.exception.OptimisticLockException) Optional(java.util.Optional) TestData(org.ehrbase.client.TestData) DefaultRestClientTestHelper.setupDefaultRestClientWithDefaultProvider(org.ehrbase.client.openehrclient.defaultrestclient.DefaultRestClientTestHelper.setupDefaultRestClientWithDefaultProvider) Territory(org.ehrbase.client.classgenerator.shareddefinition.Territory) BeforeClass(org.junit.BeforeClass) EhrbaseBloodPressureSimpleDeV0Composition(org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition) EhrbaseMultiOccurrenceDeV1Composition(org.ehrbase.client.classgenerator.examples.ehrbasemultioccurrencedev1composition.EhrbaseMultiOccurrenceDeV1Composition) ArrayList(java.util.ArrayList) ProVirusCluster(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.definition.ProVirusCluster) Flattener(org.ehrbase.client.flattener.Flattener) ClientException(org.ehrbase.client.exception.ClientException) Enhancer(net.sf.cglib.proxy.Enhancer) BefundObservation(org.ehrbase.client.classgenerator.examples.geccoserologischerbefundcomposition.definition.BefundObservation) PartySelf(com.nedap.archie.rm.generic.PartySelf) Integration(org.ehrbase.client.Integration) Tuple(org.assertj.core.groups.Tuple) CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) CompositionTestDataCanonicalJson(org.ehrbase.test_data.composition.CompositionTestDataCanonicalJson) DvText(com.nedap.archie.rm.datavalues.DvText) EpisodeofcareAdminEntry(org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.definition.EpisodeofcareAdminEntry) TestDataTemplateProvider(org.ehrbase.client.templateprovider.TestDataTemplateProvider) DefaultValuePath(org.ehrbase.serialisation.walker.defaultvalues.DefaultValuePath) WrongStatusCodeException(org.ehrbase.client.exception.WrongStatusCodeException) Test(org.junit.Test) IOException(java.io.IOException) Participation(com.nedap.archie.rm.generic.Participation) DefaultValues(org.ehrbase.serialisation.walker.defaultvalues.DefaultValues) KorotkoffSoundsDefiningCode(org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.definition.KorotkoffSoundsDefiningCode) VirologischerBefundComposition(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.VirologischerBefundComposition) VirusnachweistestDefiningCode(org.ehrbase.client.classgenerator.examples.geccoserologischerbefundcomposition.definition.VirusnachweistestDefiningCode) CompositionEndpoint(org.ehrbase.client.openehrclient.CompositionEndpoint) Assert(org.junit.Assert) Collections(java.util.Collections) Setting(org.ehrbase.client.classgenerator.shareddefinition.Setting) CompositionEndpoint(org.ehrbase.client.openehrclient.CompositionEndpoint) EpisodeofcareAdminEntry(org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.definition.EpisodeofcareAdminEntry) EpisodeOfCareComposition(org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.EpisodeOfCareComposition) Test(org.junit.Test)

Aggregations

CompositionEndpoint (org.ehrbase.client.openehrclient.CompositionEndpoint)7 Test (org.junit.Test)7 EhrbaseBloodPressureSimpleDeV0Composition (org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition)5 VersionUid (org.ehrbase.client.openehrclient.VersionUid)4 PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)3 Composition (com.nedap.archie.rm.composition.Composition)2 DvText (com.nedap.archie.rm.datavalues.DvText)2 Participation (com.nedap.archie.rm.generic.Participation)2 PartySelf (com.nedap.archie.rm.generic.PartySelf)2 IOException (java.io.IOException)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 StandardCharsets (java.nio.charset.StandardCharsets)2 OffsetDateTime (java.time.OffsetDateTime)2 ZoneOffset (java.time.ZoneOffset)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 Optional (java.util.Optional)2 UUID (java.util.UUID)2 Enhancer (net.sf.cglib.proxy.Enhancer)2