Search in sources :

Example 1 with DataRequirementSortComponent

use of org.hl7.fhir.r5.model.DataRequirement.DataRequirementSortComponent 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 2 with DataRequirementSortComponent

use of org.hl7.fhir.r5.model.DataRequirement.DataRequirementSortComponent 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.r4b.model.StructureDefinition) Coding(org.hl7.fhir.r4b.model.Coding) DataRequirementSortComponent(org.hl7.fhir.r4b.model.DataRequirement.DataRequirementSortComponent) CanonicalType(org.hl7.fhir.r4b.model.CanonicalType) DataRequirementCodeFilterComponent(org.hl7.fhir.r4b.model.DataRequirement.DataRequirementCodeFilterComponent) DataRequirementDateFilterComponent(org.hl7.fhir.r4b.model.DataRequirement.DataRequirementDateFilterComponent) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Aggregations

XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)2 CanonicalType (org.hl7.fhir.r4b.model.CanonicalType)1 Coding (org.hl7.fhir.r4b.model.Coding)1 DataRequirementCodeFilterComponent (org.hl7.fhir.r4b.model.DataRequirement.DataRequirementCodeFilterComponent)1 DataRequirementDateFilterComponent (org.hl7.fhir.r4b.model.DataRequirement.DataRequirementDateFilterComponent)1 DataRequirementSortComponent (org.hl7.fhir.r4b.model.DataRequirement.DataRequirementSortComponent)1 StructureDefinition (org.hl7.fhir.r4b.model.StructureDefinition)1 CanonicalType (org.hl7.fhir.r5.model.CanonicalType)1 Coding (org.hl7.fhir.r5.model.Coding)1 DataRequirementCodeFilterComponent (org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent)1 DataRequirementDateFilterComponent (org.hl7.fhir.r5.model.DataRequirement.DataRequirementDateFilterComponent)1 DataRequirementSortComponent (org.hl7.fhir.r5.model.DataRequirement.DataRequirementSortComponent)1 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)1