Search in sources :

Example 21 with Tag

use of org.hl7.cql_annotations.r1.Tag in project org.hl7.fhir.core by hapifhir.

the class NarrativeGenerator method renderResponse.

private void renderResponse(XhtmlNode root, BundleEntryResponseComponent response) {
    root.para().addText("Request:");
    StringBuilder b = new StringBuilder();
    b.append(response.getStatus() + "\r\n");
    if (response.hasLocation())
        b.append("Location: " + response.getLocation() + "\r\n");
    if (response.hasEtag())
        b.append("E-Tag: " + response.getEtag() + "\r\n");
    if (response.hasLastModified())
        b.append("LastModified: " + response.getEtag() + "\r\n");
    root.pre().addText(b.toString());
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder)

Example 22 with Tag

use of org.hl7.cql_annotations.r1.Tag in project org.hl7.fhir.core by hapifhir.

the class Turtle method parseComplex.

private TTLComplex parseComplex(Lexer lexer) throws FHIRFormatError {
    TTLComplex result = new TTLComplex(lexer.startLine, lexer.startCol);
    boolean done = lexer.peek(LexerTokenType.TOKEN, "]");
    while (!done) {
        String uri = null;
        if (lexer.peekType() == LexerTokenType.URI)
            uri = lexer.uri();
        else {
            String t = lexer.peekType() == LexerTokenType.WORD ? lexer.word() : null;
            if (lexer.type == LexerTokenType.TOKEN && lexer.token.equals(":")) {
                lexer.token(":");
                if (!prefixes.containsKey(t))
                    throw new FHIRFormatError("unknown prefix " + t);
                uri = prefixes.get(t) + lexer.word();
            } else if (t.equals("a"))
                uri = prefixes.get("rdfs") + "type";
            else
                throw lexer.error("unexpected token");
        }
        boolean inlist = false;
        if (lexer.peek(LexerTokenType.TOKEN, "(")) {
            inlist = true;
            lexer.token("(");
        }
        boolean rpt = false;
        do {
            if (lexer.peek(LexerTokenType.TOKEN, "[")) {
                lexer.token("[");
                result.addPredicate(uri, parseComplex(lexer));
                lexer.token("]");
            } else if (lexer.peekType() == LexerTokenType.URI) {
                TTLURL u = new TTLURL(lexer.startLine, lexer.startCol);
                u.setUri(lexer.uri());
                result.addPredicate(uri, u);
            } else if (lexer.peekType() == LexerTokenType.LITERAL) {
                TTLLiteral u = new TTLLiteral(lexer.startLine, lexer.startCol);
                u.value = lexer.literal();
                if (lexer.peek(LexerTokenType.TOKEN, "^")) {
                    lexer.token("^");
                    lexer.token("^");
                    if (lexer.peekType() == LexerTokenType.URI) {
                        u.type = lexer.uri();
                    } else {
                        String l = lexer.word();
                        lexer.token(":");
                        u.type = prefixes.get(l) + lexer.word();
                    }
                }
                if (lexer.peek(LexerTokenType.TOKEN, "@")) {
                    // lang tag - skip it
                    lexer.token("@");
                    String lang = lexer.word();
                    if (!lang.matches(LANG_REGEX)) {
                        throw new FHIRFormatError("Invalid Language tag " + lang);
                    }
                }
                result.addPredicate(uri, u);
            } else if (lexer.peekType() == LexerTokenType.WORD || lexer.peek(LexerTokenType.TOKEN, ":")) {
                int sl = lexer.startLine;
                int sc = lexer.startCol;
                String pfx = lexer.peekType() == LexerTokenType.WORD ? lexer.word() : null;
                if (Utilities.isDecimal(pfx, true) && !lexer.peek(LexerTokenType.TOKEN, ":")) {
                    TTLLiteral u = new TTLLiteral(sl, sc);
                    u.value = pfx;
                    result.addPredicate(uri, u);
                } else if (("false".equals(pfx) || "true".equals(pfx)) && !lexer.peek(LexerTokenType.TOKEN, ":")) {
                    TTLLiteral u = new TTLLiteral(sl, sc);
                    u.value = pfx;
                    result.addPredicate(uri, u);
                } else {
                    if (!prefixes.containsKey(pfx))
                        throw new FHIRFormatError("Unknown prefix " + (pfx == null ? "''" : pfx));
                    TTLURL u = new TTLURL(sl, sc);
                    lexer.token(":");
                    u.setUri(prefixes.get(pfx) + lexer.word());
                    result.addPredicate(uri, u);
                }
            } else if (!lexer.peek(LexerTokenType.TOKEN, ";") && (!inlist || !lexer.peek(LexerTokenType.TOKEN, ")"))) {
                throw new FHIRFormatError("unexpected token " + lexer.token);
            }
            if (inlist)
                rpt = !lexer.peek(LexerTokenType.TOKEN, ")");
            else {
                rpt = lexer.peek(LexerTokenType.TOKEN, ",");
                if (rpt)
                    lexer.readNext(false);
            }
        } while (rpt);
        if (inlist)
            lexer.token(")");
        if (lexer.peek(LexerTokenType.TOKEN, ";")) {
            while ((lexer.peek(LexerTokenType.TOKEN, ";"))) lexer.token(";");
            done = lexer.peek(LexerTokenType.TOKEN, ".") || lexer.peek(LexerTokenType.TOKEN, "]");
        } else {
            done = true;
        }
    }
    return result;
}
Also used : FHIRFormatError(org.hl7.fhir.exceptions.FHIRFormatError)

