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;
}
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;
}
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());
}
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());
}
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());
}
Aggregations