lib/sections/claims.js
function extrapolateDatesFromLines(claimLines, returnChildObj) {
    var lowTime;
    var highTime;
    var pointTime;
    if (returnChildObj.date_time) {
        if (returnChildObj.date_time.low) {
            lowTime = returnChildObj.date_time.low;
        }
        if (returnChildObj.date_time.high) {
            highTime = returnChildObj.date_time.high;
        }
        if (returnChildObj.date_time.point) {
            pointTime = returnChildObj.date_time.point;
        }
    }

    for (var x in claimLines) {

        if (typeof (claimLines[x]) === "function") {
            continue;
        }

        var claimLineObj = claimLines[x];
        if (claimLineObj.date_time) {
            /*if the main claim body has undefined dates, populate it with
             claim lines date */
            if (claimLineObj.date_time.low && lowTime === undefined) {
                lowTime = claimLineObj.date_time.low;
            }
            if (claimLineObj.date_time.high && highTime === undefined) {
                highTime = claimLineObj.date_time.high;
            }
            if (claimLineObj.date_time.point && pointTime === undefined) {
                pointTime = claimLineObj.date_time.point;
            }
            //if the claim lines are defined, then update them with better/more accurate information
            if (lowTime !== undefined && claimLineObj.date_time.low) {
                var lowDateTime = new Date(lowTime.date);
                var lineLowDateTime = new Date(claimLineObj.date_time.low.date);
                if (lineLowDateTime < lowDateTime) {
                    lowTime = claimLineObj.date_time.low;
                }
            }
            if (highTime !== undefined && claimLineObj.date_time.high) {
                var highDateTime = new Date(highTime.date);
                var lineHighDateTime = new Date(claimLineObj.date_time.high.date);
                if (lineHighDateTime > highDateTime) {
                    highTime = claimLineObj.date_time.high;
                }
            }
            //on the assumption that the most recent service date is most relevant
            if (pointTime !== undefined && claimLineObj.date_time.point) {
                var pointDateTime = new Date(pointTime.date);
                var linePointDateTime = new Date(claimLineObj.date_time.point.date);
                if (pointDateTime > pointDateTime) {
                    pointTime = claimLineObj.date_time.point;
                }
            }
        }
    }
    //assign the newly discovered times to the main claims body object
    if (returnChildObj.date_time === undefined) {
        returnChildObj.date_time = {};
    }
    if (lowTime) {
        returnChildObj.date_time.low = lowTime;
    }
    if (highTime) {
        returnChildObj.date_time.high = highTime;
    }
    if (pointTime) {
        returnChildObj.date_time.point = pointTime;
    }

}
function extrapolateDatesFromLines(claimLines, returnChildObj) {
    var lowTime;
    var highTime;
    var pointTime;
    if (returnChildObj.date_time) {
        if (returnChildObj.date_time.low) {
            lowTime = returnChildObj.date_time.low;
        }
        if (returnChildObj.date_time.high) {
            highTime = returnChildObj.date_time.high;
        }
        if (returnChildObj.date_time.point) {
            pointTime = returnChildObj.date_time.point;
        }
    }

    for (var x in claimLines) {

        if (typeof (claimLines[x]) === "function") {
            continue;
        }

        var claimLineObj = claimLines[x];
        if (claimLineObj.date_time) {
            /*if the main claim body has undefined dates, populate it with
             claim lines date */
            if (claimLineObj.date_time.low && lowTime === undefined) {
                lowTime = claimLineObj.date_time.low;
            }
            if (claimLineObj.date_time.high && highTime === undefined) {
                highTime = claimLineObj.date_time.high;
            }
            if (claimLineObj.date_time.point && pointTime === undefined) {
                pointTime = claimLineObj.date_time.point;
            }
            //if the claim lines are defined, then update them with better/more accurate information
            if (lowTime !== undefined && claimLineObj.date_time.low) {
                var lowDateTime = new Date(lowTime.date);
                var lineLowDateTime = new Date(claimLineObj.date_time.low.date);
                if (lineLowDateTime < lowDateTime) {
                    lowTime = claimLineObj.date_time.low;
                }
            }
            if (highTime !== undefined && claimLineObj.date_time.high) {
                var highDateTime = new Date(highTime.date);
                var lineHighDateTime = new Date(claimLineObj.date_time.high.date);
                if (lineHighDateTime > highDateTime) {
                    highTime = claimLineObj.date_time.high;
                }
            }
            //on the assumption that the most recent service date is most relevant
            if (pointTime !== undefined && claimLineObj.date_time.point) {
                var pointDateTime = new Date(pointTime.date);
                var linePointDateTime = new Date(claimLineObj.date_time.point.date);
                if (pointDateTime > pointDateTime) {
                    pointTime = claimLineObj.date_time.point;
                }
            }
        }
    }
    //assign the newly discovered times to the main claims body object
    if (returnChildObj.date_time === undefined) {
        returnChildObj.date_time = {};
    }
    if (lowTime) {
        returnChildObj.date_time.low = lowTime;
    }
    if (highTime) {
        returnChildObj.date_time.high = highTime;
    }
    if (pointTime) {
        returnChildObj.date_time.point = pointTime;
    }

}
function extrapolateDatesFromLines ( claimLines , returnChildObj ) { var lowTime ; var highTime ; var pointTime ; if ( returnChildObj . date_time ) { if ( returnChildObj . date_time . low ) { lowTime = returnChildObj . date_time . low ; } if ( returnChildObj . date_time . high ) { highTime = returnChildObj . date_time . high ; } if ( returnChildObj . date_time . point ) { pointTime = returnChildObj . date_time . point ; } } for ( var x in claimLines ) { if ( typeof ( claimLines [ x ] ) === "function" ) { continue ; } var claimLineObj = claimLines [ x ] ; if ( claimLineObj . date_time ) { /*if the main claim body has undefined dates, populate it with
             claim lines date */ if ( claimLineObj . date_time . low && lowTime === undefined ) { lowTime = claimLineObj . date_time . low ; } if ( claimLineObj . date_time . high && highTime === undefined ) { highTime = claimLineObj . date_time . high ; } if ( claimLineObj . date_time . point && pointTime === undefined ) { pointTime = claimLineObj . date_time . point ; } //if the claim lines are defined, then update them with better/more accurate information if ( lowTime !== undefined && claimLineObj . date_time . low ) { var lowDateTime = new Date ( lowTime . date ) ; var lineLowDateTime = new Date ( claimLineObj . date_time . low . date ) ; if ( lineLowDateTime < lowDateTime ) { lowTime = claimLineObj . date_time . low ; } } if ( highTime !== undefined && claimLineObj . date_time . high ) { var highDateTime = new Date ( highTime . date ) ; var lineHighDateTime = new Date ( claimLineObj . date_time . high . date ) ; if ( lineHighDateTime > highDateTime ) { highTime = claimLineObj . date_time . high ; } } //on the assumption that the most recent service date is most relevant if ( pointTime !== undefined && claimLineObj . date_time . point ) { var pointDateTime = new Date ( pointTime . date ) ; var linePointDateTime = new Date ( claimLineObj . date_time . point . date ) ; if ( pointDateTime > pointDateTime ) { pointTime = claimLineObj . date_time . point ; } } } } //assign the newly discovered times to the main claims body object if ( returnChildObj . date_time === undefined ) { returnChildObj . date_time = { } ; } if ( lowTime ) { returnChildObj . date_time . low = lowTime ; } if ( highTime ) { returnChildObj . date_time . high = highTime ; } if ( pointTime ) { returnChildObj . date_time . point = pointTime ; } }
extrapolates main claim body dates from claim lines
extrapolates main claim body dates from claim lines