Search in sources :

Example 96 with CanonicalType

use of org.hl7.fhir.r5.model.CanonicalType in project org.hl7.fhir.core by hapifhir.

the class CanonicalResourceComparer method compareCanonicalList.

protected void compareCanonicalList(String name, List<CanonicalType> left, List<CanonicalType> right, Map<String, StructuralMatch<String>> comp, IssueSeverity level, CanonicalResourceComparison<? extends CanonicalResource> res, List<CanonicalType> union, List<CanonicalType> intersection) {
    List<CanonicalType> matchR = new ArrayList<>();
    StructuralMatch<String> combined = new StructuralMatch<String>();
    for (CanonicalType l : left) {
        CanonicalType r = findCanonicalInList(right, l);
        if (r == null) {
            union.add(l);
            combined.getChildren().add(new StructuralMatch<String>(l.getValue(), vm(IssueSeverity.INFORMATION, "Removed the item '" + l.getValue() + "'", fhirType() + "." + name, res.getMessages())));
        } else {
            matchR.add(r);
            union.add(r);
            intersection.add(r);
            StructuralMatch<String> sm = new StructuralMatch<String>(l.getValue(), r.getValue());
            combined.getChildren().add(sm);
        }
    }
    for (CanonicalType r : right) {
        if (!matchR.contains(r)) {
            union.add(r);
            combined.getChildren().add(new StructuralMatch<String>(vm(IssueSeverity.INFORMATION, "Added the item '" + r.getValue() + "'", fhirType() + "." + name, res.getMessages()), r.getValue()));
        }
    }
    comp.put(name, combined);
}
Also used : ArrayList(java.util.ArrayList) CanonicalType(org.hl7.fhir.r4b.model.CanonicalType)

Example 97 with CanonicalType

use of org.hl7.fhir.r5.model.CanonicalType in project org.hl7.fhir.core by hapifhir.

the class ValueSetCheckerSimple method findValueSetRef.

private ConceptReferenceComponent findValueSetRef(String system, String code) {
    if (valueset == null)
        return null;
    // if it has an expansion
    for (ValueSetExpansionContainsComponent exp : valueset.getExpansion().getContains()) {
        if (system.equals(exp.getSystem()) && code.equals(exp.getCode())) {
            ConceptReferenceComponent cc = new ConceptReferenceComponent();
            cc.setDisplay(exp.getDisplay());
            cc.setDesignation(exp.getDesignation());
            return cc;
        }
    }
    for (ConceptSetComponent inc : valueset.getCompose().getInclude()) {
        if (system.equals(inc.getSystem())) {
            for (ConceptReferenceComponent cc : inc.getConcept()) {
                if (cc.getCode().equals(code)) {
                    return cc;
                }
            }
        }
        for (CanonicalType url : inc.getValueSet()) {
            ConceptReferenceComponent cc = getVs(url.asStringValue()).findValueSetRef(system, code);
            if (cc != null) {
                return cc;
            }
        }
    }
    return null;
}
Also used : ConceptSetComponent(org.hl7.fhir.r4b.model.ValueSet.ConceptSetComponent) ValueSetExpansionContainsComponent(org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionContainsComponent) ConceptReferenceComponent(org.hl7.fhir.r4b.model.ValueSet.ConceptReferenceComponent) CanonicalType(org.hl7.fhir.r4b.model.CanonicalType)

Example 98 with CanonicalType

use of org.hl7.fhir.r5.model.CanonicalType in project org.hl7.fhir.core by hapifhir.

the class QuestionnaireRenderer method renderRootDefinition.

