Search in sources :

Example 1 with StructureDefinitionSpreadsheetGenerator

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");
    }
}
Also used : StructureDefinitionSpreadsheetGenerator(org.hl7.fhir.r5.renderers.spreadsheets.StructureDefinitionSpreadsheetGenerator) FileOutputStream(java.io.FileOutputStream) CodeSystemSpreadsheetGenerator(org.hl7.fhir.r5.renderers.spreadsheets.CodeSystemSpreadsheetGenerator) ValueSetSpreadsheetGenerator(org.hl7.fhir.r5.renderers.spreadsheets.ValueSetSpreadsheetGenerator) ConceptMapSpreadsheetGenerator(org.hl7.fhir.r5.renderers.spreadsheets.ConceptMapSpreadsheetGenerator)

Example 2 with StructureDefinitionSpreadsheetGenerator

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;
}
Also used : StructureDefinitionMappingComponent(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionMappingComponent) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) XSSFRow(org.apache.poi.xssf.usermodel.XSSFRow) Row(org.apache.poi.ss.usermodel.Row) ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition) Sheet(org.apache.poi.ss.usermodel.Sheet) XSSFSheet(org.apache.poi.xssf.usermodel.XSSFSheet)

Example 3 with StructureDefinitionSpreadsheetGenerator

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;
}
Also used : StructureDefinitionMappingComponent(org.hl7.fhir.r4b.model.StructureDefinition.StructureDefinitionMappingComponent) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) XSSFRow(org.apache.poi.xssf.usermodel.XSSFRow) Row(org.apache.poi.ss.usermodel.Row) ElementDefinition(org.hl7.fhir.r4b.model.ElementDefinition) Sheet(org.apache.poi.ss.usermodel.Sheet) XSSFSheet(org.apache.poi.xssf.usermodel.XSSFSheet)

Aggregations

Row (org.apache.poi.ss.usermodel.Row)2 Sheet (org.apache.poi.ss.usermodel.Sheet)2 XSSFRow (org.apache.poi.xssf.usermodel.XSSFRow)2 XSSFSheet (org.apache.poi.xssf.usermodel.XSSFSheet)2 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)2 FileOutputStream (java.io.FileOutputStream)1 ElementDefinition (org.hl7.fhir.r4b.model.ElementDefinition)1 StructureDefinitionMappingComponent (org.hl7.fhir.r4b.model.StructureDefinition.StructureDefinitionMappingComponent)1 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)1 StructureDefinitionMappingComponent (org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionMappingComponent)1 CodeSystemSpreadsheetGenerator (org.hl7.fhir.r5.renderers.spreadsheets.CodeSystemSpreadsheetGenerator)1 ConceptMapSpreadsheetGenerator (org.hl7.fhir.r5.renderers.spreadsheets.ConceptMapSpreadsheetGenerator)1 StructureDefinitionSpreadsheetGenerator (org.hl7.fhir.r5.renderers.spreadsheets.StructureDefinitionSpreadsheetGenerator)1 ValueSetSpreadsheetGenerator (org.hl7.fhir.r5.renderers.spreadsheets.ValueSetSpreadsheetGenerator)1