Search in sources :

Example 11 with PrimitiveType

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

the class VersionConvertorPrimitiveType10_30Test method testNullValueDstu2Primitive.

@ParameterizedTest(name = "Testing dstu2 -> dstu3 conversion of null value {0}.")
@MethodSource("dstu2PrimitiveTypes")
public <T extends PrimitiveType> void testNullValueDstu2Primitive(String classname, T obj) {
    obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new StringType("A value"));
    Assertions.assertNull(((org.hl7.fhir.dstu3.model.PrimitiveType) VersionConvertorFactory_10_30.convertType(obj)).getValue());
}
Also used : StringType(org.hl7.fhir.dstu2.model.StringType) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 12 with PrimitiveType

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

the class VersionConvertorPrimitiveType10_50Test method testNullValueDstu2Primitive.

@ParameterizedTest(name = "Testing dstu2 -> r5 conversion of null value {0}.")
@MethodSource("dstu2PrimitiveTypes")
public <T extends PrimitiveType> void testNullValueDstu2Primitive(String classname, T obj) {
    obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new StringType("A value"));
    Assertions.assertNull(((org.hl7.fhir.r4.model.PrimitiveType) VersionConvertorFactory_10_40.convertType(obj)).getValue());
}
Also used : StringType(org.hl7.fhir.dstu2.model.StringType) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 13 with PrimitiveType

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

the class VersionConvertorPrimitiveType30_40Test method testNullValueDstu2Primitive.

@ParameterizedTest(name = "Testing dstu3 -> r4 conversion of null value {0}.")
@MethodSource("dstu3PrimitiveTypes")
public <T extends PrimitiveType> void testNullValueDstu2Primitive(String classname, T obj) {
    obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new StringType("A value"));
    Assertions.assertNull(((org.hl7.fhir.r4.model.PrimitiveType) VersionConvertorFactory_30_40.convertType(obj)).getValue());
}
Also used : StringType(org.hl7.fhir.dstu3.model.StringType) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 14 with PrimitiveType

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

the class PrimitiveType method equalsDeep.

@Override
public boolean equalsDeep(Base obj) {
    if (!super.equalsDeep(obj))
        return false;
    if (obj == null) {
        return false;
    }
    if (!(obj.getClass() == getClass())) {
        return false;
    }
    PrimitiveType<?> o = (PrimitiveType<?>) obj;
    EqualsBuilder b = new EqualsBuilder();
    b.append(getValue(), o.getValue());
    return b.isEquals();
}
Also used : IPrimitiveType(org.hl7.fhir.instance.model.api.IPrimitiveType) EqualsBuilder(org.apache.commons.lang3.builder.EqualsBuilder)

Example 15 with PrimitiveType

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

the class BaseWorkerContext method describeValidationParameters.

@SuppressWarnings("rawtypes")
private String describeValidationParameters(Parameters pin) {
    CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
    for (ParametersParameterComponent p : pin.getParameter()) {
        if (p.hasValue() && p.getValue() instanceof PrimitiveType) {
            b.append(p.getName() + "=" + ((PrimitiveType) p.getValue()).asStringValue());
        } else if (p.hasValue() && p.getValue() instanceof Coding) {
            b.append("system=" + ((Coding) p.getValue()).getSystem());
            b.append("code=" + ((Coding) p.getValue()).getCode());
            b.append("display=" + ((Coding) p.getValue()).getDisplay());
        } else if (p.hasValue() && p.getValue() instanceof CodeableConcept) {
            if (((CodeableConcept) p.getValue()).hasCoding()) {
                Coding c = ((CodeableConcept) p.getValue()).getCodingFirstRep();
                b.append("system=" + c.getSystem());
                b.append("code=" + c.getCode());
                b.append("display=" + c.getDisplay());
            } else if (((CodeableConcept) p.getValue()).hasText()) {
                b.append("text=" + ((CodeableConcept) p.getValue()).getText());
            }
        } else if (p.hasResource() && (p.getResource() instanceof ValueSet)) {
            b.append("valueset=" + getVSSummary((ValueSet) p.getResource()));
        }
    }
    return b.toString();
}
Also used : Coding(org.hl7.fhir.dstu3.model.Coding) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) PrimitiveType(org.hl7.fhir.dstu3.model.PrimitiveType) ValueSet(org.hl7.fhir.dstu3.model.ValueSet) ParametersParameterComponent(org.hl7.fhir.dstu3.model.Parameters.ParametersParameterComponent) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Aggregations

FHIRException (org.hl7.fhir.exceptions.FHIRException)18 EqualsBuilder (org.apache.commons.lang3.builder.EqualsBuilder)12 IPrimitiveType (org.hl7.fhir.instance.model.api.IPrimitiveType)12 IOException (java.io.IOException)10 NotImplementedException (org.apache.commons.lang3.NotImplementedException)10 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)9 MethodSource (org.junit.jupiter.params.provider.MethodSource)9 PrimitiveType (org.hl7.fhir.r5.model.PrimitiveType)8 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)8 URISyntaxException (java.net.URISyntaxException)6 PrimitiveType (org.hl7.fhir.definitions.model.PrimitiveType)6 FileNotFoundException (java.io.FileNotFoundException)5 ArrayList (java.util.ArrayList)5 PrimitiveType (org.hl7.fhir.dstu3.model.PrimitiveType)5 PrimitiveType (org.hl7.fhir.r4b.model.PrimitiveType)5 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)5 URI (java.net.URI)4 ElementDefn (org.hl7.fhir.definitions.model.ElementDefn)4 StringType (org.hl7.fhir.dstu3.model.StringType)4 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)3