@Test public void testBasic() throws Exception { String[] directives = new String[] { "parse-as-hl7 body", "keep body_hl7_MSH", }; List<Row> rows = Arrays.asList( new Row("body", adtA01), new Row("body", adt08), new Row("body", adt04), new Row("body", success), new Row("body", error), new Row("body", orders), new Row("body", results), new Row("body", nte) ); rows = TestingRig.execute(directives, rows); Assert.assertNotNull(rows); }
@Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { try { int idx = row.find(column); if (idx != -1) { Object object = row.getValue(idx); if (object == null) { throw new DirectiveExecutionException( NAME, String.format("Column '%s' has null value. It should be a non-null 'String'.", column) ); } if (object instanceof String) { Message message = parser.parse((String) object); HL7MessageVisitor visitor = new HL7MessageVisitor(row, column + "_hl7", depth); MessageVisitors.visit(message, MessageVisitors.visitPopulatedElements(visitor)).getDelegate(); } else { throw new DirectiveExecutionException( NAME, String.format("Column '%s' has invalid type '%s'. It should be of type 'String'.", column, object.getClass().getSimpleName()) ); } } } catch (HL7Exception e) { throw new DirectiveExecutionException(NAME, e.getMessage(), e); } } return rows; }
HL7Parser implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { try { int idx = row.find(column); if (idx != -1) { Object object = row.getValue(idx); if (object == null) { throw new DirectiveExecutionException( NAME, String.format("Column '%s' has null value. It should be a non-null 'String'.", column) ); } if (object instanceof String) { Message message = parser.parse((String) object); HL7MessageVisitor visitor = new HL7MessageVisitor(row, column + "_hl7", depth); MessageVisitors.visit(message, MessageVisitors.visitPopulatedElements(visitor)).getDelegate(); } else { throw new DirectiveExecutionException( NAME, String.format("Column '%s' has invalid type '%s'. It should be of type 'String'.", column, object.getClass().getSimpleName()) ); } } } catch (HL7Exception e) { throw new DirectiveExecutionException(NAME, e.getMessage(), e); } } return rows; } }
HL7Parser implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { try { int idx = row.find(column); if (idx != -1) { Object object = row.getValue(idx); if (object == null) { throw new DirectiveExecutionException( NAME, String.format("Column '%s' has null value. It should be a non-null 'String'.", column) ); } if (object instanceof String) { Message message = parser.parse((String) object); HL7MessageVisitor visitor = new HL7MessageVisitor(row, column + "_hl7", depth); MessageVisitors.visit(message, MessageVisitors.visitPopulatedElements(visitor)).getDelegate(); } else { throw new DirectiveExecutionException( NAME, String.format("Column '%s' has invalid type '%s'. It should be of type 'String'.", column, object.getClass().getSimpleName()) ); } } } catch (HL7Exception e) { throw new DirectiveExecutionException(NAME, e.getMessage(), e); } } return rows; }  }
HL7Parser implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { try { int idx = row.find(column); if (idx != -1) { Object object = row.getValue(idx); if (object == null) { throw new DirectiveExecutionException( NAME, String.format("Column '%s' has null value. It should be a non-null 'String'.", column) ); } if (object instanceof String) { Message message = parser.parse((String) object); HL7MessageVisitor visitor = new HL7MessageVisitor(row, column + "_hl7", depth); MessageVisitors.visit(message, MessageVisitors.visitPopulatedElements(visitor)).getDelegate(); } else { throw new DirectiveExecutionException( NAME, String.format("Column '%s' has invalid type '%s'. It should be of type 'String'.", column, object.getClass().getSimpleName()) ); } } } catch (HL7Exception e) { throw new DirectiveExecutionException(NAME, e.getMessage(), e); } } return rows; }  @Override UsageDefinition define(); @Override void initialize(Arguments args); @Override void destroy(); @Override Mutation lineage(); @Override List<Row> execute(List<Row> rows, ExecutorContext context); }
HL7Parser implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { try { int idx = row.find(column); if (idx != -1) { Object object = row.getValue(idx); if (object == null) { throw new DirectiveExecutionException( NAME, String.format("Column '%s' has null value. It should be a non-null 'String'.", column) ); } if (object instanceof String) { Message message = parser.parse((String) object); HL7MessageVisitor visitor = new HL7MessageVisitor(row, column + "_hl7", depth); MessageVisitors.visit(message, MessageVisitors.visitPopulatedElements(visitor)).getDelegate(); } else { throw new DirectiveExecutionException( NAME, String.format("Column '%s' has invalid type '%s'. It should be of type 'String'.", column, object.getClass().getSimpleName()) ); } } } catch (HL7Exception e) { throw new DirectiveExecutionException(NAME, e.getMessage(), e); } } return rows; }  @Override UsageDefinition define(); @Override void initialize(Arguments args); @Override void destroy(); @Override Mutation lineage(); @Override List<Row> execute(List<Row> rows, ExecutorContext context); static final String NAME; }