<commit_before>// Graphics library for the Blood Pressure Centiles SMART Application
//
// Author: <NAME>
//
// Revision history:
//       2012-01-02  Implemented custom scaling capability for the long term view
//       2011-06-06  Code refactored
//       2011-06-02  Long term view slpit in two; legent
//       2011-05-19  Code improvements and additional inline documentation
//       2011-05-16  Added SMART integration to app
//       2011-05-13  Improved filtering at load times; Improved the presentation (axis labels, transparency); Fixed range slider issues; Removed Pop-up animation; Fixed handling of less than 3 data points
//       2011-05-12  Fixed redrawing bugs; Implemented workaround for Raphael text drawing in hidden canvas bug; Added filters and filter UI
//       2011-05-10  Merged the short and long term view generator code; Added patient name label
//       2011-05-09  Added data table output; packaged the data variables into a "patient" object; added short-term view
//       2011-05-06  Refactored the code to improve reusability; Added zones abstraction engine; Fixed scaling issues
//
//    TO DO:
//       [X] Integrate with SMART
//       [ ] Clean up the drawGraph function

// Initialize the BPC global obeject as needed
var BPC;
if (!BPC) {
    BPC = {};
}

(function () {
    "use strict";
    
    // The canvases for the short and long term graphs
    var r_short,
        r_long;


    /**
    * Initializes the BPC app with a new patient
    *
    * @param {Object} newPatient The new patient object
    */
    BPC.initApp = function (patient, demo_mode) {
        
        var i, age;

        if (patient) {
            // Update the global patient handle
            BPC.patient = patient;
            
            // Initialize the patient object
            BPC.initPatient (patient);
            
            // Clear the error message
            $("#info").text("").hide();
            
            // Draw the views
            $("#tabs").show();
            BPC.drawViews (patient,BPC.zones);
            
            // Initialize the UI
            BPC.initUI ();
            
            // Find the last pre-adult data record available
            for (i = patient.data.length - 1; i >= 0; i--) {
                if (patient.data[i].age < BPC.ADULT_AGE) {
                    break;
                }
            }

            // Initialize the calculator
            if (i >= 0) {
                BPC.initCalculator ({
                           age: patient.data[i].age, 
                           sex: patient.sex, 
                           height: patient.data[i].height, 
                           systolic: patient.data[i].systolic, 
                           diastolic: patient.data[i].diastolic});
            }
            
            // Display the demo dialog, if needed
            if (demo_mode) {
                $( "#dialog-demo" ).dialog({
                    closeOnEscape: false,
                    draggable: false,
                    resizable: false,
                    modal: true,
                    buttons: {
                        Ok: function() {
                            $( this ).dialog( "close" );
                        }
                    }
                });
            }
            
            // Caculate the current age of the patient
            age = years_apart(new XDate().toISOString(), patient.birthdate);
            
            // Display warning dialog if the patient has reached adult age
            if (age >= BPC.ADULT_AGE) {
                $("#alert-message").text(demographics.name + " is " + BPC.getYears(age) + " years old!");
                $( "#dialog-message" ).dialog({
                    closeOnEscape: false,
                    draggable: false,
                    resizable: false,
                    modal: true,
                    buttons: {
                        Ok: function() {
                            $( this ).dialog( "close" );<commit_msg>Minor bug fix<commit_after>// Graphics library for the Blood Pressure Centiles SMART Application
//
// Author: <NAME>
//
// Revision history:
//       2012-01-02  Implemented custom scaling capability for the long term view
//       2011-06-06  Code refactored
//       2011-06-02  Long term view slpit in two; legent
//       2011-05-19  Code improvements and additional inline documentation
//       2011-05-16  Added SMART integration to app
//       2011-05-13  Improved filtering at load times; Improved the presentation (axis labels, transparency); Fixed range slider issues; Removed Pop-up animation; Fixed handling of less than 3 data points
//       2011-05-12  Fixed redrawing bugs; Implemented workaround for Raphael text drawing in hidden canvas bug; Added filters and filter UI
//       2011-05-10  Merged the short and long term view generator code; Added patient name label
//       2011-05-09  Added data table output; packaged the data variables into a "patient" object; added short-term view
//       2011-05-06  Refactored the code to improve reusability; Added zones abstraction engine; Fixed scaling issues
//
//    TO DO:
//       [X] Integrate with SMART
//       [ ] Clean up the drawGraph function

// Initialize the BPC global obeject as needed
var BPC;
if (!BPC) {
    BPC = {};
}

(function () {
    "use strict";
    
    // The canvases for the short and long term graphs
    var r_short,
        r_long;


    /**
    * Initializes the BPC app with a new patient
    *
    * @param {Object} newPatient The new patient object
    */
    BPC.initApp = function (patient, demo_mode) {
        
        var i, age;

        if (patient) {
            // Update the global patient handle
            BPC.patient = patient;
            
            // Initialize the patient object
            BPC.initPatient (patient);
            
            // Clear the error message
            $("#info").text("").hide();
            
            // Draw the views
            $("#tabs").show();
            BPC.drawViews (patient,BPC.zones);
            
            // Initialize the UI
            BPC.initUI ();
            
            // Find the last pre-adult data record available
            for (i = patient.data.length - 1; i >= 0; i--) {
                if (patient.data[i].age < BPC.ADULT_AGE) {
                    break;
                }
            }

            // Initialize the calculator
            if (i >= 0) {
                BPC.initCalculator ({
                           age: patient.data[i].age, 
                           sex: patient.sex, 
                           height: patient.data[i].height, 
                           systolic: patient.data[i].systolic, 
                           diastolic: patient.data[i].diastolic});
            }
            
            // Display the demo dialog, if needed
            if (demo_mode) {
                $( "#dialog-demo" ).dialog({
                    closeOnEscape: false,
                    draggable: false,
                    resizable: false,
                    modal: true,
                    buttons: {
                        Ok: function() {
                            $( this ).dialog( "close" );
                        }
                    }
                });
            }
            
            // Caculate the current age of the patient
            age = years_apart(new XDate().toISOString(), patient.birthdate);
            
            // Display warning dialog if the patient has reached adult age
            if (age >= BPC.ADULT_AGE) {
                $("#alert-message").text(patient.name + " is " + BPC.getYears(age) + " years old!");
                $( "#dialog-message" ).dialog({
                    closeOnEscape: false,
                    draggable: false,
                    resizable: false,
                    modal: true,
                    buttons: {
                        Ok: function() {
                            $( this ).dialog( "close" );
{'fraction_non_alphanumeric': 0.09403526322370889, 'fraction_numerical': 0.021007877954232836, 'mean_word_length': 1.320278503046127, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '6637182', 'n_tokens_mistral': 2174, 'n_tokens_neox': 1962, 'n_words': 666}