Search in sources :

Example 1 with ResourceTemplateProvider

use of org.ehrbase.fhirbridge.ehr.ResourceTemplateProvider in project fhir-bridge by ehrbase.

the class AbstractSetupIT method setup.

@BeforeAll
static void setup() throws URISyntaxException {
    CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
    credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("myuser", "myPassword432"));
    CloseableHttpClient httpClient = HttpClientBuilder.create().setDefaultCredentialsProvider(credentialsProvider).build();
    DefaultRestClient client = new DefaultRestClient(new OpenEhrClientConfig(new URI("http://localhost:8080/ehrbase/")), new ResourceTemplateProvider("classpath:/opt/*.opt"), httpClient);
    PATIENT_ID = UUID.randomUUID().toString();
    EhrStatus ehrStatus = new EhrStatus();
    ehrStatus.setSubject(new PartySelf(new PartyRef(new HierObjectId(PATIENT_ID), "demographic", "PERSON")));
    ehrStatus.setArchetypeNodeId("openEHR-EHR-EHR_STATUS.generic.v1");
    ehrStatus.setName(new DvText("Integration tests status"));
    client.ehrEndpoint().createEhr(ehrStatus);
}
Also used : CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) BasicCredentialsProvider(org.apache.http.impl.client.BasicCredentialsProvider) EhrStatus(com.nedap.archie.rm.ehr.EhrStatus) BasicCredentialsProvider(org.apache.http.impl.client.BasicCredentialsProvider) CredentialsProvider(org.apache.http.client.CredentialsProvider) DefaultRestClient(org.ehrbase.client.openehrclient.defaultrestclient.DefaultRestClient) URI(java.net.URI) UsernamePasswordCredentials(org.apache.http.auth.UsernamePasswordCredentials) PartySelf(com.nedap.archie.rm.generic.PartySelf) DvText(com.nedap.archie.rm.datavalues.DvText) PartyRef(com.nedap.archie.rm.support.identification.PartyRef) OpenEhrClientConfig(org.ehrbase.client.openehrclient.OpenEhrClientConfig) ResourceTemplateProvider(org.ehrbase.fhirbridge.ehr.ResourceTemplateProvider) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 2 with ResourceTemplateProvider

use of org.ehrbase.fhirbridge.ehr.ResourceTemplateProvider in project fhir-bridge by ehrbase.

the class CompositionProducer method debugMapping.

private void debugMapping(CompositionEntity composition) {
    ResourceTemplateProvider resourceTemplateProvider = new ResourceTemplateProvider("classpath:/opt/");
    resourceTemplateProvider.afterPropertiesSet();
    Unflattener unflattener = new Unflattener(resourceTemplateProvider);
    RMObject rmObject = unflattener.unflatten(composition);
    CanonicalJson canonicalJson = new CanonicalJson();
    String compositionJson = canonicalJson.marshal(rmObject);
    writeToFile(compositionJson);
}
Also used : CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) ResourceTemplateProvider(org.ehrbase.fhirbridge.ehr.ResourceTemplateProvider) Unflattener(org.ehrbase.client.flattener.Unflattener) RMObject(com.nedap.archie.rm.RMObject)

Example 3 with ResourceTemplateProvider

use of org.ehrbase.fhirbridge.ehr.ResourceTemplateProvider 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

ResourceTemplateProvider (org.ehrbase.fhirbridge.ehr.ResourceTemplateProvider)3 RMObject (com.nedap.archie.rm.RMObject)2 CanonicalJson (org.ehrbase.serialisation.jsonencoding.CanonicalJson)2 DvText (com.nedap.archie.rm.datavalues.DvText)1 EhrStatus (com.nedap.archie.rm.ehr.EhrStatus)1 PartySelf (com.nedap.archie.rm.generic.PartySelf)1 HierObjectId (com.nedap.archie.rm.support.identification.HierObjectId)1 PartyRef (com.nedap.archie.rm.support.identification.PartyRef)1 URI (java.net.URI)1 UsernamePasswordCredentials (org.apache.http.auth.UsernamePasswordCredentials)1 CredentialsProvider (org.apache.http.client.CredentialsProvider)1 BasicCredentialsProvider (org.apache.http.impl.client.BasicCredentialsProvider)1 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)1 CompositionEntity (org.ehrbase.client.classgenerator.interfaces.CompositionEntity)1 Flattener (org.ehrbase.client.flattener.Flattener)1 Unflattener (org.ehrbase.client.flattener.Unflattener)1 OpenEhrClientConfig (org.ehrbase.client.openehrclient.OpenEhrClientConfig)1 DefaultRestClient (org.ehrbase.client.openehrclient.defaultrestclient.DefaultRestClient)1 Diff (org.javers.core.diff.Diff)1 BeforeAll (org.junit.jupiter.api.BeforeAll)1