Search in sources :

Example 91 with ValueSetExpansionContainsComponent

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

the class QuestionnaireRenderer method listOptions.

private void listOptions(Questionnaire q, QuestionnaireItemComponent i, XhtmlNode select) {
    if (i.hasAnswerValueSet()) {
        ValueSet vs = null;
        if (!Utilities.noString(i.getAnswerValueSet()) && i.getAnswerValueSet().startsWith("#")) {
            vs = (ValueSet) q.getContained(i.getAnswerValueSet().substring(1));
            if (vs != null && !vs.hasUrl()) {
                vs = vs.copy();
                vs.setUrl(q.getUrl() + "--" + q.getContained(i.getAnswerValueSet().substring(1)));
            }
        } else {
            vs = context.getContext().fetchResource(ValueSet.class, i.getAnswerValueSet());
        }
        if (vs != null) {
            ValueSetExpansionOutcome exp = context.getContext().expandVS(vs, true, false);
            if (exp.getValueset() != null) {
                for (ValueSetExpansionContainsComponent cc : exp.getValueset().getExpansion().getContains()) {
                    select.option(cc.getCode(), cc.hasDisplay() ? cc.getDisplay() : cc.getCode(), false);
                }
                return;
            }
        }
    } else if (i.hasAnswerOption()) {
        renderItemOptions(select, i);
    }
    select.option("a", "??", false);
}
Also used : ValueSetExpansionContainsComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent) ValueSetExpansionOutcome(org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome) ValueSet(org.hl7.fhir.r5.model.ValueSet)

Example 92 with ValueSetExpansionContainsComponent

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

the class QuestionnaireResponseRenderer method renderLinks.

