use of org.openhealthtools.mdht.uml.cda.ClinicalDocument in project nifi by apache.
the class ExtractCCDAAttributes method onTrigger.
@Override
public void onTrigger(final ProcessContext context, final ProcessSession session) {
// stores CDA attributes
Map<String, String> attributes = new TreeMap<String, String>();
getLogger().info("Processing CCDA");
FlowFile flowFile = session.get();
if (flowFile == null) {
return;
}
if (processMap.isEmpty()) {
getLogger().error("Process Mapping is not loaded");
session.transfer(flowFile, REL_FAILURE);
return;
}
final Boolean skipValidation = context.getProperty(SKIP_VALIDATION).asBoolean();
final StopWatch stopWatch = new StopWatch(true);
ClinicalDocument cd = null;
try {
// Load and optionally validate CDA document
cd = loadDocument(session.read(flowFile), skipValidation);
} catch (ProcessException e) {
session.transfer(flowFile, REL_FAILURE);
return;
}
getLogger().debug("Loaded document for {} in {}", new Object[] { flowFile, stopWatch.getElapsed(TimeUnit.MILLISECONDS) });
getLogger().debug("Processing elements");
// Process CDA element using mapping data
processElement(null, cd, attributes);
flowFile = session.putAllAttributes(flowFile, attributes);
stopWatch.stop();
getLogger().debug("Successfully processed {} in {}", new Object[] { flowFile, stopWatch.getDuration(TimeUnit.MILLISECONDS) });
if (getLogger().isDebugEnabled()) {
for (Entry<String, String> entry : attributes.entrySet()) {
getLogger().debug("Attribute: {}={}", new Object[] { entry.getKey(), entry.getValue() });
}
}
session.transfer(flowFile, REL_SUCCESS);
}
Aggregations