Search in sources :

Example 6 with SearchParameter

use of org.hl7.fhir.r4b.model.SearchParameter in project kindling by HL7.

the class SourceParser method loadCommonSearchParameters.

private void loadCommonSearchParameters() throws FHIRFormatError, FileNotFoundException, IOException {
    Bundle bnd = (Bundle) new XmlParser().parse(new CSFileInputStream(Utilities.path(srcDir, "searchparameter", "common-search-parameters.xml")));
    for (BundleEntryComponent be : bnd.getEntry()) {
        SearchParameter sp = (SearchParameter) be.getResource();
        CommonSearchParameter csp = new CommonSearchParameter();
        csp.setId(sp.getId());
        csp.setCode(sp.getCode());
        for (CodeType ct : sp.getBase()) {
            csp.getResources().add(ct.asStringValue());
            definitions.getCommonSearchParameters().put(ct.asStringValue() + "::" + sp.getCode(), csp);
        }
    }
}
Also used : XmlParser(org.hl7.fhir.r5.formats.XmlParser) XLSXmlParser(org.hl7.fhir.utilities.xls.XLSXmlParser) BundleEntryComponent(org.hl7.fhir.r5.model.Bundle.BundleEntryComponent) Bundle(org.hl7.fhir.r5.model.Bundle) CommonSearchParameter(org.hl7.fhir.definitions.model.CommonSearchParameter) CodeType(org.hl7.fhir.r5.model.CodeType) CommonSearchParameter(org.hl7.fhir.definitions.model.CommonSearchParameter) SearchParameter(org.hl7.fhir.r5.model.SearchParameter) CSFileInputStream(org.hl7.fhir.utilities.CSFileInputStream)

Example 7 with SearchParameter

use of org.hl7.fhir.r4b.model.SearchParameter in project kindling by HL7.

the class SpreadSheetReloader method processPack.

private void processPack(XSSFSheet src, String ref) throws FHIRFormatError, FileNotFoundException, IOException {
    ImplementationGuide ig = (ImplementationGuide) parseXml(fnIG(resourceName + "-" + ref));
    ig.getDefinition().getResource().clear();
    XSSFRow cols = src.getRow(0);
    for (int i = 1; i <= src.getLastRowNum(); i++) {
        XSSFRow row = src.getRow(i);
        String n = getValue(row, cols, CN_NAME);
        String v = getValue(row, cols, CN_VALUE);
        if (Utilities.noString(v)) {
            v = null;
        }
        switch(n) {
            case CN_ID:
                ig.setId(v);
                break;
            case CN_CODE:
                readExt(ig, v, BuildExtensions.EXT_CODE, ExtensionType.Code);
            case CN_NAME:
                ig.setName(v);
                break;
            case CN_TITLE:
                ig.setTitle(v);
                break;
            case CN_VERSION:
                ig.setVersion(v);
                break;
            case CN_DESCRIPTION:
                ig.setDescription(v);
                break;
            case CN_PUBLISHER:
                ig.setPublisher(v);
                break;
            case CN_STATUS:
                ig.setStatus(PublicationStatus.fromCode(v));
                break;
            case CN_EXPERIMENTAL:
                ig.getExperimentalElement().setValueAsString(v);
                break;
            case CN_DATE:
                ig.getDateElement().setValueAsString(v);
                break;
            case CN_FMM:
                readExt(ig, v, BuildExtensions.EXT_FMM_LEVEL, ExtensionType.Integer);
                break;
            case CN_WORK_GROUP:
                readExt(ig, v, BuildExtensions.EXT_WORKGROUP, ExtensionType.Code);
                break;
            case CN_INTRODUCTION:
                readExt(ig, v, BuildExtensions.EXT_INTRODUCTION, ExtensionType.String);
                break;
            case CN_NOTES:
                readExt(ig, v, BuildExtensions.EXT_NOTES, ExtensionType.String);
                break;
            case CN_EXTENSION:
                if (v != null) {
                    ig.getDefinition().addResource().getReference().setReference("StructureDefinition/" + v);
                }
                break;
            case CN_PROFILE:
                if (v != null) {
                    ig.getDefinition().addResource().getReference().setReference("StructureDefinition/" + v);
                }
                break;
            case CN_EXAMPLE:
                if (v != null) {
                    ig.getDefinition().addResource().getReference().setReference(v);
                }
                break;
            case CN_SEARCH_PARAMETER:
                if (v != null) {
                    ig.getDefinition().addResource().getReference().setReference("SearchParameter/" + v);
                }
                break;
        }
    }
    saveXml(fnIG(resourceName + "-" + ref), ig);
}
Also used : ImplementationGuide(org.hl7.fhir.r5.model.ImplementationGuide) XSSFRow(org.apache.poi.xssf.usermodel.XSSFRow)

