lib/cmsTxtToIntObj.js
function processClaimsLineChild(objectString) {
    var claimLineObj = {};
    var obj = {};
    var objArray = [];
    var keyValuePairRegExp = /(\n){1,}[\S\s,]+?(:)[\S\s]+?(?=((\n){1,})|$)/gi;
    var keyValuePairArray = objectString.match(keyValuePairRegExp);

    //unusual steps are required to parse meta data and claims summary
    for (var s = 0; s < keyValuePairArray.length; s++) {
        //clean up the key value pair
        var keyValuePairString = trimStringEnds(keyValuePairArray[s], ['\n']);
        //split each string by the :, the result is an array of size two
        var keyValuePair = keyValuePairString.split(/:(.*)/);
        var key = removeUnwantedCharacters(keyValuePair[0].trim(), ['\n', '-']);
        key = key.toLowerCase();
        var value = keyValuePair[1].trim();

        var claimLineCheckRegExp = /claim lines/i;
        if (claimLineCheckRegExp.test(key)) {
            claimLineObj.claimNumber = value;
            continue;
        }

        if (value.length === 0) {
            value = null;
        }
        //create a new object for line number
        if (key in obj) {
            objArray.push(obj);
            obj = {};
        }
        obj[key] = value;
    }
    objArray.push(obj);
    claimLineObj.data = objArray;
    return claimLineObj;
}
function processClaimsLineChild(objectString) {
    var claimLineObj = {};
    var obj = {};
    var objArray = [];
    var keyValuePairRegExp = /(\n){1,}[\S\s,]+?(:)[\S\s]+?(?=((\n){1,})|$)/gi;
    var keyValuePairArray = objectString.match(keyValuePairRegExp);

    //unusual steps are required to parse meta data and claims summary
    for (var s = 0; s < keyValuePairArray.length; s++) {
        //clean up the key value pair
        var keyValuePairString = trimStringEnds(keyValuePairArray[s], ['\n']);
        //split each string by the :, the result is an array of size two
        var keyValuePair = keyValuePairString.split(/:(.*)/);
        var key = removeUnwantedCharacters(keyValuePair[0].trim(), ['\n', '-']);
        key = key.toLowerCase();
        var value = keyValuePair[1].trim();

        var claimLineCheckRegExp = /claim lines/i;
        if (claimLineCheckRegExp.test(key)) {
            claimLineObj.claimNumber = value;
            continue;
        }

        if (value.length === 0) {
            value = null;
        }
        //create a new object for line number
        if (key in obj) {
            objArray.push(obj);
            obj = {};
        }
        obj[key] = value;
    }
    objArray.push(obj);
    claimLineObj.data = objArray;
    return claimLineObj;
}
function processClaimsLineChild ( objectString ) { var claimLineObj = { } ; var obj = { } ; var objArray = [ ] ; var keyValuePairRegExp = / (\n){1,}[\S\s,]+?(:)[\S\s]+?(?=((\n){1,})|$) / gi ; var keyValuePairArray = objectString . match ( keyValuePairRegExp ) ; //unusual steps are required to parse meta data and claims summary for ( var s = 0 ; s < keyValuePairArray . length ; s ++ ) { //clean up the key value pair var keyValuePairString = trimStringEnds ( keyValuePairArray [ s ] , [ '\n' ] ) ; //split each string by the :, the result is an array of size two var keyValuePair = keyValuePairString . split ( / :(.*) / ) ; var key = removeUnwantedCharacters ( keyValuePair [ 0 ] . trim ( ) , [ '\n' , '-' ] ) ; key = key . toLowerCase ( ) ; var value = keyValuePair [ 1 ] . trim ( ) ; var claimLineCheckRegExp = / claim lines / i ; if ( claimLineCheckRegExp . test ( key ) ) { claimLineObj . claimNumber = value ; continue ; } if ( value . length === 0 ) { value = null ; } //create a new object for line number if ( key in obj ) { objArray . push ( obj ) ; obj = { } ; } obj [ key ] = value ; } objArray . push ( obj ) ; claimLineObj . data = objArray ; return claimLineObj ; }
function to process claim section of the document
function to process claim section of the document