Search in sources :

Example 51 with Extension

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

the class SpreadSheetCreator method exlist.

private String exlist(OperationDefinition opd, boolean isResponse, String lcode) {
    sortExtensions(opd);
    List<String> tl = new ArrayList<>();
    for (Extension ext : opd.getExtensionsByUrl(BuildExtensions.EXT_OP_EXAMPLE)) {
        String list = ext.getExtensionString(BuildExtensions.EXT_OP_EXAMPLE_LIST);
        String resp = ext.getExtensionString(BuildExtensions.EXT_OP_EXAMPLE_RESPONSE);
        if (lcode.equals(list) && ("true".equals(resp)) == isResponse) {
            tl.add(ext.getExtensionString(BuildExtensions.EXT_OP_EXAMPLE_CONTENT));
        }
    }
    return String.join(" | ", tl);
}
Also used : Extension(org.hl7.fhir.r5.model.Extension) ArrayList(java.util.ArrayList)

Example 52 with Extension

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

the class ExtensionDefinitionValidator method checkNoValueAndExtensions.

private void checkNoValueAndExtensions(StructureDefinition sd) throws FHIRException {
    boolean hasValue = false;
    for (ElementDefinition ed : sd.getSnapshot().getElement()) {
        if (ed.getPath().startsWith("Extension.value")) {
            if (!ed.getMax().equals("0")) {
                hasValue = true;
            }
        }
    }
    if (hasValue) {
        for (ElementDefinition ed : sd.getSnapshot().getElement()) {
            if (ed.getPath().equals("Extension.extension")) {
                ed.setMax("0");
            }
            if (ed.getPath().startsWith("Extension.extension.")) {
                throw new FHIRException("The extension " + sd.getUrl() + " has both value and extensions");
            }
        }
        boolean found = false;
        int ip = 0;
        for (ElementDefinition ed : sd.getDifferential().getElement()) {
            if (ed.getPath().equals("Extension.extension")) {
                ed.setMax("0");
                found = true;
            }
            if (ed.getPath().equals("Extension") || ed.getPath().equals("Extension.id"))
                ip++;
        }
        if (!found) {
            ElementDefinition ed = new ElementDefinition();
            ed.setPath("Extension.extension");
            ed.setMax("0");
            sd.getDifferential().getElement().add(ip, ed);
        }
    }
}
Also used : ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition) FHIRException(org.hl7.fhir.exceptions.FHIRException)

Example 53 with Extension

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

the class Regenerator method generateExtension.

private CanonicalResource generateExtension(String root, ResourceDefn r, Profile p, StructureDefinition sd) throws IOException {
    File fn = new File(Utilities.path(root, sd.fhirType().toLowerCase() + "-extension-" + sd.getId() + ".gen.xml"));
    sd.setSnapshot(null);
    new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(fn), sd);
    fn.setLastModified(r.getTimestamp());
    return sd;
}
Also used : XmlParser(org.hl7.fhir.r5.formats.XmlParser) FileOutputStream(java.io.FileOutputStream) File(java.io.File)

Example 54 with Extension

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

the class ResourceParser method convertOperationParameter.

public OperationParameter convertOperationParameter(OperationDefinitionParameterComponent psrc, boolean part) throws IOException {
    List<String> pl = new ArrayList<>();
    for (CanonicalType u : psrc.getTargetProfile()) {
        pl.add(u.asStringValue().replace("http://hl7.org/fhir/StructureDefinition/", ""));
    }
    String t;
    if (psrc.hasExtension(BuildExtensions.EXT_ALLOWED_TYPE)) {
        for (Extension e : psrc.getExtensionsByUrl(BuildExtensions.EXT_ALLOWED_TYPE)) {
            pl.add(e.getValue().primitiveValue());
        }
        t = String.join(" | ", pl);
    } else if (psrc.hasType()) {
        t = psrc.getType().toCode();
        if (pl.size() > 0) {
            t = t + "(" + String.join("|", pl) + ")";
        }
    } else {
        t = "Tuple";
    }
    OperationParameter p = new OperationParameter(psrc.getName(), part ? null : psrc.getUse().toCode(), psrc.getDocumentation(), psrc.getMin(), psrc.getMax(), t, psrc.hasSearchType() ? psrc.getSearchType().toCode() : null, null);
    if (psrc.hasBinding()) {
        p.setBs(parseBinding(psrc.getBinding()));
    }
    for (OperationDefinitionParameterComponent pc : psrc.getPart()) {
        p.getParts().add(convertOperationParameter(pc, true));
    }
    return p;
}
Also used : Extension(org.hl7.fhir.r5.model.Extension) OperationParameter(org.hl7.fhir.definitions.model.OperationParameter) ArrayList(java.util.ArrayList) CanonicalType(org.hl7.fhir.r5.model.CanonicalType) OperationDefinitionParameterComponent(org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterComponent)

