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]");
}
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());
}
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"));
}
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));
}
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;
}
Aggregations