Search in sources :

Example 91 with Attachment

use of org.hl7.fhir.dstu2016may.model.Attachment in project org.hl7.fhir.core by hapifhir.

the class JsonParser method composeType.

protected void composeType(String prefix, DataType type) throws IOException {
    if (type == null) {
        ;
    } else if (type instanceof Address) {
        composeAddress(prefix + "Address", (Address) type);
    } else if (type instanceof Age) {
        composeAge(prefix + "Age", (Age) type);
    } else if (type instanceof Annotation) {
        composeAnnotation(prefix + "Annotation", (Annotation) type);
    } else if (type instanceof Attachment) {
        composeAttachment(prefix + "Attachment", (Attachment) type);
    } else if (type instanceof CodeableConcept) {
        composeCodeableConcept(prefix + "CodeableConcept", (CodeableConcept) type);
    } else if (type instanceof CodeableReference) {
        composeCodeableReference(prefix + "CodeableReference", (CodeableReference) type);
    } else if (type instanceof Coding) {
        composeCoding(prefix + "Coding", (Coding) type);
    } else if (type instanceof ContactDetail) {
        composeContactDetail(prefix + "ContactDetail", (ContactDetail) type);
    } else if (type instanceof ContactPoint) {
        composeContactPoint(prefix + "ContactPoint", (ContactPoint) type);
    } else if (type instanceof Contributor) {
        composeContributor(prefix + "Contributor", (Contributor) type);
    } else if (type instanceof Count) {
        composeCount(prefix + "Count", (Count) type);
    } else if (type instanceof DataRequirement) {
        composeDataRequirement(prefix + "DataRequirement", (DataRequirement) type);
    } else if (type instanceof Distance) {
        composeDistance(prefix + "Distance", (Distance) type);
    } else if (type instanceof Dosage) {
        composeDosage(prefix + "Dosage", (Dosage) type);
    } else if (type instanceof Duration) {
        composeDuration(prefix + "Duration", (Duration) type);
    } else if (type instanceof ElementDefinition) {
        composeElementDefinition(prefix + "ElementDefinition", (ElementDefinition) type);
    } else if (type instanceof Expression) {
        composeExpression(prefix + "Expression", (Expression) type);
    } else if (type instanceof Extension) {
        composeExtension(prefix + "Extension", (Extension) type);
    } else if (type instanceof HumanName) {
        composeHumanName(prefix + "HumanName", (HumanName) type);
    } else if (type instanceof Identifier) {
        composeIdentifier(prefix + "Identifier", (Identifier) type);
    } else if (type instanceof MarketingStatus) {
        composeMarketingStatus(prefix + "MarketingStatus", (MarketingStatus) type);
    } else if (type instanceof Meta) {
        composeMeta(prefix + "Meta", (Meta) type);
    } else if (type instanceof Money) {
        composeMoney(prefix + "Money", (Money) type);
    } else if (type instanceof Narrative) {
        composeNarrative(prefix + "Narrative", (Narrative) type);
    } else if (type instanceof ParameterDefinition) {
        composeParameterDefinition(prefix + "ParameterDefinition", (ParameterDefinition) type);
    } else if (type instanceof Period) {
        composePeriod(prefix + "Period", (Period) type);
    } else if (type instanceof Population) {
        composePopulation(prefix + "Population", (Population) type);
    } else if (type instanceof ProdCharacteristic) {
        composeProdCharacteristic(prefix + "ProdCharacteristic", (ProdCharacteristic) type);
    } else if (type instanceof ProductShelfLife) {
        composeProductShelfLife(prefix + "ProductShelfLife", (ProductShelfLife) type);
    } else if (type instanceof Quantity) {
        composeQuantity(prefix + "Quantity", (Quantity) type);
    } else if (type instanceof Range) {
        composeRange(prefix + "Range", (Range) type);
    } else if (type instanceof Ratio) {
        composeRatio(prefix + "Ratio", (Ratio) type);
    } else if (type instanceof RatioRange) {
        composeRatioRange(prefix + "RatioRange", (RatioRange) type);
    } else if (type instanceof Reference) {
        composeReference(prefix + "Reference", (Reference) type);
    } else if (type instanceof RelatedArtifact) {
        composeRelatedArtifact(prefix + "RelatedArtifact", (RelatedArtifact) type);
    } else if (type instanceof SampledData) {
        composeSampledData(prefix + "SampledData", (SampledData) type);
    } else if (type instanceof Signature) {
        composeSignature(prefix + "Signature", (Signature) type);
    } else if (type instanceof Timing) {
        composeTiming(prefix + "Timing", (Timing) type);
    } else if (type instanceof TriggerDefinition) {
        composeTriggerDefinition(prefix + "TriggerDefinition", (TriggerDefinition) type);
    } else if (type instanceof UsageContext) {
        composeUsageContext(prefix + "UsageContext", (UsageContext) type);
    } else if (type instanceof CodeType) {
        composeCodeCore(prefix + "Code", (CodeType) type, false);
        composeCodeExtras(prefix + "Code", (CodeType) type, false);
    } else if (type instanceof OidType) {
        composeOidCore(prefix + "Oid", (OidType) type, false);
        composeOidExtras(prefix + "Oid", (OidType) type, false);
    } else if (type instanceof CanonicalType) {
        composeCanonicalCore(prefix + "Canonical", (CanonicalType) type, false);
        composeCanonicalExtras(prefix + "Canonical", (CanonicalType) type, false);
    } else if (type instanceof UuidType) {
        composeUuidCore(prefix + "Uuid", (UuidType) type, false);
        composeUuidExtras(prefix + "Uuid", (UuidType) type, false);
    } else if (type instanceof UrlType) {
        composeUrlCore(prefix + "Url", (UrlType) type, false);
        composeUrlExtras(prefix + "Url", (UrlType) type, false);
    } else if (type instanceof UnsignedIntType) {
        composeUnsignedIntCore(prefix + "UnsignedInt", (UnsignedIntType) type, false);
        composeUnsignedIntExtras(prefix + "UnsignedInt", (UnsignedIntType) type, false);
    } else if (type instanceof MarkdownType) {
        composeMarkdownCore(prefix + "Markdown", (MarkdownType) type, false);
        composeMarkdownExtras(prefix + "Markdown", (MarkdownType) type, false);
    } else if (type instanceof IdType) {
        composeIdCore(prefix + "Id", (IdType) type, false);
        composeIdExtras(prefix + "Id", (IdType) type, false);
    } else if (type instanceof PositiveIntType) {
        composePositiveIntCore(prefix + "PositiveInt", (PositiveIntType) type, false);
        composePositiveIntExtras(prefix + "PositiveInt", (PositiveIntType) type, false);
    } else if (type instanceof DateType) {
        composeDateCore(prefix + "Date", (DateType) type, false);
        composeDateExtras(prefix + "Date", (DateType) type, false);
    } else if (type instanceof DateTimeType) {
        composeDateTimeCore(prefix + "DateTime", (DateTimeType) type, false);
        composeDateTimeExtras(prefix + "DateTime", (DateTimeType) type, false);
    } else if (type instanceof StringType) {
        composeStringCore(prefix + "String", (StringType) type, false);
        composeStringExtras(prefix + "String", (StringType) type, false);
    } else if (type instanceof IntegerType) {
        composeIntegerCore(prefix + "Integer", (IntegerType) type, false);
        composeIntegerExtras(prefix + "Integer", (IntegerType) type, false);
    } else if (type instanceof Integer64Type) {
        composeInteger64Core(prefix + "Integer64", (Integer64Type) type, false);
        composeInteger64Extras(prefix + "Integer64", (Integer64Type) type, false);
    } else if (type instanceof UriType) {
        composeUriCore(prefix + "Uri", (UriType) type, false);
        composeUriExtras(prefix + "Uri", (UriType) type, false);
    } else if (type instanceof InstantType) {
        composeInstantCore(prefix + "Instant", (InstantType) type, false);
        composeInstantExtras(prefix + "Instant", (InstantType) type, false);
    } else if (type instanceof BooleanType) {
        composeBooleanCore(prefix + "Boolean", (BooleanType) type, false);
        composeBooleanExtras(prefix + "Boolean", (BooleanType) type, false);
    } else if (type instanceof Base64BinaryType) {
        composeBase64BinaryCore(prefix + "Base64Binary", (Base64BinaryType) type, false);
        composeBase64BinaryExtras(prefix + "Base64Binary", (Base64BinaryType) type, false);
    } else if (type instanceof TimeType) {
        composeTimeCore(prefix + "Time", (TimeType) type, false);
        composeTimeExtras(prefix + "Time", (TimeType) type, false);
    } else if (type instanceof DecimalType) {
        composeDecimalCore(prefix + "Decimal", (DecimalType) type, false);
        composeDecimalExtras(prefix + "Decimal", (DecimalType) type, false);
    } else
        throw new Error("Unhandled type");
}
Also used : FHIRFormatError(org.hl7.fhir.exceptions.FHIRFormatError)

