Search in sources :

Example 81 with BooleanType

use of org.hl7.fhir.r4.model.BooleanType in project org.hl7.fhir.core by hapifhir.

the class BooleanTypeNullTest method equalsShallow.

@Test
@DisplayName("Test null value equalsShallow()")
void equalsShallow() {
    BooleanType nullBoolean = new BooleanType();
    BooleanType validBoolean = new BooleanType("false");
    Assertions.assertFalse(nullBoolean.equalsShallow(validBoolean));
}
Also used : BooleanType(org.hl7.fhir.r4b.model.BooleanType) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 82 with BooleanType

use of org.hl7.fhir.r4.model.BooleanType in project org.hl7.fhir.core by hapifhir.

the class ValueSetRenderer method generateExpansion.

private boolean generateExpansion(XhtmlNode x, ValueSet vs, boolean header, List<UsedConceptMap> maps) throws FHIRFormatError, DefinitionException, IOException {
    boolean hasExtensions = false;
    List<String> langs = new ArrayList<String>();
    // map of url = description, where url is the designation code. Designations that are for languages won't make it into this list
    Map<String, String> designations = new HashMap<>();
    if (header) {
        XhtmlNode h = x.addTag(getHeader());
        h.tx("Value Set Contents");
        if (IsNotFixedExpansion(vs))
            addMarkdown(x, vs.getDescription());
        if (vs.hasCopyright())
            generateCopyright(x, vs);
    }
    if (ToolingExtensions.hasExtension(vs.getExpansion(), ToolingExtensions.EXT_EXP_TOOCOSTLY)) {
        List<Extension> exl = vs.getExpansion().getExtensionsByUrl(ToolingExtensions.EXT_EXP_TOOCOSTLY);
        boolean other = false;
        for (Extension ex : exl) {
            if (ex.getValue() instanceof BooleanType) {
                x.para().style("border: maroon 1px solid; background-color: #FFCCCC; font-weight: bold; padding: 8px").addText(vs.getExpansion().getContains().isEmpty() ? getContext().getTooCostlyNoteEmpty() : getContext().getTooCostlyNoteNotEmpty());
            } else if (!other) {
                x.para().style("border: maroon 1px solid; background-color: #FFCCCC; font-weight: bold; padding: 8px").addText(vs.getExpansion().getContains().isEmpty() ? getContext().getTooCostlyNoteEmptyDependent() : getContext().getTooCostlyNoteNotEmptyDependent());
                other = true;
            }
        }
    } else {
        Integer count = countMembership(vs);
        if (count == null)
            x.para().tx("This value set does not contain a fixed number of concepts");
        else
            x.para().tx("This value set contains " + count.toString() + " concepts");
    }
    generateContentModeNotices(x, vs.getExpansion());
    generateVersionNotice(x, vs.getExpansion());
    CodeSystem allCS = null;
    boolean doLevel = false;
    for (ValueSetExpansionContainsComponent cc : vs.getExpansion().getContains()) {
        if (cc.hasContains()) {
            doLevel = true;
            break;
        }
    }
    // checkDoSystem(vs, src);
    boolean doSystem = true;
    boolean doDefinition = checkDoDefinition(vs.getExpansion().getContains());
    if (doSystem && allFromOneSystem(vs)) {
        doSystem = false;
        XhtmlNode p = x.para();
        p.tx("All codes in this table are from the system ");
        allCS = getContext().getWorker().fetchCodeSystem(vs.getExpansion().getContains().get(0).getSystem());
        String ref = null;
        if (allCS != null)
            ref = getCsRef(allCS);
        if (ref == null)
            p.code(vs.getExpansion().getContains().get(0).getSystem());
        else
            p.ah(context.fixReference(ref)).code(vs.getExpansion().getContains().get(0).getSystem());
    }
    XhtmlNode t = x.table("codes");
    XhtmlNode tr = t.tr();
    if (doLevel)
        tr.td().b().tx("Level");
    tr.td().attribute("style", "white-space:nowrap").b().tx("Code");
    if (doSystem)
        tr.td().b().tx("System");
    XhtmlNode tdDisp = tr.td();
    tdDisp.b().tx("Display");
    boolean doDesignations = false;
    for (ValueSetExpansionContainsComponent c : vs.getExpansion().getContains()) {
        scanForDesignations(c, langs, designations);
    }
    if (doDefinition) {
        tr.td().b().tx("Definition");
        doDesignations = false;
    } else {
        // if we're not doing definitions and we don't have too many languages, we'll do them in line
        doDesignations = langs.size() + designations.size() < MAX_DESIGNATIONS_IN_LINE;
        if (doDesignations) {
            if (vs.hasLanguage()) {
                tdDisp.tx(" - " + describeLang(vs.getLanguage()));
            }
            for (String url : designations.keySet()) {
                tr.td().b().addText(designations.get(url));
            }
            for (String lang : langs) {
                tr.td().b().addText(describeLang(lang));
            }
        }
    }
    addMapHeaders(tr, maps);
    for (ValueSetExpansionContainsComponent c : vs.getExpansion().getContains()) {
        addExpansionRowToTable(t, c, 1, doLevel, doSystem, doDefinition, maps, allCS, langs, designations, doDesignations);
    }
    if (!doDesignations && langs.size() + designations.size() > 0) {
        Collections.sort(langs);
        if (designations.size() == 0) {
            x.para().b().tx("Additional Language Displays");
        } else if (langs.size() == 0) {
            x.para().b().tx("Additional Designations");
        } else {
            x.para().b().tx("Additional Designations and Language Displays");
        }
        t = x.table("codes");
        tr = t.tr();
        tr.td().b().tx("Code");
        for (String url : designations.keySet()) {
            tr.td().b().addText(designations.get(url));
        }
        for (String lang : langs) {
            tr.td().b().addText(describeLang(lang));
        }
        for (ValueSetExpansionContainsComponent c : vs.getExpansion().getContains()) {
            addDesignationRow(c, t, langs, designations);
        }
    }
    return hasExtensions;
}
Also used : ValueSetExpansionContainsComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) BooleanType(org.hl7.fhir.r5.model.BooleanType) CodeSystem(org.hl7.fhir.r5.model.CodeSystem) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) Extension(org.hl7.fhir.r5.model.Extension)

