Search in sources :

Example 1 with OperationDefinitionParameterBindingComponent

use of org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterBindingComponent in project kindling by HL7.

the class SpreadSheetReloader method parseBinding.

private void parseBinding(OperationDefinitionParameterComponent param, String value, XSSFSheet bindings) {
    if (Utilities.noString(value)) {
        param.setBinding(null);
    } else {
        XSSFRow cols = bindings.getRow(0);
        XSSFRow row = lookupRow(bindings, cols, CN_BINDING_NAME, value);
        if (row == null) {
            throw new FHIRException("Unable to find binding " + value + " in " + xlsx);
        }
        OperationDefinitionParameterBindingComponent bs = param.getBinding();
        bs.removeExtension(BuildExtensions.EXT_NAME);
        readExt(bs, row, cols, CN_BINDING_NAME, BuildExtensions.EXT_BINDING_NAME, ExtensionType.String);
        readExt(bs, row, cols, CN_DEFINITION, BuildExtensions.EXT_DEFINITION, ExtensionType.String);
        bs.setStrength(BindingStrength.fromCode(getValue(row, cols, CN_STRENGTH)));
        bs.setValueSet(getValue(row, cols, CN_VALUE_SET));
        readExt(bs, row, cols, CN_OID, BuildExtensions.EXT_VS_OID, ExtensionType.String);
        readExt(bs, row, cols, CN_URI, BuildExtensions.EXT_URI, ExtensionType.String);
        readExt(bs, row, cols, CN_WEBSITE_EMAIL, BuildExtensions.EXT_WEBSITE, ExtensionType.Uri);
        readExt(bs, row, cols, CN_V2, BuildExtensions.EXT_V2_MAP, ExtensionType.String);
        readExt(bs, row, cols, CN_V3, BuildExtensions.EXT_V3_MAP, ExtensionType.String);
        readExt(bs, row, cols, CN_COPYRIGHT, BuildExtensions.EXT_COPYRIGHT, ExtensionType.String);
        readExt(bs, row, cols, CN_COMMITTEE_NOTES, BuildExtensions.EXT_COMMITTEE_NOTES, ExtensionType.Markdown);
    }
}
Also used : XSSFRow(org.apache.poi.xssf.usermodel.XSSFRow) OperationDefinitionParameterBindingComponent(org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterBindingComponent) FHIRException(org.hl7.fhir.exceptions.FHIRException)

Example 2 with OperationDefinitionParameterBindingComponent

use of org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterBindingComponent in project kindling by HL7.

the class SpreadSheetCreator method bind.

private String bind(OperationDefinitionParameterComponent ed, XSSFSheet bindings) {
    if (ed.hasBinding()) {
        Row row = bindings.createRow(bindingRowCount++);
        int columnCount = 0;
        String name;
        OperationDefinitionParameterBindingComponent bs = ed.getBinding();
        sortExtensions(ed.getBinding());
        if (bs.hasExtension(BuildExtensions.EXT_BINDING_NAME)) {
            name = bs.getExtensionString(BuildExtensions.EXT_BINDING_NAME);
        } else {
            name = "??";
        }
        addCell(name, row, columnCount++);
        addCell(ext(bs, BuildExtensions.EXT_DEFINITION), row, columnCount++);
        addCell(bs.getStrength().toCode(), row, columnCount++);
        addCell(bs.getValueSet(), row, columnCount++);
        addCell(null, row, columnCount++);
        addCell(ext(bs, BuildExtensions.EXT_VS_OID), row, columnCount++);
        addCell(ext(bs, BuildExtensions.EXT_URI), row, columnCount++);
        addCell(ext(bs, BuildExtensions.EXT_WEBSITE), row, columnCount++);
        addCell(ext(bs, BuildExtensions.EXT_V2_MAP), row, columnCount++);
        addCell(ext(bs, BuildExtensions.EXT_V3_MAP), row, columnCount++);
        addCell(ext(bs, BuildExtensions.EXT_COPYRIGHT), row, columnCount++);
        addCell(ext(bs, BuildExtensions.EXT_COMMITTEE_NOTES), row, columnCount++);
        return name;
    }
    return null;
}
Also used : OperationDefinitionParameterBindingComponent(org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterBindingComponent) Row(org.apache.poi.ss.usermodel.Row)