Example 92 with Attachment

use of org.hl7.fhir.dstu2016may.model.Attachment in project org.hl7.fhir.core by hapifhir.

the class Questionnaire40_50 method convertQuestionnaireItemType.

public static org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType> convertQuestionnaireItemType(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType> src) throws FHIRException {
    if (src == null || src.isEmpty())
        return null;
    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemTypeEnumFactory());
    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
    tgt.addExtension(VersionConvertorConstants.EXT_QUESTIONNAIRE_ITEM_TYPE_ORIGINAL, new CodeType(src.getValueAsString()));
    switch(src.getValue()) {
        case GROUP:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.GROUP);
            break;
        case DISPLAY:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.DISPLAY);
            break;
        case QUESTION:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.GROUP);
            break;
        case BOOLEAN:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.BOOLEAN);
            break;
        case DECIMAL:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.DECIMAL);
            break;
        case INTEGER:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.INTEGER);
            break;
        case DATE:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.DATE);
            break;
        case DATETIME:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.DATETIME);
            break;
        case TIME:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.TIME);
            break;
        case STRING:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.STRING);
            break;
        case TEXT:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.TEXT);
            break;
        case URL:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.URL);
            break;
        case CHOICE:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.CODING);
            break;
        case OPENCHOICE:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.CODING);
            break;
        case ATTACHMENT:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.ATTACHMENT);
            break;
        case REFERENCE:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.REFERENCE);
            break;
        case QUANTITY:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.QUANTITY);
            break;
        default:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.NULL);
            break;
    }
    return tgt;
}
Also used : QuestionnaireItemType(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType) CodeType(org.hl7.fhir.r5.model.CodeType)

