Search in sources :

Example 6 with UsageContext

use of org.hl7.fhir.dstu3.model.UsageContext in project org.hl7.fhir.core by hapifhir.

the class ProfileDrivenRenderer method displayLeaf.

private boolean displayLeaf(ResourceWrapper res, BaseWrapper ew, ElementDefinition defn, XhtmlNode x, String name, boolean showCodeDetails, boolean allowLinks) throws FHIRException, UnsupportedEncodingException, IOException {
    if (ew == null)
        return false;
    Base e = ew.getBase();
    if (e == null)
        return false;
    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 UriType) {
        if (Utilities.isAbsoluteUrlLinkable(((UriType) e).getValue()) && allowLinks) {
            x.tx(name + ": ");
            x.ah(((UriType) e).getValue()).addText(((UriType) e).getValue());
        } else {
            x.addText(name + ": " + ((UriType) 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.tx("Extensions: todo");
        return false;
    } else if (e instanceof org.hl7.fhir.r4b.model.DateType) {
        x.addText(name + ": " + ((org.hl7.fhir.r4b.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).hasValue()) {
            x.addText(name);
            x.addText(": ");
            x.addText(((BooleanType) e).getValueAsString());
            return true;
        }
    } else if (e instanceof CodeableReference) {
        if (((CodeableReference) e).hasReference()) {
            Reference r = ((CodeableReference) e).getReference();
            renderReference(res, x, r, allowLinks);
        } else {
            renderCodeableConcept(x, ((CodeableReference) e).getConcept(), showCodeDetails);
        }
        return true;
    } else if (e instanceof CodeableConcept) {
        renderCodeableConcept(x, (CodeableConcept) e, showCodeDetails);
        return true;
    } else if (e instanceof Coding) {
        renderCoding(x, (Coding) e, showCodeDetails);
        return true;
    } else if (e instanceof Annotation) {
        renderAnnotation(x, (Annotation) e, showCodeDetails);
        return true;
    } else if (e instanceof org.hl7.fhir.r4b.model.IntegerType) {
        x.addText(Integer.toString(((org.hl7.fhir.r4b.model.IntegerType) e).getValue()));
        return true;
    } else if (e instanceof org.hl7.fhir.r4b.model.DecimalType) {
        x.addText(((org.hl7.fhir.r4b.model.DecimalType) e).getValue().toString());
        return true;
    } else if (e instanceof Identifier) {
        renderIdentifier(x, (Identifier) e);
        return true;
    } else if (e instanceof HumanName) {
        renderHumanName(x, (HumanName) e);
        return true;
    } else if (e instanceof SampledData) {
        renderSampledData(x, (SampledData) e);
        return true;
    } else if (e instanceof Address) {
        renderAddress(x, (Address) e);
        return true;
    } else if (e instanceof ContactPoint) {
        if (allowLinks) {
            renderContactPoint(x, (ContactPoint) e);
        } else {
            displayContactPoint(x, (ContactPoint) e);
        }
        return true;
    } else if (e instanceof Timing) {
        renderTiming(x, (Timing) e);
        return true;
    } else if (e instanceof Quantity) {
        renderQuantity(x, (Quantity) e, showCodeDetails);
        return true;
    } else if (e instanceof Ratio) {
        renderQuantity(x, ((Ratio) e).getNumerator(), showCodeDetails);
        x.tx("/");
        renderQuantity(x, ((Ratio) e).getDenominator(), showCodeDetails);
        return true;
    } else if (e instanceof Period) {
        Period p = (Period) e;
        x.addText(name + ": ");
        x.addText(!p.hasStart() ? "?ngen-2?" : p.getStartElement().toHumanDisplay());
        x.tx(" --> ");
        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() : "?ngen-3");
        } else
            x.tx("?ngen-4?");
        return true;
    } else if (e instanceof Narrative) {
        return false;
    } else if (e instanceof Resource) {
        return false;
    } else if (e instanceof ContactDetail) {
        ContactDetail cd = (ContactDetail) e;
        if (cd.hasName()) {
            x.tx(cd.getName() + ": ");
        }
        boolean first = true;
        for (ContactPoint c : cd.getTelecom()) {
            if (first)
                first = false;
            else
                x.tx(",");
            if (allowLinks) {
                renderContactPoint(x, c);
            } else {
                displayContactPoint(x, c);
            }
        }
        return true;
    } else if (e instanceof Range) {
        return false;
    } else if (e instanceof Meta) {
        return false;
    } else if (e instanceof Dosage) {
        return false;
    } else if (e instanceof Signature) {
        return false;
    } else if (e instanceof UsageContext) {
        return false;
    } else if (e instanceof RelatedArtifact) {
        return false;
    } else if (e instanceof ElementDefinition) {
        return false;
    } else if (e instanceof Base64BinaryType) {
        return false;
    } else if (!(e instanceof Attachment))
        throw new NotImplementedException("type " + e.getClass().getName() + " not handled yet");
    return false;
}
Also used : Meta(org.hl7.fhir.r4b.model.Meta) Address(org.hl7.fhir.r4b.model.Address) StringType(org.hl7.fhir.r4b.model.StringType) Attachment(org.hl7.fhir.r4b.model.Attachment) Dosage(org.hl7.fhir.r4b.model.Dosage) Identifier(org.hl7.fhir.r4b.model.Identifier) Coding(org.hl7.fhir.r4b.model.Coding) Narrative(org.hl7.fhir.r4b.model.Narrative) SampledData(org.hl7.fhir.r4b.model.SampledData) PrimitiveType(org.hl7.fhir.r4b.model.PrimitiveType) ElementDefinition(org.hl7.fhir.r4b.model.ElementDefinition) InstantType(org.hl7.fhir.r4b.model.InstantType) DomainResource(org.hl7.fhir.r4b.model.DomainResource) Resource(org.hl7.fhir.r4b.model.Resource) Period(org.hl7.fhir.r4b.model.Period) ResourceWithReference(org.hl7.fhir.r4b.renderers.utils.Resolver.ResourceWithReference) Range(org.hl7.fhir.r4b.model.Range) RelatedArtifact(org.hl7.fhir.r4b.model.RelatedArtifact) IdType(org.hl7.fhir.r4b.model.IdType) DateTimeType(org.hl7.fhir.r4b.model.DateTimeType) UsageContext(org.hl7.fhir.r4b.model.UsageContext) Timing(org.hl7.fhir.r4b.model.Timing) CodeableConcept(org.hl7.fhir.r4b.model.CodeableConcept) NotImplementedException(org.apache.commons.lang3.NotImplementedException) UriType(org.hl7.fhir.r4b.model.UriType) HumanName(org.hl7.fhir.r4b.model.HumanName) ContactPoint(org.hl7.fhir.r4b.model.ContactPoint) Ratio(org.hl7.fhir.r4b.model.Ratio) Enumeration(org.hl7.fhir.r4b.model.Enumeration) CodeableReference(org.hl7.fhir.r4b.model.CodeableReference) ResourceWithReference(org.hl7.fhir.r4b.renderers.utils.Resolver.ResourceWithReference) Reference(org.hl7.fhir.r4b.model.Reference) BooleanType(org.hl7.fhir.r4b.model.BooleanType) Quantity(org.hl7.fhir.r4b.model.Quantity) Base(org.hl7.fhir.r4b.model.Base) Annotation(org.hl7.fhir.r4b.model.Annotation) Extension(org.hl7.fhir.r4b.model.Extension) ContactDetail(org.hl7.fhir.r4b.model.ContactDetail) CodeableReference(org.hl7.fhir.r4b.model.CodeableReference) Signature(org.hl7.fhir.r4b.model.Signature) CodeType(org.hl7.fhir.r4b.model.CodeType) Base64BinaryType(org.hl7.fhir.r4b.model.Base64BinaryType)

Example 7 with UsageContext

use of org.hl7.fhir.dstu3.model.UsageContext in project eCRNow by drajer-health.

the class ApplicationUtils method isAGrouperValueSet.

public static boolean isAGrouperValueSet(ValueSet v) {
    boolean retVal = false;
    if (v != null) {
        if (v.getUseContextFirstRep() != null) {
            logger.debug("Found Use Context ");
            UsageContext uc = v.getUseContextFirstRep();
            if (uc.getValue() != null && (uc.getValue() instanceof Reference)) {
                logger.debug("Found Use Context Reference ");
                Reference rr = (Reference) uc.getValue();
                if (rr != null && rr.getReference() != null && (rr.getReference().contains(PlanDefinitionProcessor.GROUPER_VALUE_SET_REFERENCE_1) || rr.getReference().contains(PlanDefinitionProcessor.GROUPER_VALUE_SET_REFERENCE_2))) {
                    logger.debug("Found Grouper VALUE SET = {}", v.getId());
                    retVal = true;
                }
            }
        }
    }
    return retVal;
}
Also used : UsageContext(org.hl7.fhir.r4.model.UsageContext) Reference(org.hl7.fhir.r4.model.Reference)

Example 8 with UsageContext

use of org.hl7.fhir.dstu3.model.UsageContext in project eCRNow by drajer-health.

the class ApplicationUtils method isACovidValueSet.

public static boolean isACovidValueSet(ValueSet v) {
    boolean retVal = false;
    if (v != null) {
        logger.debug("Checking Value Set Id {}", v.getId());
        if (v.getUseContextFirstRep() != null) {
            UsageContext uc = v.getUseContextFirstRep();
            if (uc.getValue() != null && (uc.getValue() instanceof CodeableConcept)) {
                CodeableConcept cc = (CodeableConcept) uc.getValue();
                if (cc.getCodingFirstRep() != null && (cc.getCodingFirstRep().getCode() != null && cc.getCodingFirstRep().getCode().contentEquals(PlanDefinitionProcessor.COVID_SNOMED_USE_CONTEXT_CODE))) {
                    logger.debug("Found COVID VALUE SET = {}", v.getId());
                    retVal = true;
                }
            }
        }
    }
    return retVal;
}
Also used : UsageContext(org.hl7.fhir.r4.model.UsageContext) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 9 with UsageContext

use of org.hl7.fhir.dstu3.model.UsageContext in project kindling by HL7.

the class PageProcessor method getProfileContext.

private String getProfileContext(CanonicalResource mr, String prefix) throws DefinitionException {
    DataRenderer gen = new DataRenderer(workerContext);
    CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
    for (UsageContext uc : mr.getUseContext()) {
        String vs = gen.display(uc.getValue());
        if (vs != null)
            b.append(gen.display(uc.getCode()) + ": " + vs);
    }
    for (CodeableConcept cc : mr.getJurisdiction()) {
        b.append("Country: " + gen.displayCodeableConcept(cc));
    }
    if (mr.getExperimental()) {
        if (isTrialUse(mr))
            b.append("Not yet ready for Production use");
        else
            b.append("Not Intended for Production use");
    }
    if (b.length() == 0)
        return "<a href=\"" + prefix + "metadatatypes.html#UsageContext\">Use Context</a>: Any";
    else
        return "<a href=\"" + prefix + "metadatatypes.html#UsageContext\">Use Context</a>: " + b.toString();
}
Also used : DataRenderer(org.hl7.fhir.r5.renderers.DataRenderer) UsageContext(org.hl7.fhir.r5.model.UsageContext) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) CodeableConcept(org.hl7.fhir.r5.model.CodeableConcept)

