Search in sources :

Example 51 with UriType

use of org.hl7.fhir.dstu2.model.UriType in project org.hl7.fhir.core by hapifhir.

the class StructureMapUtilities method renderImports.

private void renderImports(StringBuilder b, StructureMap map) {
    for (UriType s : map.getImport()) {
        b.append("imports \"");
        b.append(s.getValue());
        b.append("\"\r\n");
    }
    if (map.hasImport())
        b.append("\r\n");
}
Also used : UriType(org.hl7.fhir.dstu2016may.model.UriType)

Example 52 with UriType

use of org.hl7.fhir.dstu2.model.UriType in project org.hl7.fhir.core by hapifhir.

the class FluentPathTests method testTyping.

@Test
public void testTyping() throws FileNotFoundException, IOException, FHIRException {
    ElementDefinition ed = new ElementDefinition();
    ed.getBinding().setValueSet(new UriType("http://test.org"));
    testBoolean(null, ed.getBinding().getValueSet(), "ElementDefinition.binding.valueSetUri", "startsWith('http:') or startsWith('https') or startsWith('urn:')", true);
}
Also used : ElementDefinition(org.hl7.fhir.dstu2016may.model.ElementDefinition) UriType(org.hl7.fhir.dstu2016may.model.UriType) Test(org.junit.jupiter.api.Test)

Example 53 with UriType

use of org.hl7.fhir.dstu2.model.UriType in project org.hl7.fhir.core by hapifhir.

the class SearchParameter method setProperty.

@Override
public Base setProperty(String name, Base value) throws FHIRException {
    if (name.equals("url")) {
        // UriType
        this.url = castToUri(value);
    } else if (name.equals("version")) {
        // StringType
        this.version = castToString(value);
    } else if (name.equals("name")) {
        // StringType
        this.name = castToString(value);
    } else if (name.equals("status")) {
        value = new PublicationStatusEnumFactory().fromType(castToCode(value));
        // Enumeration<PublicationStatus>
        this.status = (Enumeration) value;
    } else if (name.equals("experimental")) {
        // BooleanType
        this.experimental = castToBoolean(value);
    } else if (name.equals("date")) {
        // DateTimeType
        this.date = castToDateTime(value);
    } else if (name.equals("publisher")) {
        // StringType
        this.publisher = castToString(value);
    } else if (name.equals("contact")) {
        this.getContact().add(castToContactDetail(value));
    } else if (name.equals("useContext")) {
        this.getUseContext().add(castToUsageContext(value));
    } else if (name.equals("jurisdiction")) {
        this.getJurisdiction().add(castToCodeableConcept(value));
    } else if (name.equals("purpose")) {
        // MarkdownType
        this.purpose = castToMarkdown(value);
    } else if (name.equals("code")) {
        // CodeType
        this.code = castToCode(value);
    } else if (name.equals("base")) {
        this.getBase().add(castToCode(value));
    } else if (name.equals("type")) {
        value = new SearchParamTypeEnumFactory().fromType(castToCode(value));
        // Enumeration<SearchParamType>
        this.type = (Enumeration) value;
    } else if (name.equals("derivedFrom")) {
        // UriType
        this.derivedFrom = castToUri(value);
    } else if (name.equals("description")) {
        // MarkdownType
        this.description = castToMarkdown(value);
    } else if (name.equals("expression")) {
        // StringType
        this.expression = castToString(value);
    } else if (name.equals("xpath")) {
        // StringType
        this.xpath = castToString(value);
    } else if (name.equals("xpathUsage")) {
        value = new XPathUsageTypeEnumFactory().fromType(castToCode(value));
        // Enumeration<XPathUsageType>
        this.xpathUsage = (Enumeration) value;
    } else if (name.equals("target")) {
        this.getTarget().add(castToCode(value));
    } else if (name.equals("comparator")) {
        value = new SearchComparatorEnumFactory().fromType(castToCode(value));
        this.getComparator().add((Enumeration) value);
    } else if (name.equals("modifier")) {
        value = new SearchModifierCodeEnumFactory().fromType(castToCode(value));
        this.getModifier().add((Enumeration) value);
    } else if (name.equals("chain")) {
        this.getChain().add(castToString(value));
    } else if (name.equals("component")) {
        this.getComponent().add((SearchParameterComponentComponent) value);
    } else
        return super.setProperty(name, value);
    return value;
}
Also used : PublicationStatusEnumFactory(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatusEnumFactory) SearchParamTypeEnumFactory(org.hl7.fhir.dstu3.model.Enumerations.SearchParamTypeEnumFactory)

Example 54 with UriType

use of org.hl7.fhir.dstu2.model.UriType in project org.hl7.fhir.core by hapifhir.

the class NarrativeGenerator method genInclude.

private boolean genInclude(ResourceContext rcontext, XhtmlNode ul, ConceptSetComponent inc, String type, List<String> langs) throws FHIRException {
    boolean hasExtensions = false;
    XhtmlNode li;
    li = ul.li();
    CodeSystem e = context.fetchCodeSystem(inc.getSystem());
    if (inc.hasSystem()) {
        if (inc.getConcept().size() == 0 && inc.getFilter().size() == 0) {
            li.addText(type + " all codes defined in ");
            addCsRef(inc, li, e);
        } else {
            if (inc.getConcept().size() > 0) {
                li.addText(type + " these codes as defined in ");
                addCsRef(inc, li, e);
                XhtmlNode t = li.table("none");
                boolean hasComments = false;
                boolean hasDefinition = false;
                for (ConceptReferenceComponent c : inc.getConcept()) {
                    hasComments = hasComments || ExtensionHelper.hasExtension(c, ToolingExtensions.EXT_VS_COMMENT);
                    hasDefinition = hasDefinition || ExtensionHelper.hasExtension(c, ToolingExtensions.EXT_DEFINITION);
                }
                if (hasComments || hasDefinition)
                    hasExtensions = true;
                addTableHeaderRowStandard(t, false, true, hasDefinition, hasComments, false);
                for (ConceptReferenceComponent c : inc.getConcept()) {
                    XhtmlNode tr = t.tr();
                    XhtmlNode td = tr.td();
                    ConceptDefinitionComponent cc = getConceptForCode(e, c.getCode(), inc);
                    addCodeToTable(false, inc.getSystem(), c.getCode(), c.hasDisplay() ? c.getDisplay() : cc != null ? cc.getDisplay() : "", td);
                    td = tr.td();
                    if (!Utilities.noString(c.getDisplay()))
                        td.addText(c.getDisplay());
                    else if (cc != null && !Utilities.noString(cc.getDisplay()))
                        td.addText(cc.getDisplay());
                    td = tr.td();
                    if (ExtensionHelper.hasExtension(c, ToolingExtensions.EXT_DEFINITION))
                        smartAddText(td, ToolingExtensions.readStringExtension(c, ToolingExtensions.EXT_DEFINITION));
                    else if (cc != null && !Utilities.noString(cc.getDefinition()))
                        smartAddText(td, cc.getDefinition());
                    if (ExtensionHelper.hasExtension(c, ToolingExtensions.EXT_VS_COMMENT)) {
                        smartAddText(tr.td(), "Note: " + ToolingExtensions.readStringExtension(c, ToolingExtensions.EXT_VS_COMMENT));
                    }
                    for (ConceptReferenceDesignationComponent cd : c.getDesignation()) {
                        if (cd.hasLanguage() && !langs.contains(cd.getLanguage()))
                            langs.add(cd.getLanguage());
                    }
                }
            }
            boolean first = true;
            for (ConceptSetFilterComponent f : inc.getFilter()) {
                if (first) {
                    li.addText(type + " codes from ");
                    first = false;
                } else
                    li.tx(" and ");
                addCsRef(inc, li, e);
                li.tx(" where " + f.getProperty() + " " + describe(f.getOp()) + " ");
                if (e != null && codeExistsInValueSet(e, f.getValue())) {
                    String href = prefix + getCsRef(e);
                    if (href.contains("#"))
                        href = href + "-" + Utilities.nmtokenize(f.getValue());
                    else
                        href = href + "#" + e.getId() + "-" + Utilities.nmtokenize(f.getValue());
                    li.ah(href).addText(f.getValue());
                } else if ("concept".equals(f.getProperty()) && inc.hasSystem()) {
                    li.addText(f.getValue());
                    ValidationResult vr = context.validateCode(inc.getSystem(), f.getValue(), null);
                    if (vr.isOk()) {
                        li.tx(" (" + vr.getDisplay() + ")");
                    }
                } else
                    li.addText(f.getValue());
                String disp = ToolingExtensions.getDisplayHint(f);
                if (disp != null)
                    li.tx(" (" + disp + ")");
            }
        }
        if (inc.hasValueSet()) {
            li.tx(", where the codes are contained in ");
            boolean first = true;
            for (UriType vs : inc.getValueSet()) {
                if (first)
                    first = false;
                else
                    li.tx(", ");
                AddVsRef(rcontext, vs.asStringValue(), li);
            }
        }
    } else {
        li = ul.li();
        li.tx("Import all the codes that are contained in ");
        boolean first = true;
        for (UriType vs : inc.getValueSet()) {
            if (first)
                first = false;
            else
                li.tx(", ");
            AddVsRef(rcontext, vs.asStringValue(), li);
        }
    }
    return hasExtensions;
}
Also used : ConceptSetFilterComponent(org.hl7.fhir.dstu3.model.ValueSet.ConceptSetFilterComponent) ConceptDefinitionComponent(org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent) ConceptReferenceDesignationComponent(org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceDesignationComponent) ValidationResult(org.hl7.fhir.dstu3.context.IWorkerContext.ValidationResult) CodeSystem(org.hl7.fhir.dstu3.model.CodeSystem) ConceptReferenceComponent(org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceComponent) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) UriType(org.hl7.fhir.dstu3.model.UriType)

