push from final_version to master

This commit is contained in:
BOHUNG 2020-01-28 18:29:04 +08:00
parent 294d98f83f
commit 62045584fc
10 changed files with 301 additions and 252 deletions

View File

@ -15,6 +15,9 @@ $(document).ready(function(){
$('#cancer_table .cencer_table_name').css('max-width','39%'); $('#cancer_table .cencer_table_name').css('max-width','39%');
}; };
}; };
function round(num,Digit){
return Math.round(Number(num)*(10**Digit))/(10**Digit);
};
head_data.done(function(){ head_data.done(function(){
// $('.header-nav').html(head_images.responseJSON['head_images']); // $('.header-nav').html(head_images.responseJSON['head_images']);
// $('.navbar-brand').html(head_images.responseJSON['title']) // $('.navbar-brand').html(head_images.responseJSON['title'])
@ -353,11 +356,11 @@ $(document).ready(function(){
var year = $('#current_year').attr('value'); var year = $('#current_year').attr('value');
var lpv_current = lpv_real[lpv_real.length-1]+lpv_dict[arguments[0]]; var lpv_current = lpv_real[lpv_real.length-1]+lpv_dict[arguments[0]];
lpv_real.push(lpv_current); lpv_real.push(lpv_current);
var servive_ratio = Math.round((Math.exp(lpv_calc[year])**Math.exp(lpv_current))*100); var servive_ratio = round((Math.exp(lpv_calc[year])**Math.exp(lpv_current))*100,2);
var benefit = servive_ratio - servive_ratio_arr[servive_ratio_arr.length - 1]; var benefit = servive_ratio - servive_ratio_arr[servive_ratio_arr.length - 1];
servive_ratio_arr.push(servive_ratio); servive_ratio_arr.push(servive_ratio);
$('tr.'+arguments[0]+' td.Overall_Survival').html(servive_ratio+'%'); $('tr.'+arguments[0]+' td.Overall_Survival').html(servive_ratio+'%');
$('tr.'+arguments[0]+' td.Additional_Benefit').html(benefit+'%'); $('tr.'+arguments[0]+' td.Additional_Benefit').html(round(benefit,2)+'%');
$('tr.'+arguments[0]).css('display','table-row'); $('tr.'+arguments[0]).css('display','table-row');
$('tr.tr_show').eq(-1).after($('tr.'+arguments[0])); $('tr.tr_show').eq(-1).after($('tr.'+arguments[0]));
$('tr.'+arguments[0]).addClass('tr_show'); $('tr.'+arguments[0]).addClass('tr_show');
@ -378,9 +381,9 @@ $(document).ready(function(){
add_choices_str = add_choices_transform[0]; add_choices_str = add_choices_transform[0];
var extra_therapy_texts = result.responseJSON['extra_therapy_texts']; var extra_therapy_texts = result.responseJSON['extra_therapy_texts'];
extra_therapy_texts = extra_therapy_texts.replace('{{extra_therapy}}','</span><span class="'+arguments[0]+' choices">'+add_choices_str+'</span><span>'); extra_therapy_texts = extra_therapy_texts.replace('{{extra_therapy}}','</span><span class="'+arguments[0]+' choices">'+add_choices_str+'</span><span>');
extra_therapy_texts = extra_therapy_texts.replace('{{survival_num}}','</span><span class="'+arguments[0]+' Overall_Survival">'+servive_ratio+'</span><span>'); extra_therapy_texts = extra_therapy_texts.replace('{{survival_num}}','</span><span class="'+arguments[0]+' Overall_Survival">'+Math.round(servive_ratio)+'</span><span>');
extra_therapy_texts = extra_therapy_texts.replace('{{surgery_year}}','</span><span class="surgery_year">'+year+'</span><span>'); extra_therapy_texts = extra_therapy_texts.replace('{{surgery_year}}','</span><span class="surgery_year">'+year+'</span><span>');
extra_therapy_texts = extra_therapy_texts.replace('{{Additional_Benefit}}','</span><span class="'+arguments[0]+' Additional_Benefit">'+benefit+'</span><span>'); extra_therapy_texts = extra_therapy_texts.replace('{{Additional_Benefit}}','</span><span class="'+arguments[0]+' Additional_Benefit">'+Math.round(benefit)+'</span><span>');
var new_text = '<p class="texts_show"><span>'; var new_text = '<p class="texts_show"><span>';
new_text += (extra_therapy_texts+'</span></p>'); new_text += (extra_therapy_texts+'</span></p>');
$('#result_text_content .extra-text .texts_show').eq(-1).after(new_text) $('#result_text_content .extra-text .texts_show').eq(-1).after(new_text)
@ -396,13 +399,13 @@ $(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++){
lpv_real[i] -= lpv_dict[arguments[0]]; lpv_real[i] -= lpv_dict[arguments[0]];
var servive_ratio = Math.round((Math.exp(lpv_calc[year])**Math.exp(lpv_real[i]))*100); var servive_ratio = round((Math.exp(lpv_calc[year])**Math.exp(lpv_real[i]))*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+'%');
$('.'+active_treatment[i]+'.Overall_Survival').html(servive_ratio); $('.'+active_treatment[i]+'.Overall_Survival').html(Math.round(servive_ratio));
$('tr.'+active_treatment[i]+' td.Additional_Benefit').html(benefit+'%'); $('tr.'+active_treatment[i]+' td.Additional_Benefit').html(round(benefit,2)+'%');
$('.'+active_treatment[i]+'.Additional_Benefit').html(benefit); $('.'+active_treatment[i]+'.Additional_Benefit').html(Math.round(benefit));
}; };
var add_choices = []; var add_choices = [];
for(var i = 1;i < this.length; i++){ for(var i = 1;i < this.length; i++){
@ -412,9 +415,9 @@ $(document).ready(function(){
for(var j = 0;j<add_choices.length;j++){ for(var j = 0;j<add_choices.length;j++){
add_choices_transform.push($('[for="'+add_choices[j]+'"]').html()) add_choices_transform.push($('[for="'+add_choices[j]+'"]').html())
}; };
var add_choices_str = add_choices_transform.slice(0,add_choices_transform.length-1).join('、'); var add_choices_str = (I18n.locale == 'en' ? add_choices_transform.slice(0,add_choices_transform.length-1).join(', ') : add_choices_transform.slice(0,add_choices_transform.length-1).join('、'));
if(add_choices_transform.length >= 2) if(add_choices_transform.length >= 2)
add_choices_str += ('以及'+add_choices_transform[add_choices_transform.length-1]) add_choices_str += ((I18n.locale == 'en' ? ', and ': '以及')+add_choices_transform[add_choices_transform.length-1])
else else
add_choices_str = add_choices_transform[0]; add_choices_str = add_choices_transform[0];
$('.'+active_treatment[i]+'.choices').html(add_choices_str); $('.'+active_treatment[i]+'.choices').html(add_choices_str);
@ -425,15 +428,17 @@ $(document).ready(function(){
$('tr.'+arguments[0]+' td.Additional_Benefit').html('-'); $('tr.'+arguments[0]+' td.Additional_Benefit').html('-');
$('tr.'+arguments[0]).css('display','none'); $('tr.'+arguments[0]).css('display','none');
$('tr.'+arguments[0]).removeClass('tr_show'); $('tr.'+arguments[0]).removeClass('tr_show');
$('a.'+arguments[0]).eq(0).parent().remove(); $('span.'+arguments[0]).eq(0).parent().remove();
lpv_real = lpv_real.remove_item_from_array(lpv_real[index]); lpv_real = lpv_real.remove_item_from_array(lpv_real[index]);
servive_ratio_arr = servive_ratio_arr.remove_item_from_array(servive_ratio_arr[index]); servive_ratio_arr = servive_ratio_arr.remove_item_from_array(servive_ratio_arr[index]);
if(this.length == 2){ if(this.length == 2){
$('.addition').css('display','none'); $('.addition').css('display','none');
$('#result_text_content .extra-text').css('display','none'); $('#result_text_content .extra-text').css('display','none');
}; };
console.log(this)
return Array.prototype.remove_item_from_array.apply(this, arguments); return Array.prototype.remove_item_from_array.apply(this, arguments);
}else{ }else{
console.log(this)
return Array.prototype.remove_item_from_array.apply(this, arguments); return Array.prototype.remove_item_from_array.apply(this, arguments);
}; };
}; };
@ -544,17 +549,17 @@ $(document).ready(function(){
function calculate_and_change_result_value(obj){ function calculate_and_change_result_value(obj){
obj.servive_ratio_arr = []; obj.servive_ratio_arr = [];
for(var i = 0;i<obj.active_treatment.length;i++){ for(var i = 0;i<obj.active_treatment.length;i++){
var servive_ratio = Math.round((Math.exp(obj.lpv_calc[obj.year])**Math.exp(obj.lpv_real[i]))*100); var servive_ratio = round((Math.exp(obj.lpv_calc[obj.year])**Math.exp(obj.lpv_real[i]))*100,2);
var benefit = servive_ratio - obj.servive_ratio_arr[obj.servive_ratio_arr.length-1]; var benefit = servive_ratio - obj.servive_ratio_arr[obj.servive_ratio_arr.length-1];
obj.servive_ratio_arr.push(servive_ratio); obj.servive_ratio_arr.push(servive_ratio);
$('tr.'+obj.active_treatment[i]+' td.Overall_Survival').html(servive_ratio+'%'); $('tr.'+obj.active_treatment[i]+' td.Overall_Survival').html(servive_ratio+'%');
$('.'+obj.active_treatment[i]+'.Overall_Survival').html(servive_ratio); $('.'+obj.active_treatment[i]+'.Overall_Survival').html(Math.round(servive_ratio));
if(i != 0){ if(i != 0){
$('tr.'+obj.active_treatment[i]+' td.Additional_Benefit').html(benefit+'%'); $('tr.'+obj.active_treatment[i]+' td.Additional_Benefit').html(round(benefit,2)+'%');
$('.'+obj.active_treatment[i]+'.Additional_Benefit').html(benefit); $('.'+obj.active_treatment[i]+'.Additional_Benefit').html(Math.round(benefit));
} }
} }
$('.'+obj.active_treatment[0]+'.Overall_Survival').html(obj.servive_ratio_arr[0]); $('.'+obj.active_treatment[0]+'.Overall_Survival').html(Math.round(obj.servive_ratio_arr[0]));
}; };
function after_submit_change_func(obj){ function after_submit_change_func(obj){
var post_json = get_input_data(); var post_json = get_input_data();
@ -615,7 +620,7 @@ $(document).ready(function(){
result['pstage'] = 4 result['pstage'] = 4
if((Number(result_json['ER_status']) != 2 || Number(result_json['PR_status']) != 2) && (Number(result_json['HER2_status']) != 1)) if((Number(result_json['ER_status']) != 2 || Number(result_json['PR_status']) != 2) && (Number(result_json['HER2_status']) != 1))
result['subtype'] = 1; result['subtype'] = 1;
else if(Number(result_json['ER_status']) == 2 && Number(result_json['PR_status']) == 2 && (Number(result_json['HER2_status']) == 1)) else if(Number(result_json['HER2_status']) == 1)
result['subtype'] = 2; result['subtype'] = 2;
else if(Number(result_json['ER_status']) == 2 && Number(result_json['PR_status']) == 2 && (Number(result_json['HER2_status']) != 1)) else if(Number(result_json['ER_status']) == 2 && Number(result_json['PR_status']) == 2 && (Number(result_json['HER2_status']) != 1))
result['subtype'] = 3; result['subtype'] = 3;

View File

@ -6,6 +6,14 @@
.head_logo{ .head_logo{
height: 4em; height: 4em;
} }
.texts_under_result{
font-weight: bold;
padding-top: 1em;
color: #5d7ca2;
}
th.cancer_th.Treatment {
width: 39%;
}
@media screen and (max-width: 48em){ @media screen and (max-width: 48em){
.navbar-brand{ .navbar-brand{
width: 100%; width: 100%;
@ -209,7 +217,7 @@ input.float_num{
color: #5d7ca2; color: #5d7ca2;
} }
#result_contents{ #result_contents{
padding-top: 2em; padding-top: 1em;
} }
#choice_fields{ #choice_fields{
padding: 2em 0 0 calc(20% - 1.625em); padding: 2em 0 0 calc(20% - 1.625em);
@ -232,12 +240,12 @@ input.float_num{
color: white; color: white;
} }
.result_tab_group{ .result_tab_group{
width: 20%; width: 15%;
margin: 0; margin: 0;
float: left; float: left;
} }
.result_content_group{ .result_content_group{
width: 80%; width: 85%;
margin: 0; margin: 0;
float: right; float: right;
} }

View File

@ -32,6 +32,14 @@ button, input, select, textarea {
.head_logo{ .head_logo{
height: 4em; height: 4em;
} }
.texts_under_result{
font-weight: bold;
padding-top: 1em;
color: #5d7ca2;
}
th.cancer_th.Treatment {
width: 39%;
}
div.num_group{ div.num_group{
position: relative; position: relative;
float: left; float: left;
@ -210,7 +218,7 @@ input.float_num{
color: #5d7ca2; color: #5d7ca2;
} }
#result_contents{ #result_contents{
padding-top: 2em; padding-top: 1em;
} }
#choice_fields{ #choice_fields{
padding: 2em 0 0 calc(20% - 1.625em); padding: 2em 0 0 calc(20% - 1.625em);
@ -233,12 +241,12 @@ input.float_num{
color: white; color: white;
} }
.result_tab_group{ .result_tab_group{
width: 20%; width: 15%;
margin: 0; margin: 0;
float: left; float: left;
} }
.result_content_group{ .result_content_group{
width: 80%; width: 85%;
margin: 0; margin: 0;
float: right; float: right;
} }

View File

@ -87,7 +87,7 @@ class Admin::CancerpredictsController < OrbitAdminController
end end
end end
end end
@create_items = ['title_texts','form_result_is_right','text_descibe','years','table_above_texts','text_above_texts','surgery_only_texts','extra_texts','extra_therapy_texts','danger_texts'] @create_items = ['title_texts','form_result_is_right','text_descibe','years','table_above_texts','text_above_texts','surgery_only_texts','extra_texts','extra_therapy_texts','danger_texts','texts_between_Result_and_result_block']
params_cancer = params.require("cancerpredictfields").permit! params_cancer = params.require("cancerpredictfields").permit!
@create_items.each do |item| @create_items.each do |item|
if (@form_to_show[item].class == BSON::Document) || (@form_to_show.send(item).class == Hash) if (@form_to_show[item].class == BSON::Document) || (@form_to_show.send(item).class == Hash)
@ -190,6 +190,14 @@ class Admin::CancerpredictsController < OrbitAdminController
@index += 1 @index += 1
end end
end end
Dir.chdir("public") do
@site_locales = Site.last.in_use_locales.each do |locale|
@file_tmp = File.new('cancer_tool_table_tmp_'+locale.to_s+'.txt', 'w')
tmp_table_texts = create_table(locale)
@file_tmp.write(tmp_table_texts)
@file_tmp.close
end
end
Dir.chdir("public") do Dir.chdir("public") do
@file_back = File.open('cancerfield_back'+@index.to_s+'.txt', 'w') @file_back = File.open('cancerfield_back'+@index.to_s+'.txt', 'w')
@file_back.write(@form_to_show.attributes) @file_back.write(@form_to_show.attributes)
@ -200,6 +208,234 @@ class Admin::CancerpredictsController < OrbitAdminController
end end
redirect_to admin_cancerpredicts_path redirect_to admin_cancerpredicts_path
end end
def create_table(current_locale)
create_first_field
current_site = Site.last
@size = {}
@size_name = ['small','medium','large']
@size_name.each{|name| @size[name] = @form_to_show[name]['font_size']}
@size_active_size = ''
@size.each{|size_key,size_value| (@form_to_show[size_key]['active'].to_i == 1) ? ( @size_active_size = size_value ): nil }
@table_str = '<div id="cancer_table" style="font-size:' + @size_active_size + ';"><div id="show_help_modal" class="modal fade"></div>'
@table_str += '<div id="cancer_table_top"><div id="text_describe">'+@form_to_show.text_descibe[current_locale] +'</div>'
@table_str += '<div id="font_size_choices">'+'<label id="font_texts">'+t('cancerpredict.font_size').titleize+':</label>'
@size.each{|size_key,size_value| @table_str += ('<button class="cancer_table_btn '+((@form_to_show[size_key]['active'].to_i == 1) ? 'active' :'') + ' btn btn-default btn-sm" onclick="document.getElementById(\'cancer_table\').style[\'font-size\']=\''+size_value+'\';document.getElementById(\'cancer_predict_result_block\').style[\'font-size\']=\''+size_value+'\';">'+t('cancerpredict.'+size_key).titleize+'</button>' )}
@table_str += '</div></div><div style="clear:both;"></div>'
@table_str_left = '<div id="cancer_table_left">'
@table_str_right = '<div id="cancer_table_right">'
@form_to_show.form_show.each do |num,property|
@field_property = {}
property.each do |key,value|
@value= value
if @value.class == BSON::Document || @value.class == Hash
@disp_value = @value[current_locale] rescue ""
else
@disp_value = @value
end
@field_property[key] = @disp_value
end
if @field_property['right'] == 0
@table_str_left += '<div data-key='+num.to_s+'>'
break if @field_property["name"] == ""
@table_str_left += '<label for="'+@field_property["variable"]+'" style="float:left;'+(@field_property["comment_text"] == "" ? "margin-right: 2.125em;" : "")+'" class="cencer_table_name">'
@table_str_left += @field_property["name"]
@table_str_left += '</label>'
if @field_property["comment_text"] != ""
@table_str_left += '<button tabindex="0" class="cancer_help_btn" data-target="#show_help_modal" style="float:left;cursor: pointer;padding: 0em 0.475em;font-size: 1.25em;border-radius: 15px;background-color: rgb(210, 106, 2);border-color: rgb(210, 106, 2);color: white;"><i aria-hidden="true" class="fa fa-question"></i></button>'
@table_str_left += '<input class="help_texts" type="hidden" value="'+@field_property["comment_text"]+'" name='+@field_property["variable"]+'/>'
else
@site_locales = current_site.in_use_locales
@site_locales.delete(current_locale)
@site_locales.each do |locale|
next if property["comment_text"][locale.to_s] == ""
@field_property["comment_text"] = property["comment_text"][locale.to_s]
break
end
if @field_property["comment_text"] != ""
@table_str_left += '<button tabindex="0" class="cancer_help_btn" data-target="#show_help_modal" style="float:left;cursor: pointer;padding: 0em 0.475em;font-size: 1.25em;border-radius: 15px;background-color: rgb(210, 106, 2);border-color: rgb(210, 106, 2);color: white;"><i aria-hidden="true" class="fa fa-question"></i></button>'
@table_str_left += '<input class="help_texts" type="hidden" value="'+@field_property["comment_text"]+'" name='+@field_property["variable"]+'/>'
else
@table_str_left += '<div style="margin-right: 2.125em;float: left;"></div>'
end
end
if @field_property["is_num"] == 1
if @field_property["is_float"] == 1
@table_str_left += '<div class="num_group"><input class="num_only float_num cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'"/></div>'
else
@table_str_left += '<div class="num_group"><form class="for_num">'
@table_str_left += '<input class="num_only cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'" onkeyup="value=value.replace(/[^\d]/g,\'\') "onbeforepaste="clipboardData.setData(\'text\',clipboardData.getData(\'text\').replace(/[^\d]/g,\'\'))"/>'
@table_str_left += '<input class="num_only_value" type="hidden" value="0"/>'
@please_choice = (current_locale.to_s == "zh_tw") ? "請選擇" : "Please choice"
@table_str_left += '<select class="select_num"><option value="">'+@please_choice+'</option>'
if @field_property["choice_fields"] != []
@field_property["choice_fields"].each do |choice|
@table_str_left += ('<option value="0">' + choice.to_s.titleize + '</option>')
end
end
for @num in @field_property["range"][0] .. @field_property["range"][1]
@table_str_left += ('<option value="' + @num.to_s + '">' + @num.to_s + '</option>')
end
@table_str_left += '</select></form></div>'
end
else
@table_str_left += '<div class= "cancer-btn-group cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;">'
@field_property["choice_fields"].each do |create_choice|
@table_str_left += '<button class="cancer_table_btn btn btn-default btn-sm">'+create_choice.titleize+'</button>'
@table_str_left += '<input type="hidden" value="0" name="'+create_choice+'"/>'
end
@table_str_left += '</div>'
end
if @field_property["hint"].to_s != ""
@table_str_left +='<div style="color: rgb(104, 104, 104);font-size:0.75em;clear:both;">'+@field_property["hint"]+'</div>'
end
@table_str_left += '</div><div style="clear:both;"></div>'
else
@table_str_right += '<div data-key='+num.to_s+'>'
break if @field_property["name"] == ""
@table_str_right += '<label for="'+@field_property["variable"]+'" style="float:left;'+(@field_property["comment_text"] == "" ? "margin-right: 2.125em;" : "")+'" class="cencer_table_name">'
@table_str_right += @field_property["name"]
@table_str_right += '</label>'
if @field_property["comment_text"] != ""
@table_str_right += '<button tabindex="0" class="cancer_help_btn" data-target="#show_help_modal" style="float:left;cursor: pointer;padding: 0em 0.475em;font-size: 1.25em;border-radius: 15px;background-color: rgb(210, 106, 2);border-color: rgb(210, 106, 2);color: white;"><i aria-hidden="true" class="fa fa-question"></i></button>'
@table_str_right += '<input class="help_texts" type="hidden" value="'+@field_property["comment_text"]+'" name='+@field_property["variable"]+'/>'
else
@site_locales = current_site.in_use_locales
@site_locales.delete(current_locale)
@site_locales.each do |locale|
next if property["comment_text"][locale.to_s] == ""
@field_property["comment_text"] = property["comment_text"][locale.to_s]
break
end
if @field_property["comment_text"] != ""
@table_str_right += '<button tabindex="0" class="cancer_help_btn" data-target="#show_help_modal" style="float:left;cursor: pointer;padding: 0em 0.475em;font-size: 1.25em;border-radius: 15px;background-color: rgb(210, 106, 2);border-color: rgb(210, 106, 2);color: white;"><i aria-hidden="true" class="fa fa-question"></i></button>'
@table_str_right += '<input class="help_texts" type="hidden" value="'+@field_property["comment_text"]+'" name='+@field_property["variable"]+'/>'
else
@table_str_right += '<div style="margin-right: 2.125em;float: left;"></div>'
end
end
if @field_property["is_num"] == 1
if @field_property["is_float"] == 1
@table_str_right += '<div class="num_group"><input class="num_only float_num cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'"/><button class="btn-sub"></button><button class="btn-add"></button></div>'
else
@table_str_right += '<div class="num_group"><form class="for_num">'
@table_str_right += '<input class="num_only cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'" onkeyup="value=value.replace(/[^\d]/g,\'\') "onbeforepaste="clipboardData.setData(\'text\',clipboardData.getData(\'text\').replace(/[^\d]/g,\'\'))"/>'
@table_str_right += '<input class="num_only_value" type="hidden" value="0"/>'
@please_choice = (current_locale.to_s == "zh_tw") ? "請選擇" : "Please choice"
@table_str_right += '<select class="select_num"><option value="">'+@please_choice+'</option>'
if @field_property["choice_fields"] != []
@field_property["choice_fields"].each do |choice|
@table_str_right += ('<option value="0">' + choice.to_s.titleize + '</option>')
end
end
for @num in @field_property["range"][0] .. @field_property["range"][1]
@table_str_right += ('<option value="' + @num.to_s + '">' + @num.to_s + '</option>')
end
@table_str_right += '</select></form></div>'
end
else
@table_str_right += '<div class= "cancer-btn-group cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;">'
@field_property["choice_fields"].each do |create_choice|
@table_str_right += '<button class="cancer_table_btn btn btn-default btn-sm">'+create_choice.titleize+'</button>'
@table_str_right += '<input type="hidden" value="0" name="'+create_choice+'"/>'
end
@table_str_right += '</div>'
end
if @field_property["hint"].to_s != ""
@table_str_right +='<div class="hint-texts">'+@field_property["hint"]+'</div>'
end
@table_str_right += '</div><div style="clear:both;"></div>'
end
end
@table_str_left += '</div>'
@table_str_right += '</div>'
@table_str += (@table_str_left+@table_str_right)
@table_str +='<div style="clear:both;"></div>'
@table_result_str = '<div id="cancer_predict_result" style="'+((@form_to_show.form_result_is_right == 0) ? 'float:right;' : '')+'"><span class="result_title">'+t("cancerpredict.table.result").to_s+'</span><div style="clear:both;"></div>'
@tab_name = ['table','text']
@table_result_str +='<div class="texts_under_result">' + @form_to_show.texts_between_Result_and_result_block[current_locale]+'</div>'
@table_result_str += '<div id="result_contents"><div class="result_tab_group">'
@tab_name.each_with_index{|name,index| @table_result_str += ('<div id="result_'+name+'_tab" class="result_tab'+((index != 0) ? "" : " active")+'"><a>'+t("cancerpredict.table."+name).to_s+'</a></div><div style="clear:both;"></div>')}
@table_result_str += '</div><div class="result_content_group">'
@tab_name.each{|name| @table_result_str += '<div id="result_'+name+'_content" class="result_content"><a>'+'no content'+'</a></div>'}
@table_result_str += '</div></div></div>'
@table_button = '<div id="cancer_table_button_group">'
@submit_btn_str='<button id="cancer_table_submit">'+t('cancerpredict.table.Submit').to_s+'</button>'
@reset_btn_str='<button id="cancer_table_reset">'+t('cancerpredict.table.Reset').to_s+'</button>'
@table_button += (@submit_btn_str+@reset_btn_str+'<div style="clear:both;"></div></div></div>')
@table_result_choice_fileds = '<div id="cancer_table_right_result">' if @form_to_show.form_result_is_right == 1
@table_result_choice_fileds = '<div id="cancer_table_left_result">' if @form_to_show.form_result_is_right == 0
@table_result_choice_fileds += '<span class="result_title">'+t('cancerpredict.table.Therapy_choice').to_s+'</span><div style="clear:both;"></div>'
@table_result_choice_fileds += '<div id="choice_fields">'
@form_to_show.form_show_in_result.each do |num,property|
@field_property = {}
property.each do |key,value|
@value= value
if @value.class == BSON::Document || @value.class == Hash
@disp_value = @value[current_locale.to_s] rescue ""
else
@disp_value = @value
end
@field_property[key] = @disp_value
end
@table_result_choice_fileds += '<div data-key='+num.to_s+'>'
break if @field_property["name"] == ""
@table_result_choice_fileds += '<label for="'+@field_property["variable"]+'" style="float:left;'+(@field_property["comment_text"] == "" ? "margin-right: 2.125em;" : "")+'" class="cencer_table_name">'
@table_result_choice_fileds += @field_property["name"]
@table_result_choice_fileds += '</label>'
if @field_property["comment_text"] != ""
@table_result_choice_fileds += '<button tabindex="0" class="cancer_help_btn" data-target="#show_help_modal" style="float:left;cursor: pointer;padding: 0em 0.475em;font-size: 1.25em;border-radius: 15px;background-color: rgb(210, 106, 2);border-color: rgb(210, 106, 2);color: white;"><i aria-hidden="true" class="fa fa-question"></i></button>'
@table_result_choice_fileds += '<input class="help_texts" type="hidden" value="'+@field_property["comment_text"]+'" name='+@field_property["variable"]+'></input>'
else
@site_locales = current_site.in_use_locales
@site_locales.delete(current_locale)
@site_locales.each do |locale|
next if property["comment_text"][locale.to_s] == ""
@field_property["comment_text"] = property["comment_text"][locale.to_s]
break
end
if @field_property["comment_text"] != ""
@table_result_choice_fileds += '<button tabindex="0" class="cancer_help_btn" data-target="#show_help_modal" style="float:left;cursor: pointer;padding: 0em 0.475em;font-size: 1.25em;border-radius: 15px;background-color: rgb(210, 106, 2);border-color: rgb(210, 106, 2);color: white;"><i aria-hidden="true" class="fa fa-question"></i></button>'
@table_result_choice_fileds += '<input class="help_texts" type="hidden" value="'+@field_property["comment_text"]+'" name='+@field_property["variable"]+'/>'
else
@table_result_choice_fileds += '<div style="margin-right: 2.125em;float: left;"></div>'
end
end
if @field_property["is_num"] == 1
if @field_property["is_float"] == 1
@table_result_choice_fileds += '<div class="num_group"><input class="num_only float_num cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'"/><button class="btn-sub"></button><button class="btn-add"></button>'
else
@table_result_choice_fileds += '<div class="num_group"><form class="for_num">'
@table_result_choice_fileds += '<input class="num_only cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'" onkeyup="value=value.replace(/[^\d]/g,\'\') "onbeforepaste="clipboardData.setData(\'text\',clipboardData.getData(\'text\').replace(/[^\d]/g,\'\'))"/><button class="btn-sub"></button><button class="btn-add"></button></div>'
@table_str_left += '<input class="num_only_value" type="hidden" value="0"/>'
@please_choice = (current_locale.to_s == "zh_tw") ? "請選擇" : "Please choice"
@table_result_choice_fileds += '<select class="select_num"><option value="">'+@please_choice+'</option>'
if @field_property["choice_fields"] != []
@field_property["choice_fields"].each do |choice|
@table_result_choice_fileds += ('<option value="0">' + choice.to_s.titleize + '</option>')
end
end
for @num in @field_property["range"][0] .. @field_property["range"][1]
@table_result_choice_fileds += ('<option value="' + @num.to_s + '">' + @num.to_s + '</option>')
end
@table_result_choice_fileds += '</select></form></div>'
end
else
@table_result_choice_fileds += '<div class= "cancer-btn-group cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;">'
@field_property["choice_fields"].each do |create_choice|
@table_result_choice_fileds += '<button class="cancer_table_btn btn btn-default btn-sm">'+create_choice.titleize+'</button>'
@table_result_choice_fileds += '<input type="hidden" value="0" name="'+create_choice+'"></input>'
end
@table_result_choice_fileds += '</div>'
end
if @field_property["hint"].to_s != ""
@table_result_choice_fileds +='<div class="hint-texts">'+@field_property["hint"]+'</div>'
end
@table_result_choice_fileds += '</div><div style="clear:both;"></div>'
end
@table_result_choice_fileds += '</div></div>'
@table_str += (@table_button+'<div id="cancer_predict_result_block" style="font-size:' + @size_active_size + ';">'+@table_result_str+@table_result_choice_fileds+'</div>'+'<div style="clear:both;"></div>')
return @table_str
end
def showSubmit def showSubmit
@results = Cancerpredictrecord.where("title"=>@app_title).take_while{true} @results = Cancerpredictrecord.where("title"=>@app_title).take_while{true}
@variables = [] @variables = []
@ -243,6 +479,14 @@ class Admin::CancerpredictsController < OrbitAdminController
@form_to_show.title=@app_title @form_to_show.title=@app_title
@form_to_show.save @form_to_show.save
@form_to_show = Cancerpredictfields.where("title"=>@app_title).first @form_to_show = Cancerpredictfields.where("title"=>@app_title).first
Dir.chdir("public") do
@site_locales = Site.last.in_use_locales.each do |locale|
@file_tmp = File.new('cancer_tool_table_tmp_'+locale.to_s+'.txt', 'w')
tmp_table_texts = create_table(locale)
@file_tmp.write(tmp_table_texts)
@file_tmp.close
end
end
else else
@form_to_show = Cancerpredictfields.where("title"=>@app_title).first @form_to_show = Cancerpredictfields.where("title"=>@app_title).first
end end

View File

@ -108,7 +108,7 @@ class CancerpredictsController < ApplicationController
end end
if (params['data']['ER_status'].to_i != 2 || params['data']['PR_status'].to_i != 2) && (params['data']['HER2_status'].to_i != 1) if (params['data']['ER_status'].to_i != 2 || params['data']['PR_status'].to_i != 2) && (params['data']['HER2_status'].to_i != 1)
result['subtype'] = 1 result['subtype'] = 1
elsif params['data']['ER_status'].to_i == 2 && params['data']['PR_status'].to_i == 2 && (params['data']['HER2_status'].to_i == 1) elsif params['data']['HER2_status'].to_i == 1
result['subtype'] = 2 result['subtype'] = 2
elsif params['data']['ER_status'].to_i == 2 && params['data']['PR_status'].to_i == 2 && (params['data']['HER2_status'].to_i != 1) elsif params['data']['ER_status'].to_i == 2 && params['data']['PR_status'].to_i == 2 && (params['data']['HER2_status'].to_i != 1)
result['subtype'] = 3 result['subtype'] = 3
@ -190,7 +190,7 @@ class CancerpredictsController < ApplicationController
result['texts'] += '</span>' result['texts'] += '</span>'
end end
@lpv_calc = [-0.001476145,-0.01261639,-0.02519608] @lpv_calc = [-0.001476145,-0.01261639,-0.02519608]
@servive_ratio = ((Math.exp(@lpv_calc[-1])**(Math.exp(result['lpv'])))*100).round @servive_ratio = ((Math.exp(@lpv_calc[-1])**(Math.exp(result['lpv'])))*100).round(2)
@surgery_only_texts = @form_to_show.surgery_only_texts[locale] @surgery_only_texts = @form_to_show.surgery_only_texts[locale]
@surgery_only_texts.insert(0,'<p class="show"><span>') @surgery_only_texts.insert(0,'<p class="show"><span>')
@surgery_only_texts = @surgery_only_texts.gsub('{{Surgery_only}}','<span class="'+@therapy_names[0]+' Overall_Survival">'+@servive_ratio.round.to_s+'</span><span>') @surgery_only_texts = @surgery_only_texts.gsub('{{Surgery_only}}','<span class="'+@therapy_names[0]+' Overall_Survival">'+@servive_ratio.round.to_s+'</span><span>')
@ -211,229 +211,7 @@ class CancerpredictsController < ApplicationController
uid = OrbitHelper.params[:uid] rescue "" uid = OrbitHelper.params[:uid] rescue ""
tags = OrbitHelper.widget_tags tags = OrbitHelper.widget_tags
categories = OrbitHelper.widget_categories || [] categories = OrbitHelper.widget_categories || []
create_first_field @table_str = File.read('public/cancer_tool_table_tmp_'+I18n.locale.to_s+'.txt')
@size = {}
@size_name = ['small','medium','large']
@size_name.each{|name| @size[name] = @form_to_show[name]['font_size']}
@size_active_size = ''
@size.each{|size_key,size_value| (@form_to_show[size_key]['active'].to_i == 1) ? ( @size_active_size = size_value ): nil }
@table_str = '<div id="cancer_table" style="font-size:' + @size_active_size + ';"><div id="show_help_modal" class="modal fade"></div>'
@table_str += '<div id="cancer_table_top"><div id="text_describe">'+@form_to_show.text_descibe[I18n.locale.to_s] +'</div>'
@table_str += '<div id="font_size_choices">'+'<label id="font_texts">'+t('cancerpredict.font_size')+':</label>'
@size.each{|size_key,size_value| @table_str += ('<button class="cancer_table_btn '+((@form_to_show[size_key]['active'].to_i == 1) ? 'active' :'') + ' btn btn-default btn-sm" onclick="document.getElementById(\'cancer_table\').style[\'font-size\']=\''+size_value+'\';document.getElementById(\'cancer_predict_result_block\').style[\'font-size\']=\''+size_value+'\';">'+t('cancerpredict.'+size_key)+'</button>' )}
@table_str += '</div></div><div style="clear:both;"></div>'
@table_str_left = '<div id="cancer_table_left">'
@table_str_right = '<div id="cancer_table_right">'
@form_to_show.form_show.each do |num,property|
@field_property = {}
property.each do |key,value|
@value= value
if @value.class == BSON::Document || @value.class == Hash
@disp_value = @value[I18n.locale.to_s] rescue ""
else
@disp_value = @value
end
@field_property[key] = @disp_value
end
if @field_property['right'] == 0
@table_str_left += '<div data-key='+num.to_s+'>'
break if @field_property["name"] == ""
@table_str_left += '<label for="'+@field_property["variable"]+'" style="float:left;'+(@field_property["comment_text"] == "" ? "margin-right: 2.125em;" : "")+'" class="cencer_table_name">'
@table_str_left += @field_property["name"]
@table_str_left += '</label>'
if @field_property["comment_text"] != ""
@table_str_left += '<button tabindex="0" class="cancer_help_btn" data-target="#show_help_modal" style="float:left;cursor: pointer;padding: 0em 0.475em;font-size: 1.25em;border-radius: 15px;background-color: rgb(210, 106, 2);border-color: rgb(210, 106, 2);color: white;"><i aria-hidden="true" class="fa fa-question"></i></button>'
@table_str_left += '<input class="help_texts" type="hidden" value="'+@field_property["comment_text"]+'" name='+@field_property["variable"]+'/>'
else
@site_locales = current_site.in_use_locales
@site_locales.delete(I18n.locale)
@site_locales.each do |locale|
next if property["comment_text"][locale.to_s] == ""
@field_property["comment_text"] = property["comment_text"][locale.to_s]
break
end
if @field_property["comment_text"] != ""
@table_str_left += '<button tabindex="0" class="cancer_help_btn" data-target="#show_help_modal" style="float:left;cursor: pointer;padding: 0em 0.475em;font-size: 1.25em;border-radius: 15px;background-color: rgb(210, 106, 2);border-color: rgb(210, 106, 2);color: white;"><i aria-hidden="true" class="fa fa-question"></i></button>'
@table_str_left += '<input class="help_texts" type="hidden" value="'+@field_property["comment_text"]+'" name='+@field_property["variable"]+'/>'
else
@table_str_left += '<div style="margin-right: 2.125em;float: left;"></div>'
end
end
if @field_property["is_num"] == 1
if @field_property["is_float"] == 1
@table_str_left += '<div class="num_group"><input class="num_only float_num cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'"/></div>'
else
@table_str_left += '<div class="num_group"><form class="for_num">'
@table_str_left += '<input class="num_only cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'" onkeyup="value=value.replace(/[^\d]/g,\'\') "onbeforepaste="clipboardData.setData(\'text\',clipboardData.getData(\'text\').replace(/[^\d]/g,\'\'))"/>'
@table_str_left += '<input class="num_only_value" type="hidden" value="0"/>'
@please_choice = (I18n.locale.to_s == "zh_tw") ? "請選擇" : "Please choice"
@table_str_left += '<select class="select_num"><option value="">'+@please_choice+'</option>'
if @field_property["choice_fields"] != []
@field_property["choice_fields"].each do |choice|
@table_str_left += ('<option value="0">' + choice.to_s + '</option>')
end
end
for @num in @field_property["range"][0] .. @field_property["range"][1]
@table_str_left += ('<option value="' + @num.to_s + '">' + @num.to_s + '</option>')
end
@table_str_left += '</select></form></div>'
end
else
@table_str_left += '<div class= "cancer-btn-group cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;">'
@field_property["choice_fields"].each do |create_choice|
@table_str_left += '<button class="cancer_table_btn btn btn-default btn-sm">'+create_choice+'</button>'
@table_str_left += '<input type="hidden" value="0" name="'+create_choice+'"/>'
end
@table_str_left += '</div>'
end
if @field_property["hint"].to_s != ""
@table_str_left +='<div style="color: rgb(104, 104, 104);font-size:0.75em;clear:both;">'+@field_property["hint"]+'</div>'
end
@table_str_left += '</div><div style="clear:both;"></div>'
else
@table_str_right += '<div data-key='+num.to_s+'>'
break if @field_property["name"] == ""
@table_str_right += '<label for="'+@field_property["variable"]+'" style="float:left;'+(@field_property["comment_text"] == "" ? "margin-right: 2.125em;" : "")+'" class="cencer_table_name">'
@table_str_right += @field_property["name"]
@table_str_right += '</label>'
if @field_property["comment_text"] != ""
@table_str_right += '<button tabindex="0" class="cancer_help_btn" data-target="#show_help_modal" style="float:left;cursor: pointer;padding: 0em 0.475em;font-size: 1.25em;border-radius: 15px;background-color: rgb(210, 106, 2);border-color: rgb(210, 106, 2);color: white;"><i aria-hidden="true" class="fa fa-question"></i></button>'
@table_str_right += '<input class="help_texts" type="hidden" value="'+@field_property["comment_text"]+'" name='+@field_property["variable"]+'/>'
else
@site_locales = current_site.in_use_locales
@site_locales.delete(I18n.locale)
@site_locales.each do |locale|
next if property["comment_text"][locale.to_s] == ""
@field_property["comment_text"] = property["comment_text"][locale.to_s]
break
end
if @field_property["comment_text"] != ""
@table_str_right += '<button tabindex="0" class="cancer_help_btn" data-target="#show_help_modal" style="float:left;cursor: pointer;padding: 0em 0.475em;font-size: 1.25em;border-radius: 15px;background-color: rgb(210, 106, 2);border-color: rgb(210, 106, 2);color: white;"><i aria-hidden="true" class="fa fa-question"></i></button>'
@table_str_right += '<input class="help_texts" type="hidden" value="'+@field_property["comment_text"]+'" name='+@field_property["variable"]+'/>'
else
@table_str_right += '<div style="margin-right: 2.125em;float: left;"></div>'
end
end
if @field_property["is_num"] == 1
if @field_property["is_float"] == 1
@table_str_right += '<div class="num_group"><input class="num_only float_num cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'"/><button class="btn-sub"></button><button class="btn-add"></button></div>'
else
@table_str_right += '<div class="num_group"><form class="for_num">'
@table_str_right += '<input class="num_only cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'" onkeyup="value=value.replace(/[^\d]/g,\'\') "onbeforepaste="clipboardData.setData(\'text\',clipboardData.getData(\'text\').replace(/[^\d]/g,\'\'))"/>'
@table_str_right += '<input class="num_only_value" type="hidden" value="0"/>'
@please_choice = (I18n.locale.to_s == "zh_tw") ? "請選擇" : "Please choice"
@table_str_right += '<select class="select_num"><option value="">'+@please_choice+'</option>'
if @field_property["choice_fields"] != []
@field_property["choice_fields"].each do |choice|
@table_str_right += ('<option value="0">' + choice.to_s + '</option>')
end
end
for @num in @field_property["range"][0] .. @field_property["range"][1]
@table_str_right += ('<option value="' + @num.to_s + '">' + @num.to_s + '</option>')
end
@table_str_right += '</select></form></div>'
end
else
@table_str_right += '<div class= "cancer-btn-group cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;">'
@field_property["choice_fields"].each do |create_choice|
@table_str_right += '<button class="cancer_table_btn btn btn-default btn-sm">'+create_choice+'</button>'
@table_str_right += '<input type="hidden" value="0" name="'+create_choice+'"/>'
end
@table_str_right += '</div>'
end
if @field_property["hint"].to_s != ""
@table_str_right +='<div class="hint-texts">'+@field_property["hint"]+'</div>'
end
@table_str_right += '</div><div style="clear:both;"></div>'
end
end
@table_str_left += '</div>'
@table_str_right += '</div>'
@table_str += (@table_str_left+@table_str_right)
@table_str +='<div style="clear:both;"></div>'
@table_result_str = '<div id="cancer_predict_result" style="'+((@form_to_show.form_result_is_right == 0) ? 'float:right;' : '')+'"><span class="result_title">'+t("cancerpredict.table.result").to_s+'</span><div style="clear:both;"></div>'
@tab_name = ['table','text']
@table_result_str += '<div id="result_contents"><div class="result_tab_group">'
@tab_name.each_with_index{|name,index| @table_result_str += ('<div id="result_'+name+'_tab" class="result_tab'+((index != 0) ? "" : " active")+'"><a>'+t("cancerpredict.table."+name).to_s+'</a></div><div style="clear:both;"></div>')}
@table_result_str += '</div><div class="result_content_group">'
@tab_name.each{|name| @table_result_str += '<div id="result_'+name+'_content" class="result_content"><a>'+'no content'+'</a></div>'}
@table_result_str += '</div></div></div>'
@table_button = '<div id="cancer_table_button_group">'
@submit_btn_str='<button id="cancer_table_submit">'+t('cancerpredict.table.Submit').to_s+'</button>'
@reset_btn_str='<button id="cancer_table_reset">'+t('cancerpredict.table.Reset').to_s+'</button>'
@table_button += (@submit_btn_str+@reset_btn_str+'<div style="clear:both;"></div></div></div>')
@table_result_choice_fileds = '<div id="cancer_table_right_result">' if @form_to_show.form_result_is_right == 1
@table_result_choice_fileds = '<div id="cancer_table_left_result">' if @form_to_show.form_result_is_right == 0
@table_result_choice_fileds += '<span class="result_title">'+t('cancerpredict.table.Therapy_choice').to_s+'</span><div style="clear:both;"></div>'
@table_result_choice_fileds += '<div id="choice_fields">'
@form_to_show.form_show_in_result.each do |num,property|
@field_property = {}
property.each do |key,value|
@value= value
if @value.class == BSON::Document || @value.class == Hash
@disp_value = @value[I18n.locale.to_s] rescue ""
else
@disp_value = @value
end
@field_property[key] = @disp_value
end
@table_result_choice_fileds += '<div data-key='+num.to_s+'>'
break if @field_property["name"] == ""
@table_result_choice_fileds += '<label for="'+@field_property["variable"]+'" style="float:left;'+(@field_property["comment_text"] == "" ? "margin-right: 2.125em;" : "")+'" class="cencer_table_name">'
@table_result_choice_fileds += @field_property["name"]
@table_result_choice_fileds += '</label>'
if @field_property["comment_text"] != ""
@table_result_choice_fileds += '<button tabindex="0" class="cancer_help_btn" data-target="#show_help_modal" style="float:left;cursor: pointer;padding: 0em 0.475em;font-size: 1.25em;border-radius: 15px;background-color: rgb(210, 106, 2);border-color: rgb(210, 106, 2);color: white;"><i aria-hidden="true" class="fa fa-question"></i></button>'
@table_result_choice_fileds += '<input class="help_texts" type="hidden" value="'+@field_property["comment_text"]+'" name='+@field_property["variable"]+'></input>'
else
@site_locales = current_site.in_use_locales
@site_locales.delete(I18n.locale)
@site_locales.each do |locale|
next if property["comment_text"][locale.to_s] == ""
@field_property["comment_text"] = property["comment_text"][locale.to_s]
break
end
if @field_property["comment_text"] != ""
@table_result_choice_fileds += '<button tabindex="0" class="cancer_help_btn" data-target="#show_help_modal" style="float:left;cursor: pointer;padding: 0em 0.475em;font-size: 1.25em;border-radius: 15px;background-color: rgb(210, 106, 2);border-color: rgb(210, 106, 2);color: white;"><i aria-hidden="true" class="fa fa-question"></i></button>'
@table_result_choice_fileds += '<input class="help_texts" type="hidden" value="'+@field_property["comment_text"]+'" name='+@field_property["variable"]+'/>'
else
@table_result_choice_fileds += '<div style="margin-right: 2.125em;float: left;"></div>'
end
end
if @field_property["is_num"] == 1
if @field_property["is_float"] == 1
@table_result_choice_fileds += '<div class="num_group"><input class="num_only float_num cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'"/><button class="btn-sub"></button><button class="btn-add"></button>'
else
@table_result_choice_fileds += '<div class="num_group"><form class="for_num">'
@table_result_choice_fileds += '<input class="num_only cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'" onkeyup="value=value.replace(/[^\d]/g,\'\') "onbeforepaste="clipboardData.setData(\'text\',clipboardData.getData(\'text\').replace(/[^\d]/g,\'\'))"/><button class="btn-sub"></button><button class="btn-add"></button></div>'
@table_str_left += '<input class="num_only_value" type="hidden" value="0"/>'
@please_choice = (I18n.locale.to_s == "zh_tw") ? "請選擇" : "Please choice"
@table_result_choice_fileds += '<select class="select_num"><option value="">'+@please_choice+'</option>'
if @field_property["choice_fields"] != []
@field_property["choice_fields"].each do |choice|
@table_result_choice_fileds += ('<option value="0">' + choice.to_s + '</option>')
end
end
for @num in @field_property["range"][0] .. @field_property["range"][1]
@table_result_choice_fileds += ('<option value="' + @num.to_s + '">' + @num.to_s + '</option>')
end
@table_result_choice_fileds += '</select></form></div>'
end
else
@table_result_choice_fileds += '<div class= "cancer-btn-group cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;">'
@field_property["choice_fields"].each do |create_choice|
@table_result_choice_fileds += '<button class="cancer_table_btn btn btn-default btn-sm">'+create_choice+'</button>'
@table_result_choice_fileds += '<input type="hidden" value="0" name="'+create_choice+'"></input>'
end
@table_result_choice_fileds += '</div>'
end
if @field_property["hint"].to_s != ""
@table_result_choice_fileds +='<div class="hint-texts">'+@field_property["hint"]+'</div>'
end
@table_result_choice_fileds += '</div><div style="clear:both;"></div>'
end
@table_result_choice_fileds += '</div></div>'
@table_str += (@table_button+'<div id="cancer_predict_result_block" style="font-size:' + @size_active_size + ';">'+@table_result_str+@table_result_choice_fileds+'</div>'+'<div style="clear:both;"></div>')
{ {
"cancerpredict" => [], "cancerpredict" => [],
"extras"=>{"table"=> @table_str} "extras"=>{"table"=> @table_str}

View File

@ -26,7 +26,7 @@ class Cancerpredictfields
3=>{:variable=>"Targeted_therapy",:name=>{"zh_tw"=>"標靶治療","en"=>"Targeted therapy"},:is_num=>0,:hint=>{'zh_tw'=>'抗HER2治療','en'=>''}, :comment_text=>{'zh_tw'=>'','en'=>''}, :choice_fields=> {"zh_tw"=>['否','是'],"en"=>['No','Yes']},:range=>[]} 3=>{:variable=>"Targeted_therapy",:name=>{"zh_tw"=>"標靶治療","en"=>"Targeted therapy"},:is_num=>0,:hint=>{'zh_tw'=>'抗HER2治療','en'=>''}, :comment_text=>{'zh_tw'=>'','en'=>''}, :choice_fields=> {"zh_tw"=>['否','是'],"en"=>['No','Yes']},:range=>[]}
} }
field :form_result_is_right , :type=> Integer ,default: 0 field :form_result_is_right , :type=> Integer ,default: 0
field :text_descibe ,type:Hash ,default:{"zh_tw"=>"歡迎使用台灣準備乳癌預後系統!<br/>本預測系統由台灣癌症登記資料庫2011至2015年間共90,841位乳癌病人所建立 <br/>若要開始 請在下方輸入相關資訊","en"=>"Welcome to the Taiwan Breast Cancer Prediction System!<br/>The prediction system is constructed using 90,841 breast cancer patients clinical data from the Taiwan Cancer Registry database between 2011 and 2015, and validated by using 49,374 breast cancer patients clinical data from the US-based Surveillance, Epidemiology, and End Results (SEER) database.<br/>To start, please enter the information below."} field :text_descibe ,type:Hash ,default:{"zh_tw"=>"歡迎使用台灣準備乳癌預後系統!<br/>本預測系統由台灣癌症登記資料庫2011至2015年間共90,841位乳癌病人所建立 <br/>若要開始 請在下方輸入相關資訊","en"=>"Welcome to the Taiwan Breast Cancer Prediction System!<br/>The prediction system is constructed using clinical data from 90,841 breast cancer patients in the Taiwan Cancer Registry database between 2011 to 2015, and validated using clinical data from 49,374 breast cancer patients in the U.S.-based Surveillance, Epidemiology and End Results (SEER) database. <br/>To start, please select the information below."}
field :small ,type:Hash ,default:{'font_size'=>"0.825em",'active'=>0} field :small ,type:Hash ,default:{'font_size'=>"0.825em",'active'=>0}
field :medium ,type:Hash ,default:{'font_size'=>"1em",'active'=>1} field :medium ,type:Hash ,default:{'font_size'=>"1em",'active'=>1}
field :large ,type:Hash ,default:{'font_size'=>"1.25em",'active'=>0} field :large ,type:Hash ,default:{'font_size'=>"1.25em",'active'=>0}
@ -34,12 +34,13 @@ class Cancerpredictfields
field :title_images_id ,type:Array , default: [BSON::ObjectId('5df87cd88cd8924491000036')] field :title_images_id ,type:Array , default: [BSON::ObjectId('5df87cd88cd8924491000036')]
field :title_texts ,type:Hash ,default:{'zh_tw'=>'華人癌症存活預測','en'=>'Asian breast cancer prediction'} field :title_texts ,type:Hash ,default:{'zh_tw'=>'華人癌症存活預測','en'=>'Asian breast cancer prediction'}
field :table_above_texts ,type:Hash ,default:{'zh_tw'=>"下表之分析為針對手術後病人根據選定的術後治療分別估計在第1年、3及5年的存活率。",'en'=>'The analysis is for women who had undergone surgery.The table shows the 1-, 3- and 5-year survival rates,based on the treatment you have selected.'} field :table_above_texts ,type:Hash ,default:{'zh_tw'=>"下表之分析為針對手術後病人根據選定的術後治療分別估計在第1年、3及5年的存活率。",'en'=>'The analysis is for women who had undergone surgery.The table shows the 1-, 3- and 5-year survival rates,based on the treatment you have selected.'}
field :text_above_texts ,type:Hash ,default:{'zh_tw'=>"此研究分析來自已接受根除性手術後之婦女所得之結果,根據您所輸入的資訊以及治療方式,在術後第{{years}}年,",'en'=>'The analysis is for women who had undergone surgery. Base on the information and the treatment you have selected, the predictions of survival status{{years}}'} field :text_above_texts ,type:Hash ,default:{'zh_tw'=>"此研究分析來自已接受根除性手術後之婦女所得之結果,根據您所輸入的資訊以及治療方式,在術後<br/>第{{years}}年,",'en'=>'The analysis is for women who had undergone surgery. Base on the information and the treatment you have selected, the predictions of survival status<br/>{{years}}'}
field :surgery_only_texts ,type:Hash ,default:{'zh_tw'=>'100 位只接受根除性手術的婦女中,有{{Surgery_only}}位婦女,術後{{surgery_year}}年仍為存活','en'=>'after surgery are as follows:<br/>{{Surgery_only}} out of 100 women treated with surgery only are alive at {{surgery_year}} years.'} field :surgery_only_texts ,type:Hash ,default:{'zh_tw'=>'100 位只接受根除性手術的婦女中,有{{Surgery_only}}位婦女,術後{{surgery_year}}年仍為存活','en'=>'after surgery are as follows:<br/>{{Surgery_only}} out of 100 women treated with surgery only are alive at {{surgery_year}} years.'}
field :extra_texts ,type:Hash ,default:{'zh_tw'=>',此外','en'=>''} field :extra_texts ,type:Hash ,default:{'zh_tw'=>',此外','en'=>''}
field :extra_therapy_texts ,type:Hash ,default:{'zh_tw'=>'100 位在術後有接受{{extra_therapy}}的婦女中,有{{survival_num}}位婦女,術後{{surgery_year}}年仍為存活(多了{{Additional_Benefit}}位)','en'=>'{{survival_num}} out of 100 women treated with {{extra_therapy}} are alive (an extra {{Additional_Benefit}})'} field :extra_therapy_texts ,type:Hash ,default:{'zh_tw'=>'100 位在術後有接受{{extra_therapy}}的婦女中,有{{survival_num}}位婦女,術後{{surgery_year}}年仍為存活(多了{{Additional_Benefit}}位)','en'=>'{{survival_num}} out of 100 women treated with {{extra_therapy}} are alive (an extra {{Additional_Benefit}})'}
field :danger_texts ,type:Hash ,default:{'zh_tw'=>'請注意紅框的輸入資料是否符合要求!','en'=>'Please check whether input data in red blocks are correct!'} field :danger_texts ,type:Hash ,default:{'zh_tw'=>'請注意紅框的輸入資料是否符合要求!','en'=>'Please check whether input data in red blocks are correct!'}
field :years ,type:Array ,default:[1,3,5] field :years ,type:Array ,default:[1,3,5]
field :texts_between_Result_and_result_block ,type:Hash ,default:{'zh_tw'=>'如果欲將預測結果應用於臨床上,請務必與您的主治醫師討論後再做最後決定。','en'=>'Please note that the patients need to consult with their medical doctors before making any decision.'}
#field :image_uploader ,type:Object #field :image_uploader ,type:Object
scope :can_display, ->{where(:is_hidden=>false,:is_preview => false).any_of({:postdate.lt=>Time.now, :deadline.gt=>Time.now},{:postdate.lt=>Time.now, :deadline=>nil}).order_by([:is_top, :desc],[:postdate, :desc])} scope :can_display, ->{where(:is_hidden=>false,:is_preview => false).any_of({:postdate.lt=>Time.now, :deadline.gt=>Time.now},{:postdate.lt=>Time.now, :deadline=>nil}).order_by([:is_top, :desc],[:postdate, :desc])}
scope :is_approved, ->{where(:approved => true)} scope :is_approved, ->{where(:approved => true)}

View File

@ -205,7 +205,7 @@
<div><%= form.check_box "form_result_is_right",{:checked=>false,:class=>"checkbox",:style=>"float: left;position: relative;left: 0;transform: none!important;margin-left: 1em;",:id=>"form_result_is_right"}%></div> <div><%= form.check_box "form_result_is_right",{:checked=>false,:class=>"checkbox",:style=>"float: left;position: relative;left: 0;transform: none!important;margin-left: 1em;",:id=>"form_result_is_right"}%></div>
<%end%> <%end%>
<div style="clear:both;"></div> <div style="clear:both;"></div>
<% @create_items = ['years','table_above_texts','text_above_texts','surgery_only_texts','extra_texts','extra_therapy_texts','danger_texts'] %> <% @create_items = ['years','table_above_texts','text_above_texts','surgery_only_texts','extra_texts','extra_therapy_texts','danger_texts','texts_between_Result_and_result_block'] %>
<% @create_items.each do |item|%> <% @create_items.each do |item|%>
<label for="<%=item%>" style="float: left;margin-right:1em;"><%= t('cancerpredict.'+item)+':' %></label> <label for="<%=item%>" style="float: left;margin-right:1em;"><%= t('cancerpredict.'+item)+':' %></label>
<% if @form_to_show[item].class == BSON::Document || @form_to_show[item].class == Hash %> <% if @form_to_show[item].class == BSON::Document || @form_to_show[item].class == Hash %>

View File

@ -2,6 +2,7 @@
<thead> <thead>
<tr> <tr>
<% if !@results[0].nil? %> <% if !@results[0].nil? %>
<th><%=((I18n.locale=="en") ? 'submit time' : '提交時間') %></th>
<% @results[0].names.each do |key,name|%> <% @results[0].names.each do |key,name|%>
<th><%=name[I18n.locale.to_s].to_s.html_safe %></th> <th><%=name[I18n.locale.to_s].to_s.html_safe %></th>
<%end%> <%end%>
@ -17,6 +18,7 @@
<table> <table>
<thead> <thead>
<tr> <tr>
<th><%=((I18n.locale=="en") ? 'submit time' : '提交時間') %></th>
<% result.names.each do |key,name|%> <% result.names.each do |key,name|%>
<th><%=name[I18n.locale.to_s].to_s.html_safe %></th> <th><%=name[I18n.locale.to_s].to_s.html_safe %></th>
<%end%> <%end%>
@ -25,6 +27,7 @@
<tbody> <tbody>
<% end %> <% end %>
<tr> <tr>
<td><%= result.created_at %></td>
<% result.result.each do |key,value| %> <% result.result.each do |key,value| %>
<% @key_len %> <% @key_len %>
<% if key != "locale" %> <% if key != "locale" %>

View File

@ -22,6 +22,7 @@ en:
extra_texts: Extra texts extra_texts: Extra texts
extra_therapy_texts: Extra therapy texts extra_therapy_texts: Extra therapy texts
danger_texts: Warning texts danger_texts: Warning texts
texts_between_Result_and_result_block: Texts between "Result" and "Result block"
table: table:
welcome: Welcome to The after breast cancer healing system of Taiwanprepare!\nTo start, please enter the relevant information below. welcome: Welcome to The after breast cancer healing system of Taiwanprepare!\nTo start, please enter the relevant information below.
Reset: Reset Reset: Reset

View File

@ -22,6 +22,7 @@ zh_tw:
extra_texts: 額外文字 extra_texts: 額外文字
extra_therapy_texts: 額外治療的文字 extra_therapy_texts: 額外治療的文字
danger_texts: 警告文字 danger_texts: 警告文字
texts_between_Result_and_result_block: 在"結果"和"結果區塊"之間的文字
table: table:
welcome: 歡迎使用台灣準備乳癌癒後系統!\n若要開始 請在下方輸入相關資訊 welcome: 歡迎使用台灣準備乳癌癒後系統!\n若要開始 請在下方輸入相關資訊
Reset: 重置 Reset: 重置