Search in sources :

Example 61 with Composition

use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.

the class FlatJsonUnmarshallerTest method unmarshalAllTypes.

@Test
public void unmarshalAllTypes() throws IOException, XmlException {
    OPERATIONALTEMPLATE template = TemplateDocument.Factory.parse(OperationalTemplateTestData.ALL_TYPES.getStream()).getTemplate();
    WebTemplate webTemplate = new OPTParser(template).parse();
    FlatJsonUnmarshaller cut = new FlatJsonUnmarshaller();
    String flat = IOUtils.toString(CompositionTestDataSimSDTJson.ALL_TYPES.getStream(), StandardCharsets.UTF_8);
    Composition actual = cut.unmarshal(flat, webTemplate);
    assertThat(actual).isNotNull();
    // Choice Node was correctly parsed
    Object choice = actual.itemAtPath("/content[openEHR-EHR-EVALUATION.test_all_types.v1]/data[at0001]/items[at0009]/value");
    assertThat(choice).isNotNull();
    assertThat(choice.getClass()).isEqualTo(DvQuantity.class);
    assertThat(((DvQuantity) choice).getMagnitude()).isEqualTo(148.01210165023804d);
    assertThat(((DvQuantity) choice).getUnits()).isEqualTo("mm[H20]");
}
Also used : OPERATIONALTEMPLATE(org.openehr.schemas.v1.OPERATIONALTEMPLATE) Composition(com.nedap.archie.rm.composition.Composition) DvQuantity(com.nedap.archie.rm.datavalues.quantity.DvQuantity) WebTemplate(org.ehrbase.webtemplate.model.WebTemplate) OPTParser(org.ehrbase.webtemplate.parser.OPTParser) Test(org.junit.Test)

Example 62 with Composition

use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.

the class NullFlavorTestOverwritten method nullFlavourMapBuild.

@Test
public void nullFlavourMapBuild() throws Exception {
    String template = this.getFileContent("/res/Demo Vitals.xml");
    String json = this.getFileContent("/res/NullFlavor4.json");
    Composition unmarshal = getFlatJson(template, FlatFormat.SIM_SDT).unmarshal(json);
    assertThat(unmarshal).isNotNull();
    Element element1 = (Element) unmarshal.itemsAtPath("/content[openEHR-EHR-SECTION.ispek_dialog.v1]/items[openEHR-EHR-OBSERVATION.lab_test-hba1c.v1,2]/data/events[at0003]/data/items[at0.63]").get(0);
    assertThat(element1.getValue()).isNull();
    assertThat(element1.getNullFlavour()).isEqualTo(NullFlavour.NO_INFORMATION.toCodedText());
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) Element(com.nedap.archie.rm.datastructures.Element) Test(org.junit.jupiter.api.Test) NullFlavorTest(care.better.platform.web.template.NullFlavorTest)

Example 63 with Composition

use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.

the class RussianBuilderTestOverwrite method testVaccinationCardYear.

@Override
@Test
public void testVaccinationCardYear() throws Exception {
    String template = this.getFileContent("/res/openEHR-EHR-COMPOSITION.vaccination_card.opt");
    String structuredJson = this.getFileContent("/res/ru-composition.json").replace(",\"end_time\":[\"2019-05-06T14:56:57.670+03:00\"]", "");
    Composition marshal = Helper.getFlatJson(template, FlatFormat.STRUCTURED).unmarshal(structuredJson);
    String flatJson = Helper.getFlatJson(template, FlatFormat.SIM_SDT).marshal(marshal);
    Map<String, Object> retrieve = new ObjectMapper().readValue(flatJson, Map.class);
    Assertions.assertThat(retrieve).contains(Assertions.entry("карта_профилактических_прививок/туберкулезные_пробы/заготовка_заголовка:0/результат_иммунодиагностики/дата", "2013"));
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) RussianBuilderTest(care.better.platform.web.template.RussianBuilderTest) Test(org.junit.Test)

Example 64 with Composition

use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.

the class OtherParticipationsQueryTestIT method testQueryOtherParticipations.