Example 55 with UriType

use of org.hl7.fhir.dstu2.model.UriType in project org.hl7.fhir.core by hapifhir.

the class QuestionnaireBuilder method convertType.

@SuppressWarnings("unchecked")
private Type convertType(Base value, QuestionnaireItemType af, ValueSet vs, String path) throws FHIRException {
    switch(af) {
        // simple cases
        case BOOLEAN:
            if (value instanceof BooleanType)
                return (Type) value;
        case DECIMAL:
            if (value instanceof DecimalType)
                return (Type) value;
        case INTEGER:
            if (value instanceof IntegerType)
                return (Type) value;
        case DATE:
            if (value instanceof DateType)
                return (Type) value;
        case DATETIME:
            if (value instanceof DateTimeType)
                return (Type) value;
        case TIME:
            if (value instanceof TimeType)
                return (Type) value;
        case STRING:
            if (value instanceof StringType)
                return (Type) value;
            else if (value instanceof UriType)
                return new StringType(((UriType) value).asStringValue());
        case TEXT:
            if (value instanceof StringType)
                return (Type) value;
        case QUANTITY:
            if (value instanceof Quantity)
                return (Type) value;
        // ? QuestionnaireItemTypeAttachment: ...?
        case CHOICE:
        case OPENCHOICE:
            if (value instanceof Coding)
                return (Type) value;
            else if (value instanceof Enumeration) {
                Coding cc = new Coding();
                cc.setCode(((Enumeration<Enum<?>>) value).asStringValue());
                cc.setSystem(getSystemForCode(vs, cc.getCode(), path));
                return cc;
            } else if (value instanceof StringType) {
                Coding cc = new Coding();
                cc.setCode(((StringType) value).asStringValue());
                cc.setSystem(getSystemForCode(vs, cc.getCode(), path));
                return cc;
            }
        case REFERENCE:
            if (value instanceof Reference)
                return (Type) value;
            else if (value instanceof StringType) {
                Reference r = new Reference();
                r.setReference(((StringType) value).asStringValue());
            }
    }
    throw new FHIRException("Unable to convert from '" + value.getClass().toString() + "' for Answer Format " + af.toCode() + ", path = " + path);
}
Also used : Enumeration(org.hl7.fhir.dstu3.model.Enumeration) StringType(org.hl7.fhir.dstu3.model.StringType) Reference(org.hl7.fhir.dstu3.model.Reference) BooleanType(org.hl7.fhir.dstu3.model.BooleanType) Quantity(org.hl7.fhir.dstu3.model.Quantity) FHIRException(org.hl7.fhir.exceptions.FHIRException) TimeType(org.hl7.fhir.dstu3.model.TimeType) DateTimeType(org.hl7.fhir.dstu3.model.DateTimeType) UriType(org.hl7.fhir.dstu3.model.UriType) IntegerType(org.hl7.fhir.dstu3.model.IntegerType) DateTimeType(org.hl7.fhir.dstu3.model.DateTimeType) Coding(org.hl7.fhir.dstu3.model.Coding) DecimalType(org.hl7.fhir.dstu3.model.DecimalType) DateType(org.hl7.fhir.dstu3.model.DateType)

Aggregations

FHIRException (org.hl7.fhir.exceptions.FHIRException)60 UriType (org.hl7.fhir.r5.model.UriType)45 ArrayList (java.util.ArrayList)42 UriType (org.hl7.fhir.r4.model.UriType)41 UriType (org.hl7.fhir.r4b.model.UriType)29 UriType (org.hl7.fhir.dstu3.model.UriType)26 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)24 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)22 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)19 List (java.util.List)17 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)16 NotImplementedException (org.apache.commons.lang3.NotImplementedException)15 TypeRefComponent (org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent)14 UriType (org.hl7.fhir.dstu2016may.model.UriType)12 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)12 Coding (org.hl7.fhir.r4.model.Coding)12 IOException (java.io.IOException)11 StringType (org.hl7.fhir.r4.model.StringType)10 org.hl7.fhir.r5.model (org.hl7.fhir.r5.model)10 StringType (org.hl7.fhir.r5.model.StringType)10