use of org.hl7.fhir.definitions.model.BindingSpecification.BindingMethod in project kindling by HL7.
the class BindingsFixer method processSheet.
private static void processSheet(XLSXmlParser xls, Sheet sheet, String dir, String sfx) throws Exception {
for (int row = 0; row < sheet.rows.size(); row++) {
String bindingName = sheet.getColumn(row, "Binding Name");
if (Utilities.noString(bindingName) || bindingName.startsWith("!"))
continue;
BindingMethod method = BindingsParser.readBinding(sheet.getColumn(row, "Binding"), "??");
String ref = sheet.getColumn(row, "Reference");
if (method == BindingMethod.CodeList) {
if (ref.startsWith("#valueset-"))
throw new Exception("don't start code list references with #valueset-");
String vfn = Utilities.path(dir, "valueset-" + sfx + ref.substring(1) + ".xml");
String cfn = Utilities.path(dir, "codesystem-" + sfx + ref.substring(1) + ".xml");
File vf = new File(vfn);
File cf = new File(cfn);
if (!vf.exists()) {
System.out.println("Produce " + vfn);
ValueSet vs = ValueSetUtilities.makeShareable(new ValueSet());
vs.setVersion(Constants.VERSION);
vs.setId(sfx + ref.substring(1));
vs.setUrl("http://hl7.org/fhir/ValueSet/" + sfx + ref.substring(1));
vs.setDescription(sheet.getColumn(row, "Description"));
vs.setName(bindingName);
vs.setStatus(PublicationStatus.fromCode(sheet.getColumn(row, "Status")));
vs.setCopyright(sheet.getColumn(row, "Copyright"));
Sheet css = xls.getSheets().get(ref.substring(1));
if (css == null) {
throw new Exception("Error parsing binding " + bindingName + ": code list reference '" + ref + "' not resolved");
}
CodeSystem cs = CodeSystemUtilities.makeShareable(new CodeSystem());
cs.setVersion(Constants.VERSION);
cs.setId(sfx + ref.substring(1));
cs.setUrl("http://hl7.org/fhir/" + sfx + ref.substring(1));
cs.setDescription(sheet.getColumn(row, "Description"));
cs.setName(bindingName);
cs.setStatus(PublicationStatus.fromCode(sheet.getColumn(row, "Status")));
cs.setCopyright(sheet.getColumn(row, "Copyright"));
vs.getCompose().addInclude().setSystem(cs.getUrl());
processCodes(cs, css);
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(vf), vs);
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(cf), cs);
}
}
}
}
Aggregations