<commit_before>'use strict';

var fs = require('fs');
var path = require('path');
var util = require('util');

var moment = require('moment');
var async = require('async');

var PdfMake = require('pdfmake');

var sections = require('./sections');
var patientData = require('./patient-data');
var models = require('../models');
var _ = require('lodash');

var fileCounter = 1;

var fonts = {
    Roboto: {
        normal: path.join(__dirname, 'fonts/Roboto-Regular.ttf'),
        bold: path.join(__dirname, 'fonts/Roboto-Medium.ttf'),
        italics: path.join(__dirname, 'fonts/Roboto-Italic.ttf'),
        bolditalics: path.join(__dirname, 'fonts/Roboto-Italic.ttf')
    }
};

var headerFooterHandler = function(demographicsList) {
    var pageInfos = [];

    return {
        layoutInfoAccepter: function(pages) {
            var dindex = 0;
            var pindex = 1;
            var counts = [1]
            pages.forEach(function(page, index) {
                if (index > 0) {
                    if (page.items[0].type === 'image') {
                        dindex = dindex + 1;
                        pindex = 1;
                        counts.push(1);
                    } else {
                        ++pindex;
                        counts[dindex] = pindex;
                    }
                }
                pageInfos.push({
                    dindex: dindex,
                    pindex: pindex
                })
            });
            pageInfos.forEach(function(pageInfo, index) {
                var dindex = pageInfo.dindex;
                pageInfo.count = counts[dindex];
            });
        },
        header: function(currentPage, pageCount) {
            var pageInfo = pageInfos[currentPage-1];
            var dindex = pageInfo.dindex;
            return {
                text: 'CONFIDENTIAL ' + demographicsList[dindex].name + ' ' + moment().format('MM/DD/YYYY HH:mm'),
                bold: true,
                alignment: 'center',
                fontSize: 18
            }
        },
        footer: function(currentPage) {
            var pageInfo = pageInfos[currentPage-1];
            var pindex = pageInfo.pindex;
            var count = pageInfo.count;
            return {
                text: pindex.toString() + ' of ' + count.toString(),
                alignment: 'center'
            }
        }
    };
};<commit_msg>Put DOB on top of each page instead of current date time<commit_after>'use strict';

var fs = require('fs');
var path = require('path');
var util = require('util');

var moment = require('moment');
var async = require('async');

var PdfMake = require('pdfmake');

var sections = require('./sections');
var patientData = require('./patient-data');
var models = require('../models');
var _ = require('lodash');

var fileCounter = 1;

var fonts = {
    Roboto: {
        normal: path.join(__dirname, 'fonts/Roboto-Regular.ttf'),
        bold: path.join(__dirname, 'fonts/Roboto-Medium.ttf'),
        italics: path.join(__dirname, 'fonts/Roboto-Italic.ttf'),
        bolditalics: path.join(__dirname, 'fonts/Roboto-Italic.ttf')
    }
};

var headerFooterHandler = function(demographicsList) {
    var pageInfos = [];

    return {
        layoutInfoAccepter: function(pages) {
            var dindex = 0;
            var pindex = 1;
            var counts = [1]
            pages.forEach(function(page, index) {
                if (index > 0) {
                    if (page.items[0].type === 'image') {
                        dindex = dindex + 1;
                        pindex = 1;
                        counts.push(1);
                    } else {
                        ++pindex;
                        counts[dindex] = pindex;
                    }
                }
                pageInfos.push({
                    dindex: dindex,
                    pindex: pindex
                })
            });
            pageInfos.forEach(function(pageInfo, index) {
                var dindex = pageInfo.dindex;
                pageInfo.count = counts[dindex];
            });
        },
        header: function(currentPage, pageCount) {
            var pageInfo = pageInfos[currentPage-1];
            var dindex = pageInfo.dindex;
            return {
                text: 'CONFIDENTIAL - ' + demographicsList[dindex].name + ' - DOB: ' + demographicsList[dindex].DOB,
                bold: true,
                alignment: 'center',
                fontSize: 18
            }
        },
        footer: function(currentPage) {
            var pageInfo = pageInfos[currentPage-1];
            var pindex = pageInfo.pindex;
            var count = pageInfo.count;
            return {
                text: pindex.toString() + ' of ' + count.toString(),
                alignment: 'center'
            }
        }
    };
};
{'fraction_non_alphanumeric': 0.12429848264394097, 'fraction_numerical': 0.0054042818540843895, 'mean_word_length': 1.4881075491209927, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6314399', 'n_tokens_mistral': 1382, 'n_tokens_neox': 1296, 'n_words': 281}