Search in sources :

Example 6 with IndexOf

use of org.hl7.elm.r1.IndexOf in project kindling by HL7.

the class ResourceParser method parsePacks.

private void parsePacks(ResourceDefn r, String n, String t) throws Exception {
    Set<String> codes = new HashSet<>();
    ListResource list = (ListResource) parseXml("list-" + t + "-packs.xml");
    for (ListResourceEntryComponent le : list.getEntry()) {
        String id = le.getItem().getReference().substring(le.getItem().getReference().indexOf("/") + 1);
        if (codes.contains(id)) {
            throw new FHIRException("Duplicate code " + id + " for resource " + n);
        }
        codes.add(id);
        ImplementationGuide ig = (ImplementationGuide) parseXml("implementationguide-" + id + ".xml");
        if (!id.startsWith(r.getName() + "-")) {
            throw new FHIRException("Illegal ig name " + id + " - should start with " + r.getName() + "-");
        }
        id = id.substring(t.length() + 1);
        r.getConformancePackages().add(convertPack(ig, id, r.getWg()));
    }
}
Also used : ImplementationGuide(org.hl7.fhir.r5.model.ImplementationGuide) ListResourceEntryComponent(org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent) ListResource(org.hl7.fhir.r5.model.ListResource) FHIRException(org.hl7.fhir.exceptions.FHIRException) HashSet(java.util.HashSet)

Example 7 with IndexOf

use of org.hl7.elm.r1.IndexOf in project kindling by HL7.

the class WebMaker method insertTargetImages.

private void insertTargetImages(XhtmlNode node, XhtmlNode parent, String pagename) {
    if (node.getName() != null && (node.getName().equals("h1") || node.getName().equals("h2") || node.getName().equals("h3") || node.getName().equals("h4") || node.getName().equals("h5"))) {
        int i = parent.getChildNodes().indexOf(node) - 1;
        while (i > 0 && parent.getChildNodes().get(i).getNodeType() != NodeType.Element) i--;
        if (i > 0 && parent.getChildNodes().get(i).getName().equals("a")) {
            String link = parent.getChildNodes().get(i).getAttribute("name");
            parent.getChildNodes().get(i).addText(" ");
            node.addText(" ");
            if (node.hasAttribute("class"))
                throw new Error("test");
            else
                node.setAttribute("class", "self-link-parent");
            XhtmlNode a = node.addTag("a");
            a.setAttribute("href", pagename + "#" + link);
            a.setAttribute("title", "link to here");
            XhtmlNode svg = a.addTag("svg");
            XhtmlNode path = svg.addTag("path");
            String pathData = "M1520 1216q0-40-28-68l-208-208q-28-28-68-28-42 0-72 32 3 3 19 18.5t21.5 21.5 15 19 13 25.5 3.5 27.5q0 40-28 68t-68 28q-15 0-27.5-3.5t-25.5-13-19-15-21.5-21.5-18.5-19q-33 31-33 73 0 40 28 68l206 207q27 27 68 27 40 0 68-26l147-146q28-28 28-67zm-703-705q0-40-28-68l-206-207q-28-28-68-28-39 0-68 27l-147 146q-28 28-28 67 0 40 28 68l208 208q27 27 68 27 42 0 72-31-3-3-19-18.5t-21.5-21.5-15-19-13-25.5-3.5-27.5q0-40 28-68t68-28q15 0 27.5 3.5t25.5 13 19 15 21.5 21.5 18.5 19q33-31 33-73zm895 705q0 120-85 203l-147 146q-83 83-203 83-121 0-204-85l-206-207q-83-83-83-203 0-123 88-209l-88-88q-86 88-208 88-120 0-204-84l-208-208q-84-84-84-204t85-203l147-146q83-83 203-83 121 0 204 85l206 207q83 83 83 203 0 123-88 209l88 88q86-88 208-88 120 0 204 84l208 208q84 84 84 204z";
            svg.attribute("height", "20").attribute("width", "20").attribute("viewBox", "0 0 1792 1792").attribute("class", "self-link");
            path.attribute("d", pathData).attribute("fill", "navy");
        }
    }
    for (XhtmlNode child : node.getChildNodes()) insertTargetImages(child, node, pagename);
}
Also used : XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 8 with IndexOf