Example 8 with SearchParameter

use of org.hl7.fhir.r4b.model.SearchParameter in project kindling by HL7.

the class SpreadSheetReloader method readSearchParameter.

private void readSearchParameter(XSSFRow row, XSSFRow cols, SearchParameter sp) {
    sp.setType(SearchParamType.fromCode(getValue(row, cols, CN_TYPE)));
    sp.setExpression(getValue(row, cols, CN_EXPRESSION));
    sp.setDescription(getValue(row, cols, CN_DESCRIPTION));
    sp.setXpath(getValue(row, cols, CN_X_PATH));
    sp.getTarget().clear();
    for (String s : splitValue(row, cols, CN_TARGET_TYPES, "\\|")) {
        sp.getTarget().add(new CodeType(s));
    }
    readExt(sp, row, cols, CN_PATH, BuildExtensions.EXT_PATH, ExtensionType.String);
    readExt(sp, row, cols, CN_COMMITTEE_NOTES, BuildExtensions.EXT_COMMITTEE_NOTES, ExtensionType.String);
}
Also used : CodeType(org.hl7.fhir.r5.model.CodeType)

Example 9 with SearchParameter

use of org.hl7.fhir.r4b.model.SearchParameter 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 10 with SearchParameter

use of org.hl7.fhir.r4b.model.SearchParameter in project kindling by HL7.

the class Regenerator method generateCP.