Example 23 with Tag

use of org.hl7.cql_annotations.r1.Tag in project org.hl7.fhir.core by hapifhir.

the class XhtmlParser method parse.

private XhtmlDocument parse(String entryName) throws FHIRFormatError, IOException {
    XhtmlDocument result = new XhtmlDocument();
    skipWhiteSpaceAndComments(result);
    if (peekChar() != '<')
        throw new FHIRFormatError("Unable to Parse HTML - does not start with tag. Found " + peekChar() + descLoc());
    readChar();
    markLocation();
    QName n = new QName(readName().toLowerCase());
    if ((entryName != null) && !n.getName().equals(entryName))
        throw new FHIRFormatError("Unable to Parse HTML - starts with '" + n + "' not '" + entryName + "'" + descLoc());
    XhtmlNode root = result.addTag(n.getName());
    root.setLocation(markLocation());
    parseAttributes(root);
    markLocation();
    NSMap nsm = checkNamespaces(n, root, null, true);
    if (readChar() == '/') {
        if (peekChar() != '>')
            throw new FHIRFormatError("unexpected non-end of element " + n + " " + descLoc());
        readChar();
    } else {
        unwindPoint = null;
        List<XhtmlNode> p = new ArrayList<>();
        parseElementInner(root, p, nsm, true);
    }
    return result;
}
Also used : FHIRFormatError(org.hl7.fhir.exceptions.FHIRFormatError) ArrayList(java.util.ArrayList)

Example 24 with Tag

use of org.hl7.cql_annotations.r1.Tag in project org.hl7.fhir.core by hapifhir.

the class XhtmlParser method parseFragment.

private XhtmlNode parseFragment() throws IOException, FHIRException {
    skipWhiteSpace();
    if (peekChar() != '<')
        throw new FHIRException("Unable to Parse HTML - does not start with tag. Found " + peekChar() + descLoc());
    readChar();
    if (peekChar() == '?') {
        readToTagEnd();
        skipWhiteSpaceInternal();
        if (peekChar() != '<')
            throw new FHIRException("Unable to Parse HTML - does not start with tag after processing instruction. Found " + peekChar() + descLoc());
        readChar();
    }
    String n = readName().toLowerCase();
    readToTagEnd();
    XhtmlNode result = new XhtmlNode(NodeType.Element);
    int colonIndex = n.indexOf(':');
    if (colonIndex != -1) {
        n = n.substring(colonIndex + 1);
    }
    result.setName(n);
    unwindPoint = null;
    List<XhtmlNode> p = new ArrayList<>();
    parseElementInner(result, p, null, true);
    return result;
}
Also used : ArrayList(java.util.ArrayList) FHIRException(org.hl7.fhir.exceptions.FHIRException)

Example 25 with Tag

use of org.hl7.cql_annotations.r1.Tag in project org.hl7.fhir.core by hapifhir.

the class Turtle method parseComplex.