// private boolean renderFormItem(XhtmlNode x, QuestionnaireResponse q, QuestionnaireItemComponent i, String pfx, int indent) throws IOException {
// boolean hasExt = false;
// XhtmlNode d = x.div().style("width: "+Integer.toString(900-indent*10)+"px; border-top: 1px #eeeeee solid");
// if (indent > 0) {
// d.style("margin-left: "+Integer.toString(10*indent)+"px");
// }
// XhtmlNode display = d.div().style("display: inline-block; width: "+Integer.toString(500-indent*10)+"px");
// XhtmlNode details = d.div().style("border: 1px #ccccff solid; padding: 2px; display: inline-block; background-color: #fefce7; width: 380px");
// XhtmlNode p = display.para();
// if (i.getType() == QuestionnaireItemType.GROUP) {
// p = p.b();
// }
// if (i.hasPrefix()) {
// p.tx(i.getPrefix());
// p.tx(": ");
// }
// p.span(null, "linkId: "+i.getLinkId()).tx(i.getText());
// if (i.getRequired()) {
// p.span("color: red", "Mandatory").tx("*");
// }
// 
// XhtmlNode input = null;
// switch (i.getType()) {
// case STRING:
// p.tx(" ");
// input = p.input(i.getLinkId(), "text", i.getType().getDisplay(), 60);
// break;
// case ATTACHMENT:
// break;
// case BOOLEAN:
// p.tx(" ");
// input = p.input(i.getLinkId(), "checkbox", i.getType().getDisplay(), 1);
// break;
// case CHOICE:
// input = p.select(i.getLinkId());
// listOptions(q, i, input);
// break;
// case DATE:
// p.tx(" ");
// input = p.input(i.getLinkId(), "date", i.getType().getDisplay(), 10);
// break;
// case DATETIME:
// p.tx(" ");
// input = p.input(i.getLinkId(), "datetime-local", i.getType().getDisplay(), 25);
// break;
// case DECIMAL:
// p.tx(" ");
// input = p.input(i.getLinkId(), "number", i.getType().getDisplay(), 15);
// break;
// case DISPLAY:
// break;
// case GROUP:
// 
// break;
// case INTEGER:
// p.tx(" ");
// input = p.input(i.getLinkId(), "number", i.getType().getDisplay(), 10);
// break;
// case OPENCHOICE:
// break;
// case QUANTITY:
// p.tx(" ");
// input = p.input(i.getLinkId(), "number", "value", 15);
// p.tx(" ");
// input = p.input(i.getLinkId(), "unit", "unit", 10);
// break;
// case QUESTION:
// break;
// case REFERENCE:
// break;
// case TEXT:
// break;
// case TIME:
// break;
// case URL:
// break;
// default:
// break;
// }
// if (input != null) {
// if (i.getReadOnly()) {
// input.attribute("readonly", "1");
// input.style("background-color: #eeeeee");
// }
// }
// 
// //  if (i.hasExtension("http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse-choiceOrientation")) {
// //  String code = ToolingExtensions.readStringExtension(i,  "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse-choiceOrientation");
// //  flags.addPiece(gen.new Piece("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-QuestionnaireResponse-observationLinkPeriod", null, "Orientation: "+code).addHtml(new XhtmlNode(NodeType.Element, "img").attribute("src", Utilities.path(context.getLocalPrefix(), "icon-qi-"+code+".png"))));
// //}
// 
// 
// XhtmlNode ul = details.ul();
// boolean hasFlag = false;
// XhtmlNode flags = item(ul, "Flags");
// item(ul, "linkId", i.getLinkId());
// 
// if (ToolingExtensions.readBoolExtension(i, "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-QuestionnaireResponse-isSubject")) {
// hasFlag = true;
// flags.ah("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-QuestionnaireResponse-isSubject", "Can change the subject of the QuestionnaireResponse").img(Utilities.path(context.getLocalPrefix(), "icon-qi-subject.png"));
// }
// if (ToolingExtensions.readBoolExtension(i, "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse-hidden")) {
// hasFlag = true;
// flags.ah(Utilities.pathURL(context.getSpecificationLink(), "extension-QuestionnaireResponse-hidden.html"), "Is a hidden item").img(Utilities.path(context.getLocalPrefix(), "icon-qi-hidden.png"));
// d.style("background-color: #eeeeee");
// }
// if (ToolingExtensions.readBoolExtension(i, "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-QuestionnaireResponse-optionalDisplay")) {
// hasFlag = true;
// flags.ah("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-QuestionnaireResponse-optionalDisplay", "Is optional to display").img(Utilities.path(context.getLocalPrefix(), "icon-qi-optional.png"));
// }
// if (i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-QuestionnaireResponse-observationLinkPeriod")) {
// hasFlag = true;
// flags.ah("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-QuestionnaireResponse-observationLinkPeriod", "Is linked to an observation").img(Utilities.path(context.getLocalPrefix(), "icon-qi-observation.png"));
// }
// if (i.hasExtension("http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse-displayCategory")) {
// CodeableConcept cc = i.getExtensionByUrl("http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse-displayCategory").getValueCodeableConcept();
// String code = cc.getCode("http://hl7.org/fhir/QuestionnaireResponse-display-category");
// hasFlag = true;
// flags.ah("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-QuestionnaireResponse-displayCategory", "Category: "+code).img(Utilities.path(context.getLocalPrefix(), "icon-qi-"+code+".png"));
// }
// 
// if (i.hasMaxLength()) {
// item(ul, "Max Length", Integer.toString(i.getMaxLength()));
// }
// if (i.hasDefinition()) {
// genDefinitionLink(item(ul, "Definition"), i);
// }
// if (i.hasEnableWhen()) {
// item(ul, "Enable When", "todo");
// }
// if (i.hasAnswerValueSet()) {
// XhtmlNode ans = item(ul, "Answers");
// if (i.getAnswerValueSet().startsWith("#")) {
// ValueSet vs = (ValueSet) q.getContained(i.getAnswerValueSet().substring(1));
// if (vs == null) {
// ans.tx(i.getAnswerValueSet());
// } else {
// ans.ah(vs.getUserString("path")).tx(vs.present());
// }
// } else {
// ValueSet vs = context.getWorker().fetchResource(ValueSet.class, i.getAnswerValueSet());
// if (vs == null  || !vs.hasUserData("path")) {
// ans.tx(i.getAnswerValueSet());
// } else {
// ans.ah(vs.getUserString("path")).tx(vs.present());
// }
// }
// }
// if (i.hasAnswerOption()) {
// item(ul, "Answers", Integer.toString(i.getAnswerOption().size())+" "+Utilities.pluralize("option", i.getAnswerOption().size()), context.getDefinitionsTarget()+"#item."+i.getLinkId());
// }
// if (i.hasInitial()) {
// XhtmlNode vi = item(ul, "Initial Values");
// boolean first = true;
// for (QuestionnaireItemInitialComponent v : i.getInitial()) {
// if (first) first = false; else vi.tx(", ");
// if (v.getValue().isPrimitive()) {
// vi.tx(v.getValue().primitiveValue());
// } else {
// vi.tx("{todo}");
// }
// }
// }
// if (!hasFlag) {
// ul.remove(flags);
// }
// //    if (i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-QuestionnaireResponse-enableWhenExpression") || i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-QuestionnaireResponse-itemContext") || i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-QuestionnaireResponse-calculatedExpression") || i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-QuestionnaireResponse-contextExpression") || i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-QuestionnaireResponse-candidateExpression") || i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-QuestionnaireResponse-initialExpression")) {
// //      if (!defn.getPieces().isEmpty()) defn.addPiece(gen.new Piece("br"));
// //      defn.getPieces().add(gen.new Piece(null, "Expressions: ", null));
// //      Piece p = gen.new Piece("ul");
// //      defn.getPieces().add(p);
// //      for (Extension e : i.getExtensionsByUrl("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-QuestionnaireResponse-initialExpression")) {
// //        addExpression(p, e.getValueExpression(), "Initial Value", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-QuestionnaireResponse-initialExpression");
// //      }
// //      for (Extension e : i.getExtensionsByUrl("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-QuestionnaireResponse-contextExpression")) {
// //        addExpression(p, e.getValueExpression(), "Context", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-QuestionnaireResponse-contextExpression");
// //      }
// //      for (Extension e : i.getExtensionsByUrl("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-QuestionnaireResponse-itemContext")) {
// //        addExpression(p, e.getValueExpression(), "Item Context", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-QuestionnaireResponse-itemContext");
// //      }
// //      for (Extension e : i.getExtensionsByUrl("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-QuestionnaireResponse-enableWhenExpression")) {
// //        addExpression(p, e.getValueExpression(), "Enable When", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-QuestionnaireResponse-enableWhenExpression");
// //      }
// //      for (Extension e : i.getExtensionsByUrl("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-QuestionnaireResponse-calculatedExpression")) {
// //        addExpression(p, e.getValueExpression(), "Calculated Value", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-QuestionnaireResponse-calculatedExpression");
// //      }
// //      for (Extension e : i.getExtensionsByUrl("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-QuestionnaireResponse-candidateExpression")) {
// //        addExpression(p, e.getValueExpression(), "Candidates", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-QuestionnaireResponse-candidateExpression");
// //      }
// //    }
// //
// 
// int t = 1;
// for (QuestionnaireItemComponent c : i.getItem()) {
// hasExt = renderFormItem(x, q, c, pfx == null ? null : pfx+"."+Integer.toString(t), indent+1) || hasExt;
// t++;
// }
// return hasExt;
// }
// 
// private void item(XhtmlNode ul, String name, String value, String valueLink) {
// if (!Utilities.noString(value)) {
// ul.li().style("font-size: 10px").ah(valueLink).tx(name+": "+value);
// }
// }
// 
// private void item(XhtmlNode ul, String name, String value) {
// if (!Utilities.noString(value)) {
// ul.li().style("font-size: 10px").tx(name+": "+value);
// }
// }
// private XhtmlNode item(XhtmlNode ul, String name) {
// XhtmlNode li = ul.li();
// li.style("font-size: 10px").tx(name+": ");
// return li;
// }
// 
// 
// private void listOptions(QuestionnaireResponse q, QuestionnaireItemComponent i, XhtmlNode select) {
// if (i.hasAnswerValueSet()) {
// ValueSet vs = null;
// if (i.getAnswerValueSet().startsWith("#")) {
// vs = (ValueSet) q.getContained(i.getAnswerValueSet().substring(1)).copy();
// if (vs != null && !vs.hasUrl()) {
// vs.setUrl("urn:uuid:"+UUID.randomUUID().toString().toLowerCase());
// }
// } else {
// vs = context.getContext().fetchResource(ValueSet.class, i.getAnswerValueSet());
// }
// if (vs != null) {
// ValueSetExpansionOutcome exp = context.getContext().expandVS(vs, true, false);
// if (exp.getValueset() != null) {
// for (ValueSetExpansionContainsComponent cc : exp.getValueset().getExpansion().getContains()) {
// select.option(cc.getCode(), cc.hasDisplay() ? cc.getDisplay() : cc.getCode(), false);
// }
// return;
// }
// }
// } else if (i.hasAnswerOption()) {
// 
// }
// select.option("a", "??", false);
// }
// 
// public String display(Resource dr) throws UnsupportedEncodingException, IOException {
// return display((QuestionnaireResponse) dr);
// }
// 
// public String display(QuestionnaireResponse q) throws UnsupportedEncodingException, IOException {
// return "QuestionnaireResponse "+q.present();
// }
// 
private boolean renderLinks(XhtmlNode x, QuestionnaireResponse q) {
    x.para().tx("Try this QuestionnaireResponse out:");
    XhtmlNode ul = x.ul();
    ul.li().ah("http://todo.nlm.gov/path?mode=ig&src=" + Utilities.pathURL(context.getSelfLink(), "package.tgz") + "&q=" + q.getId() + ".json").tx("NLM Forms Library");
    return false;
}
Also used : XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 93 with ValueSetExpansionContainsComponent

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

