use of org.hl7.fhir.dstu3.model.Condition in project bunsen by cerner.
the class BroadcastableMappings method broadcast.
/**
* Broadcast mappings stored in the given conceptMaps instance that match the given
* conceptMapUris.
*
* @param conceptMaps the {@link ConceptMaps} instance with the content to broadcast
* @param conceptMapUriToVersion map of the concept map URIs to broadcast to their versions.
* @return a broadcast variable containing a mappings object usable in UDFs.
*/
public static Broadcast<BroadcastableMappings> broadcast(ConceptMaps conceptMaps, Map<String, String> conceptMapUriToVersion) {
Map<String, ConceptMap> mapsToLoad = conceptMaps.getMaps().collectAsList().stream().filter(conceptMap -> conceptMap.getVersion().equals(conceptMapUriToVersion.get(conceptMap.getUrl()))).collect(Collectors.toMap(ConceptMap::getUrl, Function.identity()));
// Expand the concept maps to load and sort them so dependencies are before
// their dependents in the list.
List<String> sortedMapsToLoad = sortMapsToLoad(conceptMapUriToVersion.keySet(), mapsToLoad);
// Since this is used to map from one system to another, we use only targets
// that don't introduce inaccurate meanings. (For instance, we can't map
// general condition code to a more specific type, since that is not
// representative of the source data.)
Dataset<Mapping> mappings = conceptMaps.getMappings(conceptMapUriToVersion).filter("equivalence in ('equivalent', 'equals', 'wider', 'subsumes')");
// Group mappings by their concept map URI
Map<String, List<Mapping>> groupedMappings = mappings.collectAsList().stream().collect(Collectors.groupingBy(Mapping::getConceptMapUri));
Map<String, BroadcastableConceptMap> broadcastableMaps = new HashMap<>();
for (String conceptMapUri : sortedMapsToLoad) {
ConceptMap map = mapsToLoad.get(conceptMapUri);
Set<String> children = getMapChildren(map);
List<BroadcastableConceptMap> childMaps = children.stream().map(child -> broadcastableMaps.get(child)).collect(Collectors.toList());
BroadcastableConceptMap broadcastableConceptMap = new BroadcastableConceptMap(conceptMapUri, groupedMappings.getOrDefault(conceptMapUri, Collections.emptyList()), childMaps);
broadcastableMaps.put(conceptMapUri, broadcastableConceptMap);
}
JavaSparkContext ctx = new JavaSparkContext(conceptMaps.getMaps().sparkSession().sparkContext());
return ctx.broadcast(new BroadcastableMappings(broadcastableMaps));
}
use of org.hl7.fhir.dstu3.model.Condition in project jcabi-dynamo by jcabi.
the class ConditionsTest method workAsMapOfConditions.
/**
* Conditions can work as a map of conditions.
* @throws Exception If some problem inside
*/
@Test
public void workAsMapOfConditions() throws Exception {
final String name = "id";
final Condition condition = new Condition();
final Map<String, Condition> conds = new Conditions().with(name, condition);
MatcherAssert.assertThat(conds.keySet(), Matchers.hasSize(1));
MatcherAssert.assertThat(conds, Matchers.hasEntry(name, condition));
MatcherAssert.assertThat(new Conditions(conds), Matchers.hasEntry(name, condition));
}
use of org.hl7.fhir.dstu3.model.Condition in project jcabi-dynamo by jcabi.
the class H2Data method iterate.
@Override
public Iterable<Attributes> iterate(final String table, final Conditions conds) throws IOException {
try {
final StringBuilder sql = new StringBuilder("SELECT * FROM ").append(H2Data.encodeTableName(table));
if (!conds.isEmpty()) {
sql.append(" WHERE ");
Joiner.on(H2Data.AND).appendTo(sql, Iterables.transform(conds.keySet(), H2Data.WHERE));
}
JdbcSession session = new JdbcSession(this.connection()).sql(sql.toString());
for (final Condition cond : conds.values()) {
if (cond.getAttributeValueList().size() != 1) {
throw new UnsupportedOperationException("at the moment only one value of condition is supported");
}
if (!cond.getComparisonOperator().equals(ComparisonOperator.EQ.toString())) {
throw new UnsupportedOperationException(String.format("at the moment only EQ operator is supported: %s", cond.getComparisonOperator()));
}
final AttributeValue val = cond.getAttributeValueList().get(0);
session = session.set(H2Data.value(val));
}
return session.select(H2Data.OUTCOME);
} catch (final SQLException ex) {
throw new IOException(ex);
}
}
use of org.hl7.fhir.dstu3.model.Condition in project aws-doc-sdk-examples by awsdocs.
the class DynamoDBDynamicFaultInjection method main.
public static void main(String[] args) throws Exception {
init();
try {
// Create a table with a primary key named 'name', which holds a
// string
createTable();
// Describe our new table
describeTable();
// Add some items
putItem(newItem("Bill & Ted's Excellent Adventure", 1989, "****", "James", "Sara"));
putItem(newItem("Airplane", 1980, "*****", "James", "Billy Bob"));
// Get some items
getItem("Airplane");
getItem("Bill & Ted's Excellent Adventure");
// Scan items for movies with a year attribute greater than 1985
Map<String, Condition> scanFilter = new HashMap<String, Condition>();
Condition condition = new Condition().withComparisonOperator(ComparisonOperator.GT.toString()).withAttributeValueList(new AttributeValue().withN("1985"));
scanFilter.put("year", condition);
ScanRequest scanRequest = new ScanRequest(TABLENAME).withScanFilter(scanFilter);
ScanResult scanResult = dynamoDBClient.scan(scanRequest);
logger.info("Result: " + scanResult);
} catch (AmazonServiceException ase) {
logger.error("Service Exception: " + ase);
} catch (AmazonClientException ace) {
logger.error("Client Exception: " + ace);
}
}
use of org.hl7.fhir.dstu3.model.Condition in project aws-doc-sdk-examples by awsdocs.
the class LowLevelQuery method makeReplyKeyConditions.
/**
* A simple helper function that returns a KeyCondition map filled in with
* the partition key equality condition for a the Reply example table, given
* a forumName and threadSubject.
*/
private static Map<String, Condition> makeReplyKeyConditions(String forumName, String threadSubject) {
String replyId = forumName + "#" + threadSubject;
Condition partitionKeyCondition = new Condition().withComparisonOperator(ComparisonOperator.EQ).withAttributeValueList(new AttributeValue().withS(replyId));
Map<String, Condition> keyConditions = new HashMap<String, Condition>();
keyConditions.put("Id", partitionKeyCondition);
return keyConditions;
}
Aggregations