Search in sources :

Example 16 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 17 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 18 with Tag

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

the class RdfParser method composeMeta.

protected void composeMeta(Complex parent, String parentType, String name, Meta element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeElement(t, "Meta", name, element, index);
    if (element.hasVersionIdElement())
        composeId(t, "Meta", "versionId", element.getVersionIdElement(), -1);
    if (element.hasLastUpdatedElement())
        composeInstant(t, "Meta", "lastUpdated", element.getLastUpdatedElement(), -1);
    if (element.hasSourceElement())
        composeUri(t, "Meta", "source", element.getSourceElement(), -1);
    for (int i = 0; i < element.getProfile().size(); i++) composeCanonical(t, "Meta", "profile", element.getProfile().get(i), i);
    for (int i = 0; i < element.getSecurity().size(); i++) composeCoding(t, "Meta", "security", element.getSecurity().get(i), i);
    for (int i = 0; i < element.getTag().size(); i++) composeCoding(t, "Meta", "tag", element.getTag().get(i), i);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Example 19 with Tag

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

the class NarrativeGenerator method generateVersionNotice.

@SuppressWarnings("rawtypes")
private void generateVersionNotice(XhtmlNode x, ValueSetExpansionComponent expansion) {
    Map<String, String> versions = new HashMap<String, String>();
    boolean firstVersion = true;
    for (ValueSetExpansionParameterComponent p : expansion.getParameter()) {
        if (p.getName().equals("version")) {
            String[] parts = ((PrimitiveType) p.getValue()).asStringValue().split("\\|");
            if (parts.length == 2)
                versions.put(parts[0], parts[1]);
            if (!versions.isEmpty()) {
                StringBuilder b = new StringBuilder();
                if (firstVersion) {
                    // the first version
                    // set the <p> tag and style attribute
                    x.para().setAttribute("style", "border: black 1px dotted; background-color: #EEEEEE; padding: 8px");
                    firstVersion = false;
                } else {
                    // the second (or greater) version
                    // add line break before the version text
                    x.br();
                }
                b.append("Expansion based on ");
                boolean firstPart = true;
                for (String s : versions.keySet()) {
                    if (firstPart)
                        firstPart = false;
                    else
                        b.append(", ");
                    if (!s.equals("http://snomed.info/sct"))
                        b.append(describeSystem(s) + " version " + versions.get(s));
                    else {
                        parts = versions.get(s).split("\\/");
                        if (parts.length >= 5) {
                            String m = describeModule(parts[4]);
                            if (parts.length == 7)
                                b.append("SNOMED CT " + m + " edition " + formatSCTDate(parts[6]));
                            else
                                b.append("SNOMED CT " + m + " edition");
                        } else
                            b.append(describeSystem(s) + " version " + versions.get(s));
                    }
                }
                // add the version text
                x.addText(b.toString());
            }
        }
    }
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) HashMap(java.util.HashMap) ValueSetExpansionParameterComponent(org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionParameterComponent)

Example 20 with Tag

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

the class NarrativeGenerator method generateVersionNotice.

@SuppressWarnings("rawtypes")
private void generateVersionNotice(XhtmlNode x, ValueSetExpansionComponent expansion) {
    Map<String, String> versions = new HashMap<String, String>();
    boolean firstVersion = true;
    for (ValueSetExpansionParameterComponent p : expansion.getParameter()) {
        if (p.getName().equals("version")) {
            String[] parts = ((PrimitiveType) p.getValue()).asStringValue().split("\\|");
            if (parts.length == 2)
                versions.put(parts[0], parts[1]);
            if (!versions.isEmpty()) {
                StringBuilder b = new StringBuilder();
                if (firstVersion) {
                    // the first version
                    // set the <p> tag and style attribute
                    x.para().setAttribute("style", "border: black 1px dotted; background-color: #EEEEEE; padding: 8px");
                    firstVersion = false;
                } else {
                    // the second (or greater) version
                    // add line break before the version text
                    x.br();
                }
                b.append("Expansion based on ");
                boolean firstPart = true;
                for (String s : versions.keySet()) {
                    if (firstPart)
                        firstPart = false;
                    else
                        b.append(", ");
                    if (!s.equals("http://snomed.info/sct"))
                        b.append(describeSystem(s) + " version " + versions.get(s));
                    else {
                        parts = versions.get(s).split("\\/");
                        if (parts.length >= 5) {
                            String m = describeModule(parts[4]);
                            if (parts.length == 7)
                                b.append("SNOMED CT " + m + " edition " + formatSCTDate(parts[6]));
                            else
                                b.append("SNOMED CT " + m + " edition");
                        } else
                            b.append(describeSystem(s) + " version " + versions.get(s));
                    }
                }
                // add the version text
                x.addText(b.toString());
            }
        }
    }
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder)

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