Search in sources :

Example 1 with OpenEhrClient

use of org.ehrbase.client.openehrclient.OpenEhrClient in project fhir-bridge by ehrbase.

the class CompositionComponent method doInit.

@Override
protected void doInit() throws Exception {
    if (configuration.getOpenEhrClient() == null && isAllowAutoWiredOpenEhrClient()) {
        Set<OpenEhrClient> beans = getCamelContext().getRegistry().findByType(OpenEhrClient.class);
        if (beans.size() == 1) {
            OpenEhrClient client = beans.iterator().next();
            configuration.setOpenEhrClient(client);
        } else if (beans.size() > 1) {
            LOG.debug("Cannot autowire OpenEhrClient as {} instances found in registry.", beans.size());
        }
    }
    super.doStart();
}
Also used : OpenEhrClient(org.ehrbase.client.openehrclient.OpenEhrClient)

Example 2 with OpenEhrClient

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

the class DefaultRestCompositionEndpointIT method testSaveCompositionWithDefaultEntity.

@Test
public void testSaveCompositionWithDefaultEntity() throws URISyntaxException {
    openEhrClient = setupDefaultRestClientWithDefaultProvider(o -> {
        DefaultValues defaultValues = new DefaultValues();
        defaultValues.addDefaultValue(DefaultValuePath.END_TIME, OffsetDateTime.of(2019, 05, 03, 22, 00, 00, 00, ZoneOffset.UTC));
        Participation participation = new Participation(new PartyIdentified(null, "Dr. Peter", null), new DvText("Performer"), ParticipationMode.PHYSICALLY_PRESENT.toCodedText(), null);
        defaultValues.addDefaultValue(DefaultValuePath.PARTICIPATION, new ArrayList<>(Collections.singleton(participation)));
        return defaultValues;
    });
    ehr = openEhrClient.ehrEndpoint().createEhr();
    EhrbaseBloodPressureSimpleDeV0Composition bloodPressureSimpleDeV0 = TestData.buildEhrbaseBloodPressureSimpleDeV0WithEmptyFields();
    // Not set during creation
    assertThat(bloodPressureSimpleDeV0.getEndTimeValue()).isNull();
    assertThat(bloodPressureSimpleDeV0.getParticipations()).isEmpty();
    // during saving default values will be set
    bloodPressureSimpleDeV0 = openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(bloodPressureSimpleDeV0);
    assertThat(bloodPressureSimpleDeV0.getEndTimeValue()).isEqualTo(OffsetDateTime.of(2019, 05, 03, 22, 00, 00, 00, ZoneOffset.UTC));
    assertThat(bloodPressureSimpleDeV0.getParticipations()).extracting(p -> ((PartyIdentified) p.getPerformer()).getName(), p -> p.getMode().getValue()).containsExactlyInAnyOrder(new Tuple("Dr. Peter", "physically present"));
}
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) Participation(com.nedap.archie.rm.generic.Participation) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) ArrayList(java.util.ArrayList) DefaultValues(org.ehrbase.serialisation.walker.defaultvalues.DefaultValues) EhrbaseBloodPressureSimpleDeV0Composition(org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition) Tuple(org.assertj.core.groups.Tuple) DvText(com.nedap.archie.rm.datavalues.DvText) Test(org.junit.Test)

Aggregations

Composition (com.nedap.archie.rm.composition.Composition)1 DvText (com.nedap.archie.rm.datavalues.DvText)1 Participation (com.nedap.archie.rm.generic.Participation)1 PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)1 PartySelf (com.nedap.archie.rm.generic.PartySelf)1 IOException (java.io.IOException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 StandardCharsets (java.nio.charset.StandardCharsets)1 OffsetDateTime (java.time.OffsetDateTime)1 ZoneOffset (java.time.ZoneOffset)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Optional (java.util.Optional)1 UUID (java.util.UUID)1 Enhancer (net.sf.cglib.proxy.Enhancer)1 MethodInterceptor (net.sf.cglib.proxy.MethodInterceptor)1 IOUtils (org.apache.commons.io.IOUtils)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.assertThatNoException (org.assertj.core.api.Assertions.assertThatNoException)1