Fix js contents.
This commit is contained in:
parent
a56f6ba5e3
commit
9d2872b884
|
@ -385,7 +385,7 @@ $(document).ready(function(){
|
||||||
$('#cancer_predict_result_block').css('display','block');
|
$('#cancer_predict_result_block').css('display','block');
|
||||||
var lpv_real = [result.responseJSON['lpv_variable']];
|
var lpv_real = [result.responseJSON['lpv_variable']];
|
||||||
var lpv_dict={}
|
var lpv_dict={}
|
||||||
var lpv_calc=/*lpv_calc_formula_start*/{1: "0.8095037^( exp(lpv_current) )",1.5: "0.729158^( exp(lpv_current) )",2: "0.6717211^( exp(lpv_current) )", 2.5: "0.6056773^( exp(lpv_current) )"}/*lpv_calc_formula_end*/
|
var lpv_calc=/*lpv_calc_formula_start*/{"1":"0.8095037**( Math.exp(lpv_current) )","1.5":"0.729158**( Math.exp(lpv_current) )","2":"0.6717211**( Math.exp(lpv_current) )","2.5":"0.6056773**( Math.exp(lpv_current) )"}/*lpv_calc_formula_end*/
|
||||||
active_treatment.push = function() {
|
active_treatment.push = function() {
|
||||||
if(arguments.length == 1){
|
if(arguments.length == 1){
|
||||||
var year = $('#current_year').attr('value');
|
var year = $('#current_year').attr('value');
|
||||||
|
@ -434,7 +434,8 @@ $(document).ready(function(){
|
||||||
if(index < this.length - 1){
|
if(index < this.length - 1){
|
||||||
for(var i = index + 1;i < this.length; i++){
|
for(var i = index + 1;i < this.length; i++){
|
||||||
change_object_variables(lpv_real[i] , lpv_dict[arguments[0]] , '-' , 'self');
|
change_object_variables(lpv_real[i] , lpv_dict[arguments[0]] , '-' , 'self');
|
||||||
var servive_ratio = round((Math.exp(lpv_calc[year])**Math.exp(lpv_real[i]))*100,2);
|
var lpv_current = lpv_real[i];
|
||||||
|
var servive_ratio = round(eval(lpv_calc[year])*100,2);
|
||||||
servive_ratio_arr[i] = servive_ratio;
|
servive_ratio_arr[i] = servive_ratio;
|
||||||
var benefit = servive_ratio - ((i == index+1) ? servive_ratio_arr[index - 1] : servive_ratio_arr[i - 1]);
|
var benefit = servive_ratio - ((i == index+1) ? servive_ratio_arr[index - 1] : servive_ratio_arr[i - 1]);
|
||||||
$('tr.'+active_treatment[i]+' td.Overall_Survival').html(servive_ratio+'%');
|
$('tr.'+active_treatment[i]+' td.Overall_Survival').html(servive_ratio+'%');
|
||||||
|
@ -686,28 +687,26 @@ function calculate_first_lpv(result_json){
|
||||||
index++;
|
index++;
|
||||||
});
|
});
|
||||||
result['N4'] = (2 - Number(result_json['N4']));
|
result['N4'] = (2 - Number(result_json['N4']));
|
||||||
result['O20'] = (2 - Number(result_json['O20']));
|
|
||||||
result['O18'] = (2 - Number(result_json['O18']));
|
|
||||||
result['N12'] = (2 - Number(result_json['N12']));
|
result['N12'] = (2 - Number(result_json['N12']));
|
||||||
result['N20'] = (2 - Number(result_json['N20']));
|
result['N20'] = (2 - Number(result_json['N20']));
|
||||||
result['N31'] = (2 - Number(result_json['N31']));
|
result['N31'] = (2 - Number(result_json['N31']));
|
||||||
result['O6'] = (2 - Number(result_json['O6']));
|
result['O6'] = (2 - Number(result_json['O6']));
|
||||||
result['N34'] = (2 - Number(result_json['N34']));
|
result['N34'] = (2 - Number(result_json['N34']));
|
||||||
result['N46'] = (2 - Number(result_json['N46']));
|
|
||||||
result['N14'] = (2 - Number(result_json['N14']));
|
result['N14'] = (2 - Number(result_json['N14']));
|
||||||
result['N29'] = (2 - Number(result_json['N29']));
|
|
||||||
result['N2'] = (2 - Number(result_json['N2']));
|
|
||||||
result['N26'] = (2 - Number(result_json['N26']));
|
result['N26'] = (2 - Number(result_json['N26']));
|
||||||
|
result['O3'] = (2 - Number(result_json['O3']));
|
||||||
|
result['O20'] = (2 - Number(result_json['O20']));
|
||||||
|
result['O18'] = (2 - Number(result_json['O18']));
|
||||||
result['O11'] = (2 - Number(result_json['O11']));
|
result['O11'] = (2 - Number(result_json['O11']));
|
||||||
|
result['N29'] = (2 - Number(result_json['N29']));
|
||||||
result['N6'] = (2 - Number(result_json['N6']));
|
result['N6'] = (2 - Number(result_json['N6']));
|
||||||
result['O14'] = (2 - Number(result_json['O14']));
|
result['O14'] = (2 - Number(result_json['O14']));
|
||||||
result['N43'] = (2 - Number(result_json['N43']));
|
result['N43'] = (2 - Number(result_json['N43']));
|
||||||
result['O3'] = (2 - Number(result_json['O3']));
|
|
||||||
result['O17'] = (2 - Number(result_json['O17']));
|
result['O17'] = (2 - Number(result_json['O17']));
|
||||||
result['O9'] = (2 - Number(result_json['O9']));
|
result['O9'] = (2 - Number(result_json['O9']));
|
||||||
|
|
||||||
try{
|
try{
|
||||||
result['lpv'] = (A = 0.1327868* (result["sex_value"]- 0.4858824) + 0.0371720* (result["age_test1"] - 61.56000) -0.07447278* (result["age_test2"] - 13.10152) + 0.4315686* (result["age_test3"] - 0.9844332) + 0.0009163615*( result["calH_test1"] - 182.9347) -0.0007536899*( result["calH_test2"] - 124.8706) -0.0004697183*( result["calH_test3"] -80.75636) + 0.0001401325*( result["calAH_test1"] - 700.7824) -0.001349783*( result["calAH_test2"] - 634.2167) +0.001753832*( result["calAH_test3"] -419.3361) + 0.0001906046*( result["calDH_test1"] -835.2894) -0.000251567*( result["calDH_test2"] - 213.1630) -0.002173942*( result["fat_test1"] -108.4149)+0.003066541*( result["fat_test2"] - 28.33497) +0.6700708*(result["N4"]-0.3241176) +0.3336162*(result["O3"]-0.4994118) +0.1322476*(result["O20"]-0.1741176) +0.9084972*(result["O18"]-0.008823529) +0.2978388*(result["N12"]-0.1152941) +0.1777935*(result["N20"]-0.3582353) +1.588042*(result["N31"]-0.002352941) +0.2197419*(result["O6"]-0.07823529) +1.791159*(result["N34"]-0.001176471) -14.02639*(result["N46"]-0.003529412) +0.4305973*(result["N14"]-0.02176471) -0.4472885*(result["N29"]-0.02411765) -1.570431*(result["N20"]-0.0005882353) +0.2601319*(result["N26"]-0.04941176) -0.2364269*(result["O11"]-0.1164706) +0.1784179*(result["N6"]-0.1070588) +0.6023170*(result["O14"]-0.01294118) -1.031959*(result["N43"]-0.007058824) +0.4257809*(result["O17"]-0.01823529) +0.2002546*(result["O9"]-0.06176471));
|
result['lpv'] = (A = 0.1327868* (result["sex_value"]- 0.4858824) + 0.0371720* (result["age_test1"] - 61.56000) -0.07447278* (result["age_test2"] - 13.10152) + 0.4315686* (result["age_test3"] - 0.9844332) + 0.0009163615*( result["calH_test1"] - 182.9347) -0.0007536899*( result["calH_test2"] - 124.8706) -0.00004697183*( result["calH_test3"] -80.75636) + 0.0001401325*( result["calAH_test1"] - 700.7824) -0.001349783*( result["calAH_test2"] - 634.2167) +0.001753832*( result["calAH_test3"] -419.3361) + 0.0001906046*( result["calDH_test1"] -835.2894) -0.000251567*( result["calDH_test2"] - 213.1630) -0.002173942*( result["fat_test1"] -108.4149)+0.003066541*( result["fat_test2"] - 28.33497) +0.6700708*(result["N4"]-0.3241176) +0.3336162*(result["O3"]-0.4994118) +0.1322476*(result["O20"]-0.1741176) +0.9084972*(result["O18"]-0.008823529) +0.2978388*(result["N12"]-0.1152941) +0.1777935*(result["N20"]-0.3582353) +1.588042*(result["N31"]-0.002352941) +0.2197419*(result["O6"]-0.07823529) +1.791159*(result["N34"]-0.001176471) +0.4305973*(result["N14"]-0.02176471) -0.4472885*(result["N29"]-0.02411765) +0.2601319*(result["N26"]-0.04941176) -0.2364269*(result["O11"]-0.1164706) +0.1784179*(result["N6"]-0.1070588) +0.6023170*(result["O14"]-0.01294118) -1.031959*(result["N43"]-0.007058824) +0.4257809*(result["O17"]-0.01823529) +0.2002546*(result["O9"]-0.06176471));
|
||||||
}catch(e){result['lpv'] = "error"};
|
}catch(e){result['lpv'] = "error"};
|
||||||
console.log(result['lpv']);
|
console.log(result['lpv']);
|
||||||
result['lpv_variable']['A'] = A;
|
result['lpv_variable']['A'] = A;
|
||||||
|
@ -731,25 +730,20 @@ function calculate_first_lpv(result_json){
|
||||||
|
|
||||||
function calculate_servive_ratio(year,obj){
|
function calculate_servive_ratio(year,obj){
|
||||||
var servive_ratio;
|
var servive_ratio;
|
||||||
|
|
||||||
var A = obj['A'];
|
var A = obj['A'];
|
||||||
switch(year) {
|
switch(year) {
|
||||||
case '1':
|
case '1':
|
||||||
servive_ratio = 0.8095037**( Math.exp(A) );
|
servive_ratio = 0.8095037**( Math.exp(A) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '1.5':
|
case '1.5':
|
||||||
servive_ratio = 0.729158**( Math.exp(A) );
|
servive_ratio = 0.729158**( Math.exp(A) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '2':
|
case '2':
|
||||||
servive_ratio = 0.6717211**( Math.exp(A) );
|
servive_ratio = 0.6717211**( Math.exp(A) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '2.5':
|
case '2.5':
|
||||||
servive_ratio = 0.6056773**( Math.exp(A) );
|
servive_ratio = 0.6056773**( Math.exp(A) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
console.log('not found year.');
|
console.log('not found year.');
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,7 +191,7 @@ class Cancerpredictfields
|
||||||
if property[:is_num] == 1
|
if property[:is_num] == 1
|
||||||
js_code += "\t\t\t\tresult['#{@variable}'] = Number(result_json['#{@variable}']);\r\n"
|
js_code += "\t\t\t\tresult['#{@variable}'] = Number(result_json['#{@variable}']);\r\n"
|
||||||
elsif property[:choice_fields].present?
|
elsif property[:choice_fields].present?
|
||||||
if property[:map_values].class == Array && property[:choice_fields].class == Array && property[:map_values].length == property[:choice_fields].length
|
if property[:need_map_values] == 1
|
||||||
js_code += "\t\t\t\tmap_values = #{property[:map_values]};\r\n"
|
js_code += "\t\t\t\tmap_values = #{property[:map_values]};\r\n"
|
||||||
js_code += "\t\t\t\tresult['#{@variable}'] = map_values[Number(result_json['#{@variable}'']) - 1];\r\n"
|
js_code += "\t\t\t\tresult['#{@variable}'] = map_values[Number(result_json['#{@variable}'']) - 1];\r\n"
|
||||||
else
|
else
|
||||||
|
@ -236,7 +236,7 @@ class Cancerpredictfields
|
||||||
result = {};
|
result = {};
|
||||||
#{js_code}
|
#{js_code}
|
||||||
try{
|
try{
|
||||||
result['lpv'] = (#{formula});
|
result['lpv'] = (#{formula.gsub(/\s{2,10}/," ")});
|
||||||
}catch(e){result['lpv'] = \"error\"};
|
}catch(e){result['lpv'] = \"error\"};
|
||||||
console.log(result['lpv']);
|
console.log(result['lpv']);
|
||||||
#{formula_variables.map{|v| "result['lpv_variable']['#{v}'] = #{v};"}.join("\r\n\t\t\t\t") }
|
#{formula_variables.map{|v| "result['lpv_variable']['#{v}'] = #{v};"}.join("\r\n\t\t\t\t") }
|
||||||
|
@ -259,7 +259,7 @@ class Cancerpredictfields
|
||||||
};"
|
};"
|
||||||
@years = self.years
|
@years = self.years
|
||||||
switch_texts = "
|
switch_texts = "
|
||||||
#{formula_variables.map{|v| "var #{v} = obj['#{v}'];"}.join("\r\n\t\t\t\t")}
|
#{formula_variables.map{|v| "var #{v} = obj['#{v}'];"}.join("\n ")}
|
||||||
switch(year) {"
|
switch(year) {"
|
||||||
@years.each do |year|
|
@years.each do |year|
|
||||||
year_index = @years.index(year)
|
year_index = @years.index(year)
|
||||||
|
@ -267,8 +267,7 @@ class Cancerpredictfields
|
||||||
"
|
"
|
||||||
case '#{year}':
|
case '#{year}':
|
||||||
servive_ratio = #{self.tmp_years_settings[year_index]};
|
servive_ratio = #{self.tmp_years_settings[year_index]};
|
||||||
break;
|
break;"
|
||||||
"
|
|
||||||
end
|
end
|
||||||
switch_texts += "
|
switch_texts += "
|
||||||
default:
|
default:
|
||||||
|
@ -277,8 +276,7 @@ class Cancerpredictfields
|
||||||
js_code = js_code +"
|
js_code = js_code +"
|
||||||
|
|
||||||
function calculate_servive_ratio(year,obj){
|
function calculate_servive_ratio(year,obj){
|
||||||
var servive_ratio;
|
var servive_ratio;#{switch_texts}
|
||||||
#{switch_texts}
|
|
||||||
return servive_ratio;
|
return servive_ratio;
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
|
|
Loading…
Reference in New Issue