use of org.hl7.fhir.utilities.xls.XLSXmlNormaliser in project kindling by HL7.
the class BindingsParser method parse.
public List<BindingSpecification> parse() throws Exception {
List<BindingSpecification> results = new ArrayList<BindingSpecification>();
// BindingSpecification n = new BindingSpecification();
// n.setName("*unbound*");
// n.setBinding(BindingSpecification.Binding.Unbound);
// results.add(n);
xls = new XLSXmlParser(file, filename);
new XLSXmlNormaliser(filename, exceptionIfExcelNotNormalised).go();
Sheet sheet = xls.getSheets().get("Bindings");
for (int row = 0; row < sheet.rows.size(); row++) {
processLine(results, sheet, row);
}
return results;
}
use of org.hl7.fhir.utilities.xls.XLSXmlNormaliser in project kindling by HL7.
the class SourceParser method loadCompositeType.
private String loadCompositeType(String n, Map<String, org.hl7.fhir.definitions.model.TypeDefn> map, String fmm, boolean isAbstract) throws Exception {
TypeParser tp = new TypeParser(version.toString());
List<TypeRef> ts = tp.parse(n, false, null, context, true);
definitions.getKnownTypes().addAll(ts);
StandardsStatus status = loadStatus(n);
String nv = loadNormativeVersion(n);
try {
TypeRef t = ts.get(0);
File csv = new CSFile(dtDir + t.getName().toLowerCase() + ".xml");
if (csv.exists()) {
OldSpreadsheetParser p = new OldSpreadsheetParser("core", new CSFileInputStream(csv), csv.getName(), csv.getAbsolutePath(), definitions, srcDir, logger, registry, version, context, genDate, isAbstract, page, true, ini, wg("fhir"), definitions.getProfileIds(), fpUsages, page.getConceptMaps(), exceptionIfExcelNotNormalised, page.packageInfo(), page.getRc());
org.hl7.fhir.definitions.model.TypeDefn el = p.parseCompositeType();
el.setFmmLevel(fmm);
el.setStandardsStatus(status);
el.setNormativeVersion(nv);
map.put(t.getName(), el);
genTypeProfile(el);
errors.addAll(p.getErrors());
return el.getName();
} else {
String p = ini.getStringProperty("types", n);
csv = new CSFile(dtDir + p.toLowerCase() + ".xml");
if (!csv.exists())
throw new Exception("unable to find a definition for " + n + " in " + p);
XLSXmlParser xls = new XLSXmlParser(new CSFileInputStream(csv), csv.getAbsolutePath());
new XLSXmlNormaliser(csv.getAbsolutePath(), exceptionIfExcelNotNormalised).go();
Sheet sheet = xls.getSheets().get("Restrictions");
boolean found = false;
for (int i = 0; i < sheet.rows.size(); i++) {
if (sheet.getColumn(i, "Name").equals(n)) {
found = true;
Invariant inv = new Invariant();
inv.setId(n);
inv.setEnglish(sheet.getColumn(i, "Rules"));
inv.setOcl(sheet.getColumn(i, "OCL"));
inv.setXpath(sheet.getColumn(i, "XPath"));
inv.setExpression(sheet.getColumn(i, "Expression"));
inv.setExplanation(sheet.getColumn(i, "Explanation"));
inv.setTurtle(sheet.getColumn(i, "RDF"));
ProfiledType pt = new ProfiledType();
pt.setDefinition(sheet.getColumn(i, "Definition"));
pt.setDescription(sheet.getColumn(i, "Rules"));
String structure = sheet.getColumn(i, "Structure");
if (!Utilities.noString(structure)) {
String[] parts = structure.split("\\;");
for (String pp : parts) {
String[] words = pp.split("\\=");
pt.getRules().put(words[0], words[1]);
}
}
pt.setName(n);
pt.setBaseType(p);
pt.setInvariant(inv);
definitions.getConstraints().put(n, pt);
}
}
if (!found)
throw new Exception("Unable to find definition for " + n);
return n;
}
} catch (Exception e) {
throw new Exception("Unable to load " + n + ": " + e.getMessage(), e);
}
}
use of org.hl7.fhir.utilities.xls.XLSXmlNormaliser in project kindling by HL7.
the class SourceParser method loadStatusCodes.
private void loadStatusCodes() throws FileNotFoundException, Exception {
XLSXmlParser xml = new XLSXmlParser(new CSFileInputStream(srcDir + "status-codes.xml"), "Status Codes");
new XLSXmlNormaliser(srcDir + "status-codes.xml", exceptionIfExcelNotNormalised).go();
Sheet sheet = xml.getSheets().get("Status Codes");
for (int row = 0; row < sheet.rows.size(); row++) {
String path = sheet.getColumn(row, "Path");
ArrayList<String> codes = new ArrayList<String>();
for (int i = 1; i <= 80; i++) {
String s = sheet.getColumn(row, "c" + Integer.toString(i));
if (s.endsWith("?"))
s = s.substring(0, s.length() - 1);
codes.add(s);
}
definitions.getStatusCodes().put(path, codes);
}
}
use of org.hl7.fhir.utilities.xls.XLSXmlNormaliser in project org.hl7.fhir.core by hapifhir.
the class XLSXmlNormaliserTests method testConvert.
@Test
public void testConvert() throws FHIRException, TransformerException, ParserConfigurationException, SAXException, IOException {
XLSXmlNormaliser n = new XLSXmlNormaliser("src/test/resources/observation-spreadsheet.xml", "target/observation-spreadsheet.out.xml", true);
n.go();
// n = new XLSXmlNormaliser("C:\\work\\org.hl7.fhir\\build\\source\\observation\\observation-spreadsheet.before.xml", "C:\\\\work\\\\org.hl7.fhir\\\\build\\\\source\\\\observation\\\\observation-spreadsheet.before.out.xml", true);
// n.go();
Assertions.assertTrue(true);
}
use of org.hl7.fhir.utilities.xls.XLSXmlNormaliser in project kindling by HL7.
the class SourceParser method loadPrimitives.
private void loadPrimitives() throws Exception {
XLSXmlParser xls = new XLSXmlParser(new CSFileInputStream(dtDir + "primitives.xml"), "primitives");
new XLSXmlNormaliser(dtDir + "primitives.xml", exceptionIfExcelNotNormalised).go();
Sheet sheet = xls.getSheets().get("Imports");
for (int row = 0; row < sheet.rows.size(); row++) {
processImport(sheet, row);
}
sheet = xls.getSheets().get("Patterns");
for (int row = 0; row < sheet.rows.size(); row++) {
processStringPattern(sheet, row);
}
}
Aggregations