Search in sources :

Example 11 with QuestionnaireItemAnswerOptionComponent

use of org.hl7.fhir.r4b.model.Questionnaire.QuestionnaireItemAnswerOptionComponent in project org.hl7.fhir.core by hapifhir.

the class QuestionnaireRenderer method renderItemOptions.

public void renderItemOptions(XhtmlNode x, QuestionnaireItemComponent i) {
    if (i.hasAnswerOption()) {
        boolean useSelect = false;
        for (QuestionnaireItemAnswerOptionComponent opt : i.getAnswerOption()) {
            useSelect = useSelect || opt.getInitialSelected();
        }
        x.an("opt-item." + i.getLinkId());
        x.para().b().tx("Answer options for " + i.getLinkId());
        XhtmlNode ul = x.ul();
        for (QuestionnaireItemAnswerOptionComponent opt : i.getAnswerOption()) {
            XhtmlNode li = ul.li();
            li.style("font-size: 11px");
            if (useSelect) {
                if (opt.getInitialSelected()) {
                    li.img("icon-selected.png");
                } else {
                    li.img("icon-not-selected.png");
                }
            }
            if (opt.getValue().isPrimitive()) {
                li.tx(opt.getValue().primitiveValue());
            } else if (opt.getValue() instanceof Coding) {
                Coding c = (Coding) opt.getValue();
                String link = c.hasSystem() ? context.getWorker().getLinkForUrl(context.getSpecificationLink(), c.getSystem()) : null;
                if (link == null) {
                    li.tx(c.getSystem() + "#" + c.getCode());
                } else {
                    li.ah(link).tx(describeSystem(c.getSystem()));
                    li.tx(": " + c.getCode());
                }
                if (c.hasDisplay()) {
                    li.tx(" (\"" + c.getDisplay() + "\")");
                }
            } else {
                li.tx("??");
            }
        }
    }
}
Also used : QuestionnaireItemAnswerOptionComponent(org.hl7.fhir.r4b.model.Questionnaire.QuestionnaireItemAnswerOptionComponent) Coding(org.hl7.fhir.r4b.model.Coding) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Aggregations

QuestionnaireItemAnswerOptionComponent (org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemAnswerOptionComponent)8 ArrayList (java.util.ArrayList)7 FHIRException (org.hl7.fhir.exceptions.FHIRException)7 Element (org.hl7.fhir.r5.elementmodel.Element)5 NodeStack (org.hl7.fhir.validation.instance.utils.NodeStack)5 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)4 Coding (org.hl7.fhir.r5.model.Coding)3 Coding (org.hl7.fhir.r4b.model.Coding)2 QuestionnaireItemAnswerOptionComponent (org.hl7.fhir.r4b.model.Questionnaire.QuestionnaireItemAnswerOptionComponent)2 QuestionnaireItemAnswerOptionComponent (org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemAnswerOptionComponent)1 QuestionnaireItemComponent (org.hl7.fhir.r4b.model.Questionnaire.QuestionnaireItemComponent)1 QuestionnaireItemEnableWhenComponent (org.hl7.fhir.r4b.model.Questionnaire.QuestionnaireItemEnableWhenComponent)1 QuestionnaireItemInitialComponent (org.hl7.fhir.r4b.model.Questionnaire.QuestionnaireItemInitialComponent)1 ValueSet (org.hl7.fhir.r4b.model.ValueSet)1 DateType (org.hl7.fhir.r5.model.DateType)1 IntegerType (org.hl7.fhir.r5.model.IntegerType)1 QuestionnaireItemComponent (org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent)1 QuestionnaireItemEnableWhenComponent (org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemEnableWhenComponent)1 QuestionnaireItemInitialComponent (org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemInitialComponent)1 StringType (org.hl7.fhir.r5.model.StringType)1