private void generateCP(String root, ResourceDefn r, Profile p) throws IOException {
    ImplementationGuide ig = new ImplementationGuide();
    ig.setId(r.getName() + "-" + p.getCategory());
    ig.setTitle(p.getTitle());
    ig.setStatus(PublicationStatus.ACTIVE);
    ig.setDate(new Date(r.getTimestamp()));
    for (String s : p.getMetadata().keySet()) {
        List<String> vl = p.getMetadata().get(s);
        for (String v : vl) {
            if (!Utilities.noString(v)) {
                switch(s) {
                    // case "id": ig.setId(v); break;
                    case "name":
                        ig.setName(v);
                        break;
                    case "author.name":
                        ig.setPublisher(v);
                        break;
                    case "code":
                        ig.addExtension(BuildExtensions.EXT_CODE, new CodeType(v));
                        break;
                    case "fmm":
                        ig.addExtension(ToolingExtensions.EXT_FMM_LEVEL, new CodeType(v));
                        break;
                    case "description":
                        ig.setDescription(v);
                        break;
                    case "status":
                        ig.setStatus(PublicationStatus.fromCode(v));
                        break;
                    case "publication.status":
                        break;
                    case "version":
                        ig.setVersion(v);
                        break;
                    case "display":
                        ig.setTitle(v);
                        break;
                    case "workgroup":
                        ig.addExtension(ToolingExtensions.EXT_WORKGROUP, new CodeType(v));
                        break;
                    case "date":
                        ig.getDateElement().setValueAsString(v);
                        break;
                    case "Experimental":
                        ig.setExperimental(Utilities.existsInList(v.toLowerCase(), "y", "yes", "1", "true"));
                        break;
                    default:
                        if (s.startsWith("fmm-") || Utilities.existsInList(s, "extension.uri", "author.reference", "published.structure", "notes", "introduction") || s.startsWith("!")) {
                        // ignore these
                        } else if (s.startsWith("summary-")) {
                            String n = s.substring(8);
                            for (ConstraintStructure cs : p.getProfiles()) {
                                if (n.equals(cs.getTitle()) || n.equals(cs.getId())) {
                                    cs.setSummary(v);
                                }
                            }
                        } else {
                            System.out.println("Unknown metadata item: " + s + "=" + v);
                        }
                }
            }
        }
    }
    if (!Utilities.noString(p.getIntroduction())) {
        ig.addExtension(BuildExtensions.EXT_INTRODUCTION, new StringType(p.getIntroduction()));
    }
    if (!Utilities.noString(p.getNotes())) {
        ig.addExtension(BuildExtensions.EXT_NOTES, new StringType(p.getNotes()));
    }
    for (ConstraintStructure cs : p.getProfiles()) {
        CanonicalResource cr = generateProfile(root, r, p, cs);
        ImplementationGuideDefinitionResourceComponent res = ig.getDefinition().addResource();
        res.getReference().setReference(cr.fhirType() + "/" + cr.getId());
    }
    for (StructureDefinition cs : p.getExtensions()) {
        CanonicalResource cr = generateExtension(root, r, p, cs.copy());
        ImplementationGuideDefinitionResourceComponent res = ig.getDefinition().addResource();
        res.getReference().setReference(cr.fhirType() + "/" + cr.getId());
    }
    for (SearchParameter cs : p.getSearchParameters()) {
        CanonicalResource cr = generateSearchParameter(root, r, p, cs);
        ImplementationGuideDefinitionResourceComponent res = ig.getDefinition().addResource();
        res.getReference().setReference(cr.fhirType() + "/" + cr.getId());
    }
    for (Example cs : p.getExamples()) {
        ImplementationGuideDefinitionResourceComponent res = ig.getDefinition().addResource();
        generateExample(root, r, p, cs, res);
    }
    File fn = new File(Utilities.path(root, ig.fhirType().toLowerCase() + "-" + ig.getId() + ".gen.xml"));
    new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(fn), ig);
    fn.setLastModified(r.getTimestamp());
}
Also used : XmlParser(org.hl7.fhir.r5.formats.XmlParser) ImplementationGuide(org.hl7.fhir.r5.model.ImplementationGuide) StringType(org.hl7.fhir.r5.model.StringType) Date(java.util.Date) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) Example(org.hl7.fhir.definitions.model.Example) OperationExample(org.hl7.fhir.definitions.model.Operation.OperationExample) FileOutputStream(java.io.FileOutputStream) CodeType(org.hl7.fhir.r5.model.CodeType) ImplementationGuideDefinitionResourceComponent(org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDefinitionResourceComponent) ConstraintStructure(org.hl7.fhir.definitions.model.ConstraintStructure) SearchParameter(org.hl7.fhir.r5.model.SearchParameter) CanonicalResource(org.hl7.fhir.r5.model.CanonicalResource) File(java.io.File)

Aggregations

SearchParameter (org.hl7.fhir.r5.model.SearchParameter)32 FHIRException (org.hl7.fhir.exceptions.FHIRException)13 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)13 ArrayList (java.util.ArrayList)12 File (java.io.File)9 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)9 SearchParameter (org.hl7.fhir.r4b.model.SearchParameter)9 CodeType (org.hl7.fhir.r5.model.CodeType)9 HashSet (java.util.HashSet)8 FileOutputStream (java.io.FileOutputStream)7 XmlParser (org.hl7.fhir.r5.formats.XmlParser)7 FileNotFoundException (java.io.FileNotFoundException)6 IOException (java.io.IOException)6 SearchParameterDefn (org.hl7.fhir.definitions.model.SearchParameterDefn)6 CanonicalResource (org.hl7.fhir.r5.model.CanonicalResource)6 ContactPoint (org.hl7.fhir.r5.model.ContactPoint)6 ImplementationGuide (org.hl7.fhir.r5.model.ImplementationGuide)6 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)6 ConstraintStructure (org.hl7.fhir.definitions.model.ConstraintStructure)5 Example (org.hl7.fhir.definitions.model.Example)5