Example 93 with Attachment

use of org.hl7.fhir.dstu2016may.model.Attachment in project org.hl7.fhir.core by hapifhir.

the class NarrativeGenerator method displayLeaf.

private boolean displayLeaf(ResourceWrapper res, BaseWrapper ew, ElementDefinition defn, XhtmlNode x, String name, boolean showCodeDetails) throws FHIRException, UnsupportedEncodingException, IOException {
    if (ew == null)
        return false;
    Base e = ew.getBase();
    Map<String, String> displayHints = readDisplayHints(defn);
    if (name.endsWith("[x]"))
        name = name.substring(0, name.length() - 3);
    if (!showCodeDetails && e instanceof PrimitiveType && isDefault(displayHints, ((PrimitiveType) e)))
        return false;
    if (e instanceof StringType) {
        x.addText(name + ": " + ((StringType) e).getValue());
        return true;
    } else if (e instanceof CodeType) {
        x.addText(name + ": " + ((CodeType) e).getValue());
        return true;
    } else if (e instanceof IdType) {
        x.addText(name + ": " + ((IdType) e).getValue());
        return true;
    } else if (e instanceof DateTimeType) {
        x.addText(name + ": " + ((DateTimeType) e).toHumanDisplay());
        return true;
    } else if (e instanceof InstantType) {
        x.addText(name + ": " + ((InstantType) e).toHumanDisplay());
        return true;
    } else if (e instanceof Extension) {
        x.addText("Extensions: todo");
        return true;
    } else if (e instanceof org.hl7.fhir.dstu2016may.model.DateType) {
        x.addText(name + ": " + ((org.hl7.fhir.dstu2016may.model.DateType) e).toHumanDisplay());
        return true;
    } else if (e instanceof Enumeration) {
        // todo: look up a display name if there is one
        x.addText(((Enumeration<?>) e).getValue().toString());
        return true;
    } else if (e instanceof BooleanType) {
        if (((BooleanType) e).getValue()) {
            x.addText(name);
            return true;
        }
    } else if (e instanceof CodeableConcept) {
        renderCodeableConcept((CodeableConcept) e, x, showCodeDetails);
        return true;
    } else if (e instanceof Coding) {
        renderCoding((Coding) e, x, showCodeDetails);
        return true;
    } else if (e instanceof Annotation) {
        renderAnnotation((Annotation) e, x, showCodeDetails);
        return true;
    } else if (e instanceof org.hl7.fhir.dstu2016may.model.IntegerType) {
        x.addText(Integer.toString(((org.hl7.fhir.dstu2016may.model.IntegerType) e).getValue()));
        return true;
    } else if (e instanceof org.hl7.fhir.dstu2016may.model.DecimalType) {
        x.addText(((org.hl7.fhir.dstu2016may.model.DecimalType) e).getValue().toString());
        return true;
    } else if (e instanceof Identifier) {
        renderIdentifier((Identifier) e, x);
        return true;
    } else if (e instanceof HumanName) {
        renderHumanName((HumanName) e, x);
        return true;
    } else if (e instanceof SampledData) {
        renderSampledData((SampledData) e, x);
        return true;
    } else if (e instanceof Address) {
        renderAddress((Address) e, x);
        return true;
    } else if (e instanceof ContactPoint) {
        renderContactPoint((ContactPoint) e, x);
        return true;
    } else if (e instanceof Timing) {
        renderTiming((Timing) e, x);
        return true;
    } else if (e instanceof Quantity) {
        renderQuantity((Quantity) e, x, showCodeDetails);
        return true;
    } else if (e instanceof Ratio) {
        renderQuantity(((Ratio) e).getNumerator(), x, showCodeDetails);
        x.addText("/");
        renderQuantity(((Ratio) e).getDenominator(), x, showCodeDetails);
        return true;
    } else if (e instanceof Period) {
        Period p = (Period) e;
        x.addText(name + ": ");
        x.addText(!p.hasStart() ? "??" : p.getStartElement().toHumanDisplay());
        x.addText(" --> ");
        x.addText(!p.hasEnd() ? "(ongoing)" : p.getEndElement().toHumanDisplay());
        return true;
    } else if (e instanceof Reference) {
        Reference r = (Reference) e;
        if (r.hasDisplayElement())
            x.addText(r.getDisplay());
        else if (r.hasReferenceElement()) {
            ResourceWithReference tr = resolveReference(res, r.getReference());
            // getDisplayForReference(tr.getReference()));
            x.addText(tr == null ? r.getReference() : "????");
        } else
            x.addText("??");
        return true;
    } else if (e instanceof Narrative) {
        return false;
    } else if (e instanceof Resource) {
        return false;
    } else if (!(e instanceof Attachment))
        throw new NotImplementedException("type " + e.getClass().getName() + " not handled yet");
    return false;
}
Also used : Address(org.hl7.fhir.dstu2016may.model.Address) StringType(org.hl7.fhir.dstu2016may.model.StringType) NotImplementedException(org.apache.commons.lang3.NotImplementedException) Attachment(org.hl7.fhir.dstu2016may.model.Attachment) HumanName(org.hl7.fhir.dstu2016may.model.HumanName) ContactPoint(org.hl7.fhir.dstu2016may.model.ContactPoint) Identifier(org.hl7.fhir.dstu2016may.model.Identifier) Coding(org.hl7.fhir.dstu2016may.model.Coding) Narrative(org.hl7.fhir.dstu2016may.model.Narrative) SampledData(org.hl7.fhir.dstu2016may.model.SampledData) PrimitiveType(org.hl7.fhir.dstu2016may.model.PrimitiveType) Ratio(org.hl7.fhir.dstu2016may.model.Ratio) InstantType(org.hl7.fhir.dstu2016may.model.InstantType) Enumeration(org.hl7.fhir.dstu2016may.model.Enumeration) Reference(org.hl7.fhir.dstu2016may.model.Reference) BooleanType(org.hl7.fhir.dstu2016may.model.BooleanType) Resource(org.hl7.fhir.dstu2016may.model.Resource) DomainResource(org.hl7.fhir.dstu2016may.model.DomainResource) Quantity(org.hl7.fhir.dstu2016may.model.Quantity) Period(org.hl7.fhir.dstu2016may.model.Period) Base(org.hl7.fhir.dstu2016may.model.Base) Annotation(org.hl7.fhir.dstu2016may.model.Annotation) IdType(org.hl7.fhir.dstu2016may.model.IdType) Extension(org.hl7.fhir.dstu2016may.model.Extension) DateTimeType(org.hl7.fhir.dstu2016may.model.DateTimeType) CodeType(org.hl7.fhir.dstu2016may.model.CodeType) EventTiming(org.hl7.fhir.dstu2016may.model.Timing.EventTiming) Timing(org.hl7.fhir.dstu2016may.model.Timing) CodeableConcept(org.hl7.fhir.dstu2016may.model.CodeableConcept)