Example 3 with OperationDefinitionParameterBindingComponent

use of org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterBindingComponent in project kindling by HL7.

the class ResourceParser method parseBinding.

private BindingSpecification parseBinding(OperationDefinitionParameterBindingComponent binding) throws IOException {
    BindingSpecification bs = new BindingSpecification("core", binding.getExtensionString(BuildExtensions.EXT_BINDING_NAME), "true".equals(binding.getExtensionString("http://hl7.org/fhir/StructureDefinition/elementdefinition-isCommonBinding")));
    bs.setStrength(binding.getStrength());
    bs.setBindingMethod(BindingMethod.ValueSet);
    bs.setReference(binding.getValueSet());
    if (bs.hasReference()) {
        bs.setValueSet(loadValueSet(bs.getReference(), false));
    }
    if (binding.hasExtension("http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet")) {
        bs.setMaxReference(binding.getExtensionString("http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet"));
        bs.setMaxValueSet(loadValueSet(bs.getMaxReference(), false));
    }
    if (binding.hasExtension(BuildExtensions.EXT_V2_MAP)) {
        bs.setV2Map(binding.getExtensionString(BuildExtensions.EXT_V2_MAP));
    }
    if (binding.hasExtension(BuildExtensions.EXT_V3_MAP)) {
        bs.setV3Map(binding.getExtensionString(BuildExtensions.EXT_V3_MAP));
    }
    if (binding.hasExtension(BuildExtensions.EXT_DEFINITION)) {
        bs.setDefinition(binding.getExtensionString(BuildExtensions.EXT_DEFINITION));
    }
    if (binding.hasExtension(BuildExtensions.EXT_URI)) {
        bs.setUri(binding.getExtensionString(BuildExtensions.EXT_URI));
    }
    if (binding.hasExtension(BuildExtensions.EXT_WEBSITE)) {
        bs.setWebSite(binding.getExtensionString(BuildExtensions.EXT_WEBSITE));
    }
    if (binding.hasExtension(BuildExtensions.EXT_EMAIL)) {
        bs.setEmail(binding.getExtensionString(BuildExtensions.EXT_EMAIL));
    }
    if (binding.hasExtension(BuildExtensions.EXT_COPYRIGHT)) {
        bs.setCopyright(binding.getExtensionString(BuildExtensions.EXT_COPYRIGHT));
    }
    if (binding.hasExtension(BuildExtensions.EXT_CS_OID)) {
        bs.setCsOid(binding.getExtensionString(BuildExtensions.EXT_CS_OID));
    }
    if (binding.hasExtension(BuildExtensions.EXT_VS_OID)) {
        bs.setVsOid(binding.getExtensionString(BuildExtensions.EXT_VS_OID));
    }
    if (binding.hasExtension(BuildExtensions.EXT_STATUS)) {
        bs.setStatus(PublicationStatus.fromCode(binding.getExtensionString(BuildExtensions.EXT_STATUS)));
    }
    return bs;
}
Also used : BindingSpecification(org.hl7.fhir.definitions.model.BindingSpecification)

Example 4 with OperationDefinitionParameterBindingComponent

use of org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterBindingComponent in project kindling by HL7.

the class ProfileGenerator method produceOpParam.

