Search in sources :

Example 1 with CompositionEntity

use of org.ehrbase.client.classgenerator.interfaces.CompositionEntity in project fhir-bridge by ehrbase.

the class ProvideResourceResponseProcessor method process.

@Override
public void process(Exchange exchange) throws Exception {
    CompositionEntity composition = exchange.getIn().getBody(CompositionEntity.class);
    MethodOutcome outcome = exchange.getProperty(CamelConstants.OUTCOME, MethodOutcome.class);
    String resourceId = outcome.getId().getIdPart();
    ResourceComposition resourceComposition = resourceCompositionRepository.findById(resourceId).orElse(new ResourceComposition(resourceId));
    resourceComposition.setCompositionId(getCompositionId(composition));
    resourceCompositionRepository.save(resourceComposition);
    LOG.debug("Saved ResourceComposition: resourceId={}, compositionId={}", resourceComposition.getResourceId(), resourceComposition.getCompositionId());
    exchange.getMessage().setBody(outcome);
}
Also used : CompositionEntity(org.ehrbase.client.classgenerator.interfaces.CompositionEntity) ResourceComposition(org.ehrbase.fhirbridge.core.domain.ResourceComposition) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome)

Example 2 with CompositionEntity

use of org.ehrbase.client.classgenerator.interfaces.CompositionEntity in project fhir-bridge by ehrbase.

the class AbstractMappingTestSetupIT method compareCompositions.

public Diff compareCompositions(Javers javers, String paragonFilePath, CompositionEntity mappedComposition) throws IOException {
    RMObject composition = new CanonicalJson().unmarshal(testFileLoader.loadResourceToString(paragonFilePath), com.nedap.archie.rm.composition.Composition.class);
    ResourceTemplateProvider resourceTemplateProvider = new ResourceTemplateProvider("classpath:/opt/");
    resourceTemplateProvider.afterPropertiesSet();
    Flattener cut = new Flattener(resourceTemplateProvider);
    CompositionEntity paragonComposition = cut.flatten(composition, mappedComposition.getClass());
    Diff diff = javers.compare(paragonComposition, mappedComposition);
    diff.getChanges().forEach(System.out::println);
    return diff;
}
Also used : CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) ResourceTemplateProvider(org.ehrbase.fhirbridge.ehr.ResourceTemplateProvider) CompositionEntity(org.ehrbase.client.classgenerator.interfaces.CompositionEntity) Diff(org.javers.core.diff.Diff) Flattener(org.ehrbase.client.flattener.Flattener) RMObject(com.nedap.archie.rm.RMObject)

Aggregations

CompositionEntity (org.ehrbase.client.classgenerator.interfaces.CompositionEntity)2 MethodOutcome (ca.uhn.fhir.rest.api.MethodOutcome)1 RMObject (com.nedap.archie.rm.RMObject)1 Flattener (org.ehrbase.client.flattener.Flattener)1 ResourceComposition (org.ehrbase.fhirbridge.core.domain.ResourceComposition)1 ResourceTemplateProvider (org.ehrbase.fhirbridge.ehr.ResourceTemplateProvider)1 CanonicalJson (org.ehrbase.serialisation.jsonencoding.CanonicalJson)1 Diff (org.javers.core.diff.Diff)1