Search in sources :

Example 1 with Condition

use of org.hl7.fhir.dstu3.model.Condition in project openhab1-addons by openhab.

the class DynamoDBPersistenceService method constructTimeCondition.

private Condition constructTimeCondition(FilterCriteria filter) {
    boolean hasBegin = filter.getBeginDate() != null;
    boolean hasEnd = filter.getEndDate() != null;
    final Condition timeCondition;
    if (!hasBegin && !hasEnd) {
        timeCondition = null;
    } else if (!hasBegin && hasEnd) {
        timeCondition = new Condition().withComparisonOperator(ComparisonOperator.LE).withAttributeValueList(new AttributeValue().withS(AbstractDynamoDBItem.DATEFORMATTER.format(filter.getEndDate())));
    } else if (hasBegin && !hasEnd) {
        timeCondition = new Condition().withComparisonOperator(ComparisonOperator.GE).withAttributeValueList(new AttributeValue().withS(AbstractDynamoDBItem.DATEFORMATTER.format(filter.getBeginDate())));
    } else {
        timeCondition = new Condition().withComparisonOperator(ComparisonOperator.BETWEEN).withAttributeValueList(new AttributeValue().withS(AbstractDynamoDBItem.DATEFORMATTER.format(filter.getBeginDate())), new AttributeValue().withS(AbstractDynamoDBItem.DATEFORMATTER.format(filter.getEndDate())));
    }
    return timeCondition;
}
Also used : Condition(com.amazonaws.services.dynamodbv2.model.Condition) AttributeValue(com.amazonaws.services.dynamodbv2.model.AttributeValue)

Example 2 with Condition

use of org.hl7.fhir.dstu3.model.Condition in project openhab1-addons by openhab.

the class DynamoDBPersistenceService method createQueryExpression.

/**
     * Construct dynamodb query from filter
     *
     * @param filter
     * @return DynamoDBQueryExpression corresponding to the given FilterCriteria
     */
private DynamoDBQueryExpression<DynamoDBItem<?>> createQueryExpression(Class<? extends DynamoDBItem<?>> dtoClass, FilterCriteria filter) {
    DynamoDBItem<?> item = getDynamoDBHashKey(dtoClass, filter.getItemName());
    final DynamoDBQueryExpression<DynamoDBItem<?>> queryExpression = new DynamoDBQueryExpression<DynamoDBItem<?>>().withHashKeyValues(item).withScanIndexForward(filter.getOrdering() == Ordering.ASCENDING).withLimit(filter.getPageSize());
    Condition timeFilter = maybeAddTimeFilter(queryExpression, filter);
    maybeAddStateFilter(filter, queryExpression);
    logger.debug("Querying: {} with {}", filter.getItemName(), timeFilter);
    return queryExpression;
}
Also used : Condition(com.amazonaws.services.dynamodbv2.model.Condition)

Example 3 with Condition

use of org.hl7.fhir.dstu3.model.Condition in project bunsen by cerner.

the class FhirEncodersTest method testFromRdd.

@Test
public void testFromRdd() {
    JavaSparkContext context = new JavaSparkContext(spark.sparkContext());
    JavaRDD<Condition> conditionRdd = context.parallelize(ImmutableList.of(condition));
    Dataset<Condition> ds = spark.createDataset(conditionRdd.rdd(), encoders.of(Condition.class));
    Condition convertedCondition = ds.head();
    Assert.assertEquals(condition.getId(), convertedCondition.getId());
}
Also used : Condition(org.hl7.fhir.dstu3.model.Condition) JavaSparkContext(org.apache.spark.api.java.JavaSparkContext) Test(org.junit.Test)

Example 4 with Condition

use of org.hl7.fhir.dstu3.model.Condition in project bunsen by cerner.

the class FunctionsTest method resourceToJson.

@Test
public void resourceToJson() {
    Dataset<String> jsonDs = Functions.toJson(conditions, "condition");
    String conditionJson = jsonDs.first();
    Condition parsedCondition = (Condition) CONTEXT.newJsonParser().parseResource(conditionJson);
    Assert.assertEquals(condition.getId(), parsedCondition.getId());
}
Also used : Condition(org.hl7.fhir.dstu3.model.Condition) Test(org.junit.Test)

Example 5 with Condition

use of org.hl7.fhir.dstu3.model.Condition in project bunsen by cerner.

the class FunctionsTest method bundleToJson.

@Test
public void bundleToJson() {
    String jsonBundle = Functions.toJsonBundle(conditions);
    Bundle bundle = (Bundle) CONTEXT.newJsonParser().parseResource(jsonBundle);
    Condition parsedCondition = (Condition) bundle.getEntryFirstRep().getResource();
    Assert.assertEquals(condition.getId(), parsedCondition.getId());
}
Also used : Condition(org.hl7.fhir.dstu3.model.Condition) Bundle(org.hl7.fhir.dstu3.model.Bundle) Test(org.junit.Test)

Aggregations

Condition (com.amazonaws.services.dynamodbv2.model.Condition)16 AttributeValue (com.amazonaws.services.dynamodbv2.model.AttributeValue)14 HashMap (java.util.HashMap)9 Condition (org.hl7.fhir.dstu3.model.Condition)7 Test (org.junit.Test)7 QueryRequest (com.amazonaws.services.dynamodbv2.model.QueryRequest)6 QueryResult (com.amazonaws.services.dynamodbv2.model.QueryResult)6 Map (java.util.Map)5 DynamoDBScanExpression (com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBScanExpression)2 ComparisonOperator (com.amazonaws.services.dynamodbv2.model.ComparisonOperator)2 ConsumedCapacity (com.amazonaws.services.dynamodbv2.model.ConsumedCapacity)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 JavaSparkContext (org.apache.spark.api.java.JavaSparkContext)2 IdDt (ca.uhn.fhir.model.primitive.IdDt)1 MethodOutcome (ca.uhn.fhir.rest.api.MethodOutcome)1 AmazonClientException (com.amazonaws.AmazonClientException)1 AmazonServiceException (com.amazonaws.AmazonServiceException)1 ScanRequest (com.amazonaws.services.dynamodbv2.model.ScanRequest)1 ScanResult (com.amazonaws.services.dynamodbv2.model.ScanResult)1