[ 
https://issues.apache.org/jira/browse/NIFI-3147?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15878453#comment-15878453
 ] 

ASF GitHub Bot commented on NIFI-3147:
--------------------------------------

Github user jfrazee commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1312#discussion_r102486824
  
    --- Diff: 
nifi-nar-bundles/nifi-ccda-bundle/nifi-ccda-processors/src/main/java/org/apache/nifi/processors/ccda/ExtractCCDAAttributes.java
 ---
    @@ -0,0 +1,383 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.nifi.processors.ccda;
    +
    +import java.io.IOException;
    +import java.io.InputStream;
    +import java.io.OutputStream;
    +import java.util.ArrayList;
    +import java.util.HashMap;
    +import java.util.HashSet;
    +import java.util.LinkedHashMap;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.Map.Entry;
    +import java.util.Properties;
    +import java.util.Set;
    +import java.util.TreeMap;
    +
    +import org.apache.commons.jexl3.JexlBuilder;
    +import org.apache.commons.jexl3.JexlContext;
    +import org.apache.commons.jexl3.JexlEngine;
    +import org.apache.commons.jexl3.JexlExpression;
    +import org.apache.commons.jexl3.MapContext;
    +import org.apache.commons.lang3.StringUtils;
    +import org.apache.nifi.annotation.behavior.InputRequirement;
    +import org.apache.nifi.annotation.behavior.InputRequirement.Requirement;
    +import org.apache.nifi.annotation.behavior.SideEffectFree;
    +import org.apache.nifi.annotation.behavior.SupportsBatching;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.flowfile.FlowFile;
    +import org.apache.nifi.flowfile.attributes.CoreAttributes;
    +import org.apache.nifi.processor.AbstractProcessor;
    +import org.apache.nifi.processor.ProcessContext;
    +import org.apache.nifi.processor.ProcessSession;
    +import org.apache.nifi.processor.ProcessorInitializationContext;
    +import org.apache.nifi.processor.Relationship;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.io.OutputStreamCallback;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.eclipse.emf.common.util.Diagnostic;
    +import org.openhealthtools.mdht.uml.cda.CDAPackage;
    +import org.openhealthtools.mdht.uml.cda.ClinicalDocument;
    +import org.openhealthtools.mdht.uml.cda.ccd.CCDPackage;
    +import org.openhealthtools.mdht.uml.cda.consol.ConsolPackage;
    +import org.openhealthtools.mdht.uml.cda.hitsp.HITSPPackage;
    +import org.openhealthtools.mdht.uml.cda.ihe.IHEPackage;
    +import org.openhealthtools.mdht.uml.cda.util.CDAUtil;
    +import org.openhealthtools.mdht.uml.cda.util.CDAUtil.ValidationHandler;
    +
    +import com.google.gson.Gson;
    +import com.google.gson.GsonBuilder;
    +
    +@SideEffectFree
    +@SupportsBatching
    +@InputRequirement(Requirement.INPUT_REQUIRED)
    +@Tags({"CCDA", "healthcare", "extract", "JSON", "attributes"})
    +@CapabilityDescription("Extracts information from an Consolidated CDA 
formatted FlowFile and provides JSON as FlowFile content "
    +        + "and individual attributes as FlowFile attributes. The 
attributes are named as <Parent> <dot> <Key>. "
    +        + "If the Parent is repeating, the naming will be <Parent> 
<underscore> <Parent Index> <dot> <Key>. "
    +        + "For example, section.act_07.observation.name=Essential 
hypertension")
    +public class ExtractCCDAAttributes extends AbstractProcessor {
    +
    +    private static final String APPLICATION_JSON = "application/json";
    +    private static final char FIELD_SEPARATOR = '@';
    +    private static final char KEY_VALUE_SEPARATOR = '#';
    +
    +    private Map<String, Map<String, String>> processMap = new 
LinkedHashMap<String, Map<String, String>>(); // stores mapping data for Parser
    +    private List<String> timingStats = new ArrayList<String>(); // stores 
timing statistics
    +    private Map<String, String> attributes = new TreeMap<String, 
String>(); // stores CDA attributes
    --- End diff --
    
    This should be local to onTrigger(). I know you're using it in addElement() 
but as long as you pass it into addElement()  you can mutate it or change 
addElement() to have it as a return value you'll be good.


> Build processor to parse CCDA into attributes and JSON
> ------------------------------------------------------
>
>                 Key: NIFI-3147
>                 URL: https://issues.apache.org/jira/browse/NIFI-3147
>             Project: Apache NiFi
>          Issue Type: New Feature
>          Components: Extensions
>            Reporter: Kedar Chitale
>              Labels: attributes, ccda, healthcare, json, parser
>   Original Estimate: 336h
>  Remaining Estimate: 336h
>
> Accept a CCDA document, Parse the document to create JSON text and individual 
> attributes for example code.codeSystemName=LOINC



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to