diff --git a/nifi-nar-bundles/nifi-hl7-bundle/nifi-hl7-processors/pom.xml b/nifi-nar-bundles/nifi-hl7-bundle/nifi-hl7-processors/pom.xml
index d2daccc51a..b86d71d7e3 100644
--- a/nifi-nar-bundles/nifi-hl7-bundle/nifi-hl7-processors/pom.xml
+++ b/nifi-nar-bundles/nifi-hl7-bundle/nifi-hl7-processors/pom.xml
@@ -55,14 +55,17 @@
org.apache.nifi
nifi-hl7-query-language
- 1.2.0-SNAPSHOT
-
+
+ commons-beanutils
+ commons-beanutils
+ 1.9.2
+
ca.uhn.hapi
hapi-base
2.2
-
+
ca.uhn.hapi
hapi-structures-v21
@@ -103,7 +106,7 @@
hapi-structures-v26
2.2
-
+
org.apache.nifi
nifi-mock
diff --git a/nifi-nar-bundles/nifi-hl7-bundle/nifi-hl7-processors/src/main/java/org/apache/nifi/processors/hl7/ExtractHL7Attributes.java b/nifi-nar-bundles/nifi-hl7-bundle/nifi-hl7-processors/src/main/java/org/apache/nifi/processors/hl7/ExtractHL7Attributes.java
index 40a7cf929b..4ceb12eb39 100644
--- a/nifi-nar-bundles/nifi-hl7-bundle/nifi-hl7-processors/src/main/java/org/apache/nifi/processors/hl7/ExtractHL7Attributes.java
+++ b/nifi-nar-bundles/nifi-hl7-bundle/nifi-hl7-processors/src/main/java/org/apache/nifi/processors/hl7/ExtractHL7Attributes.java
@@ -27,7 +27,10 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.text.WordUtils;
@@ -218,7 +221,7 @@ public class ExtractHL7Attributes extends AbstractProcessor {
// 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 componentEntry : getAllComponents(fieldKey, field).entrySet()) {
+ for (final Map.Entry 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);
@@ -298,25 +301,50 @@ public class ExtractHL7Attributes extends AbstractProcessor {
return fields;
}
- private static Map getAllComponents(final String fieldKey, final Type field) throws HL7Exception {
+ private static Map getAllComponents(final String fieldKey, final Type field, final boolean useNames) throws HL7Exception {
final Map components = new TreeMap<>();
if (!isEmpty(field) && (field instanceof Composite)) {
- final Type[] types = ((Composite) field).getComponents();
- for (int i = 0; i < types.length; i++) {
- final Type type = types[i];
- if (!isEmpty(type)) {
- String fieldName = field.getName();
- if (fieldName.equals("CM_MSG")) {
- fieldName = "CM";
+ if (useNames) {
+ final Pattern p = Pattern.compile("^(cm_msg|[a-z][a-z][a-z]?)([0-9]+)_(\\w+)$");
+ try {
+ final java.beans.PropertyDescriptor[] properties = PropertyUtils.getPropertyDescriptors(field);
+ for (final java.beans.PropertyDescriptor property : properties) {
+ final String propertyName = property.getName();
+ final Matcher matcher = p.matcher(propertyName);
+ if (matcher.find()) {
+ final Type type = (Type) PropertyUtils.getProperty(field, propertyName);
+ if (!isEmpty(type)) {
+ final String componentName = matcher.group(3);
+ final String typeKey = new StringBuilder()
+ .append(fieldKey)
+ .append(".")
+ .append(componentName)
+ .toString();
+ components.put(typeKey, type);
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ } else {
+ final Type[] types = ((Composite) field).getComponents();
+ for (int i = 0; i < types.length; i++) {
+ final Type type = types[i];
+ if (!isEmpty(type)) {
+ String fieldName = field.getName();
+ if (fieldName.equals("CM_MSG")) {
+ fieldName = "CM";
+ }
+ final String typeKey = new StringBuilder()
+ .append(fieldKey)
+ .append(".")
+ .append(fieldName)
+ .append(".")
+ .append(i+1)
+ .toString();
+ components.put(typeKey, type);
}
- final String typeKey = new StringBuilder()
- .append(fieldKey)
- .append(".")
- .append(fieldName)
- .append(".")
- .append(i+1)
- .toString();
- components.put(typeKey, type);
}
}
}
diff --git a/nifi-nar-bundles/nifi-hl7-bundle/nifi-hl7-processors/src/test/java/org/apache/nifi/processors/hl7/TestExtractHL7Attributes.java b/nifi-nar-bundles/nifi-hl7-bundle/nifi-hl7-processors/src/test/java/org/apache/nifi/processors/hl7/TestExtractHL7Attributes.java
index 51ebf9652b..64517df15b 100644
--- a/nifi-nar-bundles/nifi-hl7-bundle/nifi-hl7-processors/src/test/java/org/apache/nifi/processors/hl7/TestExtractHL7Attributes.java
+++ b/nifi-nar-bundles/nifi-hl7-bundle/nifi-hl7-processors/src/test/java/org/apache/nifi/processors/hl7/TestExtractHL7Attributes.java
@@ -213,64 +213,64 @@ public class TestExtractHL7Attributes {
expectedAttributes.put("MSH.FieldSeparator", "|");
expectedAttributes.put("MSH.EncodingCharacters", "^~\\&");
- expectedAttributes.put("MSH.SendingApplication.HD.1", "XXXXXXXX");
- expectedAttributes.put("MSH.ReceivingApplication.HD.1", "HealthProvider");
- expectedAttributes.put("MSH.MessageType.CM.1", "ORU");
- expectedAttributes.put("MSH.MessageType.CM.2", "R01");
+ expectedAttributes.put("MSH.SendingApplication.NamespaceID", "XXXXXXXX");
+ expectedAttributes.put("MSH.ReceivingApplication.NamespaceID", "HealthProvider");
+ expectedAttributes.put("MSH.MessageType.MessageType", "ORU");
+ expectedAttributes.put("MSH.MessageType.TriggerEvent", "R01");
expectedAttributes.put("MSH.MessageControlID", "Q1111111111111111111");
- expectedAttributes.put("MSH.ProcessingID.PT.1", "P");
+ expectedAttributes.put("MSH.ProcessingID.ProcessingID", "P");
expectedAttributes.put("MSH.VersionID", "2.3");
expectedAttributes.put("ORC_1.OrderControl", "NW");
- expectedAttributes.put("ORC_1.PlacerOrderNumber.EI.1", "987654321");
- expectedAttributes.put("ORC_1.PlacerOrderNumber.EI.2", "EPC");
- expectedAttributes.put("ORC_1.FillerOrderNumber.EI.1", "123456789");
- expectedAttributes.put("ORC_1.FillerOrderNumber.EI.2", "EPC");
+ expectedAttributes.put("ORC_1.PlacerOrderNumber.EntityIdentifier", "987654321");
+ expectedAttributes.put("ORC_1.PlacerOrderNumber.NamespaceID", "EPC");
+ expectedAttributes.put("ORC_1.FillerOrderNumber.EntityIdentifier", "123456789");
+ expectedAttributes.put("ORC_1.FillerOrderNumber.NamespaceID", "EPC");
expectedAttributes.put("ORC_1.DateTimeOfTransaction", "20161003000000");
- expectedAttributes.put("ORC_1.OrderingProvider.XCN.1", "SMITH");
+ expectedAttributes.put("ORC_1.OrderingProvider.IDNumber", "SMITH");
expectedAttributes.put("OBR_1.SetIDObservationRequest", "1");
- expectedAttributes.put("OBR_1.PlacerOrderNumber.EI.1", "341856649");
- expectedAttributes.put("OBR_1.PlacerOrderNumber.EI.2", "HNAM_ORDERID");
- expectedAttributes.put("OBR_1.FillerOrderNumber.EI.1", "000000000000000000");
- expectedAttributes.put("OBR_1.UniversalServiceIdentifier.CE.1", "648088");
- expectedAttributes.put("OBR_1.UniversalServiceIdentifier.CE.2", "Basic Metabolic Panel");
+ expectedAttributes.put("OBR_1.PlacerOrderNumber.EntityIdentifier", "341856649");
+ expectedAttributes.put("OBR_1.PlacerOrderNumber.NamespaceID", "HNAM_ORDERID");
+ expectedAttributes.put("OBR_1.FillerOrderNumber.EntityIdentifier", "000000000000000000");
+ expectedAttributes.put("OBR_1.UniversalServiceIdentifier.Identifier", "648088");
+ expectedAttributes.put("OBR_1.UniversalServiceIdentifier.Text", "Basic Metabolic Panel");
expectedAttributes.put("OBR_1.ObservationDateTime", "20150101000000");
- expectedAttributes.put("OBR_1.OrderingProvider.XCN.1", "1620");
- expectedAttributes.put("OBR_1.OrderingProvider.XCN.2", "Johnson");
- expectedAttributes.put("OBR_1.OrderingProvider.XCN.3", "Corey");
- expectedAttributes.put("OBR_1.OrderingProvider.XCN.4", "A");
+ expectedAttributes.put("OBR_1.OrderingProvider.IDNumber", "1620");
+ expectedAttributes.put("OBR_1.OrderingProvider.FamilyName", "Johnson");
+ expectedAttributes.put("OBR_1.OrderingProvider.GivenName", "Corey");
+ expectedAttributes.put("OBR_1.OrderingProvider.MiddleInitialOrName", "A");
expectedAttributes.put("OBR_1.ResultsRptStatusChngDateTime", "20150101000000");
expectedAttributes.put("OBR_1.ResultStatus", "F");
expectedAttributes.put("OBR_1.ScheduledDateTime", "20150101000000");
expectedAttributes.put("OBX_1.SetIDOBX", "1");
expectedAttributes.put("OBX_1.ValueType", "NM");
- expectedAttributes.put("OBX_1.ObservationIdentifier.CE.1", "GLU");
- expectedAttributes.put("OBX_1.ObservationIdentifier.CE.2", "Glucose Lvl");
+ expectedAttributes.put("OBX_1.ObservationIdentifier.Identifier", "GLU");
+ expectedAttributes.put("OBX_1.ObservationIdentifier.Text", "Glucose Lvl");
expectedAttributes.put("OBX_1.ObservationSubID", "59");
expectedAttributes.put("OBX_1.ObservationValue", "mg/dL");
- expectedAttributes.put("OBX_1.Units.CE.1", "65-99");
- expectedAttributes.put("OBX_1.Units.CE.2", "65");
- expectedAttributes.put("OBX_1.Units.CE.3", "99");
+ expectedAttributes.put("OBX_1.Units.Identifier", "65-99");
+ expectedAttributes.put("OBX_1.Units.Text", "65");
+ expectedAttributes.put("OBX_1.Units.NameOfCodingSystem", "99");
expectedAttributes.put("OBX_1.ReferencesRange", "L");
expectedAttributes.put("OBX_1.NatureOfAbnormalTest", "F");
expectedAttributes.put("OBX_1.UserDefinedAccessChecks", "20150102000000");
- expectedAttributes.put("PD1.PatientPrimaryCareProviderNameIDNo.XCN.1", "1234567890");
- expectedAttributes.put("PD1.PatientPrimaryCareProviderNameIDNo.XCN.2", "LAST");
- expectedAttributes.put("PD1.PatientPrimaryCareProviderNameIDNo.XCN.3", "FIRST");
- expectedAttributes.put("PD1.PatientPrimaryCareProviderNameIDNo.XCN.4", "M");
- expectedAttributes.put("PD1.PatientPrimaryCareProviderNameIDNo.XCN.9", "NPI");
+ expectedAttributes.put("PD1.PatientPrimaryCareProviderNameIDNo.IDNumber", "1234567890");
+ expectedAttributes.put("PD1.PatientPrimaryCareProviderNameIDNo.FamilyName", "LAST");
+ expectedAttributes.put("PD1.PatientPrimaryCareProviderNameIDNo.GivenName", "FIRST");
+ expectedAttributes.put("PD1.PatientPrimaryCareProviderNameIDNo.MiddleInitialOrName", "M");
+ expectedAttributes.put("PD1.PatientPrimaryCareProviderNameIDNo.AssigningAuthority", "NPI");
- expectedAttributes.put("PID.PatientIDInternalID.CX.1", "12345");
- expectedAttributes.put("PID.PatientIDInternalID.CX.4", "XYZ");
- expectedAttributes.put("PID.PatientIDInternalID.CX.5", "MR");
- expectedAttributes.put("PID.PatientName.XPN.1", "SMITH");
- expectedAttributes.put("PID.PatientName.XPN.2", "JOHN");
+ expectedAttributes.put("PID.PatientIDInternalID.ID", "12345");
+ expectedAttributes.put("PID.PatientIDInternalID.AssigningAuthority", "XYZ");
+ expectedAttributes.put("PID.PatientIDInternalID.IdentifierTypeCode", "MR");
+ expectedAttributes.put("PID.PatientName.FamilyName", "SMITH");
+ expectedAttributes.put("PID.PatientName.GivenName", "JOHN");
expectedAttributes.put("PID.DateOfBirth", "19700100");
expectedAttributes.put("PID.Sex", "M");
- expectedAttributes.put("PID.PatientAccountNumber.CX.1", "111111111111");
+ expectedAttributes.put("PID.PatientAccountNumber.ID", "111111111111");
expectedAttributes.put("PID.SSNNumberPatient", "123456789");
runTests(message, expectedAttributes, true, true);
diff --git a/nifi-nar-bundles/nifi-hl7-bundle/pom.xml b/nifi-nar-bundles/nifi-hl7-bundle/pom.xml
index 4ee8cd67fd..a0b8cdfe9b 100644
--- a/nifi-nar-bundles/nifi-hl7-bundle/pom.xml
+++ b/nifi-nar-bundles/nifi-hl7-bundle/pom.xml
@@ -30,4 +30,19 @@
nifi-hl7-nar
+
+
+
+ org.apache.nifi
+ nifi-hl7-processors
+ 1.2.0-SNAPSHOT
+
+
+ org.apache.nifi
+ nifi-hl7-query-language
+ 1.2.0-SNAPSHOT
+
+
+
+