Example 94 with Attachment

use of org.hl7.fhir.dstu2016may.model.Attachment in project org.hl7.fhir.core by hapifhir.

the class QuestionnaireRenderer method renderFormItem.

private boolean renderFormItem(XhtmlNode x, Questionnaire 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:
        case OPENCHOICE:
            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 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/questionnaire-choiceOrientation")) {
    // String code = ToolingExtensions.readStringExtension(i,  "http://hl7.org/fhir/StructureDefinition/questionnaire-choiceOrientation");
    // flags.addPiece(gen.new Piece("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-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-questionnaire-isSubject")) {
        hasFlag = true;
        flags.ah("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-isSubject", "Can change the subject of the questionnaire").img(Utilities.path(context.getLocalPrefix(), "icon-qi-subject.png"));
    }
    if (ToolingExtensions.readBoolExtension(i, "http://hl7.org/fhir/StructureDefinition/questionnaire-hidden")) {
        hasFlag = true;
        flags.ah(Utilities.pathURL(context.getSpecificationLink(), "extension-questionnaire-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-questionnaire-optionalDisplay")) {
        hasFlag = true;
        flags.ah("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-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-questionnaire-observationLinkPeriod")) {
        hasFlag = true;
        flags.ah("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observationLinkPeriod", "Is linked to an observation").img(Utilities.path(context.getLocalPrefix(), "icon-qi-observation.png"));
    }
    if (i.hasExtension("http://hl7.org/fhir/StructureDefinition/questionnaire-displayCategory")) {
        CodeableConcept cc = i.getExtensionByUrl("http://hl7.org/fhir/StructureDefinition/questionnaire-displayCategory").getValueCodeableConcept();
        String code = cc.getCode("http://hl7.org/fhir/questionnaire-display-category");
        hasFlag = true;
        flags.ah("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-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 (!Utilities.noString(i.getAnswerValueSet()) && 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 {
                renderCoding(vi, v.getValueCoding(), true);
            }
        }
    }
    if (!hasFlag) {
        ul.remove(flags);
    }
    // if (i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-enableWhenExpression") || i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemContext") || i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-calculatedExpression") || i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-contextExpression") || i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-candidateExpression") || i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-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-questionnaire-initialExpression")) {
    // addExpression(p, e.getValueExpression(), "Initial Value", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression");
    // }
    // for (Extension e : i.getExtensionsByUrl("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-contextExpression")) {
    // addExpression(p, e.getValueExpression(), "Context", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-contextExpression");
    // }
    // for (Extension e : i.getExtensionsByUrl("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemContext")) {
    // addExpression(p, e.getValueExpression(), "Item Context", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemContext");
    // }
    // for (Extension e : i.getExtensionsByUrl("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-enableWhenExpression")) {
    // addExpression(p, e.getValueExpression(), "Enable When", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-enableWhenExpression");
    // }
    // for (Extension e : i.getExtensionsByUrl("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-calculatedExpression")) {
    // addExpression(p, e.getValueExpression(), "Calculated Value", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-calculatedExpression");
    // }
    // for (Extension e : i.getExtensionsByUrl("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-candidateExpression")) {
    // addExpression(p, e.getValueExpression(), "Candidates", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-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;
}
Also used : QuestionnaireItemComponent(org.hl7.fhir.r4b.model.Questionnaire.QuestionnaireItemComponent) QuestionnaireItemInitialComponent(org.hl7.fhir.r4b.model.Questionnaire.QuestionnaireItemInitialComponent) ValueSet(org.hl7.fhir.r4b.model.ValueSet) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) CodeableConcept(org.hl7.fhir.r4b.model.CodeableConcept)

