Search in sources :

Example 1 with HL7Field

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;
}
Also used : HL7Field(org.apache.nifi.hl7.model.HL7Field) HL7Segment(org.apache.nifi.hl7.model.HL7Segment) ArrayList(java.util.ArrayList)

Example 2 with HL7Field

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());
}
Also used : HL7Field(org.apache.nifi.hl7.model.HL7Field) HL7Message(org.apache.nifi.hl7.model.HL7Message) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)2 HL7Field (org.apache.nifi.hl7.model.HL7Field)2 List (java.util.List)1 HL7Message (org.apache.nifi.hl7.model.HL7Message)1 HL7Segment (org.apache.nifi.hl7.model.HL7Segment)1 Test (org.junit.Test)1