Search in sources :

Example 11 with FHIRFormatError

use of org.hl7.fhir.exceptions.FHIRFormatError in project kindling by HL7.

the class SpreadSheetCreator method addSearchParams.

private void addSearchParams(XSSFWorkbook excel) throws FHIRFormatError, FileNotFoundException, IOException {
    Bundle bnd = (Bundle) parseXml(fnSP());
    XSSFSheet sheet = excel.createSheet(SN_SEARCH);
    addSearchColumns(sheet);
    int rowCount = 0;
    for (BundleEntryComponent be : bnd.getEntry()) {
        rowCount++;
        addSearchParam(sheet, (SearchParameter) be.getResource(), rowCount);
    }
}
Also used : XSSFSheet(org.apache.poi.xssf.usermodel.XSSFSheet) BundleEntryComponent(org.hl7.fhir.r5.model.Bundle.BundleEntryComponent) Bundle(org.hl7.fhir.r5.model.Bundle)

Example 12 with FHIRFormatError

use of org.hl7.fhir.exceptions.FHIRFormatError 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 13 with FHIRFormatError

use of org.hl7.fhir.exceptions.FHIRFormatError in project kindling by HL7.

the class SpreadSheetCreator method addResourceSheets.

private XSSFSheet addResourceSheets(XSSFWorkbook excel) throws FHIRFormatError, FileNotFoundException, IOException {
    StructureDefinition sd = (StructureDefinition) parseXml(fnSD());
    sd.setText(null);
    XSSFSheet resource = excel.createSheet(SpreadSheetCreator.SN_RESOURCE);
    XSSFSheet bindings = excel.createSheet(SpreadSheetCreator.SN_BINDINGS);
    XSSFSheet invariants = excel.createSheet(SpreadSheetCreator.SN_INVARIANTS);
    addResourceColumns(resource, sd);
    addBindingColumns(bindings, sd);
    addInvariantColumns(invariants, sd);
    int rowCount = 0;
    invRowCount = 1;
    bindingRowCount = 1;
    for (ElementDefinition ed : sd.getDifferential().getElement()) {
        rowCount++;
        addElements(resource, bindings, invariants, ed, rowCount);
    }
    return bindings;
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) XSSFSheet(org.apache.poi.xssf.usermodel.XSSFSheet) ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition)

Example 14 with FHIRFormatError

use of org.hl7.fhir.exceptions.FHIRFormatError in project kindling by HL7.

the class ResourceParser method parseResource.

private ResourceDefn parseResource(String t) throws FHIRFormatError, FileNotFoundException, IOException {
    StructureDefinition sd = (StructureDefinition) parseXml("structuredefinition-" + t + ".xml");
    sdList.put(sd.getUrl(), sd);
    sd.setVersion(version);
    ResourceDefn r = new ResourceDefn();
    r.setName(sd.getName());
    r.setEnteredInErrorStatus(ToolingExtensions.readStringExtension(sd, BuildExtensions.EXT_ENTERED_IN_ERROR_STATUS));
    r.setStatus(StandardsStatus.fromCode(ToolingExtensions.readStringExtension(sd, ToolingExtensions.EXT_STANDARDS_STATUS)));
    r.setAbstract(sd.getAbstract());
    r.setInterface(ToolingExtensions.readBoolExtension(sd, BuildExtensions.EXT_RESOURCE_INTERFACE));
    r.setWg(definitions.getWorkgroups().get(ToolingExtensions.readStringExtension(sd, ToolingExtensions.EXT_WORKGROUP)));
    r.setFmmLevel(ToolingExtensions.readStringExtension(sd, ToolingExtensions.EXT_FMM_LEVEL));
    r.setProposedOrder(ToolingExtensions.readStringExtension(sd, BuildExtensions.EXT_PROPOSED_ORDER));
    r.setSecurityCategorization(SecurityCategorization.fromCode(ToolingExtensions.readStringExtension(sd, "http://hl7.org/fhir/StructureDefinition/structuredefinition-security-category")));
    r.setRequirements(sd.getPurpose());
    r.setDefinition(sd.getDescription());
    if (sd.hasExtension(BuildExtensions.EXT_TEMPLATE)) {
        String tname = BuildExtensions.readStringExtension(sd, BuildExtensions.EXT_TEMPLATE);
        ResourceDefn template = definitions.getResourceByName(tname);
        r.setTemplate(template.getRoot());
    }
    // private long timestamp; only set in regenerator...?
    // todo:
    // private List<InheritedMapping> inheritedMappings = new ArrayList<InheritedMapping>();
    // private ElementDefn template;
    // private Map<String, PointSpec> layout = new HashMap<String, PointSpec>();
    ProfileUtilities pu = new ProfileUtilities(context, null, null);
    r.setRoot(parseTypeDefinition(pu, sd.getDifferential().getElementFirstRep(), sd));
    r.getRoot().setFmmLevel(r.getFmmLevel());
    r.getRoot().setRequirements(r.getRequirements());
    if (r.isAbstract()) {
        r.getRoot().setAbstractType(true);
    }
    if (sd.hasBaseDefinition()) {
        r.getRoot().getTypes().add(new TypeRef(sd.getBaseDefinition().replace("http://hl7.org/fhir/StructureDefinition/", "")));
    }
    return r;
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) ProfileUtilities(org.hl7.fhir.r5.conformance.ProfileUtilities) TypeRef(org.hl7.fhir.definitions.model.TypeRef) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn)

Example 15 with FHIRFormatError

use of org.hl7.fhir.exceptions.FHIRFormatError in project kindling by HL7.

the class ResourceParser method processProfile.

private ConstraintStructure processProfile(String rid, String igId, ImplementationGuideDefinitionResourceComponent res, WorkGroup wg) throws FHIRFormatError, FileNotFoundException, IOException {
    StructureDefinition sd = (StructureDefinition) parseXml("structuredefinition-profile-" + rid + ".xml");
    ImplementationGuideDefn ig = definitions.getIgs().get(BuildExtensions.readStringExtension(res, igId));
    if (ig == null) {
        ig = definitions.getIgs().get("core");
    }
    ConstraintStructure cs = new ConstraintStructure(sd, ig, wg == null ? wg(sd) : wg, null, false);
    return cs;
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) ImplementationGuideDefn(org.hl7.fhir.definitions.model.ImplementationGuideDefn) ConstraintStructure(org.hl7.fhir.definitions.model.ConstraintStructure)

Aggregations

XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)85 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)61 FileInputStream (java.io.FileInputStream)43 ArrayList (java.util.ArrayList)36 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)36 FileOutputStream (java.io.FileOutputStream)29 IOException (java.io.IOException)27 FHIRException (org.hl7.fhir.exceptions.FHIRException)26 File (java.io.File)22 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)19 XhtmlParser (org.hl7.fhir.utilities.xhtml.XhtmlParser)18 StructureDefinition (org.hl7.fhir.dstu3.model.StructureDefinition)13 StructureDefinition (org.hl7.fhir.r4b.model.StructureDefinition)13 JsonElement (com.google.gson.JsonElement)12 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)12 XhtmlComposer (org.hl7.fhir.utilities.xhtml.XhtmlComposer)12 XmlParser (org.hl7.fhir.r5.formats.XmlParser)11 Resource (org.hl7.fhir.dstu3.model.Resource)9 HashMap (java.util.HashMap)8 Extension (org.hl7.fhir.r5.model.Extension)8