use of org.apache.nifi.hl7.model.HL7Field in project nifi by apache.
the class FieldEvaluator method evaluate.
public List<HL7Field> evaluate(final Map<String, Object> objectMap) {
final List<HL7Segment> segments = segmentEvaluator.evaluate(objectMap);
if (segments == null) {
return Collections.emptyList();
}
final Integer index = indexEvaluator.evaluate(objectMap);
if (index == null) {
return Collections.emptyList();
}
final List<HL7Field> fields = new ArrayList<>();
for (final HL7Segment segment : segments) {
final List<HL7Field> segmentFields = segment.getFields();
if (segmentFields.size() <= index) {
continue;
}
fields.add(segmentFields.get(index));
}
return fields;
}
use of org.apache.nifi.hl7.model.HL7Field in project nifi by apache.
the class TestHL7Query method testSelectField.
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testSelectField() throws HL7Exception, IOException {
final HL7Query query = HL7Query.compile("SELECT PID.5");
final HL7Message msg = hypoglycemia;
final QueryResult result = query.evaluate(msg);
assertTrue(result.isMatch());
final List<String> labels = result.getLabels();
assertEquals(1, labels.size());
assertEquals(1, result.getHitCount());
final Object names = result.nextHit().getValue("PID.5");
assertTrue(names instanceof List);
final List<Object> nameList = (List) names;
assertEquals(1, nameList.size());
final HL7Field nameField = (HL7Field) nameList.get(0);
assertEquals("SMITH^JOHN", nameField.getValue());
}
Aggregations