Example 83 with BooleanType

use of org.hl7.fhir.r4.model.BooleanType in project org.hl7.fhir.core by hapifhir.

the class ProfileDrivenRenderer method renderLeaf.

private void renderLeaf(ResourceWrapper res, BaseWrapper ew, ElementDefinition defn, XhtmlNode parent, XhtmlNode x, boolean title, boolean showCodeDetails, Map<String, String> displayHints, String path, int indent) throws FHIRException, UnsupportedEncodingException, IOException, EOperationOutcome {
    if (ew == null)
        return;
    Base e = ew.getBase();
    if (e instanceof StringType)
        x.addText(((StringType) e).getValue());
    else if (e instanceof CodeType)
        x.addText(((CodeType) e).getValue());
    else if (e instanceof IdType)
        x.addText(((IdType) e).getValue());
    else if (e instanceof Extension)
        return;
    else if (e instanceof InstantType)
        x.addText(((InstantType) e).toHumanDisplay());
    else if (e instanceof DateTimeType) {
        renderDateTime(x, e);
    } else if (e instanceof Base64BinaryType)
        x.addText(new Base64().encodeAsString(((Base64BinaryType) e).getValue()));
    else if (e instanceof org.hl7.fhir.r5.model.DateType) {
        org.hl7.fhir.r5.model.DateType dt = ((org.hl7.fhir.r5.model.DateType) e);
        renderDate(x, dt);
    } else if (e instanceof Enumeration) {
        Object ev = ((Enumeration<?>) e).getValue();
        // todo: look up a display name if there is one
        x.addText(ev == null ? "" : ev.toString());
    } else if (e instanceof BooleanType) {
        x.addText(((BooleanType) e).getValue().toString());
    } else if (e instanceof CodeableConcept) {
        renderCodeableConcept(x, (CodeableConcept) e, showCodeDetails);
    } else if (e instanceof Coding) {
        renderCoding(x, (Coding) e, showCodeDetails);
    } else if (e instanceof CodeableReference) {
        renderCodeableReference(x, (CodeableReference) e, showCodeDetails);
    } else if (e instanceof Annotation) {
        renderAnnotation(x, (Annotation) e);
    } else if (e instanceof Identifier) {
        renderIdentifier(x, (Identifier) e);
    } else if (e instanceof org.hl7.fhir.r5.model.IntegerType) {
        if (((org.hl7.fhir.r5.model.IntegerType) e).hasValue()) {
            x.addText(Integer.toString(((org.hl7.fhir.r5.model.IntegerType) e).getValue()));
        } else {
            x.addText("??");
        }
    } else if (e instanceof org.hl7.fhir.r5.model.Integer64Type) {
        if (((org.hl7.fhir.r5.model.Integer64Type) e).hasValue()) {
            x.addText(Long.toString(((org.hl7.fhir.r5.model.Integer64Type) e).getValue()));
        } else {
            x.addText("??");
        }
    } else if (e instanceof org.hl7.fhir.r5.model.DecimalType) {
        x.addText(((org.hl7.fhir.r5.model.DecimalType) e).getValue().toString());
    } else if (e instanceof HumanName) {
        renderHumanName(x, (HumanName) e);
    } else if (e instanceof SampledData) {
        renderSampledData(x, (SampledData) e);
    } else if (e instanceof Address) {
        renderAddress(x, (Address) e);
    } else if (e instanceof ContactPoint) {
        renderContactPoint(x, (ContactPoint) e);
    } else if (e instanceof Expression) {
        renderExpression(x, (Expression) e);
    } else if (e instanceof Money) {
        renderMoney(x, (Money) e);
    } 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(",");
            renderContactPoint(x, c);
        }
    } else if (e instanceof UriType) {
        renderUri(x, (UriType) e, defn.getPath(), rcontext != null && rcontext.getResourceResource() != null ? rcontext.getResourceResource().getId() : null);
    } else if (e instanceof Timing) {
        renderTiming(x, (Timing) e);
    } else if (e instanceof Range) {
        renderRange(x, (Range) e);
    } else if (e instanceof Quantity) {
        renderQuantity(x, (Quantity) e, showCodeDetails);
    } else if (e instanceof Ratio) {
        renderQuantity(x, ((Ratio) e).getNumerator(), showCodeDetails);
        x.tx("/");
        renderQuantity(x, ((Ratio) e).getDenominator(), showCodeDetails);
    } else if (e instanceof Period) {
        Period p = (Period) e;
        renderPeriod(x, p);
    } else if (e instanceof Reference) {
        Reference r = (Reference) e;
        if (r.getReference() != null && r.getReference().contains("#")) {
            if (containedIds.contains(r.getReference().substring(1))) {
                x.ah(r.getReference()).tx("See " + r.getReference());
            } else {
                // in this case, we render the resource in line
                ResourceWrapper rw = null;
                for (ResourceWrapper t : res.getContained()) {
                    if (r.getReference().substring(1).equals(t.getId())) {
                        rw = t;
                    }
                }
                if (rw == null) {
                    renderReference(res, x, r);
                } else {
                    x.an(rw.getId());
                    ResourceRenderer rr = RendererFactory.factory(rw, context.copy().setAddGeneratedNarrativeHeader(false));
                    rr.render(parent.blockquote(), rw);
                }
            }
        } else {
            renderReference(res, x, r);
        }
    } else if (e instanceof Resource) {
        return;
    } else if (e instanceof DataRequirement) {
        DataRequirement p = (DataRequirement) e;
        renderDataRequirement(x, p);
    } else if (e instanceof PrimitiveType) {
        x.tx(((PrimitiveType) e).primitiveValue());
    } else if (e instanceof ElementDefinition) {
        x.tx("todo-bundle");
    } else if (e != null && !(e instanceof Attachment) && !(e instanceof Narrative) && !(e instanceof Meta)) {
        throw new NotImplementedException("type " + e.getClass().getName() + " not handled - should not be here");
    }
}
Also used : ResourceWrapper(org.hl7.fhir.r5.renderers.utils.BaseWrappers.ResourceWrapper) Meta(org.hl7.fhir.r5.model.Meta) Address(org.hl7.fhir.r5.model.Address) StringType(org.hl7.fhir.r5.model.StringType) Attachment(org.hl7.fhir.r5.model.Attachment) DataRequirement(org.hl7.fhir.r5.model.DataRequirement) Identifier(org.hl7.fhir.r5.model.Identifier) Coding(org.hl7.fhir.r5.model.Coding) Narrative(org.hl7.fhir.r5.model.Narrative) SampledData(org.hl7.fhir.r5.model.SampledData) PrimitiveType(org.hl7.fhir.r5.model.PrimitiveType) ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition) InstantType(org.hl7.fhir.r5.model.InstantType) Resource(org.hl7.fhir.r5.model.Resource) DomainResource(org.hl7.fhir.r5.model.DomainResource) Period(org.hl7.fhir.r5.model.Period) Range(org.hl7.fhir.r5.model.Range) IdType(org.hl7.fhir.r5.model.IdType) DateTimeType(org.hl7.fhir.r5.model.DateTimeType) Timing(org.hl7.fhir.r5.model.Timing) CodeableConcept(org.hl7.fhir.r5.model.CodeableConcept) Base64(org.apache.commons.codec.binary.Base64) NotImplementedException(org.apache.commons.lang3.NotImplementedException) UriType(org.hl7.fhir.r5.model.UriType) HumanName(org.hl7.fhir.r5.model.HumanName) ContactPoint(org.hl7.fhir.r5.model.ContactPoint) Money(org.hl7.fhir.r5.model.Money) Ratio(org.hl7.fhir.r5.model.Ratio) Enumeration(org.hl7.fhir.r5.model.Enumeration) Reference(org.hl7.fhir.r5.model.Reference) ResourceWithReference(org.hl7.fhir.r5.renderers.utils.Resolver.ResourceWithReference) CodeableReference(org.hl7.fhir.r5.model.CodeableReference) BooleanType(org.hl7.fhir.r5.model.BooleanType) Quantity(org.hl7.fhir.r5.model.Quantity) Base(org.hl7.fhir.r5.model.Base) Annotation(org.hl7.fhir.r5.model.Annotation) Extension(org.hl7.fhir.r5.model.Extension) ContactDetail(org.hl7.fhir.r5.model.ContactDetail) Expression(org.hl7.fhir.r5.model.Expression) CodeableReference(org.hl7.fhir.r5.model.CodeableReference) CodeType(org.hl7.fhir.r5.model.CodeType) Base64BinaryType(org.hl7.fhir.r5.model.Base64BinaryType)

