Search in sources :

Example 1 with ElementDefinitionSlicingComponent

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

the class XmlSpecGenerator method describeSlicing.

private String describeSlicing(ElementDefinitionSlicingComponent slicing) {
    CommaSeparatedStringBuilder csv = new CommaSeparatedStringBuilder();
    for (ElementDefinitionSlicingDiscriminatorComponent d : slicing.getDiscriminator()) {
        csv.append(d.getType().toCode() + ":" + d.getPath());
    }
    String s = slicing.getOrdered() ? " in any order" : " in the specified order" + (slicing.hasRules() ? slicing.getRules().getDisplay() : "");
    return " sliced by " + csv.toString() + " " + s;
}
Also used : ElementDefinitionSlicingDiscriminatorComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder)

Example 2 with ElementDefinitionSlicingComponent

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

the class JsonSpecGenerator method describeSlicing.

private String describeSlicing(ElementDefinitionSlicingComponent slicing) {
    CommaSeparatedStringBuilder csv = new CommaSeparatedStringBuilder();
    for (ElementDefinitionSlicingDiscriminatorComponent d : slicing.getDiscriminator()) {
        csv.append(d.getType().toCode() + ":" + d.getPath());
    }
    String s = slicing.getOrdered() ? " in any order, " : " in the specified order, " + (slicing.hasRules() ? slicing.getRules().getDisplay() : "");
    return " sliced by " + csv.toString() + " " + s;
}
Also used : ElementDefinitionSlicingDiscriminatorComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder)

Example 3 with ElementDefinitionSlicingComponent

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

the class ProfileGenerator method processDiscriminator.

private void processDiscriminator(ElementDefn e, String path, ElementDefinition ce) throws Exception {
    ce.setSlicing(new ElementDefinitionSlicingComponent());
    ce.getSlicing().setDescription(e.getSliceDescription());
    String[] d = e.getDiscriminator().get(0).split("\\|");
    if (d.length >= 1)
        ce.getSlicing().addDiscriminator(ProfileUtilities.interpretR2Discriminator(d[0].trim(), false));
    if (d.length >= 2)
        ce.getSlicing().setOrdered(Boolean.parseBoolean(d[1].trim()));
    else
        ce.getSlicing().setOrdered(false);
    if (d.length >= 3)
        ce.getSlicing().setRules(SlicingRules.fromCode(d[2].trim()));
    else
        ce.getSlicing().setRules(SlicingRules.OPEN);
    for (int i = 1; i < e.getDiscriminator().size(); i++) {
        // we've already process the first in the list
        String s = e.getDiscriminator().get(i).trim();
        if (s.contains("|"))
            throw new Exception("illegal discriminator \"" + s + "\" at " + path);
        ce.getSlicing().addDiscriminator(ProfileUtilities.interpretR2Discriminator(s, false));
    }
}
Also used : ElementDefinitionSlicingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent) ContactPoint(org.hl7.fhir.r5.model.ContactPoint) FHIRException(org.hl7.fhir.exceptions.FHIRException) URISyntaxException(java.net.URISyntaxException)

Example 4 with ElementDefinitionSlicingComponent

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

the class DictHTMLGenerator method generateSlicing.

private void generateSlicing(StructureDefinition profile, ElementDefinitionSlicingComponent slicing) throws IOException {
    StringBuilder b = new StringBuilder();
    if (slicing.getOrdered())
        b.append("<li>ordered</li>");
    else
        b.append("<li>unordered</li>");
    if (slicing.hasRules())
        b.append("<li>" + slicing.getRules().getDisplay() + "</li>");
    if (!slicing.getDiscriminator().isEmpty()) {
        b.append("<li>discriminators: ");
        boolean first = true;
        for (ElementDefinitionSlicingDiscriminatorComponent s : slicing.getDiscriminator()) {
            if (first)
                first = false;
            else
                b.append(", ");
            b.append(s.getType().toCode() + ":" + s.getPath());
        }
        b.append("</li>");
    }
    tableRowNE("Slicing", "profiling.html#slicing", "This element introduces a set of slices. The slicing rules are: <ul> " + b.toString() + "</ul>");
}
Also used : ElementDefinitionSlicingDiscriminatorComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder)

Example 5 with ElementDefinitionSlicingComponent

use of org.hl7.fhir.r4b.model.ElementDefinition.ElementDefinitionSlicingComponent in project org.hl7.fhir.core by hapifhir.

the class ProfileUtilities method generateSlicer.

private Slicer generateSlicer(ElementDefinition child, ElementDefinitionSlicingComponent slicing, StructureDefinition structure) {
    // given a child in a structure, it's sliced. figure out the slicing xpath
    if (child.getPath().endsWith(".extension")) {
        ElementDefinition ued = getUrlFor(structure, child);
        if ((ued == null || !ued.hasFixed()) && !(child.hasType() && (child.getType().get(0).hasProfile())))
            return new Slicer(false);
        else {
            Slicer s = new Slicer(true);
            String url = (ued == null || !ued.hasFixed()) ? child.getType().get(0).getProfile() : ((UriType) ued.getFixed()).asStringValue();
            s.name = " with URL = '" + url + "'";
            s.criteria = "[@url = '" + url + "']";
            return s;
        }
    } else
        return new Slicer(false);
}
Also used : ElementDefinition(org.hl7.fhir.dstu3.model.ElementDefinition)

Aggregations

CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)11 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)7 ElementDefinitionSlicingDiscriminatorComponent (org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent)6 Rule (org.hl7.fhir.utilities.xml.SchematronWriter.Rule)6 Section (org.hl7.fhir.utilities.xml.SchematronWriter.Section)6 FHIRException (org.hl7.fhir.exceptions.FHIRException)4 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)4 ElementDefinition (org.hl7.fhir.r4.model.ElementDefinition)4 ElementDefinitionSlicingComponent (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent)4 ElementDefinition (org.hl7.fhir.r4b.model.ElementDefinition)4 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)4 ElementDefinitionSlicingComponent (org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 ElementDefinition (org.hl7.fhir.dstu2.model.ElementDefinition)3 ElementDefinitionSlicingComponent (org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent)3 ElementDefinition (org.hl7.fhir.dstu2016may.model.ElementDefinition)3 ElementDefinitionSlicingComponent (org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionSlicingComponent)3 ElementDefinition (org.hl7.fhir.dstu3.model.ElementDefinition)3 ElementDefinitionSlicingComponent (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent)3