use of org.hl7.fhir.definitions.model.Example.ExampleType in project kindling by HL7.
the class OldSpreadsheetParser method readExamples.
private void readExamples(ResourceDefn defn, Sheet sheet) throws Exception {
if (sheet != null) {
for (int row = 0; row < sheet.rows.size(); row++) {
String name = sheet.getColumn(row, "Name");
if (name != null && !name.equals("") && !name.startsWith("!")) {
String id = sheet.getColumn(row, "Identity");
if (id == null || id.equals(""))
throw new Exception("Example " + name + " has no identity parsing " + this.name);
String desc = sheet.getColumn(row, "Description");
if (desc == null || desc.equals(""))
throw new Exception("Example " + name + " has no description parsing " + this.name);
String filename = sheet.getColumn(row, "Filename");
if (filename.startsWith(defn.getName().toLowerCase() + "-examples."))
throw new Exception("Cannot name an example file " + filename);
File file = new CSFile(folder + filename);
String type = sheet.getColumn(row, "Type");
if (!file.exists() && !("tool".equals(type) || isSpecialType(type)))
throw new Exception("Example " + name + " file '" + file.getAbsolutePath() + "' not found parsing " + this.name);
List<Example> list = defn.getExamples();
String pn = sheet.getColumn(row, "Profile");
if (!Utilities.noString(pn) && !pn.startsWith("!")) {
Profile ap = null;
for (Profile r : defn.getConformancePackages()) {
if (r.getTitle().equals(pn))
ap = r;
}
if (ap == null)
throw new Exception("Example " + name + " profile '" + pn + "' not found parsing " + this.name);
else
list = ap.getExamples();
}
ExampleType etype = parseExampleType(type, row);
list.add(new Example(name, id, desc, file, parseBoolean(sheet.getColumn(row, "Registered"), row, true), etype, isAbstract));
}
}
}
if (defn.getExamples().size() == 0) {
File file = new CSFile(folder + title + "-example.xml");
if (!file.exists() && !isAbstract)
throw new Exception("Example (file '" + file.getAbsolutePath() + "') not found parsing " + this.name);
if (file.exists())
defn.getExamples().add(new Example("General", "example", "Example of " + title, file, true, ExampleType.XmlFile, isAbstract));
}
}
use of org.hl7.fhir.definitions.model.Example.ExampleType in project kindling by HL7.
the class ResourceParser method parseExamples.
private void parseExamples(ResourceDefn r, String n, String t) throws FHIRException, Exception {
ListResource list = (ListResource) parseXml("list-" + t + "-examples.xml");
for (ListResourceEntryComponent le : list.getEntry()) {
boolean reg = le.hasExtension(BuildExtensions.EXT_NOT_REGISTERED) ? !BuildExtensions.readBoolExtension(le, BuildExtensions.EXT_NOT_REGISTERED) : true;
ExampleType type = ExampleType.XmlFile;
if (le.getFlag().hasCoding(BuildExtensions.EXT_EXAMPLE_TYPE, "container")) {
type = ExampleType.Container;
} else if (le.getFlag().hasCoding(BuildExtensions.EXT_EXAMPLE_TYPE, "csv")) {
type = ExampleType.CsvFile;
} else if (le.getFlag().hasCoding(BuildExtensions.EXT_EXAMPLE_TYPE, "tool")) {
type = ExampleType.Tool;
}
String id = le.getItem().getReference().substring(le.getItem().getReference().lastIndexOf("/") + 1);
String ig = le.getExtensionString(BuildExtensions.EXT_IG);
CSFile path = Utilities.noString(ig) ? new CSFile(Utilities.path(folder, le.getExtensionString(BuildExtensions.EXT_TITLE) + ".xml")) : new CSFile(Utilities.path(rootFolder(), "guides", ig, le.getExtensionString(BuildExtensions.EXT_TITLE) + "." + ext(type)));
Example ex = new Example(le.getItem().getDisplay(), id, le.getExtensionString(BuildExtensions.EXT_DESCRIPTION), path, reg, type, false);
r.getExamples().add(ex);
}
}
Aggregations