private boolean renderRootDefinition(XhtmlNode tbl, Questionnaire q, List<QuestionnaireItemComponent> parents) throws IOException {
    boolean ext = false;
    XhtmlNode td = tbl.tr().td("structure").colspan("2").span(null, null).attribute("class", "self-link-parent");
    td.an(q.getId());
    td.img(Utilities.path(context.getLocalPrefix(), "icon_q_root.gif"));
    td.tx(" Questionnaire ");
    td.b().tx(q.getId());
    // general information
    defn(tbl, "URL", q.getUrl());
    defn(tbl, "Version", q.getVersion());
    defn(tbl, "Name", q.getName());
    defn(tbl, "Title", q.getTitle());
    if (q.hasDerivedFrom()) {
        td = defn(tbl, "Derived From");
        boolean first = true;
        for (CanonicalType c : q.getDerivedFrom()) {
            if (first)
                first = false;
            else
                td.tx(", ");
            // todo: make these a reference
            td.tx(c.asStringValue());
        }
    }
    defn(tbl, "Status", q.getStatus().getDisplay());
    defn(tbl, "Experimental", q.getExperimental());
    defn(tbl, "Publication Date", q.getDateElement().primitiveValue());
    defn(tbl, "Approval Date", q.getApprovalDateElement().primitiveValue());
    defn(tbl, "Last Review Date", q.getLastReviewDateElement().primitiveValue());
    if (q.hasEffectivePeriod()) {
        renderPeriod(defn(tbl, "Effective Period"), q.getEffectivePeriod());
    }
    if (q.hasSubjectType()) {
        td = defn(tbl, "Subject Type");
        boolean first = true;
        for (CodeType c : q.getSubjectType()) {
            if (first)
                first = false;
            else
                td.tx(", ");
            td.tx(c.asStringValue());
        }
    }
    defn(tbl, "Description", q.getDescription());
    defn(tbl, "Purpose", q.getPurpose());
    defn(tbl, "Copyright", q.getCopyright());
    if (q.hasCode()) {
        td = defn(tbl, Utilities.pluralize("Code", q.getCode().size()));
        boolean first = true;
        for (Coding c : q.getCode()) {
            if (first)
                first = false;
            else
                td.tx(", ");
            renderCodingWithDetails(td, c);
        }
    }
    return false;
}
Also used : Coding(org.hl7.fhir.r5.model.Coding) CodeType(org.hl7.fhir.r5.model.CodeType) CanonicalType(org.hl7.fhir.r5.model.CanonicalType) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 99 with CanonicalType

use of org.hl7.fhir.r5.model.CanonicalType in project org.hl7.fhir.core by hapifhir.

the class DataRenderer method renderDataRequirement.

