lib/cmsTxtToIntObj.js
function hook(cps, section) {
    var i, len;
    if (section["section header"] === "empty") {
        if (section["data"]) {
            // Guess it's a claim
            len = section["data"].length;
            for (i = 0; i < len; i++) {
                if (section["data"][i]["claim number"]) {
                    section["section header"] = "claim summary";
                    if (!section["claim number"]) {
                        section["claim number"] = section["data"][i]["claim number"];
                    }
                    break;
                }
            }
        }
    }
    if (section["section header"] === "claim" || section["section header"] === "claim summary") {
        if (!section["claim number"]) {
            if (section["data"]) {

                len = section["data"].length;
                for (i = 0; i < len; i++) {
                    if (section["data"][i]["claim number"]) {
                        section["claim number"] = section["data"][i]["claim number"];
                        break;
                    }
                }

            }
        }
    }
}
function hook(cps, section) {
    var i, len;
    if (section["section header"] === "empty") {
        if (section["data"]) {
            // Guess it's a claim
            len = section["data"].length;
            for (i = 0; i < len; i++) {
                if (section["data"][i]["claim number"]) {
                    section["section header"] = "claim summary";
                    if (!section["claim number"]) {
                        section["claim number"] = section["data"][i]["claim number"];
                    }
                    break;
                }
            }
        }
    }
    if (section["section header"] === "claim" || section["section header"] === "claim summary") {
        if (!section["claim number"]) {
            if (section["data"]) {

                len = section["data"].length;
                for (i = 0; i < len; i++) {
                    if (section["data"][i]["claim number"]) {
                        section["claim number"] = section["data"][i]["claim number"];
                        break;
                    }
                }

            }
        }
    }
}
function hook ( cps , section ) { var i , len ; if ( section [ "section header" ] === "empty" ) { if ( section [ "data" ] ) { // Guess it's a claim len = section [ "data" ] . length ; for ( i = 0 ; i < len ; i ++ ) { if ( section [ "data" ] [ i ] [ "claim number" ] ) { section [ "section header" ] = "claim summary" ; if ( ! section [ "claim number" ] ) { section [ "claim number" ] = section [ "data" ] [ i ] [ "claim number" ] ; } break ; } } } } if ( section [ "section header" ] === "claim" || section [ "section header" ] === "claim summary" ) { if ( ! section [ "claim number" ] ) { if ( section [ "data" ] ) { len = section [ "data" ] . length ; for ( i = 0 ; i < len ; i ++ ) { if ( section [ "data" ] [ i ] [ "claim number" ] ) { section [ "claim number" ] = section [ "data" ] [ i ] [ "claim number" ] ; break ; } } } } } }
Massage each section trying to restore a broken structure if any
Massage each section trying to restore a broken structure if any