use of org.hl7.fhir.r5.renderers.spreadsheets.StructureDefinitionSpreadsheetGenerator in project org.hl7.fhir.core by hapifhir.
the class ValidationService method generateSpreadsheet.
public void generateSpreadsheet(CliContext cliContext, ValidationEngine validator) throws Exception {
CanonicalResource cr = validator.loadCanonicalResource(cliContext.getSources().get(0), cliContext.getSv());
boolean ok = true;
if (cr instanceof StructureDefinition) {
new StructureDefinitionSpreadsheetGenerator(validator.getContext(), false, false).renderStructureDefinition((StructureDefinition) cr).finish(new FileOutputStream(cliContext.getOutput()));
} else if (cr instanceof CodeSystem) {
new CodeSystemSpreadsheetGenerator(validator.getContext()).renderCodeSystem((CodeSystem) cr).finish(new FileOutputStream(cliContext.getOutput()));
} else if (cr instanceof ValueSet) {
new ValueSetSpreadsheetGenerator(validator.getContext()).renderValueSet((ValueSet) cr).finish(new FileOutputStream(cliContext.getOutput()));
} else if (cr instanceof ConceptMap) {
new ConceptMapSpreadsheetGenerator(validator.getContext()).renderConceptMap((ConceptMap) cr).finish(new FileOutputStream(cliContext.getOutput()));
} else {
ok = false;
System.out.println(" ...Unable to generate spreadsheet for " + cliContext.getSources().get(0) + ": no way to generate a spreadsheet for a " + cr.fhirType());
}
if (ok) {
System.out.println(" ...generated spreadsheet successfully");
}
}
use of org.hl7.fhir.r5.renderers.spreadsheets.StructureDefinitionSpreadsheetGenerator in project org.hl7.fhir.core by hapifhir.
the class StructureDefinitionSpreadsheetGenerator method renderStructureDefinition.
public StructureDefinitionSpreadsheetGenerator renderStructureDefinition(StructureDefinition sd) throws Exception {
if (sd == null) {
System.out.println("no structure!");
}
if (!sd.hasSnapshot()) {
throw new DefinitionException(context.formatMessage(I18nConstants.NEEDS_A_SNAPSHOT));
}
addStructureDefinitionMetadata(renderCanonicalResource(sd), sd);
Sheet sheet = makeSheet("Elements");
Row headerRow = sheet.createRow(0);
for (int i = 0; i < titles.length; i++) {
addCell(headerRow, i, titles[i], styles.get("header"));
}
int i = titles.length - 1;
for (StructureDefinitionMappingComponent map : sd.getMapping()) {
i++;
addCell(headerRow, i, "Mapping: " + map.getName(), styles.get("header"));
}
for (ElementDefinition child : sd.getSnapshot().getElement()) {
processElement(sheet, sd, child);
}
configureSheet(sheet, sd);
return this;
}
use of org.hl7.fhir.r5.renderers.spreadsheets.StructureDefinitionSpreadsheetGenerator in project org.hl7.fhir.core by hapifhir.
the class StructureDefinitionSpreadsheetGenerator method renderStructureDefinition.
public StructureDefinitionSpreadsheetGenerator renderStructureDefinition(StructureDefinition sd) throws Exception {
if (sd == null) {
System.out.println("no structure!");
}
if (!sd.hasSnapshot()) {
throw new DefinitionException(context.formatMessage(I18nConstants.NEEDS_A_SNAPSHOT));
}
addStructureDefinitionMetadata(renderCanonicalResource(sd), sd);
Sheet sheet = makeSheet("Elements");
Row headerRow = sheet.createRow(0);
for (int i = 0; i < titles.length; i++) {
addCell(headerRow, i, titles[i], styles.get("header"));
}
int i = titles.length - 1;
for (StructureDefinitionMappingComponent map : sd.getMapping()) {
i++;
addCell(headerRow, i, "Mapping: " + map.getName(), styles.get("header"));
}
for (ElementDefinition child : sd.getSnapshot().getElement()) {
processElement(sheet, sd, child);
}
configureSheet(sheet, sd);
return this;
}
Aggregations