public void renderDataRequirement(XhtmlNode x, DataRequirement dr) throws FHIRFormatError, DefinitionException, IOException {
    XhtmlNode tbl = x.table("grid");
    XhtmlNode tr = tbl.tr();
    XhtmlNode td = tr.td().colspan("2");
    td.b().tx("Type");
    td.tx(": ");
    StructureDefinition sd = context.getWorker().fetchTypeDefinition(dr.getType().toCode());
    if (sd != null && sd.hasUserData("path")) {
        td.ah(sd.getUserString("path")).tx(dr.getType().toCode());
    } else {
        td.tx(dr.getType().toCode());
    }
    if (dr.hasProfile()) {
        td.tx(" (");
        boolean first = true;
        for (CanonicalType p : dr.getProfile()) {
            if (first)
                first = false;
            else
                td.tx(" | ");
            sd = context.getWorker().fetchResource(StructureDefinition.class, p.getValue());
            if (sd != null && sd.hasUserData("path")) {
                td.ah(sd.getUserString("path")).tx(sd.present());
            } else {
                td.tx(p.asStringValue());
            }
        }
        td.tx(")");
    }
    if (dr.hasSubject()) {
        tr = tbl.tr();
        td = tr.td().colspan("2");
        td.b().tx("Subject");
        if (dr.hasSubjectReference()) {
            renderReference(td, dr.getSubjectReference());
        } else {
            renderCodeableConcept(td, dr.getSubjectCodeableConcept());
        }
    }
    if (dr.hasCodeFilter() || dr.hasDateFilter()) {
        tr = tbl.tr().backgroundColor("#efefef");
        tr.td().tx("Filter");
        tr.td().tx("Value");
    }
    for (DataRequirementCodeFilterComponent cf : dr.getCodeFilter()) {
        tr = tbl.tr();
        if (cf.hasPath()) {
            tr.td().tx(cf.getPath());
        } else {
            tr.td().tx("Search on " + cf.getSearchParam());
        }
        if (cf.hasValueSet()) {
            td = tr.td();
            td.tx("In ValueSet ");
            render(td, cf.getValueSetElement());
        } else {
            boolean first = true;
            td = tr.td();
            td.tx("One of these codes: ");
            for (Coding c : cf.getCode()) {
                if (first)
                    first = false;
                else
                    td.tx(", ");
                render(td, c);
            }
        }
    }
    for (DataRequirementDateFilterComponent cf : dr.getDateFilter()) {
        tr = tbl.tr();
        if (cf.hasPath()) {
            tr.td().tx(cf.getPath());
        } else {
            tr.td().tx("Search on " + cf.getSearchParam());
        }
        render(tr.td(), cf.getValue());
    }
    if (dr.hasSort() || dr.hasLimit()) {
        tr = tbl.tr();
        td = tr.td().colspan("2");
        if (dr.hasLimit()) {
            td.b().tx("Limit");
            td.tx(": ");
            td.tx(dr.getLimit());
            if (dr.hasSort()) {
                td.tx(", ");
            }
        }
        if (dr.hasSort()) {
            td.b().tx("Sort");
            td.tx(": ");
            boolean first = true;
            for (DataRequirementSortComponent p : dr.getSort()) {
                if (first)
                    first = false;
                else
                    td.tx(" | ");
                td.tx(p.getDirection() == SortDirection.ASCENDING ? "+" : "-");
                td.tx(p.getPath());
            }
        }
    }
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) Coding(org.hl7.fhir.r5.model.Coding) DataRequirementSortComponent(org.hl7.fhir.r5.model.DataRequirement.DataRequirementSortComponent) CanonicalType(org.hl7.fhir.r5.model.CanonicalType) DataRequirementCodeFilterComponent(org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent) DataRequirementDateFilterComponent(org.hl7.fhir.r5.model.DataRequirement.DataRequirementDateFilterComponent) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 100 with CanonicalType

use of org.hl7.fhir.r5.model.CanonicalType in project org.hl7.fhir.core by hapifhir.

the class CapabilityStatementRenderer method render.