@Test
public void testQueryOtherParticipations() throws IOException {
    ehr = openEhrClient.ehrEndpoint().createEhr();
    Composition composition = new CanonicalJson().unmarshal(IOUtils.toString(CompositionTestDataCanonicalJson.OTHER_PARTICIPATIONS.getStream(), StandardCharsets.UTF_8), Composition.class);
    VersionUid versionUid = openEhrClient.compositionEndpoint(ehr).mergeRaw(composition);
    Query query = Query.buildNativeQuery("Select c0/content[openEHR-EHR-ACTION.minimal.v1]/other_participations/performer/name as performer_name" + " from EHR e[ehr_id/value = $ehr_id] contains (COMPOSITION c0[openEHR-EHR-COMPOSITION.minimal.v1])" + " WHERE c0/uid/value = $comp_uuid ");
    QueryResponseData result = openEhrClient.aqlEndpoint().executeRaw(query, new ParameterValue("ehr_id", ehr), new ParameterValue("comp_uuid", versionUid.getUuid()));
    List expectedResults = Arrays.asList(List.of("Frederick Wolfstein"));
    assertTrue(CollectionUtils.isEqualCollection(result.getRows(), expectedResults));
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) CompositionTestDataCanonicalJson(org.ehrbase.test_data.composition.CompositionTestDataCanonicalJson) VersionUid(org.ehrbase.client.openehrclient.VersionUid) Query(org.ehrbase.client.aql.query.Query) ParameterValue(org.ehrbase.client.aql.parameter.ParameterValue) QueryResponseData(org.ehrbase.response.openehr.QueryResponseData) List(java.util.List) Test(org.junit.Test)

Example 65 with Composition

use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.

the class DefaultRestCompositionEndpoint method mergeCompositionEntity.

@Override
public <T> T mergeCompositionEntity(T entity) {
    Composition composition = (Composition) new Unflattener(defaultRestClient.getTemplateProvider(), defaultRestClient.getDefaultValuesProvider()).unflatten(entity);
    Optional<VersionUid> versionUid = extractVersionUid(entity);
    final VersionUid updatedVersion = internalMerge(composition, versionUid.orElse(null));
    Flattener.addVersion(entity, updatedVersion);
    entity = (T) new Flattener(defaultRestClient.getTemplateProvider()).flatten(composition, entity.getClass());
    Flattener.addVersion(entity, updatedVersion);
    return entity;
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) VersionUid(org.ehrbase.client.openehrclient.VersionUid) Flattener(org.ehrbase.client.flattener.Flattener) Unflattener(org.ehrbase.client.flattener.Unflattener)

Aggregations

Composition (com.nedap.archie.rm.composition.Composition)138 Test (org.junit.Test)103 CanonicalJson (org.ehrbase.serialisation.jsonencoding.CanonicalJson)66 CompositionTestDataCanonicalJson (org.ehrbase.test_data.composition.CompositionTestDataCanonicalJson)53 LightRawJsonEncoder (org.ehrbase.serialisation.dbencoding.rawjson.LightRawJsonEncoder)30 TestDataTemplateProvider (org.ehrbase.client.templateprovider.TestDataTemplateProvider)29 RMDataFormat (org.ehrbase.serialisation.RMDataFormat)28 IOException (java.io.IOException)21 List (java.util.List)21 CoronaAnamneseComposition (org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.CoronaAnamneseComposition)20 Tuple (org.assertj.core.groups.Tuple)19 EhrbaseBloodPressureSimpleDeV0Composition (org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition)19 StandardCharsets (java.nio.charset.StandardCharsets)18 IOUtils (org.apache.commons.io.IOUtils)18 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)18 EhrbaseMultiOccurrenceDeV1Composition (org.ehrbase.client.classgenerator.examples.ehrbasemultioccurrencedev1composition.EhrbaseMultiOccurrenceDeV1Composition)18 OPERATIONALTEMPLATE (org.openehr.schemas.v1.OPERATIONALTEMPLATE)18 EpisodeOfCareComposition (org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.EpisodeOfCareComposition)17 CompositionTestDataCanonicalXML (org.ehrbase.test_data.composition.CompositionTestDataCanonicalXML)17 WebTemplate (org.ehrbase.webtemplate.model.WebTemplate)16