throw new UnsupportedOperationException("Not supported yet.");
}
public void parse(Message message, String string) throws HL7Exception {
//MessagePointer ptr = new MessagePointer(this, m, getEncodingChars(message));
MessageIterator messageIter = new MessageIterator(message, "MSH", true);
FilterIterator.Predicate<Structure> segmentsOnly = new FilterIterator.Predicate<Structure>() {
public boolean evaluate(Structure obj) {
if (Segment.class.isAssignableFrom(obj.getClass())) {
return true;
} else {
return false;
}
}
};
FilterIterator<Structure> segmentIter = new FilterIterator<Structure>(messageIter, segmentsOnly);
String[] segments = split(string, segDelim);
char delim = '|';
for (int i = 0; i < segments.length; i++) {
//get rid of any leading whitespace characters ...
if (segments[i] != null && segments[i].length() > 0 && Character.isWhitespace(segments[i].charAt(0)))
segments[i] = stripLeadingWhitespace(segments[i]);
//sometimes people put extra segment delimiters at end of msg ...
if (segments[i] != null && segments[i].length() >= 3) {
final String name;
if (i == 0) {
name = segments[i].substring(0, 3);
delim = segments[i].charAt(3);
} else {
if (segments[i].indexOf(delim) >= 0 ) {
name = segments[i].substring(0, segments[i].indexOf(delim));
} else {
name = segments[i];
}
}
log.debug("Parsing segment {}", name);
messageIter.setDirection(name);
FilterIterator.Predicate<Structure> byDirection = new FilterIterator.Predicate<Structure>() {
public boolean evaluate(Structure obj) {
Structure s = (Structure) obj;
log.debug("PipeParser iterating message in direction {} at {} ", name, s.getName());
return s.getName().matches(name + "\\d*");