Advertisement
Ranga14

JS/JQuery Namespace Functions Example File

Feb 3rd, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // EFFECTS JS
  2. // ====================================================================
  3. // This file contains all effects, transitions and animatinos between pages.
  4. // ====================================================================
  5.  
  6. var effect = {
  7.  
  8.     // ====================================================================
  9.     // Physician Flow
  10.     // ====================================================================
  11.  
  12.     physicianFlow: function() {
  13.  
  14.         // Hide Patient Table & Results
  15.         $(patientTable).hide();
  16.         $(medicalRecordTable).hide();
  17.         $patientMedical.hide();
  18.  
  19.         // Show next page
  20.         $patientMedical.fadeIn();
  21.         $(patientUpdate).fadeIn();
  22.         $physicanBtnExam.fadeIn();
  23.  
  24.         // Change Page Title
  25.         $title.fadeIn().text('Patient Medical Info');
  26.  
  27.     },
  28.  
  29.     exam: function() {
  30.  
  31.         // Fetch the Error
  32.         var errorCheck = effect.validation();
  33.  
  34.         // Error Checking
  35.         if ( errorCheck.val != 0 ) {
  36.  
  37.             // Hide any Alerts
  38.             $alert.hide();
  39.  
  40.             // Hide Patient Update Info
  41.             $(patientUpdate).hide();
  42.    
  43.             // Show Progress & next page
  44.             $progress.fadeIn();
  45.             $patientVitals.fadeIn();
  46.  
  47.             // Change Page Title (Since they're now in the Exam flow.)
  48.             $title.fadeIn().text('Examination');
  49.  
  50.             // Reset Button
  51.             $(this).text('Continue to Ears, Nose & Throat');
  52.             $(this).off('click').on('click', effect.examEarsNoseThroat);
  53.  
  54.             // Reset to Top
  55.             effect.pageReset();
  56.  
  57.         } else {
  58.  
  59.             // Attach Error Classes & Show Messaging
  60.             $(errorCheck.container).each(function(){
  61.                 $(this).parent().addClass('has-error');
  62.                 $alert.fadeIn();
  63.             });
  64.  
  65.         }
  66.  
  67.     },
  68.  
  69.     examEarsNoseThroat: function() {
  70.  
  71.         // Show/Hide Content
  72.         $patientVitals.hide();
  73.         $patientEarsNoseThroat.fadeIn();
  74.         $restartBtn.fadeIn();
  75.  
  76.         // Update Progress Bar
  77.         $progressBar.attr('aria-valuenow', '11');
  78.         $progressBar.attr('style', 'width: 11%');
  79.         $progressBar.text('11%');
  80.  
  81.         // Reset Button
  82.         $(this).text('Continue to Upper Extremity');
  83.         $(this).off('click').on('click', effect.examUpperExtremity);
  84.  
  85.         // Reset to Top
  86.         effect.pageReset();
  87.  
  88.     },
  89.  
  90.     examUpperExtremity: function() {
  91.  
  92.         // Show/Hide Content
  93.         $patientEarsNoseThroat.hide();
  94.         $patientUpperExtremity.fadeIn();
  95.  
  96.         // Update Progress Bar
  97.         $progressBar.attr('aria-valuenow', '22');
  98.         $progressBar.attr('style', 'width: 22%');
  99.         $progressBar.text('22%');
  100.  
  101.         // Reset Button
  102.         $(this).text('Continue to Lower Extremity');
  103.         $(this).off('click').on('click', effect.examLowerExtremity);
  104.  
  105.         // Reset to Top
  106.         effect.pageReset();
  107.  
  108.     },
  109.  
  110.     examLowerExtremity: function() {
  111.  
  112.         // Show/Hide Content
  113.         $patientUpperExtremity.hide();
  114.         $patientLowerExtremity.fadeIn();
  115.  
  116.         // Update Progress Bar
  117.         $progressBar.attr('aria-valuenow', '33');
  118.         $progressBar.attr('style', 'width: 33%');
  119.         $progressBar.text('33%');
  120.  
  121.         // Reset Button
  122.         $(this).text('Continue to Chest & Lungs');
  123.         $(this).off('click').on('click', effect.examChestLungs);
  124.  
  125.         // Reset to Top
  126.         effect.pageReset();
  127.  
  128.     },
  129.  
  130.     examChestLungs: function() {
  131.  
  132.         // Show/Hide Content
  133.         $patientLowerExtremity.hide();
  134.         $patientChestLungs.fadeIn();
  135.  
  136.         // Update Progress Bar
  137.         $progressBar.attr('aria-valuenow', '44');
  138.         $progressBar.attr('style', 'width: 44%');
  139.         $progressBar.text('44%');
  140.  
  141.         // Reset Button
  142.         $(this).text('Continue to Heart & Blood');
  143.         $(this).off('click').on('click', effect.examHeartBlood);
  144.  
  145.         // Reset to Top
  146.         effect.pageReset();
  147.  
  148.     },
  149.  
  150.     examHeartBlood: function() {
  151.  
  152.         // Show/Hide Content
  153.         $patientChestLungs.hide();
  154.         $patientHeartBlood.fadeIn();
  155.  
  156.         // Update Progress Bar
  157.         $progressBar.attr('aria-valuenow', '56');
  158.         $progressBar.attr('style', 'width: 56%');
  159.         $progressBar.text('56%');
  160.  
  161.         // Reset Button
  162.         $(this).text('Continue to Abdominal');
  163.         $(this).off('click').on('click', effect.examAbdominal);
  164.  
  165.         // Reset to Top
  166.         effect.pageReset();
  167.  
  168.     },
  169.  
  170.     examAbdominal: function() {
  171.  
  172.         // Show/Hide Content
  173.         $patientHeartBlood.hide();
  174.         $patientAbdominal.fadeIn();
  175.  
  176.         // Update Progress Bar
  177.         $progressBar.attr('aria-valuenow', '67');
  178.         $progressBar.attr('style', 'width: 67%');
  179.         $progressBar.text('67%');
  180.  
  181.         // Reset Button
  182.         $(this).text('Continue to Neurological');
  183.         $(this).off('click').on('click', effect.examNeurological);
  184.  
  185.         // Reset to Top
  186.         effect.pageReset();
  187.  
  188.     },
  189.  
  190.     examNeurological: function() {
  191.  
  192.         // Show/Hide Content
  193.         $patientAbdominal.hide();
  194.         $patientNeurological.fadeIn();
  195.  
  196.         // Update Progress Bar
  197.         $progressBar.attr('aria-valuenow', '78');
  198.         $progressBar.attr('style', 'width: 78%');
  199.         $progressBar.text('78%');
  200.  
  201.         // Reset Button
  202.         $(this).text('Continue to Procedure');
  203.         $(this).off('click').on('click', effect.examProcedure);
  204.  
  205.         // Reset to Top
  206.         effect.pageReset();
  207.  
  208.     },
  209.  
  210.     examProcedure: function() {
  211.  
  212.         // Show/Hide Content
  213.         $patientNeurological.hide();
  214.         $patientProcedure.fadeIn();
  215.  
  216.         // Update Progress Bar
  217.         $progressBar.attr('aria-valuenow', '89');
  218.         $progressBar.attr('style', 'width: 89%');
  219.         $progressBar.text('89%');
  220.  
  221.         // Reset Button
  222.         $(this).text('Complete Exam');
  223.         $(this).off('click').on('click', effect.examComplete);
  224.  
  225.         // Reset to Top
  226.         effect.pageReset();
  227.  
  228.     },
  229.  
  230.     examComplete: function() {
  231.  
  232.         // Show/Hide Content
  233.         $patientProcedure.hide();
  234.         $restartBtn.hide();
  235.         $backBtn.hide();
  236.         $(this).hide();
  237.         $physicanBtnExam.hide();
  238.  
  239.         // Update Progress Bar
  240.         $progressBar.attr('aria-valuenow', '100');
  241.         $progressBar.attr('style', 'width: 100%');
  242.         $progressBar.text('100%');
  243.  
  244.         // Fade out the progress bar and fade in the completion screen
  245.         $progress.addClass('success-highlight').delay(2000).fadeOut(1000, function(e){
  246.             $patientComplete.fadeIn();
  247.         });
  248.  
  249.     },
  250.  
  251.     patientDDX: function() {
  252.  
  253.         // Change Page Title
  254.         $title.fadeIn().text('DDX Results & Referrals');
  255.  
  256.         // Show/Hide Content
  257.         $patientComplete.hide();
  258.         $patientDDX.fadeIn();
  259.         $patientNextBtn.fadeIn();
  260.  
  261.     },
  262.  
  263.     patientReferred: function() {
  264.  
  265.         // Grab the Button ID
  266.         var $rID = $patientDDXRefBtn.prop('id');
  267.  
  268.         // Change the Button Text & Class to disabled
  269.         $('#' + $rID).text('Referred').addClass('btn-disabled');
  270.  
  271.     },
  272.  
  273.     patientNext: function() {
  274.  
  275.         // Show/Hide Content
  276.         $patientNextBtn.hide();
  277.         $patientDDX.hide();
  278.         $(patientTable).fadeIn();
  279.  
  280.         // Change Page Title
  281.         $title.fadeIn().text('Find Patient');
  282.  
  283.         // Scroll to Top table result
  284.         var $offset = $(patientTable).offset();
  285.         $htmlBody.animate({
  286.             scrollTop: $offset.top,
  287.             scrollLeft: $offset.left
  288.         });
  289.     },
  290.  
  291.     medicalEncounters: function() {
  292.  
  293.         // Hide Patient Table & Results
  294.         $(patientTable).hide();
  295.         $patientMedical.hide();
  296.  
  297.         // Show next page
  298.         $(medicalRecordTable).fadeIn();
  299.  
  300.         // Change Page Title
  301.         $title.fadeIn().text('Medical Encounters');
  302.  
  303.     },
  304.  
  305.     referrals: {
  306.  
  307.         init: function(viewType) {
  308.  
  309.             // Process & Show Ref data     
  310.             referrals.initialize(viewType);
  311.  
  312.             // Hide Patient Table & Results
  313.             $(medicalInfoPatient).hide();
  314.             $(patientTable).hide();
  315.             $patientMedical.hide();
  316.             $navFileManager.hide();
  317.             $(fileManager).hide();
  318.             $(patientFlowCtn).hide();
  319.             $(patientEncounters).hide();
  320.             $(medicalInfoPatientEdit).hide();
  321.  
  322.             effect.progress.revert();
  323.             effect.btn.hide();
  324.  
  325.             // Show sub nav
  326.             $(subNav).fadeIn();
  327.             $navReferrals.fadeIn();
  328.             $searchCtn.fadeIn();
  329.  
  330.             // Show next page
  331.             $(referralsTable).fadeIn();
  332.  
  333.             // Change Page Title
  334.             $title.fadeIn().text('Referrals');
  335.  
  336.         },
  337.  
  338.         process: function(viewType) {
  339.  
  340.             // Process & Show Ref data     
  341.             referrals.initialize(viewType);
  342.  
  343.         },
  344.  
  345.     },
  346.  
  347.     patientEdit: function() {
  348.  
  349.         // Hide Patient Table & Results
  350.         $(patientTable).hide();
  351.         $(patientUpdate).hide();
  352.         $(medicalRecordTable).hide();
  353.         $physicanBtnExam.hide();
  354.         $patientVitals.hide();
  355.  
  356.         effect.progress.revert();
  357.  
  358.         // Show next page
  359.         $patientMedical.fadeIn();
  360.         $(patientEdit).fadeIn();
  361.         $physicanBtnEdit.fadeIn();
  362.  
  363.         // Change Page Title
  364.         $title.fadeIn().text('Patient Medical Info');
  365.  
  366.     },
  367.  
  368.     patientEditComplete: function() {
  369.  
  370.         // Hide Patient Table & Results
  371.         $(patientEdit).hide();
  372.         $(patientAdd).hide();
  373.         $physicanBtnEdit.hide();
  374.  
  375.         // Show next page
  376.         $(patientTable).fadeIn();
  377.        
  378.         // Change Page Title
  379.         $title.fadeIn().text('Manage Patient(s)');
  380.     },
  381.  
  382.     addPatient: function(data) {
  383.  
  384.         if ( $(data).closest('body').prop('id') == 'admin' ) {
  385.  
  386.             console.log('Admin Add Patient Scope');
  387.  
  388.             // Hide Patient Table & Results
  389.             $examManager.hide();
  390.             $ddxManager.hide();
  391.  
  392.             // Show next page
  393.             $patientMedical.fadeIn();
  394.             $(patientAdd).fadeIn();
  395.             $physicanBtnAdd.fadeIn();
  396.  
  397.         } else {
  398.  
  399.             console.log('Normal Add Patient Scope');
  400.  
  401.             // Hide Patient Table & Results
  402.             $searchCtn.hide();
  403.             $(patientTable).hide();
  404.             $(medicalRecordTable).hide();
  405.             $(patientUpdate).hide();
  406.             $physicanBtnExam.hide();
  407.             $patientVitals.hide();
  408.             $genericFiles.hide();
  409.             $labManager.hide();
  410.             $(fileManager).hide();
  411.             $(subNav).hide();
  412.             $(referralsTable).hide();
  413.             $(patientFlowCtn).hide();
  414.             $(patientEncounters).hide();
  415.             $patientFlowPanel.hide();
  416.             $(medicalInfoPatientEdit).hide();
  417.  
  418.             effect.progress.revert();
  419.             effect.btn.init();
  420.             effect.btn.hideEdit();
  421.  
  422.             // Show next page
  423.             $patientsMedicalInfoNew.fadeIn();
  424.             $patientMedical.fadeIn();
  425.             $(patientAdd).fadeIn();
  426.             $physicanBtnAdd.fadeIn();
  427.             $(patientUpdate).show();
  428.  
  429.             // Change Page Title
  430.             $title.fadeIn().text('Patient Medical Info');
  431.             $ptBtn.text('Begin Questionnaire');
  432.  
  433.         }
  434.  
  435.     },
  436.  
  437.     patientAddComplete: function() {
  438.  
  439.         // Hide Patient Table & Results
  440.         $(patientAdd).hide();
  441.         $physicanBtnAdd.hide();
  442.  
  443.         // Show next page
  444.         $(patientTable).fadeIn();
  445.        
  446.         // Change Page Title
  447.         $title.fadeIn().text('Manage Patient(s)');
  448.     },
  449.  
  450.     files: {
  451.  
  452.         requiredFiles: function() {
  453.  
  454.             // Hide Patient Table & Results
  455.             $(medicalInfoPatient).hide();
  456.             $(medicalRecordTable).hide();
  457.             $(patientTable).hide();
  458.             $navReferrals.hide();
  459.             $(referralsTable).hide();
  460.             $genericFiles.hide();
  461.             $labManager.hide();
  462.             $(patientFlowCtn).hide();
  463.             $(patientEncounters).hide();
  464.             $(medicalInfoPatientEdit).hide();
  465.  
  466.             effect.progress.revert();
  467.             effect.btn.hide();
  468.            
  469.             // Show
  470.             $(fileManager).fadeIn();
  471.             $requiredFiles.fadeIn();
  472.             $(subNav).fadeIn();
  473.             $navFileManager.fadeIn();
  474.             $searchCtn.fadeIn();
  475.            
  476.             // Change Page Title
  477.             $title.fadeIn().text('Required Files');
  478.  
  479.         },
  480.  
  481.         genericFiles: function() {
  482.  
  483.             // Hide Patient Table & Results
  484.             $(medicalInfoPatient).hide();
  485.             $(medicalRecordTable).hide();
  486.             $(patientTable).hide();
  487.             $navReferrals.hide();
  488.             $requiredFiles.hide();
  489.             $labManager.hide();
  490.            
  491.             // Show
  492.             $genericFiles.fadeIn();
  493.             $(subNav).fadeIn();
  494.             $navFileManager.fadeIn();
  495.             effect.btn.init();
  496.  
  497.             // Change Page Title
  498.             $title.fadeIn().text('Generic Files');
  499.             $ptBtn.fadeIn().html('<span class="glyphicon glyphicon-open-file"></span> Upload New File');
  500.  
  501.         },
  502.  
  503.         labManager: function() {
  504.  
  505.             // Hide Patient Table & Results
  506.             $(medicalInfoPatient).hide();
  507.             $(medicalRecordTable).hide();
  508.             $(patientTable).hide();
  509.             $navReferrals.hide();
  510.             $requiredFiles.hide();
  511.             $genericFiles.hide();
  512.            
  513.             // Show
  514.             $labManager.fadeIn();
  515.             $(subNav).fadeIn();
  516.             $navFileManager.fadeIn();
  517.             effect.btn.init();
  518.            
  519.             // Change Page Title
  520.             $title.fadeIn().text('Lab Manager');
  521.             $ptBtn.fadeIn().html('<span class="glyphicon glyphicon-open-file"></span> Upload New File');
  522.  
  523.         }
  524.  
  525.     },
  526.  
  527.     // ====================================================================
  528.     // Patient Flow
  529.     // ====================================================================
  530.  
  531.     patientFlow: function(data){
  532.  
  533.         // Fetch the Error
  534.         var errorCheck = effect.validation();
  535.         // alex error overrride
  536.         errorCheck.val = 1;
  537.         // end alex error override
  538.         // Error Checking
  539.         if ( errorCheck.val != 0 ) {
  540.  
  541.             // Hide any Alerts
  542.             $alert.hide();
  543.  
  544.             // Hide Patient Update Info
  545.             $(patientUpdate).hide();
  546.    
  547.             // Show Progress & next page
  548.             $(patientFlowCtn).fadeIn();
  549.             $patientInfo.fadeIn();
  550.  
  551.             // Insert Restart Button
  552.             $restartBtn.fadeIn();
  553.  
  554.             // Get the button id and check to see if the button was Clicked vs Swiped
  555.             var $id = $(this).attr('id');
  556.  
  557.             // Reset Button
  558.             $ptBtn.text('Continue to Insurance');
  559.  
  560.             if ( this.id = $id ) {
  561.                                
  562.                 $(this).off('click').on('click', effect.patientInsurance);
  563.  
  564.             } else {
  565.  
  566.                 $ptBtn.off('click').on('click', effect.patientInsurance);
  567.  
  568.             }
  569.  
  570.             // Add Current state to history
  571.             History.addEntry('patientFlow');
  572.  
  573.             if ( $id != null || $id != undefined || data == 'swipe' ) {
  574.                 effect.progress.init();
  575.             }
  576.  
  577.             // Save Data
  578.             patient.saveInformation();
  579.            
  580.             // Reset to Top
  581.             effect.pageReset();
  582.  
  583.         } else {
  584.  
  585.             console.log('patient flow errors' + errorCheck.container);
  586.  
  587.             // Attach Error Classes & Show Messaging
  588.             $(errorCheck.container).each(function(){
  589.                 $(this).parent().addClass('has-error');
  590.                 $alert.fadeIn();
  591.             });
  592.  
  593.         }
  594.  
  595.     },
  596.  
  597.     patientInsurance: function(data) {
  598.  
  599.         // Show/Hide Content
  600.         $patientInfo.hide();
  601.         $patientInsurance.fadeIn();
  602.         $backBtn.css('visibility', 'visible');
  603.  
  604.         // Get the button id and check to see if the button was Clicked vs Swiped
  605.         var $id = $(this).attr('id');
  606.  
  607.         // Reset Button
  608.         $ptBtn.text('Continue to Allergies');
  609.  
  610.         if ( this.id = $id ) {
  611.  
  612.             $(this).off('click').on('click', effect.patientAllergy);
  613.  
  614.         } else {
  615.  
  616.             $ptBtn.off('click').on('click', effect.patientAllergy);
  617.  
  618.         }
  619.  
  620.         // Add Current state to history
  621.         History.addEntry('patientInsurance');
  622.  
  623.         console.log('btn id: ' + $id);
  624.  
  625.         if ( $id != null || $id != undefined || data == 'swipe' ) {
  626.             effect.progress.init();
  627.         }
  628.  
  629.         // Save Data
  630.         patient.saveContactInfo();
  631.  
  632.         // Reset to Top
  633.         effect.pageReset();
  634.  
  635.     },
  636.  
  637.     patientAllergy: function(data) {
  638.  
  639.         // Show/Hide Content
  640.         $patientInsurance.hide();
  641.         $patientAllergy.fadeIn();
  642.  
  643.         // Get the button id and check to see if the button was Clicked vs Swiped
  644.         var $id = $(this).attr('id');
  645.  
  646.         // Reset Button
  647.         $ptBtn.text('Continue to Shot History');
  648.  
  649.         if ( this.id = $id ) {
  650.  
  651.             $(this).off('click').on('click', effect.patientShots);
  652.  
  653.         } else {
  654.  
  655.             $ptBtn.off('click').on('click', effect.patientShots);
  656.  
  657.         }
  658.  
  659.         // Add Current state to history
  660.         History.addEntry('patientAllergy');
  661.  
  662.         console.log('btn id: ' + $id);
  663.  
  664.         if ( $id != null || $id != undefined || data == 'swipe' ) {
  665.             effect.progress.init();
  666.         }
  667.        
  668.         // Save Data
  669.         patient.saveInsurance();
  670.  
  671.         // Reset to Top
  672.         effect.pageReset();
  673.  
  674.     },
  675.  
  676.     patientShots: function(data) {
  677.  
  678.         // Show/Hide Content
  679.         $patientAllergy.hide();
  680.         $patientShots.fadeIn();
  681.  
  682.         // Get the button id and check to see if the button was Clicked vs Swiped
  683.         var $id = $(this).attr('id');
  684.  
  685.         // Reset Button
  686.         $ptBtn.text('Continue to Medications');
  687.  
  688.         if ( this.id = $id ) {
  689.  
  690.             $(this).off('click').on('click', effect.patientMedications);
  691.  
  692.         } else {
  693.  
  694.             $ptBtn.off('click').on('click', effect.patientMedications);
  695.  
  696.         }
  697.  
  698.         // Add Current state to history
  699.         History.addEntry('patientShots');
  700.  
  701.         console.log('btn id: ' + $id);
  702.  
  703.         if ( $id != null || $id != undefined || data == 'swipe' ) {
  704.             effect.progress.init();
  705.         }
  706.  
  707.         // Save Data
  708.         patient.saveAllergies();
  709.  
  710.         // Reset to Top
  711.         effect.pageReset();
  712.  
  713.     },
  714.  
  715.     patientMedications: function(data) {
  716.  
  717.         // Show/Hide Content
  718.         $patientShots.hide();
  719.         $patientMedications.fadeIn();
  720.  
  721.         // Get the button id and check to see if the button was Clicked vs Swiped
  722.         var $id = $(this).attr('id');
  723.  
  724.         // Reset Button
  725.         $ptBtn.text('Continue to Family History');
  726.  
  727.         if ( this.id = $id ) {
  728.  
  729.             $(this).off('click').on('click', effect.patientFamilyHistory);
  730.  
  731.         } else {
  732.  
  733.             $ptBtn.off('click').on('click', effect.patientFamilyHistory);
  734.  
  735.         }
  736.  
  737.         // Add Current state to history
  738.         History.addEntry('patientMedications');
  739.  
  740.         if ( $id != null || $id != undefined || data == 'swipe' ) {
  741.             effect.progress.init();
  742.         }
  743.  
  744.         // Save Data
  745.         patient.saveShotHistory();
  746.  
  747.         // Reset to Top
  748.         effect.pageReset();
  749.  
  750.     },
  751.  
  752.     patientFamilyHistory: function(data) {
  753.  
  754.         // Show/Hide Content
  755.         $patientMedications.hide();
  756.         $patientFamilyHistory.fadeIn();
  757.  
  758.         // Get the button id and check to see if the button was Clicked vs Swiped
  759.         var $id = $(this).attr('id');
  760.  
  761.         // Reset Button
  762.         $ptBtn.text('Continue to Current Complaint');
  763.  
  764.         if ( this.id = $id ) {
  765.  
  766.             $(this).off('click').on('click', effect.patientComplaint);
  767.        
  768.         } else {
  769.  
  770.             $ptBtn.off('click').on('click', effect.patientComplaint);
  771.  
  772.         }
  773.  
  774.         // Add Current state to history
  775.         History.addEntry('patientFamilyHistory');
  776.  
  777.         if ( $id != null || $id != undefined || data == 'swipe' ) {
  778.             effect.progress.init();
  779.         }
  780.  
  781.         // Save Data
  782.         patient.saveMedications();
  783.  
  784.         // Reset to Top
  785.         effect.pageReset();
  786.  
  787.     },
  788.  
  789.     patientComplaint: function(data) {
  790.  
  791.         // Show/Hide Content
  792.         $patientFamilyHistory.hide();
  793.         $patientComplaint.fadeIn();
  794.  
  795.         // Get the button id and check to see if the button was Clicked vs Swiped
  796.         var $id = $(this).attr('id');
  797.  
  798.         // Reset Button
  799.         $ptBtn.text('Continue to History of Present Illness');
  800.  
  801.         if ( this.id = $id ) {
  802.  
  803.             $(this).off('click').on('click', effect.patientHPI);
  804.  
  805.         } else {
  806.  
  807.             $ptBtn.off('click').on('click', effect.patientHPI);
  808.  
  809.         }
  810.  
  811.         // Add Current state to history
  812.         History.addEntry('patientComplaint');
  813.  
  814.         if ( $id != null || $id != undefined || data == 'swipe' ) {
  815.             effect.progress.init();
  816.         }
  817.  
  818.         // Save Data
  819.         patient.saveFamilyHistory();
  820.  
  821.         // Reset to Top
  822.         effect.pageReset();
  823.  
  824.     },
  825.  
  826.     patientHPI: function(data) {
  827.  
  828.         // Show/Hide Content
  829.         $patientComplaint.hide();
  830.         $patientHPI.fadeIn();
  831.  
  832.         // Get the button id and check to see if the button was Clicked vs Swiped
  833.         var $id = $(this).attr('id');
  834.  
  835.         // Reset Button
  836.         $ptBtn.text('Continue to Review of Symptoms');
  837.  
  838.         if ( this.id = $id ) {
  839.  
  840.             $(this).off('click').on('click', effect.patientReviewSymptoms);
  841.  
  842.         } else {
  843.  
  844.             $ptBtn.off('click').on('click', effect.patientReviewSymptoms);
  845.  
  846.         }
  847.  
  848.         // Add Current state to history
  849.         History.addEntry('patientHPI');
  850.  
  851.         if ( $id != null || $id != undefined || data == 'swipe' ) {
  852.             effect.progress.init();
  853.         }
  854.  
  855.         // Save Data
  856.         patient.saveCurrentComplaint();
  857.  
  858.         // Reset to Top
  859.         effect.pageReset();
  860.  
  861.     },
  862.  
  863.     patientReviewSymptoms: function(data) {
  864.  
  865.         // Show/Hide Content
  866.         $patientHPI.hide();
  867.         $patientReviewSymptoms.fadeIn();
  868.  
  869.         // Get the button id and check to see if the button was Clicked vs Swiped
  870.         var $id = $(this).attr('id');
  871.  
  872.         // Reset Button
  873.         $ptBtn.text('Continue to Past Medical');
  874.  
  875.         if ( this.id = $id ) {
  876.  
  877.             $(this).off('click').on('click', effect.patientPastMedical);
  878.  
  879.         } else {
  880.  
  881.             $ptBtn.off('click').on('click', effect.patientPastMedical);
  882.  
  883.         }
  884.  
  885.         // Add Current state to history
  886.         History.addEntry('patientReviewSymptoms');
  887.  
  888.         if ( $id != null || $id != undefined || data == 'swipe' ) {
  889.             effect.progress.init();
  890.         }
  891.  
  892.         // Save Data
  893.         patient.saveHpi();
  894.  
  895.         // Reset to Top
  896.         effect.pageReset();
  897.  
  898.     },
  899.  
  900.     patientPastMedical: function(data) {
  901.  
  902.         // Show/Hide Content
  903.         $patientReviewSymptoms.hide();
  904.         $patientPastMedical.fadeIn();
  905.  
  906.         // Get the button id and check to see if the button was Clicked vs Swiped
  907.         var $id = $(this).attr('id');
  908.  
  909.         // Reset Button
  910.         $ptBtn.text('Continue to Previous Medications');
  911.  
  912.         if ( this.id = $id ) {
  913.  
  914.             $(this).off('click').on('click', effect.patientPreviousMedications);
  915.  
  916.         } else {
  917.  
  918.             $ptBtn.off('click').on('click', effect.patientPreviousMedications);
  919.  
  920.         }
  921.  
  922.         // Add Current state to history
  923.         History.addEntry('patientPastMedical');
  924.  
  925.         if ( $id != null || $id != undefined || data == 'swipe' ) {
  926.             effect.progress.init();
  927.         }
  928.  
  929.         // Save Data
  930.         patient.saveReviewOfSymptoms();
  931.  
  932.         // Reset to Top
  933.         effect.pageReset();
  934.  
  935.     },
  936.  
  937.     patientPreviousMedications: function(data) {
  938.  
  939.         // Show/Hide Content
  940.         $patientPastMedical.hide();
  941.         $patientPreviousMedications.fadeIn();
  942.  
  943.         // Get the button id and check to see if the button was Clicked vs Swiped
  944.         var $id = $(this).attr('id');
  945.  
  946.         // Reset Button
  947.         $ptBtn.text('Continue to Previous Treatments');
  948.  
  949.         if ( this.id = $id ) {
  950.  
  951.             $(this).off('click').on('click', effect.patientPreviousTreatments);
  952.  
  953.         } else {
  954.  
  955.             $ptBtn.off('click').on('click', effect.patientPreviousTreatments);
  956.  
  957.         }
  958.  
  959.         // Add Current state to history
  960.         History.addEntry('patientPreviousMedications');
  961.  
  962.         if ( $id != null || $id != undefined || data == 'swipe' ) {
  963.             effect.progress.init();
  964.         }
  965.  
  966.         // Save Data
  967.         patient.savePastMedicalHistory();
  968.  
  969.         // Reset to Top
  970.         effect.pageReset();
  971.  
  972.     },
  973.  
  974.     patientPreviousTreatments: function(data) {
  975.  
  976.         // Show/Hide Content
  977.         $patientPreviousMedications.hide();
  978.         $patientPreviousTreatments.fadeIn();
  979.  
  980.         // Get the button id and check to see if the button was Clicked vs Swiped
  981.         var $id = $(this).attr('id');
  982.  
  983.         // Reset Button
  984.         $ptBtn.text('Continue to Hospitalizations');
  985.  
  986.         if ( this.id = $id ) {
  987.  
  988.             $(this).off('click').on('click', effect.patientHospitalizations);
  989.  
  990.         } else {
  991.  
  992.             $ptBtn.off('click').on('click', effect.patientHospitalizations);
  993.  
  994.         }
  995.  
  996.         // Add Current state to history
  997.         History.addEntry('patientPreviousTreatments');
  998.  
  999.         if ( $id != null || $id != undefined || data == 'swipe' ) {
  1000.             effect.progress.init();
  1001.         }
  1002.  
  1003.         // Save Data
  1004.         patient.savePreviousMedications();
  1005.  
  1006.         // Reset to Top
  1007.         effect.pageReset();
  1008.  
  1009.     },
  1010.  
  1011.     patientHospitalizations: function(data) {
  1012.  
  1013.         // Show/Hide Content
  1014.         $patientPreviousTreatments.hide();
  1015.         $patientHospitalizations.fadeIn();
  1016.  
  1017.         // Get the button id and check to see if the button was Clicked vs Swiped
  1018.         var $id = $(this).attr('id');
  1019.  
  1020.         // Reset Button
  1021.         $ptBtn.text('Complete');
  1022.  
  1023.         if ( this.id = $id ) {
  1024.  
  1025.             $(this).off('click').on('click', effect.patientInfoComplete);
  1026.  
  1027.         } else {
  1028.  
  1029.             $ptBtn.off('click').on('click', effect.patientInfoComplete);
  1030.  
  1031.         }
  1032.  
  1033.         // Add Current state to history
  1034.         History.addEntry('patientHospitalizations');
  1035.  
  1036.         if ( $id != null || $id != undefined || data == 'swipe' ) {
  1037.             effect.progress.init();
  1038.         }
  1039.  
  1040.         // Save Data
  1041.         patient.savePreviousTreatments();
  1042.  
  1043.         // Reset to Top
  1044.         effect.pageReset();
  1045.  
  1046.     },
  1047.  
  1048.     patientInfoComplete: function() {
  1049.  
  1050.         // Save Data
  1051.         patient.savePreviousHospitalizations();
  1052.  
  1053.         // Show/Hide Content
  1054.         $patientHospitalizations.hide();
  1055.         $restartBtn.hide();
  1056.         $backBtn.hide();
  1057.         $ptBtn.hide();
  1058.  
  1059.         // Init Progress
  1060.         effect.progress.init('1');
  1061.  
  1062.         // Fade out the progress bar and fade in the completion screen
  1063.         $patientInfoComplete.fadeIn(2000);
  1064.  
  1065.         // Footer Fix
  1066.         $(footer).addClass('footer-fix');
  1067.  
  1068.     },
  1069.  
  1070.     symptom: {
  1071.  
  1072.         cats: {
  1073.             // Drop data from db here?
  1074.             name: 'Bleeding'
  1075.         },
  1076.  
  1077.         types: {
  1078.             // Drop data from db here?
  1079.             name: 'Trauma / Injury'
  1080.         },
  1081.  
  1082.         category: function() {
  1083.             //$symptomList.fadeIn(500);
  1084.             // Fade in text of of Symptom Category
  1085.             $symptomCategory.text(effect.symptom.cats.name).fadeIn();
  1086.             // Fade in Checkbox and set name of checkbox based on Symptom Category
  1087.             $symptomCategoryForm.fadeIn().attr('name', effect.symptom.cats.name);
  1088.         },
  1089.  
  1090.         result: function() {
  1091.             $symptomCategoryCheck.prop('disabled', true);
  1092.             $symptomTypeAnswer.fadeIn(1000).attr('name', effect.symptom.types.name);
  1093.         },
  1094.  
  1095.         restart: function() {
  1096.             $symptomList.hide();
  1097.             $symptomCategory.empty();
  1098.             $symptomCategoryCheck.prop('disabled', false).attr('checked', false).removeAttr('name');
  1099.             $symptomTypeAnswer.val('').removeAttr('name').hide();
  1100.         },
  1101.  
  1102.         // Body Part Hover Effets
  1103.         part: {
  1104.  
  1105.             knee: function() {
  1106.                 $markerKnee.stop().fadeToggle();
  1107.                 $tipKnee.stop().fadeToggle();
  1108.             },
  1109.  
  1110.             shoulder: function() {
  1111.                 $markerShoulder.stop().fadeToggle();
  1112.                 $tipShoulder.stop().fadeToggle();
  1113.             }
  1114.  
  1115.         }
  1116.  
  1117.     },
  1118.  
  1119.     list: {
  1120.  
  1121.         add: function(data, textValue) {
  1122.             var preload = false;
  1123.             var $id = $(data).closest('.listForm').attr('id');
  1124.             console.log($id);
  1125.             var $listType = $('#' + $id + ' select option:selected').text();
  1126.  
  1127.             if(typeof textValue !== 'undefined')
  1128.             {
  1129.                 preload = true;
  1130.                 $listType = textValue;
  1131.             }
  1132.             num++;
  1133.  
  1134.             // Grab row id
  1135.            
  1136.  
  1137.             // Add a Medication Condition)
  1138.             if ($id == 'medForm' ) {
  1139.                 if(!preload)
  1140.                 {
  1141.                     var $medName = $('#patientDrug').val();
  1142.                     var $medDose = $('#patientDosage').val();
  1143.                     var $medRowId = '';
  1144.                 }
  1145.                 else
  1146.                 {
  1147.                    
  1148.                     var $medRowId = $listType.id;
  1149.                     var $medName = $listType.medName.trim();
  1150.                     var $medDose = $listType.medDosage.trim();
  1151.                     $listType = $listType.dosageFrequency.trim();
  1152.                 }
  1153.                 //$listType = $medDose +' of ' + $medName + ' ' + $listType + ' times a day';
  1154.  
  1155.                 var html= '';
  1156.  
  1157.                 html+= '<tr class="listRow" id="listRow' + num + '">';
  1158.                     html+= '<input type="hidden" class="hiddenDelId" value="'+$medRowId+'">';
  1159.                     html+= '<td class="col-md-3 listRecord medname">' + $medName + '</td>';
  1160.                     html+= '<td class="col-md-3 listRecord medose">' + $medDose + '</td>';
  1161.                     html+= '<td class="col-md-4 listRecord medfreq">' + $listType;
  1162.                     if(!preload) html+= ' a day';
  1163.                     html+=  '</td>';
  1164.                     html+= '<td class="col-md-2 text-right">';
  1165.                         html+= '<button type="button" class="btn btn-danger removeBtn" alt="Remove" title="Remove">';
  1166.                             html+= '<div class="glyphicon glyphicon-minus-sign"></div>';
  1167.                         html+= '</button>';
  1168.                     html+= '</td>';
  1169.                 html+= '</tr>';
  1170.  
  1171.             // Add a Hospital Condition
  1172.             } else if ($id == 'hospForm' ) {
  1173.                 if(!preload)
  1174.                 {
  1175.                     var $hospDate = patient.getDateDropdown('#patientHospMonth', '#patientHospDay', '#patientHospYear');
  1176.                     var $hospReason = $('#patientHospReason').val();
  1177.                     var $hospLocation = $('#patientHospLocation').val();
  1178.                     var $hospRowId = '';
  1179.                 }
  1180.                 else
  1181.                 {
  1182.                     var $hospRowId = $listType.id;
  1183.                     var $hospDate = $listType.startDate;
  1184.                     var $hospReason = $listType.reason;
  1185.                     var $hospLocation = $listType.location;
  1186.                 }
  1187.  
  1188.                 var html= '';
  1189.                 html+= '<tr class="listRow" id="listRow' + num + '">';
  1190.                     html+= '<input type="hidden" class="hospHiddenDelId" value="'+$hospRowId+'">';
  1191.                     //html+= '<td class="col-md-10 listRecord">' + $listType + '</td>';
  1192.                     html+= '<td class="col-md-3 hospReason">' + $hospReason + '</td>';
  1193.                     html+= '<td class="col-md-3 hospLoc">' + $hospLocation + '</td>';
  1194.                     html+= '<td class="col-md-4 hospDate">' + $hospDate + '</td>';
  1195.                     html+= '<td class="col-md-2 text-right">';
  1196.                         html+= '<button type="button" class="btn btn-danger removeBtn" alt="Remove" title="Remove">';
  1197.                             html+= '<div class="glyphicon glyphicon-minus-sign"></div>';
  1198.                         html+= '</button>';
  1199.                     html+= '</td>';
  1200.                 html+= '</tr>';
  1201.  
  1202.             // All else (Generic Single Item List)
  1203.             } else {
  1204.  
  1205.                 var html= '';
  1206.                 html+= '<tr class="listRow" id="listRow' + num + '">';
  1207.                     html+= '<td class="col-md-10 listRecord">' + $listType + '</td>';
  1208.                     html+= '<td class="col-md-2 text-right">';
  1209.                         html+= '<button type="button" class="btn btn-danger removeBtn" alt="Remove" title="Remove">';
  1210.                             html+= '<div class="glyphicon glyphicon-minus-sign"></div>';
  1211.                         html+= '</button>';
  1212.                     html+= '</td>';
  1213.                 html+= '</tr>';
  1214.  
  1215.             }
  1216.  
  1217.             $('#' + $id + ' ' + listRecord).fadeIn();
  1218.             $('#' + $id + ' ' + listEntry).append(html);
  1219.  
  1220.         },
  1221.  
  1222.         remove: function(data) {
  1223.             var $formId = $(data).closest('.listForm').attr('id');
  1224.             // Grab row id
  1225.             var $id = $(data).closest('.listRow').attr('id');
  1226.  
  1227.             if($formId == 'medForm')
  1228.             {
  1229.                 var delList = $('#medFormDeleteList');
  1230.                 var oldValue = delList.val();
  1231.                 var newVal = $('#' + $id + ' .hiddenDelId').val();
  1232.  
  1233.                 // don't add to delete list if medication was added this session
  1234.                 if(typeof newVal !== 'undefined' && newVal != '')
  1235.                 {
  1236.                     if(oldValue == '')
  1237.                         delList.val(newVal);
  1238.                     else
  1239.                         delList.val(oldValue + ',' + newVal);
  1240.                 }
  1241.             }
  1242.             if($formId == 'hospForm')
  1243.             {
  1244.                 var delList = $('#hospFormDeleteList');
  1245.                 var oldValue = delList.val();
  1246.                 var newVal = $('#' + $id + ' .hospHiddenDelId').val();
  1247.  
  1248.                 // don't add to delete list if medication was added this session
  1249.                 if(typeof newVal !== 'undefined' && newVal != '')
  1250.                 {
  1251.                     if(oldValue == '')
  1252.                         delList.val(newVal);
  1253.                     else
  1254.                         delList.val(oldValue + ',' + newVal);
  1255.                 }
  1256.             }
  1257.  
  1258.             // Remove row
  1259.             $('#' + $id).remove();
  1260.  
  1261.         }
  1262.  
  1263.     },
  1264.  
  1265.     // ====================================================================
  1266.     // Nurse
  1267.     // ====================================================================
  1268.  
  1269.     nurse: function() {
  1270.  
  1271.         $nurseInfo.fadeIn();
  1272.  
  1273.         $nurseBtn.off('click').on('click', effect.nurseContactInfo);
  1274.  
  1275.     },
  1276.  
  1277.     nurseContactInfo: function() {
  1278.  
  1279.         $nurseInfo.hide();
  1280.         $nurseContactInfo.fadeIn();
  1281.  
  1282.         $nurseBtn.text('Continue to Insurance');
  1283.  
  1284.         $nurseBtn.off('click').on('click', effect.nurseInsurance);
  1285.  
  1286.         // Reset to Top
  1287.         effect.pageReset();
  1288.        
  1289.     },
  1290.  
  1291.     nurseInsurance: function() {
  1292.  
  1293.         $nurseContactInfo.hide();
  1294.         $nurseInsurance.fadeIn();
  1295.  
  1296.         $nurseBtn.text('Complete');
  1297.  
  1298.         $nurseBtn.off('click').on('click', effect.nurseComplete);
  1299.        
  1300.         // Reset to Top
  1301.         effect.pageReset();
  1302.  
  1303.     },
  1304.  
  1305.     nurseComplete: function() {
  1306.  
  1307.         $nurseInsurance.hide();
  1308.         $nurseBtn.hide();
  1309.  
  1310.         // Reset to Top
  1311.         effect.pageReset();
  1312.  
  1313.         // Fade out the progress bar and fade in the completion screen
  1314.         $patientInfoComplete.fadeIn(2000);
  1315.  
  1316.     },
  1317.  
  1318.     // ====================================================================
  1319.     // Global
  1320.     // ====================================================================
  1321.  
  1322.     restart: function() {
  1323.  
  1324.         try{physician.hideAll();}catch(e){}
  1325.         // Hide Titles
  1326.         $title.empty();
  1327.  
  1328.         if ( $('body').hasClass('patient') ) {
  1329.  
  1330.             // Reset Title
  1331.             $title.text('Patient Information');
  1332.  
  1333.             // Hide any Alerts
  1334.             $alert.hide();
  1335.  
  1336.             // Show Patient Update Info
  1337.             $(patientUpdate).fadeIn();
  1338.             $patientFlowPanel.hide();
  1339.             $(patientFlowCtn).hide();
  1340.  
  1341.             // Hide Buttons
  1342.             $restartBtn.hide();
  1343.             $backBtn.css('visibility', 'hidden');
  1344.  
  1345.             // Reset button to default
  1346.             $ptBtn.text('Begin Questionnaire');
  1347.             $ptBtn.off('click').on('click', effect.patientFlow);
  1348.  
  1349.         } else {
  1350.  
  1351.             // Reset Title
  1352.             $title.text('Manage Patient(s)');
  1353.  
  1354.             // Show/Hide Content Blocks
  1355.             $searchCtn.fadeIn();
  1356.             $(patientTable).fadeIn();
  1357.             $patientMedical.hide();
  1358.             $(medicalRecordTable).hide();
  1359.             $patientComplete.hide();
  1360.             $patientDDX.hide();
  1361.             $(patientAdd).hide();
  1362.             $physicanBtnAdd.hide();
  1363.             $(patientEdit).hide();
  1364.             $physicanBtnEdit.hide();
  1365.             $genericFiles.hide();
  1366.             $labManager.hide();
  1367.             $(fileManager).hide();
  1368.             $(subNav).hide();
  1369.             $(patientUpdate).hide();
  1370.             $patientFlowPanel.hide();
  1371.             $(patientEncounters).hide();
  1372.             $(medicalInfoPatientEdit).hide();
  1373.  
  1374.             effect.progress.revert();
  1375.             effect.btn.hide();
  1376.  
  1377.             // Reset button to default
  1378.             $examBtn.text('Start Exam');
  1379.             $examBtn.off('click').on('click', effect.exam);
  1380.  
  1381.         }
  1382.  
  1383.         // Reset to the Home page
  1384.         // $(start).slideDown('fast', function(){
  1385.         //  $(this).removeClass('page-sliver');
  1386.         //  $(start + ' .container').fadeIn();
  1387.         // });
  1388.  
  1389.         // Hide Modal
  1390.         this.modalClose();
  1391.  
  1392.     },
  1393.  
  1394.     login: {
  1395.  
  1396.         error: function() {
  1397.  
  1398.             $(login + ' .alert').text('Error: Your username (or) password is incorrect. Please try again.').fadeIn();
  1399.  
  1400.         }
  1401.  
  1402.     },
  1403.  
  1404.     sort: {
  1405.  
  1406.         asc: function(data) {
  1407.  
  1408.             $(data).removeClass('glyphicon-triangle-top').addClass('glyphicon-triangle-bottom');
  1409.  
  1410.         },
  1411.  
  1412.         desc: function(data) {
  1413.  
  1414.             $(data).removeClass('glyphicon-triangle-bottom').addClass('glyphicon-triangle-top');
  1415.            
  1416.         }
  1417.  
  1418.     },
  1419.  
  1420.     filter: {
  1421.  
  1422.         renderSearch: function(data) {
  1423.  
  1424.             // Increment
  1425.             num++
  1426.  
  1427.             var $ctnName = $(data).closest('.container').prop('id');
  1428.  
  1429.             console.log('id: ' + $ctnName);
  1430.  
  1431.             if ( $('#' + $ctnName + ' .filter').length == 1 ) {
  1432.                 var $searchTypeVal = $('.filter0 .search-type option:selected').val();
  1433.                 var $searchType = $('.filter0 .search-type');
  1434.                 var $options = $('.filter0 .search-type option');
  1435.             } else {
  1436.                 var $searchTypeVal = $('.filter' + num + ' .search-type option:selected').val();
  1437.                 var $searchType = $('.filter' + num + ' .search-type');
  1438.                 var $options = $('.filter' + num + ' .search-type option');
  1439.             }
  1440.  
  1441.             var $values = $.map($options, function(option) {
  1442.                
  1443.                 if ( option.value != $searchTypeVal ) {
  1444.  
  1445.                     return '<option>' + option.value + '</option>';
  1446.  
  1447.                 }
  1448.  
  1449.             });
  1450.  
  1451.             // Remove commas from the string
  1452.             $values = String($values).replace(/,/g , '');
  1453.             $values = String($values).replace('<option>', '<option selected="selected">');
  1454.             $searchType.prop('disabled', true);
  1455.  
  1456.             var html= '';
  1457.             html+= '<div class="row filter filter' + num + '" style="display: none;">';
  1458.                 html+= '<div class="col-lg-8 col-md-8 col-xs-6">';
  1459.                     html+= '<div class="input-group">';
  1460.                         html+= '<span class="input-group-addon" id="basic-addon1">';
  1461.                             html+= '<span class="glyphicon glyphicon-search" aria-hidden="true"></span>';
  1462.                         html+= '</span>';
  1463.                         html+= '<input type="text" class="form-control" placeholder="Type your search string here...">';
  1464.                     html+= '</div>';
  1465.                 html+= '</div>';
  1466.                 html+= '<div class="col-lg-2 col-md-2 col-xs-4">';
  1467.                     html+= '<select class="form-control search-type">';
  1468.                         html+= $values;
  1469.                     html+= '</select>';
  1470.                 html+= '</div>';
  1471.                 html+= '<div class="col-lg-2 col-md-2 col-xs-4">';
  1472.                     html+= '<button type="button" class="btn btn-danger" id="removeFilter' + num + '">Remove Filter</button>';
  1473.                 html+= '</div>';
  1474.             html+= '</div>';
  1475.  
  1476.             $(html).appendTo('.form-group').slideDown();
  1477.  
  1478.         },
  1479.  
  1480.         changeOption: function(data) {
  1481.  
  1482.             var $currentSelection = $(data).find('.filter:last .search-type option');
  1483.             var $selected = $(data).find('.filter:last .search-type option:selected');
  1484.  
  1485.             // Remove current selection
  1486.             $currentSelection.removeAttr('selected');
  1487.  
  1488.             // Update new selection and refresh selected item
  1489.             $selected.attr('selected', 'selected').prop('selected', true);
  1490.  
  1491.             $(data).attr('selected');
  1492.  
  1493.         },
  1494.  
  1495.         removeOption: function(data) {
  1496.  
  1497.             if ( $(data).attr('id') == 'removeFilter0' ) {
  1498.  
  1499.                 var $currentSelection = $('#first input');
  1500.  
  1501.                 $currentSelection.val('');
  1502.  
  1503.             } else {
  1504.  
  1505.                 var $currentSelection = $(data).closest('.filter');
  1506.                 var $btn = $(data).attr('id');
  1507.  
  1508.                 $currentSelection.fadeOut().remove();
  1509.  
  1510.             }
  1511.  
  1512.         }
  1513.  
  1514.     },
  1515.  
  1516.     pageReset: function() {
  1517.  
  1518.         // Reset to the top of page. (Mostly for smaller resolutions.)
  1519.         var offset = $pageWrap.offset();
  1520.         $htmlBody.animate({
  1521.             scrollTop: offset.top,
  1522.             scrollLeft: offset.left
  1523.         });
  1524.  
  1525.     },
  1526.  
  1527.     navClick: function() {
  1528.  
  1529.         $(patientEdit).hide();
  1530.         $physicanBtnEdit.hide();
  1531.  
  1532.     },
  1533.  
  1534.     loading: function() {
  1535.  
  1536.         arr = {
  1537.             'title': 'Please wait while your Results load...',
  1538.             'content': '<div class="text-center"><span class="glyphicon glyphicon-refresh glyphicon-refresh-animate"></span></div>'
  1539.         }
  1540.  
  1541.         this.modalAlert(arr.title, arr.content, 'static', 'false');
  1542.  
  1543.     },
  1544.  
  1545.     // Progress Function
  1546.     progress: {
  1547.  
  1548.         init: function(data) {
  1549.  
  1550.             console.log('Data: ' + data);
  1551.  
  1552.             $progress.fadeIn();
  1553.  
  1554.             $flowCount = $('#patientFlow .panel-default').size();
  1555.             $percent = $progressBar.attr('aria-valuenow');
  1556.  
  1557.             console.log('Current flow: ' + $flowCount);
  1558.             console.log('Current Percent: ' + $percent);
  1559.  
  1560.             // if ( data == 'start' ) {
  1561.             //  // If the user is in the first part of the flow, set to 0
  1562.             //  var panel = 0;
  1563.             // } else {
  1564.                 // Divide Result (# of Panels) & Assign %
  1565.                 var panel = 100 / $flowCount;
  1566.             // }
  1567.  
  1568.             var panelRound = Math.round(panel);
  1569.  
  1570.             console.log('Panel Round: ' + panelRound);
  1571.  
  1572.             if ( data == 'back' ) {
  1573.                 var addedPercent = Number($percent) - Number(panelRound);
  1574.                 console.log('back: ' + addedPercent);
  1575.             } else {
  1576.                 var addedPercent = Number($percent) + Number(panelRound);
  1577.                 console.log('forward: ' + addedPercent);
  1578.             }
  1579.  
  1580.             console.log('Added Percent: ' + addedPercent);
  1581.  
  1582.             var percent = Math.round(addedPercent);
  1583.  
  1584.             if ( data != 1 ) {
  1585.  
  1586.                 console.log('Completion: ' + percent);
  1587.  
  1588.                 // Update Progress Bar with values
  1589.                 $progressBar.attr('aria-valuenow', percent);
  1590.                 $progressBar.attr('style', 'width: ' + percent + '%');
  1591.                 $progressBar.text(percent + '%');
  1592.  
  1593.             } else {
  1594.  
  1595.                 console.log('Completion is DONE');
  1596.  
  1597.                 $('.progress-container .well').addClass('success-highlight');
  1598.                 $progressBar.attr('aria-valuenow', '100');
  1599.                 $progressBar.attr('style', 'width: 100%');
  1600.                 $progressBar.text('100%');
  1601.  
  1602.                 // Fade out the progress bar and fade in the completion screen
  1603.                 $progress.delay(2000).fadeOut(1000);
  1604.  
  1605.             }
  1606.  
  1607.         },
  1608.  
  1609.         revert: function() {
  1610.  
  1611.             $progress.hide();
  1612.             $('.progress-container .well').removeClass('success-highlight');
  1613.             $progressBar.attr('aria-valuenow', '0');
  1614.             $progressBar.attr('style', 'width: 0%');
  1615.             $progressBar.text('0%');
  1616.  
  1617.         }
  1618.  
  1619.     },
  1620.  
  1621.     accordion: function(data) {
  1622.  
  1623.         var $accordionID = $(data).prop('id');
  1624.  
  1625.         $('.' + $accordionID).slideToggle();
  1626.  
  1627.     },
  1628.  
  1629.     register: function() {
  1630.  
  1631.         // Fix footer issue
  1632.         $('body#home').css('height', 'auto');
  1633.  
  1634.         $registerQ.fadeOut();
  1635.         $registerHero.fadeOut();
  1636.         $registration.slideDown();
  1637.  
  1638.     },
  1639.  
  1640.     disableRow: function(data) {
  1641.  
  1642.         $(data).addClass('active').addClass('text-muted');
  1643.  
  1644.     },
  1645.  
  1646.     date: {
  1647.  
  1648.         year: function() {
  1649.  
  1650.             var start = 1900;
  1651.             var end = new Date().getFullYear();
  1652.             var options = "";
  1653.             for(var year = start ; year <=end; year++){
  1654.               options += "<option>"+ year +"</option>";
  1655.             }
  1656.             $('.year').append(options);
  1657.  
  1658.         }
  1659.        
  1660.     },
  1661.  
  1662.     btn: {
  1663.  
  1664.         init: function() {
  1665.  
  1666.             $btnWrap.fadeIn();
  1667.             $ptBtn.show();
  1668.  
  1669.         },
  1670.  
  1671.         hide: function() {
  1672.  
  1673.             $backBtn.css('visibility', 'hidden');
  1674.             $btnWrap.hide();
  1675.             $ptBtn.text('');
  1676.  
  1677.         },
  1678.  
  1679.         hideEdit: function () {
  1680.  
  1681.             $('.btn-wrapper-edit').hide();
  1682.  
  1683.         }
  1684.  
  1685.     },
  1686.  
  1687.     other: function(data) {
  1688.  
  1689.         var $id = $(data).closest('.columns').attr('id');
  1690.         var $id2 = $(data).closest('.rows').attr('id');
  1691.  
  1692.         console.log('id2: ' + $id2);
  1693.  
  1694.         if ( $('#' + $id).hasClass('columns') ) {
  1695.             $('#' + $id + 'Text').fadeToggle();
  1696.         } else {
  1697.             $('#' + $id2 + 'Text').fadeToggle();
  1698.         }
  1699.  
  1700.     },
  1701.  
  1702.     // ====================================================================
  1703.     // Modals
  1704.     // ====================================================================
  1705.  
  1706.     modal: function() {
  1707.  
  1708.         // Grab the Modal Name from the ID attribute
  1709.         function modalName() {
  1710.             var $modalID = '#' + $modal.prop('id');
  1711.             return $modalID;
  1712.         }
  1713.  
  1714.         return modalName();
  1715.  
  1716.     },
  1717.  
  1718.     modalAlert: function(title, text, confirmText, cancelText) {
  1719.  
  1720.         // Error Checking
  1721.         if (title == null || title == undefined || text == null || text == undefined) {
  1722.  
  1723.             try{console.log('Incorrect inputs for modal alert');}catch(e){}
  1724.             return false;
  1725.  
  1726.         }
  1727.  
  1728.         // Fetch the modal name
  1729.         var name = this.modal();
  1730.  
  1731.         if ( confirmText == 'static' && cancelText == 'false' ) {
  1732.  
  1733.             console.log('Disabled Modal.');
  1734.  
  1735.             // Launch Bootstrap modal with messaging
  1736.             $(name).on('show.bs.modal', function() {
  1737.                 $(name + ' .modal-title').empty().append(title);
  1738.                 $(name + ' .modal-body p').empty().append(text);
  1739.             }).modal({
  1740.                 backdrop: 'static',
  1741.                 keyboard: false
  1742.             });
  1743.  
  1744.         } else {
  1745.  
  1746.             console.log('Normal Modal.');
  1747.  
  1748.             // Launch Bootstrap modal with messaging
  1749.             $(name).on('show.bs.modal', function() {
  1750.                 $(name + ' .modal-title').empty().append(title);
  1751.                 $(name + ' .modal-body p').empty().append(text);
  1752.                 $(name + ' .modal-footer .btn-primary').empty().append(confirmText);
  1753.                 $(name + ' .modal-footer .btn-default').empty().append(cancelText);
  1754.             }).modal('show');
  1755.  
  1756.         }
  1757.  
  1758.     },
  1759.  
  1760.     modalClose: function() {
  1761.  
  1762.         // Fetch the modal name
  1763.         var modalName = this.modal();
  1764.  
  1765.         // Close the modal
  1766.         $(modalName).modal('hide');
  1767.  
  1768.     },
  1769.  
  1770.     // ====================================================================
  1771.     // Admin
  1772.     // ====================================================================
  1773.  
  1774.     examManage: function() {
  1775.  
  1776.         //$(patientTable).hide();
  1777.         $patientMedical.hide();
  1778.         $ddxManager.hide();
  1779.         $examManager.fadeIn();
  1780.  
  1781.     },
  1782.  
  1783.     ddxManage: function() {
  1784.  
  1785.         $patientMedical.hide();
  1786.         $examManager.hide();
  1787.         $ddxManager.fadeIn();
  1788.  
  1789.     },
  1790.  
  1791.     question: {
  1792.  
  1793.         formOpen: function(data) {
  1794.  
  1795.             // Pull Click ID to target DOM elements
  1796.             var $clickID = $(data).prop('id');
  1797.  
  1798.             $('#' + $clickID).closest(questionWrapper).hide();
  1799.             $('.' + $clickID).fadeIn();
  1800.  
  1801.         },
  1802.  
  1803.         formClose: function(data) {
  1804.  
  1805.             // Pull Click ID to target DOM elements
  1806.             var $clickID = $(data).data('id');
  1807.  
  1808.             $('.' + $clickID).hide();
  1809.             $('#' + $clickID).closest(questionWrapper).fadeIn();
  1810.  
  1811.         }
  1812.  
  1813.     },
  1814.  
  1815.     answer: {
  1816.  
  1817.         formOpen: function(data) {
  1818.  
  1819.             // Pull Click ID to target DOM elements
  1820.             var $clickID = $(data).prop('id');
  1821.  
  1822.             $('#' + $clickID).closest(answerWrapper).hide();
  1823.             $('.' + $clickID).fadeIn();
  1824.  
  1825.         },
  1826.  
  1827.         formClose: function(data) {
  1828.  
  1829.             // Pull Click ID to target DOM elements
  1830.             var $clickID = $(data).data('id');
  1831.  
  1832.             $('.' + $clickID).hide();
  1833.             $('#' + $clickID).closest(answerWrapper).fadeIn();
  1834.  
  1835.         }
  1836.  
  1837.     },
  1838.  
  1839.     // ====================================================================
  1840.     // ID (This might be removed.)
  1841.     // ====================================================================
  1842.  
  1843.     patientID: function() {
  1844.         // Get the Patient ID to pass
  1845.         // var patientID = e.attr('id');
  1846.         // console.log('id: ' + patientID);
  1847.     },
  1848.  
  1849.     // ====================================================================
  1850.     // Form Input
  1851.     // ====================================================================
  1852.  
  1853.     formInput: function() {
  1854.  
  1855.         if ( $formInput.parent().hasClass('has-error') ) {
  1856.             $formInput.parent().removeClass('has-error');
  1857.         }
  1858.  
  1859.     },
  1860.  
  1861.     // ====================================================================
  1862.     // Error Checking
  1863.     // ====================================================================
  1864.  
  1865.     validation: function() {
  1866.  
  1867.         // Grab the Modal Name from the ID attribute
  1868.         function input() {
  1869.             var $input = $(patientUpdate + ' input');
  1870.  
  1871.             $input.each(function(){
  1872.                 value = $(this).val();
  1873.             });
  1874.  
  1875.             // Check to see if there's a value
  1876.             if ( value === undefined || value === null || value === '' ) {
  1877.                 var value = 0;
  1878.  
  1879.                 effect.pageReset();
  1880.             }
  1881.  
  1882.             return { container: $input, val: value };
  1883.         }
  1884.  
  1885.         return input();
  1886.  
  1887.     }
  1888.  
  1889. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement