Search in sources :

Example 51 with Sheet

use of org.hl7.fhir.utilities.xls.XLSXmlParser.Sheet in project kindling by HL7.

the class SourceParser method processStringPattern.

private void processStringPattern(Sheet sheet, int row) throws Exception {
    DefinedStringPattern prim = new DefinedStringPattern();
    prim.setCode(sheet.getColumn(row, "Data Type"));
    prim.setDefinition(sheet.getColumn(row, "Definition"));
    prim.setComment(sheet.getColumn(row, "Comments"));
    prim.setRegex(sheet.getColumn(row, "RegEx"));
    prim.setSchema(sheet.getColumn(row, "Schema"));
    prim.setJsonType(sheet.getColumn(row, "Json"));
    prim.setBase(sheet.getColumn(row, "Base"));
    TypeRef td = new TypeRef();
    td.setName(prim.getCode());
    definitions.getKnownTypes().add(td);
    definitions.getPrimitives().put(prim.getCode(), prim);
}
Also used : DefinedStringPattern(org.hl7.fhir.definitions.model.DefinedStringPattern) TypeRef(org.hl7.fhir.definitions.model.TypeRef)

Example 52 with Sheet

use of org.hl7.fhir.utilities.xls.XLSXmlParser.Sheet in project kindling by HL7.

the class SourceParser method loadCompartments.

private void loadCompartments() throws FileNotFoundException, Exception {
    XLSXmlParser xml = new XLSXmlParser(new CSFileInputStream(srcDir + "compartments.xml"), "compartments.xml");
    new XLSXmlNormaliser(srcDir + "compartments.xml", exceptionIfExcelNotNormalised).go();
    Sheet sheet = xml.getSheets().get("compartments");
    for (int row = 0; row < sheet.rows.size(); row++) {
        Compartment c = new Compartment();
        c.setName(sheet.getColumn(row, "Name"));
        if (!c.getName().startsWith("!")) {
            c.setTitle(sheet.getColumn(row, "Title"));
            c.setDescription(sheet.getColumn(row, "Description"));
            c.setIdentity(sheet.getColumn(row, "Identification"));
            c.setMembership(sheet.getColumn(row, "Inclusion"));
            definitions.getCompartments().add(c);
        }
    }
    sheet = xml.getSheets().get("resources");
    for (int row = 0; row < sheet.rows.size(); row++) {
        String mn = sheet.getColumn(row, "Resource");
        if (!Utilities.noString(mn) && !mn.startsWith("!")) {
            ResourceDefn r = definitions.getResourceByName(mn);
            for (Compartment c : definitions.getCompartments()) {
                c.getResources().put(r, sheet.getColumn(row, c.getName()));
            }
        }
    }
}
Also used : Compartment(org.hl7.fhir.definitions.model.Compartment) XLSXmlParser(org.hl7.fhir.utilities.xls.XLSXmlParser) XLSXmlNormaliser(org.hl7.fhir.utilities.xls.XLSXmlNormaliser) Sheet(org.hl7.fhir.utilities.xls.XLSXmlParser.Sheet) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn) CSFileInputStream(org.hl7.fhir.utilities.CSFileInputStream)

Example 53 with Sheet

use of org.hl7.fhir.utilities.xls.XLSXmlParser.Sheet in project kindling by HL7.

the class SourceParser method processImport.

private void processImport(Sheet sheet, int row) throws Exception {
    PrimitiveType prim = new PrimitiveType();
    prim.setCode(sheet.getColumn(row, "Data Type"));
    prim.setDefinition(sheet.getColumn(row, "Definition"));
    prim.setComment(sheet.getColumn(row, "Comments"));
    prim.setSchemaType(sheet.getColumn(row, "Schema"));
    prim.setJsonType(sheet.getColumn(row, "Json"));
    prim.setRegex(sheet.getColumn(row, "RegEx"));
    prim.setV2(sheet.getColumn(row, "v2"));
    prim.setV3(sheet.getColumn(row, "v3"));
    TypeRef td = new TypeRef();
    td.setName(prim.getCode());
    definitions.getKnownTypes().add(td);
    definitions.getPrimitives().put(prim.getCode(), prim);
}
Also used : TypeRef(org.hl7.fhir.definitions.model.TypeRef) PrimitiveType(org.hl7.fhir.definitions.model.PrimitiveType)

Example 54 with Sheet

use of org.hl7.fhir.utilities.xls.XLSXmlParser.Sheet in project kindling by HL7.

the class SpreadSheetCreator method addPack.