use of org.hl7.elm.r1.IndexOf in project org.hl7.fhir.core by hapifhir.

the class FHIRPathEngine method processDateConstant.

private Base processDateConstant(Object appInfo, String value) throws PathEngineException {
    if (value.startsWith("T"))
        return new TimeType(value.substring(1));
    String v = value;
    if (v.length() > 10) {
        int i = v.substring(10).indexOf("-");
        if (i == -1)
            i = v.substring(10).indexOf("+");
        if (i == -1)
            i = v.substring(10).indexOf("Z");
        v = i == -1 ? value : v.substring(0, 10 + i);
    }
    if (v.length() > 10)
        return new DateTimeType(value);
    else
        return new DateType(value);
}
Also used : DateTimeType(org.hl7.fhir.dstu2.model.DateTimeType) DateType(org.hl7.fhir.dstu2.model.DateType) DateTimeType(org.hl7.fhir.dstu2.model.DateTimeType) TimeType(org.hl7.fhir.dstu2.model.TimeType)

Example 9 with IndexOf

use of org.hl7.elm.r1.IndexOf in project org.hl7.fhir.core by hapifhir.

the class ProfileUtilities method extensionIsComplex.

private boolean extensionIsComplex(String value) {
    if (value.contains("#")) {
        StructureDefinition ext = context.fetchResource(StructureDefinition.class, value.substring(0, value.indexOf("#")));
        if (ext == null)
            return false;
        String tail = value.substring(value.indexOf("#") + 1);
        ElementDefinition ed = null;
        for (ElementDefinition ted : ext.getSnapshot().getElement()) {
            if (tail.equals(ted.getSliceName())) {
                ed = ted;
                break;
            }
        }
        if (ed == null)
            return false;
        int i = ext.getSnapshot().getElement().indexOf(ed);
        int j = i + 1;
        while (j < ext.getSnapshot().getElement().size() && !ext.getSnapshot().getElement().get(j).getPath().equals(ed.getPath())) j++;
        return j - i > 5;
    } else {
        StructureDefinition ext = context.fetchResource(StructureDefinition.class, value);
        return ext != null && ext.getSnapshot().getElement().size() > 5;
    }
}
Also used : StructureDefinition(org.hl7.fhir.dstu3.model.StructureDefinition) ElementDefinition(org.hl7.fhir.dstu3.model.ElementDefinition)

Example 10 with IndexOf

use of org.hl7.elm.r1.IndexOf in project org.hl7.fhir.core by hapifhir.

the class ProfileUtilities method copyElements.

private void copyElements(StructureDefinition sd, List<ElementDefinition> list) {
    for (ElementDefinition ed : list) {
        if (ed.getPath().contains(".")) {
            ElementDefinition n = ed.copy();
            n.setPath(sd.getSnapshot().getElementFirstRep().getPath() + "." + ed.getPath().substring(ed.getPath().indexOf(".") + 1));
            sd.getSnapshot().addElement(n);
        }
    }
}
Also used : ElementDefinition(org.hl7.fhir.dstu3.model.ElementDefinition)

Aggregations

DefinitionException (org.hl7.fhir.exceptions.DefinitionException)12 ArrayList (java.util.ArrayList)11 FHIRException (org.hl7.fhir.exceptions.FHIRException)11 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)9 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)8 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)7 FileNotFoundException (java.io.FileNotFoundException)6 IOException (java.io.IOException)6 ContactPoint (org.hl7.fhir.r5.model.ContactPoint)6 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)6 List (java.util.List)5 ElementDefinition (org.hl7.fhir.r4.model.ElementDefinition)5 ElementDefinition (org.hl7.fhir.r4b.model.ElementDefinition)5 File (java.io.File)4 NotImplementedException (org.apache.commons.lang3.NotImplementedException)4 ElementDefinition (org.hl7.fhir.dstu3.model.ElementDefinition)4 PathEngineException (org.hl7.fhir.exceptions.PathEngineException)4 URISyntaxException (java.net.URISyntaxException)3 ParseException (java.text.ParseException)3 IndexOf (io.atlasmap.v2.IndexOf)2