private void produceOpParam(String path, List<OperationDefinitionParameterComponent> opd, OperationParameter p, OperationParameterUse defUse) throws Exception {
    OperationDefinitionParameterComponent pp = new OperationDefinitionParameterComponent();
    pp.setName(p.getName());
    if (path.contains("."))
        pp.setUse(defUse);
    else if (p.getUse().equals("in"))
        pp.setUse(OperationParameterUse.IN);
    else if (p.getUse().equals("out"))
        pp.setUse(OperationParameterUse.OUT);
    else
        // but this is validated elsewhere
        throw new Exception("Unable to determine parameter use: " + p.getUse() + " at " + path + "." + p.getName());
    pp.setDocumentation(preProcessMarkdown(p.getDoc(), "Operation Parameter Doco"));
    pp.setMin(p.getMin());
    pp.setMax(p.getMax());
    if (p.getBs() != null) {
        if (p.getBs().hasMax())
            throw new Error("Max binding not handled yet");
        pp.setBinding(new OperationDefinitionParameterBindingComponent().setStrength(p.getBs().getStrength()).setValueSet(buildValueSetReference(p.getBs())));
        if (!Utilities.noString(p.getBinding().getName())) {
            pp.getBinding().addExtension("http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName", new StringType(p.getBinding().getName()));
        }
    }
    if (!Utilities.noString(p.getProfile())) {
        pp.addTargetProfile(p.getProfile());
    }
    opd.add(pp);
    if (p.getFhirType().equals("Tuple")) {
        for (OperationParameter part : p.getParts()) {
            produceOpParam(path + "." + p.getName(), pp.getPart(), part, pp.getUse());
        }
    } else {
        List<TypeRef> trs = new TypeParser(version.toCode()).parse(p.getFhirType(), false, null, null, false);
        if (trs.size() > 1) {
            if (p.getSearchType() != null)
                pp.setSearchType(SearchParamType.fromCode(p.getSearchType()));
            pp.setType(Enumerations.FHIRAllTypes.fromCode("Element"));
            for (TypeRef tr : trs) {
                pp.addExtension(ToolingExtensions.EXT_ALLOWED_TYPE, new UriType(tr.getName()));
                if (tr.getParams().size() > 0)
                    throw new Error("Multiple types for an operation parameter, where one is a reference, is not supported by the build tools");
            }
        } else {
            TypeRef tr = trs.get(0);
            if (definitions.getConstraints().containsKey(tr.getName())) {
                ProfiledType pt = definitions.getConstraints().get(tr.getName());
                pp.setType(Enumerations.FHIRAllTypes.fromCode(pt.getBaseType().equals("*") ? "Type" : pt.getBaseType()));
                pp.addTargetProfile("http://hl7.org/fhir/StructureDefinition/" + pt.getName());
            } else {
                if (p.getSearchType() != null)
                    pp.setSearchType(SearchParamType.fromCode(p.getSearchType()));
                pp.setType(Enumerations.FHIRAllTypes.fromCode(tr.getName().equals("*") ? "Type" : tr.getName()));
                if (tr.getParams().size() == 1 && !tr.getParams().get(0).equals("Any"))
                    pp.addTargetProfile("http://hl7.org/fhir/StructureDefinition/" + tr.getParams().get(0));
            }
        }
    }
}
Also used : TypeParser(org.hl7.fhir.definitions.parsers.TypeParser) ProfiledType(org.hl7.fhir.definitions.model.ProfiledType) StringType(org.hl7.fhir.r5.model.StringType) TypeRef(org.hl7.fhir.definitions.model.TypeRef) OperationDefinitionParameterBindingComponent(org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterBindingComponent) OperationParameter(org.hl7.fhir.definitions.model.OperationParameter) FHIRFormatError(org.hl7.fhir.exceptions.FHIRFormatError) FHIRException(org.hl7.fhir.exceptions.FHIRException) URISyntaxException(java.net.URISyntaxException) OperationDefinitionParameterComponent(org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterComponent) UriType(org.hl7.fhir.r5.model.UriType)

Aggregations

OperationDefinitionParameterBindingComponent (org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterBindingComponent)3 FHIRException (org.hl7.fhir.exceptions.FHIRException)2 URISyntaxException (java.net.URISyntaxException)1 Row (org.apache.poi.ss.usermodel.Row)1 XSSFRow (org.apache.poi.xssf.usermodel.XSSFRow)1 BindingSpecification (org.hl7.fhir.definitions.model.BindingSpecification)1 OperationParameter (org.hl7.fhir.definitions.model.OperationParameter)1 ProfiledType (org.hl7.fhir.definitions.model.ProfiledType)1 TypeRef (org.hl7.fhir.definitions.model.TypeRef)1 TypeParser (org.hl7.fhir.definitions.parsers.TypeParser)1 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)1 OperationDefinitionParameterComponent (org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterComponent)1 StringType (org.hl7.fhir.r5.model.StringType)1 UriType (org.hl7.fhir.r5.model.UriType)1