private void addPack(XSSFSheet sheet, String ref) throws FHIRFormatError, FileNotFoundException, IOException {
    ImplementationGuide ig = (ImplementationGuide) parseXml(fnIG(ref));
    ig.setText(null);
    int rowCount = 1;
    sortExtensions(ig);
    addPackRow(sheet, CN_ID, ig.getId(), rowCount++);
    addPackRow(sheet, CN_CODE, BuildExtensions.readStringExtension(ig, BuildExtensions.EXT_CODE), rowCount++);
    addPackRow(sheet, CN_NAME, ig.getName(), rowCount++);
    addPackRow(sheet, CN_TITLE, ig.getTitle(), rowCount++);
    addPackRow(sheet, CN_VERSION, ig.getVersion(), rowCount++);
    addPackRow(sheet, CN_DESCRIPTION, ig.getDescription(), rowCount++);
    addPackRow(sheet, CN_PUBLISHER, ig.getPublisher(), rowCount++);
    addPackRow(sheet, CN_STATUS, ig.getStatus().toCode(), rowCount++);
    addPackRow(sheet, CN_EXPERIMENTAL, ig.getExperimentalElement().primitiveValue(), rowCount++);
    addPackRow(sheet, CN_DATE, ig.getDateElement().primitiveValue(), rowCount++);
    addPackRow(sheet, CN_FMM, BuildExtensions.readStringExtension(ig, BuildExtensions.EXT_FMM_LEVEL), rowCount++);
    addPackRow(sheet, CN_WORK_GROUP, BuildExtensions.readStringExtension(ig, BuildExtensions.EXT_WORKGROUP), rowCount++);
    addPackRow(sheet, CN_INTRODUCTION, BuildExtensions.readStringExtension(ig, BuildExtensions.EXT_INTRODUCTION), rowCount++);
    addPackRow(sheet, CN_NOTES, BuildExtensions.readStringExtension(ig, BuildExtensions.EXT_NOTES), rowCount++);
    for (ImplementationGuideDefinitionResourceComponent res : ig.getDefinition().getResource()) {
        String r = res.getReference().getReference();
        String id = r.substring(r.indexOf("/") + 1);
        if (r.startsWith("SearchParameter/")) {
            addPackRow(sheet, CN_SEARCH_PARAMETER, id, rowCount++);
        } else if (r.startsWith("StructureDefinition/")) {
            String fn = fnExt(id);
            if (new File(fn).exists()) {
                addPackRow(sheet, CN_EXTENSION, id, rowCount++);
            } else {
                addPackRow(sheet, CN_PROFILE, id, rowCount++);
            }
        } else {
            addPackRow(sheet, CN_EXAMPLE, r, rowCount++);
        }
    }
}
Also used : ImplementationGuide(org.hl7.fhir.r5.model.ImplementationGuide) ImplementationGuideDefinitionResourceComponent(org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDefinitionResourceComponent) File(java.io.File) IniFile(org.hl7.fhir.utilities.IniFile)

Example 55 with Sheet

use of org.hl7.fhir.utilities.xls.XLSXmlParser.Sheet in project kindling by HL7.

the class SpreadSheetCreator method addExamples.

private void addExamples(XSSFWorkbook excel) throws FHIRFormatError, FileNotFoundException, IOException {
    ListResource list = (ListResource) parseXml(fnExamples());
    list.setText(null);
    XSSFSheet sheet = excel.createSheet(SN_EXAMPLES);
    addExampleColumns(sheet);
    int rowCount = 0;
    for (ListResourceEntryComponent li : list.getEntry()) {
        rowCount++;
        addExample(sheet, li, rowCount);
    }
}
Also used : XSSFSheet(org.apache.poi.xssf.usermodel.XSSFSheet) ListResourceEntryComponent(org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent) ListResource(org.hl7.fhir.r5.model.ListResource)

Aggregations

FHIRException (org.hl7.fhir.exceptions.FHIRException)18 Sheet (org.hl7.fhir.utilities.xls.XLSXmlParser.Sheet)15 Sheet (org.apache.poi.ss.usermodel.Sheet)14 Row (org.apache.poi.ss.usermodel.Row)13 XSSFSheet (org.apache.poi.xssf.usermodel.XSSFSheet)12 ArrayList (java.util.ArrayList)8 XSSFRow (org.apache.poi.xssf.usermodel.XSSFRow)8 ElementDefn (org.hl7.fhir.definitions.model.ElementDefn)8 Invariant (org.hl7.fhir.definitions.model.Invariant)8 XLSXmlParser (org.hl7.fhir.utilities.xls.XLSXmlParser)8 TypeRef (org.hl7.fhir.definitions.model.TypeRef)7 File (java.io.File)6 BindingSpecification (org.hl7.fhir.definitions.model.BindingSpecification)5 ResourceDefn (org.hl7.fhir.definitions.model.ResourceDefn)5 IniFile (org.hl7.fhir.utilities.IniFile)5 HashMap (java.util.HashMap)4 ConditionalFormattingRule (org.apache.poi.ss.usermodel.ConditionalFormattingRule)4 FontFormatting (org.apache.poi.ss.usermodel.FontFormatting)4 PatternFormatting (org.apache.poi.ss.usermodel.PatternFormatting)4 SheetConditionalFormatting (org.apache.poi.ss.usermodel.SheetConditionalFormatting)4