use of com.nedap.archie.rm.RMObject in project openEHR_SDK by ehrbase.
the class AutoWhereIT method testContextAutoWhere.
@Test
public void testContextAutoWhere() throws IOException {
String rootPath = "c/context";
RMObject referenceNode = aComposition.getContext();
String contains = "composition c[openEHR-EHR-COMPOSITION.test_all_types.v1]";
String csvTestSet = dirPath + "/testContextAttributesWhere.csv";
assertThat(autoWhereQuery.testItemPaths(csvTestSet, rootPath, contains, referenceNode)).isTrue();
}
use of com.nedap.archie.rm.RMObject in project openEHR_SDK by ehrbase.
the class AutoWhereIT method testInstructionAutoWhere.
@Test
public void testInstructionAutoWhere() throws IOException {
String rootPath = "i";
RMObject referenceNode = (RMObject) aComposition.itemsAtPath("/content[openEHR-EHR-SECTION.test_all_types.v1]/items[at0001]/items[at0002]/items[openEHR-EHR-INSTRUCTION.test_all_types.v1]").get(0);
String contains = "composition c[openEHR-EHR-COMPOSITION.test_all_types.v1]" + " contains section s[openEHR-EHR-SECTION.test_all_types.v1]" + " contains instruction i[openEHR-EHR-INSTRUCTION.test_all_types.v1]";
String csvTestSet = dirPath + "/testInstructionWhere.csv";
assertThat(autoWhereQuery.testItemPaths(csvTestSet, rootPath, contains, referenceNode)).isTrue();
}
use of com.nedap.archie.rm.RMObject in project openEHR_SDK by ehrbase.
the class CanonicalEhrQuery1IT method testEhrAttributesDrillDown3.
@Test
public void testEhrAttributesDrillDown3() {
String rootPath = "e/ehr_status";
RMObject referenceNode = referenceEhrStatus;
String[] attributePaths = { "archetype_node_id", "archetype_details", "archetype_details/archetype_id", "archetype_details/archetype_id/value", "archetype_details/template_id", "archetype_details/template_id/value", "archetype_details/rm_version", "subject", "is_queryable", "is_modifiable" };
for (String attributePath : attributePaths) {
String aqlSelect = rootPath + "/" + attributePath;
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("select ");
stringBuilder.append(aqlSelect);
stringBuilder.append(" from EHR e[ehr_id/value = $ehr_id]");
Query<Record1<Map>> query = Query.buildNativeQuery(stringBuilder.toString(), Map.class);
QueryResponseData result = openEhrClient.aqlEndpoint().executeRaw(query, new ParameterValue("ehr_id", ehrUUID));
List<Object> objectList = result.getRows().get(0);
assertThat(valueObject(objectList.get(0))).as(aqlSelect).isEqualTo(attributeValueAt(referenceNode, attributePath));
}
}
use of com.nedap.archie.rm.RMObject in project openEHR_SDK by ehrbase.
the class CanonicalXML method marshal.
public String marshal(RMObject rmObject, Boolean withHeader) {
StringWriter stringWriter = new StringWriter();
try {
Marshaller marshaller = JAXBUtil.getArchieJAXBContext().createMarshaller();
marshaller.setProperty("jaxb.fragment", !withHeader);
if (rmObject.getClass().getAnnotation(XmlRootElement.class) == null) {
QName qName = new QName(null, new SnakeCase(rmObject.getClass().getSimpleName()).camelToSnake());
JAXBElement<RMObject> root = new JAXBElement<>(qName, RMObject.class, rmObject);
marshaller.marshal(root, stringWriter);
} else {
marshaller.marshal(rmObject, stringWriter);
}
} catch (JAXBException e) {
throw new org.ehrbase.serialisation.exception.MarshalException(e.getMessage(), e);
}
return stringWriter.toString();
}
use of com.nedap.archie.rm.RMObject in project openEHR_SDK by ehrbase.
the class ToCompositionWalker method postHandle.
@Override
protected void postHandle(Context<T> context) {
RMObject currentRM = context.getRmObjectDeque().peek();
WebTemplateNode currentNode = context.getNodeDeque().peek();
if (currentRM instanceof Locatable) {
org.ehrbase.webtemplate.parser.NodeId nodeId = new NodeId(currentNode.getNodeId());
if (nodeId.isArchetypeId()) {
Archetyped archetyped = new Archetyped();
archetyped.setArchetypeId(new ArchetypeID(nodeId.getNodeId()));
archetyped.setRmVersion(RM_VERSION_1_4_0);
TemplateId templateId = new TemplateId();
templateId.setValue(context.getTemplateId());
archetyped.setTemplateId(templateId);
((Locatable) currentRM).setArchetypeDetails(archetyped);
((Locatable) currentRM).setArchetypeNodeId(nodeId.getNodeId());
}
}
normalise(currentRM);
}
Aggregations