Search in sources :

Example 1 with ListResourceEntryComponent

use of org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent in project kindling by HL7.

the class SpreadSheetReloader method getExample.

private ListResourceEntryComponent getExample(List<ListResourceEntryComponent> oldEx, String c) {
    for (ListResourceEntryComponent li : oldEx) {
        if (c.equals(li.getItem().getDisplay())) {
            return li;
        }
    }
    ListResourceEntryComponent res = new ListResourceEntryComponent();
    res.getItem().setDisplay(c);
    return res;
}
Also used : ListResourceEntryComponent(org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent)

Example 2 with ListResourceEntryComponent

use of org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent in project kindling by HL7.

the class SpreadSheetReloader method processExamples.

private void processExamples(XSSFWorkbook excel) throws FHIRFormatError, FileNotFoundException, IOException {
    ListResource list = (ListResource) parseXml(fnOperations());
    XSSFSheet src = getSheet(excel, SN_SEARCH);
    List<ListResourceEntryComponent> oldEx = list.getEntry();
    list.setEntry(new ArrayList<>());
    XSSFRow cols = src.getRow(0);
    for (int i = 1; i < src.getLastRowNum(); i++) {
        XSSFRow row = src.getRow(i);
        if (row != null && hasValue(row, cols, CN_NAME)) {
            String c = getValue(row, cols, CN_NAME);
            ListResourceEntryComponent li = getExample(oldEx, c);
            list.addEntry(li);
            readExample(row, cols, li);
        }
    }
}
Also used : XSSFSheet(org.apache.poi.xssf.usermodel.XSSFSheet) XSSFRow(org.apache.poi.xssf.usermodel.XSSFRow) ListResourceEntryComponent(org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent) ListResource(org.hl7.fhir.r5.model.ListResource)

Example 3 with ListResourceEntryComponent

use of org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent in project kindling by HL7.

the class SpreadSheetCreator method addPacks.

private void addPacks(XSSFWorkbook excel) throws FHIRFormatError, FileNotFoundException, IOException {
    ListResource list = (ListResource) parseXml(fnPacks());
    list.setText(null);
    for (ListResourceEntryComponent li : list.getEntry()) {
        String ref = li.getItem().getReference();
        ref = ref.substring(ref.indexOf("/") + 1);
        String id = ref.contains("-") ? ref.substring(ref.indexOf("-") + 1) : ref;
        XSSFSheet sheet = excel.createSheet("Pack " + id);
        addPackColumns(sheet);
        addPack(sheet, ref);
    }
}
Also used : XSSFSheet(org.apache.poi.xssf.usermodel.XSSFSheet) ListResourceEntryComponent(org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent) ListResource(org.hl7.fhir.r5.model.ListResource)

Example 4 with ListResourceEntryComponent

use of org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent in project kindling by HL7.

the class SpreadSheetCreator method addOperations.

private void addOperations(XSSFWorkbook excel, XSSFSheet bindings) throws FHIRFormatError, FileNotFoundException, IOException {
    ListResource list = (ListResource) parseXml(fnOperations());
    list.setText(null);
    XSSFSheet sheet = excel.createSheet(SN_OPERATIONS);
    addOperationColumns(sheet);
    int rowCount = 1;
    for (ListResourceEntryComponent li : list.getEntry()) {
        String ref = li.getItem().getReference();
        ref = ref.substring(ref.indexOf("/") + 1);
        OperationDefinition opd = (OperationDefinition) parseXml(fnOpDef(ref));
        opd.setText(null);
        rowCount = addOperation(sheet, bindings, opd, 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) OperationDefinition(org.hl7.fhir.r5.model.OperationDefinition)

Example 5 with ListResourceEntryComponent

use of org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent in project kindling by HL7.

the class Regenerator method generateExamples.

private void generateExamples(String root, ResourceDefn r) throws FileNotFoundException, IOException {
    ListResource list = new ListResource();
    list.setId(r.getName() + "-examples");
    list.setStatus(ListStatus.CURRENT);
    list.setMode(ListMode.WORKING);
    for (Example ex : r.getExamples()) {
        ListResourceEntryComponent li = list.addEntry();
        li.getItem().setReference(ex.getResourceName() + "/" + ex.getId());
        li.getItem().setDisplay(ex.getName());
        if (ex.getDescription() != null) {
            li.addExtension(BuildExtensions.EXT_DESCRIPTION, new StringType(ex.getDescription()));
        }
        if (ex.getTitle() != null) {
            li.addExtension(BuildExtensions.EXT_TITLE, new StringType(ex.getTitle()));
        }
        switch(ex.getType()) {
            case Container:
                li.getFlag().addCoding(BuildExtensions.EXT_EXAMPLE_TYPE, "container", null);
                break;
            case CsvFile:
                li.getFlag().addCoding(BuildExtensions.EXT_EXAMPLE_TYPE, "csv", null);
                break;
            case Tool:
                li.getFlag().addCoding(BuildExtensions.EXT_EXAMPLE_TYPE, "tool", null);
                break;
            default:
                break;
        }
        if (!ex.isRegistered()) {
            li.addExtension(BuildExtensions.EXT_NOT_REGISTERED, new BooleanType(!ex.isRegistered()));
        }
        if (ex.getIg() != null) {
            li.addExtension(BuildExtensions.EXT_IG, new CodeType(ex.getIg()));
        }
        if (ex.getExampleFor() != null) {
            li.addExtension(BuildExtensions.EXT_EXAMPLE_FOR, new StringType(ex.getExampleFor()));
        }
    }
    File fn = new File(Utilities.path(root, list.fhirType().toLowerCase() + "-" + list.getId() + ".gen.xml"));
    new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(fn), list);
    fn.setLastModified(r.getTimestamp());
}
Also used : XmlParser(org.hl7.fhir.r5.formats.XmlParser) StringType(org.hl7.fhir.r5.model.StringType) Example(org.hl7.fhir.definitions.model.Example) OperationExample(org.hl7.fhir.definitions.model.Operation.OperationExample) ListResourceEntryComponent(org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent) FileOutputStream(java.io.FileOutputStream) BooleanType(org.hl7.fhir.r5.model.BooleanType) CodeType(org.hl7.fhir.r5.model.CodeType) ListResource(org.hl7.fhir.r5.model.ListResource) File(java.io.File)

Aggregations

ListResourceEntryComponent (org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent)12 ListResource (org.hl7.fhir.r5.model.ListResource)10 File (java.io.File)4 XSSFSheet (org.apache.poi.xssf.usermodel.XSSFSheet)4 FileOutputStream (java.io.FileOutputStream)3 XmlParser (org.hl7.fhir.r5.formats.XmlParser)3 OperationDefinition (org.hl7.fhir.r5.model.OperationDefinition)3 Example (org.hl7.fhir.definitions.model.Example)2 OperationExample (org.hl7.fhir.definitions.model.Operation.OperationExample)2 BooleanType (org.hl7.fhir.r5.model.BooleanType)2 StringType (org.hl7.fhir.r5.model.StringType)2 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)2 HashSet (java.util.HashSet)1 XSSFRow (org.apache.poi.xssf.usermodel.XSSFRow)1 ExampleType (org.hl7.fhir.definitions.model.Example.ExampleType)1 Operation (org.hl7.fhir.definitions.model.Operation)1 Profile (org.hl7.fhir.definitions.model.Profile)1 FHIRException (org.hl7.fhir.exceptions.FHIRException)1 Annotation (org.hl7.fhir.r4b.model.Annotation)1 ListResourceEntryComponent (org.hl7.fhir.r4b.model.ListResource.ListResourceEntryComponent)1