Search in sources :

Example 16 with ParameterDefinition

use of org.hl7.fhir.r4b.model.ParameterDefinition in project quality-measure-and-cohort-service by Alvearie.

the class FHIRRestUtilsTest method testConstructAppropriateJsonRange.

@Test
public void testConstructAppropriateJsonRange() {
    ParameterDefinition definition = new ParameterDefinition();
    definition.setType("Range");
    Extension extension = new Extension();
    extension.setUrl("http://ibm.com/fhir/cdm/StructureDefinition/default-value");
    Range range = new Range();
    Quantity lowQuantity = new Quantity();
    lowQuantity.setUnit("year");
    lowQuantity.setValue(10);
    Quantity highQuantity = new Quantity();
    highQuantity.setUnit("year");
    highQuantity.setValue(100);
    range.setLow(lowQuantity);
    range.setHigh(highQuantity);
    extension.setValue(range);
    List<Extension> extensions = new ArrayList<>();
    extensions.add(extension);
    definition.setExtension(extensions);
    String defaultResult = FHIRRestUtils.complicatedTypeValueConstructor(definition);
    assertEquals("{\"low\":{\"value\":10,\"unit\":\"year\"},\"high\":{\"value\":100,\"unit\":\"year\"}}", defaultResult);
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) ArrayList(java.util.ArrayList) Quantity(org.hl7.fhir.r4.model.Quantity) Range(org.hl7.fhir.r4.model.Range) ParameterDefinition(org.hl7.fhir.r4.model.ParameterDefinition) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 17 with ParameterDefinition

use of org.hl7.fhir.r4b.model.ParameterDefinition in project quality-measure-and-cohort-service by Alvearie.

the class FHIRRestUtilsTest method testConstructAppropriateJsonQuantity.

@Test
public void testConstructAppropriateJsonQuantity() {
    ParameterDefinition definition = new ParameterDefinition();
    definition.setType("Quantity");
    Extension extension = new Extension();
    extension.setUrl("http://ibm.com/fhir/cdm/StructureDefinition/default-value");
    Quantity quantity = new Quantity();
    quantity.setUnit("year");
    quantity.setValue(10);
    extension.setValue(quantity);
    List<Extension> extensions = new ArrayList<>();
    extensions.add(extension);
    definition.setExtension(extensions);
    String defaultResult = FHIRRestUtils.complicatedTypeValueConstructor(definition);
    assertEquals("{\"value\":10,\"unit\":\"year\"}", defaultResult);
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) ArrayList(java.util.ArrayList) Quantity(org.hl7.fhir.r4.model.Quantity) ParameterDefinition(org.hl7.fhir.r4.model.ParameterDefinition) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 18 with ParameterDefinition

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

the class RdfParser method composeParameterDefinition.