public boolean render(XhtmlNode x, CapabilityStatement conf) throws FHIRFormatError, DefinitionException, IOException {
    x.h2().addText(conf.getName());
    addMarkdown(x, conf.getDescription());
    if (conf.getRest().size() > 0) {
        CapabilityStatementRestComponent rest = conf.getRest().get(0);
        XhtmlNode t = x.table(null);
        addTableRow(t, "Mode", rest.getMode().toString());
        addMarkdown(addTableRow(t, "Description"), rest.getDocumentation());
        addTableRow(t, "Transaction", showOp(rest, SystemRestfulInteraction.TRANSACTION));
        addTableRow(t, "System History", showOp(rest, SystemRestfulInteraction.HISTORYSYSTEM));
        addTableRow(t, "System Search", showOp(rest, SystemRestfulInteraction.SEARCHSYSTEM));
        boolean hasVRead = false;
        boolean hasPatch = false;
        boolean hasDelete = false;
        boolean hasHistory = false;
        boolean hasUpdates = false;
        for (CapabilityStatementRestResourceComponent r : rest.getResource()) {
            hasVRead = hasVRead || hasOp(r, TypeRestfulInteraction.VREAD);
            hasPatch = hasPatch || hasOp(r, TypeRestfulInteraction.PATCH);
            hasDelete = hasDelete || hasOp(r, TypeRestfulInteraction.DELETE);
            hasHistory = hasHistory || hasOp(r, TypeRestfulInteraction.HISTORYTYPE);
            hasUpdates = hasUpdates || hasOp(r, TypeRestfulInteraction.HISTORYINSTANCE);
        }
        t = x.table(null);
        XhtmlNode tr = t.tr();
        tr.th().b().tx("Resource Type");
        tr.th().b().tx("Profile");
        tr.th().b().attribute("title", "GET a resource (read interaction)").tx("Read");
        if (hasVRead)
            tr.th().b().attribute("title", "GET past versions of resources (vread interaction)").tx("V-Read");
        tr.th().b().attribute("title", "GET all set of resources of the type (search interaction)").tx("Search");
        tr.th().b().attribute("title", "PUT a new resource version (update interaction)").tx("Update");
        if (hasPatch)
            tr.th().b().attribute("title", "PATCH a new resource version (patch interaction)").tx("Patch");
        tr.th().b().attribute("title", "POST a new resource (create interaction)").tx("Create");
        if (hasDelete)
            tr.th().b().attribute("title", "DELETE a resource (delete interaction)").tx("Delete");
        if (hasUpdates)
            tr.th().b().attribute("title", "GET changes to a resource (history interaction on instance)").tx("Updates");
        if (hasHistory)
            tr.th().b().attribute("title", "GET changes for all resources of the type (history interaction on type)").tx("History");
        XhtmlNode profCell = null;
        boolean hasProf = false;
        boolean hasSupProf = false;
        for (CapabilityStatementRestResourceComponent r : rest.getResource()) {
            tr = t.tr();
            tr.td().addText(r.getType());
            // Show profiles
            profCell = tr.td();
            hasProf = r.hasProfile();
            hasSupProf = r.hasSupportedProfile();
            if ((!hasProf) && (!hasSupProf)) {
                profCell.nbsp();
            } else if (hasProf) {
                profCell.ah(r.getProfile()).addText(r.getProfile());
                if (hasSupProf) {
                    profCell.br();
                    profCell.addText("Additional supported profiles:");
                    for (CanonicalType sp : r.getSupportedProfile()) {
                        profCell.br();
                        profCell.nbsp().nbsp();
                        profCell.ah(sp.getValue()).addText(sp.getValue());
                    }
                }
            } else {
                // Case of only supported profiles
                profCell.addText("Supported profiles:");
                for (CanonicalType sp : r.getSupportedProfile()) {
                    profCell.br();
                    profCell.nbsp().nbsp();
                    profCell.ah(sp.getValue()).addText(sp.getValue());
                }
            }
            // Show capabilities
            tr.td().addText(showOp(r, TypeRestfulInteraction.READ));
            if (hasVRead)
                tr.td().addText(showOp(r, TypeRestfulInteraction.VREAD));
            tr.td().addText(showOp(r, TypeRestfulInteraction.SEARCHTYPE));
            tr.td().addText(showOp(r, TypeRestfulInteraction.UPDATE));
            if (hasPatch)
                tr.td().addText(showOp(r, TypeRestfulInteraction.PATCH));
            tr.td().addText(showOp(r, TypeRestfulInteraction.CREATE));
            if (hasDelete)
                tr.td().addText(showOp(r, TypeRestfulInteraction.DELETE));
            if (hasUpdates)
                tr.td().addText(showOp(r, TypeRestfulInteraction.HISTORYINSTANCE));
            if (hasHistory)
                tr.td().addText(showOp(r, TypeRestfulInteraction.HISTORYTYPE));
        }
    }
    return true;
}
Also used : CapabilityStatementRestComponent(org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestComponent) CapabilityStatementRestResourceComponent(org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestResourceComponent) CanonicalType(org.hl7.fhir.r5.model.CanonicalType) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Aggregations

CanonicalType (org.hl7.fhir.r4.model.CanonicalType)45 CanonicalType (org.hl7.fhir.r5.model.CanonicalType)37 ArrayList (java.util.ArrayList)27 CanonicalType (org.hl7.fhir.r4b.model.CanonicalType)19 TypeRefComponent (org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent)14 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)13 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)12 Test (org.junit.jupiter.api.Test)12 List (java.util.List)10 FHIRException (org.hl7.fhir.exceptions.FHIRException)9 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)9 HashMap (java.util.HashMap)7 HashSet (java.util.HashSet)7 Extension (org.hl7.fhir.r4.model.Extension)7 Library (org.hl7.fhir.r4.model.Library)7 StringType (org.hl7.fhir.r4.model.StringType)6 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)6 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)5 Bundle (org.hl7.fhir.r4.model.Bundle)5 IdType (org.hl7.fhir.r4.model.IdType)5