Skip to content

Commit cb34496

Browse files
committed
fix label generation
1 parent d4d3f71 commit cb34496

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/main/java/de/uksh/medic/etl/openehrmapper/Generator.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,20 @@ private String getElementLabel(String path, String code, String archetype) throw
842842
cache.put(newPath, (String) expr.evaluate(opt, XPathConstants.STRING));
843843
}
844844
if ("".equals(cache.get(newPath))) {
845-
return getElementLabel(path + "/../..", code, archetype);
845+
return getElementLabelLoop(path + "/..", code, archetype);
846+
}
847+
return cache.get(newPath);
848+
}
849+
850+
private String getElementLabelLoop(String path, String code, String archetype) throws Exception {
851+
String newPath = path + "/../../term_definitions[@code=\"" + code
852+
+ "\"]/items[@id=\"text\"]/text()";
853+
if (!cache.containsKey(newPath)) {
854+
XPathExpression expr = XP.compile(newPath);
855+
cache.put(newPath, (String) expr.evaluate(opt, XPathConstants.STRING));
856+
}
857+
if ("".equals(cache.get(newPath))) {
858+
return getElementLabelLoop(path + "/..", code, archetype);
846859
}
847860
return cache.get(newPath);
848861
}

0 commit comments

Comments
 (0)