Example 10 with UsageContext

use of org.hl7.fhir.dstu3.model.UsageContext in project org.hl7.fhir.core by hapifhir.

the class Questionnaire14_50 method convertQuestionnaire.

public static org.hl7.fhir.dstu2016may.model.Questionnaire convertQuestionnaire(org.hl7.fhir.r5.model.Questionnaire src) throws FHIRException {
    if (src == null || src.isEmpty())
        return null;
    org.hl7.fhir.dstu2016may.model.Questionnaire tgt = new org.hl7.fhir.dstu2016may.model.Questionnaire();
    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyDomainResource(src, tgt);
    if (src.hasUrl())
        tgt.setUrlElement(Uri14_50.convertUri(src.getUrlElement()));
    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(Identifier14_50.convertIdentifier(t));
    if (src.hasVersion())
        tgt.setVersionElement(String14_50.convertString(src.getVersionElement()));
    if (src.hasStatus())
        tgt.setStatusElement(convertQuestionnaireStatus(src.getStatusElement()));
    if (src.hasDate())
        tgt.setDateElement(DateTime14_50.convertDateTime(src.getDateElement()));
    if (src.hasPublisher())
        tgt.setPublisherElement(String14_50.convertString(src.getPublisherElement()));
    for (ContactDetail t : src.getContact()) for (org.hl7.fhir.r5.model.ContactPoint t1 : t.getTelecom()) tgt.addTelecom(ContactPoint14_50.convertContactPoint(t1));
    for (UsageContext t : src.getUseContext()) tgt.addUseContext(CodeableConcept14_50.convertCodeableConcept(t.getValueCodeableConcept()));
    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getJurisdiction()) tgt.addUseContext(CodeableConcept14_50.convertCodeableConcept(t));
    if (src.hasTitle())
        tgt.setTitleElement(String14_50.convertString(src.getTitleElement()));
    for (org.hl7.fhir.r5.model.Coding t : src.getCode()) tgt.addConcept(Coding14_50.convertCoding(t));
    for (CodeType t : src.getSubjectType()) tgt.addSubjectType(t.getValue());
    for (org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent t : src.getItem()) tgt.addItem(convertQuestionnaireItemComponent(t));
    return tgt;
}
Also used : ContactDetail(org.hl7.fhir.r5.model.ContactDetail) UsageContext(org.hl7.fhir.r5.model.UsageContext) CodeType(org.hl7.fhir.r5.model.CodeType)

