Search in sources :

Example 1 with HL7Segment

use of org.apache.nifi.hl7.model.HL7Segment in project nifi by apache.

the class HapiMessage method populateSegments.

private void populateSegments(final Group group, final List<HL7Segment> segments) throws HL7Exception {
    for (final String structureName : group.getNames()) {
        final Structure[] structures = group.getAll(structureName);
        if (group.isGroup(structureName)) {
            for (final Structure structure : structures) {
                populateSegments((Group) structure, segments);
            }
        } else {
            for (final Structure structure : structures) {
                final Segment segment = (Segment) structure;
                final HapiSegment hapiSegment = new HapiSegment(segment);
                segments.add(hapiSegment);
            }
        }
    }
}
Also used : Structure(ca.uhn.hl7v2.model.Structure) HL7Segment(org.apache.nifi.hl7.model.HL7Segment) Segment(ca.uhn.hl7v2.model.Segment)

Example 2 with HL7Segment

use of org.apache.nifi.hl7.model.HL7Segment 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 3 with HL7Segment

use of org.apache.nifi.hl7.model.HL7Segment in project nifi by apache.

the class SegmentEvaluator method evaluate.

public List<HL7Segment> evaluate(final Map<String, Object> objectMap) {
    final String segmentType = segmentTypeEvaluator.evaluate(objectMap);
    if (segmentType == null) {
        return Collections.emptyList();
    }
    final HL7Message message = (HL7Message) objectMap.get(Evaluator.MESSAGE_KEY);
    final List<HL7Segment> segments = message.getSegments(segmentType);
    return (segments == null) ? Collections.<HL7Segment>emptyList() : segments;
}
Also used : HL7Segment(org.apache.nifi.hl7.model.HL7Segment) HL7Message(org.apache.nifi.hl7.model.HL7Message)

Aggregations

HL7Segment (org.apache.nifi.hl7.model.HL7Segment)3 Segment (ca.uhn.hl7v2.model.Segment)1 Structure (ca.uhn.hl7v2.model.Structure)1 ArrayList (java.util.ArrayList)1 HL7Field (org.apache.nifi.hl7.model.HL7Field)1 HL7Message (org.apache.nifi.hl7.model.HL7Message)1