From f5af46731ea4bf85dc5d2c923a1cdde5079963dc Mon Sep 17 00:00:00 2001 From: chiu Date: Mon, 9 Dec 2019 21:25:59 +0800 Subject: [PATCH] fix bugs --- app/assets/javascripts/cancer_predict.js | 13 +++++++++---- app/controllers/cancerpredicts_controller.rb | 12 ++++++------ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/cancer_predict.js b/app/assets/javascripts/cancer_predict.js index 059dc36..f73f118 100644 --- a/app/assets/javascripts/cancer_predict.js +++ b/app/assets/javascripts/cancer_predict.js @@ -161,6 +161,7 @@ $(document).ready(function(){ $('.cancer-btn-group input').attr('value',0); $('.num_only').val(''); $('#cancer_table .cancer_form_field').removeClass('cancertable_empty'); + $('#cancer_predict_result_block').css('display','none'); }); $('#cancer_table_submit').click(function(){ var flag; @@ -264,7 +265,7 @@ $(document).ready(function(){ var year = $('#current_year').attr('value'); var lpv_current = lpv_real[lpv_real.length-1]+lpv_dict[arguments[0]]; lpv_real.push(lpv_current); - var servive_ratio = (Math.exp(lpv_calc[year])**lpv_current)*100; + var servive_ratio = Math.round((Math.exp(lpv_calc[year])**Math.exp(lpv_current))*100); var benefit = servive_ratio - servive_ratio_arr[servive_ratio_arr.length - 1]; servive_ratio_arr.push(servive_ratio); $('tr.'+arguments[0]+' td.Overall_Survival').html(servive_ratio+'%'); @@ -300,8 +301,8 @@ $(document).ready(function(){ var year = $('#current_year').attr('value'); if(index < this.length - 1){ for(var i = index + 1;i < this.length; i++){ - lpv_real[i] -= lpv_dict[arguments[0]] - var servive_ratio = (Math.exp(lpv_calc[year])**lpv_real[i])*100; + lpv_real[i] -= lpv_dict[arguments[0]]; + var servive_ratio = Math.round((Math.exp(lpv_calc[year])**Math.exp(lpv_real[i]))*100); var benefit = servive_ratio - servive_ratio_arr[servive_ratio_arr.length - 1]; $('tr.'+active_treatment[i]+' td.Overall_Survival').html(servive_ratio+'%'); $('.'+active_treatment[i]+'.Overall_Survival').html(servive_ratio); @@ -346,11 +347,15 @@ $(document).ready(function(){ $('#'+treatmeny_method[i]+' .cancer_table_btn').eq(1).click(function(){ if(!active_treatment.includes($(this).parent().attr('id'))){ active_treatment.push($(this).parent().attr('id')) + console.log(active_treatment); + console.log(servive_ratio_arr); }; }); $('#'+treatmeny_method[i]+' .cancer_table_btn').eq(0).click(function(){ if(active_treatment.includes($(this).parent().attr('id'))){ active_treatment = active_treatment.remove_item_from_array($(this).parent().attr('id')); + console.log(active_treatment); + console.log(servive_ratio_arr); }; }); }; @@ -362,7 +367,7 @@ $(document).ready(function(){ var year = $(this).attr('value'); servive_ratio_arr = []; for(var i = 0;i"123"} + result = {} result['age1'] = -(params['data']['age'].to_f/100)**(-0.5) - result['age2'] = -(params['data']['age'].to_f/100)**(-0.5)*Math.log(params['data']['age'].to_f/100,10) - result['size1'] = -Math.log(params['data']['size'].to_f/10,10) + result['age2'] = -((params['data']['age'].to_f/100)**(-0.5))*Math.log(params['data']['age'].to_f/100,Math.exp(1)) + result['size1'] = -Math.log(params['data']['size'].to_f/10,Math.exp(1)) result['nposit'] = -((params['data']['ratio'].to_f+0.1)/0.1)**0.5 if params['data']['grade'].to_i == 2 result['grade_2'] = 1 @@ -57,7 +57,7 @@ class CancerpredictsController < ApplicationController else result['lvi_yes'] = 0 end - result['lpv'] = ((result['age1']-0.7276655)*(-10.87)+(result['age2']-0.4540707)*8.968+(result['size1']-0.643632)*0.7678+(result['nposit']-1.346932)*0.5339+ + result['lpv'] = ((result['age1']-0.7276655)*(10.87)+(result['age2']+0.4540707)*8.968+(result['size1']-0.643632)*0.7678+(result['nposit']-1.346932)*0.5339+ result['grade_2']*0.4795+result['grade_3']*0.818+result['subtype_HER2']*0.1806+result['subtype_triple']*0.6457+result['pstage_2']*0.5311+ result['pstage_3']*1.134+result['pstage_4']*2.172+result['lvi_yes']*0.3321-0.04 rescue 'error') @years = ['1','3','5'] @@ -79,14 +79,14 @@ class CancerpredictsController < ApplicationController @therapy_choices.each_with_index do |choice,i| result['table'] += '' @table_head.each_with_index do |head,index| - result['table'] += ('' + ((index == 0) ? choice : '-') + '') + result['table'] += ('' + ((index == 0) ? (((i==0)? '' : '+') + choice) : '-') + '') end result['table'] += '' end result['texts'] = '此研究分析來自已接受根除性手術後之婦女所得之結果,根據您所輸入的資訊以及治療方式,'+'
'+'在術後第' @years.each{|year| result['texts'] += ('')} result['texts'] += ',' - @servive_ratio = (Math.exp(-0.001476145)**(result['lpv']))*100 + @servive_ratio = ((Math.exp(-0.001476145)**(Math.exp(result['lpv'])))*100).round result['texts'] += ('

100 位只接受根除性手術的婦女中,有 '+ ''+@servive_ratio.round.to_s+''+' 位婦女,術後 '+''+@years[0].to_s+''+'年仍為存活

') result['texts'] += ''+',此外'