Aggregations

NotImplementedException (org.apache.commons.lang3.NotImplementedException)3 UsageContext (org.hl7.fhir.r4.model.UsageContext)3 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)3 UsageContext (org.hl7.fhir.r5.model.UsageContext)3 ContactDetail (org.hl7.fhir.dstu3.model.ContactDetail)2 UsageContext (org.hl7.fhir.dstu3.model.UsageContext)2 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)2 CodeType (org.hl7.fhir.r5.model.CodeType)2 CodeableConcept (org.hl7.fhir.r5.model.CodeableConcept)2 ContactDetail (org.hl7.fhir.r5.model.ContactDetail)2 BindingSpecification (org.hl7.fhir.definitions.model.BindingSpecification)1 CodeListToValueSetParser (org.hl7.fhir.definitions.parsers.CodeListToValueSetParser)1 ValueSetGenerator (org.hl7.fhir.definitions.parsers.ValueSetGenerator)1 Address (org.hl7.fhir.dstu3.model.Address)1 Annotation (org.hl7.fhir.dstu3.model.Annotation)1 Attachment (org.hl7.fhir.dstu3.model.Attachment)1 Base (org.hl7.fhir.dstu3.model.Base)1 BooleanType (org.hl7.fhir.dstu3.model.BooleanType)1 CodeType (org.hl7.fhir.dstu3.model.CodeType)1 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)1