ca.uhn.hl7v2.model.Group Java Examples
The following examples show how to use
ca.uhn.hl7v2.model.Group.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExtractHL7Attributes.java From localization_nifi with Apache License 2.0 | 5 votes |
public static Map<String, String> getAttributes(final Group group, final boolean useNames, final boolean parseFields) throws HL7Exception { final Map<String, String> attributes = new TreeMap<>(); if (!isEmpty(group)) { for (final Map.Entry<String, Segment> segmentEntry : getAllSegments(group).entrySet()) { final String segmentKey = segmentEntry.getKey(); final Segment segment = segmentEntry.getValue(); final Map<String, Type> fields = getAllFields(segmentKey, segment, useNames); for (final Map.Entry<String, Type> fieldEntry : fields.entrySet()) { final String fieldKey = fieldEntry.getKey(); final Type field = fieldEntry.getValue(); // These maybe should used the escaped values, but that would // change the existing non-broken behavior of the processor if (parseFields && (field instanceof Composite) && !isTimestamp(field)) { for (final Map.Entry<String, Type> componentEntry : getAllComponents(fieldKey, field, useNames).entrySet()) { final String componentKey = componentEntry.getKey(); final Type component = componentEntry.getValue(); final String componentValue = HL7_ESCAPING.unescape(component.encode(), HL7_ENCODING); if (!StringUtils.isEmpty(componentValue)) { attributes.put(componentKey, componentValue); } } } else { final String fieldValue = HL7_ESCAPING.unescape(field.encode(), HL7_ENCODING); if (!StringUtils.isEmpty(fieldValue)) { attributes.put(fieldKey, fieldValue); } } } } } return attributes; }
Example #2
Source File: ExtractHL7Attributes.java From localization_nifi with Apache License 2.0 | 5 votes |
private static void addSegments(final Group group, final Map<String, Segment> segments, final Map<String, Integer> segmentIndexes) throws HL7Exception { if (!isEmpty(group)) { for (final String name : group.getNames()) { for (final Structure structure : group.getAll(name)) { if (group.isGroup(name) && structure instanceof Group) { addSegments((Group) structure, segments, segmentIndexes); } else if (structure instanceof Segment) { addSegments((Segment) structure, segments, segmentIndexes); } } segmentIndexes.put(name, segmentIndexes.getOrDefault(name, 1) + 1); } } }
Example #3
Source File: ExtractHL7Attributes.java From localization_nifi with Apache License 2.0 | 5 votes |
private static boolean isRepeating(final Segment segment) throws HL7Exception { if (isEmpty(segment)) { return false; } final Group parent = segment.getParent(); final Group grandparent = parent.getParent(); if (parent == grandparent) { return false; } return grandparent.isRepeating(parent.getName()); }
Example #4
Source File: ExtractHL7Attributes.java From nifi with Apache License 2.0 | 5 votes |
public static Map<String, String> getAttributes(final Group group, final boolean useNames, final boolean parseFields) throws HL7Exception { final Map<String, String> attributes = new TreeMap<>(); if (!isEmpty(group)) { for (final Map.Entry<String, Segment> segmentEntry : getAllSegments(group).entrySet()) { final String segmentKey = segmentEntry.getKey(); final Segment segment = segmentEntry.getValue(); final Map<String, Type> fields = getAllFields(segmentKey, segment, useNames); for (final Map.Entry<String, Type> fieldEntry : fields.entrySet()) { final String fieldKey = fieldEntry.getKey(); final Type field = fieldEntry.getValue(); // These maybe should used the escaped values, but that would // change the existing non-broken behavior of the processor if (parseFields && (field instanceof Composite) && !isTimestamp(field)) { for (final Map.Entry<String, Type> componentEntry : getAllComponents(fieldKey, field, useNames).entrySet()) { final String componentKey = componentEntry.getKey(); final Type component = componentEntry.getValue(); final String componentValue = HL7_ESCAPING.unescape(component.encode(), HL7_ENCODING); if (!StringUtils.isEmpty(componentValue)) { attributes.put(componentKey, componentValue); } } } else { final String fieldValue = HL7_ESCAPING.unescape(field.encode(), HL7_ENCODING); if (!StringUtils.isEmpty(fieldValue)) { attributes.put(fieldKey, fieldValue); } } } } } return attributes; }
Example #5
Source File: ExtractHL7Attributes.java From nifi with Apache License 2.0 | 5 votes |
private static void addSegments(final Group group, final Map<String, Segment> segments, final Map<String, Integer> segmentIndexes) throws HL7Exception { if (!isEmpty(group)) { for (final String name : group.getNames()) { for (final Structure structure : group.getAll(name)) { if (group.isGroup(name) && structure instanceof Group) { addSegments((Group) structure, segments, segmentIndexes); } else if (structure instanceof Segment) { addSegments((Segment) structure, segments, segmentIndexes); } } segmentIndexes.put(name, segmentIndexes.getOrDefault(name, 1) + 1); } } }
Example #6
Source File: ExtractHL7Attributes.java From nifi with Apache License 2.0 | 5 votes |
private static boolean isRepeating(final Segment segment) throws HL7Exception { if (isEmpty(segment)) { return false; } final Group parent = segment.getParent(); final Group grandparent = parent.getParent(); if (parent == grandparent) { return false; } return grandparent.isRepeating(parent.getName()); }
Example #7
Source File: ExtractHL7Attributes.java From localization_nifi with Apache License 2.0 | 4 votes |
private static Map<String, Segment> getAllSegments(final Group group) throws HL7Exception { final Map<String, Segment> segments = new TreeMap<>(); addSegments(group, segments, new HashMap<String, Integer>()); return Collections.unmodifiableMap(segments); }
Example #8
Source File: ExtractHL7Attributes.java From nifi with Apache License 2.0 | 4 votes |
private static Map<String, Segment> getAllSegments(final Group group) throws HL7Exception { final Map<String, Segment> segments = new TreeMap<>(); addSegments(group, segments, new HashMap<String, Integer>()); return Collections.unmodifiableMap(segments); }