Example 55 with Extension

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

the class SvgGenerator method determineMetrics.

private Point determineMetrics(String[] classNames) throws Exception {
    double width = textWidth("Element") * 1.8;
    double height = HEADER_HEIGHT + GAP_HEIGHT * 2;
    // if ("true".equals(ini.getStringProperty("diagram", "element-attributes"))) {
    // height = height + LINE_HEIGHT + GAP_HEIGHT;
    // width = textWidth("extension : Extension 0..*");
    // }
    Point p = new Point(0, 0, PointKind.unknown);
    ClassItem item = new ClassItem(p.x, p.y, width, height, id);
    classes.put(null, item);
    double x = item.right() + MARGIN_X;
    double y = item.bottom() + MARGIN_Y;
    if (classNames != null) {
        for (String cn : classNames) {
            if (definitions.getPrimitives().containsKey(cn)) {
                DefinedCode cd = definitions.getPrimitives().get(cn);
                ElementDefn fake = new ElementDefn();
                fake.setName(cn);
                fakes.put(cn, fake);
                if (cd instanceof DefinedStringPattern)
                    p = determineMetrics(fake, classes.get(fakes.get(((DefinedStringPattern) cd).getBase())), cn, false, cd);
                else
                    p = determineMetrics(fake, item, cn, false, cd);
            } else if ("xhtml".equals(cn)) {
                ElementDefn fake = new ElementDefn();
                fake.setName("xhtml");
                fakes.put("xhtml", fake);
                DefinedCode cd = new DefinedCode("xhtml", "XHTML for resource narrative", null);
                p = determineMetrics(fake, item, cn, false, cd);
            } else if (definitions.getConstraints().containsKey(cn)) {
                ProfiledType cd = definitions.getConstraints().get(cn);
                ElementDefn ed = definitions.getElementDefn(cd.getBaseType());
                ClassItem parentClss = classes.get(ed);
                ElementDefn fake = new ElementDefn();
                fake.setName(cn);
                fakes.put(cn, fake);
                p = determineMetrics(fake, parentClss, cn, false, null);
            } else {
                ElementDefn c = definitions.getElementDefn(cn);
                p = determineMetrics(c, item, c.getName(), false, null);
            }
            x = Math.max(x, p.x + MARGIN_X);
            y = Math.max(y, p.y + MARGIN_Y);
        }
    }
    return new Point(x, y, PointKind.unknown);
}
Also used : DefinedStringPattern(org.hl7.fhir.definitions.model.DefinedStringPattern) ProfiledType(org.hl7.fhir.definitions.model.ProfiledType) DefinedCode(org.hl7.fhir.definitions.model.DefinedCode) ElementDefn(org.hl7.fhir.definitions.model.ElementDefn)

Aggregations

Extension (org.hl7.fhir.r4.model.Extension)154 ArrayList (java.util.ArrayList)104 Coding (org.hl7.fhir.r4.model.Coding)69 Test (org.junit.jupiter.api.Test)69 Extension (org.hl7.fhir.dstu3.model.Extension)67 FHIRException (org.hl7.fhir.exceptions.FHIRException)55 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)46 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)42 Extension (org.hl7.fhir.r5.model.Extension)41 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)39 Test (org.junit.Test)36 Cell (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)35 List (java.util.List)34 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)34 Date (java.util.Date)30 Coding (org.hl7.fhir.dstu3.model.Coding)29 Piece (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece)27 Row (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row)27 Reference (org.hl7.fhir.dstu3.model.Reference)26 Patient (org.hl7.fhir.r4.model.Patient)26