the class ValueSetRenderer method addExpansionRowToTable.

private void addExpansionRowToTable(XhtmlNode t, ValueSetExpansionContainsComponent c, int i, boolean doLevel, boolean doSystem, boolean doDefinition, List<UsedConceptMap> maps, CodeSystem allCS, List<String> langs, Map<String, String> designations, boolean doDesignations) {
    XhtmlNode tr = t.tr();
    XhtmlNode td = tr.td();
    String tgt = makeAnchor(c.getSystem(), c.getCode());
    td.an(tgt);
    if (doLevel) {
        td.addText(Integer.toString(i));
        td = tr.td();
    }
    String s = Utilities.padLeft("", '\u00A0', i * 2);
    td.attribute("style", "white-space:nowrap").addText(s);
    addCodeToTable(c.getAbstract(), c.getSystem(), c.getCode(), c.getDisplay(), td);
    if (doSystem) {
        td = tr.td();
        td.addText(c.getSystem());
    }
    td = tr.td();
    if (c.hasDisplayElement())
        td.addText(c.getDisplay());
    if (doDefinition) {
        CodeSystem cs = allCS;
        if (cs == null)
            cs = getContext().getWorker().fetchCodeSystem(c.getSystem());
        td = tr.td();
        if (cs != null)
            td.addText(CodeSystemUtilities.getCodeDefinition(cs, c.getCode()));
    }
    for (UsedConceptMap m : maps) {
        td = tr.td();
        List<TargetElementComponentWrapper> mappings = findMappingsForCode(c.getCode(), m.getMap());
        boolean first = true;
        for (TargetElementComponentWrapper mapping : mappings) {
            if (!first)
                td.br();
            first = false;
            XhtmlNode span = td.span(null, mapping.comp.getRelationship().toString());
            span.addText(getCharForRelationship(mapping.comp));
            addRefToCode(td, mapping.group.getTarget(), m.getLink(), mapping.comp.getCode());
            if (!Utilities.noString(mapping.comp.getComment()))
                td.i().tx("(" + mapping.comp.getComment() + ")");
        }
    }
    if (doDesignations) {
        addDesignationsToRow(c, designations, tr);
        addLangaugesToRow(c, langs, tr);
    }
    for (ValueSetExpansionContainsComponent cc : c.getContains()) {
        addExpansionRowToTable(t, cc, i + 1, doLevel, doSystem, doDefinition, maps, allCS, langs, designations, doDesignations);
    }
}
Also used : ValueSetExpansionContainsComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent) CodeSystem(org.hl7.fhir.r5.model.CodeSystem) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 94 with ValueSetExpansionContainsComponent

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