Example 84 with BooleanType

use of org.hl7.fhir.r4.model.BooleanType in project snowstorm by IHTSDO.

the class FHIRValueSetProviderTest method testExpandTypeThrowsFHIROperationExceptionIfVersionUsedWhilePerformingPOSTOperation.

@Test(expected = FHIROperationException.class)
public void testExpandTypeThrowsFHIROperationExceptionIfVersionUsedWhilePerformingPOSTOperation() throws FHIROperationException {
    Mockito.doThrow(new FHIROperationException(OperationOutcome.IssueType.NOTSUPPORTED, "Input parameter 'version' is not currently " + "supported in the context of a ValueSet $expand operation. Use system-version or force-system-version parameters instead.")).when(fhirHelper).notSupported(Mockito.anyString(), Mockito.any(), Mockito.anyString());
    fhirValueSetProvider.expandInstance(IdType.newRandomUuid(), getHttpServletRequestWithRequestMethodPOST(), Mockito.mock(HttpServletResponse.class), VALUE_SET_EXPANSION_POST_BODY_WITH_VERSION, "", "", new BooleanType(), new BooleanType(), Collections.emptyList(), "", "", "", new StringType(), new StringType(), new StringType());
}
Also used : StringType(org.hl7.fhir.r4.model.StringType) BooleanType(org.hl7.fhir.r4.model.BooleanType) HttpServletResponse(javax.servlet.http.HttpServletResponse) Test(org.junit.Test)

