Skip to content

Commit

Permalink
prepare for xml export, fix first level labels
Browse files Browse the repository at this point in the history
  • Loading branch information
nr23730 committed Feb 29, 2024
1 parent 8a45b5d commit aeadff8
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/main/java/de/uksh/medic/etl/openehrmapper/EHRParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Map;
import javax.xml.bind.JAXBException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
Expand All @@ -29,7 +30,7 @@

public class EHRParser {
public String build(Map<String, Object> map)
throws ParserConfigurationException, SAXException, XPathExpressionException, IOException {
throws ParserConfigurationException, SAXException, XPathExpressionException, IOException, JAXBException {
String file = "oBDS_ST.opt";
String pathContent = "/template/definition[rm_type_name = \"COMPOSITION\"]"
+ "/attributes[rm_attribute_name=\"content\"]";
Expand Down Expand Up @@ -79,18 +80,24 @@ public String build(Map<String, Object> map)

ArrayList<ContentItem> content = new ArrayList<ContentItem>();
composition.setContent(content);
Generator.processAttributeChildren(pathContent, "", content, applyMap);
Generator.processAttributeChildren(pathContent, composition.getArchetypeNodeId(), content, applyMap);

EventContext context = new EventContext(new DvDateTime((String) map.get("start_time")),
new DvCodedText("other care", new CodePhrase(new TerminologyId("openehr"), "238")));
composition.setContext(context);
ItemTree itemTree = new ItemTree();
context.setOtherContext(itemTree);
Generator.processAttributeChildren(pathContext, "", itemTree, applyMap);
Generator.processAttributeChildren(pathContext, composition.getArchetypeNodeId(), itemTree, applyMap);

System.out.println("Finished JSON-Generation. Generating String.");

String ehr = JacksonUtil.getObjectMapper().writeValueAsString(composition);

// Marshaller marshaller = JAXBUtil.getArchieJAXBContext().createMarshaller();
// StringWriter writer = new StringWriter();
// marshaller.marshal(composition, writer);
// String ehr = writer.toString();

return ehr;

}
Expand Down

0 comments on commit aeadff8

Please sign in to comment.