the class ValueSetExpanderSimple method addCodeAndDescendents.

private void addCodeAndDescendents(CodeSystem cs, String system, ConceptDefinitionComponent def, ValueSetExpansionContainsComponent parent, ExpansionProfile profile, List<ValueSet> filters) throws FHIRException {
    if (!CodeSystemUtilities.isDeprecated(cs, def)) {
        ValueSetExpansionContainsComponent np = null;
        boolean abs = CodeSystemUtilities.isNotSelectable(cs, def);
        boolean inc = CodeSystemUtilities.isInactive(cs, def);
        if (canBeHeirarchy || !abs)
            np = addCode(system, def.getCode(), def.getDisplay(), parent, def.getDesignation(), profile, abs, inc, filters);
        for (ConceptDefinitionComponent c : def.getConcept()) addCodeAndDescendents(cs, system, c, np, profile, filters);
    } else
        for (ConceptDefinitionComponent c : def.getConcept()) addCodeAndDescendents(cs, system, c, null, profile, filters);
}
Also used : ConceptDefinitionComponent(org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent)

Example 95 with ValueSetExpansionContainsComponent

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

the class ValueSetExpanderSimple method addCode.

private ValueSetExpansionContainsComponent addCode(String system, String code, String display, ValueSetExpansionContainsComponent parent, List<ConceptDefinitionDesignationComponent> designations, ExpansionProfile profile, boolean isAbstract, boolean inactive, List<ValueSet> filters) {
    if (filters != null && !filters.isEmpty() && !filterContainsCode(filters, system, code))
        return null;
    ValueSetExpansionContainsComponent n = new ValueSet.ValueSetExpansionContainsComponent();
    n.setSystem(system);
    n.setCode(code);
    if (isAbstract)
        n.setAbstract(true);
    if (inactive)
        n.setInactive(true);
    if (profile.getIncludeDesignations() && designations != null) {
        for (ConceptDefinitionDesignationComponent t : designations) {
            ToolingExtensions.addLanguageTranslation(n, t.getLanguage(), t.getValue());
        }
    }
    ConceptDefinitionDesignationComponent t = profile.hasLanguage() ? getMatchingLang(designations, profile.getLanguage()) : null;
    if (t == null)
        n.setDisplay(display);
    else
        n.setDisplay(t.getValue());
    String s = key(n);
    if (map.containsKey(s) || excludeKeys.contains(s)) {
        canBeHeirarchy = false;
    } else {
        codes.add(n);
        map.put(s, n);
        total++;
    }
    if (canBeHeirarchy && parent != null) {
        parent.getContains().add(n);
    } else {
        roots.add(n);
    }
    return n;
}
Also used : ConceptDefinitionDesignationComponent(org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionDesignationComponent)

Aggregations

ValueSetExpansionContainsComponent (org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent)32 ValueSetExpansionContainsComponent (org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionContainsComponent)22 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)20 ValueSetExpansionContainsComponent (org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent)17 ValueSet (org.hl7.fhir.r4.model.ValueSet)9 HashMap (java.util.HashMap)8 ValueSet (org.hl7.fhir.r5.model.ValueSet)8 ArrayList (java.util.ArrayList)7 ValueSetExpansionContainsComponent (org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionContainsComponent)7 ValueSetExpansionContainsComponent (org.hl7.fhir.dstu2016may.model.ValueSet.ValueSetExpansionContainsComponent)7 IOException (java.io.IOException)6 ValueSetExpansionContainsComponent (org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionContainsComponent)6 ValueSetExpansionComponent (org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent)6 ConceptDefinitionComponent (org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent)6 ValueSet (org.hl7.fhir.dstu2.model.ValueSet)5 TerminologyServiceException (org.hl7.fhir.exceptions.TerminologyServiceException)5 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)5 ValueSet (org.hl7.fhir.dstu2016may.model.ValueSet)4 ValueSet (org.hl7.fhir.r4b.model.ValueSet)4 FHIRException (org.hl7.fhir.exceptions.FHIRException)3