private TTLComplex parseComplex(Lexer lexer) throws FHIRFormatError {
    TTLComplex result = new TTLComplex(lexer.startLine, lexer.startCol);
    boolean done = lexer.peek(LexerTokenType.TOKEN, "]");
    while (!done) {
        String uri = null;
        if (lexer.peekType() == LexerTokenType.URI)
            uri = lexer.uri();
        else {
            String t = lexer.peekType() == LexerTokenType.WORD ? lexer.word() : null;
            if (lexer.type == LexerTokenType.TOKEN && lexer.token.equals(":")) {
                lexer.token(":");
                if (!prefixes.containsKey(t))
                    throw new FHIRFormatError("unknown prefix " + t);
                uri = prefixes.get(t) + lexer.word();
            } else if (t.equals("a"))
                uri = prefixes.get("rdfs") + "type";
            else
                throw lexer.error("unexpected token");
        }
        boolean inlist = false;
        if (lexer.peek(LexerTokenType.TOKEN, "(")) {
            inlist = true;
            lexer.token("(");
        }
        boolean rpt = false;
        do {
            if (lexer.peek(LexerTokenType.TOKEN, "[")) {
                lexer.token("[");
                result.addPredicate(uri, parseComplex(lexer));
                lexer.token("]");
            } else if (lexer.peekType() == LexerTokenType.URI) {
                TTLURL u = new TTLURL(lexer.startLine, lexer.startCol);
                u.setUri(lexer.uri());
                result.addPredicate(uri, u);
            } else if (lexer.peekType() == LexerTokenType.LITERAL) {
                TTLLiteral u = new TTLLiteral(lexer.startLine, lexer.startCol);
                u.value = lexer.literal();
                if (lexer.peek(LexerTokenType.TOKEN, "^")) {
                    lexer.token("^");
                    lexer.token("^");
                    if (lexer.peekType() == LexerTokenType.URI) {
                        u.type = lexer.uri();
                    } else {
                        String l = lexer.word();
                        lexer.token(":");
                        u.type = prefixes.get(l) + lexer.word();
                    }
                }
                if (lexer.peek(LexerTokenType.TOKEN, "@")) {
                    // lang tag - skip it
                    lexer.token("@");
                    String lang = lexer.word();
                    if (!lang.matches(LANG_REGEX)) {
                        throw new FHIRFormatError("Invalid Language tag " + lang);
                    }
                }
                result.addPredicate(uri, u);
            } else if (lexer.peekType() == LexerTokenType.WORD || lexer.peek(LexerTokenType.TOKEN, ":")) {
                int sl = lexer.startLine;
                int sc = lexer.startCol;
                String pfx = lexer.peekType() == LexerTokenType.WORD ? lexer.word() : null;
                if (Utilities.isDecimal(pfx, true, true) && !lexer.peek(LexerTokenType.TOKEN, ":")) {
                    TTLLiteral u = new TTLLiteral(sl, sc);
                    u.value = pfx;
                    result.addPredicate(uri, u);
                } else if (("false".equals(pfx) || "true".equals(pfx)) && !lexer.peek(LexerTokenType.TOKEN, ":")) {
                    TTLLiteral u = new TTLLiteral(sl, sc);
                    u.value = pfx;
                    result.addPredicate(uri, u);
                } else {
                    if (!prefixes.containsKey(pfx))
                        throw new FHIRFormatError("Unknown prefix " + (pfx == null ? "''" : pfx));
                    TTLURL u = new TTLURL(sl, sc);
                    lexer.token(":");
                    u.setUri(prefixes.get(pfx) + lexer.word());
                    result.addPredicate(uri, u);
                }
            } else if (!lexer.peek(LexerTokenType.TOKEN, ";") && (!inlist || !lexer.peek(LexerTokenType.TOKEN, ")"))) {
                throw new FHIRFormatError("unexpected token " + lexer.token);
            }
            if (inlist)
                rpt = !lexer.peek(LexerTokenType.TOKEN, ")");
            else {
                rpt = lexer.peek(LexerTokenType.TOKEN, ",");
                if (rpt)
                    lexer.readNext(false);
            }
        } while (rpt);
        if (inlist)
            lexer.token(")");
        if (lexer.peek(LexerTokenType.TOKEN, ";")) {
            while ((lexer.peek(LexerTokenType.TOKEN, ";"))) lexer.token(";");
            done = lexer.peek(LexerTokenType.TOKEN, ".") || lexer.peek(LexerTokenType.TOKEN, "]");
        } else {
            done = true;
        }
    }
    return result;
}
Also used : FHIRFormatError(org.hl7.fhir.exceptions.FHIRFormatError)

Aggregations

Tag (org.openstreetmap.osmosis.core.domain.v0_6.Tag)66 Test (org.junit.Test)26 CommonEntityData (org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData)23 WayNode (org.openstreetmap.osmosis.core.domain.v0_6.WayNode)17 IOException (java.io.IOException)16 ArrayList (java.util.ArrayList)16 Node (org.openstreetmap.osmosis.core.domain.v0_6.Node)16 OsmUser (org.openstreetmap.osmosis.core.domain.v0_6.OsmUser)16 Date (java.util.Date)12 Way (org.openstreetmap.osmosis.core.domain.v0_6.Way)12 Coding (org.hl7.fhir.r4.model.Coding)10 RelationMember (org.openstreetmap.osmosis.core.domain.v0_6.RelationMember)10 OsmosisRuntimeException (org.openstreetmap.osmosis.core.OsmosisRuntimeException)9 Relation (org.openstreetmap.osmosis.core.domain.v0_6.Relation)9 Test (org.junit.jupiter.api.Test)7 SQLException (java.sql.SQLException)6 UUID (java.util.UUID)6 LocationTag (org.openmrs.LocationTag)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 Osmformat (crosby.binary.Osmformat)5