From 5d386b449590d0254dcc25bb87936ac8cc1337f6 Mon Sep 17 00:00:00 2001 From: Niklas Reimer Date: Tue, 5 Mar 2024 18:49:18 +0100 Subject: [PATCH] implement xds enveloping --- iti41.xml | 265 ++++++++++++++++++ .../java/de/uksh/medic/etl/OpenEhrObds.java | 18 +- 2 files changed, 280 insertions(+), 3 deletions(-) create mode 100644 iti41.xml diff --git a/iti41.xml b/iti41.xml new file mode 100644 index 0000000..ac950ed --- /dev/null +++ b/iti41.xml @@ -0,0 +1,265 @@ + + + + 9f48bcfe-592c-49db-872c-4b2194695940 + urn:ihe:iti:2007:ProvideAndRegisterDocumentSet-b + + + + + + + + + + + UKSH^^^^^^^^^1.2.276.0.76.3.1.454.1.2.1 + + + + + FA Innere Medizin und (SP) Kardiologie + + + + + + + MPIID^^^&1.2.276.0.76.3.1.454.1.11.100&ISO + + + + + + 1.3.6.1.4.1.19376.3.276.1.5.12 + + + + + + + + + + + + + + 20231216014613 + + + + + + + + + + + + Original + + + + + + + + UKSH^^^^^^^^^1.2.276.0.76.3.1.454.1.2.1 + + + + + FA Innere Medizin und (SP) Kardiologie + + + + + + + + + + + + + + + + + 1.3.6.1.4.1.19376.3.276.1.5.8 + + + + + + + + + + 2.16.840.1.113883.5.25 + + + + + + + + + + 1.3.6.1.4.1.19376.1.2.3 + + + + + + + + + + 1.3.6.1.4.1.19376.3.276.1.5.2 + + + + + + + + + + 1.3.6.1.4.1.19376.3.276.1.5.5 + + + + + + + + + + 1.3.6.1.4.1.19376.3.276.1.5.9 + + + + + + + + + 20231216014613 + + + + + de-DE + + + + + MPIID^^^&1.2.276.0.76.3.1.454.1.11.100&ISO + + + + + 1.2.276.0.76.3.1.454.1.1.102 + + + + + 20231216014613 + + + + + 20231216014613 + + + + + + EHRCONTENT + + + \ No newline at end of file diff --git a/src/main/java/de/uksh/medic/etl/OpenEhrObds.java b/src/main/java/de/uksh/medic/etl/OpenEhrObds.java index 61fab35..1cc7c15 100644 --- a/src/main/java/de/uksh/medic/etl/OpenEhrObds.java +++ b/src/main/java/de/uksh/medic/etl/OpenEhrObds.java @@ -23,6 +23,7 @@ import java.io.IOException; import java.io.InputStream; import java.net.URISyntaxException; +import java.nio.file.Files; import java.util.*; import java.util.Map.Entry; import java.util.stream.Collectors; @@ -78,7 +79,7 @@ public static void main(String[] args) throws IOException { // ToDo: Replace with Kafka consumer - File f = new File("st.xml"); + File f = new File("op.xml"); Map m = new LinkedHashMap<>(); walkXmlTree(xmlMapper.readValue(f, new TypeReference>() { @@ -233,8 +234,19 @@ private static Map convertMdr(Set> xml private static void buildOpenEhrComposition(Map data) { EHRParser ep = new EHRParser(); try (BufferedWriter writer = new BufferedWriter( - new FileWriter(i++ + "_" + ((List) data.get("ehr_id")).get(0) + ".json"))) { - writer.write(ep.build(data)); + new FileWriter(i + "_" + ((List) data.get("ehr_id")).get(0) + ".json"))) { + String ehr = ep.build(data); + writer.write(ehr); + String content = Files.readString(new File("iti41.xml").toPath()); + content = content.replaceAll("MPIID", ((List) data.get("ehr_id")).get(0)); + content = content.replaceAll("EHRCONTENT", new String(Base64.getEncoder().encode(ehr.getBytes()))); + content = content.replace("UUID1", UUID.randomUUID().toString()); + content = content.replace("UUID2", UUID.randomUUID().toString()); + content = content.replace("TIMESTAMP", String.valueOf(System.currentTimeMillis())); + BufferedWriter writerXDS = new BufferedWriter( + new FileWriter(i++ + "_" + ((List) data.get("ehr_id")).get(0) + ".xml")); + writerXDS.write(content); + writerXDS.close(); } catch (XPathExpressionException | IOException | ParserConfigurationException | SAXException | JAXBException e) { // TODO Auto-generated catch block