Search in sources :

Example 1 with ClinicalDocument

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);
}
Also used : FlowFile(org.apache.nifi.flowfile.FlowFile) ProcessException(org.apache.nifi.processor.exception.ProcessException) ClinicalDocument(org.openhealthtools.mdht.uml.cda.ClinicalDocument) TreeMap(java.util.TreeMap) StopWatch(org.apache.nifi.util.StopWatch)

Aggregations

TreeMap (java.util.TreeMap)1 FlowFile (org.apache.nifi.flowfile.FlowFile)1 ProcessException (org.apache.nifi.processor.exception.ProcessException)1 StopWatch (org.apache.nifi.util.StopWatch)1 ClinicalDocument (org.openhealthtools.mdht.uml.cda.ClinicalDocument)1