Search in sources :

Example 41 with ParameterDefinition

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

the class R4ParameterDefinitionWithDefaultToCohortParameterConverterTest method testCodeableConcept__shouldReturnConceptParameter.

@Test
public void testCodeableConcept__shouldReturnConceptParameter() {
    ParameterDefinition parameterDefinition = getBaseParameterDefinition("CodeableConcept");
    CodeableConcept fhirValue = new CodeableConcept();
    fhirValue.setText("plainText");
    fhirValue.addCoding(makeCoding("s1", "val1", "d1", "ver1"));
    fhirValue.addCoding(makeCoding("s2", "val2", "d2", "ver2"));
    parameterDefinition.addExtension(CDMConstants.PARAMETER_DEFAULT_URL, fhirValue);
    List<CodeParameter> expectedCodeParameters = new ArrayList<>();
    expectedCodeParameters.add(new CodeParameter().setSystem("s1").setValue("val1").setDisplay("d1").setVersion("ver1"));
    expectedCodeParameters.add(new CodeParameter().setSystem("s2").setValue("val2").setDisplay("d2").setVersion("ver2"));
    ConceptParameter expectedParameter = new ConceptParameter().setDisplay("plainText");
    expectedParameter.setCodes(expectedCodeParameters);
    assertEquals(expectedParameter, R4ParameterDefinitionWithDefaultToCohortParameterConverter.toCohortParameter(parameterDefinition));
}
Also used : ConceptParameter(com.ibm.cohort.cql.evaluation.parameters.ConceptParameter) ArrayList(java.util.ArrayList) CodeParameter(com.ibm.cohort.cql.evaluation.parameters.CodeParameter) ParameterDefinition(org.hl7.fhir.r4.model.ParameterDefinition) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.Test)

Example 42 with ParameterDefinition

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

the class R4ParameterDefinitionWithDefaultToCohortParameterConverterTest method testRatio__shouldReturnRatioParameter.

@Test
public void testRatio__shouldReturnRatioParameter() {
    ParameterDefinition parameterDefinition = getBaseParameterDefinition("Ratio");
    String denominatorString = "1.5";
    String numeratorString = "2.5";
    BigDecimal denominatorValue = new BigDecimal(denominatorString);
    BigDecimal numeratorValue = new BigDecimal(numeratorString);
    String unit = "ml";
    org.hl7.fhir.r4.model.Ratio fhirValue = new org.hl7.fhir.r4.model.Ratio().setDenominator(new org.hl7.fhir.r4.model.Quantity().setValue(denominatorValue).setUnit(unit)).setNumerator(new org.hl7.fhir.r4.model.Quantity().setValue(numeratorValue).setUnit(unit));
    parameterDefinition.addExtension(CDMConstants.PARAMETER_DEFAULT_URL, fhirValue);
    RatioParameter expectedParameter = new RatioParameter().setDenominator(new QuantityParameter().setUnit(unit).setAmount(denominatorString)).setNumerator(new QuantityParameter().setUnit(unit).setAmount(numeratorString));
    assertEquals(expectedParameter, R4ParameterDefinitionWithDefaultToCohortParameterConverter.toCohortParameter(parameterDefinition));
}
Also used : QuantityParameter(com.ibm.cohort.cql.evaluation.parameters.QuantityParameter) BigDecimal(java.math.BigDecimal) RatioParameter(com.ibm.cohort.cql.evaluation.parameters.RatioParameter) ParameterDefinition(org.hl7.fhir.r4.model.ParameterDefinition) Test(org.junit.Test)

Example 43 with ParameterDefinition

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

the class R4ParameterDefinitionWithDefaultToCohortParameterConverterTest method testQuantity__shouldReturnQuantityParameter.

@Test
public void testQuantity__shouldReturnQuantityParameter() {
    ParameterDefinition parameterDefinition = getBaseParameterDefinition("Quantity");
    String decimalString = "1.5";
    BigDecimal bigDecimalValue = new BigDecimal(decimalString);
    String unit = "ml";
    org.hl7.fhir.r4.model.Quantity fhirValue = new org.hl7.fhir.r4.model.Quantity();
    fhirValue.setUnit(unit);
    fhirValue.setValue(bigDecimalValue);
    parameterDefinition.addExtension(CDMConstants.PARAMETER_DEFAULT_URL, fhirValue);
    QuantityParameter expectedParameter = new QuantityParameter().setUnit(unit).setAmount(decimalString);
    assertEquals(expectedParameter, R4ParameterDefinitionWithDefaultToCohortParameterConverter.toCohortParameter(parameterDefinition));
}
Also used : QuantityParameter(com.ibm.cohort.cql.evaluation.parameters.QuantityParameter) BigDecimal(java.math.BigDecimal) ParameterDefinition(org.hl7.fhir.r4.model.ParameterDefinition) Test(org.junit.Test)

Example 44 with ParameterDefinition

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

the class R4ParameterDefinitionWithDefaultToCohortParameterConverterTest method testDateTimeWithTimezone__shouldReturnDatetimeParameter.

@Test
public void testDateTimeWithTimezone__shouldReturnDatetimeParameter() {
    ParameterDefinition parameterDefinition = getBaseParameterDefinition("dateTime");
    String dateString = "2020-01-01T00:00:00.0+04:00";
    DateTimeType fhirValue = new DateTimeType(dateString);
    parameterDefinition.addExtension(CDMConstants.PARAMETER_DEFAULT_URL, fhirValue);
    assertEquals(new DatetimeParameter(dateString), R4ParameterDefinitionWithDefaultToCohortParameterConverter.toCohortParameter(parameterDefinition));
}
Also used : DateTimeType(org.hl7.fhir.r4.model.DateTimeType) DatetimeParameter(com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter) ParameterDefinition(org.hl7.fhir.r4.model.ParameterDefinition) Test(org.junit.Test)

Example 45 with ParameterDefinition

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

the class R4ParameterDefinitionWithDefaultToCohortParameterConverterTest method testDateTimeNoTimezone__shouldReturnDatetimeParameter.

@Test
public void testDateTimeNoTimezone__shouldReturnDatetimeParameter() {
    ParameterDefinition parameterDefinition = getBaseParameterDefinition("dateTime");
    String dateString = "2020-01-01T00:00:00.0";
    DateTimeType fhirValue = new DateTimeType(dateString);
    parameterDefinition.addExtension(CDMConstants.PARAMETER_DEFAULT_URL, fhirValue);
    assertEquals(new DatetimeParameter("2020-01-01T00:00:00.0"), R4ParameterDefinitionWithDefaultToCohortParameterConverter.toCohortParameter(parameterDefinition));
}
Also used : DateTimeType(org.hl7.fhir.r4.model.DateTimeType) DatetimeParameter(com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter) ParameterDefinition(org.hl7.fhir.r4.model.ParameterDefinition) Test(org.junit.Test)

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