protected void composeParameterDefinition(Complex parent, String parentType, String name, ParameterDefinition element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeElement(t, "ParameterDefinition", name, element, index);
    if (element.hasNameElement())
        composeCode(t, "ParameterDefinition", "name", element.getNameElement(), -1);
    if (element.hasUseElement())
        composeEnum(t, "ParameterDefinition", "use", element.getUseElement(), -1);
    if (element.hasMinElement())
        composeInteger(t, "ParameterDefinition", "min", element.getMinElement(), -1);
    if (element.hasMaxElement())
        composeString(t, "ParameterDefinition", "max", element.getMaxElement(), -1);
    if (element.hasDocumentationElement())
        composeString(t, "ParameterDefinition", "documentation", element.getDocumentationElement(), -1);
    if (element.hasTypeElement())
        composeCode(t, "ParameterDefinition", "type", element.getTypeElement(), -1);
    if (element.hasProfile())
        composeReference(t, "ParameterDefinition", "profile", element.getProfile(), -1);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Example 19 with ParameterDefinition

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

the class JsonParser method composeType.

protected void composeType(String prefix, Type type) throws IOException {
    if (type == null)
        ;
    else if (type instanceof Age)
        composeAge(prefix + "Age", (Age) type);
    else if (type instanceof Count)
        composeCount(prefix + "Count", (Count) type);
    else if (type instanceof Money)
        composeMoney(prefix + "Money", (Money) type);
    else if (type instanceof Distance)
        composeDistance(prefix + "Distance", (Distance) type);
    else if (type instanceof Duration)
        composeDuration(prefix + "Duration", (Duration) type);
    else if (type instanceof SimpleQuantity)
        composeSimpleQuantity(prefix + "SimpleQuantity", (SimpleQuantity) type);
    else if (type instanceof Period)
        composePeriod(prefix + "Period", (Period) type);
    else if (type instanceof Coding)
        composeCoding(prefix + "Coding", (Coding) type);
    else if (type instanceof Range)
        composeRange(prefix + "Range", (Range) type);
    else if (type instanceof Quantity)
        composeQuantity(prefix + "Quantity", (Quantity) type);
    else if (type instanceof Attachment)
        composeAttachment(prefix + "Attachment", (Attachment) type);
    else if (type instanceof Ratio)
        composeRatio(prefix + "Ratio", (Ratio) type);
    else if (type instanceof Annotation)
        composeAnnotation(prefix + "Annotation", (Annotation) type);
    else if (type instanceof SampledData)
        composeSampledData(prefix + "SampledData", (SampledData) type);
    else if (type instanceof Reference)
        composeReference(prefix + "Reference", (Reference) type);
    else if (type instanceof CodeableConcept)
        composeCodeableConcept(prefix + "CodeableConcept", (CodeableConcept) type);
    else if (type instanceof Identifier)
        composeIdentifier(prefix + "Identifier", (Identifier) type);
    else if (type instanceof Signature)
        composeSignature(prefix + "Signature", (Signature) type);
    else if (type instanceof TriggerDefinition)
        composeTriggerDefinition(prefix + "TriggerDefinition", (TriggerDefinition) type);
    else if (type instanceof ElementDefinition)
        composeElementDefinition(prefix + "ElementDefinition", (ElementDefinition) type);
    else if (type instanceof Timing)
        composeTiming(prefix + "Timing", (Timing) type);
    else if (type instanceof ModuleMetadata)
        composeModuleMetadata(prefix + "ModuleMetadata", (ModuleMetadata) type);
    else if (type instanceof ActionDefinition)
        composeActionDefinition(prefix + "ActionDefinition", (ActionDefinition) type);
    else if (type instanceof Address)
        composeAddress(prefix + "Address", (Address) type);
    else if (type instanceof HumanName)
        composeHumanName(prefix + "HumanName", (HumanName) type);
    else if (type instanceof DataRequirement)
        composeDataRequirement(prefix + "DataRequirement", (DataRequirement) type);
    else if (type instanceof Meta)
        composeMeta(prefix + "Meta", (Meta) type);
    else if (type instanceof ParameterDefinition)
        composeParameterDefinition(prefix + "ParameterDefinition", (ParameterDefinition) type);
    else if (type instanceof ContactPoint)
        composeContactPoint(prefix + "ContactPoint", (ContactPoint) type);
    else if (type instanceof MarkdownType) {
        composeMarkdownCore(prefix + "Markdown", (MarkdownType) type, false);
        composeMarkdownExtras(prefix + "Markdown", (MarkdownType) type, false);
    } else if (type instanceof UnsignedIntType) {
        composeUnsignedIntCore(prefix + "UnsignedInt", (UnsignedIntType) type, false);
        composeUnsignedIntExtras(prefix + "UnsignedInt", (UnsignedIntType) type, false);
    } else if (type instanceof CodeType) {
        composeCodeCore(prefix + "Code", (CodeType) type, false);
        composeCodeExtras(prefix + "Code", (CodeType) type, false);
    } else if (type instanceof IdType) {
        composeIdCore(prefix + "Id", (IdType) type, false);
        composeIdExtras(prefix + "Id", (IdType) type, false);
    } else if (type instanceof OidType) {
        composeOidCore(prefix + "Oid", (OidType) type, false);
        composeOidExtras(prefix + "Oid", (OidType) type, false);
    } else if (type instanceof PositiveIntType) {
        composePositiveIntCore(prefix + "PositiveInt", (PositiveIntType) type, false);
        composePositiveIntExtras(prefix + "PositiveInt", (PositiveIntType) type, false);
    } else if (type instanceof UuidType) {
        composeUuidCore(prefix + "Uuid", (UuidType) type, false);
        composeUuidExtras(prefix + "Uuid", (UuidType) type, false);
    } else if (type instanceof IntegerType) {
        composeIntegerCore(prefix + "Integer", (IntegerType) type, false);
        composeIntegerExtras(prefix + "Integer", (IntegerType) type, false);
    } else if (type instanceof DateTimeType) {
        composeDateTimeCore(prefix + "DateTime", (DateTimeType) type, false);
        composeDateTimeExtras(prefix + "DateTime", (DateTimeType) type, false);
    } else if (type instanceof DateType) {
        composeDateCore(prefix + "Date", (DateType) type, false);
        composeDateExtras(prefix + "Date", (DateType) type, false);
    } else if (type instanceof DecimalType) {
        composeDecimalCore(prefix + "Decimal", (DecimalType) type, false);
        composeDecimalExtras(prefix + "Decimal", (DecimalType) type, false);
    } else if (type instanceof UriType) {
        composeUriCore(prefix + "Uri", (UriType) type, false);
        composeUriExtras(prefix + "Uri", (UriType) 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 StringType) {
        composeStringCore(prefix + "String", (StringType) type, false);
        composeStringExtras(prefix + "String", (StringType) type, false);
    } else if (type instanceof BooleanType) {
        composeBooleanCore(prefix + "Boolean", (BooleanType) type, false);
        composeBooleanExtras(prefix + "Boolean", (BooleanType) type, false);
    } else if (type instanceof InstantType) {
        composeInstantCore(prefix + "Instant", (InstantType) type, false);
        composeInstantExtras(prefix + "Instant", (InstantType) type, false);
    } else
        throw new Error("Unhandled type");
}
Also used : FHIRFormatError(org.hl7.fhir.exceptions.FHIRFormatError)

Example 20 with ParameterDefinition

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

the class RdfParser method composeParameterDefinition.

protected void composeParameterDefinition(Complex parent, String parentType, String name, ParameterDefinition element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeElement(t, "ParameterDefinition", name, element, index);
    if (element.hasNameElement())
        composeCode(t, "ParameterDefinition", "name", element.getNameElement(), -1);
    if (element.hasUseElement())
        composeCode(t, "ParameterDefinition", "use", element.getUseElement(), -1);
    if (element.hasMinElement())
        composeInteger(t, "ParameterDefinition", "min", element.getMinElement(), -1);
    if (element.hasMaxElement())
        composeString(t, "ParameterDefinition", "max", element.getMaxElement(), -1);
    if (element.hasDocumentationElement())
        composeString(t, "ParameterDefinition", "documentation", element.getDocumentationElement(), -1);
    if (element.hasTypeElement())
        composeCode(t, "ParameterDefinition", "type", element.getTypeElement(), -1);
    if (element.hasProfile())
        composeReference(t, "ParameterDefinition", "profile", element.getProfile(), -1);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Aggregations

ParameterDefinition (org.hl7.fhir.r4.model.ParameterDefinition)32 Test (org.junit.Test)26 Extension (org.hl7.fhir.r4.model.Extension)14 DatetimeParameter (com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter)9 ArrayList (java.util.ArrayList)9 DateTimeType (org.hl7.fhir.r4.model.DateTimeType)9 QuantityParameter (com.ibm.cohort.cql.evaluation.parameters.QuantityParameter)8 StringParameter (com.ibm.cohort.cql.evaluation.parameters.StringParameter)8 Quantity (org.hl7.fhir.r4.model.Quantity)8 Range (org.hl7.fhir.r4.model.Range)8 CodeParameter (com.ibm.cohort.cql.evaluation.parameters.CodeParameter)7 IntervalParameter (com.ibm.cohort.cql.evaluation.parameters.IntervalParameter)7 Period (org.hl7.fhir.r4.model.Period)7 BooleanParameter (com.ibm.cohort.cql.evaluation.parameters.BooleanParameter)6 ConceptParameter (com.ibm.cohort.cql.evaluation.parameters.ConceptParameter)6 DateParameter (com.ibm.cohort.cql.evaluation.parameters.DateParameter)6 DecimalParameter (com.ibm.cohort.cql.evaluation.parameters.DecimalParameter)6 IntegerParameter (com.ibm.cohort.cql.evaluation.parameters.IntegerParameter)6 RatioParameter (com.ibm.cohort.cql.evaluation.parameters.RatioParameter)6 TimeParameter (com.ibm.cohort.cql.evaluation.parameters.TimeParameter)6