Example 85 with BooleanType

use of org.hl7.fhir.r4.model.BooleanType in project redmatch by aehrc.

the class RedmatchGrammarCodeSystemGenerator method createBaseCodeSystem.

private CodeSystem createBaseCodeSystem(VersionedFhirPackage fhirPackage) {
    CodeSystem cs = new CodeSystem();
    cs.setId("redmatch-" + fhirPackage.getName());
    cs.setUrl("http://redmatch." + fhirPackage.getName());
    cs.setVersion(fhirPackage.getVersion());
    cs.setName("Redmatch Validation Code System for " + fhirPackage.getName());
    cs.setStatus(PublicationStatus.ACTIVE);
    cs.setDescription("A code system with all the valid paths used to refer to attributes of resources in " + fhirPackage.getName());
    cs.setValueSet("http://redmatch." + fhirPackage.getName() + "?vs");
    cs.setHierarchyMeaning(CodeSystemHierarchyMeaning.ISA);
    cs.setContent(CodeSystemContentMode.COMPLETE);
    cs.setExperimental(false);
    cs.setCompositional(false);
    cs.setVersionNeeded(false);
    cs.addProperty().setCode("parent").setDescription("Parent codes.").setType(PropertyType.CODE);
    cs.addProperty().setCode("root").setDescription("Indicates if this concept is a root concept.").setType(PropertyType.BOOLEAN);
    cs.addProperty().setCode("deprecated").setDescription("Indicates if this concept is deprecated.").setType(PropertyType.BOOLEAN);
    cs.addProperty().setCode("parentResourceOrProfile").setDescription("If this concept represents an attribute then this property represents the resource or profile" + "that contains the attribute. If this concepts is a profile or resource then the parent resource is Object.").setType(PropertyType.CODE);
    cs.addProperty().setCode("min").setDescription("Minimum cardinality").setType(PropertyType.INTEGER);
    cs.addProperty().setCode("max").setDescription("Maximum cardinality").setType(PropertyType.STRING);
    cs.addProperty().setCode("type").setDescription("Data type for this element.").setType(PropertyType.STRING);
    cs.addProperty().setCode("targetProfile").setDescription("If this code represents a Reference attribute, contains an allowed target profile.").setType(PropertyType.STRING);
    cs.addProperty().setCode("profile").setDescription("Indicates if this code represents a profile.").setType(PropertyType.BOOLEAN);
    cs.addProperty().setCode("baseResource").setDescription("For profiles, indicates the resource the profile constrains.").setType(PropertyType.CODE);
    cs.addProperty().setCode("extensionUrl").setDescription("If this code represents an extension, then this is its url.").setType(PropertyType.STRING);
    cs.addProperty().setCode("profileUrl").setDescription("If this code represents a profile, then this is its url.").setType(PropertyType.STRING);
    cs.addFilter().setCode("root").setValue("True or false.").addOperator(FilterOperator.EQUAL);
    cs.addFilter().setCode("deprecated").setValue("True or false.").addOperator(FilterOperator.EQUAL);
    cs.addFilter().setCode("parentResourceOrProfile").setValue("The parent resource or profile code.").addOperator(FilterOperator.EQUAL);
    cs.addFilter().setCode("profile").setValue("True or false.").addOperator(FilterOperator.EQUAL);
    // Create root concept
    ConceptDefinitionComponent objectRoot = cs.addConcept().setCode("Object").setDisplay("Object");
    objectRoot.addProperty().setCode("root").setValue(new BooleanType(true));
    objectRoot.addProperty().setCode("deprecated").setValue(new BooleanType(false));
    ConceptDefinitionComponent complexTypeRoot = cs.addConcept().setCode("ComplexType").setDisplay("ComplexType");
    complexTypeRoot.addProperty().setCode("root").setValue(new BooleanType(false));
    complexTypeRoot.addProperty().setCode("deprecated").setValue(new BooleanType(false));
    complexTypeRoot.addProperty().setCode("parent").setValue(new CodeType("Object"));
    ConceptDefinitionComponent resourceRoot = cs.addConcept().setCode("Resource").setDisplay("Resource");
    resourceRoot.addProperty().setCode("root").setValue(new BooleanType(false));
    resourceRoot.addProperty().setCode("deprecated").setValue(new BooleanType(false));
    resourceRoot.addProperty().setCode("parent").setValue(new CodeType("Object"));
    ConceptDefinitionComponent profileRoot = cs.addConcept().setCode("Profile").setDisplay("Profile");
    profileRoot.addProperty().setCode("root").setValue(new BooleanType(false));
    profileRoot.addProperty().setCode("deprecated").setValue(new BooleanType(false));
    profileRoot.addProperty().setCode("parent").setValue(new CodeType("Object"));
    return cs;
}
Also used : CodeSystem(org.hl7.fhir.r4.model.CodeSystem)

Aggregations

ArrayList (java.util.ArrayList)59 BooleanType (org.hl7.fhir.r5.model.BooleanType)38 BooleanType (org.hl7.fhir.r4.model.BooleanType)37 FHIRException (org.hl7.fhir.exceptions.FHIRException)33 BooleanType (org.hl7.fhir.r4b.model.BooleanType)27 BooleanType (org.hl7.fhir.dstu3.model.BooleanType)19 NotImplementedException (org.apache.commons.lang3.NotImplementedException)18 Base (org.hl7.fhir.r5.model.Base)17 Test (org.junit.Test)16 StringType (org.hl7.fhir.r4.model.StringType)15 Base (org.hl7.fhir.r4b.model.Base)15 BooleanType (org.hl7.fhir.dstu2016may.model.BooleanType)13 IOException (java.io.IOException)12 HashMap (java.util.HashMap)11 BooleanType (org.hl7.fhir.dstu2.model.BooleanType)11 Base (org.hl7.fhir.dstu2.model.Base)10 StringType (org.hl7.fhir.dstu3.model.StringType)10 StringType (org.hl7.fhir.r5.model.StringType)10 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)9 Coding (org.hl7.fhir.r4.model.Coding)9