Example 95 with Attachment

use of org.hl7.fhir.dstu2016may.model.Attachment in project org.hl7.fhir.core by hapifhir.

the class LibraryRenderer method renderAttachment.

private void renderAttachment(XhtmlNode x, Attachment att, boolean noShowData, int counter, String baseId) {
    boolean ref = !att.hasData() && att.hasUrl();
    if (ref) {
        XhtmlNode p = x.para();
        if (att.hasTitle()) {
            p.tx(att.getTitle());
            p.tx(": ");
        }
        p.code().ah(att.getUrl()).tx(att.getUrl());
        p.tx(" (");
        p.code().tx(att.getContentType());
        p.tx(lang(att));
        p.tx(")");
    } else if (!att.hasData()) {
        XhtmlNode p = x.para();
        if (att.hasTitle()) {
            p.tx(att.getTitle());
            p.tx(": ");
        }
        p.code().tx("No Content");
        p.tx(" (");
        p.code().tx(att.getContentType());
        p.tx(lang(att));
        p.tx(")");
    } else {
        String txt = getText(att);
        if (isImage(att.getContentType())) {
            XhtmlNode p = x.para();
            if (att.hasTitle()) {
                p.tx(att.getTitle());
                p.tx(": (");
                p.code().tx(att.getContentType());
                p.tx(lang(att));
                p.tx(")");
            } else {
                p.code().tx(att.getContentType() + lang(att));
            }
            if (att.getData().length < LibraryRenderer.DATA_IMG_SIZE_CUTOFF) {
                x.img("data: " + att.getContentType() + ">;base64," + b64(att.getData()));
            } else {
                String filename = "Library-" + baseId + (counter == 0 ? "" : "-" + Integer.toString(counter)) + "." + imgExtension(att.getContentType());
                x.img(filename);
            }
        } else if (txt != null && !noShowData) {
            XhtmlNode p = x.para();
            if (att.hasTitle()) {
                p.tx(att.getTitle());
                p.tx(": (");
                p.code().tx(att.getContentType());
                p.tx(lang(att));
                p.tx(")");
            } else {
                p.code().tx(att.getContentType() + lang(att));
            }
            String prismCode = determinePrismCode(att);
            if (prismCode != null && !tooBig(txt)) {
                x.pre().code().setAttribute("class", "language-" + prismCode).tx(txt);
            } else {
                x.pre().code().tx(txt);
            }
        } else {
            XhtmlNode p = x.para();
            if (att.hasTitle()) {
                p.tx(att.getTitle());
                p.tx(": ");
            }
            p.code().tx("Content not shown - (");
            p.code().tx(att.getContentType());
            p.tx(lang(att));
            p.tx(", size = " + Utilities.describeSize(att.getData().length) + ")");
        }
    }
}
Also used : XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Aggregations

Attachment (org.hl7.fhir.r4.model.Attachment)33 Reference (org.hl7.fhir.r4.model.Reference)17 ArrayList (java.util.ArrayList)16 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)16 NotImplementedException (org.apache.commons.lang3.NotImplementedException)14 Coding (org.hl7.fhir.r4.model.Coding)11 DiagnosticReport (org.hl7.fhir.r4.model.DiagnosticReport)10 List (java.util.List)9 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)9 DocumentReference (org.hl7.fhir.r4.model.DocumentReference)9 Observation (org.hl7.fhir.r4.model.Observation)9 Test (org.junit.jupiter.api.Test)9 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)8 Resource (org.hl7.fhir.r4.model.Resource)8 FhirContext (ca.uhn.fhir.context.FhirContext)5 HashMap (java.util.HashMap)5 Base64 (org.apache.commons.codec.binary.Base64)5 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)5 Extension (org.hl7.fhir.r4.model.Extension)5 Library (org.hl7.fhir.r4.model.Library)5